Rounding

From ADempiere
Jump to: navigation, search
This Wiki is read-only for reference purposes to avoid broken links.


Note.gif Note:

The Functional Team is preparing to release the 3.70 software and is considering including the Rounding feature enhancements, created by Daniel Tamm, as part of the application. Our testing of this feature has raised a few questions and the Functional Team would appreciate your opinions before we make the decision to include the feature or not. Please add your comments/arguments on the discussion page or in the Source Forge forum post. The decision will be made on 29 July 2011.

Currency rounding is limited at the moment in Adempiere. This article describes the current functionality and a proposed enhanced functionality.

Settings

Rounding settings are primarily found in the price list setup.

Price precision

Price precision tells us how many decimals should be used when generating prices. NOTE. This doesn't seem to work in the Create Price List process.

Price list

A price list can be generated with another price list as source. In general the purchase price list is used as source and the sales pricelist is generated from the purchase price list according to a set of rules - Price list schema.

Price List Schema

The price list schema defines how the target price should be calculated. This can involve rounding and this is the only place where rounding currently is used in Adempiere.

M_PriceList_Create

This is the process that generates the target price list. This process is very database centered and most logic is done in the database. The rounding is also performed by the database.

Rounding Rules

These are the defined rounding rules in ADempiere:

Code Description
0 Whole Number .00
5 Nickel 0.05, .10, .15 ..
9 Ending in 9/5
C Currency Precision
D Dime .10, .20, .30 ...
N No Rounding
Q Quarter .25, .50, .75 ..
T Ten 10.00, 20.00, ...

The rounding rules are defined in the reference "M_DiscountPriceList RoundingRule".

Suggested rounding functionality - FR 3028588

Rounding is useful in many circumstances. Invoices that are paid electronically can normally be paid to currency precision. However, cash payments may have to be rounded to the nearest available coin/bill. Coins and bills are not static since currency value can change over time. Different countries also have big differences, some uses in fractions in reality, (British pounds) and some only in theory and electronic transactions (Swedish crowns).

Due to this fact it is desirable to be able to automatically round totals of sales (ie sales orders, sales invoices) according to a given (and adjustable) rounding rule.

It may also be desirable to round purchase invoices (purchase orders, purchase invoices). This function might not have to be fully automatic since you can't say beforehand if your vendor will round their invoice or not.

Rounding setting

The rounding settings are preferrable set on price list level where both currency and price precision is set with current functionality. All settings below will reside on the price list level.

Document Rounding Rule

All that is needed on the pricelist level is a reference to Rounding Rule. Default rule would be none.

The rounding rule on the price list level shouldn't affect the rounding in the Price List Schema since the rounding on price list level is "document rounding". "Document Rounding" meaning that documents that use this pricelist will apply the selected rounding rule.

Document Rounding Charge

All rules except "No Rounding" will demand a reference to a charge. The charge specifies how the rounding difference will be accounted.

If there are documents that can have charges (sales orders etc) the charge specified in this setting will be used to adjust the total amount of the document. If the charge line of the given type doesn't exist, a charge of the type will simply be added to the document before it's completed. If a charge line of the given type exists, the charge line will be adjusted accordingly.

If no rounding is necessary no charge line will be added / adjusted.

Allow manual rounding

This is a Y/N setting. If manual rounding is allowed, a process button will be available on the document that enables the user to run the rounding process before the document is completed.

If manual rounding is not allowed, rounding will unconditionally take place when the document is completed. The rounding button won't be visible.

Document rounding

The rounding functionality will be activated on documents that refer to a pricelist. These document will have the rounding functionality applied when the documents are completed. If manual rounding is enabled, the user can trigger the rounding before the document is completed.

Changes to AD

  • Add Element RoundingRule
  • Add Element RoundingCharge
  • Add column RoundingRule to PriceList, Reference = List, Reference Key = M_DiscountPriceList RoundingRule
  • Add column RoundingCharge to PriceList, Reference = Search, Reference Key = C_Charge, Length=10, Mandatory Logic = @RoundingRule@!
  • Add field Rounding Rule to Price List
  • Add field Rounding Charge to Price List, Display Logic = @RoundingRule@!, Same line=Y

Testing

  • Create a product with a random name and set its price on the purchase price list in a way that the price will be rounded on sales price lists at qty 1 and on orders and invoices at fractional quantities.

For all Rounding Rules:

  • Create a price list that uses that rule
  • Create a version of the price list based on the purchase price list
  • Verify that the prices have been rounded correctly
  • Open a new sales order (POS Order) - assign it to Joe Block and set the price list to the new price list just created. (This sets the rounding rule for the order/invoice). Save.
  • Add an order line and include the test product. Set the qty so that the line and grand total will have to be rounded. Save.
  • Complete the order.
  • Check the grand total and the line totals against the rounding rule.
  • zoom across to the invoice
  • Check the grand total and the line totals against the rounding rule.
  • Repeat