- last edited on: 2021-07-17
Algorithm For Distributing The Correction of The Subtotal Through a Specifically Defined Amount In Tax Groups
This algorithm is verified for the following models of fiscal devices:
- Group "A" - FP-2000, FP-800, FP-650, SK-21F, SK-31F, FMP-10, FP-700;
- Group "B" - DP-05, DP-15, DP-25, DP-35, DP-150, WP-50;
- Group "C" - FP-700X, DP-25X, DP-150X, WP-50X, WP-500X, FMP-55X, FMP-350X, DP-05C;
In Bulgaria it is allowed to make corrections on the amount currently accumulated on the fiscal receipt (“on” the Subtotal). One of the possible ways to do this is to have the client software send the fiscal device a command for adding a discount or surcharge “on” the Subtotal with a specifically defined amount.
- This article is related to clarifications on algorithms used by fiscal devices in Bulgaria for rounding off;
- This article is related to clarifying the algorithm for making corrections on the Subtotal;
A correction has to be distributed among each of the accumulated amounts in different tax groups "CurrentSumForVATGroupX". These are the amounts in tax groups which have accumulated thus far as a result of sales in a given fiscal receipt. From the point of view of the “simulation” software with regard to the new corrected sums "AdjustedSumForVATGroupX" we have to know how the fiscal device determines the value of the adjustment "AdjustmentSum" in each of the tax groups. A reminder: what is discussed here is the tax groups which have taken part thus far in the sales listed in the fiscal receipt. The value of this adjustment is distributed among registers through the algorithm described below.
First we calculate the sum (“AdjustmentSumForVATGroupX”), with which the fiscal device will adjust each of the amounts accumulated so far "CurrentSumForVATGroupX", by means of the following formula:

The result must be rounded off to the second decimal after the decimal separator.
Discount
For a discount (on each of the amounts accumulated in different tax groups which are listed in the fiscal receipt), the following formula is used:

Surcharge
For a surcharge (on each of the amounts accumulated in different tax groups which are listed in the fiscal receipt), the following formula is used:

Note: Each of the amounts resulting from the above formulae (“AdjustedSumForVATGroupX”) must automatically be presented rounded off to the second decimal after the decimal separator.
Calculated Total Sum
The total sum can be calculated as follows:

"TotalVatSumcalculated" is the total sum in the fiscal device after carrying out the calculation described above.
Rounding Off Error
When distributing the discount “AdjustmentSum” among different groups it is entirely possible that the total calculated sum is inaccurate. This “error” is the result of the rounding off process. In other words, it is entirely possible that the values of "TotalVatSumNew" and "TotalVatSumCalculated" do not match. For this reason an additional method for calculating this error "roundErrorsSum" is applied in case the difference between these values is equal to or greater than one stotinka.

In fiscal devices, it is not allowed to have pending amounts (having sums disappear from taxes, in a fashion) and for that reason the pending amount "roundErrorsSum" must also be distributed among tax groups.
Algorithms for allocating this difference depending on the model - you can find in the links below:
- Algorithm for distributing the error from rounding off - for all devices in group "A":
- FP-2000, FP-800, FP-650, SK-21F, SK-31F, FMP-10, FP-700;
- Algorithm for distributing the error from rounding off - for all devices in group "B" and group "C":
- DP-05, DP-15, DP-25, DP-35, DP-150, WP-50;
- FP-700X, DP-25X, DP-150X, WP-50X, WP-500X, FMP-55X, FMP-350X, DP-05C;
If the information in this article is incomplete or incorrect, don’t hesitate to contact me so I can make the necessary edits.

