Skip to content

Commit c6ae57d

Browse files
committed
refactor: update tax category structure in invoice mappers and tests
- Replace direct use of 'taxPercent' and 'taxScheme' with nested 'taxCategory' (or 'classifiedTaxCategory') arrays in InvoiceIntegrationTest, InvoiceMapperTest, and InvoiceValidatorTest. - Adjust mapping logic to accommodate the new data structure for tax category information. - Ensure tests reflect the updated structure.
1 parent 3fadfdd commit c6ae57d

File tree

3 files changed

+44
-16
lines changed

3 files changed

+44
-16
lines changed

tests/Integration/InvoiceIntegrationTest.php

+14-4
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,12 @@ public function testCompleteInvoiceGenerationFlow(): void
104104
[
105105
'taxableAmount' => 200,
106106
'taxAmount' => 30,
107-
'percent' => 15,
108-
'taxScheme' => ['id' => 'VAT']
107+
'taxCategory' => [
108+
'percent' => 15,
109+
'taxScheme' => [
110+
'id' => 'VAT'
111+
]
112+
]
109113
]
110114
]
111115
],
@@ -124,8 +128,14 @@ public function testCompleteInvoiceGenerationFlow(): void
124128
'lineExtensionAmount' => 200, // Calculated: 100 * 2 = 200
125129
'item' => [
126130
'name' => 'Product A',
127-
'taxPercent' => 15,
128-
'taxScheme' => ['id' => 'VAT']
131+
'classifiedTaxCategory' => [
132+
[
133+
'percent' => 15,
134+
'taxScheme' => [
135+
'id' => 'VAT'
136+
]
137+
]
138+
],
129139
],
130140
'price' => [
131141
'amount' => 100,

tests/Mappers/InvoiceMapperTest.php

+13-7
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,11 @@ public function testMapToInvoiceWithValidData(): void
124124
[
125125
'taxableAmount' => 4,
126126
'taxAmount' => 0.6,
127-
'percent' => 15,
128-
'taxScheme' => [
129-
'id' => 'VAT'
127+
'taxCategory' => [
128+
'percent' => 15,
129+
'taxScheme' => [
130+
'id' => 'VAT'
131+
]
130132
]
131133
]
132134
]
@@ -147,10 +149,14 @@ public function testMapToInvoiceWithValidData(): void
147149
'lineExtensionAmount' => 4,
148150
'item' => [
149151
'name' => 'Product',
150-
'taxPercent' => 15,
151-
'taxScheme' => [
152-
'id' => 'VAT'
153-
]
152+
'classifiedTaxCategory' => [
153+
[
154+
'percent' => 15,
155+
'taxScheme' => [
156+
'id' => 'VAT'
157+
]
158+
]
159+
],
154160
],
155161
'price' => [
156162
'amount' => 2,

tests/Mappers/InvoiceValidatorTest.php

+17-5
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,14 @@ public function testValidInvoiceData(): void
7979
'lineExtensionAmount'=> 200, // 100 * 2 = 200
8080
'item' => [
8181
'name' => 'Product A',
82-
'taxPercent' => 15,
83-
'taxScheme' => ['id' => 'VAT']
82+
'classifiedTaxCategory' => [
83+
[
84+
'percent' => 15,
85+
'taxScheme' => [
86+
'id' => 'VAT'
87+
]
88+
]
89+
],
8490
],
8591
'price' => [
8692
'amount' => 100,
@@ -154,12 +160,18 @@ public function testMissingRequiredFieldThrowsException(): void
154160
'lineExtensionAmount'=> 200,
155161
'item' => [
156162
'name' => 'Product A',
157-
'taxPercent' => 15,
158-
'taxScheme' => ['id' => 'VAT']
163+
'classifiedTaxCategory' => [
164+
[
165+
'percent' => 15,
166+
'taxScheme' => [
167+
'id' => 'VAT'
168+
]
169+
]
170+
],
159171
],
160172
'price' => [
161173
'amount' => 100,
162-
'unitCode' => 'PCE'
174+
'unitCode' => 'PCE',
163175
],
164176
'taxTotal' => [
165177
'taxAmount' => 30,

0 commit comments

Comments
 (0)