#118 Bank Statement not Balanced (bug)

X-R2.4.2
closed
Jorg Janke
7
2002-05-29
2002-05-27
Arash Zeini
No

- What did you want to achieve?

I wanted to create an order with "Target Document Type"
as "Walk-In Receipt". Payment method is set to "on credit".
The customer has enough credit to buy a product.

- What did you do and how can we reproduce it?

Probably difficult to reproduce as it is based on my own
accounting rules.

- How did the system react?

It doesn't post the order stating "Not balanced". At the
other hand in Open Items/Payment I can see the invoice
and can make the payment, which then is posted
successfully. It appears also in the "Accounting fact"
window.

What doesn "Not Balanced" mean in this context and how
can I solve the problem?

Discussion

  • Jorg Janke
    Jorg Janke
    2002-05-27

    Logged In: YES
    user_id=87038

    OK, the issue seems to be:
    When you post an invoice, you get "Not Balanced".
    I had a look in the code: It seems the only way an invoice can
    be out of balance is if you use Charges. Charges are fully
    implemented in the accounting part, but I think not in the
    actually invoicing.
    Please do the following: Run the Application server with trace
    level 6 or higher. Post the invoice. In the server log, it is
    explicitly printed what the balance is.
    There are two balances: source balance (i.e. the document is
    not OK) and accounting balance (i.e. after optional currency
    conversion the accounting lines balance).

     
  • Jorg Janke
    Jorg Janke
    2002-05-27

    • priority: 9 --> 7
     
  • Arash Zeini
    Arash Zeini
    2002-05-27

    Logged In: YES
    user_id=320514

    OK, I will try this tomorrow.
    I know that I am not using charges explicitly. I have to see
    where they come in. I know from earlier times that I was
    getting an error message stating 'Source not balanced'.

     
  • Arash Zeini
    Arash Zeini
    2002-05-28

    server log for not balanced

     
    Attachments
  • Arash Zeini
    Arash Zeini
    2002-05-28

    Logged In: YES
    user_id=320514

    The whole day I have played with the system, but couldn't figure
    out what happens. I get the "Not balanced" message almost
    throughout the process. I am sending you here a log from the
    server with regards to "Bank statement" for a check payment. I
    can process the statement but when I post it, I get "Not
    balanced", with the following log message:
    See attachment

     
  • Jorg Janke
    Jorg Janke
    2002-05-28

    Logged In: YES
    user_id=87038

    According to the log, you have an unbalanced Bank
    Statement. The C_BankStatement_ID=1000009 with header
    = 8888 and line=0.
    If you click on Notice (in the menu), you should see it and
    you can zoom from there to the document.

     
  • Jorg Janke
    Jorg Janke
    2002-05-28

    • summary: order not posting --> Bank Statement not Balanced
    • status: open --> pending
     
  • Arash Zeini
    Arash Zeini
    2002-05-28

    Logged In: YES
    user_id=320514

    I tried to use "Notice" yesterday for the "Not balanced" orders
    but it didn't allow me to zoom into the document. It simply did
    nothing.
    I will try this for the Bank statement too.

    It might help me fixing the problem, if you could tell me what the
    "balance" means here , in this context.

    Thanks,
    AZ

     
  • Arash Zeini
    Arash Zeini
    2002-05-28

    • status: pending --> open
     
  • Jorg Janke
    Jorg Janke
    2002-05-28

    Logged In: YES
    user_id=87038

    Fresh from the source:
    public BigDecimal getBalance()
    {
    BigDecimal retValue = Env.ZERO;
    StringBuffer sb = new StringBuffer (" [");
    // Total
    retValue = retValue.add(getAmount
    (Doc.AMTTYPE_Gross));
    sb.append(getAmount
    (Doc.AMTTYPE_Gross));
    // - Lines
    for (int i = 0; i < p_lines.length; i++)
    {
    retValue = retValue.subtract
    (p_lines[i].getAmount());
    sb.append("-").append
    (p_lines[i].getAmount());
    }
    sb.append("]");
    //
    Log.trace(Log.l4_Data, toString() + "
    Balance=" + retValue + sb.toString());
    return retValue;
    } // getBalance
    ---
    i.e. your Bank Statement gross (total) is 8888 and your lines
    in that BanlStatements are 0 (i.e. the bank Statement has no
    lines).
    This is odd. The C_BankStatement_Post updates the
    StatementDifference with the Total (StmtAmt) of the lines.
    Could you please check the bank statement:
    SELECT bs.C_BankStatement_ID, bs.Name,
    bs.StatementDifference, bs.Processed, bs.Posted, SUM
    (bsl.StmtAmt)
    FROM C_BankStatement bs, C_BankStatementLine bsl
    WHERE bs.C_BankStatement_ID=bsl.C_BankStatement_ID
    GROUP BY bs.C_BankStatement_ID, bs.Name,
    bs.StatementDifference, bs.Processed, bs.Posted
    ****
    Reclassifying as Support Request

     
  • Jorg Janke
    Jorg Janke
    2002-05-28

    • labels: 364562 -->
    • milestone: 186884 -->
    • assigned_to: jjanke --> nobody
     
  • Jorg Janke
    Jorg Janke
    2002-05-28

    • labels: --> Functional Problem (how to ..)
    • milestone: --> X-R2.4.2
    • assigned_to: nobody --> jjanke
    • status: open --> pending
     
  • Jorg Janke
    Jorg Janke
    2002-05-28

    Logged In: YES
    user_id=87038

    *** Status set to PENDING ***
    If the issue solved, please CLOSE this request -
    otherwise set the status back to OPEN
    (we only check OPEN items).
    If there is no reaction within a week, we assume
    it works and the system will automatically CLOSE it.
    ***

     
  • Arash Zeini
    Arash Zeini
    2002-05-29

    Screenshot of Bank statement and line

     
    Attachments
  • Arash Zeini
    Arash Zeini
    2002-05-29

    • status: pending --> open
     
  • Arash Zeini
    Arash Zeini
    2002-05-29

    Logged In: YES
    user_id=320514

    I have attached a screenshot to show you both screens of the
    document. The Bank Statement was created via "create from"
    and the line seems to have the necessary information. At least it
    is not empty.

    I will post the result of the SQL afterward.

     
  • Arash Zeini
    Arash Zeini
    2002-05-29

    Result of the SQL statement

     
    Attachments
  • Arash Zeini
    Arash Zeini
    2002-05-29

    Logged In: YES
    user_id=320514

    C_BANKSTATEMENT_ID,2,,10,0,NUMBER,22,C_BANKSTATEMENT_ID,,,java.math.BigDecimal,
    NAME,12,,60,0,VARCHAR2,60,NAME,,,java.lang.String,
    STATEMENTDIFFERENCE,2,,0,0,NUMBER,22,STATEMENTDIFFERENCE,,,java.math.BigDecimal,
    PROCESSED,1,,1,0,CHAR,1,PROCESSED,,,java.lang.String,
    POSTED,1,,1,0,CHAR,1,POSTED,,,java.lang.String,
    SUM(BSL.STMTAMT),2,,0,0,NUMBER,22,SUM(BSL.STMTAMT),,,java.math.BigDecimal,

     
  • Arash Zeini
    Arash Zeini
    2002-05-29

    Logged In: YES
    user_id=320514

    I am writing this on behalf of arashb.

    By going through the code, he has found that there might be a
    problem in /server/org/compiere/acct/DocLine_Bank.java, in
    SetAmount, which causes the "Not Balanced" problem. It seems
    that the amounts set are not passed further, which makes
    Compiere think it is unbalanced, whereas as you can see in the
    screenshots the amounts are there and set in fact through
    Compiere itself through the "create from" button.

    This again, as we suspect, could be connected to the fact if
    Multicurrency for an organization is selected or not!??!?!?! In
    case an organization has multicurrency enabled, it doesn't check
    for balance, which might be the case in GardenWorld. But in our
    organization this might not be the case and hence the same
    code and application returns an error where there should not be
    one. I.e. it chekces for balances but as the values are not
    passed correctly, the post fails.

    Could this be the case???

     
  • Jorg Janke
    Jorg Janke
    2002-05-29

    • summary: Bank Statement not Balanced --> Bank Statement not Balanced (bug)
    • status: open --> pending
     
  • Jorg Janke
    Jorg Janke
    2002-05-29

    Logged In: YES
    user_id=87038

    Yep, sorry it is a bug. The Doc_BankStatement.getBalance()
    should be:
    // - Lines
    for (int i = 0; i < p_lines.length; i++)
    {
    BigDecimal lineBalance = ((DocLine_Bank)p_lines
    [i]).getStmtAmt();
    retValue = retValue.subtract(lineBalance);
    sb.append("-").append(lineBalance);
    }
    --
    The test cases we used had a zero total ;-( [usually this is
    agood thing as if your balance is zero - you are OK]
    Sorry about this. I fixed it (CVS updated).

     
  • Arash Zeini
    Arash Zeini
    2002-05-29

    • status: pending --> open
     
  • Arash Zeini
    Arash Zeini
    2002-05-29

    Logged In: YES
    user_id=320514

    OK, Thanks :)

     
  • Jorg Janke
    Jorg Janke
    2002-05-29

    • status: open --> closed