Dears,
I'm trying to get the settlement amount for projects invoices. I'm getting only one settled amount but not all invoices settled amount. I create a static method to find settlement amount with SalesId as input parameter in ProjInvoiceItem table so I can use it from anywhere. Please find below code.
//ProjInvoiceItem table public display AmountCur amountSettled() { CustTrans custTrans; ProjInvoiceItem projInvoiceItem; ProjInvoiceJour projInvoiceJour; AmountCur amntCur; SalesTable salesTable; while select sum(SettleAmountCur) from custTrans where custTrans.Invoice == this.ProjInvoiceId { amntCur = custTrans.SettleAmountCur; } return amntCur; } /* while select firstOnly projInvoiceItem join projInvoiceJour where projInvoiceItem.ProjInvoiceId == projInvoiceJour.ProjInvoiceId && projInvoiceJour.InvoiceDate == this.InvoiceDate { amntCur = projInvoiceJour.amountSettled(); } return amntCur; }*/ //ProjInvoiceItem table public static ProjInvoiceItem findFromSalesId(SalesId _salesID) { ProjInvoiceItem projInvoiceItem; if(_salesID) { select firstOnly projInvoiceItem index hint InvoiceIdx where projInvoiceItem.SalesId == _salesID; } return projInvoiceItem; } //test job static void stlledAmount(Args _args) { info(strFmt("Amount %1", ProjInvoiceItem::findFromSalesId("SO008350").amountSettled())); }//I need to see all invoices settled amount which belongs the specific SO.