How to Calculate purchase order total value using X++ in Dynamics 365 FO?
What is a Purchase Order?
A Purchase Order is a document that represents a request to a vendor to supply goods or services at a specific price and delivery date. The purchase order includes details such as the quantity, unit price, and delivery date of the items or services requested, as well as the vendor's information and the buyer's information.
A purchase order is typically created in the procurement and sourcing module in Dynamics 365 Finance and Operations, and it can be generated automatically from a requisition or manually entered by a user. Once the purchase order is approved and sent to the vendor, it serves as a legally binding agreement between the buyer and the seller.
The purchase order also serves as a basis for tracking the status of the order and receiving the items or services in the receiving and warehousing module. It can also be used for invoice matching and for tracking vendor performance metrics.
Why this article?
It is often difficult to calculate the totals of PO using X++ in D365FO. The form of totals in the Purchase order shows different totals of PO, but it is difficult for developers to get them using X++ code. For this purpose, I am writing this article to give you the code to calculate the totals of PO using X++.
What is Purchase Order Total?
In Dynamics 365 Finance and Operations, the Purchase Order Total refers to the total cost of the items or services requested in a purchase order. This includes the price of the items or services, any applicable taxes or fees, and any additional charges such as shipping or handling fees.
The Purchase Order Total is calculated automatically in Dynamics 365 Finance and Operations based on the details entered in the purchase order. It can be viewed on the purchase order form and can also be used in various financial and accounting processes, such as budgeting, cost accounting, and financial reporting.
Having an accurate Purchase Order Total is important for effective budget management and financial control, as it enables buyers to track and manage their purchasing activities more effectively and provides greater transparency into the costs associated with their procurement processes.
In Dynamics 365 FO, you can review the totals of PO using the following steps:
1. Under Module > Click on Procurement and Sourcing Module.2. Under purchase orders > Click on All purchase order menu.
3. You can see all the purchase orders created previously, select one purchase order.
You can see the Total under the Purchase Order tab on the action bar.
4. Click the menu Total, and a dialog box shows totals for the whole order.
Calculate the purchase order total value using X++
For this,
1. Create a runnable class (job) named as CalculatePurchaseOrderTotals.
2. Copy the below code and paste it into the newly created class.
internal final class CalculatePurchaseOrderTotals { public static void main(Args _args) { //Calculate totals per Purchase order PurchTotals purchTotals; PurchTable purchTable = PurchTable::find('00000041'); //Change the Purchase Order Id as per your system's data AmountCur totalAmount; purchTotals = PurchTotals::newPurchTable(purchTable); purchTotals.calc(); totalAmount = purchTotals.purchTotalAmount(); info(strFmt("Purchase order: %1 - Total value: %2", purchTable.PurchId, totalAmount)); } }
3. Change the Purchase order id according to your system’s purchase order data. Here we selected 00000041 as the purchase order id.
4. Successfully build and run the job.
5. You can see the purchase order total value in the info log as shown below,
If this article is useful to you, please try to share it with your friends, if you have any doubts about this article please comment in the comment box.
Published on:
Learn moreRelated posts
Exploring the Differences: Managed vs. Unmanaged Solutions in Dynamics CRM/Dataverse
In Dynamics CRM/Dataverse, solutions are central to Application Lifecycle Management (ALM), providing a structured way to manage, package, and...
Effective Strategies for Debugging Plugins in Dynamics CRM
In a recent interview, I was asked about debugging plugins in Dynamics CRM. The interviewer specifically wanted to know my approach to plugin ...
Practical Hints for Technical Management of D365FO Go-Live
In this post, I share practical insights from my experience managing the technical side of Go-Live for D365FO projects, focusing on key activi...
D365FO Integration: Event-Based Exports to External Web Services
How to implement robust, efficient integrations between Dynamics 365 Finance and Operations and external Web Services. This post covers design...
Physical cost inclusion for Weighted Average Valuation in Microsoft Dynamics 365 Finance and Operations: Part-13
What is physical cost in Dynamics 365 F&O? Anything which has been received or shipped but not invoiced is considered as physical cost for...
Product bundles in Microsoft Dynamics 365 Finance and Operations
Product bundle was first introduced in module revenue recognition but as we all know the there is new modules which has been introduced and wi...
Is Microsoft Dynamics CRM Affordable for Small Nonprofits?
Satish Reddy By Satish Reddy | Reading time 6 mins When considering a CRM solution, affordability is often a primary concern for small no...
How Microsoft Dynamics CRM Services Helps a Startup Nonprofit
Satish Reddy By Satish Reddy | Reading time 6 mins For startup nonprofits, the right Customer Relationship Management (CRM) system can be...