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

GOBL 0.200 #18

Merged
merged 3 commits into from
Sep 26, 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
2 changes: 1 addition & 1 deletion assets/styles/invoice.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ section.title .hero img {
}
section.title span.paid {
font-size: 9pt;
font-weight: 600;
font-weight: 400;
vertical-align: text-bottom;
padding: 0.5mm 1.5mm;
border-radius: 1mm;
Expand Down
7 changes: 4 additions & 3 deletions components/bill/invoice/invoice.templ
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/invopop/gobl.html/components/t"
"github.com/invopop/gobl.html/internal"
"github.com/invopop/gobl/bill"
"github.com/invopop/gobl/cbc"
"github.com/invopop/gobl/org"
"github.com/invopop/gobl/tax"
)
Expand Down Expand Up @@ -82,7 +83,7 @@ templ title(inv *bill.Invoice) {

func i18nTitleTag(inv *bill.Invoice) string {
typ := string(inv.Type)
if inv.Tax.ContainsTag(tax.TagSimplified) && inv.Type == bill.InvoiceTypeStandard {
if inv.HasTags(tax.TagSimplified) && inv.Type == bill.InvoiceTypeStandard {
typ = typ + "-simplified"
}
return typ
Expand Down Expand Up @@ -113,9 +114,9 @@ func logoHeight(img *org.Image) string {
return "40" // pixels
}

func code(series, code string) string {
func code(series, code cbc.Code) string {
if series == "" {
return code
return code.String()
}
return fmt.Sprintf("%s-%s", series, code)
}
17 changes: 9 additions & 8 deletions components/bill/invoice/invoice_templ.go

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

10 changes: 5 additions & 5 deletions components/bill/invoice/line_support.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
)

type lineSupport struct {
categories []*tax.Category
categories []*tax.CategoryDef
discounts bool
charges bool
refs bool
Expand All @@ -17,9 +17,9 @@ type lineSupport struct {
// some of the columns that will need to be shown
func prepareLineSupport(inv *bill.Invoice) *lineSupport {
ls := new(lineSupport)
r := inv.TaxRegime()
r := inv.RegimeDef()

cats := make([]*tax.Category, 0)
cats := make([]*tax.CategoryDef, 0)
for _, l := range inv.Lines {
if len(l.Discounts) > 0 {
ls.discounts = true
Expand All @@ -34,7 +34,7 @@ func prepareLineSupport(inv *bill.Invoice) *lineSupport {
ls.units = true
}
for _, combo := range l.Taxes {
cat := r.Category(combo.Category)
cat := r.CategoryDef(combo.Category)
if cat != nil {
cats = addCategory(cats, cat)
}
Expand All @@ -57,7 +57,7 @@ func prepareLineSupport(inv *bill.Invoice) *lineSupport {
}

// addCategory if not there already
func addCategory(cats []*tax.Category, cat *tax.Category) []*tax.Category {
func addCategory(cats []*tax.CategoryDef, cat *tax.CategoryDef) []*tax.CategoryDef {
for _, c := range cats {
if c.Code == cat.Code {
return cats
Expand Down
2 changes: 1 addition & 1 deletion components/bill/invoice/summary.templ
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ templ summaryOrderingRows(inv *bill.Invoice) {
@t.T(".order")
</span>
<span class="value">
{ inv.Ordering.Code }
{ inv.Ordering.Code.String() }
</span>
</li>
}
Expand Down
4 changes: 2 additions & 2 deletions components/bill/invoice/summary_templ.go

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

7 changes: 5 additions & 2 deletions components/bill/invoice/taxes.templ
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,11 @@ func taxCategoryRowSpan(ct *tax.CategoryTotal, row int) int {
}

func taxCategoryTotalName(ctx context.Context, inv *bill.Invoice, cat *tax.CategoryTotal) string {
r := inv.TaxRegime()
category := r.Category(cat.Code)
r := inv.RegimeDef()
category := r.CategoryDef(cat.Code)
if category == nil {
return cat.Code.String()
}
return category.Name.In(t.Lang(ctx))
}

Expand Down
7 changes: 5 additions & 2 deletions components/bill/invoice/taxes_templ.go

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

7 changes: 5 additions & 2 deletions components/bill/invoice/totals.templ
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,11 @@ func totalPricesIncludeTax(ctx context.Context, inv *bill.Invoice) string {
if inv.Tax == nil || inv.Tax.PricesInclude == "" {
return ""
}
r := inv.TaxRegime()
category := r.Category(inv.Tax.PricesInclude)
r := inv.RegimeDef()
category := r.CategoryDef(inv.Tax.PricesInclude)
if category == nil {
return inv.Tax.PricesInclude.String()
}
return category.Name.In(t.Lang(ctx))
}

Expand Down
7 changes: 5 additions & 2 deletions components/bill/invoice/totals_templ.go

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

3 changes: 1 addition & 2 deletions components/org/address.templ
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"strings"

"github.com/invopop/ctxi18n/i18n"
"github.com/invopop/gobl/l10n"
"github.com/invopop/gobl/org"
"github.com/invopop/gobl.html/components/t"
)
Expand Down Expand Up @@ -73,7 +72,7 @@ func buildStreetWithNumbers(addr *org.Address) string {
func addrNumberFirst(addr *org.Address) bool {
// TODO: add more countries here!
switch addr.Country {
case l10n.GB, l10n.US, l10n.CA, l10n.FR:
case "GB", "US", "CA", "FR":
return true
default:
return false
Expand Down
5 changes: 2 additions & 3 deletions components/org/address_templ.go

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

15 changes: 7 additions & 8 deletions components/org/party.templ
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/invopop/gobl.html/components/regimes/co"
"github.com/invopop/gobl.html/components/t"
"github.com/invopop/gobl/cbc"
"github.com/invopop/gobl/l10n"
"github.com/invopop/gobl/org"
"github.com/invopop/gobl/tax"
)
Expand Down Expand Up @@ -169,17 +168,17 @@ func showTaxID(party *org.Party) bool {
func taxIDLabel(ctx context.Context, party *org.Party) string {
tID := party.TaxID
switch tID.Country {
case l10n.ES:
case "ES":
return "NIF"
case l10n.CO:
case "CO":
return "NIT"
case l10n.MX:
case "MX":
return "RFC"
case l10n.FR:
case "FR":
return "TVA"
case l10n.PT:
case "PT":
return "NIF"
case l10n.IT:
case "IT":
return "P.IVA"
default:
return i18n.T(ctx, ".labels.default")
Expand All @@ -190,7 +189,7 @@ func taxIDCode(party *org.Party) string {
tID := party.TaxID
code := tID.Code.String()
switch tID.Country {
case l10n.CO:
case "CO":
return co.FormatTaxIDCode(code)
default:
return tID.Code.String()
Expand Down
21 changes: 10 additions & 11 deletions components/org/party_templ.go

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

Loading
Loading