From fe53dd5e04a077e4b28854a4dc7d275075c443ca Mon Sep 17 00:00:00 2001 From: Javier Martinez Date: Thu, 12 Dec 2024 15:55:14 +0000 Subject: [PATCH] upgrade to GOBL v0.207.0 --- components/bill/invoice/helpers.go | 2 +- components/bill/invoice/line_support.go | 4 +- components/bill/invoice/lines.templ | 13 +++--- components/bill/invoice/lines_templ.go | 33 ++++++++-------- components/bill/invoice/payment.templ | 2 +- components/bill/invoice/payment_templ.go | 4 +- components/bill/invoice/summary.templ | 3 +- components/bill/invoice/summary_templ.go | 19 +++++---- components/bill/invoice/totals.templ | 23 ----------- components/bill/invoice/totals_templ.go | 35 ----------------- components/org/address.templ | 7 ++-- components/org/address_templ.go | 7 ++-- components/org/party.templ | 2 +- components/org/party_templ.go | 2 +- components/regimes/co/dian.templ | 17 ++++---- components/regimes/co/dian_templ.go | 11 +++--- components/regimes/es/verifactu.templ | 37 +++++------------- components/regimes/es/verifactu_templ.go | 50 +++++------------------- examples/invoice-es-verifactu.json | 4 -- examples/out/full-invoice.html | 8 ---- go.mod | 2 +- go.sum | 4 ++ 22 files changed, 84 insertions(+), 205 deletions(-) diff --git a/components/bill/invoice/helpers.go b/components/bill/invoice/helpers.go index 40996b7..b5648ef 100644 --- a/components/bill/invoice/helpers.go +++ b/components/bill/invoice/helpers.go @@ -7,7 +7,7 @@ import ( // HasHeaderQR returns a boolean indicating whether the envelope has some QR codes to be displayed in the header or not. func HasHeaderQR(env *gobl.Envelope) bool { - hasVerifactu, _, _ := es.HasVerifactuQR(env) + hasVerifactu, _ := es.HasVerifactuQR(env) hasTicketBAI, _, _ := es.HasTicketBAIQR(env) return hasVerifactu || hasTicketBAI } diff --git a/components/bill/invoice/line_support.go b/components/bill/invoice/line_support.go index 5673a21..4be2ab0 100644 --- a/components/bill/invoice/line_support.go +++ b/components/bill/invoice/line_support.go @@ -41,12 +41,12 @@ func prepareLineSupport(inv *bill.Invoice) *lineSupport { } } for _, row := range inv.Discounts { - if row.Ref != "" { + if row.Code != "" { ls.refs = true } } for _, row := range inv.Charges { - if row.Ref != "" { + if row.Code != "" { ls.refs = true } } diff --git a/components/bill/invoice/lines.templ b/components/bill/invoice/lines.templ index 7163ad2..98c2fb4 100644 --- a/components/bill/invoice/lines.templ +++ b/components/bill/invoice/lines.templ @@ -2,10 +2,9 @@ package invoice import ( "fmt" - - "github.com/invopop/gobl/bill" - "github.com/invopop/gobl.html/components/t" "github.com/invopop/gobl.html/components/regimes/mx" + "github.com/invopop/gobl.html/components/t" + "github.com/invopop/gobl/bill" ) templ lines(inv *bill.Invoice) { @@ -191,8 +190,8 @@ templ discountRow(row *bill.Discount, ls *lineSupport) { if ls.refs { - if row.Ref != "" { - { row.Ref } + if row.Code != "" { + { row.Code.String() } } else { } @@ -262,8 +261,8 @@ templ chargeRow(row *bill.Charge, ls *lineSupport) { if ls.refs { - if row.Ref != "" { - { row.Ref } + if row.Code != "" { + { row.Code.String() } } else { } diff --git a/components/bill/invoice/lines_templ.go b/components/bill/invoice/lines_templ.go index f8f8d68..4db5a50 100644 --- a/components/bill/invoice/lines_templ.go +++ b/components/bill/invoice/lines_templ.go @@ -10,7 +10,6 @@ import templruntime "github.com/a-h/templ/runtime" import ( "fmt" - "github.com/invopop/gobl.html/components/regimes/mx" "github.com/invopop/gobl.html/components/t" "github.com/invopop/gobl/bill" @@ -166,7 +165,7 @@ func linesWithSupport(inv *bill.Invoice, ls *lineSupport) templ.Component { var templ_7745c5c3_Var4 string templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(cat.Name.In(t.Lang(ctx))) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/lines.templ`, Line: 49, Col: 33} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/lines.templ`, Line: 48, Col: 33} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) if templ_7745c5c3_Err != nil { @@ -298,7 +297,7 @@ func line(_ *bill.Invoice, l *bill.Line, ls *lineSupport) templ.Component { var templ_7745c5c3_Var7 string templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprint(l.Index)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/lines.templ`, Line: 85, Col: 24} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/lines.templ`, Line: 84, Col: 24} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) if templ_7745c5c3_Err != nil { @@ -317,7 +316,7 @@ func line(_ *bill.Invoice, l *bill.Line, ls *lineSupport) templ.Component { var templ_7745c5c3_Var8 string templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(l.Item.Ref) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/lines.templ`, Line: 90, Col: 17} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/lines.templ`, Line: 89, Col: 17} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8)) if templ_7745c5c3_Err != nil { @@ -341,7 +340,7 @@ func line(_ *bill.Invoice, l *bill.Line, ls *lineSupport) templ.Component { var templ_7745c5c3_Var9 string templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(l.Item.Name) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/lines.templ`, Line: 97, Col: 22} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/lines.templ`, Line: 96, Col: 22} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9)) if templ_7745c5c3_Err != nil { @@ -359,7 +358,7 @@ func line(_ *bill.Invoice, l *bill.Line, ls *lineSupport) templ.Component { var templ_7745c5c3_Var10 string templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(l.Item.Description) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/lines.templ`, Line: 100, Col: 31} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/lines.templ`, Line: 99, Col: 31} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10)) if templ_7745c5c3_Err != nil { @@ -395,7 +394,7 @@ func line(_ *bill.Invoice, l *bill.Line, ls *lineSupport) templ.Component { var templ_7745c5c3_Var11 string templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(string(l.Item.Unit)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/lines.templ`, Line: 110, Col: 26} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/lines.templ`, Line: 109, Col: 26} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11)) if templ_7745c5c3_Err != nil { @@ -669,7 +668,7 @@ func discountRow(row *bill.Discount, ls *lineSupport) templ.Component { var templ_7745c5c3_Var17 string templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("D%d", row.Index)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/lines.templ`, Line: 190, Col: 34} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/lines.templ`, Line: 189, Col: 34} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17)) if templ_7745c5c3_Err != nil { @@ -684,11 +683,11 @@ func discountRow(row *bill.Discount, ls *lineSupport) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - if row.Ref != "" { + if row.Code != "" { var templ_7745c5c3_Var18 string - templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(row.Ref) + templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(row.Code.String()) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/lines.templ`, Line: 195, Col: 14} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/lines.templ`, Line: 194, Col: 24} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18)) if templ_7745c5c3_Err != nil { @@ -712,7 +711,7 @@ func discountRow(row *bill.Discount, ls *lineSupport) templ.Component { var templ_7745c5c3_Var19 string templ_7745c5c3_Var19, templ_7745c5c3_Err = templ.JoinStringErrs(row.Reason) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/lines.templ`, Line: 202, Col: 15} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/lines.templ`, Line: 201, Col: 15} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var19)) if templ_7745c5c3_Err != nil { @@ -866,7 +865,7 @@ func chargeRow(row *bill.Charge, ls *lineSupport) templ.Component { var templ_7745c5c3_Var22 string templ_7745c5c3_Var22, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("C%d", row.Index)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/lines.templ`, Line: 261, Col: 34} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/lines.templ`, Line: 260, Col: 34} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var22)) if templ_7745c5c3_Err != nil { @@ -881,11 +880,11 @@ func chargeRow(row *bill.Charge, ls *lineSupport) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - if row.Ref != "" { + if row.Code != "" { var templ_7745c5c3_Var23 string - templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(row.Ref) + templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(row.Code.String()) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/lines.templ`, Line: 266, Col: 14} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/lines.templ`, Line: 265, Col: 24} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23)) if templ_7745c5c3_Err != nil { @@ -909,7 +908,7 @@ func chargeRow(row *bill.Charge, ls *lineSupport) templ.Component { var templ_7745c5c3_Var24 string templ_7745c5c3_Var24, templ_7745c5c3_Err = templ.JoinStringErrs(row.Reason) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/lines.templ`, Line: 273, Col: 15} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/lines.templ`, Line: 272, Col: 15} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var24)) if templ_7745c5c3_Err != nil { diff --git a/components/bill/invoice/payment.templ b/components/bill/invoice/payment.templ index be391fb..e943227 100644 --- a/components/bill/invoice/payment.templ +++ b/components/bill/invoice/payment.templ @@ -45,7 +45,7 @@ templ paymentInstructions(inst *pay.Instructions) { @t.T(".ref") - { inst.Ref } + { inst.Ref.String() } } diff --git a/components/bill/invoice/payment_templ.go b/components/bill/invoice/payment_templ.go index 8aecdab..db235c8 100644 --- a/components/bill/invoice/payment_templ.go +++ b/components/bill/invoice/payment_templ.go @@ -161,9 +161,9 @@ func paymentInstructions(inst *pay.Instructions) templ.Component { return templ_7745c5c3_Err } var templ_7745c5c3_Var6 string - templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(inst.Ref) + templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(inst.Ref.String()) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/payment.templ`, Line: 48, Col: 16} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/payment.templ`, Line: 48, Col: 25} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6)) if templ_7745c5c3_Err != nil { diff --git a/components/bill/invoice/summary.templ b/components/bill/invoice/summary.templ index 8c3b918..f5d983c 100644 --- a/components/bill/invoice/summary.templ +++ b/components/bill/invoice/summary.templ @@ -8,7 +8,6 @@ import ( "github.com/invopop/gobl/cal" "github.com/invopop/gobl/cbc" "github.com/invopop/gobl/currency" - "github.com/invopop/gobl/tax" "strings" ) @@ -150,7 +149,7 @@ func currencyName(ctx context.Context, cur currency.Code) string { return i18n.T(ctx, "billing.invoice.summary.currency_value", i18n.M{"desc": name, "code": cur}) } -func mapTaxExtension(ctx context.Context, k cbc.Key, v tax.ExtValue) string { +func mapTaxExtension(ctx context.Context, k cbc.Key, v cbc.Code) string { // find the key translation label := i18n.T(ctx, ".ext_map."+k.String()) if strings.HasPrefix(label, "!") { // if match found diff --git a/components/bill/invoice/summary_templ.go b/components/bill/invoice/summary_templ.go index de1116f..c50bf6f 100644 --- a/components/bill/invoice/summary_templ.go +++ b/components/bill/invoice/summary_templ.go @@ -16,7 +16,6 @@ import ( "github.com/invopop/gobl/cal" "github.com/invopop/gobl/cbc" "github.com/invopop/gobl/currency" - "github.com/invopop/gobl/tax" "strings" ) @@ -93,7 +92,7 @@ func summary(inv *bill.Invoice) templ.Component { var templ_7745c5c3_Var3 string templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(currencyName(ctx, inv.Currency)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/summary.templ`, Line: 35, Col: 39} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/summary.templ`, Line: 34, Col: 39} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) if templ_7745c5c3_Err != nil { @@ -163,7 +162,7 @@ func summary(inv *bill.Invoice) templ.Component { var templ_7745c5c3_Var4 string templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(code(pre.Series, pre.Code)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/summary.templ`, Line: 64, Col: 35} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/summary.templ`, Line: 63, Col: 35} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) if templ_7745c5c3_Err != nil { @@ -195,7 +194,7 @@ func summary(inv *bill.Invoice) templ.Component { var templ_7745c5c3_Var5 string templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(pre.Reason) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/summary.templ`, Line: 73, Col: 20} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/summary.templ`, Line: 72, Col: 20} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) if templ_7745c5c3_Err != nil { @@ -227,7 +226,7 @@ func summary(inv *bill.Invoice) templ.Component { var templ_7745c5c3_Var6 string templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(label) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/summary.templ`, Line: 86, Col: 16} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/summary.templ`, Line: 85, Col: 16} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6)) if templ_7745c5c3_Err != nil { @@ -240,7 +239,7 @@ func summary(inv *bill.Invoice) templ.Component { var templ_7745c5c3_Var7 string templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(v.String()) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/summary.templ`, Line: 89, Col: 21} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/summary.templ`, Line: 88, Col: 21} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) if templ_7745c5c3_Err != nil { @@ -305,7 +304,7 @@ func summaryOrderingRows(inv *bill.Invoice) templ.Component { var templ_7745c5c3_Var9 string templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(inv.Ordering.Code.String()) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/summary.templ`, Line: 107, Col: 32} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/summary.templ`, Line: 106, Col: 32} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9)) if templ_7745c5c3_Err != nil { @@ -331,7 +330,7 @@ func summaryOrderingRows(inv *bill.Invoice) templ.Component { var templ_7745c5c3_Var10 string templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(ident.Label) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/summary.templ`, Line: 118, Col: 18} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/summary.templ`, Line: 117, Col: 18} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10)) if templ_7745c5c3_Err != nil { @@ -344,7 +343,7 @@ func summaryOrderingRows(inv *bill.Invoice) templ.Component { var templ_7745c5c3_Var11 string templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(ident.Code.String()) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/summary.templ`, Line: 121, Col: 26} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/summary.templ`, Line: 120, Col: 26} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11)) if templ_7745c5c3_Err != nil { @@ -419,7 +418,7 @@ func currencyName(ctx context.Context, cur currency.Code) string { return i18n.T(ctx, "billing.invoice.summary.currency_value", i18n.M{"desc": name, "code": cur}) } -func mapTaxExtension(ctx context.Context, k cbc.Key, v tax.ExtValue) string { +func mapTaxExtension(ctx context.Context, k cbc.Key, v cbc.Code) string { // find the key translation label := i18n.T(ctx, ".ext_map."+k.String()) if strings.HasPrefix(label, "!") { // if match found diff --git a/components/bill/invoice/totals.templ b/components/bill/invoice/totals.templ index 9fbd61f..946c278 100644 --- a/components/bill/invoice/totals.templ +++ b/components/bill/invoice/totals.templ @@ -99,18 +99,6 @@ templ totalsBaseRows(inv *bill.Invoice, totals *bill.Totals) { } templ totalsPayableRows(inv *bill.Invoice, totals *bill.Totals) { - if totals.Outlays != nil { - for _, o := range inv.Outlays { - - - @t.T(".outlay", i18n.M{"i": o.Index, "txt": outlayText(o)}) - - - @t.LM(o.Amount) - - - } - } if inv.Type.In(bill.InvoiceTypeCreditNote) { @@ -204,14 +192,3 @@ func advanceMap(adv *pay.Advance) i18n.M { } return i18n.M{"date": date, "txt": txt} } - -func outlayText(outlay *bill.Outlay) string { - txt := outlay.Description - if outlay.Code != "" { - txt = outlay.Code + " " + txt - } - if outlay.Date != nil { - txt += " " + outlay.Date.String() - } - return txt -} diff --git a/components/bill/invoice/totals_templ.go b/components/bill/invoice/totals_templ.go index 8f2147e..08e32b3 100644 --- a/components/bill/invoice/totals_templ.go +++ b/components/bill/invoice/totals_templ.go @@ -286,30 +286,6 @@ func totalsPayableRows(inv *bill.Invoice, totals *bill.Totals) templ.Component { templ_7745c5c3_Var4 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - if totals.Outlays != nil { - for _, o := range inv.Outlays { - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = t.T(".outlay", i18n.M{"i": o.Index, "txt": outlayText(o)}).Render(ctx, templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = t.LM(o.Amount).Render(ctx, templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - } - } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err @@ -493,14 +469,3 @@ func advanceMap(adv *pay.Advance) i18n.M { } return i18n.M{"date": date, "txt": txt} } - -func outlayText(outlay *bill.Outlay) string { - txt := outlay.Description - if outlay.Code != "" { - txt = outlay.Code + " " + txt - } - if outlay.Date != nil { - txt += " " + outlay.Date.String() - } - return txt -} diff --git a/components/org/address.templ b/components/org/address.templ index 18159d8..a116943 100644 --- a/components/org/address.templ +++ b/components/org/address.templ @@ -1,11 +1,10 @@ package org import ( - "strings" - "github.com/invopop/ctxi18n/i18n" - "github.com/invopop/gobl/org" "github.com/invopop/gobl.html/components/t" + "github.com/invopop/gobl/org" + "strings" ) templ Address(addr *org.Address) { @@ -52,7 +51,7 @@ func buildAddressLines(addr *org.Address) []string { lines = append(lines, addr.Region) } if addr.Code != "" { - lines = append(lines, addr.Code) + lines = append(lines, addr.Code.String()) } return lines } diff --git a/components/org/address_templ.go b/components/org/address_templ.go index 43d2997..09e8c33 100644 --- a/components/org/address_templ.go +++ b/components/org/address_templ.go @@ -9,11 +9,10 @@ import "github.com/a-h/templ" import templruntime "github.com/a-h/templ/runtime" import ( - "strings" - "github.com/invopop/ctxi18n/i18n" "github.com/invopop/gobl.html/components/t" "github.com/invopop/gobl/org" + "strings" ) func Address(addr *org.Address) templ.Component { @@ -124,7 +123,7 @@ func addressLines(addr *org.Address) templ.Component { var templ_7745c5c3_Var4 string templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(txt) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/org/address.templ`, Line: 32, Col: 8} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/org/address.templ`, Line: 31, Col: 8} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) if templ_7745c5c3_Err != nil { @@ -164,7 +163,7 @@ func buildAddressLines(addr *org.Address) []string { lines = append(lines, addr.Region) } if addr.Code != "" { - lines = append(lines, addr.Code) + lines = append(lines, addr.Code.String()) } return lines } diff --git a/components/org/party.templ b/components/org/party.templ index 1ee7f07..9435847 100644 --- a/components/org/party.templ +++ b/components/org/party.templ @@ -196,7 +196,7 @@ func taxIDCode(party *org.Party) string { } } -func mapPartyExtension(ctx context.Context, k cbc.Key, v tax.ExtValue) string { +func mapPartyExtension(ctx context.Context, k cbc.Key, v cbc.Code) string { // find the key translation label := i18n.T(ctx, ".ext_map."+k.String()) if !strings.HasPrefix(label, "!") { // if match found diff --git a/components/org/party_templ.go b/components/org/party_templ.go index 7048f4d..5d9d23b 100644 --- a/components/org/party_templ.go +++ b/components/org/party_templ.go @@ -569,7 +569,7 @@ func taxIDCode(party *org.Party) string { } } -func mapPartyExtension(ctx context.Context, k cbc.Key, v tax.ExtValue) string { +func mapPartyExtension(ctx context.Context, k cbc.Key, v cbc.Code) string { // find the key translation label := i18n.T(ctx, ".ext_map."+k.String()) if !strings.HasPrefix(label, "!") { // if match found diff --git a/components/regimes/co/dian.templ b/components/regimes/co/dian.templ index 113f2b8..dfc4f1b 100644 --- a/components/regimes/co/dian.templ +++ b/components/regimes/co/dian.templ @@ -1,14 +1,13 @@ package co import ( - "regexp" - - "github.com/invopop/gobl" - "github.com/invopop/gobl/bill" - "github.com/invopop/gobl/regimes/co" - "github.com/invopop/gobl.html/components/t" "github.com/invopop/ctxi18n/i18n" + "github.com/invopop/gobl" "github.com/invopop/gobl.html/components/images" + "github.com/invopop/gobl.html/components/t" + "github.com/invopop/gobl/addons/co/dian" + "github.com/invopop/gobl/bill" + "regexp" ) var dianQRHTTPRegexp = regexp.MustCompile(`https.+`) @@ -70,7 +69,7 @@ func dianURL(qr string) string { func dianCUDE(env *gobl.Envelope) string { for _, stamp := range env.Head.Stamps { switch stamp.Provider { - case co.StampProviderDIANCUDE: + case dian.StampCUDE: return stamp.Value } } @@ -83,7 +82,7 @@ func dianPrecedingCUDE(inv *bill.Invoice) string { } for _, stamp := range inv.Preceding[0].Stamps { switch stamp.Provider { - case co.StampProviderDIANCUDE: + case dian.StampCUDE: return stamp.Value } } @@ -93,7 +92,7 @@ func dianPrecedingCUDE(inv *bill.Invoice) string { func dianQR(env *gobl.Envelope) string { for _, stamp := range env.Head.Stamps { switch stamp.Provider { - case co.StampProviderDIANQR: + case dian.StampQR: return stamp.Value } } diff --git a/components/regimes/co/dian_templ.go b/components/regimes/co/dian_templ.go index 3eefcc9..1634c45 100644 --- a/components/regimes/co/dian_templ.go +++ b/components/regimes/co/dian_templ.go @@ -9,14 +9,13 @@ import "github.com/a-h/templ" import templruntime "github.com/a-h/templ/runtime" import ( - "regexp" - "github.com/invopop/ctxi18n/i18n" "github.com/invopop/gobl" "github.com/invopop/gobl.html/components/images" "github.com/invopop/gobl.html/components/t" + "github.com/invopop/gobl/addons/co/dian" "github.com/invopop/gobl/bill" - "github.com/invopop/gobl/regimes/co" + "regexp" ) var dianQRHTTPRegexp = regexp.MustCompile(`https.+`) @@ -140,7 +139,7 @@ func dianURL(qr string) string { func dianCUDE(env *gobl.Envelope) string { for _, stamp := range env.Head.Stamps { switch stamp.Provider { - case co.StampProviderDIANCUDE: + case dian.StampCUDE: return stamp.Value } } @@ -153,7 +152,7 @@ func dianPrecedingCUDE(inv *bill.Invoice) string { } for _, stamp := range inv.Preceding[0].Stamps { switch stamp.Provider { - case co.StampProviderDIANCUDE: + case dian.StampCUDE: return stamp.Value } } @@ -163,7 +162,7 @@ func dianPrecedingCUDE(inv *bill.Invoice) string { func dianQR(env *gobl.Envelope) string { for _, stamp := range env.Head.Stamps { switch stamp.Provider { - case co.StampProviderDIANQR: + case dian.StampQR: return stamp.Value } } diff --git a/components/regimes/es/verifactu.templ b/components/regimes/es/verifactu.templ index bee1767..9609b55 100644 --- a/components/regimes/es/verifactu.templ +++ b/components/regimes/es/verifactu.templ @@ -3,33 +3,26 @@ package es import ( "github.com/invopop/gobl" "github.com/invopop/gobl.html/components/images" - "github.com/invopop/gobl/cbc" -) - -const ( - verifactuStampCode cbc.Key = "verifactu-code" - verifactuStampQR cbc.Key = "verifactu-qr" + "github.com/invopop/gobl/addons/es/verifactu" ) // VerifactuQR generates a QR code area for the Verifactu code in the given envelope. templ VerifactuQR(env *gobl.Envelope) { - if result, code, qr := HasVerifactuQR(env); result { - @generateVerifactuQR(code, qr) + if result, qr := HasVerifactuQR(env); result { + @generateVerifactuQR(qr) } } // HasVerifactuQR returns a boolean indicating whether the envelope has a Verifactu QR or not. -func HasVerifactuQR(env *gobl.Envelope) (bool, string, string) { - if code := verifactuCode(env); code != "" { - if qr := verifactuQR(env); qr != "" { - return true, code, qr - } +func HasVerifactuQR(env *gobl.Envelope) (bool, string) { + if qr := verifactuQR(env); qr != "" { + return true, qr } - return false, "", "" + return false, "" } -templ generateVerifactuQR(code, qr string) { +templ generateVerifactuQR(qr string) {