Welcome to our blog.

At one point or another, Microsoft AX developers will come across the need to work with requirements to proportionally allocate total amounts in X++ code by quantity, weight, percentage, and/or other criteria.

There are a variety of methods to accomplish these goals already embedded in the system, but not all of them yield the same results. Each calculated amount should be rounded to two decimal points and allocation should be done with minimum difference.

In the following article, we will consider the four most commonly used allocation methods. These methods are not dependent upon AX version or selection of ERP systems, so this article may be helpful for all ERP developers.


Simple proportion and proportion with a difference settlement

Please refer to the example in the table below of an allocation of $100 for 7 separate transactions with quantity = 1 for each transaction.

The first method, called as “Simple proportion”, is based upon the formula:

Amount[i] = AmountTotal * Qty[i] / QtyTotal

After rounding, we will have $100.03 as the result, i.e. there will be the difference of $0.03 between the initial allocated amount and the final allocated amount. The discrepancy in values is unacceptable in most cases.


Methods 2 and 3 are also based upon the same formula, but the total amount is settled to one specific line those being: the last line in Method 2 and to the line with the greatest amount in the Method 3. After using Methods 2 or 3, the total allocated amount is consolidated; unfortunately, the differences between lines with the same quantity can still reach $0.03, which is 3 times more compared to direct rounding ($0.01). These methods work in a number of scenarios, but in other cases we may need a more accurate algorithm.

Side note: Method 2 is more frequently used in standard AX code, i.e. LedgerAllocationProcessRequest.createVoucherOffsets() method:


Remains allocation

Method 4, the last method, is detailed in the table below. This is the method that will yield the most accurate algorithm.

The fundamental principal of Method 4 involves calculating ‘open’ amounts based upon allocation of amount and quantity.

Each time the amount for the line is calculated, deduct the “Qty to allocate” and the “Amount to allocate.” Then, use the newly calculated ‘open’ values for following calculations instead of using the initial values as seen in previous Methods (1-3).

The formula used in Method 4 is:

Amount[i] = AmountRemaining * Qty[i] / QtyRemaining

Instead of:

Amount[i] = AmountTotal * Qty[i] / QtyTotal


This approach is also frequently used in the standard code. This is often seen in inventory or in the AR/AP settlement processes.

Good luck with allocation!


Request for quotations, or RFQ are a great feature within Dynamics AX 2012 because they allow you to create a quotation for items or services that you want to purchase, to receive and compare several vendors offers based on defined data criteria such as delivery times, prices, purchase charges, quantities.

Lab scenario:

In this lab, we would like to access a quotation in order to reply it with the vendors’ bids.

Let’s start…

Create a reply to a request for quotation:

1)      To access a quotation, you need to follow the system path: Procurement and sourcing > Common > Requests for quotations > All requests for quotations. In the All request for quotations it is possible to check all quotations created in the system.


2)     Select the quotation with the status as Sent and click on Edit


3)     In the request for quotation details form, select the vendor to create a reply and click on Enter reply button


4)     In the Request for quotation reply form, click on Edit to reply the request for quotation for the selected vendor


5)     In order to enter the requested data for the quotation reply, in the Purchase quotation line FastTab click on Details to reply with the price, purchase charges, lead time, delivery date


6)     In the Quotation FastTab you can define the reply data for the quotation such as delivery data, price, purchase charges, lead time


7)     After you have defined the vendor bid details, click on Line details button to close the form and return to the Request for quotations reply main form


8)     Click on Close button to exit form and return to Request for quotation details form


9)     Back to Request for quotation details form, in the Vendor FastTab, you can notice the vendor status has been amended for Received. The status has been changed, because the quotation reply has been completed for this vendor


10)     In order to enter the requested data in the quotation reply form for all remain vendors, repeat the steps 3 till 9 in this article


11)     In the Request for quotation details form, in the Vendor FastTab, you can notice both vendor accounts has the status amended for Received now; because the quotation reply has been completed for all vendors


12)     After you have enter a reply for all vendors, click on Close button to exit form


13)     In the All request for quotations form, in the Quotations tab, click on Refresh button in the group List to refresh the form. Check the quotation in the list with status as Received for Multiple vendors


See you next time. Have fun DAXing!