-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from invopop/ksef-qr
Adding PL and KSeF with QR. Also party labels.
- Loading branch information
Showing
20 changed files
with
723 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package pl | ||
|
||
import ( | ||
"regexp" | ||
|
||
"github.com/invopop/gobl" | ||
"github.com/invopop/gobl/regimes/pl" | ||
"github.com/invopop/gobl.html/components/t" | ||
"github.com/invopop/ctxi18n/i18n" | ||
"github.com/invopop/gobl.html/components/images" | ||
) | ||
|
||
var dianQRHTTPRegexp = regexp.MustCompile(`https.+`) | ||
|
||
templ KSeFQR(env *gobl.Envelope) { | ||
if id := ksefID(env); id != "" { | ||
if qr := ksefQR(env); qr != "" { | ||
@generateQR(id, qr) | ||
} | ||
} | ||
} | ||
|
||
templ generateQR(id, qr string) { | ||
<style type="text/css"> | ||
.ksef-qr { | ||
display: flex; | ||
font-family: monospace; | ||
font-size: 7pt; | ||
} | ||
.ksef-qr .image { | ||
margin-right: 6mm; | ||
} | ||
.ksef-qr .text { | ||
margin-top: auto; | ||
word-break: break-all; | ||
} | ||
.ksef-qr img { | ||
width: 24mm; | ||
height: 24mm; | ||
} | ||
</style> | ||
<section class="ksef-qr"> | ||
<div class="image"> | ||
<a href={ templ.URL(qr) }> | ||
@images.QR(qr) | ||
</a> | ||
</div> | ||
<div class="text"> | ||
<div class="ksef-id"> | ||
@t.T("billing.invoice.regimes.pl.ksef-id", i18n.M{"id": id}) | ||
</div> | ||
</div> | ||
</section> | ||
} | ||
|
||
func ksefQR(env *gobl.Envelope) string { | ||
for _, stamp := range env.Head.Stamps { | ||
switch stamp.Provider { | ||
case pl.StampProviderKSeFQR: | ||
return stamp.Value | ||
} | ||
} | ||
return "" | ||
} | ||
|
||
func ksefID(env *gobl.Envelope) string { | ||
for _, stamp := range env.Head.Stamps { | ||
switch stamp.Provider { | ||
case pl.StampProviderKSeFID: | ||
return stamp.Value | ||
} | ||
} | ||
return "" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Package pl defines extra output for Polish invoices. | ||
package pl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.