Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#2678 Payment Does not change Open Balance

R2.6.3
closed
nnayak
5
2007-12-11
2007-11-28
Stephan Keller
No

Version 2.6.3 2007-7-30

Open Balance is not updated after a payment is completed when the payment is directly allocated to one invoice.

Start with a new BP.
Create one AP invoice for 100 and complete it. The open balance is -100.
Create an AP payment selecting the BP and the invoice just created. Complete payment. The open balance stays at -100 (should be 0).

Run "Validate Business Partner" and the open balance is correctly set to 0.

This is due to the following code in MPayment.java, completeIt method:

if (getC_BPartner_ID() != 0 && getC_Invoice_ID() == 0)
{...bp.setTotalOpenBalance()...}
Seems to me that this should be:
if (getC_BPartner_ID() != 0)
{...bp.setTotalOpenBalance()...}

Stephan Keller
Sodexis.

Discussion

  • sboda
    sboda
    2007-11-28

    • assigned_to: nobody --> sboda
     
  • Stephan Keller
    Stephan Keller
    2007-11-28

    Logged In: YES
    user_id=1617011
    Originator: YES

    one more thing:
    in 2.6.3 the bp.setTotalOpenBalance() collect the information from invoices and payments that are completed and closed (looks like this was changed from earlier versions), but when bp.setTotalOpenBalance() is called (here as well as in the allocation) the payment is not completed yet, so the current payment that is being completed is not included in the open balance calculation. The solution is maybe to add the payment amount to the open balance directly as it is done in MInvoice.

    Stephan.

     
  • Stephan Keller
    Stephan Keller
    2007-11-28

    Logged In: YES
    user_id=1617011
    Originator: YES

    I see the same issue when reversing the payment. After reversing the payment the open balance is not changed (again it changes if I run "validate business partner"). At the end of reverseCorrectIt in Mpayment, the payment should be saved before the openbalance is recalculated, this was correctly done in MInvoice.

    Stephan.

     
  • sboda
    sboda
    2007-11-29

    Logged In: YES
    user_id=1705860
    Originator: NO

    Hi Stephen,

    This issue has been fixed, it should be available in next release.

    Thanks,
    Sabitha

     
  • sboda
    sboda
    2007-11-29

    • status: open --> pending
     
  • Stephan Keller
    Stephan Keller
    2007-12-01

    Logged In: YES
    user_id=1617011
    Originator: YES

    Sabitha,

    Thanks, that sounds good.

    There is one more problem, I just noticed that the balance calculation (bp.setTotalOpenBalance()) does not take into account discount. If you start with a BP that has a zero balance and create an invoice with payment term that has a discount and simply pay it with one payment. After using validate BP you will see that the balance is not zero, but whatever the discount is. Was this fixed as well?

    Also, any chance to get the code for this such that I can apply it for my customer?

    Thanks,
    Stephan Keller,
    Sodexis.

     
  • Stephan Keller
    Stephan Keller
    2007-12-01

    • status: pending --> open
     
  • Stephan Keller
    Stephan Keller
    2007-12-02

    Logged In: YES
    user_id=1617011
    Originator: YES

    Sabitha,

    I looked at the last issue. I think that what needs to be done is to substract in bp.setTotalBalance() the discount amount and the write-off amount from all the allocation lines that have both an invoice and a payment and that have the allocation header with docstatus=CO or CL (to avoid reversed allocation).

    Something like:
    + "-COALESCE((SELECT SUM(currencyBase(al.DiscountAmt+al.WriteOffAmt,i.C_Currency_ID,i.DateOrdered,al.AD_Client_ID,al.AD_Org_ID)) "
    + "FROM C_AllocationLine al INNER JOIN C_Invoice i ON (al.C_Invoice_ID=i.C_Invoice_ID) "
    + "INNER JOIN C_AllocationHDR a ON (al.C_AllocationHDR_ID=a.C_AllocationHDR_ID)"
    + "WHERE al.C_BPartner_ID=bp.C_BPartner_ID AND al.IsActive='Y' AND a.DocStatus IN ('CO','CL')"
    + "AND al.C_Payment_ID IS NOT NULL AND al.C_Invoice_ID IS NOT NULL),0) "

    It is not clear to me what date exactly to use for the currency conversion.
    Same thing need to be done for the SO_CreditUsed.

    Stephan Keller,
    Sodexis.

     
  • sboda
    sboda
    2007-12-04

    • status: open --> pending
     
  • sboda
    sboda
    2007-12-04

    Logged In: YES
    user_id=1705860
    Originator: NO

    Stephen,

    There is one more problem, I just noticed that the balance calculation
    (bp.setTotalOpenBalance()) does not take into account discount. If you
    start with a BP that has a zero balance and create an invoice with payment
    term that has a discount and simply pay it with one payment. After using
    validate BP you will see that the balance is not zero, but whatever the
    discount is. Was this fixed as well?

    ........ Yes this issue has been fixed.

    Also, any chance to get the code for this such that I can apply it for my
    customer?

    .........3.0 Release yesterday

     
  • Stephan Keller
    Stephan Keller
    2007-12-05

    Logged In: YES
    user_id=1617011
    Originator: YES

    Sabitha,

    Checked it in compiere 3.0 and it works fine. Thanks.

    Stephan.

     
  • Stephan Keller
    Stephan Keller
    2007-12-05

    • status: pending --> closed
     
  • Stephan Keller
    Stephan Keller
    2007-12-06

    Logged In: YES
    user_id=1617011
    Originator: YES

    Sabitha,

    Sorry, reviewing the code I noticed a problem.
    If you complete a payment with a charge. The payment self allocate as it should and the balance should not change. As of right now if you do that the balance is changed. If I validate the BP after then the balance adjust correctly.

    I think that the code in MPayment.completeit between
    // Total Balance
    BigDecimal newBalance = bp.getTotalOpenBalance(false);
    and
    return DocAction.STATUS_Invalid;
    }

    should only be executed if (getC_Charge_ID() == 0).

    Stephan.

     
  • Stephan Keller
    Stephan Keller
    2007-12-06

    • status: closed --> open
     
  • sboda
    sboda
    2007-12-06

    Logged In: YES
    user_id=1705860
    Originator: NO

    Thanks Stephen!

    I have replicated below issue in latest version.

    Sabitha

     
  • sboda
    sboda
    2007-12-06

    • milestone: 746433 --> R2.6.3
    • assigned_to: sboda --> nnayak
     
  • sboda
    sboda
    2007-12-06

    • labels: --> Business Partner
     
  • Kathy Pink
    Kathy Pink
    2007-12-11

    Logged In: YES
    user_id=329831
    Originator: NO

    We are moving all Open Support Requests, Bugs and Feature Requests to Compiere Case Management. Please refer to the following link for information on creating new Support Requests.
    http://www.compiere.com/support/community.php

    Thank you

     
  • Kathy Pink
    Kathy Pink
    2007-12-11

    • status: open --> closed