web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Vendor Settlement

(0) ShareShare
ReportReport
Posted on by 1,450

Hello everyone!

I need to get all vendor invoiced transactions and all vendor honored transactions related to each transaction.

I can't find any good relation between this type of transactions (invoiced to honored). My aim is get the invoiced date and the settlement date to get how many days have passed.

I attach my code and thank you in advance.

static void JRA_VendSettlements(Args _args)
{
    TmpDueDateCompliance_ES_INL TmpDueDateCompliance_ES_INL;
    VendSettlement              VendSettlement;
    VendInvoiceJour             VendInvoiceJour;
    VendInvoiceTrans            VendInvoiceTrans;
    VendTrans                   VendTrans, offsetVendTrans;
    str                         text;
    boolean                     isFreshDelivery;

    void findSettlement(VendTrans _vendtrans, vendSettlement _vendSettlement)
    {
        VendSettlement vendSettlementNew;

        if (!_vendtrans || !_vendSettlement) return;

        select firstonly offsetVendTrans
            order by recid desc
            where offsetVendTrans.Voucher       == _vendSettlement.OffsetTransVoucher
               && offsetVendTrans.AccountNum    == _vendSettlement.AccountNum
               && offsetVendTrans.RecId         != _vendtrans.RecId;

        if (offsetVendTrans.PromissoryNoteStatus != CustVendNegInstStatus::Honored)
        {
            select firstOnly vendSettlementNew
                where   vendSettlementNew.TransRecId    == offsetVendTrans.RecId;
                    /*&&  vendSettlementNew.TransDate     == offsetVendTrans.TransDate
                    &&  vendSettlementNew.TransCompany  == offsetVendTrans.dataAreaId;*/
            findsettlement(offsetVendTrans, vendSettlementNew);
        }
    }

    ttsBegin;

    while select VendSettlement
        where VendSettlement.AccountNum == '1002'
            join    VendTrans
            where   VendTrans.RecId                 == VendSettlement.TransRecId
                &&  VendTrans.PromissoryNoteStatus  == CustVendNegInstStatus::Invoiced
    {
        //VendTrans       = VendTrans::find(VendSettlement.TransRecId);
        offsetVendTrans.clear();
        VendInvoiceJour = VendInvoiceJour::findFromVendTrans(VendTrans.Invoice, VendTrans.TransDate, VendTrans.AccountNum);

        findSettlement(VendTrans, VendSettlement);

        isFreshDelivery = PurchTable::find(VendInvoiceJour.PurchId).FreshDelivery;

        TmpDueDateCompliance_ES_INL.clear();
        TmpDueDateCompliance_ES_INL.AccountNum          = VendSettlement.AccountNum;
        TmpDueDateCompliance_ES_INL.AmountMST           = VendSettlement.SettleAmountMST;
        TmpDueDateCompliance_ES_INL.LedgerVoucher       = VendTrans.Voucher;
        TmpDueDateCompliance_ES_INL.OffsetTransVoucher  = VendSettlement.OffsetTransVoucher;
        TmpDueDateCompliance_ES_INL.DueDate             = VendSettlement.DueDate;
        TmpDueDateCompliance_ES_INL.InvoiceDate         = VendTrans.TransDate;
        TmpDueDateCompliance_ES_INL.InvoiceId           = VendTrans.Invoice;
        TmpDueDateCompliance_ES_INL.PaymDate            = offsetVendTrans.TransDate;
        TmpDueDateCompliance_ES_INL.SettlementVoucher   = offsetVendTrans.Voucher;
        TmpDueDateCompliance_ES_INL.AmountMSTSettle     = offsetVendTrans.AmountMST;
        TmpDueDateCompliance_ES_INL.Status              = offsetVendTrans.PromissoryNoteStatus;
        TmpDueDateCompliance_ES_INL.DaysReal            = TmpDueDateCompliance_ES_INL.PaymDate  - TmpDueDateCompliance_ES_INL.InvoiceDate;
        TmpDueDateCompliance_ES_INL.DaysTheory          = isFreshDelivery ? 30 : 60;
        TmpDueDateCompliance_ES_INL.DaysDifference      = TmpDueDateCompliance_ES_INL.DaysReal  - TmpDueDateCompliance_ES_INL.DaysTheory;

        
        if (TmpDueDateCompliance_ES_INL.Status == CustVendNegInstStatus::Invoiced || TmpDueDateCompliance_ES_INL.Status == CustVendNegInstStatus::Honored)
            TmpDueDateCompliance_ES_INL.insert();
    }

    ttsCommit;

}


*This post is locked for comments

  • Suggested answer
    Ludwig Reinhard Profile Picture
    Microsoft Employee on at

    Hello Jesus,

    Probably have a look at the VendStatistics form and related methods that already does a similar calculation for a single vendor. I believe that you can take out the one or the other peace from there for your purpose.

    Best regards,

    Ludwig

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Prashant Singh Profile Picture

Prashant Singh 2

#1
nmaenpaa Profile Picture

nmaenpaa 2 Moderator

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans