GetGPSalesDealsAdj(TableID : Integer;DocumentNo : Code[20];LineNo : Integer) : Decimal RR_Sales.OPEN(TableID); FR_DocumentNo := RR_Sales.FIELD(3); FR_LineNo := RR_Sales.FIELD(4); FR_DocumentNo.SETRANGE(DocumentNo); FR_LineNo.SETRANGE(LineNo); IF NOT RR_Sales.FINDFIRST THEN BEGIN RR_Sales.CLOSE; EXIT(0); END; IF TableID = DATABASE::"Posted Document Price Entry" THEN; FR_AmountIncludingVAT := RR_Sales.FIELD(30); FR_LineDealAmount := RR_Sales.FIELD(50025); AmountIncludingVAT := FR_AmountIncludingVAT.VALUE; LineDealAmount := FR_AmountIncludingVAT.VALUE; GPSalesDealsAdj := AmountIncludingVAT + LineDealAmount; WITH PostedDocPriceEntry DO BEGIN SETRANGE("Table ID",TableID); SETRANGE("Document No.",DocumentNo); SETRANGE("Document Line No.",LineNo); SETFILTER("Factor Type",'COST|ELEMENT'); IF FINDSET THEN BEGIN REPEAT GPSalesDealsAdj -= "Calculation Value"; UNTIL NEXT = 0; END; END; RR_Sales.CLOSE; EXIT(GPSalesDealsAdj);
GetGPSalesDealsAdj(TableID : Integer;DocumentNo : Code[20];LineNo : Integer) : Decimal CASE TableID OF DATABASE::"Sales Invoice Line": BEGIN SalesInvLine.GET(DocumentNo,LineNo); GPSalesDealsAdj := SalesInvLine."Amount Including VAT" + SalesInvLine."Line Deal Amount"; END; DATABASE::"Sales Cr.Memo Line": BEGIN SalesCrMemoLine.GET(DocumentNo,LineNo); GPSalesDealsAdj := SalesCrMemoLine."Amount Including VAT" + SalesCrMemoLine."Line Deal Amount"; END; END; WITH PostedDocPriceEntry DO BEGIN SETRANGE("Table ID",TableID); SETRANGE("Document No.",DocumentNo); SETRANGE("Document Line No.",LineNo); SETFILTER("Factor Type",'COST|ELEMENT'); IF FINDSET THEN BEGIN REPEAT GPSalesDealsAdj -= "Calculation Value"; UNTIL NEXT = 0; END; END; EXIT(GPSalesDealsAdj);
Answers
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
I was hoping I had discovered a way to cut down some redundancy in my code. I come from an OOP background and I want to create generalized objects all too often :oops:
Systems Analyst
NAV 2009 R2 (6.00.34463)