Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Calculate the amount while firming the Planned purchase orders

(0) ShareShare
ReportReport
Posted on by 145

Hi Everyone,

I need to know how to calculate the amount when we do the firming of the planned purchase orders which creates the Purchase orders.

My requirement is, I need to add a new field "Total Amount"in the Fact box of the Planned Purchase order similar to the Purchase orders, so need to know how Ax calculates the amount when we do the firming of the Planned PO to PO.

Best Regards 

Pranav

*This post is locked for comments

  • Verified answer
    Pranav Gupta Profile Picture
    Pranav Gupta 145 on at
    RE: Calculate the amount while firming the Planned purchase orders

    Hi,

    I have figure out the solution, below is the code:

    PurchAgreementHeader                agreementHeader;

           AgreementLine                       agreementLine;

           AgreementLineQuantityCommitment     qtyCommitment;

           PurchQty                            purchAmt;

           PurchQty                            totalPurchAmt;

           PurchQty                            discountAmt;

           PurchQty                            qtyFromPlannedPO = 50;  // Quantity taken from Planned Purchase order 

           Price                               retPrice;

           if (ReqParameters::find().ReqPOSearchPurchAgreement) // For Purch Agreement

           {

               select firstonly qtyCommitment

                   join agreementHeader

                       where qtyCommitment.Agreement       == agreementHeader.RecId    &&

                             qtyCommitment.ItemId          == '1000'                   &&

                             agreementHeader.VendAccount   == '1001';

               if (qtyCommitment.PricePerUnit <= qtyFromPlannedPO)

               {

                   if (!qtyCommitment.LineDiscountPercent)

                   {

                       purchAmt = (qtyCommitment.PricePerUnit * qtyFromPlannedPO);

                   }

                   else if (qtyCommitment.LineDiscountPercent)

                   {

                       purchAmt        = (qtyCommitment.PricePerUnit * qtyFromPlannedPO);

                       discountAmt     = (purchAmt/ qtyCommitment.LineDiscountPercent) * 100;

                       retPrice        = purchAmt - discountAmt;

                   }

               }

           }

           else if (!ReqParameters::find().ReqPOSearchPurchAgreement || !qtyCommitment) // For Trade Agreement and Item Unit Price

           {

               PriceDisc               priceDisc;

               InventTable inventTable = InventTable::find('1000');

               VendTable vendTable = VendTable::find('1001');

               //InventDim               inventDimItem       = inventTable.inventItemInventSetup().inventDim();

               InventDim inventDimItem = InventDim::find('000031');

               UnitOfMeasureSymbol     unitId              = inventTable.inventTableModuleInvent().UnitId;

               PriceDiscParameters parameters = PriceDiscParameters::construct();

               parameters.parmModuleType(ModuleInventPurchSales::Purch);

               parameters.parmItemId(inventTable.ItemId);

               parameters.parmInventDim(inventDimItem);

               parameters.parmUnitID( unitId);

               parameters.parmPriceDiscDate(systemDateGet());

               parameters.parmQty(qtyFromPlannedPO);

               parameters.parmAccountNum(vendTable.AccountNum);

               parameters.parmCurrencyCode(vendTable.Currency);

               priceDisc = PriceDisc::newFromPriceDiscParameters(parameters);

               if (priceDisc.findPrice(vendTable.PriceGroup)) // For TRADE AGREEMENT

               {

                   retPrice = priceDisc.price();

               }

               else if (priceDisc.findItemPrice()) // For ITEM Price

               {

                   retPrice = priceDisc.price();

               }

               // return retPrice;

               Info(strFmt("Unit price: %1", retPrice));

           }

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 Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans