Skip to content

Commit

Permalink
Extract PEC from new inbox email field
Browse files Browse the repository at this point in the history
  • Loading branch information
cavalle committed Nov 8, 2024
1 parent 76535d6 commit 6d8eb2d
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 39 deletions.
2 changes: 1 addition & 1 deletion address.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func newAddress(addr *org.Address) *Address {
Country: addr.Country.String(),
}
if addr.Country == l10n.IT.ISO() {
ad.Code = addr.Code
ad.Code = addr.Code.String()
} else {
ad.Code = foreignCAP
}
Expand Down
3 changes: 1 addition & 2 deletions body.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/invopop/gobl/bill"
"github.com/invopop/gobl/cbc"
"github.com/invopop/gobl/org"
"github.com/invopop/gobl/regimes/it"
)

const (
Expand Down Expand Up @@ -201,7 +200,7 @@ func findCodeTipoDocumento(inv *bill.Invoice) (string, error) {

func newDatiBollo(charges []*bill.Charge) *datiBollo {
for _, charge := range charges {
if charge.Key == it.ChargeKeyStampDuty {
if charge.Key == bill.ChargeKeyStampDuty {
return &datiBollo{
BolloVirtuale: stampDutyCode,
ImportoBollo: formatAmount(&charge.Amount),
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.22
toolchain go1.22.5

require (
github.com/invopop/gobl v0.203.0
github.com/invopop/gobl v0.204.2-0.20241108131916-4aee2eb083c6
github.com/invopop/xmldsig v0.8.0
github.com/lestrrat-go/libxml2 v0.0.0-20240521004304-a75c203ac627
github.com/spf13/cobra v1.8.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/invopop/gobl v0.203.0 h1:41aIW+gZfyVcP0G0kz+IX4w8AMSx9EgbnALpn0s9CzA=
github.com/invopop/gobl v0.203.0/go.mod h1:DmPohPel8b3ta4nDKnXRNzWQlB89cN74e0/WwPUEZUU=
github.com/invopop/gobl v0.204.2-0.20241108131916-4aee2eb083c6 h1:VttHfVmyI1yIGQNswLCZ68vxcUNOJILDPfHJkJp/Vdo=
github.com/invopop/gobl v0.204.2-0.20241108131916-4aee2eb083c6/go.mod h1:DmPohPel8b3ta4nDKnXRNzWQlB89cN74e0/WwPUEZUU=
github.com/invopop/jsonschema v0.12.0 h1:6ovsNSuvn9wEQVOyc72aycBMVQFKz7cPdMJn10CvzRI=
github.com/invopop/jsonschema v0.12.0/go.mod h1:ffZ5Km5SWWRAIN6wbDXItl95euhFz2uON45H2qjYt+0=
github.com/invopop/validation v0.7.0 h1:NBPLqvYGmLZLQuk5jh0PbaBBetJW7f2VEk/BTWJkGBU=
Expand Down
4 changes: 2 additions & 2 deletions test/data/invoice-b2g.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@
"sum": "250.00",
"discounts": [
{
"amount": "10.00",
"reason": "Sconto"
"reason": "Sconto",
"amount": "10.00"
}
],
"taxes": [
Expand Down
12 changes: 6 additions & 6 deletions test/data/invoice-credit-note.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@
"sum": "1800.00",
"discounts": [
{
"reason": "Special discount",
"percent": "10%",
"amount": "180.00",
"reason": "Special discount"
"amount": "180.00"
}
],
"taxes": [
Expand Down Expand Up @@ -168,19 +168,19 @@
"discounts": [
{
"i": 1,
"reason": "10th year anniversary discount",
"base": "1720.00",
"percent": "50%",
"amount": "860.00",
"reason": "10th year anniversary discount"
"amount": "860.00"
}
],
"charges": [
{
"i": 1,
"reason": "10th year anniversary charge",
"base": "1720.00",
"percent": "10%",
"amount": "172.00",
"reason": "10th year anniversary charge"
"amount": "172.00"
}
],
"payment": {
Expand Down
4 changes: 2 additions & 2 deletions test/data/invoice-hotel.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@
"sum": "250.00",
"discounts": [
{
"amount": "10.00",
"reason": "Sconto"
"reason": "Sconto",
"amount": "10.00"
}
],
"taxes": [
Expand Down
14 changes: 7 additions & 7 deletions test/data/invoice-irpef.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@
"sum": "1800.00",
"discounts": [
{
"reason": "Special discount",
"percent": "10%",
"amount": "180.00",
"reason": "Special discount"
"amount": "180.00"
}
],
"taxes": [
Expand Down Expand Up @@ -167,23 +167,23 @@
"discounts": [
{
"i": 1,
"reason": "10th year anniversary discount",
"base": "1720.00",
"percent": "50%",
"amount": "860.00",
"reason": "10th year anniversary discount"
"amount": "860.00"
}
],
"charges": [
{
"i": 1,
"reason": "10th year anniversary charge",
"base": "1720.00",
"percent": "10%",
"amount": "172.00",
"reason": "10th year anniversary charge"
"amount": "172.00"
},
{
"key": "stamp-duty",
"i": 2,
"key": "stamp-duty",
"amount": "12.34"
}
],
Expand Down
16 changes: 8 additions & 8 deletions test/data/invoice-simple-with-pec.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"uuid": "679a2f25-7483-11ec-9722-7ea2cb436ff6",
"dig": {
"alg": "sha256",
"val": "3a010567cc0f19963f2d6eb35418a11aa2a53dd3abc973bd4136d924e1a83802"
"val": "6e31c1f6fc49342bb71a4b449bf3531ea4bfcf1a383319f3425b0a1f73e639ef"
}
},
"doc": {
Expand Down Expand Up @@ -90,7 +90,7 @@
"inboxes": [
{
"key": "it-sdi-pec",
"code": "[email protected]"
"email": "[email protected]"
}
],
"addresses": [
Expand Down Expand Up @@ -121,9 +121,9 @@
"sum": "1800.00",
"discounts": [
{
"reason": "Special discount",
"percent": "10%",
"amount": "180.00",
"reason": "Special discount"
"amount": "180.00"
}
],
"taxes": [
Expand Down Expand Up @@ -159,19 +159,19 @@
"discounts": [
{
"i": 1,
"reason": "10th year anniversary discount",
"base": "1720.00",
"percent": "50%",
"amount": "860.00",
"reason": "10th year anniversary discount"
"amount": "860.00"
}
],
"charges": [
{
"i": 1,
"reason": "10th year anniversary charge",
"base": "1720.00",
"percent": "10%",
"amount": "172.00",
"reason": "10th year anniversary charge"
"amount": "172.00"
}
],
"payment": {
Expand Down
12 changes: 6 additions & 6 deletions test/data/invoice-simple.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@
"sum": "1800.00",
"discounts": [
{
"reason": "Special discount",
"percent": "10%",
"amount": "180.00",
"reason": "Special discount"
"amount": "180.00"
}
],
"taxes": [
Expand Down Expand Up @@ -160,19 +160,19 @@
"discounts": [
{
"i": 1,
"reason": "10th year anniversary discount",
"base": "1720.00",
"percent": "50%",
"amount": "860.00",
"reason": "10th year anniversary discount"
"amount": "860.00"
}
],
"charges": [
{
"i": 1,
"reason": "10th year anniversary charge",
"base": "1720.00",
"percent": "10%",
"amount": "172.00",
"reason": "10th year anniversary charge"
"amount": "172.00"
}
],
"payment": {
Expand Down
4 changes: 2 additions & 2 deletions transmission.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func codiceDestinatario(cus *org.Party) string {
}
for _, inbox := range cus.Inboxes {
if inbox.Key == sdi.KeyInboxCode {
return inbox.Code
return inbox.Code.String()
}
}
}
Expand All @@ -79,7 +79,7 @@ func pecDestinatario(cus *org.Party) string {
if cus != nil {
for _, inbox := range cus.Inboxes {
if inbox.Key == sdi.KeyInboxPEC {
return inbox.Code
return inbox.Email
}
}
}
Expand Down

0 comments on commit 6d8eb2d

Please sign in to comment.