adsenseheader

Monday, November 4, 2019

Get Accounting distribution for Purchase order line in AX for D365 for operations

Hi Guys,

The below code shall help you in pulling Account Distribution allocation factors between the Customer for a PurchaseOrder line.

while select forupdate RecId from sourceDocLine
                where
                    sourceDocLine.SourceDocumentHeader == purchTable.SourceDocumentHeader
            join forupdate accDist
                where
                    accDist.SourceDocumentLine == sourceDocLine.RecId &&
                    accDist.ReferenceRole != AccountingDistributionReferenceRole::Reversing
            notexists join revAccDist
                where
                    (   revAccDist.ReferenceDistribution == accDist.RecId &&
                        revAccDist.SourceDocumentLine == sourceDocLine.RecId &&
                        revAccDist.ReferenceRole == AccountingDistributionReferenceRole::Reversing
                    )
                    ||
                    (
                        revAccDist.ReferenceDistribution == accDist.RecId &&
                        revAccDist.SourceDocumentLine == sourceDocLine.RecId &&
                        revAccDist.ReferenceRole == AccountingDistributionReferenceRole::Adjusting
                    )
        {
            if (accDist.AllocationFactor == 1.0)
            {
                continue;
            }

            allocationFactor += accDist.AllocationFactor;

            // Write the your business logic her based on the allocation factor
Note: the First loop would always result with allocation factor 1

            if (allocationFactor == 1.0)
            {
                break ;
            }


Hope this help you

Thanks,
Pradeep

No comments:

Post a Comment