コード例 #1
0
        protected override void updateCostAndProfit(ProductCirculation cir, ProductCirculationRecord record)
        {
            /*********更新数量和成本总价**********/
            ProductStainlessDao stainlessDao = cirDao.getProductDao() as ProductStainlessDao;
            ProductStainless    stainless    = stainlessDao.FindByID(record.ProductID);

            double leftNum = stainless.Num + conf.productDirection * record.TotalNum;

            //只有采购入货才需要更新成本价,通过成本价重新计算来抵冲收付的差额
            //销售、销售退货、采购退货通过利润的计算来抵消收付的差额
            //采购退货之所以不重新计算成本价,是因为如果退货价格很高的话,可能导致成本价为负数
            if (conf.type == ProductCirculation.CirculationType.purchase)
            {
                double totalCost = stainless.PriceCost * stainless.Num + conf.productDirection * record.Price * record.TotalNum;
                if (leftNum != 0)
                {
                    double cost = totalCost / leftNum;
                    stainless.PriceCost = cost;
                }
            }

            //double乘以int会出现0.9999999的问题
            stainless.Num = (double)((decimal)stainless.Num + conf.productDirection * (decimal)record.TotalNum);

            stainlessDao.Update(stainless);


            /*************增加利润表记录**********/
            if (conf.type == ProductCirculation.CirculationType.sell || conf.type == ProductCirculation.CirculationType.sellBack || conf.type == ProductCirculation.CirculationType.purchaseBack)
            {
                SellProfit profit = new SellProfit(cir, record, stainless.PriceCost);
                SellProfitDao.getInstance().Insert(profit);
            }
        }
コード例 #2
0
        //弃核
        protected override void cancelUpdateCostAndProfit(ProductCirculation cir, ProductCirculationRecord record)
        {
            /*********更新数量**********/
            ProductStainlessDao stainlessDao = cirDao.getProductDao() as ProductStainlessDao;
            ProductStainless    stainless    = stainlessDao.FindByID(record.ProductID);

            stainless.Num = (double)((decimal)stainless.Num - conf.productDirection * (decimal)record.TotalNum);
            stainlessDao.Update(stainless);
        }