Skip to content
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

Add Veri*factu invoice and new layout for displaying QRs at the top #21

Merged
merged 9 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
345 changes: 186 additions & 159 deletions assets/styles/invoice.css

Large diffs are not rendered by default.

7 changes: 1 addition & 6 deletions components/bill/invoice/customer_templ.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 16 additions & 2 deletions components/bill/invoice/invoice.templ
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@ import (
templ Invoice(env *gobl.Envelope, inv *bill.Invoice) {
// Footer needs to be at the top to show on all pages
<article class="invoice">
<header>
<header class={ headerClass(env) }>
<div class="details">
@title(inv)
@summary(inv)
</div>
// Spanish QRs
@es.VerifactuQR(env)
@es.TicketBAIQR(env)
<div class="contacts">
@supplier(inv)
if inv.Customer != nil {
Expand All @@ -44,7 +47,6 @@ templ Invoice(env *gobl.Envelope, inv *bill.Invoice) {
@notes(inv)
<div class="extensions">
// Region specific information
@es.TicketBAIQR(env)
@co.DIANQR(env, inv)
@mx.CFDI(env, inv)
@pl.KSeFQR(env)
Expand Down Expand Up @@ -120,3 +122,15 @@ func code(series, code cbc.Code) string {
}
return fmt.Sprintf("%s-%s", series, code)
}

func hasHeaderQR(env *gobl.Envelope) bool {
return es.HasVerifactuQR(env) || es.HasTicketBAIQR(env)
}

func headerClass(env *gobl.Envelope) string {
if hasHeaderQR(env) {
return "with-qr"
}

return "regular"
}
112 changes: 73 additions & 39 deletions components/bill/invoice/invoice_templ.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions components/bill/invoice/line_support.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
13 changes: 6 additions & 7 deletions components/bill/invoice/lines.templ
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -191,8 +190,8 @@ templ discountRow(row *bill.Discount, ls *lineSupport) {
</td>
if ls.refs {
<td class="ref">
if row.Ref != "" {
{ row.Ref }
if row.Code != "" {
{ row.Code.String() }
} else {
<!-- empty -->
}
Expand Down Expand Up @@ -262,8 +261,8 @@ templ chargeRow(row *bill.Charge, ls *lineSupport) {
</td>
if ls.refs {
<td class="ref">
if row.Ref != "" {
{ row.Ref }
if row.Code != "" {
{ row.Code.String() }
} else {
<!-- empty -->
}
Expand Down
Loading
Loading