+1

Create payables from receivables macro

Ádám Csillag 1 week ago 0

Hi,

I'm trying to create a macro that creates a payable for every receivable in the project. The problem is that $tmSavingsFactory.createTMSavings() is always returning null. Is this the right approach? Thanks in advance.


#set($service = $utils.getService("com.radzisz.xtrf.service.ActivityService"))
#set($service2 = $utils.getService("com.radzisz.xtrf.service.TMSavingsService"))
#set($catTool = $service2.getAvailableCatTools()[0].catTool)
#set($tmSavingsFactory = $utils.createInstance("com.radzisz.xtrf.service.chargeTmSavings.TmSavingsForChargeFactory"))

#foreach( $project in $utils.unwrap(${list}) )
    #foreach($task in $project.tasks)
        #set($tf = $task.projectFinance)
        #foreach($r in $tf.catReceivables)
            #foreach($activity in $task.activities)
                #set($rates = $activity.providerPriceProfile.getTmRates($catTool))
                #set($tmSavings = $r.TmSavings)
                #set($tmSavingPayable = $tmSavingsFactory.createTMSavings($tmSavings, $rates))
                #set($payable = $service.createActivityCatPayable($activity))
                $payable.updateTmSavings($tmSavingPayable)
                $activity.addCATPayable($payable)
            #end
        #end
    #end
#end