Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0039969Openbravo ERP09. Financial managementpublic2019-01-16 19:162019-03-28 14:56
ngarcia 
markmm82 
urgentmajoralways
closedfixed 
5
 
3.0PR19Q2 
Sandrahuguet
Core
No
0039969: Process failed during execution when posting a payment/transaction/reconciliation of a Cash VAT invoice with different currency
Process failed during execution when posting a payment/transaction/reconciliation of a Cash VAT invoice with different currency than the general ledger currency.

In createFactCashVAT of CashVATUtil class, taxAmountConverted could be 0 and in that case factLine1 is null and a NullPointerException is raised when trying to create factLine2
As system admin role:
   Install Cash VAT Management module

As group admin role:
   Set an Organization as Cash VAT
   Set a Tax Rate as Cash VAT
   Create a sales price list in MXN
   Add a price to a product in it
   Define a conversion of 0.04 between MXN and EUR and between MXN and USD
   Create a Sales Invoice
   Select previously created price list (MXN)
   Set it as Cash VAT
   Add a line and select previously created tax rate and product
   Complete it
   Add a payment of 0.06 to it with today's date
   Add a new payment with the pending amount and a different date
   Check a record with a Tax Amount of 0.01 is shown in 'Sales Invoice - Tax - Cash VAT'
   Try to post the payment or the transaction and check the following error is shown:
      Process failed during execution

   The log shows:
      java.lang.NullPointerException
    at org.openbravo.erpCommon.utility.CashVATUtil.createFactCashVAT(CashVATUtil.java:563)
    at org.openbravo.erpCommon.ad_forms.DocFINReconciliation.createFactPaymentDetails(DocFINReconciliation.java:898)
    at org.openbravo.erpCommon.ad_forms.DocFINReconciliation.createFactPayment(DocFINReconciliation.java:704)
    at org.openbravo.erpCommon.ad_forms.DocFINReconciliation.createFact(DocFINReconciliation.java:596)
    at org.openbravo.erpCommon.ad_forms.AcctServer.postLogic(AcctServer.java:1114)
No tags attached.
related to defect 0040091 scheduled markmm82 If converted amount is zero the document should be disabled for accounting. 
Issue History
2019-01-16 19:16ngarciaNew Issue
2019-01-16 19:16ngarciaAssigned To => Triage Finance
2019-01-16 19:16ngarciaModules => Core
2019-01-16 19:16ngarciaResolution time => 1549407600
2019-01-16 19:16ngarciaTriggers an Emergency Pack => No
2019-01-17 09:39dmiguelezAssigned ToTriage Finance => markmm82
2019-01-21 02:40markmm82Note Added: 0109027
2019-01-21 20:13markmm82Statusnew => scheduled
2019-01-28 23:58markmm82Note Added: 0109289
2019-01-29 00:09markmm82Note Edited: 0109289bug_revision_view_page.php?bugnote_id=0109289#r18209
2019-01-29 12:04SandrahuguetReview Assigned To => Sandrahuguet
2019-01-31 17:19SandrahuguetRelationship addedrelated to 0040091
2019-02-05 17:40hgbotCheckin
2019-02-05 17:40hgbotNote Added: 0109597
2019-02-05 17:40hgbotStatusscheduled => resolved
2019-02-05 17:40hgbotResolutionopen => fixed
2019-02-05 17:40hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/e36d52a51aee7822955668823c7762d590201fe7 [^]
2019-02-05 17:40hgbotCheckin
2019-02-05 17:40hgbotNote Added: 0109598
2019-02-05 17:40hgbotCheckin
2019-02-05 17:40hgbotNote Added: 0109599
2019-02-05 17:42dmiguelezNote Added: 0109602
2019-02-05 17:42dmiguelezStatusresolved => closed
2019-02-05 17:42dmiguelezFixed in Version => 3.0PR19Q2
2019-02-20 00:10markmm82Note Edited: 0109027bug_revision_view_page.php?bugnote_id=0109027#r18347
2019-03-28 14:55hudsonbotCheckin
2019-03-28 14:55hudsonbotNote Added: 0110794
2019-03-28 14:55hudsonbotCheckin
2019-03-28 14:55hudsonbotNote Added: 0110795
2019-03-28 14:56hudsonbotCheckin
2019-03-28 14:56hudsonbotNote Added: 0110796

Notes
(0109027)
markmm82   
2019-01-21 02:40   
(edited on: 2019-02-20 00:10)
Test Plan:
As system admin role:
   Install Cash VAT Management module

As group admin role:
   Set an Organization as Cash VAT
   Set a Tax Rate as Cash VAT
   Create a sales price list in MXN
   Add a price to a product in it
   Define a conversion of 0.04 between MXN and EUR and between MXN and USD
   Create a Sales Invoice
   Select previously created price list (MXN)
   Set it as Cash VAT
   Add a line and select previously created tax rate and product
   Complete it
   Add a payment of 0.06 to it with today's date
   Add a new payment with the pending amount and a different date
   Check a record with a Tax Amount of 0.01 is shown in 'Sales Invoice - Tax - Cash VAT'
   Try to post the payment or the transaction and check the process ends with a warning explaining that the Document is disabled for accounting

