/// <summary> /// 按最新价格重新核算出库单明细价格和头表金额 /// </summary> /// <param name="outMaster">出库单表头</param> /// <param name="billOrder">出库单明细列表</param> /// <param name="belongSystem">所属系统(药房系统,药库系统)</param> protected void AuditPrice(YP_OutMaster outMaster, List <YP_OutOrder> billOrder, string belongSystem) { outMaster.RetailFee = 0; outMaster.TradeFee = 0; outMaster.OutFee = 0; foreach (YP_OutOrder order in billOrder) { YP_MakerDic makerDic = BindEntity <YP_MakerDic> .CreateInstanceDAL(oleDb).GetModel(order.MakerDicID); if (makerDic.RetailPrice != order.RetailPrice || makerDic.TradePrice != order.TradePrice) { order.RetailPrice = makerDic.RetailPrice; order.TradePrice = makerDic.TradePrice; if (belongSystem == ConfigManager.YF_SYSTEM) { order.RetailFee = AccountWriter.YF_ComputeTotalFee(order.RetailPrice, order.OutNum, order.UnitNum); order.TradeFee = AccountWriter.YF_ComputeTotalFee(order.TradePrice, order.OutNum, order.UnitNum); } else { order.RetailFee = AccountWriter.YK_ComputeTotalFee(order.RetailPrice, order.OutNum); order.TradeFee = AccountWriter.YK_ComputeTotalFee(order.TradePrice, order.OutNum); } } outMaster.RetailFee += order.RetailFee; outMaster.TradeFee += order.TradeFee; outMaster.OutFee += order.RetailFee; } }
/// <summary> /// 计算余额 /// </summary> /// <param name="account">台帐信息</param> protected override void ComputeFee(YP_Account account) { if (account.OpType == ConfigManager.OP_YF_ADJPRICE) { account.BalanceFee = AccountWriter.YF_ComputeTotalFee(account.RetailPrice, account.OverNum, account.UnitNum); } else { account.BalanceFee = AccountWriter.YK_ComputeTotalFee(account.RetailPrice, account.OverNum); } }
/// <summary> /// 按处方明细构造发药单明细 /// </summary> /// <param name="recipeOrder">处方明细</param> /// <param name="dispMaster">发药单表头</param> /// <param name="dispenseModel">发药方式(发药还是退药)</param> /// <returns>发药单明细</returns> public override List <BillOrder> BuildNewDispOrder(DataTable recipeOrder, YP_DRMaster dispMaster, int dispenseModel) { if (recipeOrder == null) { return(null); } if (recipeOrder.Rows.Count <= 0) { return(null); } List <BillOrder> rtnList = new List <BillOrder>(); for (int index = 0; index < recipeOrder.Rows.Count; index++) { YP_DROrder dispOrder = new YP_DROrder(); DataRow dRow = recipeOrder.Rows[index]; dispOrder.ChemName = dRow["CHEMNAME"].ToString(); //药品化学名称 dispOrder.DeptID = dispMaster.DeptID; //发药部门ID dispOrder.DoseNum = 0; //剂数默认为0 dispOrder.DrugOC_Flag = 1; //1表发药,0表退药 dispOrder.DrugOCNum = Convert.ToDecimal(dRow["AMOUNT"]); dispOrder.InpatientID = dispMaster.InpatientID; dispOrder.InvoiceNum = dispMaster.InvoiceNum; //发票号默认为0 dispOrder.LeastUnit = Convert.ToInt32(dRow["UNIT"]); //发药单位ID dispOrder.MakerDicID = Convert.ToInt32(dRow["ITEMID"]); //厂家典标识ID dispOrder.MasterDrugOCID = dispMaster.MasterDrugOCID; //对应表头ID dispOrder.OrderRecipeID = Convert.ToInt32(dRow["PRESORDERID"]); //处方明细ID dispOrder.Refundment_Flag = 0; //1表已退费,0表未退费 decimal hjRetailFee = Convert.ToDecimal(dRow["TOLAL_FEE"]); //零售金额 decimal recipeNum = Convert.ToDecimal(dRow["PRESAMOUNT"]); dispOrder.RetailPrice = Convert.ToDecimal(dRow["SELL_PRICE"]); //零售价 dispOrder.SpecDicID = Convert.ToInt32(dRow["SPECDICID"]); //药品规格标识ID dispOrder.TradePrice = Convert.ToDecimal(dRow["BUY_PRICE"]); //批发价 //批发金额 dispOrder.TradeFee = dispOrder.TradePrice * Convert.ToDecimal(dRow["AMOUNT"]) / Convert.ToDecimal(dRow["RELATIONNUM"]); dispOrder.Uniform_Flag = 0;//1表示住院,0表示门诊,2表住院统领 dispOrder.UnitNum = Convert.ToInt32(dRow["RELATIONNUM"]); dispOrder.Curedeptid = Convert.ToInt32(dRow["PRESDEPTCODE"]); dispOrder.RetailFee = AccountWriter.YF_ComputeTotalFee(dispOrder.RetailPrice, dispOrder.DrugOCNum, dispOrder.UnitNum); rtnList.Add(dispOrder); } return(rtnList); }
/// <summary> /// 药库入库单审核 /// </summary> /// <param name="billMaster">药库入库单头表</param> /// <param name="auditerID">审核人员ID</param> /// <param name="auditDeptID">审核部门ID</param> public override void AuditBill(BillMaster billMaster, long auditerID, long auditDeptID) { try { YP_InMaster inStore = (YP_InMaster)billMaster; string strWhere = BLL.Tables.yk_inmaster.MASTERINSTORAGEID + oleDb.EuqalTo() + inStore.MasterInStorageID + oleDb.And() + BLL.Tables.yk_inmaster.AUDIT_FLAG + oleDb.EuqalTo() + "1"; if (BindEntity <YP_InMaster> .CreateInstanceDAL(oleDb, BLL.Tables.YK_INMASTER).Exists(strWhere)) { throw new Exception("该张单据已经审核过。。。"); } oleDb.BeginTransaction(); DateTime _currentTime = XcDate.ServerDateTime; inStore.AuditTime = _currentTime; inStore.Audit_Flag = 1; inStore.AuditPeopleID = Convert.ToInt32(auditerID); IBaseDAL <YP_InOrder> ykInOrder = BindEntity <YP_InOrder> .CreateInstanceDAL(oleDb, BLL.Tables.YK_INORDER); IBaseDAL <YP_InMaster> ykInMaster = BindEntity <YP_InMaster> .CreateInstanceDAL(oleDb, BLL.Tables.YK_INMASTER); List <YP_InOrder> listStore = ykInOrder.GetListArray("MasterInStorageID=" + inStore.MasterInStorageID + ""); base.AuditPrice(inStore, listStore, ConfigManager.YK_SYSTEM); ykInMaster.Update(inStore); List <BillOrder> listOrder = new List <BillOrder>(); AccountWriter actWriter = AccountFactory.GetWriter(inStore.OpType); foreach (YP_InOrder orderInstore in listStore) { orderInstore.Audit_Flag = 1; ykInOrder.Update(orderInstore); listOrder.Add(orderInstore); } Hashtable storeTable = StoreFactory.GetProcessor(inStore.OpType).ChangeStoreNum(billMaster, listOrder); AccountFactory.GetWriter(inStore.OpType).WriteAccount(billMaster, listOrder, storeTable); oleDb.CommitTransaction(); } catch (Exception error) { if (oleDb.IsInTransaction) { oleDb.RollbackTransaction(); } throw error; } }
/// <summary> /// 创建住院发药单明细列表 /// </summary> /// <param name="recipeOrder">护士站记账信息表</param> /// <param name="dispMaster">住院发药单表头</param> /// <param name="dispenseModel">发药模式</param> /// <returns>住院发药单明细列表</returns> public override List <BillOrder> BuildNewDispOrder(DataTable recipeOrder, YP_DRMaster dispMaster, int dispenseModel) { List <BillOrder> rtnList = new List <BillOrder>(); bool dr_Flag = (dispMaster.OpType == ConfigManager.OP_YF_DISPENSE ? true : false); for (int index = 0; index < recipeOrder.Rows.Count; index++) { DataRow dRow = recipeOrder.Rows[index]; YP_DROrder dispOrder = new YP_DROrder(); dispOrder.ChemName = dRow["CHEMNAME"].ToString(); //药品化学名称 dispOrder.DeptID = dispMaster.DeptID; //发药部门ID if (dr_Flag) { dispOrder.DrugOC_Flag = 1; dispOrder.DrugOCNum = Convert.ToDecimal(dRow["DRUGNUM"]); } else { dispOrder.DrugOC_Flag = 0; dispOrder.DrugOCNum = -Convert.ToDecimal(dRow["DRUGNUM"]); } dispOrder.InpatientID = dispMaster.InpatientID; dispOrder.InvoiceNum = 0; //发票号默认为0 dispOrder.LeastUnit = Convert.ToInt32(dRow["UNIT"]); //发药单位ID dispOrder.MakerDicID = Convert.ToInt32(dRow["MAKERDICID"]); //厂家典标识ID dispOrder.MasterDrugOCID = dispMaster.MasterDrugOCID; //对应表头ID dispOrder.OrderRecipeID = Convert.ToInt32(dRow["ORDERRECIPEID"]); //处方明细ID dispOrder.Refundment_Flag = 0; //1表已退费,0表未退费 decimal hjRetailFee = Convert.ToDecimal(dRow["RETAILFEE"]); //零售金额 dispOrder.RetailPrice = Convert.ToDecimal(dRow["RETAILPRICE"]); //零售价 dispOrder.SpecDicID = Convert.ToInt32(dRow["SPECDICID"]); //药品规格标识ID dispOrder.TradePrice = Convert.ToDecimal(dRow["TRADEPRICE"]); //批发价 //批发金额 dispOrder.TradeFee = (dispOrder.TradePrice / Convert.ToDecimal(dRow["UNITNUM"])) * dispOrder.DrugOCNum; dispOrder.Uniform_Flag = dispenseModel; dispOrder.UnitNum = Convert.ToInt32(dRow["UNITNUM"]); dispOrder.Curedeptid = Convert.ToInt32(dRow["CUREDEPT"]); dispOrder.RetailFee = AccountWriter.YF_ComputeTotalFee(dispOrder.RetailPrice, dispOrder.DrugOCNum, dispOrder.UnitNum); dispMaster.RetailFee += dispOrder.RetailFee;//统计表头的零售金额 rtnList.Add(dispOrder); } return(rtnList); }
/// <summary> /// 创建住院发药单明细列表 /// </summary> /// <param name="recipeOrder">记账明细表</param> /// <param name="dispMaster">发药单表头</param> /// <param name="dispenseModel">发药模式</param> /// <returns>住院发药单明细列表</returns> public override List <BillOrder> BuildNewDispOrder(DataTable recipeOrder, YP_DRMaster dispMaster, int dispenseModel) { List <BillOrder> rtnList = new List <BillOrder>(); for (int index = 0; index < recipeOrder.Rows.Count; index++) { YP_DROrder dispOrder = new YP_DROrder(); DataRow dRow = recipeOrder.Rows[index]; //if (dRow["ISDISPENSE"] != DBNull.Value) //{ dispOrder.ChemName = dRow["itemname"].ToString(); //药品化学名称 dispOrder.DeptID = dispMaster.DeptID; //发药部门ID dispOrder.DoseNum = 0; //剂数默认为0 dispOrder.DrugOC_Flag = dispMaster.DrugOC_Flag; // 1;//1表发药,0表退药 dispOrder.DrugOCNum = Convert.ToDecimal(dRow["AMOUNT"]) > 0 ? Convert.ToDecimal(dRow["AMOUNT"]) : Convert.ToDecimal(dRow["AMOUNT"]) * -1; dispOrder.InpatientID = dispMaster.InpatientID; dispOrder.InvoiceNum = 0; //发票号默认为0 dispOrder.LeastUnit = Convert.ToInt32(dRow["UNITID"]); //发药单位ID dispOrder.MakerDicID = Convert.ToInt32(dRow["ITEMID"]); //厂家典标识ID dispOrder.MasterDrugOCID = dispMaster.MasterDrugOCID; //对应表头ID dispOrder.OrderRecipeID = Convert.ToInt32(dRow["PRESORDERID"]); //处方明细ID dispOrder.Refundment_Flag = 0; //1表已退费,0表未退费 decimal hjRetailFee = Convert.ToDecimal(dRow["TOLAL_FEE"]); //零售金额 dispOrder.RetailPrice = Convert.ToDecimal(dRow["SELL_PRICE"]); //零售价 dispOrder.SpecDicID = Convert.ToInt32(dRow["SPECDICID"]); //药品规格标识ID dispOrder.TradePrice = Convert.ToDecimal(dRow["BUY_PRICE"]); //批发价 //批发金额 dispOrder.TradeFee = (dispOrder.TradePrice / Convert.ToDecimal(dRow["RELATIONNUM"])) * dispOrder.DrugOCNum; dispOrder.Uniform_Flag = (dispenseModel == 1?0:1); //1表示住院单人,2表住院统领 dispOrder.UnitNum = Convert.ToInt32(dRow["RELATIONNUM"]); dispOrder.Curedeptid = Convert.ToInt32(dRow["PRESDEPTCODE"]); dispOrder.RetailFee = AccountWriter.YF_ComputeTotalFee(dispOrder.RetailPrice, dispOrder.DrugOCNum, dispOrder.UnitNum); dispMaster.RetailFee += dispOrder.RetailFee; //统计表头的零售金额 rtnList.Add(dispOrder); // } } return(rtnList); }
/// <summary> /// 计算余额 /// </summary> /// <param name="account">台帐信息</param> protected override void ComputeFee(YP_Account account) { account.BalanceFee = AccountWriter.YK_ComputeTotalFee(account.RetailPrice, account.OverNum); }
/// <summary> /// 计算余额 /// </summary> /// <param name="account">台帐信息</param> protected override void ComputeFee(YP_Account account) { IBaseDAL <YP_Account> accountDao = BindEntity <YP_Account> .CreateInstanceDAL(oleDb, HIS.BLL.Tables.YF_ACCOUNT); //库存金额 decimal storeFee = 0; decimal adjLenderFee = 0; decimal adjDebitFee = 0; //判断退药期间是否有调价发生 YP_MakerDic makerDic = new YP_MakerDic(); IBaseDAL <YP_MakerDic> makerDao = BindEntity <YP_MakerDic> .CreateInstanceDAL(oleDb); makerDic = makerDao.GetModel(account.MakerDicID); //计算库存金额 storeFee = AccountWriter.YF_ComputeTotalFee(makerDic.RetailPrice, account.OverNum, account.UnitNum); //如果在发/退药期间调价 if (makerDic.RetailPrice != account.RetailPrice) { //调赢 if (makerDic.RetailPrice > account.RetailPrice) { //账务调整 adjLenderFee = (Convert.ToDecimal(account.LenderNum) / Convert.ToDecimal(account.UnitNum)) * (makerDic.RetailPrice - account.RetailPrice); account.BalanceFee = storeFee - adjLenderFee; //写发/退药台帐 accountDao.Add(account); //写调整台帐 account.AccountType = 3; account.DebitNum = 0; account.DebitFee = 0; account.LenderNum = 0; account.LenderFee = adjLenderFee; account.BalanceFee = storeFee; accountDao.Add(account); } //调亏 else { //账务调整 adjDebitFee = (Convert.ToDecimal(account.LenderNum) / Convert.ToDecimal(account.UnitNum)) * (account.RetailPrice - makerDic.RetailPrice); account.BalanceFee = storeFee + adjDebitFee; //写发/退药台帐 accountDao.Add(account); //写调整台帐 account.AccountType = 3; account.DebitNum = 0; account.DebitFee = adjDebitFee; account.LenderNum = 0; account.LenderFee = 0; account.BalanceFee = storeFee; accountDao.Add(account); } } else { account.BalanceFee = storeFee; accountDao.Add(account); } }
/// <summary> /// 构造台帐写入器 /// </summary> /// <param name="opType">台帐业务类型</param> /// <returns>台帐写入器</returns> public static AccountWriter GetWriter(string opType) { switch (opType) { case ConfigManager.OP_YF_ADJPRICE: accountWriter = new AdjPriceAccount(); break; case ConfigManager.OP_YF_APPLYIN: accountWriter = new YF_InstoreAccount(); break; case ConfigManager.OP_YF_CHECK: accountWriter = new YF_CheckAccount(); break; case ConfigManager.OP_YF_DEPTDRAW: accountWriter = new YF_OutStoreAccount(); break; case ConfigManager.OP_YF_DISPENSE: accountWriter = new DispenseAccount(); break; case ConfigManager.OP_YF_INSTORE: accountWriter = new YF_InstoreAccount(); break; case ConfigManager.OP_YF_REPORTLOSS: accountWriter = new YF_OutStoreAccount(); break; case ConfigManager.OP_YF_REFUND: accountWriter = new RefundAccount(); break; case ConfigManager.OP_YK_ADJPRICE: accountWriter = new AdjPriceAccount(); break; case ConfigManager.OP_YK_CHECK: accountWriter = new YK_CheckAccount(); break; case ConfigManager.OP_YK_DEPTDRAW: accountWriter = new YK_OutStoreAccount(); break; case ConfigManager.OP_YK_INOPTYPE: accountWriter = new YK_InstoreAccount(); break; case ConfigManager.OP_YK_BACKSTORE: accountWriter = new YK_BackStoreAccount(); break; case ConfigManager.OP_YK_OUTTOYF: accountWriter = new YK_OutStoreAccount(); break; case ConfigManager.OP_YK_REPORTLOSS: accountWriter = new YK_OutStoreAccount(); break; case ConfigManager.OP_YK_FIRSTIN: accountWriter = new YK_InstoreAccount(); break; default: return(null); } return(accountWriter); }