Skip to content

Commit

Permalink
Merge pull request #4 from invopop/tax-included-pay
Browse files Browse the repository at this point in the history
Tax included pay
  • Loading branch information
samlown committed May 28, 2024
2 parents fc41a07 + 02cf73d commit dfe2849
Show file tree
Hide file tree
Showing 20 changed files with 163 additions and 49 deletions.
6 changes: 3 additions & 3 deletions .air.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ testdata_dir = "testdata"
tmp_dir = "tmp"

[build]
args_bin = ["serve", "-p", "3001", "--pdf", "prince"]
args_bin = ["serve", "-p", "3000", "--pdf", "prince"]
bin = "./gobl.html"
cmd = "templ generate && go build ./cmd/gobl.html"
delay = 1000
Expand Down Expand Up @@ -43,8 +43,8 @@ clean_on_exit = false

[proxy]
enabled = false
app_port = 3001
proxy_port = 3000
app_port = 3000
proxy_port = 3001

[screen]
clear_on_rebuild = false
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ go.work
localazy.json

/gobl.html

/tmp
21 changes: 19 additions & 2 deletions components/bill/invoice/payment.templ
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,29 @@ templ paymentInstructions(inst *pay.Instructions) {
@t.T(".card")
</span>
<span class="value">
@t.T(".card_detaul", i18n.M{"last4": inst.Card.Last4, "holder": inst.Card.Holder})
@t.T(".card_detail", i18n.M{"last4": inst.Card.Last4, "holder": inst.Card.Holder})
</span>
</li>
}
// TODO: Direct Debit
// TODO: Online
if len(inst.Online) > 0 {
<li class="online">
<span class="label">
@t.T(".online")
</span>
for _, ol := range inst.Online {
<span class="value">
<a href={ templ.SafeURL(ol.URL) }>
if ol.Label != "" {
{ ol.Label }
} else {
{ ol.URL }
}
</a>
</span>
}
</li>
}
if inst.Notes != "" {
<li class="notes">
<span class="label">
Expand Down
114 changes: 86 additions & 28 deletions components/bill/invoice/payment_templ.go

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

15 changes: 12 additions & 3 deletions components/bill/invoice/totals.templ
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ templ totals(inv *bill.Invoice, totals *bill.Totals) {
</h2>
<table>
<tbody>
@totalsBaseRows(totals)
@totalsBaseRows(inv, totals)
@totalsPayableRows(inv, totals)
@totalsDueRows(inv, totals)
</tbody>
Expand All @@ -27,7 +27,7 @@ templ totals(inv *bill.Invoice, totals *bill.Totals) {
</section>
}

templ totalsBaseRows(totals *bill.Totals) {
templ totalsBaseRows(inv *bill.Invoice, totals *bill.Totals) {
<tr class="sum strong">
<th>
@t.T(".sum")
Expand Down Expand Up @@ -59,7 +59,7 @@ templ totalsBaseRows(totals *bill.Totals) {
if totals.TaxIncluded != nil {
<tr>
<th>
@t.T(".prices_include_tax")
@t.T(".prices_include", i18n.M{"tax": totalPricesIncludeTax(ctx, inv)})
</th>
<td>
@t.LM(*totals.TaxIncluded)
Expand Down Expand Up @@ -170,6 +170,15 @@ templ totalsDueRows(inv *bill.Invoice, totals *bill.Totals) {
}
}

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)
return category.Name.In(t.Lang(ctx))
}

func totalExchangeRates(inv *bill.Invoice) []*currency.ExchangeRate {
list := make([]*currency.ExchangeRate, 0, len(inv.ExchangeRates))
for _, er := range inv.ExchangeRates {
Expand Down
15 changes: 12 additions & 3 deletions components/bill/invoice/totals_templ.go

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

7 changes: 7 additions & 0 deletions examples/full-invoice.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,13 @@
"iban": "ES31 0240 4036 4573 9340 5564",
"name": "RANDOM"
}
],
"online": [
{
"key": "paypal",
"label": "Paypal",
"url": "https://www.paypal.com/pay?ref=PAY1234"
}
]
}
},
Expand Down
10 changes: 10 additions & 0 deletions examples/out/full-invoice.html
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,16 @@ <h2 class="title">
</span>
</span>
</li>
<li class="online">
<span class="label">
Online
</span>
<span class="value">
<a href="https://www.paypal.com/pay?ref=PAY1234">
Paypal
</a>
</span>
</li>
</ul>
</section>
<section class="notes">
Expand Down
2 changes: 1 addition & 1 deletion examples/out/invoice-tax-included.html
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ <h2>
</tr>
<tr>
<th>
Included tax
Included VAT
</th>
<td>
€848,74
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/a-h/templ v0.2.598
github.com/go-resty/resty/v2 v2.12.0
github.com/invopop/ctxi18n v0.6.0
github.com/invopop/gobl v0.77.0
github.com/invopop/gobl v0.78.0
github.com/invopop/princepdf v0.0.0-20240408123340-585be3cab91a
github.com/labstack/echo/v4 v4.11.4
github.com/piglig/go-qr v0.2.4
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ github.com/invopop/gobl v0.76.0 h1:WHGJGe+sqljGkcifQMjxaiiYe8kne2bm3Yv4HUlSqOQ=
github.com/invopop/gobl v0.76.0/go.mod h1:3ixShxX1jlOKo5Rw22HVQh3jXnK9AZa7Twcw7L92qn0=
github.com/invopop/gobl v0.77.0 h1:fONqGuP73J3bqDLE+2TI75QfXDWGc9EwJFTtIK2SL8c=
github.com/invopop/gobl v0.77.0/go.mod h1:3ixShxX1jlOKo5Rw22HVQh3jXnK9AZa7Twcw7L92qn0=
github.com/invopop/gobl v0.78.0 h1:V6rbeXYX/wtQYPMQBKQgfWvDlRvyJYRhSmaFTwyE2LE=
github.com/invopop/gobl v0.78.0/go.mod h1:3ixShxX1jlOKo5Rw22HVQh3jXnK9AZa7Twcw7L92qn0=
github.com/invopop/jsonschema v0.12.0 h1:6ovsNSuvn9wEQVOyc72aycBMVQFKz7cPdMJn10CvzRI=
github.com/invopop/jsonschema v0.12.0/go.mod h1:ffZ5Km5SWWRAIN6wbDXItl95euhFz2uON45H2qjYt+0=
github.com/invopop/princepdf v0.0.0-20240408123340-585be3cab91a h1:xt18LlIfizLkFgLi+vK/m2SWOsAbQwVwQgbkzxKY0eU=
Expand Down
Loading

0 comments on commit dfe2849

Please sign in to comment.