web
You’re offline. This is a read only version of the page.
close
Skip to main content
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

I have the same question (0)
  • Suggested answer
    Ludwig Reinhard Profile Picture
    Microsoft Employee on at
    RE: Vendor Settlement

    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#2
Alexey Lekanov Profile Picture

Alexey Lekanov 3

#3
Scott_itD Profile Picture

Scott_itD 2 Community Manager

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans