- last edited on: 2018-06-03
Algorithm For Calculating The Sum Of a Given Row of Sales In a Fiscal Receipt
If the sales in a given fiscal receipt are N in number, we will then be faced with processing the data through the following cycle: "for i:=0 to N-1".
- We take the unit price of the item (without including taxes) for a line of the sale (i). For this unit price we shall use the term “RealSinglePricei”;
- Each of the items is located in a specific tax group. Let us use the variable "VATPercentForVATGroupX", which will contain the value of the percentage for different tax groups;
- For example: for the second tax group “B”(in Bulgaria and at the time of the writing of this article), the percentage value of "VATPercentForVATGroupX" is 20%;
- For the unit price including taxes we shall use the term "VatPricei" ;
- Thus, for each row of the sale we can get:

Before using this price in the command to the fiscal device, the resulting "VatPricei" has to be rounded off to the second decimal after the decimal separator.
- Let us call the amount sold on row (i) "RealQi";
- Whatever the value of "RealQi", as an amount, it has to be rounded off to the third decimal after the decimal separator in order to be used in a fiscal device;
- The total sum which is to be inferred from a given row of a sale in a fiscal receipt (let us call it "RowSumi") is calculated through the following formula:

The result of this formula must again be rounded off to the second decimal after the decimal separator.
This is also the sum which the fiscal device will print out on the sale note within the fiscal receipt.
If the data or something else in this article is incorrect - please email me to correct the article.

