eKasa – rounding of cash payments

Rounding of cash payments is mandatory in Slovakia since July 1st, 2022.
The goal of the law is to allow people paying in cash to never have to use 0,01 and 0,02 euro coins.

The rounding is only applied on cash payments (amount paid in cash)

Cash payment must be rounded to the nearest 5 euro-cents, or exactly 5 cents if the rounding were to result in zero.
This rounding is only applied on cash payments, cashless payments like cards are not affected.

Examples of rounding:
10,43€ -> 10,45€
10,42€ -> 10,40€
00,02€ -> 00,05€

Rounding affects the overall value of the receipt

While we are not rounding the document amount directly, we are rounding the cash payment,
and if there was a rounding applied, the overall value of the document was also affected,
this is because you must include the rounding amount in the document value.

Notice that the document value is effectively the sum of its payments.

[ Example 1 ]

Document:
    Items:
        - Beer        6x 1,19€ = 7,14€
        - Chips       1x 1,59€ = 1,59€
        ------------------------------
        Sum of all items:        8,73€
        
    Payments:
        - Card                   5,00€
        - Cash           3,73 -> 3,75€
        ------------------------------
        Sum of all payments:     8,75€
        
    Rounding: +0,02€
        
    Amount (document value):     8,75€ <-- Notice that the actual sum of items (8,73) 
                                           and rounding amount (+0,02) were added,
                                           and that this is effectively equal to the
                                           sum of all payments.

Rounding of cash only payments

In case of documents which only contain cash payment(s), it’s simple,
as the amount to be paid in cash is the total amount of the document, rounded to the nearest 0,05€.

[ Example 2 ]

Document:
    Items:
        - Beer        6x 1,19€ = 7,14€
        - Chips       1x 1,59€ = 1,59€
        ------------------------------
        Sum of all items:        8,73€
        
    Payments:
        - Cash           8,73 -> 8,75€
        ------------------------------
        Sum of all payments:     8,75€
        
    Rounding: +0,02€
        
    Amount (document value):     8,75€

Rounding of cashless payment

In case of purely cashless payments (e.g. via credit card), rounding is not applied at all.

[ Example 3 ]

Document:
    Items:
        - Beer        6x 1,19€ = 7,14€
        - Chips       1x 1,59€ = 1,59€
        ------------------------------
        Sum of all items:        8,73€
        
    Payments:
        - Debit card             8,73€
        ------------------------------
        Sum of all payments:     8,73€
        
    Rounding: <none - cash not used>
        
    Amount (document value):     8,73€

Rounding of combined (cash+cashless) payments

In case of combined payments, the remaining sum to be paid after subtracting all cashless payments from the sum of all items,
i.e. the remaining sum to be paid in cash, must be rounded to the nearest 0,05€.

[ Example 4 ]

Document:
    Items:
        - Beer        6x 1,19€ = 7,14€
        - Chips       1x 1,59€ = 1,59€
        ------------------------------
        Sum of all items:        8,73€
        
    Payments:
        - Card                   1,09€
        - Voucher                2,10€
        - Cash:          5,54 -> 5,55€ <-- (8.73) - (1.09+2.10) = 5,54 remaining
        ------------------------------
        Sum of all payments:     8,74€
        
    Rounding: +0,01€
        
    Amount (document value):     8,74€
[ Example 5 ]

Document:
    Items:
        - Beer        6x 1,19€ = 7,14€
        - Chips       1x 1,59€ = 1,59€
        ------------------------------
        Sum of all items:        8,73€
        
    Payments:
        - Card                   8,00€
        - Cash:          0,73 -> 0,75€ <-- (8.73) - (8.00) = 0,73 remaining
        ------------------------------
        Sum of all payments:     8,75€
        
    Rounding: +0,02€
        
    Amount (document value):     8,75€
[ Example 6 ]

Document:
    Items:
        - Beer        6x 1,19€ = 7,14€
        - Chips       1x 1,59€ = 1,59€
        ------------------------------
        Sum of all items:        8,73€
        
    Payments:
        - Card                   0,73€
        - Cash:                  8,00€ <-- (8.73) - (0.73) = 8,00 remaining
        ------------------------------
        Sum of all payments:     8,73€
        
    Rounding: 0,00€
        
    Amount (document value):     8,73€

Validation logic

There are a couple of basic rules:

  • Each document must contain payments which fully cover its value
  • Payments can repeat (multiple card payments, different banknotes or coins),
    the only thing that matters is the sum of all payments in each category (payment method).
  • The sum of all cash payments (if you split cash payment into multiple rows on the receipt, e.g. for individual banknotes and coins),
    must be a number divisible by 0,05 (amount paid in cash had to be rounded)

The validation algorithm works like this:

  1. All cashless payments found on the document are added together to form a total cashless amount paid.
  2. This total cashless amount paid is then subtracted from the sum of all items on the document, giving us a remaining sum to be paid in cash.
  3. Remaining sum to be paid in cash is rounded to the 0,05€, giving us a rounded sum to be paid in cash, plus the rounding amount (+/- 0,02€)
  4. The rounded sum to be paid in cash is compared to sum of all cash payments declared on the document – these sums must match.
  5. Rounding amount is added to the sum of all items on the document – this must match the declared document value.

Example request

{
  "type": "PD",
  "amount": 340.15,
  "documentEntries": [
    {
      "price": 64.22,
      "quantity": 1,
      "name": "Tovar 1",
      "vatRate": "VAT_10",
      "itemType": "SALE"
    },
    {
      "price": 275.95,
      "quantity": 1,
      "name": "Tovar 2",
      "vatRate": "VAT_20",
      "itemType": "SALE"
    }
  ],
  "payments": [
    {
      "method": "CARD",
      "amount": 100.00,
      "label": "VISA ####-####-####-1234"
    },
    {
      "method": "CARD",
      "amount": 200.00,
      "label": "VISA ####-####-####-6789"
    },
    {
      "method": "CASH",
      "amount": 40.00,
      "label": "4x banknote 10€"
    },
    {
      "method": "CASH",
      "amount": 0.15,
      "label": "3x coin 0.05€"
    }
  ]
}
  •