Item Age Composition by Value

couberpucouberpu Member Posts: 317
edited 2007-02-06 in Navision Attain
Good Morning,

Has anybody had problems with report 5808, Item age composition - value, using FIFO as costing method? My total inventoryvalue is much less than the total of invtvalue! :?:

I did a quick and dirty fix in CalcUnitCost function to produce the report for the bank. But I am not sure is this a existing Navision issue or something I did. Here is what I think went wrong:
Item Ledger Entry - OnAfterGetRecord()
ValueEntry.SETRANGE("Item Ledger Entry No.","Entry No.");

CalcRemainingQty;

IF "Remaining Quantity" <> 0 THEN BEGIN
  IF Item."Costing Method" = Item."Costing Method"::Average THEN
    TotalInvtValue := AverageCost * TotalInvtQty
  ELSE BEGIN
    CalcUnitCost;
    TotalInvtValue := UnitCost * TotalInvtQty;
  END;
  FOR i := 1 TO 5 DO
    IF ("Posting Date" > PeriodStartDate[i]) AND
      ("Posting Date" <= PeriodStartDate[i + 1]) THEN
      IF Item."Costing Method" = Item."Costing Method"::Average THEN
        InvtValue[i] := AverageCost *  InvtQty[i];
END;

then in function CalcUnitCost:
CalcUnitCost()
WITH ValueEntry DO BEGIN
  TotalInvoicedQty := 0;
  ExpectedUnitCost := 0;
  UnitCost := 0;
  FOR i := 1 TO 5 DO BEGIN
    InvtValue[i] := 0;
    ExpectedInvtValue[i] := 0;
  END;

  IF FIND('-') THEN BEGIN
    REPEAT
      TotalInvoicedQty := TotalInvoicedQty + "Invoiced Quantity";
      FOR i := 1 TO 5 DO
        IF ("Posting Date" > PeriodStartDate[i]) AND
          ("Posting Date" <= PeriodStartDate[i + 1])
        THEN BEGIN
          InvtValue[i] := InvtValue[i] + "Cost Amount (Actual)";
          ExpectedInvtValue[i] := ExpectedInvtValue[i] + "Cost Amount (Expected)"
        END;
      ExpectedUnitCost := ExpectedUnitCost + "Cost Amount (Expected)";
      UnitCost := UnitCost + "Cost Amount (Actual)";
    UNTIL NEXT = 0;
    IF TotalInvoicedQty <> 0 THEN
      UnitCost := UnitCost / TotalInvoicedQty;
    ExpectedUnitCost := ExpectedUnitCost / "Item Ledger Entry".Quantity;
  END;

  IF TotalInvoicedQty <> "Item Ledger Entry".Quantity THEN BEGIN
    UnitCost := ExpectedUnitCost;
    FOR i := 1 TO 5 DO
      InvtValue[i] := ExpectedInvtValue[i];
  END;
END;

the last 2 line in function CalcUnitCost seems to be the problem. So I comment them out and make the change to Item Ledger Entry - AfterGetRecord
Item Ledger Entry - OnAfterGetRecord()
ValueEntry.SETRANGE("Item Ledger Entry No.","Entry No.");

CalcRemainingQty;

IF "Remaining Quantity" <> 0 THEN BEGIN
  IF Item."Costing Method" = Item."Costing Method"::Average THEN
    TotalInvtValue := AverageCost * TotalInvtQty
  ELSE BEGIN
    CalcUnitCost;
    TotalInvtValue := UnitCost * TotalInvtQty;
    FOR i := 1 TO 5 DO
      InvtValue[i] := UnitCost * InvtQty[i];
  END;
  FOR i := 1 TO 5 DO
    IF ("Posting Date" > PeriodStartDate[i]) AND
      ("Posting Date" <= PeriodStartDate[i + 1]) THEN
      IF Item."Costing Method" = Item."Costing Method"::Average THEN
        InvtValue[i] := AverageCost *  InvtQty[i];
END;

I knew this is not the correct way of fixing it. Can anyone help me with this?

Thanks a Million,
CouberPu :oops:

Comments

Sign In or Register to comment.