")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -177,7 +177,7 @@ func title(inv *bill.Invoice) templ.Component {
var templ_7745c5c3_Var3 string
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(supplierAlias(inv))
if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/invoice.templ`, Line: 320, Col: 25}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/invoice.templ`, Line: 55, Col: 25}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
if templ_7745c5c3_Err != nil {
@@ -203,7 +203,7 @@ func title(inv *bill.Invoice) templ.Component {
var templ_7745c5c3_Var4 string
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(code(inv.Series, inv.Code))
if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/invoice.templ`, Line: 328, Col: 31}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/invoice.templ`, Line: 63, Col: 31}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
if templ_7745c5c3_Err != nil {
diff --git a/components/bill/invoice/lines.templ b/components/bill/invoice/lines.templ
index 950d3d3..99b43e6 100644
--- a/components/bill/invoice/lines.templ
+++ b/components/bill/invoice/lines.templ
@@ -115,6 +115,7 @@ templ line(_ *bill.Invoice, l *bill.Line, ls *lineSupport) {
}
@t.LM(l.Item.Price)
+ @lineItemAltPrices(l)
|
for _, cat := range ls.categories {
@@ -145,6 +146,14 @@ templ line(_ *bill.Invoice, l *bill.Line, ls *lineSupport) {
}
+templ lineItemAltPrices(l *bill.Line) {
+ for _, a := range l.Item.AltPrices {
+
+ @t.LCD(a.Value, a.Currency)
+
+ }
+}
+
templ lineGroupDiscounts(l *bill.Line) {
for _, d := range l.Discounts {
if d.Percent != nil {
diff --git a/components/bill/invoice/lines_templ.go b/components/bill/invoice/lines_templ.go
index 13616d2..d138230 100644
--- a/components/bill/invoice/lines_templ.go
+++ b/components/bill/invoice/lines_templ.go
@@ -408,6 +408,10 @@ func line(_ *bill.Invoice, l *bill.Line, ls *lineSupport) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
+ templ_7745c5c3_Err = lineItemAltPrices(l).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
@@ -487,7 +491,7 @@ func line(_ *bill.Invoice, l *bill.Line, ls *lineSupport) templ.Component {
})
}
-func lineGroupDiscounts(l *bill.Line) templ.Component {
+func lineItemAltPrices(l *bill.Line) templ.Component {
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
if !templ_7745c5c3_IsBuffer {
@@ -500,6 +504,40 @@ func lineGroupDiscounts(l *bill.Line) templ.Component {
templ_7745c5c3_Var12 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
+ for _, a := range l.Item.AltPrices {
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = t.LCD(a.Value, a.Currency).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
+ }
+ }
+ if !templ_7745c5c3_IsBuffer {
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
+ }
+ return templ_7745c5c3_Err
+ })
+}
+
+func lineGroupDiscounts(l *bill.Line) templ.Component {
+ return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
+ templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
+ if !templ_7745c5c3_IsBuffer {
+ templ_7745c5c3_Buffer = templ.GetBuffer()
+ defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
+ }
+ ctx = templ.InitializeContext(ctx)
+ templ_7745c5c3_Var13 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var13 == nil {
+ templ_7745c5c3_Var13 = templ.NopComponent
+ }
+ ctx = templ.ClearChildren(ctx)
for _, d := range l.Discounts {
if d.Percent != nil {
templ_7745c5c3_Err = t.L(*d.Percent).Render(ctx, templ_7745c5c3_Buffer)
@@ -528,9 +566,9 @@ func lineGroupCharges(l *bill.Line) templ.Component {
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
}
ctx = templ.InitializeContext(ctx)
- templ_7745c5c3_Var13 := templ.GetChildren(ctx)
- if templ_7745c5c3_Var13 == nil {
- templ_7745c5c3_Var13 = templ.NopComponent
+ templ_7745c5c3_Var14 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var14 == nil {
+ templ_7745c5c3_Var14 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
for _, c := range l.Charges {
@@ -561,9 +599,9 @@ func discountsBody(inv *bill.Invoice, ls *lineSupport) templ.Component {
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
}
ctx = templ.InitializeContext(ctx)
- templ_7745c5c3_Var14 := templ.GetChildren(ctx)
- if templ_7745c5c3_Var14 == nil {
- templ_7745c5c3_Var14 = templ.NopComponent
+ templ_7745c5c3_Var15 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var15 == nil {
+ templ_7745c5c3_Var15 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
if len(inv.Discounts) > 0 {
@@ -597,21 +635,21 @@ func discountRow(row *bill.Discount, ls *lineSupport) templ.Component {
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
}
ctx = templ.InitializeContext(ctx)
- templ_7745c5c3_Var15 := templ.GetChildren(ctx)
- if templ_7745c5c3_Var15 == nil {
- templ_7745c5c3_Var15 = templ.NopComponent
+ templ_7745c5c3_Var16 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var16 == nil {
+ templ_7745c5c3_Var16 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
- var templ_7745c5c3_Var16 string
- templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("D%d", row.Index))
+ 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: 180, 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_Var16))
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -625,12 +663,12 @@ func discountRow(row *bill.Discount, ls *lineSupport) templ.Component {
return templ_7745c5c3_Err
}
if row.Ref != "" {
- var templ_7745c5c3_Var17 string
- templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(row.Ref)
+ var templ_7745c5c3_Var18 string
+ templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(row.Ref)
if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/lines.templ`, Line: 185, Col: 14}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/lines.templ`, Line: 194, Col: 14}
}
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17))
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -649,12 +687,12 @@ func discountRow(row *bill.Discount, ls *lineSupport) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
- var templ_7745c5c3_Var18 string
- templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(row.Reason)
+ 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: 192, 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_Var18))
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var19))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -747,9 +785,9 @@ func chargesBody(inv *bill.Invoice, ls *lineSupport) templ.Component {
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
}
ctx = templ.InitializeContext(ctx)
- templ_7745c5c3_Var19 := templ.GetChildren(ctx)
- if templ_7745c5c3_Var19 == nil {
- templ_7745c5c3_Var19 = templ.NopComponent
+ templ_7745c5c3_Var20 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var20 == nil {
+ templ_7745c5c3_Var20 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
if len(inv.Charges) > 0 {
@@ -783,21 +821,21 @@ func chargeRow(row *bill.Charge, ls *lineSupport) templ.Component {
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
}
ctx = templ.InitializeContext(ctx)
- templ_7745c5c3_Var20 := templ.GetChildren(ctx)
- if templ_7745c5c3_Var20 == nil {
- templ_7745c5c3_Var20 = templ.NopComponent
+ templ_7745c5c3_Var21 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var21 == nil {
+ templ_7745c5c3_Var21 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" |
")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
- var templ_7745c5c3_Var21 string
- templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("C%d", row.Index))
+ 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: 247, Col: 34}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/lines.templ`, Line: 256, Col: 34}
}
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21))
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var22))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -811,12 +849,12 @@ func chargeRow(row *bill.Charge, ls *lineSupport) templ.Component {
return templ_7745c5c3_Err
}
if row.Ref != "" {
- var templ_7745c5c3_Var22 string
- templ_7745c5c3_Var22, templ_7745c5c3_Err = templ.JoinStringErrs(row.Ref)
+ var templ_7745c5c3_Var23 string
+ templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(row.Ref)
if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/lines.templ`, Line: 252, Col: 14}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/lines.templ`, Line: 261, Col: 14}
}
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var22))
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -835,12 +873,12 @@ func chargeRow(row *bill.Charge, ls *lineSupport) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
- var templ_7745c5c3_Var23 string
- templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(row.Reason)
+ 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: 259, Col: 15}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/bill/invoice/lines.templ`, Line: 268, Col: 15}
}
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23))
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var24))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
diff --git a/components/bill/invoice/totals.templ b/components/bill/invoice/totals.templ
index fb44365..1091e58 100644
--- a/components/bill/invoice/totals.templ
+++ b/components/bill/invoice/totals.templ
@@ -4,6 +4,7 @@ import (
"fmt"
"github.com/invopop/gobl/bill"
+ "github.com/invopop/gobl/currency"
"github.com/invopop/gobl.html/components/t"
"github.com/invopop/ctxi18n/i18n"
"github.com/invopop/gobl/pay"
@@ -124,6 +125,16 @@ templ totalsPayableRows(inv *bill.Invoice, totals *bill.Totals) {
@t.LM(totals.Payable)
|
+ for _, er := range totalExchangeRates(inv) {
+
+
+ @t.T(".exchange_rate", i18n.M{"to": er.To, "amount": t.Localize(ctx, er.Amount)})
+ |
+
+ @t.LCD(er.Convert(totals.Payable), er.To)
+ |
+
+ }
}
templ totalsDueRows(inv *bill.Invoice, totals *bill.Totals) {
@@ -159,6 +170,16 @@ templ totalsDueRows(inv *bill.Invoice, totals *bill.Totals) {
}
}
+func totalExchangeRates(inv *bill.Invoice) []*currency.ExchangeRate {
+ list := make([]*currency.ExchangeRate, 0, len(inv.ExchangeRates))
+ for _, er := range inv.ExchangeRates {
+ if er.From == inv.Currency {
+ list = append(list, er)
+ }
+ }
+ return list
+}
+
func advanceMap(adv *pay.Advance) i18n.M {
txt := adv.Description
if adv.Ref != "" {
diff --git a/components/bill/invoice/totals_templ.go b/components/bill/invoice/totals_templ.go
index 05f14ac..4313669 100644
--- a/components/bill/invoice/totals_templ.go
+++ b/components/bill/invoice/totals_templ.go
@@ -16,6 +16,7 @@ import (
"github.com/invopop/ctxi18n/i18n"
"github.com/invopop/gobl.html/components/t"
"github.com/invopop/gobl/bill"
+ "github.com/invopop/gobl/currency"
"github.com/invopop/gobl/pay"
)
@@ -330,6 +331,28 @@ func totalsPayableRows(inv *bill.Invoice, totals *bill.Totals) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
+ for _, er := range totalExchangeRates(inv) {
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = t.T(".exchange_rate", i18n.M{"to": er.To, "amount": t.Localize(ctx, er.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 = t.LCD(er.Convert(totals.Payable), er.To).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
+ }
+ }
if !templ_7745c5c3_IsBuffer {
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
}
@@ -427,6 +450,16 @@ func totalsDueRows(inv *bill.Invoice, totals *bill.Totals) templ.Component {
})
}
+func totalExchangeRates(inv *bill.Invoice) []*currency.ExchangeRate {
+ list := make([]*currency.ExchangeRate, 0, len(inv.ExchangeRates))
+ for _, er := range inv.ExchangeRates {
+ if er.From == inv.Currency {
+ list = append(list, er)
+ }
+ }
+ return list
+}
+
func advanceMap(adv *pay.Advance) i18n.M {
txt := adv.Description
if adv.Ref != "" {
diff --git a/components/envelope.templ b/components/envelope.templ
index 27ab13a..e15a988 100644
--- a/components/envelope.templ
+++ b/components/envelope.templ
@@ -1,11 +1,17 @@
package components
import (
+ "fmt"
+ "io/fs"
+ "path/filepath"
+
"github.com/invopop/gobl"
"github.com/invopop/gobl/bill"
"github.com/invopop/gobl/note"
"github.com/invopop/gobl.html/components/bill/invoice"
"github.com/invopop/gobl.html/components/notes"
+ "github.com/invopop/gobl.html/assets"
+ "github.com/invopop/gobl.html/internal"
)
templ Envelope(env *gobl.Envelope) {
@@ -17,57 +23,7 @@ templ Envelope(env *gobl.Envelope) {
-
+ @stylesheets()
@@ -86,3 +42,53 @@ templ Envelope(env *gobl.Envelope) {