Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0038273Openbravo ERP02. Master data managementpublic2018-04-05 09:192018-05-09 19:29
ngarcia 
collazoandy4 
urgentmajoralways
closedfixed 
5
 
3.0PR18Q3 
aferraz
Core
No
0038273: Current Balance is not updated if an invoice is completed when Business Partner record is pending to be saved
Current Balance is not updated if an invoice is completed when Business Partner record is pending to be saved
As group admin role:
   Go to Business Partner window and select 'Hoteles Buenas Noches, S.A.'
   Check its current balance
   Edit some field such as the Commercial Name
   Do not save it
   Create a Sales Invoice for that business partner, add a line and complete it
   Return to the Business Partner window and save the record
   Check Current Balance remains with the same value and it should have been updated
No tags attached.
diff proposal38273.diff (3,253) 2018-04-06 08:27
https://issues.openbravo.com/file_download.php?file_id=11712&type=bug
Issue History
2018-04-05 09:19ngarciaNew Issue
2018-04-05 09:19ngarciaAssigned To => Triage Finance
2018-04-05 09:19ngarciaModules => Core
2018-04-05 09:19ngarciaResolution time => 1524693600
2018-04-05 09:19ngarciaTriggers an Emergency Pack => No
2018-04-05 09:20ngarciaIssue Monitored: ngarcia
2018-04-05 15:36jfrancesIssue Monitored: jfrances
2018-04-05 18:02dmiguelezAssigned ToTriage Finance => collazoandy4
2018-04-05 23:19achavesIssue Monitored: achaves
2018-04-06 08:27dmiguelezFile Added: proposal38273.diff
2018-04-06 08:29dmiguelezNote Added: 0103705
2018-04-06 20:28collazoandy4Statusnew => scheduled
2018-04-06 21:45collazoandy4Note Added: 0103727
2018-04-12 17:15hgbotCheckin
2018-04-12 17:15hgbotNote Added: 0103855
2018-04-12 17:15hgbotStatusscheduled => resolved
2018-04-12 17:15hgbotResolutionopen => fixed
2018-04-12 17:15hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/86538f0c012469375e97d74760b7f3b265715ef7 [^]
2018-04-12 17:15hgbotCheckin
2018-04-12 17:15hgbotNote Added: 0103856
2018-04-12 17:15aferrazReview Assigned To => aferraz
2018-04-12 17:15aferrazNote Added: 0103857
2018-04-12 17:15aferrazStatusresolved => closed
2018-04-12 17:15aferrazFixed in Version => 3.0PR18Q3
2018-05-09 19:29hudsonbotCheckin
2018-05-09 19:29hudsonbotNote Added: 0104378
2018-05-09 19:29hudsonbotCheckin
2018-05-09 19:29hudsonbotNote Added: 0104379

Notes
(0103705)
dmiguelez   
2018-04-06 08:29   
Note:

To fix wrong data UpdateCustomerBalance ModuleScript can be used.

To fix it only for one Business Partner this queries can be used (this is done for the Business Partner used to report the issue)

-- Update CreditUsed to 0
UPDATE c_bpartner SET so_creditused = 0, updatedby='0', updated=now() where c_bpartner_id = '9E6850C866BD4921AD0EB7F7796CE2C7';

