-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #429 from invopop/br-typical-nfse
Extensions and validations for the typical service note
- Loading branch information
Showing
11 changed files
with
488 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package nfse | ||
|
||
import ( | ||
"github.com/invopop/gobl/regimes/br" | ||
"github.com/invopop/gobl/tax" | ||
"github.com/invopop/validation" | ||
) | ||
|
||
const ( | ||
// ISSLiabilityDefault is the default value for the ISS liability extension | ||
ISSLiabilityDefault = "1" // Liable | ||
) | ||
|
||
func validateTaxCombo(tc *tax.Combo) error { | ||
return validation.ValidateStruct(tc, | ||
validation.Field(&tc.Ext, | ||
validation.When(tc.Category == br.TaxCategoryISS, | ||
tax.ExtensionsRequires(ExtKeyISSLiability), | ||
), | ||
), | ||
) | ||
} | ||
|
||
func normalizeTaxCombo(tc *tax.Combo) { | ||
if tc == nil || tc.Category != br.TaxCategoryISS { | ||
return | ||
} | ||
|
||
if !tc.Ext.Has(ExtKeyISSLiability) { | ||
if tc.Ext == nil { | ||
tc.Ext = make(tax.Extensions) | ||
} | ||
tc.Ext[ExtKeyISSLiability] = ISSLiabilityDefault | ||
} | ||
} |
Oops, something went wrong.