E8-F2: Service Fee Calculation¶
Epic: E8: Payment Processing
Size: S (Small)
Problem / Outcome¶
Calculate service fees and VAT correctly.
Scope¶
In-Scope:
- Every price includes its VAT (HNSTIK-418): a category's price, its match-day price, a quota seat's price and a delivery note line's price are what the buyer pays. A 30 € ticket at 5% is 28.57 € net and 1.43 € VAT
- Ticket fee by default 0% on HOME matches (the fee is in the ticket price) and 6% on AWAY matches; configurable per match (HNSTIK-308). The fee is a percentage of the ticket price, added on top of it, and includes its own VAT: 30 € + 6% is 31.80 €. A fan purchase and a quota claim pay it (a deferred claim's fee goes on the quota owner's Obračun); a free quota pays none, nor do Petrol, a Ponuda or an Otpremnica (HNSTIK-190)
- VAT rates: 5% HOME ticket, 0% AWAY ticket
- VAT rates: 25% HOME fee, 0% AWAY fee
- The match sets the rates for every channel: fan purchase, quota claim, Petrol sale, delivery note
Out-of-Scope:
- Dynamic fee rates
Acceptance Criteria¶
- AC1: Given HOME match, ticket VAT = 5%, fee VAT = 25%
- AC2: Given AWAY match, ticket VAT = 0%, fee VAT = 0%
- AC4: Given a HOME match without its own fee, checkout shows no fee; an AWAY match without one, 6% (HNSTIK-308)
- AC3: Fee shown separately on invoice from ticket price
- AC5: Given a 30 € category on a HOME match, the fan pays 30 € and the invoice shows 28.57 € net and 1.43 € VAT (HNSTIK-418)
- AC6: Given 7 tickets of 30 € at 5%, each ticket is 30 € and together they are 200.00 € net and 10.00 € VAT, as on the invoice line
Data Model Impact¶
Order table:
- ticket_amount (DECIMAL) - the tickets' net part (their prices less the VAT inside them)
- ticket_vat_amount (DECIMAL) - the VAT inside the ticket prices
- fee_amount (DECIMAL) - the service fee's net part
- fee_vat_amount (DECIMAL) - the VAT inside the fee
- total_amount (DECIMAL) - what the buyer pays: the ticket prices plus the fee
- ticket_vat_percent, fee_percent, fee_vat_percent (DECIMAL) - the rates the order was priced at
FeeConfiguration table:
- id (UUID, PK)
- match_id (UUID, FK, nullable) - null for default
- fee_percent (DECIMAL) - match-type default when unset: home 0.0, away 6.0
- ticket_vat_percent (DECIMAL) - a config is scoped to one match; match-type default when unset: home 5.0, away 0.0
- fee_vat_percent (DECIMAL) - match-type default when unset: home 25.0, away 0.0
Permissions/Roles¶
- System (calculation)
How to Verify¶
npm test -- --grep "fee calculation"
Expected: Correct amounts for HOME and AWAY matches.
Dependencies¶
Implementation Tasks¶
See E8: Payment Processing Tasks
Doc References¶
Last Updated: January 2026