Options

Connecting Payments to Invoices

MauddibMauddib Member Posts: 269
I know this might seem awfully stupid but when you look at payments in the tables 21 and 379... how do you actually work out which Invoices they were applied to? Im trying Navigate and all kinds of things and rarely am I finding a connection between payments and the invoices they were applied to.

To clarify... you pull a payment from table 21 in C/AL code into a record variable.

Based on the data in that record, how will you find the document number of the invoice this payment relates to?

GmcB

Comments

  • Options
    KowaKowa Member Posts: 918
    edited 2005-09-27
    The Navigate function only works if the document no. and usually also the posting date are the same. This will be the case if a "Bal. Account No." is filled for the "Payment Method" (Table 289).(i.e. Cash Payment ) The Cust. Ledger Entry is then automatically closed when the invoice is posted.

    If the posting dates are different ( manually appilied payment ) but the document no. is the same, Navigate can be used with undefined date.

    The field "Closed by Entry No." in Table 21 can be always be used to find the closing entry (if there a partial payments there may be more than one).
    Kai Kowalewski
  • Options
    MauddibMauddib Member Posts: 269
    The payments method table is empty in the company Im looking at.

    There could also be more than one payment against an invoice so the closed by entry number might not work?

    I need to be able to pull out ANY payment in the system and match it to the invoice it was applied to.
  • Options
    Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    If you take a look at form 232 you will see how Navision does this.

    Application is a very complicated thing in Navision.

    It is best you take what you need and leave most of the code what you don't need out with the setup you have done.
  • Options
    SavatageSavatage Member Posts: 7,142
    Maybe I didn't read it clearly but what about

    Application->Applied Entries
  • Options
    Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Savatage wrote:
    Maybe I didn't read it clearly but what about

    Application->Applied Entries

    Yes, this is also form 232.
  • Options
    KowaKowa Member Posts: 918
    Savatage wrote:
    Maybe I didn't read it clearly but what about

    Application->Applied Entries

    Yes, this is also form 232.

    No, this is Form 61.:wink:
    The code in this form can be used to find all entries that closed each other.
    Kai Kowalewski
  • Options
    Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Yes, you are right. I had the wrong form number in my mind.

    Thanks for the correction :D
  • Options
    Iqbal_FebrianoIqbal_Febriano Member Posts: 66
    I hope I didn't get it wrong. But you can use field "Applies-to Doc. No." or "Closed by Entry No." in table 21 (Cust. Ledger Entry) to find the information you need.
    Be fast, be straight, be quiet
  • Options
    MauddibMauddib Member Posts: 269
    I dont think you can use the closed by fields as this only shows the last application made doesnt it? It wont work in situations where..

    1) One payment was applied to more than one invoice
    2) One invoice required more than one payment to close it.

    Im a little new to navision programming. Surely there is a bit of code there that, given a payment document number of ledger entry number, you can list the invoices it had been related to?

    GmcB
  • Options
    Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    You are right and I must admit that this post is getting a bit confusing, which is partly on me to blame. :?

    Have you looked at the code in form 61?

    If you look in the OnOpenForm trigger you will find the code you need I think.

    If a payment is applied to more invoices you can see this in the detailed entries.
  • Options
    KowaKowa Member Posts: 918
    The Field "Cust. Ledger Entry No." in Table 379 "Detailed Cust. Ledg. Entry" is the same for the invoice and all payments. Use the "Entry No." of Table 21 and put a filter on this field.
    If only one amount was posted for several invoices these are split up into separate entries in this table.
    There are some G/L comfort add-ons which in this case create one payment entry for the full amount and a correction entry of the same amount and then create a separate payment entry for each invoice in "Cust. Ledger Entry", but in standard Navision the "Detailed Customer Ledger Entries" have to be used.
    Kai Kowalewski
  • Options
    MauddibMauddib Member Posts: 269
    I did this. I took the entry number from table 21 and used it as the filter on the detailed table. This gives all kinds of entries such as initial entry, application and so on.

    Fraid this is no good either. The document number for the payment in table 21 is the same as the document number used in the detailed entries table. No sign of the invoice numbers anywhere on this table.

    G
  • Options
    KowaKowa Member Posts: 918
    If you need an extra invoice number this can be filled into "External Document No." in the journal line, this will then be copied into Table 21 / Field 63
    Kai Kowalewski
Sign In or Register to comment.