Decimal places of quantity and amount

Source: Internet
Author: User

In ax, the base types of the edt type of the quantity and amount are both real. Although the EDT type is created, the selection is real, which is actually called decimal, because this type of EDT is translated into the numbric type in SQL Server, because the exact calculation method is used to process the quantity and amount, rather than using approximate data types such as float and real. For more information about these types, see the following link:

Http://msdn.microsoft.com/zh-cn/library/ms187912.aspx

The processing of quantity and amount in ax is mainly based on three basic EDT types, the quantity is realbase, and the amount is money and moneymst. Among them, realbase can be found in the AOT tree, and money and moneymst cannot be found, but the two of them can be found in AOT directly offline amount and amountmst.

The number of decimal places displayed on the interface is defined by noofdecimals of the edt type. This attribute is different from the stringsize of the edt type whose base type is string, the noofdecimals attribute is only used to define the number of decimal places displayed on the user interface, without affecting the number of decimal places for fields of the EDT type in the SQL Server database, I have read that the Field Types of the corresponding quantity and amount in SQL Server are numbric (28, 12). I didn't find a place to change the length in ax. OK, we can imagine that the data storage layer can only store up to 12 decimal places, so in the presentation layer, even if the value can be defined to show more than 12 digits, it does not make much sense, the actual ERP application does not need to be accurate to such a large precision. Of course, if this field is not directly stored in the database but used as the intermediate variable value for calculation, to some extent, it can improve the accuracy of the operation. After testing, noofdecimals can be set to any integer, but it is actually greater than 16 bits, it has been processed as the default value 2, such as AM The value of noofdecimals of the edt type outmst is set to 20. In fact, after being dragged to the interface, only two decimal places are displayed.
Here we can draw a conclusion that noofdecimals is only used to limit the display of the interface.ProgramUse the EDT type to define a variable. You can assign a value to the number of decimal places of any length (of course, the maximum decimal value is )), when the computing result is stored in SQL Server, it is given as 12 decimal places.

In this way, the number of decimal places on the data layer and the display layer is clearly limited. The number of decimal places on the data layer is fixed to 12 bits (of course, this setting can be modified, but I did not find it ), the presentation layer is limited by noofdecimals of the edt type. In fact, the program design should be made in the business logic layer according to the business needs in the business layer to make some restrictions, not according to the data layer and the performance Layer of the two pieces of the transaction to complete. Ax also specifies the number of decimal places in the business logic layer.
At the business level, we mention the quantity. Of course we need to contact the organization. Otherwise, we only need to say a number, which makes no sense. 5 tons and 5 kg are obviously not comparable. When we mention the amount, be sure to associate it with the currency. The yen and USD are definitely different. Ax is also based on this idea. The limit on the number of decimal places is reflected in the unit, and the limit on the number of rounded digits of the amount is written in the currency.

Let's take a look at the quantity. We take the sales quantity of the sales order as an example to describe that the corresponding extended data type of this field is salesorderedqty, in the end, we can find that the top-level EDT type is the realbase we mentioned earlier. It depends on the actual requirements, if you want to change the number of display digits to four or higher (the default value is 2), you can directly modify the realbase so that everyone can inherit from it, if you only want to modify the sales quantity, you can modify only the salesorderqty. Here, we only use modifying the salesorderedqty EDT type as an example to describe how to set the value of noofdecimals of the edt type to 4.

We can see that the number is indeed displayed as 4 digits, but if the input value is clear, I set the number of decimal places in the unit of kg to 1, as shown in:

no matter whether you enter 1.2345 or other values, you will be given a value of 1.2 or 1.3 (rounded up). If you want to enter a value of four digits, you need to set the value of the unit corresponding to the item to four digits, so that the presentation layer is consistent with the business. If you do not set the decimal places of the unit, the number field shows a string of zero, it doesn't make sense. You can set up to eight decimal places in the unit. Generally, this is enough. You can modify the Code , leave this limit open, but it can only be 12 bits at most. The data layer is limited and there is no need to save so many bits.
let's take the amount as an example. The top-level parent type of EDT saleslineamount is amount, which corresponds to amoutnmst, it indicates the amount in the original currency, while amountmst indicates the amount in the standard currency. We know that on the system management> Settings> system> modify data type interface, there is an option to modify the amount of the data type. I flipped through the code, the setting in this place only affects the EDT type amoutmst, so the EDT type inherited from amountmst is affected, but the amount represented in the original currency like the sales amount is inherited from amount, therefore, the modification here does not affect the number of digits displayed in the sales order line. Here, we modify the value of EDT saleslineamount to four digits and get the following value:
we can see that, although the value is displayed as four decimal places, the product of the quantity and price should be 34.991728. If it is rounded to four decimal places, it should be 34.9917. You have set the overall processing in the currency. In the General Ledger-> Settings-> exchange rate-> The overall (Tab), as shown in:

We can see that there are a total of four settings on the amount above. The first one is for normalization, the lineamount of the sales order line above is controlled by this field, and the other three, the amount is rounded up when two orders are actually invoiced, And the rounding price is based on the rounding setting of the price, but I am wondering that there are only three options for this general setting, if it is not set, 0.1 and 0.01, if it is not set here, ax will also take the default value 0.01, so it is equivalent to only setting it to take one decimal place 0.1. If you want to keep three decimal places, or more, there is no way to set it. This is really a strange thing. Maybe I haven't found some settings, I haven't found a place where I can set it to more decimal places after half a day... The only solution I can think of is to change the length of noofdecimals of the edt type corresponding to the normalized integer field to a longer value, which is actually a method I don't want to use, in this way, the business personnel cannot do it at all, and the business personnel cannot be asked to go to the AOT to modify it, so I think it is more reasonable to expose this EDT type to the modified data type in management? Or do I get the EDT type noofdecimals longer when I publish it? Or does Ms think that the amount should be retained up to two places? For now, I have changed the attribute noofdecimals of the edt type roundoff corresponding to normalization to 4, and then changed the normalization to 0.0001. Then I will look at the row amount of the sales order, as shown in:

In addition, the purchase price and other prices also inherit from the amount basic type. Therefore, the function of modifying the Data Type in system management does not change the decimal display digits of the price, you can only find the corresponding EDT type in AOT and modify it. In addition, the price is not like the quantity and amount. You can only modify the corresponding EDT type by controlling the business logic layer, however, the price is actually related to the currency, so this process does not give a very uniform feeling.

Okay, that's all. Since I didn't see the official document, all the content came from my own tests and guesses, so I couldn't see it correctly.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.