Skip to content

Commit 63f0e93

Browse files
save effective rate in tax invoice items
1 parent 68ac903 commit 63f0e93

1 file changed

Lines changed: 26 additions & 26 deletions

File tree

src/test/java/org/killbill/billing/plugin/vertex/VertexTaxCalculatorTest.java

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -194,32 +194,6 @@ public void testComputeDryRun() throws Exception {
194194
verify(vertexApiClient).calculateTaxes(argThat(arg -> SaleMessageTypeEnum.QUOTATION.equals(arg.getSaleMessageType())));
195195
}
196196

197-
@Test(groups = "fast")
198-
public void testTaxEffectiveRate() throws Exception {
199-
//given
200-
given(invoice.getInvoiceItems()).willReturn(Collections.singletonList(taxableInvoiceItem));
201-
given(taxResponse.getData()).willReturn(apiResponseData);
202-
final TaxesType taxesType = new TaxesType();
203-
taxesType.setCalculatedTax(MOCK_TAX_AMOUNT_1_01);
204-
given(responseLineItem.getTaxes()).willReturn(Collections.singletonList(taxesType));
205-
206-
//given tax effective rate is present
207-
taxesType.setEffectiveRate(0.09975d);
208-
209-
//then it persisted in item details invoice item field
210-
List<InvoiceItem> result = vertexTaxCalculator.compute(account, invoice, true, Collections.emptyList(), tenantContext);
211-
assertEquals("0.09975", result.get(0).getItemDetails());
212-
checkTaxItemFields(result.get(0));
213-
214-
//given effective rate is not present
215-
taxesType.setEffectiveRate(null);
216-
217-
//then no item details persisted
218-
result = vertexTaxCalculator.compute(account, invoice, true, Collections.emptyList(), tenantContext);
219-
assertNull(result.get(0).getItemDetails());
220-
checkTaxItemFields(result.get(0));
221-
}
222-
223197
@Test(groups = "fast")
224198
public void testTaxDescription() throws Exception {
225199
//given
@@ -257,6 +231,32 @@ public void testTaxDescription() throws Exception {
257231
assertEquals("CA STATE TAX", result.get(0).getDescription());
258232
}
259233

234+
@Test(groups = "fast")
235+
public void testTaxEffectiveRate() throws Exception {
236+
//given
237+
given(invoice.getInvoiceItems()).willReturn(Collections.singletonList(taxableInvoiceItem));
238+
given(taxResponse.getData()).willReturn(apiResponseData);
239+
final TaxesType taxesType = new TaxesType();
240+
taxesType.setCalculatedTax(MOCK_TAX_AMOUNT_1_01);
241+
given(responseLineItem.getTaxes()).willReturn(Collections.singletonList(taxesType));
242+
243+
//given tax effective rate is present
244+
taxesType.setEffectiveRate(0.09975d);
245+
246+
//then it persisted in item details invoice item field
247+
List<InvoiceItem> result = vertexTaxCalculator.compute(account, invoice, true, Collections.emptyList(), tenantContext);
248+
assertEquals("0.09975", result.get(0).getItemDetails());
249+
checkTaxItemFields(result.get(0));
250+
251+
//given effective rate is not present
252+
taxesType.setEffectiveRate(null);
253+
254+
//then no item details persisted
255+
result = vertexTaxCalculator.compute(account, invoice, true, Collections.emptyList(), tenantContext);
256+
assertNull(result.get(0).getItemDetails());
257+
checkTaxItemFields(result.get(0));
258+
}
259+
260260
private void checkTaxItemFields(final InvoiceItem taxItem) {
261261
assertEquals(InvoiceItemType.TAX, taxItem.getInvoiceItemType());
262262
assertEquals("Tax", taxItem.getDescription());

0 commit comments

Comments
 (0)