首页 > 代码库 > 库存计算参考

库存计算参考

static void calcInPeriodInOutQtyAmount(Args _args)
{

 
    InventTrans         inventTrans;
    InventTransOrigin   inventTransOrigin;
    InventJournalTrans  inventJournalTrans;
    InventJournalName   inventJournalName;
    InventJournalTable  inventJOurnalTable;
    Amount              receiveAmount;
    Amount              returnAmount;
    Amount              transferAmount;
    Amount              adjustAmount;
    Amount              deliveryAmount;
    Amount              returnInventQty;
    Qty                 returnQty, returnREFQty;
    Qty                 deliveryQty, deliveryREFQty;


    ttsBegin;
    while select forupdate inventDetailPeriod
    {
        returnAmount = 0;
        receiveAmount = 0;
        transferAmount = 0;
        adjustAmount = 0;
        deliveryAmount = 0;
        returnInventQty = 0;
        returnQty = 0;
        returnREFQty = 0;
        deliveryQty = 0;
        deliveryREFQty = 0;
        //计算入仓数据:采购收货,其它出入库-默认类型收货,其它出入库-入仓收货,生产入库
        select sum(Qty), sum(PdsCWQty)
            from inventTrans
            where inventTrans.ItemId            == inventDetailPeriod.ItemId
                && inventTrans.inventDimId      == inventDetailPeriod.inventDimId
                && inventTrans.DatePhysical     >= fromDate
                && inventTrans.DatePhysical     <= toDate
                && (inventTrans.StatusReceipt    == StatusReceipt::Purchased
                || inventTrans.StatusReceipt    == StatusReceipt::Received)
            exists join inventTransOrigin
            where inventTransOrigin.RecId == inventTrans.InventTransOrigin
                && (inventTransOrigin.ReferenceCategory == InventTransType::Purch
                || inventTransOrigin.ReferenceCategory == InventTransType::InventTransaction  
                || inventTransOrigin.ReferenceCategory == InventTransType::Production
                || inventTransOrigin.ReferenceCategory == InventTransType::ProdLine
                    );
        inventDetailPeriod.ReceivedInventQty    = inventTrans.Qty; 

        select sum(CostAmountPhysical)
            from inventTrans
            where inventTrans.DatePhysical      >= fromDate
                && inventTrans.DatePhysical     <= toDate
                && (inventTrans.DateFinancial   > toDate || !inventTrans.DateFinancial)
                && inventTrans.ItemId           == inventDetailPeriod.ItemId
                && inventTrans.inventDimId      == inventDetailPeriod.inventDimId
                && (inventTrans.StatusReceipt    == StatusReceipt::Purchased
                || inventTrans.StatusReceipt    == StatusReceipt::Received)
            join inventTransOrigin
            where inventTransOrigin.RecId == inventTrans.InventTransOrigin
                && (inventTransOrigin.ReferenceCategory == InventTransType::Purch
                || inventTransOrigin.ReferenceCategory == InventTransType::InventTransaction                  
                || inventTransOrigin.ReferenceCategory == InventTransType::Production
                || inventTransOrigin.ReferenceCategory == InventTransType::ProdLine
                );

        receiveAmount = inventTrans.CostAmountPhysical;
        select sum(CostAmountAdjustment), sum(CostAmountPosted)
            from inventTrans
            where inventTrans.DatePhysical >= fromDate
                && inventTrans.DatePhysical <= toDate
                && inventTrans.DateFinancial >= fromDate
                && inventTrans.DateFinancial <= toDate
                && inventTrans.DateFinancial
                && inventTrans.ItemId == inventDetailPeriod.ItemId
                && inventTrans.inventDimId == inventDetailPeriod.inventDimId
                && (inventTrans.StatusReceipt    == StatusReceipt::Purchased
                || inventTrans.StatusReceipt    == StatusReceipt::Received)
            join inventTransOrigin
            where inventTransOrigin.RecId == inventTrans.InventTransOrigin
                && (inventTransOrigin.ReferenceCategory == InventTransType::Purch
                || inventTransOrigin.ReferenceCategory == InventTransType::InventTransaction  
                || inventTransOrigin.ReferenceCategory == InventTransType::Production
                || inventTransOrigin.ReferenceCategory == InventTransType::ProdLine
                    );

        receiveAmount += inventTrans.CostAmountPosted;
        adjustAmount = inventTrans.CostAmountAdjustment;

        inventDetailPeriod.ReceiveCostAmount = receiveAmount + adjustAmount;
        inventDetailPeriod.RecievedPrice = inventDetailPeriod.ReceivedInventQty ?
                                Currency::price((inventDetailPeriod.ReceiveCostAmount / inventDetailPeriod.ReceivedInventQty)) : 0;

        //计算采购退货数据
        select sum(Qty), sum(PdsCWQty)
            from inventTrans
            where inventTrans.ItemId            == inventDetailPeriod.ItemId
                && inventTrans.inventDimId      == inventDetailPeriod.inventDimId
                && inventTrans.DatePhysical     >= fromDate
                && inventTrans.DatePhysical     <= toDate
                && (inventTrans.StatusIssue    == StatusIssue::Sold
                || inventTrans.StatusIssue    == StatusIssue::Deducted)
            join inventTransOrigin
            where inventTransOrigin.RecId == inventTrans.InventTransOrigin
                && inventTransOrigin.ReferenceCategory == InventTransType::Purch;
        inventDetailPeriod.PurchReturnInventQty    = inventTrans.Qty; 

        select sum(CostAmountPhysical)
            from inventTrans
            where inventTrans.DatePhysical      >= fromDate
                && inventTrans.DatePhysical     <= toDate
                && (inventTrans.DateFinancial   > toDate || !inventTrans.DateFinancial)
                && inventTrans.ItemId           == inventDetailPeriod.ItemId
                && inventTrans.inventDimId      == inventDetailPeriod.inventDimId
                && (inventTrans.StatusIssue    == StatusIssue::Sold
                || inventTrans.StatusIssue    == StatusIssue::Deducted)
            join inventTransOrigin
            where inventTransOrigin.RecId == inventTrans.InventTransOrigin
                && inventTransOrigin.ReferenceCategory == InventTransType::Purch;

        returnAmount = inventTrans.CostAmountPhysical;
        select sum(CostAmountAdjustment), sum(CostAmountPosted)
            from inventTrans
            where inventTrans.DatePhysical >= fromDate
                && inventTrans.DatePhysical <= toDate
                && inventTrans.DateFinancial >= fromDate
                && inventTrans.DateFinancial <= toDate
                && inventTrans.DateFinancial
                && inventTrans.ItemId == inventDetailPeriod.ItemId
                && inventTrans.inventDimId == inventDetailPeriod.inventDimId
                && (inventTrans.StatusIssue    == StatusIssue::Sold
                || inventTrans.StatusIssue    == StatusIssue::Deducted)
            join inventTransOrigin
            where inventTransOrigin.RecId == inventTrans.InventTransOrigin
                && inventTransOrigin.ReferenceCategory == InventTransType::Purch;

        adjustAmount = inventTrans.CostAmountAdjustment;
        returnAmount += inventTrans.CostAmountPosted;
        inventDetailPeriod.PurchReturnCostAmount = returnAmount + adjustAmount;
        inventDetailPeriod.PurchReturnPrice = inventDetailPeriod.PurchReturnInventQty ?
                                Currency::price((inventDetailPeriod.PurchReturnCostAmount / inventDetailPeriod.PurchReturnInventQty)) : 0;

        //calc transfer qty
        select sum(Qty), sum(PdsCWQty)
            from inventTrans
            where inventTrans.ItemId            == inventDetailPeriod.ItemId
                && inventTrans.inventDimId      == inventDetailPeriod.inventDimId
                && inventTrans.DatePhysical     >= fromDate
                && inventTrans.DatePhysical     <= toDate
                && (inventTrans.StatusIssue    == StatusIssue::Sold
                || inventTrans.StatusIssue    == StatusIssue::Deducted
                || inventTrans.StatusReceipt == StatusReceipt::Purchased
                || inventTrans.StatusReceipt == StatusReceipt::Received)
            join inventTransOrigin
            where inventTransOrigin.RecId == inventTrans.InventTransOrigin
                && inventTransOrigin.ReferenceCategory == InventTransType::InventTransfer;
        inventDetailPeriod.TransferInventQty    = inventTrans.Qty; 

        select sum(CostAmountPhysical)
            from inventTrans
            where inventTrans.DatePhysical      >= fromDate
                && inventTrans.DatePhysical     <= toDate
                && (inventTrans.DateFinancial   > toDate || !inventTrans.DateFinancial)
                && inventTrans.ItemId           == inventDetailPeriod.ItemId
                && inventTrans.inventDimId      == inventDetailPeriod.inventDimId
                && (inventTrans.StatusIssue    == StatusIssue::Sold
                || inventTrans.StatusIssue    == StatusIssue::Deducted
                || inventTrans.StatusReceipt == StatusReceipt::Purchased
                || inventTrans.StatusReceipt == StatusReceipt::Received)
            join inventTransOrigin
            where inventTransOrigin.RecId == inventTrans.InventTransOrigin
                && inventTransOrigin.ReferenceCategory == InventTransType::InventTransfer;

        transferAmount = inventTrans.CostAmountPhysical;
        select sum(CostAmountAdjustment), sum(CostAmountPosted)
            from inventTrans
            where inventTrans.DatePhysical >= fromDate
                && inventTrans.DatePhysical <= toDate
                && inventTrans.DateFinancial >= fromDate
                && inventTrans.DateFinancial <= toDate
                && inventTrans.DateFinancial
                && inventTrans.ItemId == inventDetailPeriod.ItemId
                && inventTrans.inventDimId == inventDetailPeriod.inventDimId
                && (inventTrans.StatusIssue    == StatusIssue::Sold
                || inventTrans.StatusIssue    == StatusIssue::Deducted
                || inventTrans.StatusReceipt == StatusReceipt::Purchased
                || inventTrans.StatusReceipt == StatusReceipt::Received)
            join inventTransOrigin
            where inventTransOrigin.RecId == inventTrans.InventTransOrigin
                && inventTransOrigin.ReferenceCategory == InventTransType::InventTransfer;

        transferAmount += inventTrans.CostAmountPosted;
        adjustAmount = inventTrans.CostAmountAdjustment;
        inventDetailPeriod.TransferCostAmount = transferAmount + adjustAmount;
        inventDetailPeriod.TransferPrice = inventDetailPeriod.TransferInventQty ?
                                Currency::price((inventDetailPeriod.TransferCostAmount / inventDetailPeriod.TransferInventQty)) : 0;

        //calc delivery qty and amount 计算出仓数据:销售出仓,生产出仓,固定资产出仓,物料清单出仓,其它出入库-出仓,其它出入库-默认出库,其它出入库-入仓出库
        select sum(Qty), sum(PdsCWQty)
        from inventTrans
        where inventTrans.ItemId            == inventDetailPeriod.ItemId
            && inventTrans.inventDimId      == inventDetailPeriod.inventDimId
            && inventTrans.DatePhysical     >= fromDate
            && inventTrans.DatePhysical     <= toDate
            && (inventTrans.StatusIssue    == StatusIssue::Sold
            || inventTrans.StatusIssue    == StatusIssue::Deducted)
        join inventTransOrigin
        where inventTransOrigin.RecId == inventTrans.InventTransOrigin
            && (inventTransOrigin.ReferenceCategory == InventTransType::Sales
            || (inventTransOrigin.ReferenceCategory == InventTransType::Production)
            || (inventTransOrigin.ReferenceCategory == InventTransType::Project)
            || (inventTransOrigin.ReferenceCategory == InventTransType::Asset)
            || (inventTransOrigin.ReferenceCategory == InventTransType::ProdLine)

            || inventTransOrigin.ReferenceCategory == InventTransType::InventTransaction 
            || (inventTransOrigin.ReferenceCategory == InventTransType::InventTransaction 
            || (inventTransOrigin.ReferenceCategory == InventTransType::InventTransaction
            );

        deliveryQty             = inventTrans.Qty; 

        select sum(CostAmountPhysical)
        from inventTrans
        where inventTrans.DatePhysical      >= fromDate
            && inventTrans.DatePhysical     <= toDate
            && (inventTrans.DateFinancial   > toDate || !inventTrans.DateFinancial)
            && inventTrans.ItemId           == inventDetailPeriod.ItemId
            && inventTrans.inventDimId      == inventDetailPeriod.inventDimId
            && (inventTrans.StatusIssue    == StatusIssue::Sold
            || inventTrans.StatusIssue    == StatusIssue::Deducted)
        join inventTransOrigin
        where inventTransOrigin.RecId == inventTrans.InventTransOrigin
            && (inventTransOrigin.ReferenceCategory == InventTransType::Sales
            || (inventTransOrigin.ReferenceCategory == InventTransType::Production)
            || (inventTransOrigin.ReferenceCategory == InventTransType::Project)
            || (inventTransOrigin.ReferenceCategory == InventTransType::Asset)
            || (inventTransOrigin.ReferenceCategory == InventTransType::ProdLine)
            || inventTransOrigin.ReferenceCategory == InventTransType::InventTransaction  
            );

        deliveryAmount = inventTrans.CostAmountPhysical;
        select sum(CostAmountAdjustment), sum(CostAmountPosted)
        from inventTrans
        where inventTrans.DatePhysical >= fromDate
            && inventTrans.DatePhysical <= toDate
            && inventTrans.DateFinancial >= fromDate
            && inventTrans.DateFinancial <= toDate
            && inventTrans.DateFinancial
            && inventTrans.ItemId == inventDetailPeriod.ItemId
            && inventTrans.inventDimId == inventDetailPeriod.inventDimId
            && (inventTrans.StatusIssue    == StatusIssue::Sold
            || inventTrans.StatusIssue    == StatusIssue::Deducted)
        join inventTransOrigin
        where inventTransOrigin.RecId == inventTrans.InventTransOrigin
            && (inventTransOrigin.ReferenceCategory == InventTransType::Sales
            || (inventTransOrigin.ReferenceCategory == InventTransType::Production)
            || (inventTransOrigin.ReferenceCategory == InventTransType::Project)
            || (inventTransOrigin.ReferenceCategory == InventTransType::Asset)
            || (inventTransOrigin.ReferenceCategory == InventTransType::ProdLine)

            || inventTransOrigin.ReferenceCategory == InventTransType::InventTransaction 
            || (inventTransOrigin.ReferenceCategory == InventTransType::InventTransaction 
            || (inventTransOrigin.ReferenceCategory == InventTransType::InventTransaction
            );

        deliveryAmount += (inventTrans.CostAmountPosted + inventTrans.CostAmountAdjustment);


       
        //calc invent return qty and amount 计算退仓数量
        select sum(Qty), sum(PdsCWQty)
        from inventTrans
        where inventTrans.ItemId            == inventDetailPeriod.ItemId
            && inventTrans.inventDimId      == inventDetailPeriod.inventDimId
            && inventTrans.DatePhysical     >= fromDate
            && inventTrans.DatePhysical     <= toDate
            && (inventTrans.StatusReceipt == StatusReceipt::Purchased
            || inventTrans.StatusReceipt == StatusReceipt::Received
            || inventTrans.StatusIssue == StatusIssue::Sold
            || inventTrans.StatusIssue == StatusIssue::Deducted)
        join inventTransOrigin
        where inventTransOrigin.RecId == inventTrans.InventTransOrigin
            && inventTransOrigin.ReferenceCategory == InventTransType::InventTransaction 
        returnQty = inventTrans.Qty; 

        select sum(CostAmountPhysical)
        from inventTrans
        where inventTrans.DatePhysical      >= fromDate
            && inventTrans.DatePhysical     <= toDate
            && (inventTrans.DateFinancial   > toDate || !inventTrans.DateFinancial)
            && inventTrans.ItemId           == inventDetailPeriod.ItemId
            && inventTrans.inventDimId      == inventDetailPeriod.inventDimId
            && (inventTrans.StatusReceipt == StatusReceipt::Purchased
            || inventTrans.StatusReceipt == StatusReceipt::Received
            || inventTrans.StatusIssue == StatusIssue::Sold
            || inventTrans.StatusIssue == StatusIssue::Deducted)
        join inventTransOrigin
        where inventTransOrigin.RecId == inventTrans.InventTransOrigin
            && inventTransOrigin.ReferenceCategory == InventTransType::InventTransaction

        returnAmount = inventTrans.CostAmountPhysical;
        select sum(CostAmountAdjustment), sum(CostAmountPosted)
        from inventTrans
        where inventTrans.DatePhysical >= fromDate
            && inventTrans.DatePhysical <= toDate
            && inventTrans.DateFinancial >= fromDate
            && inventTrans.DateFinancial <= toDate
            && inventTrans.DateFinancial
            && inventTrans.ItemId == inventDetailPeriod.ItemId
            && inventTrans.inventDimId == inventDetailPeriod.inventDimId
            && (inventTrans.StatusReceipt == StatusReceipt::Purchased
            || inventTrans.StatusReceipt == StatusReceipt::Received
            || inventTrans.StatusIssue == StatusIssue::Sold
            || inventTrans.StatusIssue == StatusIssue::Deducted)
        join inventTransOrigin
        where inventTransOrigin.RecId == inventTrans.InventTransOrigin
            && inventTransOrigin.ReferenceCategory == InventTransType::InventTransaction
            
        adjustAmount = inventTrans.CostAmountAdjustment;
        returnAmount += inventTrans.CostAmountPosted;
        //计算其它出入库-发货退仓,销售退仓,项目领料退仓,固定资产退仓
        select sum(Qty), sum(PdsCWQty)
        from inventTrans
        where inventTrans.ItemId            == inventDetailPeriod.ItemId
            && inventTrans.inventDimId      == inventDetailPeriod.inventDimId
            && inventTrans.DatePhysical     >= fromDate
            && inventTrans.DatePhysical     <= toDate
            && (inventTrans.StatusReceipt == StatusReceipt::Purchased
            || inventTrans.StatusReceipt == StatusReceipt::Received)
        join inventTransOrigin
        where inventTransOrigin.RecId == inventTrans.InventTransOrigin
            && (inventTransOrigin.ReferenceCategory == InventTransType::Sales
            || inventTransOrigin.ReferenceCategory == InventTransType::Project
            || inventTransOrigin.ReferenceCategory == InventTransType::Asset
            || inventTransOrigin.ReferenceCategory == InventTransType::InventTransaction 
                );
        returnQty += inventTrans.Qty; 

        select sum(CostAmountPhysical)
        from inventTrans
        where inventTrans.DatePhysical      >= fromDate
            && inventTrans.DatePhysical     <= toDate
            && (inventTrans.DateFinancial   > toDate || !inventTrans.DateFinancial)
            && inventTrans.ItemId           == inventDetailPeriod.ItemId
            && inventTrans.inventDimId      == inventDetailPeriod.inventDimId
            && (inventTrans.StatusReceipt == StatusReceipt::Purchased
            || inventTrans.StatusReceipt == StatusReceipt::Received)
        join inventTransOrigin
        where inventTransOrigin.RecId == inventTrans.InventTransOrigin
            && (inventTransOrigin.ReferenceCategory == InventTransType::Sales
            || inventTransOrigin.ReferenceCategory == InventTransType::Project
            || inventTransOrigin.ReferenceCategory == InventTransType::Asset
            || inventTransOrigin.ReferenceCategory == InventTransType::InventTransaction 
                );

        returnAmount += inventTrans.CostAmountPhysical;
        select sum(CostAmountAdjustment), sum(CostAmountPosted)
        from inventTrans
        where inventTrans.DatePhysical >= fromDate
            && inventTrans.DatePhysical <= toDate
            && inventTrans.DateFinancial >= fromDate
            && inventTrans.DateFinancial <= toDate
            && inventTrans.DateFinancial
            && inventTrans.ItemId == inventDetailPeriod.ItemId
            && inventTrans.inventDimId == inventDetailPeriod.inventDimId
            && (inventTrans.StatusReceipt == StatusReceipt::Purchased
            || inventTrans.StatusReceipt == StatusReceipt::Received)
        join inventTransOrigin
        where inventTransOrigin.RecId == inventTrans.InventTransOrigin
            && (inventTransOrigin.ReferenceCategory == InventTransType::Sales
            || inventTransOrigin.ReferenceCategory == InventTransType::Project
            || inventTransOrigin.ReferenceCategory == InventTransType::Asset
            || inventTransOrigin.ReferenceCategory == InventTransType::InventTransaction 
                );

        adjustAmount += inventTrans.CostAmountAdjustment;
        returnAmount += inventTrans.CostAmountPosted;

        inventDetailPeriod.InventReturnInventQty    = returnQty;
        inventDetailPeriod.InventReturnCWQty        = returnREFQty;
        inventDetailPeriod.InventReturnCostAmount = returnAmount + adjustAmount;

        inventDetailPeriod.InventReturnPrice = inventDetailPeriod.InventReturnInventQty ?
                                Currency::price((inventDetailPeriod.InventReturnCostAmount / inventDetailPeriod.InventReturnInventQty)) : 0;

   
        // calc adjustment qty and amount 计算调整数据
        select sum(Qty), sum(PdsCWQty)
        from inventTrans
        where inventTrans.ItemId            == inventDetailPeriod.ItemId
            && inventTrans.inventDimId      == inventDetailPeriod.inventDimId
            && inventTrans.DatePhysical     >= fromDate
            && inventTrans.DatePhysical     <= toDate
            && (inventTrans.StatusIssue     == StatusIssue::Sold
            || inventTrans.StatusIssue      == StatusIssue::Deducted
            || inventTrans.StatusReceipt == StatusReceipt::Purchased
            || inventTrans.StatusReceipt == StatusReceipt::Received)
        join inventTransOrigin
        where inventTransOrigin.RecId == inventTrans.InventTransOrigin
            && (inventTransOrigin.ReferenceCategory == InventTransType::InventLossProfit
            || inventTransOrigin.ReferenceCategory == InventTransType::InventCounting
            || inventTransOrigin.ReferenceCategory == InventTransType::BOMMain
            || inventTransOrigin.ReferenceCategory == InventTransType::BOMLine
            || inventTransOrigin.ReferenceCategory == InventTransType::InventTransaction
        inventDetailPeriod.AdjustInventQty    = inventTrans.Qty;
        

        select sum(CostAmountPhysical)
        from inventTrans
        where inventTrans.DatePhysical      >= fromDate
            && inventTrans.DatePhysical     <= toDate
            && (inventTrans.DateFinancial   > toDate || !inventTrans.DateFinancial)
            && inventTrans.ItemId           == inventDetailPeriod.ItemId
            && inventTrans.inventDimId      == inventDetailPeriod.inventDimId
            && (inventTrans.StatusIssue    == StatusIssue::Sold
            || inventTrans.StatusIssue    == StatusIssue::Deducted
            || inventTrans.StatusReceipt == StatusReceipt::Purchased
            || inventTrans.StatusReceipt == StatusReceipt::Received)
        join inventTransOrigin
        where inventTransOrigin.RecId == inventTrans.InventTransOrigin
            && (inventTransOrigin.ReferenceCategory == InventTransType::InventLossProfit
            || inventTransOrigin.ReferenceCategory == InventTransType::InventCounting
            || inventTransOrigin.ReferenceCategory == InventTransType::BOMMain
            || inventTransOrigin.ReferenceCategory == InventTransType::BOMLine
            || inventTransOrigin.ReferenceCategory == InventTransType::InventTransaction  );

        adjustAmount = inventTrans.CostAmountPhysical;
        select sum(CostAmountAdjustment), sum(CostAmountPosted)
        from inventTrans
        where inventTrans.DatePhysical >= fromDate
            && inventTrans.DatePhysical <= toDate
            && inventTrans.DateFinancial >= fromDate
            && inventTrans.DateFinancial <= toDate
            && inventTrans.DateFinancial
            && inventTrans.ItemId == inventDetailPeriod.ItemId
            && inventTrans.inventDimId == inventDetailPeriod.inventDimId
            && (inventTrans.StatusIssue    == StatusIssue::Sold
            || inventTrans.StatusIssue    == StatusIssue::Deducted
            || inventTrans.StatusReceipt == StatusReceipt::Purchased
            || inventTrans.StatusReceipt == StatusReceipt::Received)
        join inventTransOrigin
        where inventTransOrigin.RecId == inventTrans.InventTransOrigin
            && (inventTransOrigin.ReferenceCategory == InventTransType::InventLossProfit
            || inventTransOrigin.ReferenceCategory == InventTransType::InventCounting
            || inventTransOrigin.ReferenceCategory == InventTransType::BOMMain
            || inventTransOrigin.ReferenceCategory == InventTransType::BOMLine
            || inventTransOrigin.ReferenceCategory == InventTransType::InventTransaction );

        adjustAmount += inventTrans.CostAmountAdjustment + inventTrans.CostAmountPosted;
        inventDetailPeriod.AdjustCostAmount = adjustAmount;
        inventDetailPeriod.AdjustPrice =  inventDetailPeriod.AdjustInventQty ?
                                Currency::price((inventDetailPeriod.AdjustCostAmount / inventDetailPeriod.AdjustInventQty)) : 0;


        inventDetailPeriod.update();
    }
    ttsCommit;
}

 

库存计算参考