forked from invopop/gobl.fatturapa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
transmission_test.go
55 lines (42 loc) · 1.79 KB
/
transmission_test.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
53
54
55
package fatturapa_test
import (
"testing"
"github.com/invopop/gobl.fatturapa/test"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestTransmissionData(t *testing.T) {
t.Run("should contain transmitting subject info", func(t *testing.T) {
converter := test.NewConverter()
env := test.LoadTestFile("invoice-simple.json")
doc, err := test.ConvertFromGOBL(env, converter)
require.NoError(t, err)
dt := doc.FatturaElettronicaHeader.DatiTrasmissione
assert.Equal(t, converter.Config.Transmitter.CountryCode, dt.IdTrasmittente.IdPaese)
assert.Equal(t, converter.Config.Transmitter.TaxID, dt.IdTrasmittente.IdCodice)
assert.Equal(t, "679a2f25", dt.ProgressivoInvio)
assert.Equal(t, "FPR12", dt.FormatoTrasmissione)
assert.Equal(t, "ABCDEF1", dt.CodiceDestinatario)
})
t.Run("should skip transmitter info and only include codice destinatario if transmitter is not present", func(t *testing.T) {
converter := test.NewConverter()
converter.Config.Transmitter = nil
env := test.LoadTestFile("invoice-simple.json")
doc, err := test.ConvertFromGOBL(env, converter)
require.NoError(t, err)
dt := doc.FatturaElettronicaHeader.DatiTrasmissione
assert.Equal(t, "ABCDEF1", dt.CodiceDestinatario)
assert.Nil(t, dt.IdTrasmittente)
assert.Equal(t, "", dt.ProgressivoInvio)
assert.Equal(t, "", dt.FormatoTrasmissione)
})
t.Run("should set codice destinatario to 0000000 if customer is Italian with PEC", func(t *testing.T) {
converter := test.NewConverter()
env := test.LoadTestFile("invoice-simple-with-pec.json")
doc, err := test.ConvertFromGOBL(env, converter)
require.NoError(t, err)
dt := doc.FatturaElettronicaHeader.DatiTrasmissione
assert.Equal(t, "0000000", dt.CodiceDestinatario)
assert.Equal(t, "[email protected]", dt.PECDestinatario)
})
}