Sum up invoice amount until payment entry in cust ledger ent

wangjanymwangjanym Member Posts: 21
Well, I need some expert's tip how to do this. Please look below. The Entry is sorted by posting date. I want the report to sum up all invoices until the payment entry then I want it the sub total again until next payment entry. I just don't know the code to sub total invoice amount until the payment entry and restart the transaction again and again.

Any ideas?
Thanks in advance.

267.2 3/31/2008 Invoice
252.65 4/4/2008 Invoice
73 4/4/2008 Invoice
425.78 4/25/2008 Invoice
111.16 5/6/2008 Invoice
SubTotal : 1129.79
0 5/7/2008 Payment
0 5/12/2008 Payment
0 5/30/2008 Payment
395.13 6/30/2008 Invoice
179.14 7/9/2008 Invoice
SubTotal : 574.27
0 7/24/2008 Payment
505.89 9/23/2008 Invoice
146.38 9/30/2008 Invoice
SubTotal : 652.27

Comments

  • faizguy84faizguy84 Member Posts: 52
    Do u want to add the payment amount in subtotal or it is only invoice amount ?
  • gerrykistlergerrykistler Member Posts: 149
    You will need to use a decimal variable to store the sum, say InvTotal

    OnPreDataItem
    InvTotal := 0;
    
    OnAfterGetRecord:
    if "Document Type" = "Document Type"::Invoice then
      InvTotal += Amount
    else
      InvTotal := 0;
    

    Would would then probably need two different Body sections, one with the detail that gets printed when it is an invoice and another when it is a payment, plus a footer in case the last entry is an invoice. Since your example shows multiple payments you probably need to have a boolean to tell when to print the total so it only prints with the first payment after an invoice. Unless of course you can make the sort Posting Date, Document Type, then you could use a Group Footer on the Document Type for the subtotals.
    Gerry Kistler
    KCP Consultores
  • wangjanymwangjanym Member Posts: 21
    Thanks a lot guys. I appreciated your postings.

    Justin
Sign In or Register to comment.