• Item measure units & Get_Quantity_Per_Unit_Of_Measure

    Problem example:

    1. Item Base unit of measure is feet,
    2. Item Sales unit of measure is inch = 1/12 of feet (Quantity per unit of measure is 0.08333)
    3. If we sell 240 inches of item - then in Item Ledger will be posted 19.9992 feets (= 240*0.08333)

    core problem is that BC rounds QtyPerUnit to 0.00001 when entering value to field, but NOT rounding values returned from function GetQtyPerUnitOfMeasure(Item,UnitOfMeasureCode) in codeunit 5402 when it is written to "Sales Line" Qty per Unit Of measure)


    My solving suggestion:

    1. Add boolean field named "Inverse calculation" to table "Item Unit of Measure"
    2. Modify EXIT phase of function GetQtyPerUnitOfMeasure(Item,UnitOfMeasureCode) in codeunit 5402 to this (code is written in C/AL):


    IF ItemUnitOfMeasure.'Inverse calculation" THEN

      EXIT(1/ItemUnitOfMeasure."Qty. per Unit of Measure")

    ELSE

     EXIT(ItemUnitOfMeasure."Qty. per Unit of Measure"); //Standard behaviour


    In that case sold 240 inches will be posted as 20 feets in Item Ledger