hi all,
i want to calculate the average cost and post it, but after i've done my calculations in item journal line, i posted the line, and in the value entry invoiced quantity is zero and i want it to take the value of quantity in the item journal line.how can i get the field to show items.
ItemJnlLine.SETRANGE("Journal Batch Name");
IF ItemJnlLine.FIND('-') THEN BEGIN
Items.GET(ItemJnlLine."Item No.");
ItemJnlLine.VALIDATE(ItemJnlLine.Quantity);
ItemCostMgt.CalculateAverageCost(Items,AverageCostLCY,AverageCostACY);
IF AverageCostLCY = 0 THEN BEGIN
PurchInvLine.SETCURRENTKEY(PurchInvLine."Document No.",PurchInvLine."Line No.");
PurchInvLine.SETRANGE(PurchInvLine."No.",Items."No.");
IF PurchInvLine.FIND('+') THEN BEGIN
ItemJnlLine.INIT;
ItemJnlLine."Journal Template Name" := "Journal Template Name";
ItemJnlLine."Journal Batch Name" := "Journal Batch Name";
ItemJnlLine."Line No." := "Line No.";
ItemJnlLine."Item No." := "Item No.";
ItemJnlLine."Posting Date" := "Posting Date";
ItemJnlLine."Entry Type" := "Entry Type";
ItemJnlLine."Document No." := "Document No.";
ItemJnlLine.Description := Description;
ItemJnlLine.Quantity := Quantity;
ItemJnlLine."Unit Cost" := PurchInvLine."Unit Cost (LCY)";
ItemJnlLine."Quantity (Base)" := Quantity;
ItemJnlLine."Unit of Measure Code" := PurchInvLine."Unit of Measure Code";
ItemJnlLine.MODIFY;
MESSAGE(Text001 + '%1',CostAvgAmt);
END;
END;
END;
thanks
Learning Never End.
0
Comments
Secondly, since you only need to get and modify the cost of the item then you should only modify that specific field, unit of measure and not the whole ItemJnlLine record.
If the AverageCostLCY <>0 you don't do anything...
You should place an else begin/end statement with: after the:
Arhontis
https://forum.mibuso.com/search
Why don't you assign the '%1' directly to the Text-Const?
[/offtopic]
He he... you are correct Tim, if I am to improve all of the code I have ever replied to, I wouldn't have time to code my own projects...
Arhontis
https://forum.mibuso.com/search