Loading...

How to Calculate purchase order total value using X++ in Dynamics 365 FO?

How to Calculate purchase order total value using X++ in Dynamics 365 FO?
In the previous article  “Field Fixed Relation in D365 with Example “, you learned what is a Field Fixed relation and how to make a Field Fixed table relation in Dynamics 365 fo. Additionally, you learned an example associated with field fixed relations. In this article, you can learn, what is a POwhat is purchase order total value and How to Calculate the purchase order total value in D365 using X++ code.

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.

How to Calculate purchase order total value in Dynamics 365 FO?

     2. Under purchase orders > Click on All purchase order menu.

How to Calculate purchase order total value in Dynamics 365 FO?

3. You can see all the purchase orders created previously, select one purchase order.

How to Calculate purchase order total value in Dynamics 365 FO?

You can see the Total under the Purchase Order tab on the action bar.

How to Calculate purchase order total value in Dynamics 365 FO?

4. Click the menu Total, and a dialog box shows totals for the whole order.

How to Calculate purchase order total value in Dynamics 365 FO?

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));
   }
 
}
How to Calculate purchase order total value using X++ in Dynamics 365 FO?

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,

How to Calculate purchase order total value using X++ in Dynamics 365 FO?

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 more
D365 Snippets
D365 Snippets

Share post:

Related posts

Interview Questions and Answers Dynamics 365 CE and Power Platform – Ultimate Guide

In today's business landscape, Dynamics 365 Customer Engagement (CE) and the Power Platform have emerged as game-changing tools that have tran...

16 days ago

Back to Basics # 72: Limit Special Characters Using a Webresource in Dynamics CRM

Recently we got a requirement to restrict user to enter special characters. Step 1 : Use the below method for restricting special characters S...

24 days ago

Create a data maintenance strategy for Dynamics 365 finance and operations data (part two)

Welcome to part two of our series on creating a data maintenance strategy for Dynamics 365 finance and operations data. In this installment, w...

1 month ago

Create a data maintenance strategy for Dynamics 365 finance and operations data (part one)

In this two-part series, you'll learn how to create an effective data maintenance strategy for your Dynamics 365 finance and operations data. ...

1 month ago

20 Most commonly used JavaScript Scenarios with Sample code Snippet in Form Script Dataverse/ Dynamics 365 CE

JavaScript is a powerful tool for developers working with Dataverse (formerly known as Common Data Service) and Dynamics 365 Customer Engageme...

1 month ago

New and Retired Microsoft Dynamics 365 Certifications

Microsoft has recently shared updates regarding new and retired certifications for Microsoft Dynamics 365. This post provides an overview of t...

1 month ago
Stay up to date with latest Microsoft Dynamics 365 and Power Platform news!
* Yes, I agree to the privacy policy