Options

Report most recent date Customer Ledger Entry

andy76andy76 Member Posts: 616
Hello,

I don't remember how to obtain the most recent record (Posting Date) in a table such as Customer Ledger Entry, after sorting it.

Thank you

Comments

  • Options
    mohana_cse06mohana_cse06 Member Posts: 5,503
    Open Customer Card-->Customer-->Entry Statistics..
    Check how Date field is calculating..
  • Options
    andy76andy76 Member Posts: 616
    Which Date field do you mean, on code or on the screen.
    On screen I don't see date fields.

    Thank you
  • Options
    SavatageSavatage Member Posts: 7,142
    What are you looking for? a function?

    Like "FindLast"?
    http://msdn.microsoft.com/en-us/library/dd355375
  • Options
    faizguy84faizguy84 Member Posts: 52
    Do the sorting on posting date and use FindLast in customer ledger entry for each customer.

    Regards,
    Faisal Bukhari
  • Options
    andy76andy76 Member Posts: 616
    Last requirement (changed respect previous one) is to have, on Customer Card, the date o last Posted Invoices and number of days between this date and actual day.
    Do you have some suggestion to calculate that?

    Thank you
  • Options
    faizguy84faizguy84 Member Posts: 52
    "number of days between this date and actual day"

    What does this day and actual date means????

    _____________
    Regards,
    Faisal Bukhari
  • Options
    mohana_cse06mohana_cse06 Member Posts: 5,503
    andy76 wrote:
    Last requirement (changed respect previous one) is to have, on Customer Card, the date o last Posted Invoices and number of days between this date and actual day.
    Do you have some suggestion to calculate that?

    Thank you
    And also let us know what did you try and what is not working..
  • Options
    andy76andy76 Member Posts: 616
    I have to begin the development.
    I think to create a new report that pass along Customer and Customer Ledger Entries.
    Is that ok or can I find these info in other parts?

    Thank you
  • Options
    mohana_cse06mohana_cse06 Member Posts: 5,503
    faizguy84 wrote:
    "number of days between this date and actual day"

    What does this day and actual date means????
    [-o< [-o<
  • Options
    andy76andy76 Member Posts: 616
    no. of days between last invoice and today
  • Options
    mohana_cse06mohana_cse06 Member Posts: 5,503
    NoofDays := TODAY - LastInvoicedDate;
    :thumbsup:
  • Options
    SavatageSavatage Member Posts: 7,142
    andy76 wrote:
    , on Customer Card, the date of the last Posted Invoices

    Create A flowfield in the Customer Table

    50050 -> Last Invoice Date -> Datatype=Date
    FieldClass->Flowfield
    CalcFormula->Max("Cust. Ledger Entry"."Posting Date" WHERE (Document Type=FILTER(Invoice),Customer No.=FIELD(No.)))

    Add the new field to customer card.

    Save->Compile->Enjoy!
  • Options
    andy76andy76 Member Posts: 616
    Very good, I made that and seems ok.

    I don't understand when the field is exactly calculated.
    I see that all records have this field populated also if not scrolled in the form...
    When I make a new invoice for customer X, is this new field refreshed automatically.?

    I ask you that because we should extract this data of Customer table via a query.
  • Options
    SavatageSavatage Member Posts: 7,142
    If you're going to use it in a report you need to use the command CALCFIELDS to get it's current value.
    Just like any other flowfield. ie/ Balance field, etc.
    Customer.CALCFIELDS("Last Invoice Date"); needs to be added to your report to populate the field with it's current value.

    http://msdn.microsoft.com/en-us/library/dd338766.aspx

    If you view the field in form or table - it will be correct & updated.
    It finds the largest(newest) posting date of an "Invoice" type ledger entry. Therefore giving you the last invoice date for that customer.
  • Options
    andy76andy76 Member Posts: 616
    Ok, this means that should be better make a report of NAV than to create a SQL Query to extract data.

    But if I would also want to calculate the no. of days betweend that date and today, automatically updated for all customer?
    I would like to see that updated correctly in Customer List form.
  • Options
    SavatageSavatage Member Posts: 7,142
    andy76 wrote:
    But if I would also want to calculate the no. of days betweend that date and today.
    NoofDays := TODAY - "Last Invoice Date";
    :thumbsup:
  • Options
    andy76andy76 Member Posts: 616
    I know how to calculate it but not where to write the code to calculate it for all Customers and save it in the table...in which trigger?
  • Options
    SavatageSavatage Member Posts: 7,142
    I don't know if it's a "Save to table" type of value since it constantly needs recalculating. For me the date would be enough. and the #ofdays seems like overkill. It something you can easily calc for reports but you also wanty it to show on a form.

    I don;t like putting code on forms - but if it's just for a visual effect on the customer list then you have to calc it on the form.

    Add a global var to the form "NoOfDays" type integer.
    OnAfterGetRecord() of the form
    CALCFIELDS("Last Invoice Date");
    NoofDays := TODAY -"Last Invoice Date";

    Drop an integer type field onto the list & change the sourceexp to "NoOfDays" or whatever name you give it.
Sign In or Register to comment.