-
Notifications
You must be signed in to change notification settings - Fork 21
Add support for Malaysian SST regime (MY) in GOBL #523
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: main
Are you sure you want to change the base?
Conversation
… and test coverage
samlown
left a 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.
Good start. The original contributing comment checklist should be maintained as that lists useful steps which have been skipped here. Its important that the tests and linters pass, also so that we can confirm test coverage.
More attention needs to be take when comparing against existing examples. The tax category definitions for example are not aligned with any of the existing tax regimes.
|
|
||
| ## Disclaimer | ||
|
|
||
| > This implementation of the Malaysian tax regime (`MY`) for GOBL has been developed as part of a technical exercise and is intended for **demonstration and testing purposes only**. While every effort has been made to align with publicly available SST regulations and business practices in Malaysia, this module is **not certified for production use** and may not cover all legal, fiscal, or e-invoicing requirements. |
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.
I don't think this is necessary.
| ) | ||
| } | ||
|
|
||
| func validateCustomer(val any) error { |
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.
This method looks identical to the validateSupplier. Are both methods required?
| require.NoError(t, inv.Calculate()) | ||
| err := inv.Validate() | ||
| assert.ErrorContains(t, err, "supplier: (tax_id: cannot be blank.)") | ||
| }) |
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.
No test appears to be present for requiring the customer.
| validation.Required, | ||
| tax.RequireIdentityCode, |
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.
Are you sure this is a requirement? How are simplified invoices issued in Malasia when there is no customer?
| return &tax.RegimeDef{ | ||
| Country: "MY", | ||
| Currency: currency.MYR, | ||
| TaxScheme: tax.CategoryST, // tax/constants.go. Malaysia uses SST — a form of ST in GOBL terms. |
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.
I think it would be good to add a tax.CategorySST to represent this unique type in Malaysia.
| }, | ||
| }, | ||
| { | ||
| Key: "standard-10", |
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.
This is probably just standard.
| }, | ||
| }, | ||
| { | ||
| Key: "standard-8", |
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.
Assuming this category is merged into a single SST, this key could perhaps be standard+services.
| }, | ||
| Rates: []*tax.RateDef{ | ||
| { | ||
| Key: "standard-6", |
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.
Perhaps this should be reduced+services.
| taxCodeMYNumeric = regexp.MustCompile(`^\d{12}$`) | ||
|
|
||
| // Alphanumeric SST/Service Tax IDs — e.g., SST1234567890 or W10-12345678-123 | ||
| taxCodeSST = regexp.MustCompile(`^SST\d{10,12}$`) |
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.
I'd ditch the SST part and just focus on the numbers. This could be normalized out. I think it'd also be important to detail why there are different formats, even if just in the comments.
| } | ||
| str := strings.ToUpper(strings.TrimSpace(code.String())) | ||
|
|
||
| if taxCodeMYNumeric.MatchString(str) || taxCodeSST.MatchString(str) || taxCodeWStyle.MatchString(str) { |
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.
Ideally there should only be one primary tax code format to use. I'd expect SST to be the primary code to use in international transactions. But if there is a source of information where this logic was determined, it'd be useful to mention here.
This PR introduces initial support for Malaysia (
MY) into the GOBL system, implementing the Sales and Service Tax (SST) structure. The contribution includes a new regime definition, validation logic, tax category definitions, and tests.Implemented Features:
New Malaysian Regime
MYregime usingTaxScheme: "st"(Sales Tax system)Tax Categories for SST
sales-taxwith 5% and 10% ratesservice-taxwith 6% and 8% rates (including March 2024 update)Invoice Validation (
invoice.go)supplierandcustomerhave a validtax_idTax Identity Validation (
tax_identity.go)Testing
invoice_test.govalidates:tax_identity_test.goverifies:Notes:
identities[]field (e.g., for SST numbers) is supported structurally but not yet validated.