Form - OnAfterGetCurrRecord() CLEAR(purchLine); CLEAR(TotalPurchLine); //Purchase Line Record CLEAR(TotalPurchLineLCY); //Purchase Line Record FOR i := 1 TO 3 DO BEGIN TempPurchLine.DELETEALL; CLEAR(TempPurchLine); CLEAR(PurchPost); //Purch.-Post Codeunit PurchPost.GetPurchLines(Rec,TempPurchLine,i - 1); CLEAR(PurchPost); CASE i OF 1: purchLine.CalcVATAmountLines(0,Rec,TempPurchLine,TempVATAmountLine1); //VAT Amount Line Record 2: purchLine.CalcVATAmountLines(0,Rec,TempPurchLine,TempVATAmountLine2); 3: purchLine.CalcVATAmountLines(0,Rec,TempPurchLine,TempVATAmountLine3); END; PurchPost.SumPurchLinesTemp( Rec,TempPurchLine,i - 1,TotalPurchLine[i],TotalPurchLineLCY[i], VATAmount[i],VATAmountText[i]); IF "Prices Including VAT" THEN BEGIN TotalAmount2[i] := TotalPurchLine[i].Amount; TotalAmount1[i] := TotalAmount2[i] + VATAmount[i]; TotalPurchLine[i]."Line Amount" := TotalAmount1[i] + TotalPurchLine[i]."Inv. Discount Amount"; TotalAmount2LCY[i] := TotalPurchLineLCY[i].Amount; TotalAmount1LCY[i] := TotalAmount2LCY[i] + VATAmount[i]; TotalPurchLineLCY[i]."Line Amount" := TotalAmount1LCY[i] + TotalPurchLineLCY[i]."Inv. Discount Amount"; END ELSE BEGIN TotalAmount1[i] := TotalPurchLine[i].Amount; TotalAmount2[i] := TotalPurchLine[i]."Amount Including VAT"; TotalAmount1LCY[i] := TotalPurchLineLCY[i].Amount; TotalAmount2LCY[i] := TotalPurchLineLCY[i]."Amount Including VAT"; END; END;
Comments
1) Since you copied the code from the statistics form (form 403) maybe you should not just copy the variable names and types, but also the properties... like being a temporary record.
2) Unless you need the three amounts: invoiced, to be shipped and total in the form you should just get the code that you need instead all of it....