-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathordering_parse_test.go
More file actions
47 lines (36 loc) · 1.34 KB
/
ordering_parse_test.go
File metadata and controls
47 lines (36 loc) · 1.34 KB
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
package ubl_test
import (
"testing"
"github.com/invopop/gobl/bill"
"github.com/invopop/gobl/cbc"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestParseOrdering(t *testing.T) {
t.Run("ubl-example2.xml", func(t *testing.T) {
e, err := testParseInvoice("en16931/ubl-example2.xml")
require.NoError(t, err)
inv, ok := e.Extract().(*bill.Invoice)
require.True(t, ok)
ordering := inv.Ordering
assert.NotNil(t, ordering)
assert.Equal(t, "2013-06-01", ordering.Period.Start.String())
assert.Equal(t, "2013-06-30", ordering.Period.End.String())
assert.Equal(t, cbc.Code("Contract321"), ordering.Contracts[0].Code)
})
t.Run("ubl-example5.xml", func(t *testing.T) {
e, err := testParseInvoice("en16931/ubl-example5.xml")
require.NoError(t, err)
inv, ok := e.Extract().(*bill.Invoice)
require.True(t, ok)
ordering := inv.Ordering
assert.NotNil(t, ordering)
assert.Equal(t, cbc.Code("123"), ordering.Code)
assert.Equal(t, "2013-03-10", ordering.Period.Start.String())
assert.Equal(t, "2013-04-10", ordering.Period.End.String())
assert.Equal(t, cbc.Code("2013-05"), ordering.Contracts[0].Code)
assert.Equal(t, cbc.Code("PO4711"), ordering.Purchases[0].Code)
assert.Equal(t, cbc.Code("3544"), ordering.Receiving[0].Code)
assert.Equal(t, cbc.Code("5433"), ordering.Despatch[0].Code)
})
}