I created a Customer Sales Report, but when I retrieve the report, one of the item whose quantity are negative(-200), but the contribution margin are positive(+200). I create the report based on three tables, Customer, Value Entry, Cus. Ledger Entry. Here is part of my code. Can any expert find the bugs? Thanks!
Value Entry - OnPreDataItem()
CurrReport.CREATETOTALS("Invoiced Quantity","Sales Amount (Actual)",Profit,"Discount Amount");
SETFILTER("Invoiced Quantity",'<>0');
Value Entry - OnAfterGetRecord()
Profit := "Sales Amount (Actual)" + "Cost Amount (Actual)";
"Discount Amount" := -"Discount Amount";
Res. Ledger Entry - OnAfterGetRecord()
TotalSales := TotalSales + -"Res. Ledger Entry"."Total Price";
ResourceProfit := (-"Res. Ledger Entry"."Total Price") - (-"Res. Ledger Entry"."Total Cost");
ContribMargin := ContribMargin + (-"Res. Ledger Entry"."Total Price") - (-"Res. Ledger Entry"."Total Cost");
Customer, Footer (8) - OnPreSection()
"CalcProf%"(("Value Entry"."Sales Amount (Actual)" + -"Res. Ledger Entry"."Total Price"),(Profit + ResourceProfit));
0
Comments
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n