billy icon indicating copy to clipboard operation
billy copied to clipboard

The field Tax Exemption Reason is mandatory when invoices entries have price 0

Open froque opened this issue 4 years ago • 0 comments

to reproduce

  • get billy-demo-app source code
$ git clone  [email protected]:premium-minds/billy-demo-app.git
$ cd billy-demo-app
  • apply this diff
$ git diff              
diff --git a/src/main/java/dummyApp/app/DemoApp.java b/src/main/java/dummyApp/app/DemoApp.java
index a8d7f87..028dc1b 100644
--- a/src/main/java/dummyApp/app/DemoApp.java
+++ b/src/main/java/dummyApp/app/DemoApp.java
@@ -153,7 +153,7 @@ public class DemoApp {
                                .setContextUID(billyPortugal.contexts().portugal().allRegions().getUID())
                                .setQuantity(new BigDecimal("10"))
                                .setTaxPointDate(dateFormat.parse("01-02-2013"))
-                               .setUnitAmount(GenericInvoiceEntryBuilder.AmountType.WITH_TAX, new BigDecimal("100"))
+                               .setUnitAmount(GenericInvoiceEntryBuilder.AmountType.WITH_TAX, new BigDecimal("0"))
                                .setContextUID(billyPortugal.contexts().continent().allContinentRegions().getUID())
                                .setProductUID(product.getUID())
                                .setDescription(product.getDescription())
  • run the demo app
$ mvn clean package exec:java -Dexec.mainClass="dummyApp.app.App" -Dexec.args="demo"
  • fails with "The field Tax Exemption Reason is mandatory":
java.lang.NullPointerException: The field Tax Exemption Reason is mandatory
    at java.util.Objects.requireNonNull (Objects.java:348)
    at org.apache.commons.lang3.Validate.notNull (Validate.java:225)
    at com.premiumminds.billy.core.util.BillyValidator.mandatory (BillyValidator.java:76)
    at com.premiumminds.billy.portugal.services.builders.impl.PTGenericInvoiceEntryBuilderImpl.validateInstance (PTGenericInvoiceEntryBuilderImpl.java:76)
    at com.premiumminds.billy.portugal.services.builders.impl.PTInvoiceEntryBuilderImpl.validateInstance (PTInvoiceEntryBuilderImpl.java:55)
    at com.premiumminds.billy.core.services.builders.impl.AbstractBuilder.build (AbstractBuilder.java:64)
    at com.premiumminds.billy.core.services.builders.impl.GenericInvoiceBuilderImpl.addEntry (GenericInvoiceBuilderImpl.java:203)
    at com.premiumminds.billy.core.util.NotOnUpdateInterceptor.invoke (NotOnUpdateInterceptor.java:52)
    at dummyApp.app.DemoApp.createPtInvoice (DemoApp.java:162)
    at dummyApp.app.DemoApp.run (DemoApp.java:67)
    at dummyApp.app.App.main (App.java:27)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:254)
    at java.lang.Thread.run (Thread.java:832)

The correct behaviour is to not fail and issue the invoice with a price of 0.

froque avatar Jun 04 '21 09:06 froque