(0109289)
markmm82   
2019-01-28 23:58   
(edited on: 2019-01-29 00:09)
Issue could be reproduced by the following settings:
As Group Admin:
  Apply CashVat dataset.
  Go to Organization window and select F&B España, S.A
    Go to Information tab and check the Cash VAT and Doube Cash Criteria checkboxes.
  
  Go to Tax Rate window and select Entregas IVA 21% tax rate.
    Enable the Cash VAT flag.
  Go to Tax Rate -> Accounting tab and select related record to F&B España, S.A. US/A/Euro GL.
    Define a Tax Due Transitory, for example = 10000 - Capital social
    Define a Tax Credit Transitory, for example = 10100 - Fondo social
  Go to Tax Rate -> Accounting tab and select related record to F&B International Group US/A/US Dollar GL.
    Define a Tax Due Transitory, for example = 1110 - Checking Account
    Define a Tax Credit Transitory, for example = 1120 - Funds In-Transfer

  Go to General Ledger Configuration window and select F&B España, S.A. US/A/Euro in the Defaults tab.
    Define a Tax Due Transitory, for example = 1110 - Checking Account
    Define a Tax Credit Transitory, for example = 1120 - Funds In-Transfer
  Go to General Ledger Configuration window and select F&B International Group US/A/US Dollar in the Defaults tab.
    Define a Tax Due Transitory, for example = 1110 - Checking Account
    Define a Tax Credit Transitory, for example = 1120 - Funds In-Transfer

  Go to Price List window and create new one.
    Organization = F&B España, S.A.
    Name = MXN
    Currency = MXN
    Sales Price List = Y
  Go to Price List Version and define a new one:
    Name = MXN
    Valid From = Yesterday
  Add a Product Price for it:
    Product = Agua sin Gas 1L
    Unit Price = 10.00
    List Price = 10.00

  Define a conversion of 0.04 between MXN and EUR
    Currency = MXN
    To Currency = EUR
    Valid from Date = Yesterday
    Multiple Rate By = 0.04
    Divide Rate By = 25
  Define a conversion of 0.04 between MXN and USD
    Currency = MXN
    To Currency = USD
    Valid from Date = Yesterday
    Multiple Rate By = 0.04
    Divide Rate By = 25

  Go to Cuenta de Banco Financial Account
    Go to Payment Method tab and select Transferencia Payment method
      Allow the Payment IN to receive Payments in Multiple Currencies
 
  Create a Sales Invoice
   Select previously created MXN price list (with MXN currency)
   Set it as Cash VAT
   Add a line and select previously created tax rate and product
   Complete it

   Add a payment of 0.06 to it with today's date
   Add a new payment with the pending amount and a different date

   Check a record with a Tax Amount of 0.01 is shown in 'Sales Invoice - Tax - Cash VAT'
   Try to post the payment or the transaction and check the following error is shown:
      Process failed during execution

  If you debug the process you will be able to see the following NPE (Notice that the log isn't show in the console because the exception is catched and treated):
  java.lang.NullPointerException
    at org.openbravo.erpCommon.utility.CashVATUtil.createFactCashVAT(CashVATUtil.java:563)
    at org.openbravo.erpCommon.ad_forms.DocFINReconciliation.createFactPaymentDetails(DocFINReconciliation.java:898)
    at org.openbravo.erpCommon.ad_forms.DocFINReconciliation.createFactPayment(DocFINReconciliation.java:704)
    at org.openbravo.erpCommon.ad_forms.DocFINReconciliation.createFact(DocFINReconciliation.java:596)
    at org.openbravo.erpCommon.ad_forms.AcctServer.postLogic(AcctServer.java:1114)

(0109597)
hgbot   
2019-02-05 17:40   
Repository: erp/devel/pi
Changeset: e36d52a51aee7822955668823c7762d590201fe7
Author: Sandra Huguet <sandra.huguet <at> openbravo.com>
Date: Thu Jan 31 16:18:04 2019 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/e36d52a51aee7822955668823c7762d590201fe7 [^]

Fixed issue 39969 Avoid NPE when posting a payment/transaction/reconciliation
of a Cash VAT invoice with different currency.


After convert the tax amount with from the used currency to the financial account
currency it is possible that this conversion is ZERO.
If Amount converted is zero should have the same behaviour as when amount is zero.

---
M src/org/openbravo/erpCommon/utility/CashVATUtil.java
---
(0109598)
hgbot   
2019-02-05 17:40   
Repository: erp/devel/pi
Changeset: e4b5142297857df4e655dafb00f527ec7300a2b1
Author: David Miguelez <david.miguelez <at> openbravo.com>
Date: Mon Feb 04 11:53:15 2019 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/e4b5142297857df4e655dafb00f527ec7300a2b1 [^]

Related to Issue 39969. Code Review changes.

Moved logic to retrieve some variables after if clause.
If the condition is not fulfilled, it is not necessary to
initialize this variables.

---
M src/org/openbravo/erpCommon/utility/CashVATUtil.java
---
(0109599)
hgbot   
2019-02-05 17:40   
Repository: erp/devel/pi
Changeset: 5b3625a0edb358eaff2e1b1c6bee9fa977078aa6
Author: Sandra Huguet <sandra.huguet <at> openbravo.com>
Date: Mon Feb 04 13:38:49 2019 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/5b3625a0edb358eaff2e1b1c6bee9fa977078aa6 [^]

related to issue 39969 update Copyright year

---
M src/org/openbravo/erpCommon/utility/CashVATUtil.java
---
(0109602)
dmiguelez   
2019-02-05 17:42   
Code Review + Testing Ok
(0110794)
hudsonbot   
2019-03-28 14:55   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/b2fbc1588df4 [^]
Maturity status: Test
(0110795)
hudsonbot   
2019-03-28 14:55   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/b2fbc1588df4 [^]
Maturity status: Test
(0110796)
hudsonbot   
2019-03-28 14:56   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/b2fbc1588df4 [^]
Maturity status: Test