Skip to content

Commit

Permalink
Merge pull request #34 from invopop/fuel-rescale-down
Browse files Browse the repository at this point in the history
Rescaling fuel account and food voucher amounts
  • Loading branch information
samlown authored Jun 25, 2024
2 parents cd6036c + 1dbac68 commit ea2f4a3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
4 changes: 2 additions & 2 deletions food_vouchers.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func addValesDeDespensa(doc *Document, fvc *mx.FoodVouchers) {

RegistroPatronal: fvc.EmployerRegistration,
NumeroDeCuenta: fvc.AccountNumber,
Total: fvc.Total.String(),
Total: fvc.Total.RescaleDown(2).String(),

Conceptos: newVDConceptos(fvc.Lines), // nolint:misspell
}
Expand All @@ -67,7 +67,7 @@ func newVDConceptos(lines []*mx.FoodVouchersLine) []*VDConcepto {
Curp: l.Employee.CURP.String(),
Nombre: l.Employee.Name,
NumSeguridadSocial: l.Employee.SocialSecurity.String(),
Importe: l.Amount.String(),
Importe: l.Amount.RescaleDown(2).String(),
}
}

Expand Down
16 changes: 8 additions & 8 deletions fuel_account_balance.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ func addEstadoCuentaCombustible(doc *Document, fc *mx.FuelAccountBalance) {
TipoOperacion: ECCTipoOperacion,

NumeroDeCuenta: fc.AccountNumber,
SubTotal: fc.Subtotal.String(),
Total: fc.Total.String(),
SubTotal: fc.Subtotal.RescaleRange(1, 2).String(),
Total: fc.Total.RescaleRange(1, 2).String(),

Conceptos: newECCConceptos(fc.Lines), // nolint:misspell
}
Expand All @@ -80,13 +80,13 @@ func newECCConceptos(lines []*mx.FuelAccountLine) []*ECCConcepto {
Fecha: l.PurchaseDateTime.String(),
Rfc: l.VendorTaxCode.String(),
ClaveEstacion: l.ServiceStationCode.String(),
Cantidad: l.Quantity.String(),
Cantidad: l.Quantity.RescaleRange(1, 3).String(),
TipoCombustible: l.Item.Type.String(),
Unidad: l.Item.Unit.UNECE().String(),
NombreCombustible: l.Item.Name,
FolioOperacion: l.PurchaseCode.String(),
ValorUnitario: l.Item.Price.String(),
Importe: l.Total.String(),
ValorUnitario: l.Item.Price.RescaleRange(1, 3).String(),
Importe: l.Total.RescaleRange(1, 2).String(),
Traslados: newECCTraslados(l.Taxes),
}
}
Expand All @@ -100,9 +100,9 @@ func newECCTraslados(taxes []*mx.FuelAccountTax) []*ECCTraslado {
for i, t := range taxes {
tasa := ""
if t.Percent != nil {
tasa = t.Percent.Base().String()
tasa = t.Percent.Base().RescaleDown(6).String()
} else if t.Rate != nil {
tasa = t.Rate.String()
tasa = t.Rate.RescaleDown(6).String()
}
impuesto := ""
switch t.Category {
Expand All @@ -114,7 +114,7 @@ func newECCTraslados(taxes []*mx.FuelAccountTax) []*ECCTraslado {
ts[i] = &ECCTraslado{
Impuesto: impuesto,
TasaOCuota: tasa,
Importe: t.Amount.String(),
Importe: t.Amount.RescaleRange(1, 2).String(),
}
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/invopop/gobl.cfdi
go 1.20

require (
github.com/invopop/gobl v0.79.0
github.com/invopop/gobl v0.79.4-0.20240625132135-6730eea27062
github.com/joho/godotenv v1.5.1
github.com/magefile/mage v1.15.0
github.com/spf13/cobra v1.7.0
Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/invopop/gobl v0.79.0 h1:gkkWLLQPlThZbjei8Xf7te3XFV5a3h/uOiH498p9fwE=
github.com/invopop/gobl v0.79.0/go.mod h1:3ixShxX1jlOKo5Rw22HVQh3jXnK9AZa7Twcw7L92qn0=
github.com/invopop/gobl v0.79.3 h1:aXNS/COXzWdEhctUL3f0LvygAyEaqxiM20spEmFeVvE=
github.com/invopop/gobl v0.79.3/go.mod h1:3ixShxX1jlOKo5Rw22HVQh3jXnK9AZa7Twcw7L92qn0=
github.com/invopop/gobl v0.79.4-0.20240625130654-fa0f57291ebf h1:kxmeKPvPa9qUGgvflT03Ca907k131YGCLrbM9fwnf3E=
github.com/invopop/gobl v0.79.4-0.20240625130654-fa0f57291ebf/go.mod h1:3ixShxX1jlOKo5Rw22HVQh3jXnK9AZa7Twcw7L92qn0=
github.com/invopop/gobl v0.79.4-0.20240625132135-6730eea27062 h1:Bq2H/oDkc1MWipksB1xDuFl3RJmmTm58/vAR8wUqCmo=
github.com/invopop/gobl v0.79.4-0.20240625132135-6730eea27062/go.mod h1:3ixShxX1jlOKo5Rw22HVQh3jXnK9AZa7Twcw7L92qn0=
github.com/invopop/jsonschema v0.12.0 h1:6ovsNSuvn9wEQVOyc72aycBMVQFKz7cPdMJn10CvzRI=
github.com/invopop/jsonschema v0.12.0/go.mod h1:ffZ5Km5SWWRAIN6wbDXItl95euhFz2uON45H2qjYt+0=
github.com/invopop/validation v0.3.0 h1:o260kbjXzoBO/ypXDSSrCLL7SxEFUXBsX09YTE9AxZw=
Expand Down

0 comments on commit ea2f4a3

Please sign in to comment.