Aakvatech Limited - Configurable VAT Return Classification in ERPNext
A practical approach to making VAT return preparation in ERPNext more controlled, configurable, and auditable by storing VAT classification directly on invoice item rows.
Building a Configurable VAT Return Classification Flow in ERPNext
VAT reporting often starts simple and becomes complicated very quickly.
A business may initially classify transactions using tax rates or tax templates. Over time, however, statutory VAT returns usually require more than knowing whether a transaction is taxed at 15%, zero-rated, or exempt.
The return may need to distinguish between:
- exports and domestic zero-rated sales,
- taxable and exempt sales,
- imported and locally purchased goods,
- capital goods and normal operating purchases,
- claimable and non-claimable input VAT.
Trying to calculate all of this dynamically when the VAT Return report runs can make the report difficult to maintain and even harder for Finance users to audit.
For the Mauritius country-specific functionality in ERPNext, we took a different approach:
Determine the VAT classification during transaction processing, persist it on each invoice item, allow Finance to correct it where necessary, and let the VAT Return report simply aggregate the stored classifications.
This creates a much clearer separation between configuration, transaction classification, finance review, and statutory reporting.
The problem with report-time VAT classification
A common implementation pattern is for a VAT report to inspect several fields every time it runs:
- Item Tax Template
- Purchase Taxes and Charges Template
- tax rate
- supplier country
- Item Group
- fixed-asset configuration
- tax account
- invoice type
The report then tries to determine which statutory box each transaction belongs to.
This works initially, but it creates several problems.
Finance cannot easily correct an exception
Suppose an invoice item is normally classified as a standard taxable purchase, but Finance determines that this specific transaction needs a different statutory treatment.
If the VAT Return always recalculates the classification from master data, the Finance team's correction is lost unless the underlying master data or report logic is changed.
Historical reporting can change unexpectedly
If an Item Tax Template is updated later, a historical VAT Return could produce a different classification from the one that applied when the invoice was originally processed.
The report becomes the business-rules engine
Instead of being a reporting layer, the VAT Return begins to contain increasingly complex tax logic.
That makes testing and maintenance much harder.
A transaction-level classification model
The solution is to add a dedicated VAT Return Type to the invoice item itself.
The overall flow becomes:
Item Tax Template
|
v
Default VAT Return Type
|
v
Sales / Purchase Invoice Item
|
+--> Asset-specific conversion where applicable
|
+--> Finance adjustment if required
|
v
Persisted VAT Return Type
|
v
VAT Return Report
The VAT Return report no longer decides what a transaction means.
It reads the classification that was already established on the accounting transaction.
Introducing the VAT Return Type master
A new VAT Return Type master represents the statutory VAT return classifications.
Examples include:
| Box | VAT Return Type |
|---|---|
| 1.1 | Zero-rated supplies - Exports |
| 1.2 | Zero-rated supplies other than exports |
| 1.3 | Taxable supplies to exempt bodies or persons |
| 1.4 | Other taxable supplies |
| 3 | Exempt supplies |
| 6.1 | Capital goods imported |
| 6.2 | Zero-rated imports |
| 6.3 | Other imports |
| 6.4 | Capital goods purchased locally |
| 6.5 | Zero-rated local goods and services |
| 6.6 | Other local goods and services |
| 7 | Taxable input with no input tax credit |
| 8.1 | Exempt imported goods |
| 8.2 | Exempt local goods and services |
Each VAT Return Type also identifies whether it applies to:
- Sales
- Purchase
- Both
For purchase classifications, the master can additionally define a Capital Goods VAT Return Type.
For example:
6.3 Other Imports
|
+--> Capital Goods VAT Return Type = 6.1
and:
6.6 Other Local Goods & Services
|
+--> Capital Goods VAT Return Type = 6.4
This keeps the mapping configurable rather than hard-coded in Python.
Configuring Item Tax Templates
The Item Tax Template is used as the default source of VAT classification.
A new field is added:
VAT Return Type
For example:
Item Tax Template:
VAT 15% Standard Local Purchase
VAT Return Type:
6.6 - Other Goods & Services Purchased Locally
Or:
Item Tax Template:
VAT 0% Export
VAT Return Type:
1.1 - Zero-rated Supplies - Exports
This means the tax template contains the normal business classification for transactions using that template.
There is no need for a Python dictionary containing mappings such as:
"VAT 15% Standard": "6.6"
The relationship is maintained directly in ERPNext configuration.
This is important because new Item Tax Templates can be introduced without changing application code.
Sales Invoice behaviour
A VAT Return Type field is added to each Sales Invoice Item.
The field is configured to fetch its default from:
item_tax_template.vat_return_type
When a Sales Invoice is submitted, the system checks each item.
If the invoice row already has a VAT Return Type, the value is preserved.
If it is blank, the system retrieves the VAT Return Type from the selected Item Tax Template.
The result is stored directly on the Sales Invoice Item.
For example:
Item Tax Template
VAT 0% Export
|
v
VAT Return Type
1.1
|
v
Sales Invoice Item
VAT Return Type = 1.1
When the VAT Return is generated later, the invoice value goes directly into Box 1.1.
Purchase Invoice behaviour
Purchase classification follows the same principle, with one additional step for fixed assets.
The Purchase Invoice Item first gets its normal VAT Return Type from the Item Tax Template.
For example:
Item Tax Template
VAT 15% Local Purchase
|
v
VAT Return Type
6.6
The system then checks whether the purchased Item is configured as a fixed asset.
If it is not a fixed asset:
6.6 remains 6.6
If it is a fixed asset and the VAT Return Type has a configured capital-goods mapping:
6.6
|
+--> Capital Goods VAT Return Type = 6.4
the invoice item is changed automatically to:
6.4 - Capital Goods Purchased Locally
The same principle applies to imports:
6.3 Other Imports
|
+--> fixed asset
|
v
6.1 Capital Goods Imported
The key advantage is that Python does not need to know that 6.6 means local purchases or that 6.4 means local capital goods.
The relationship is stored in the VAT Return Type configuration.
Purchase Taxes and Charges Template is not used for classification
One deliberate design decision was to completely separate Purchase Taxes and Charges Template from VAT return classification.
The selected Purchase Taxes and Charges Template does not determine whether an invoice belongs to:
- Box 6.1
- Box 6.3
- Box 6.4
- Box 6.6
- or another statutory category.
Instead, classification comes from:
Item Tax Template
+
Item fixed-asset status
+
optional Finance override
This matters because one Purchase Invoice can contain items with different statutory treatments.
A parent-level Taxes and Charges Template cannot accurately represent item-level VAT classification in that scenario.
Finance can correct classifications after submission
Tax classification sometimes requires accounting judgement.
For this reason, the VAT Return Type field on:
- Sales Invoice Item
- Purchase Invoice Item
is configured with:
Allow on Submit = Yes
This means an authorized Finance user can correct the VAT Return Type on a submitted invoice without cancelling and recreating the transaction.
For example, an item may initially be classified as:
6.6 - Other Goods & Services Purchased Locally
but Finance may determine that it should instead be:
7 - Taxable Input on Which No Input Tax Is Allowed as Credit
The row can be corrected directly.
Once corrected, the VAT Return uses the revised classification.
This is one of the most important controls in the design.
The Item Tax Template provides the default, while the invoice item contains the final accounting classification.
Preserving explicit user overrides
The system also avoids overwriting intentional classifications.
On Purchase Invoice submission, capital-goods conversion is only applied when the row still contains the default value from the Item Tax Template.
For example:
Item Tax Template default = 6.6
Invoice row = 6.6
Item is fixed asset
The system can safely convert it to:
6.4
But if a user has already changed the row to:
7
before submission, that classification is preserved.
The fixed-asset logic will not replace it.
Handling historical invoices
Introducing a new classification field creates another practical challenge:
What happens to invoices that were already submitted before the feature was installed?
During migration, existing submitted Sales and Purchase Invoice Items are checked.
If the VAT Return Type is blank, the system backfills it from the existing Item Tax Template.
For purchases, fixed-asset logic is also applied during the backfill.
Existing non-blank classifications are never overwritten.
This allows historical data to be brought into the new reporting model while preserving any classifications that may already have been manually set.
How the VAT Return report works
Once item-level classification exists, the report becomes significantly simpler.
For Sales Invoice Items, the report reads:
Sales Invoice Item.vat_return_type
and aggregates the base net amount into the matching sales box.
For example:
VAT Return Type = 1.1
Net Amount = 500,000
results in:
Box 1.1 = 500,000
Similarly:
VAT Return Type = 3
Net Amount = 100,000
results in:
Box 3 = 100,000
For Purchase Invoice Items, the same approach applies.
VAT Return Type = 6.4
Net Amount = 2,000,000
results in:
Box 6.4 = 2,000,000
Classification and VAT amount are separate concepts
It is important to distinguish between:
- which VAT Return box the transaction belongs to, and
- how much VAT was actually posted.
The invoice item determines the statutory classification.
The report still reads the actual tax amounts recorded on the invoice tax rows when calculating VAT values.
For purchase transactions, the VAT amount for an invoice is allocated across the eligible item classifications based on their net values.
Therefore:
Purchase Taxes and Charges are used to determine the VAT amount, but not to determine the VAT Return classification.
This separation prevents the tax template from becoming the statutory classification engine.
Blocking incomplete VAT Returns
A VAT Return should not silently guess where an unclassified transaction belongs.
The report therefore checks submitted Sales and Purchase Invoice Items before generating the return.
If an item has no VAT Return Type, the report stops and identifies the affected invoice rows.
For example:
Purchase Invoice items are missing VAT Return Type:
row 2 of PINV-2026-00431
Finance must classify the transaction before generating the return.
This creates a useful period-end control and prevents unclassified transactions from disappearing into an arbitrary default box.
VAT Return calculations
The report aggregates the configured item classifications into the corresponding statutory sections.
Output VAT
Sales classifications populate:
1.1
1.2
1.3
1.4
3
The report calculates:
Box 5 = Total output values
and the VAT payable on taxable output is combined with other applicable VAT amounts.
Input VAT
Purchase classifications populate:
6.1
6.2
6.3
6.4
6.5
6.6
7
8.1
8.2
The report calculates:
Box 9 = Total input values
and the eligible input VAT is used in subsequent calculations.
Proportion allowable
The user enters:
Proportion Allowable %
The report applies this to the eligible input VAT:
Box 10 =
Eligible Input VAT x Proportion Allowable %
VAT payable
The report then calculates the downstream VAT account values, including:
Box 11 - VAT payable for the taxable period
Box 12 - Excess VAT brought forward
Box 13 - VAT adjustment
Box 14 - VAT due and payable
Box 15 - Repayment claims
Box 16 - Excess VAT carried forward
Box 17 - Late submission penalty
Box 18 - Period penalty
Manual statutory adjustments remain report filters because they are not normally derived from individual invoice lines.
A practical example
Assume a Purchase Invoice contains three items:
| Item | Amount | Item Tax Template | Asset? | Final VAT Return Type |
|---|---|---|---|---|
| CNC Machine | 1,000,000 | Standard Local VAT | Yes | 6.4 |
| Maintenance Parts | 200,000 | Standard Local VAT | No | 6.6 |
| Staff Expense | 100,000 | Non-Claimable VAT | No | 7 |
The VAT Return does not classify the complete invoice into one category.
Instead, it reports:
Box 6.4 1,000,000
Box 6.6 200,000
Box 7 100,000 plus applicable non-claimable VAT treatment
That is much more accurate than relying on a single Purchase Taxes and Charges Template selected at invoice level.
VAT Return workspace and dashboard
The implementation also includes a VAT Return control section inside the MRA Integration Workspace.
Finance users can access:
- VAT Return report
- VAT Return Dashboard
- VAT Return Type master
- Item Tax Templates
- Sales Invoices
- Purchase Invoices
The workspace also includes four KPI cards:
VAT Classified Sales Items
VAT Unclassified Sales Items
VAT Classified Purchase Items
VAT Unclassified Purchase Items
These immediately show whether transaction classification is complete.
Two additional charts provide a high-level view of transaction values:
- VAT Output Value by Box
- VAT Input Value by Box
This gives Finance a useful control point before running the statutory report.
Recommended month-end process
A practical VAT close process can now follow these steps.
- Open the MRA Integration Workspace.
- Review the unclassified Sales and Purchase KPI cards.
- Investigate and correct any unclassified invoice items.
- Review the VAT Output Value by Box chart.
- Review the VAT Input Value by Box chart.
- Correct exceptional invoice classifications where necessary.
- Open the VAT Return.
- Select the Company and taxable period.
- Enter any manual statutory adjustments.
- Generate and review the final return.
This provides a clear separation between:
Master configuration
|
Transaction processing
|
Finance review
|
Exception correction
|
Statutory reporting
Why this architecture works well in ERPNext
ERP systems are strongest when business rules are captured as close as possible to the transaction.
The Item Tax Template represents the standard rule.
The invoice item represents what actually happened.
The VAT Return Type master defines the statutory reporting structure.
The Finance user retains the ability to make an accounting adjustment.
The report then performs aggregation rather than trying to reconstruct accounting judgement after the fact.
This produces a system that is:
- easier to configure,
- easier to audit,
- easier for Finance users to understand,
- less dependent on hard-coded mappings,
- safer for historical reporting,
- and easier to extend when statutory requirements change.
Final recommendation
For statutory reports in ERPNext, avoid placing all classification logic inside the report itself.
Where possible, store the final reporting classification on the underlying accounting transaction and use configurable master data to provide defaults.
A good pattern is:
Master data provides the default
+
transaction context refines it
+
Finance can review and override it
+
reports aggregate the final stored result
This keeps reporting predictable while preserving the flexibility Finance teams need in real-world accounting operations.
Reference articles and discussions
- Aakvatech Limited,
csf_murepository - Aakvatech Limited, PR #18: feat: add item-level VAT return classification — https://github.com/Aakvatech-Limited/csf_mu/pull/18
- ERPNext Item Tax Template functionality
- ERPNext Sales Invoice and Purchase Invoice transaction structure
- Frappe Framework Custom Field and
fetch_fromfunctionality - Frappe Framework Dashboard, Number Card, Dashboard Chart, and Workspace functionality
- Internal Aakvatech implementation discussion and VAT Return user manual prepared for this feature
Aakvatech Limited is a Frappe Gold Partner and ERPNext implementation company headquartered in Dar es Salaam, Tanzania, operating across East Africa and the UAE.
This article was co-created using AI to accelerate drafting, with final insights curated and validated by the author. Any customer, personal, or sensitive data referenced during drafting has been anonymized or masked where applicable. All contributors, reference URLs, tools, and materials used to assist this content curation are credited in the Reference section.
No comments yet. Login to start a new discussion Start a new discussion