Example #1
0
        /// <summary>
        /// 台账写入
        /// </summary>
        /// <typeparam name="THead">物资库盘点单表头模板</typeparam>
        /// <typeparam name="TDetail">物资库盘点单明细模板</typeparam>
        /// <param name="billHead">物资库盘点单头</param>
        /// <param name="billDetails">物资库盘点单明细</param>
        /// <param name="storeResult">库存返回结果</param>
        public void WriteAccount <THead, TDetail>(THead billHead, TDetail billDetails, MWStoreResult storeResult)
        {
            MW_AuditDetail detail = billDetails as MW_AuditDetail;
            MW_AuditHead   head   = billHead as MW_AuditHead;
            int            actYear;
            int            actMonth;
            string         errMsg;

            if (!GetAccountTime(head.DeptID, out errMsg, out actYear, out actMonth))
            {
                throw new Exception(errMsg);
            }

            MW_Account account = NewObject <MW_Account>();

            account.BalanceYear  = actYear;
            account.BalanceMonth = actMonth;
            account.AccountType  = 0;
            account.BalanceFlag  = 0;
            account.BatchNO      = detail.BatchNO;
            account.BusiType     = head.BusiType;
            account.DeptID       = head.DeptID;
            account.DetailID     = detail.AuditDetailID;
            account.MaterialID   = detail.MaterialID;
            account.UnitID       = detail.UnitID;
            account.UnitName     = detail.UnitName;
            account.BillNO       = head.BillNO;
            account.RegTime      = DateTime.Now;
            //盘盈 借方
            //盘亏 贷方
            //借方
            if (detail.FactAmount - detail.ActAmount > 0)
            {
                account.StockPrice    = detail.StockPrice;
                account.RetailPrice   = detail.RetailPrice;
                account.LendAmount    = detail.FactAmount - detail.ActAmount;
                account.LendRetailFee = (detail.FactAmount - detail.ActAmount) * detail.RetailPrice;
                account.LendStockFee  = (detail.FactAmount - detail.ActAmount) * detail.StockPrice;

                account.OverAmount    = storeResult.StoreAmount;
                account.OverRetailFee = storeResult.StoreAmount * account.RetailPrice;
                account.OverStockFee  = storeResult.StoreAmount * account.StockPrice;
            }
            else
            {
                //贷方
                account.StockPrice     = detail.StockPrice;
                account.RetailPrice    = detail.RetailPrice;
                account.DebitAmount    = detail.ActAmount - detail.FactAmount;
                account.DebitRetailFee = (detail.ActAmount - detail.FactAmount) * detail.RetailPrice;
                account.DebitStockFee  = (detail.ActAmount - detail.FactAmount) * detail.StockPrice;

                account.OverAmount    = storeResult.StoreAmount;
                account.OverRetailFee = storeResult.StoreAmount * account.RetailPrice;
                account.OverStockFee  = storeResult.StoreAmount * account.StockPrice;
            }

            account.save();
        }
Example #2
0
        /// <summary>
        /// 写台帐
        /// </summary>
        /// <typeparam name="THead">头实体类</typeparam>
        /// <typeparam name="TDetail">明细实体类</typeparam>
        /// <param name="billHead">单据头</param>
        /// <param name="billDetails">单据明细</param>
        /// <param name="storeResult">库存结果信息</param>
        public void WriteAccount <THead, TDetail>(THead billHead, TDetail billDetails, MWStoreResult storeResult)
        {
            MW_InStoreDetail detail = billDetails as MW_InStoreDetail;
            MW_InStoreHead   head   = billHead as MW_InStoreHead;
            int    actYear;
            int    actMonth;
            string errMsg;

            if (!GetAccountTime(head.DeptID, out errMsg, out actYear, out actMonth))
            {
                throw new Exception(errMsg);
            }

            MW_Account account = NewObject <MW_Account>();

            account.BalanceYear  = actYear;
            account.BalanceMonth = actMonth;
            account.AccountType  = 0;
            account.BalanceFlag  = 0;
            account.BatchNO      = detail.BatchNo;
            account.BusiType     = head.BusiType;
            account.DeptID       = head.DeptID;
            account.DetailID     = detail.InDetailID;
            account.MaterialID   = detail.MaterialID;
            account.UnitID       = detail.UnitID;
            account.UnitName     = detail.UnitName;
            account.LendAmount   = detail.Amount;
            account.BillNO       = detail.BillNo;
            account.RegTime      = DateTime.Now;
            if (head.BusiType == MWConstant.OP_MW_BACKSTORE)
            {
                account.StockPrice    = storeResult.BatchAllot[0].StockPrice;
                account.RetailPrice   = storeResult.BatchAllot[0].RetailPrice;
                account.LendAmount    = detail.Amount;
                account.LendRetailFee = account.LendAmount * account.RetailPrice;
                account.LendStockFee  = account.LendAmount * account.StockPrice;

                account.OverAmount    = storeResult.BatchAllot[0].StoreAmount;
                account.OverRetailFee = storeResult.BatchAllot[0].StoreAmount * account.RetailPrice;
                account.OverStockFee  = storeResult.BatchAllot[0].StoreAmount * account.StockPrice;
            }
            else
            {
                account.StockPrice    = detail.StockPrice;
                account.RetailPrice   = detail.RetailPrice;
                account.LendAmount    = detail.Amount;
                account.LendRetailFee = detail.RetailFee;
                account.LendStockFee  = detail.StockFee;

                account.OverAmount    = storeResult.BatchAllot[0].StoreAmount;
                account.OverRetailFee = storeResult.BatchAllot[0].StoreAmount * account.RetailPrice;
                account.OverStockFee  = storeResult.BatchAllot[0].StoreAmount * account.StockPrice;
            }

            account.save();
        }