-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtransmission_in.go
52 lines (42 loc) · 1.05 KB
/
transmission_in.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package fatturapa
import (
"github.com/invopop/gobl/addons/it/sdi"
"github.com/invopop/gobl/bill"
"github.com/invopop/gobl/cbc"
"github.com/invopop/gobl/org"
"github.com/invopop/gobl/tax"
)
func goblBillInvoiceAddTransmission(inv *bill.Invoice, dt *TransmissionData) {
if inv.Tax == nil {
inv.Tax = &bill.Tax{}
}
if inv.Tax.Ext == nil {
inv.Tax.Ext = tax.Extensions{}
}
inv.Tax.Ext[sdi.ExtKeyFormat] = cbc.Code(dt.TransmissionFormat)
if dt.TransmissionFormat == "FPA12" {
inv.Tags.SetTags(tax.TagB2G)
}
if inv.Customer == nil {
inv.Customer = &org.Party{}
}
if inv.Customer.Inboxes == nil {
inv.Customer.Inboxes = []*org.Inbox{}
}
if dt.RecipientCode != "" && dt.RecipientCode != "XXXXXXX" && dt.RecipientCode != "0000000" {
inv.Customer.Inboxes = append(inv.Customer.Inboxes,
&org.Inbox{
Key: sdi.KeyInboxCode,
Code: cbc.Code(dt.RecipientCode),
},
)
}
if dt.RecipientPEC != "" {
inv.Customer.Inboxes = append(inv.Customer.Inboxes,
&org.Inbox{
Key: sdi.KeyInboxPEC,
Email: dt.RecipientPEC,
},
)
}
}