Skip to content

Commit

Permalink
Adding line item identities to description
Browse files Browse the repository at this point in the history
  • Loading branch information
samlown committed Dec 19, 2024
1 parent 961f55e commit ad4fdf6
Show file tree
Hide file tree
Showing 31 changed files with 500 additions and 80 deletions.
13 changes: 10 additions & 3 deletions assets/styles/invoice.css
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ section.lines td {
border-bottom: 0.5px solid #e5e7eb;
padding: 1.5mm 2mm;
margin: 0px;
vertical-align: top;
}
section.lines th {
font-weight: 600;
Expand All @@ -153,11 +154,17 @@ section.lines .reason {
section.lines .label {
font-weight: 500;
}
section.lines .description .extensions {
section.lines .description .extensions,
section.lines .description .identity {
display: block;
font-size: 10px;
}
section.lines .description .extensions .label {
font-weight: 500;
section.lines .description .extensions .label,
section.lines .description .identity .label {
font-weight: 400;
}
section.lines .description .identity .label:after {
content: ": "
}
section.lines .alt-price {
display: block;
Expand Down
7 changes: 6 additions & 1 deletion components/bill/invoice/customer_templ.go

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

10 changes: 9 additions & 1 deletion components/bill/invoice/invoice_templ.go

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

15 changes: 15 additions & 0 deletions components/bill/invoice/line_support.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package invoice

import (
"github.com/invopop/gobl/bill"
"github.com/invopop/gobl/cbc"
"github.com/invopop/gobl/org"
"github.com/invopop/gobl/tax"
)

Expand Down Expand Up @@ -65,3 +67,16 @@ func addCategory(cats []*tax.CategoryDef, cat *tax.CategoryDef) []*tax.CategoryD
}
return append(cats, cat)
}

// presentableIdentities will filter the list of identities so that
// the result only includes those that can be presented in the description
// area.
func presentableIdentities(idents []*org.Identity) []*org.Identity {
nis := make([]*org.Identity, 0)
for _, ident := range idents {
if ident.Label != "" || ident.Type != cbc.CodeEmpty {
nis = append(nis, ident)
}
}
return nis
}
21 changes: 21 additions & 0 deletions components/bill/invoice/lines.templ
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/invopop/gobl.html/components/regimes/mx"
"github.com/invopop/gobl.html/components/t"
"github.com/invopop/gobl/bill"
"github.com/invopop/gobl/org"
)

templ lines(inv *bill.Invoice) {
Expand Down Expand Up @@ -98,6 +99,7 @@ templ line(_ *bill.Invoice, l *bill.Line, ls *lineSupport) {
<br/>
<small>{ l.Item.Description }</small>
}
@identities(l.Item.Identities)
@mx.LineExtensions(l)
</td>
<td class="quantity">
Expand Down Expand Up @@ -145,6 +147,25 @@ templ line(_ *bill.Invoice, l *bill.Line, ls *lineSupport) {
</tr>
}

templ identities(idents []*org.Identity) {
if idents = presentableIdentities(idents); len(idents) > 0 {
for _, ident := range idents {
<span class="identity">
<span class="label">
if ident.Label != "" {
{ ident.Label }
} else {
{ ident.Type.String() }
}
</span>
<code>
{ ident.Code.String() }
</code>
</span>
}
}
}

templ lineItemAltPrices(l *bill.Line) {
for _, a := range l.Item.AltPrices {
<span class="alt-price">
Expand Down
Loading

0 comments on commit ad4fdf6

Please sign in to comment.