- last edited on: 2018-06-03
Algorithm For Correcting The Current Accumulated Sum With a Specifically Defined Amount
In Bulgaria it is permitted to correct the currently accumulated for a fiscal receipt amount (“on” the Subtotal). One of the ways is for the client software to send a command to the fiscal device for a discount or surcharge “on” the Subtotal with a specifically defined amount. The corrections are distributed to each of the accumulated amounts "SumVatGroupx". These are the amounts in different tax groups which have been accumulated thus far through sales in a given fiscal receipt.
The new total sum "TotalVatSumNew" is equal to the difference (or sum) between the current total sum "TotalVatSumCurrent" and the sum "AdjustmentSum" which we use to correct the sale.
Discount
A discount is calculated through the following formula:

Surcharge
A surcharge is calculated through the following formula:

Besides modifying the total accumulated sum in a given receipt with the amount "AdjustmentSum", the fiscal device must also distribute this correction to all of the accumulated tax groups. You can read how that happens in the article on the algorithm for distributing this correction. It turns out that because of the need for rounding off only to the second decimal after the decimal separator, there exists the possibility for mistakes when rounding off during this correction method. The way to manage this “mistake” is also explained.
If the information in this article is incomplete or incorrect, don’t hesitate to contact me so I can make the necessary edits.

