Options

Like the General Journal...

demi222demi222 Member Posts: 131
I'm trying to put two text controls on the bottom of every Ledger entry that will show the Debit Amount and the Credit Amount respectively of whatever is currently shown...
Just like the general journal.. however the general journal shows the total amout and total balance...

I need total debit amount and total credit amount.

can anyone help?

Comments

  • Options
    Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Do you mean totaling all the records which are shown or totaling the current filter?

    --

    Wat is shown can be calculated through the OnAfterGetRecord trigger. This is not advisable in terms of performance.

    If you want to show what is the filter you can copy the funcion CalcBalance in Codeunit 230 and modify it to match your requirements.

    Greetz,

    Marq
  • Options
    demi222demi222 Member Posts: 131
    I mean totaling all the records which are shown. But I need to show them as Debit and Credit.

    I would do COPYFILTERS
    Then I would do something like IF Amount < 0 then Credit +=Amount;
    and the same for debit..

    can someone help me organize.. I don't really know how to do this.
  • Options
    Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    The G/L Entry table already contains debit and credit amount fields.

    However showing the total what is on the form at the moment if very difficult, if not impossible.

    What you can do is make a function which does the totaling for you. If a user selects some records, use SetSelectionFilter and add the columns.

    --
    Still, the easy way is to total all the records within the filter, as been done by the general journal.
  • Options
    demi222demi222 Member Posts: 131
    Mark, you say...Still, the easy way is to total all the records within the filter, as been done by the general journal...

    How can I do it this way?
  • Options
    Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    1. Copy the function CalcBalance from codeunit 230 to e.g. Table 17

    PS. You can simplify the code in the function because you do not have to worry about the xrec.

    2. Change the varables to represent table 17 instead of 81

    3. Replace "Balance (LCY)" by "Debit Amount" and copy this for "Credit Amount"

    Ps. Be sure "debit amount" and "credit amount" are sumindexfields on the current key

    4. On form 20 create 2 decimal variables e.g. TotalDebit and TotalCredit, and place them on the form

    5. Call the function from OnAfterGetCurrRecord

    6. You need not to worry about user imput as in form 39 because G/L Entries are not to be modified (Mostly :D )

    Good Luck

    I Hope not to have forgotten something because I did not try it myself.
  • Options
    demi222demi222 Member Posts: 131
    Thank you,
    I will try this...
  • Options
    demi222demi222 Member Posts: 131
    When you say:
    1. Copy the function CalcBalance from codeunit 230 to e.g. Table 17

    what do you mean? I copy and I paste it into the table? Where?

    to simplify the code, I just don't use xrec..?

    sorry, I'm completely lost here
  • Options
    kinekine Member Posts: 12,562
    Add new function into the FORM:
    function UpdateSums;
    begin
      GLEntry.COPY(Rec);
      GLEntry.CALCSUMS("Credit Amount","Debit Amount");
      Credit := GLEntry."Credit Amount";
      Debit := GLEntry."Debit Amount";
    end;
    

    GLEntry is Record for G/L Entry, Credit and Debit are global var of type Decimal.

    Call this function for example in OnAfterGetCurrRecord.

    Show somewhere the variables Debit and Credit. You are done... (if you are using Native DB, you need to have defined apropriate keys and SumIndexFields for calcualting the sums...)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.