Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Unanswered

How to get project Settelment Amount for Each ProjectInvoiced

Posted on by 1,869

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. 


Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans