0

Need help transforming this C/AL code to Jet

Trying to correctly do an aging report in Jet based off of the Inventory Valuation report in NAV 2009 R2. Here is the aging and cost calculation part.. can anyone help explain what is going on here?
From what I can see they are using the Item Ledger Entry, Value Entry and Item Application Entry to adjust the remaining quantity by the posting date but I'm getting stuck trying to do that in Jet functions. I attached my document I've been working on if it helps

WITH ItemLedgEntry DO BEGIN // adjust remaining quantity "Remaining Quantity" := Quantity; IF Positive THEN BEGIN ItemApplnEntry.RESET; ItemApplnEntry.SETCURRENTKEY( "Inbound Item Entry No.","Item Ledger Entry No.","Outbound Item Entry No.","Cost Application"); ItemApplnEntry.SETRANGE("Inbound Item Entry No.","Entry No."); ItemApplnEntry.SETRANGE("Posting Date",0D,AsOfDate); ItemApplnEntry.SETFILTER("Outbound Item Entry No.",'<>%1',0); ItemApplnEntry.SETFILTER("Item Ledger Entry No.",'<>%1',"Entry No."); IF ItemApplnEntry.FIND('-') THEN REPEAT IF ItemLedgEntry2.GET(ItemApplnEntry."Item Ledger Entry No.") AND (ItemLedgEntry2."Posting Date" <= AsOfDate) THEN "Remaining Quantity" := "Remaining Quantity" + ItemApplnEntry.Quantity; UNTIL ItemApplnEntry.NEXT = 0; END ELSE BEGIN ItemApplnEntry.RESET; ItemApplnEntry.SETCURRENTKEY( "Outbound Item Entry No.","Item Ledger Entry No.","Cost Application","Transferred-from Entry No."); ItemApplnEntry.SETRANGE("Item Ledger Entry No.","Entry No."); ItemApplnEntry.SETRANGE("Outbound Item Entry No.","Entry No."); ItemApplnEntry.SETRANGE("Posting Date",0D,AsOfDate); IF ItemApplnEntry.FIND('-') THEN REPEAT IF ItemLedgEntry2.GET(ItemApplnEntry."Inbound Item Entry No.") AND (ItemLedgEntry2."Posting Date" <= AsOfDate) THEN "Remaining Quantity" := "Remaining Quantity" - ItemApplnEntry.Quantity; UNTIL ItemApplnEntry.NEXT = 0; END; // calculate adjusted cost of entry ValueEntry.RESET; ValueEntry.SETCURRENTKEY("Item Ledger Entry No.","Entry Type"); ValueEntry.SETRANGE("Item Ledger Entry No.","Entry No."); ValueEntry.SETRANGE("Posting Date",0D,AsOfDate); IF ValueEntry.FIND('-') THEN REPEAT ExpectedValue := ExpectedValue + ValueEntry."Cost Amount (Expected)"; ExpectedValueACY := ExpectedValueACY + ValueEntry."Cost Amount (Expected) (ACY)"; InvoicedValue := InvoicedValue + ValueEntry."Cost Amount (Actual)"; InvoicedValueACY := InvoicedValueACY + ValueEntry."Cost Amount (Actual) (ACY)"; UNTIL ValueEntry.NEXT = 0; "Cost Amount (Actual)" := ROUND(InvoicedValue + ExpectedValue); "Cost Amount (Actual) (ACY)" := ROUND(InvoicedValueACY + ExpectedValueACY,Currency."Amount Rounding Precision"); END;

0 comments

Please sign in to leave a comment.