/// <summary> /// 台账写入--批次发药价格差额台账 /// </summary> /// <param name="billHead">发药单表头</param> /// <param name="billDetails">发药单明细</param> /// <param name="storeParam">库存参数</param> /// <param name="batchAllot">批次</param> public void WriteAccount(DS_IPDispHead billHead, DS_IPDispDetail billDetails, StoreParam storeParam, DGBatchAllot batchAllot) { int actYear; int actMonth; string errMsg; if (!GetAccountTime(billHead.ExecDeptID, out errMsg, out actYear, out actMonth)) { throw new Exception(errMsg); } DS_Account account = NewObject <DS_Account>(); account.BalanceYear = actYear; account.BalanceMonth = actMonth; account.AccountType = 3;//药房 account.BalanceFlag = 0; account.BatchNO = billDetails.BatchNO; account.BusiType = billHead.BusiType; account.CTypeID = billDetails.CTypeID; account.DeptID = billDetails.DeptID; account.DetailID = billDetails.DispDetailID; account.DrugID = billDetails.DrugID; account.UnitID = billDetails.UnitID; account.UnitName = billDetails.UnitName; account.RegTime = DateTime.Now; //盘盈 借方 //盘亏 贷方 if (storeParam.RetailPrice < billDetails.RetailPrice) { //该批次大于处方零售价写入 贷方 account.StockPrice = billDetails.StockPrice; account.RetailPrice = billDetails.RetailPrice; //发生调整时,数量为0,只调价格 account.DebitAmount = 0; //Math.Abs(billDetails.DispAmount); account.DebitRetailFee = GetFee(Math.Abs(billDetails.DispAmount), billDetails.UnitAmount, billDetails.RetailPrice, billDetails.Dosage) - GetFee(Math.Abs(billDetails.DispAmount), billDetails.UnitAmount, storeParam.RetailPrice, billDetails.Dosage); account.DebitStockFee = GetFee(Math.Abs(billDetails.DispAmount), billDetails.UnitAmount, billDetails.StockPrice, billDetails.Dosage) - GetFee(Math.Abs(billDetails.DispAmount), billDetails.UnitAmount, storeParam.StockPrice, billDetails.Dosage); account.OverAmount = batchAllot.StoreAmount; account.OverRetailFee = batchAllot.StoreAmount * (account.RetailPrice / batchAllot.UnitAmount); account.OverStockFee = batchAllot.StoreAmount * (account.StockPrice / batchAllot.UnitAmount); } else { //发药 借方 account.StockPrice = billDetails.StockPrice; account.RetailPrice = billDetails.RetailPrice; //发生调整时,数量为0,只调价格 account.LendAmount = 0; //Math.Abs(billDetails.DispAmount); account.LendRetailFee = GetFee(Math.Abs(billDetails.DispAmount), billDetails.UnitAmount, storeParam.RetailPrice, billDetails.Dosage) - GetFee(Math.Abs(billDetails.DispAmount), billDetails.UnitAmount, billDetails.RetailPrice, billDetails.Dosage); account.LendStockFee = GetFee(Math.Abs(billDetails.DispAmount), billDetails.UnitAmount, storeParam.StockPrice, billDetails.Dosage) - GetFee(Math.Abs(billDetails.DispAmount), billDetails.UnitAmount, billDetails.StockPrice, billDetails.Dosage); account.OverAmount = batchAllot.StoreAmount; account.OverRetailFee = batchAllot.StoreAmount * (account.RetailPrice / batchAllot.UnitAmount); account.OverStockFee = batchAllot.StoreAmount * (account.StockPrice / batchAllot.UnitAmount); } account.save(); }
/// <summary> /// 转换住院发药费用明细模型 /// </summary> /// <param name="dtDetail">住院发药费用明细数据源</param> /// <param name="deptId">科室ID</param> /// <returns>住院发药费用明细数据集</returns> private List <DS_IPDispDetail> ConvertFeeDetailModel(DataTable dtDetail, int deptId) { List <DS_IPDispDetail> dispDetail = new List <DS_IPDispDetail>(); foreach (DataRow row in dtDetail.Rows) { if (row["chk"].ToString() == "1") { DS_IPDispDetail modelDetail = new DS_IPDispDetail(); modelDetail.DispDetailID = 0; modelDetail.DispHeadID = 0; modelDetail.CTypeID = Convert.ToInt32(row["CTypeID"]); modelDetail.DrugID = Convert.ToInt32(row["DrugID"]); modelDetail.DrugSpecID = Convert.ToInt32(row["DrugSpecID"]); modelDetail.ChemName = row["ChemName"].ToString(); modelDetail.DrugSpec = row["DrugSpec"].ToString(); modelDetail.ProductName = row["ProductName"].ToString(); modelDetail.UnitID = Convert.ToInt32(row["UnitID"]); modelDetail.UnitName = row["UnitName"].ToString(); modelDetail.UnitAmount = Convert.ToInt32(row["UnitAmount"]); modelDetail.DispAmount = Convert.ToInt32(row["DispAmount"]); modelDetail.Dosage = Convert.ToInt32(row["Dosage"]); modelDetail.RetailPrice = Convert.ToDecimal(row["SellPrice"]); modelDetail.StockPrice = Convert.ToDecimal(row["InPrice"]); modelDetail.BatchNO = string.Empty; modelDetail.RetailFee = Convert.ToDecimal(row["SellFee"]); modelDetail.StockFee = Convert.ToDecimal(row["StockFee"]); modelDetail.FeelID = Convert.ToInt32(row["FeeRecordID"]); modelDetail.ChargeTime = Convert.ToDateTime(row["CostDate"]); modelDetail.ChargerID = Convert.ToInt32(row["CostEmpID"]); modelDetail.MsgHeadID = Convert.ToInt32(row["BillHeadID"]); modelDetail.MsgDetaillID = Convert.ToInt32(row["BillDetailID"]); modelDetail.GroupNO = Convert.ToInt32(row["GroupNO"]); modelDetail.InpatientNO = row["InpatientNO"].ToString(); modelDetail.InPatientID = Convert.ToInt32(row["PatListID"]); modelDetail.PatName = row["PatName"].ToString(); modelDetail.BedNo = row["BedNO"].ToString(); modelDetail.PresDocID = Convert.ToInt32(row["PatDoctorID"]); modelDetail.PresDocName = row["PresDocName"].ToString(); modelDetail.UseAmount = Convert.ToInt32(row["UseAmount"]); modelDetail.UseWay = row["UseWay"].ToString(); modelDetail.Frequency = row["Frequency"].ToString(); modelDetail.UseUnit = row["UseUnit"].ToString(); modelDetail.PackUnit = row["PackUnit"].ToString(); modelDetail.Orders = row["Orders"].ToString(); modelDetail.DeptID = deptId; dispDetail.Add(modelDetail); } } return(dispDetail); }
/// <summary> /// 获取头表信息 /// </summary> /// <param name="opType">业务类型</param> /// <param name="deptId">科室Id</param> /// <param name="detailID">明细Id</param> /// <returns>头表信息</returns> public BillMasterShower GetBillHeadInfo(string opType, int deptId, int detailID) { BillMasterShower shower = new BillMasterShower(); switch (opType) { case "011": //采购入库 case "012": //期初入库 case "013": //流通入库 DS_InStoreDetail inStoreDetail = (DS_InStoreDetail)NewObject <DS_InStoreDetail>().getmodel(detailID); if (inStoreDetail != null) { DS_InstoreHead instoreHead = (DS_InstoreHead)NewObject <DS_InstoreHead>().getmodel(inStoreDetail.InHeadID); if (instoreHead != null) { shower.RegTime = instoreHead.RegTime; shower.AuditTime = instoreHead.AuditTime; shower.BillNo = instoreHead.BillNO.ToString(); shower.RelationPeopleNo = instoreHead.OpEmpID.ToString(); shower.RelationPeople = instoreHead.OpEmpName; shower.RelationUnit = instoreHead.SupplierName; shower.RetailFee = instoreHead.RetailFee; shower.StockFee = instoreHead.StockFee; shower.OpType = GetBusiTypeName(opType); shower.RegPeople = instoreHead.RegEmpName; shower.Remark = instoreHead.Remark; } } break; case "021": //内耗出库 case "022": //报损出库 DS_OutStoreDetail outStoreDetail = (DS_OutStoreDetail)NewObject <DS_OutStoreDetail>().getmodel(detailID); if (outStoreDetail != null) { DS_OutStoreHead outStoreHead = (DS_OutStoreHead)NewObject <DS_OutStoreHead>().getmodel(outStoreDetail.OutHeadID); if (outStoreDetail != null) { shower.RegTime = outStoreHead.RegTime; shower.AuditTime = outStoreHead.AuditTime; shower.BillNo = outStoreHead.BillNO.ToString(); shower.RelationPeopleNo = "暂无"; shower.RelationPeople = "暂无"; shower.RelationUnit = outStoreHead.ToDeptName; shower.RetailFee = outStoreHead.RetailFee; shower.StockFee = outStoreHead.StockFee; shower.OpType = GetBusiTypeName(opType); shower.RegPeople = outStoreHead.RegEmpName; shower.Remark = outStoreHead.Remark; } } break; case "031": //门诊发药 case "032": //门诊退药 DS_OPDispDetail oPDispDetail = (DS_OPDispDetail)NewObject <DS_OPDispDetail>().getmodel(detailID); if (oPDispDetail != null) { DS_OPDispHead oPDispHead = (DS_OPDispHead)NewObject <DS_OPDispHead>().getmodel(oPDispDetail.DispHeadID); if (oPDispHead != null) { shower.RegTime = oPDispHead.DispTime; shower.AuditTime = oPDispHead.DispTime; shower.BillNo = oPDispHead.BillNO.ToString(); shower.RelationPeopleNo = "暂无"; shower.RelationPeople = "暂无"; shower.RelationUnit = oPDispHead.PresDeptName; shower.RetailFee = oPDispHead.RetailFee; shower.StockFee = 0; shower.OpType = GetBusiTypeName(opType); shower.RegPeople = oPDispHead.PharmacistName; shower.Remark = string.Empty; } } break; case "033": //住院发药 DS_IPDispDetail iPDispDetail = (DS_IPDispDetail)NewObject <DS_IPDispDetail>().getmodel(detailID); if (iPDispDetail != null) { DS_IPDispHead iPDispHead = (DS_IPDispHead)NewObject <DS_IPDispHead>().getmodel(iPDispDetail.DispHeadID); if (iPDispHead != null) { shower.RegTime = iPDispHead.DispTime; shower.AuditTime = iPDispHead.DispTime; shower.BillNo = iPDispHead.BillNO.ToString(); shower.RelationPeopleNo = "暂无"; shower.RelationPeople = "暂无"; shower.RelationUnit = GetDeptName(iPDispHead.DeptID); shower.RetailFee = iPDispHead.RetailFee; shower.StockFee = 0; shower.OpType = GetBusiTypeName(opType); shower.RegPeople = GetEmpName(iPDispHead.PharmacistID); shower.Remark = string.Empty; } } break; case "042": //盘点审核 DS_AuditDetail auditDetail = (DS_AuditDetail)NewObject <DS_AuditDetail>().getmodel(detailID); if (auditDetail != null) { DS_AuditHead auditHead = (DS_AuditHead)NewObject <DS_AuditHead>().getmodel(auditDetail.AuditHeadID); if (auditHead != null) { shower.RegTime = auditHead.AuditTime; shower.AuditTime = auditHead.AuditTime; shower.BillNo = auditHead.BillNO.ToString(); shower.RelationPeopleNo = auditHead.EmpID.ToString(); shower.RelationPeople = auditHead.EmpName; shower.RelationUnit = GetDeptName(auditHead.DeptID); shower.RetailFee = auditHead.CheckRetailFee; shower.StockFee = auditHead.CheckStockFee; shower.OpType = GetBusiTypeName(opType); shower.RegPeople = auditHead.EmpName; shower.Remark = string.Empty; } } break; case "051": //药房调价 DG_AdjDetail adjDetail = (DG_AdjDetail)NewObject <DG_AdjDetail>().getmodel(detailID); if (adjDetail != null) { DG_AdjHead adjHead = (DG_AdjHead)NewObject <DG_AdjHead>().getmodel(adjDetail.AdjHeadID); if (adjHead != null) { shower.RegTime = adjHead.RegTime; shower.AuditTime = adjHead.ExecTime; shower.BillNo = adjHead.BillNO.ToString(); shower.RelationPeopleNo = adjHead.RegEmpID.ToString(); shower.RelationPeople = GetEmpName(adjHead.RegEmpID); shower.RelationUnit = GetDeptName(adjHead.DeptID); shower.RetailFee = 0; shower.StockFee = 0; shower.OpType = GetBusiTypeName(opType); shower.RegPeople = GetEmpName(adjHead.RegEmpID); shower.Remark = adjHead.Remark; } } break; } return(shower); }
/// <summary> /// 台账写入--批次发退药数量台账 /// </summary> /// <param name="billHead">发药单表头</param> /// <param name="billDetails">发药单明细</param> /// <param name="batchAllot">批次</param> /// <param name="refundFlag">退药标志</param> /// <param name="storeParam">库存处理参数</param> public void WriteAccount(DS_IPDispHead billHead, DS_IPDispDetail billDetails, DGBatchAllot batchAllot, int refundFlag, StoreParam storeParam) { int actYear; int actMonth; string errMsg; if (!GetAccountTime(billHead.ExecDeptID, out errMsg, out actYear, out actMonth)) { throw new Exception(errMsg); } DS_Account account = NewObject <DS_Account>(); account.BalanceYear = actYear; account.BalanceMonth = actMonth; account.AccountType = 0;//药房 account.BalanceFlag = 0; account.BatchNO = billDetails.BatchNO; account.BusiType = billHead.BusiType; account.CTypeID = billDetails.CTypeID; account.DeptID = billDetails.DeptID; account.DetailID = billDetails.DispDetailID; account.DrugID = billDetails.DrugID; account.UnitID = billDetails.UnitID; account.UnitName = billDetails.UnitName; account.RegTime = DateTime.Now; //盘盈 借方 //盘亏 贷方 if (refundFlag == 1) { //退药 借方 account.StockPrice = storeParam.StockPrice; account.RetailPrice = storeParam.RetailPrice; account.LendAmount = Math.Abs(billDetails.DispAmount); account.LendRetailFee = batchAllot.DispRetailFee; account.LendStockFee = batchAllot.DispStockFee; account.OverAmount = batchAllot.StoreAmount; //account.OverRetailFee = batchAllot.StoreAmount * (batchAllot.RetailPrice / batchAllot.UnitAmount); //account.OverStockFee = batchAllot.StoreAmount * (batchAllot.StockPrice / batchAllot.UnitAmount); //当药品批次价格和实际价格不一致时,退药按实际价格退 if (storeParam.RetailPrice.Equals(batchAllot.RetailPrice) == false) { account.OverRetailFee = batchAllot.StoreAmount * (storeParam.RetailPrice / storeParam.UnitAmount); } else { account.OverRetailFee = batchAllot.StoreAmount * (batchAllot.RetailPrice / batchAllot.UnitAmount); } if (storeParam.StockPrice.Equals(batchAllot.StockPrice) == false) { account.OverStockFee = batchAllot.StoreAmount * (storeParam.StockPrice / storeParam.UnitAmount); } else { account.OverStockFee = batchAllot.StoreAmount * (batchAllot.StockPrice / batchAllot.UnitAmount); } } else { //发药 贷方 account.StockPrice = storeParam.StockPrice; account.RetailPrice = storeParam.RetailPrice; account.DebitAmount = billDetails.DispAmount; account.DebitRetailFee = batchAllot.DispRetailFee; account.DebitStockFee = batchAllot.DispStockFee; account.OverAmount = batchAllot.StoreAmount; //account.OverRetailFee = batchAllot.StoreAmount * (batchAllot.RetailPrice / batchAllot.UnitAmount); //account.OverStockFee = batchAllot.StoreAmount * (batchAllot.StockPrice / batchAllot.UnitAmount); //当发药时价格和实际批次价格不一致时,剩余价格等于加上要发出的数量*调价后的金额减去发出药量的总金额(发出药量是按批次表原有的价格算的) if (storeParam.RetailPrice.Equals(batchAllot.RetailPrice) == false) { account.OverRetailFee = ((batchAllot.StoreAmount + billDetails.DispAmount) * (batchAllot.RetailPrice / batchAllot.UnitAmount)) - batchAllot.DispRetailFee; } else { account.OverRetailFee = batchAllot.StoreAmount * (batchAllot.RetailPrice / batchAllot.UnitAmount); } if (storeParam.StockPrice.Equals(batchAllot.StockPrice) == false) { account.OverStockFee = ((batchAllot.StoreAmount + billDetails.DispAmount) * (batchAllot.StockPrice / batchAllot.UnitAmount)) - batchAllot.DispStockFee; } else { account.OverStockFee = batchAllot.StoreAmount * (batchAllot.StockPrice / batchAllot.UnitAmount); } } account.save(); }