...
SETRANGE("No.");
IF CurrentDate <> WORKDATE THEN BEGIN
CurrentDate := WORKDATE;
END;
SETRANGE("Date Filter",0D,CurrentDate);
CALCFIELDS(
Balance,"Balance (LCY)","Balance Due","Balance Due (LCY)",
"Outstanding Orders (LCY)","Shipped Not Invoiced (LCY)");
TotalAmountLCY := "Balance (LCY)" + "Outstanding Orders (LCY)" + "Shipped Not Invoiced (LCY)" + "Outstanding Invoices (LCY)";
CALCFIELDS(
// Delete the following line.
"Sales (LCY)","Profit (LCY)","Inv. Discounts (LCY)","Inv. Amounts (LCY)","Pmt. Discounts (LCY)",
"Pmt. Disc. Tolerance (LCY)","Pmt. Tolerance (LCY)",
"Fin. Charge Memo Amounts (LCY)","Cr. Memo Amounts (LCY)","Payments (LCY)",
"Reminder Amounts (LCY)","Refunds (LCY)","Other Amounts (LCY)");
SETRANGE("Date Filter",0D,CurrentDate);
...
...
SETRANGE("No.");
IF CurrentDate <> WORKDATE THEN BEGIN
CurrentDate := WORKDATE;
END;
// Add the following lines.
StartDate := AccountingPeriod.GetFiscalYearStarttDate(CurrentDate);
EndDate := AccountingPeriod.GetFiscalYearEndtDate(CurrentDate);
CustomerSalesYTD := Rec;
CustomerSalesYTD.SETRANGE("Date Filter",StartDate,EndDate);
CustomerSalesYTD.CALCFIELDS("Sales (LCY)");
"Sales (LCY)" := CustomerSalesYTD."Sales (LCY)";
// End of the lines.
SETRANGE("Date Filter",0D,CurrentDate);
CALCFIELDS(
Balance,"Balance (LCY)","Balance Due","Balance Due (LCY)",
"Outstanding Orders (LCY)","Shipped Not Invoiced (LCY)");
TotalAmountLCY := "Balance (LCY)" + "Outstanding Orders (LCY)" + "Shipped Not Invoiced (LCY)" + "Outstanding Invoices (LCY)";
CALCFIELDS(
// Add the following line.
"Profit (LCY)","Inv. Discounts (LCY)","Inv. Amounts (LCY)","Pmt. Discounts (LCY)",
"Pmt. Disc. Tolerance (LCY)","Pmt. Tolerance (LCY)",
"Fin. Charge Memo Amounts (LCY)","Cr. Memo Amounts (LCY)","Payments (LCY)",
"Reminder Amounts (LCY)","Refunds (LCY)","Other Amounts (LCY)");
SETRANGE("Date Filter",0D,CurrentDate);
...