Download accounting/vat.md from swedishembedded/knowledge: direct link, hf CLI and curl.
- Browser
- Download file 4 kB
-
https://huggingface.co/swedishembedded/knowledge/resolve/main/accounting/vat.md
- Command line
-
hf download hf://swedishembedded/knowledge/accounting/vat.md
-
curl -L -o vat.md https://huggingface.co/swedishembedded/knowledge/resolve/main/accounting/vat.md
title: VAT return from invoices
tiers: rule 1, procedure 2, example 3, mistakes 2
VAT return from invoices
For tasks that give sales and purchase invoices and a rate table and ask for the VAT per invoice and the return totals.
Rule
The task's own files and stated rules always win over this page; use this page only for what the task leaves open.
- The request states the method: use it word for word. Which rate applies, how net and gross amounts are treated, how to round, and what the totals are. The points below only explain the usual meaning of those sentences.
- The rate comes from the task's rate table: the row for the invoice's own category whose validity range contains the invoice date. Read the request for whether a range's last day is included.
- A rate given in percent is divided by 100 once before it is used as a factor.
- Amounts are used as they stand in the file. Never rescale them.
- Net basis: VAT = net x rate. Gross basis: net = gross / (1 + rate), VAT = gross - net.
- Output VAT is the VAT on sales; input VAT is the VAT on purchases. Payable = output - input, negative when input is larger.
- Every invoice gets a line, also one whose VAT is 0.00.
- If an invoice lacks what the method needs, see
/knowledge/agent-workflow/missing-information.md.
Procedure
- Read the request's method sentence and the answer shape. Read the rate table and the invoices completely.
- Write one script file that, for each invoice: finds the table row by category and date; turns the percent into a factor; computes the VAT by the invoice's basis; rounds as the request says, with exact decimals.
- In the same script: sum the VAT of sales into output VAT and of purchases into input VAT; payable = output - input; print every line and the three totals.
- Estimate one line by hand to catch a slip of rate or scale. If the script's line is a hundred times off, the slip is in the script.
- Let the script write the answer in the request's shape: a list of lines if the shape shows a list, numbers where it shows numbers.
- Check once: number of lines = number of invoices; output + input = sum of all lines; the sign of payable. Then finish.
Worked example
Illustration only, with invented data. Your task's data differs: take no fact, count or expected result from this example.
Rate table (percent): general 20 throughout; print 10 up to and including 30 June and 5
from 1 July; export 0. The request says: half up to 0.01; gross means net = gross / (1 +
rate).
| Invoice | Date | Direction | Category | Amount | Basis | Rate | VAT |
|---|---|---|---|---|---|---|---|
| A | 30 June | sale | 300.00 | net | 10 | 30.00 | |
| B | 1 July | sale | 300.00 | net | 5 | 15.00 | |
| C | 3 July | purchase | general | 600.00 | gross | 20 | 100.00 |
| D | 5 July | sale | export | 950.00 | net | 0 | 0.00 |
| E | 9 July | purchase | 210.00 | gross | 5 | 10.00 |
A and B are one day apart; the rate changed between them. C: net = 600.00 / 1.20 = 500.00, VAT = 100.00 (not 600.00 x 0.20). E: net = 210.00 / 1.05 = 200.00, VAT = 10.00.
Output VAT = 30.00 + 15.00 + 0.00 = 45.00. Input VAT = 100.00 + 10.00 = 110.00. Payable = 45.00 - 110.00 = -65.00.
Common mistakes
- Replacing the request's stated method by another, or debating it at length.
- Using the wrong side of a rate change on its boundary dates.
- Dividing the percent by 100 twice, or deciding the amounts are in another unit.
- Computing VAT on a gross amount as gross x rate.
- Counting a purchase in output VAT, or leaving an invoice out of a total.
- Writing payable as a positive number when input VAT is larger.
- Writing the lines as an object keyed by invoice where the shape shows a list.