-- Retrieve credit used
select SUM(A.amount)
        FROM (
          SELECT bp.c_bpartner_id, COALESCE(SUM(c_currency_convert(ps.outstandingamt * (CASE WHEN inv.issotrx = 'Y' THEN 1 ELSE -1 END), inv.c_currency_id, bp.bp_currency_id, inv.created, null, inv.ad_client_id, inv.ad_org_id)), 0) as amount
          FROM c_invoice inv
          JOIN c_bpartner bp
          ON inv.c_bpartner_id = bp.c_bpartner_id
          JOIN fin_payment_schedule ps
          ON inv.c_invoice_id = ps.c_invoice_id
          WHERE ps.outstandingamt <> 0
          and bp.c_bpartner_id = '9E6850C866BD4921AD0EB7F7796CE2C7'
          GROUP BY bp.c_bpartner_id
          UNION ALL
          SELECT bp.c_bpartner_id, COALESCE(SUM(c_currency_convert((p.generated_credit - p.used_credit) * (CASE WHEN p.isreceipt = 'Y' THEN -1 ELSE 1 END), p.c_currency_id, bp.bp_currency_id, p.created, null, p.ad_client_id, p.ad_org_id)), 0) as amount
          FROM FIN_PAYMENT p
          JOIN c_bpartner bp
          ON p.c_bpartner_id = bp.c_bpartner_id
          WHERE (p.generated_credit - p.used_credit) <> 0
          AND p.generated_credit <> 0
          AND p.processed = 'Y'
          and bp.c_bpartner_id = '9E6850C866BD4921AD0EB7F7796CE2C7'
          GROUP BY bp.c_bpartner_id
        ) A
        GROUP BY A.c_bpartner_id;

-- Set new credit used based on previous query
UPDATE c_bpartner SET so_creditused = TO_NUMBER(XXX), updatedby='0', updated=now() WHERE c_bpartner_id = '9E6850C866BD4921AD0EB7F7796CE2C7';
(0103727)
collazoandy4   
2018-04-06 21:45   
Test Plan
  As group admin role:
   Go to Business Partner window and select 'Hoteles Buenas Noches, S.A.'
   Check its current balance
   Edit but not save it the Commercial Name field
   Create a Sales Invoice for that business partner, add a line and complete it
   Return to the Business Partner window and save the record
   Check an error message is shown:
     Saving failed. The record you are saving has already been changed by another user or process. Cancel your changes and refresh the data by clicking the refresh button.
(0103855)
hgbot   
2018-04-12 17:15   
Repository: erp/devel/pi
Changeset: 86538f0c012469375e97d74760b7f3b265715ef7
Author: Armaignac <collazoandy4 <at> gmail.com>
Date: Fri Apr 06 14:37:01 2018 -0400
URL: http://code.openbravo.com/erp/devel/pi/rev/86538f0c012469375e97d74760b7f3b265715ef7 [^]

Fixes issue 38273:Current Balance is not updated if an invoice is completed when
Business Partner record is pending to be saved

If while editing a business partner a sales or purchase update the current balance
this value is lost when the entity is saved because has already been changed by
another user or process.

Now when another user or process update the current balance field while editing
the business partner an error message is shown saving the entity

---
M modules/org.openbravo.advpaymentmngt/src-db/database/model/functions/APRM_GEN_PAYMENTSCHEDULE_INV.xml
M modules/org.openbravo.advpaymentmngt/src-db/database/model/functions/APRM_TAX_PAYMENT.xml
M src-db/database/model/functions/C_BP_SOCREDITUSED_REFRESH.xml
---
(0103856)
hgbot   
2018-04-12 17:15   
Repository: erp/devel/pi
Changeset: eb8f5d143b9398a5732b92621fd9943801344a1e
Author: Alvaro Ferraz <alvaro.ferraz <at> openbravo.com>
Date: Thu Apr 12 17:07:02 2018 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/eb8f5d143b9398a5732b92621fd9943801344a1e [^]

Related to issue 38273: Update copyright

---
M modules/org.openbravo.advpaymentmngt/src-db/database/model/functions/APRM_TAX_PAYMENT.xml
M src-db/database/model/functions/C_BP_SOCREDITUSED_REFRESH.xml
---
(0103857)
aferraz   
2018-04-12 17:15   
Code review + Testing OK
(0104378)
hudsonbot   
2018-05-09 19:29   
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/2be7d3efe606 [^]
Maturity status: Test
(0104379)
hudsonbot   
2018-05-09 19:29   
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/2be7d3efe606 [^]
Maturity status: Test