-
Notifications
You must be signed in to change notification settings - Fork 9.9k
Add UK Tax Rules and Categories #50373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughAdds a new UK regional setup module with two functions: Estimated code review effort🎯 3 (Moderate) | ⏱️ ~30 minutes
Pre-merge checks and finishing touches✅ Passed checks (2 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used🧠 Learnings (2)📓 Common learnings📚 Learning: 2025-11-05T16:19:19.499ZApplied to files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (4)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Nitpick comments (3)
erpnext/setup/setup_wizard/data/country_wise_tax.json (1)
4992-5038: Consider addingroot_typeto sales tax account definitions.The sales tax templates define account heads without specifying
root_type. Other countries' configurations (e.g., France at lines 608-610) explicitly setroot_type: "Liability"for VAT accounts. While the system may infer this, explicit specification ensures consistent account creation.Consider this update:
{ "account_head": { "account_name": "VAT", + "root_type": "Liability", "tax_rate": 20.00 }, "rate": 20.00 }Apply similar changes to all sales tax templates (lines 4997-5003, 5010-5015, 5022-5027).
erpnext/regional/united_kingdom/setup.py (2)
8-9: Placeholder function noted.The
setup()function is currently a placeholder. Consider adding a docstring to document its intended future purpose or remove it if not needed.
12-12: Remove unusedcountryparameter.The
countryparameter inupdate_regional_tax_settings()is never used in the function body.-def update_regional_tax_settings(country=None, company=None): +def update_regional_tax_settings(company=None):
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
erpnext/regional/united_kingdom/setup.py(1 hunks)erpnext/setup/setup_wizard/data/country_wise_tax.json(1 hunks)
🔇 Additional comments (3)
erpnext/setup/setup_wizard/data/country_wise_tax.json (2)
4982-4989: LGTM! Tax categories align with UK VAT export requirements.The two tax categories properly distinguish between EU and Rest of World exports, which is essential for UK VAT compliance post-Brexit.
5102-5166: LGTM! Item tax templates are well-structured.The item tax templates correctly define both Input VAT (Asset) and VAT (Liability) components, following the pattern established by other countries like Germany. This allows proper tax calculation for items in both purchase and sales contexts.
erpnext/regional/united_kingdom/setup.py (1)
123-128: Verify tax rule creation is idempotent.The function doesn't check if tax rules already exist before calling
make_records(). If this function is called multiple times (e.g., during a patch rerun), it could create duplicate tax rules or fail during renaming.Run the following script to check the behavior when tax rules already exist:
Consider adding a check to skip creation if tax rules already exist:
# Check if tax rules already exist existing_rules = frappe.get_all("Tax Rule", filters={"company": company, "name": ["like", "UK%"]}) if existing_rules: frappe.logger().info(f"UK Tax Rules already exist for company {company}, skipping creation") return
|
This pull request has been automatically marked as inactive because it has not had recent activity. It will be closed within 3 days if no further activity occurs, but it only takes a comment to keep a contribution alive :) Also, even if it is closed, you can always reopen the PR when you're ready. Thank you for contributing. |
5fe6df4 to
1223098
Compare
Hello!
This is a proposed Draft for automatically adding the following Documents for UK Companies:-
Sales Taxes and Charges TemplatesPurchase Taxes and Charges TemplatesItem Tax TemplateTax CategoryTax RuleWhy Draft?
A Report format should be included, too. However, I feel that creating the PR now is useful in order to get feedback on the Templates and Rules made in the initial PR commits.
Background
VAT-registered companies in the UK need to submit their VAT returns electronically, using HMRC's Making Tax Digital (MTD) API submission system.
Creating relevant Templates, Categories and Rules is one of the first major hurdles to having an automated VAT system for UK companies. By having these templates pre-exist in the system, it will help UK VAT-paying companies get off the ground running.
Implementation
Users who create a United Kingdom company will now have the following additions.
Two additional VAT Accounts:-
Name:
VATRoot Type:
LiabilityName:
Input VATRoot Type:
Asset5 x Sales Taxes and Charges Templates:-
4 x Purchase Taxes and Charges Templates:-
3 x Item Tax Templates:-
8 x Tax Rules:-
2 x Tax Categories:-
Creating reports from these accounts should hopefully then be relatively simple.
Alternative Implementation
New Chart of Account (CoA) templates can be added to one of the
erpnext/accounts/doctype/account/chart_of_accounts/subdirectories. However, the UK does not have a formalised Chart of Accounts (CoA), so each UK company (or accountant) can use a unique Chart of Accounts. Therefore, I have relied on the existing Standard and "Standard with Numbers" CoAs.As per the Regional documentation:-
There is at least one Open Issue / Feature Request relating to UK Tax:-
I have been working on a fork of https://github.com/software-to-hardware/erpnext-vat-mtd, where I found one of the first major challenges is understanding how to set up these relevant templates correctly. The original repository is abandoned, and the code author has gone AWOL.
When I started to figure out how to add these templates etc in the plugin, I found ERPNext's existing
regionalandsetupmodules do this for other countries already, and in the long term, I think are a better home for these new Rules and Template Documents.TODO