Skip to content

Commit

Permalink
Greek invoices (#8)
Browse files Browse the repository at this point in the history
* Fix typo in MX extension

* Complete and set proper ISO code to Greek's locale

* Add IAPR template for Greek invoices
  • Loading branch information
cavalle authored Jul 17, 2024
1 parent c6d0eac commit b38de21
Show file tree
Hide file tree
Showing 16 changed files with 870 additions and 13 deletions.
2 changes: 2 additions & 0 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/internal"
"github.com/invopop/gobl.html/components/regimes/pl"
"github.com/invopop/gobl.html/components/regimes/pt"
"github.com/invopop/gobl.html/components/regimes/gr"
)

// Invoice renders a complete GOBL bill.Invoice object.
Expand Down Expand Up @@ -46,6 +47,7 @@ templ Invoice(env *gobl.Envelope, inv *bill.Invoice) {
@mx.CFDI(env, inv)
@pl.KSeFQR(env)
@pt.ATQR(env)
@gr.IAPR(env)
</div>
</article>
}
Expand Down
15 changes: 10 additions & 5 deletions components/bill/invoice/invoice_templ.go

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

3 changes: 3 additions & 0 deletions components/regimes/gr/gr.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Package gr provides additional templates and helper methods
// for the Greek tax regime.
package gr
70 changes: 70 additions & 0 deletions components/regimes/gr/iapr.templ
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package gr

import (
"github.com/invopop/gobl"
"github.com/invopop/gobl/regimes/gr"
"github.com/invopop/gobl.html/components/images"
)

templ IAPR(env *gobl.Envelope) {
if hasStamps(env) {
<style type="text/css">
.iapr {
break-inside: avoid;
font-size: 7pt;
line-height: 1.6em;
display: flex;
align-items: top;
}
.iapr .image {
margin-right: 6mm;
}
.iapr img {
width: 30mm;
height: 30mm;
}
.iapr .value {
font-family: monospace;
}
</style>
<section class="iapr">
if st := env.Head.GetStamp(gr.StampIAPRQR); st != nil {
<div class="image">
<a href={ templ.URL(st.Value) }>
@images.QR(st.Value)
</a>
</div>
}
<div class="text">
if st := env.Head.GetStamp(gr.StampIAPRHash); st != nil {
<div>
<b>Σήμανση:</b>
<span class="value">{ st.Value }</span>
</div>
}
if st := env.Head.GetStamp(gr.StampIAPRUID); st != nil {
<div>
<b>UNIQUE ID:</b>
<span class="value">{ st.Value }</span>
</div>
}
if st := env.Head.GetStamp(gr.StampIAPRMark); st != nil {
<div>
<b>ΜΑΡΚ:</b>
<span class="value">{ st.Value }</span>
</div>
}
if st := env.Head.GetStamp(gr.StampIAPRProvider); st != nil {
<div>
<b>Υ.ΠΑ.Η.Ε.Σ:</b>
<span>{ st.Value }</span>
</div>
}
</div>
</section>
}
}

func hasStamps(env *gobl.Envelope) bool {
return env.Head.GetStamp(gr.StampIAPRQR) != nil
}
154 changes: 154 additions & 0 deletions components/regimes/gr/iapr_templ.go

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

2 changes: 1 addition & 1 deletion components/regimes/mx/signatures.templ
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ templ signatures(h *head.Header) {
</div>
}
<div>
Este documento es una represetnación impresa de un CFDI.
Este documento es una representación impresa de un CFDI.
</div>
</div>
</section>
Expand Down
2 changes: 1 addition & 1 deletion components/regimes/mx/signatures_templ.go

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

Loading

0 comments on commit b38de21

Please sign in to comment.