/// <summary> /// 全退 /// </summary> /// <param name="costHeadid">结算ID</param> /// <param name="operatoreid">操作员ID</param> /// <param name="refundPrescriptions">退费处方</param> /// <param name="refundInvoiceNO">退费票据号</param> /// <returns>全退后未收的处方对象</returns> public override List <Prescription> RefundFee(int costHeadid, int operatoreid, List <Prescription> refundPrescriptions, string refundInvoiceNO) { AllRefund(costHeadid, operatoreid, refundPrescriptions, refundInvoiceNO); List <Prescription> balancePresc = new List <Prescription>(); // 医生站的处方退后重新生成的处方 List <int> updateDocPres = new List <int>(); //返回需要补收的处方记录 foreach (Prescription refundPresc in refundPrescriptions) { if (refundPresc.PresAmount == 0) { refundPresc.PresAmount = 1; } if (refundPresc.Amount * refundPresc.PresAmount != refundPresc.Refundamount) { refundPresc.Amount = refundPresc.Amount * refundPresc.PresAmount - refundPresc.Refundamount; refundPresc.TotalFee = refundPresc.TotalFee - refundPresc.Refundfee; //部分退费重新生成的新处方 if (refundPresc.Refundamount > 0 && refundPresc.DocPresHeadID > 0) { updateDocPres.Add(refundPresc.FeeItemHeadID); } balancePresc.Add(refundPresc); } } if (balancePresc.Count > 0) { //补收的处方数据保存到数据库 List <int> presNum = GetPrescNum(balancePresc); for (int i = 0; i < presNum.Count; i++) { int groupid = presNum[i]; List <Prescription> presDetails = balancePresc.Where(p => p.PrescGroupID == groupid && p.SubTotalFlag == 0).ToList(); if (presDetails.Count > 0) { OP_FeeItemHead oldFeeitemHead = NewObject <OP_FeeItemHead>().getmodel(presDetails[0].FeeItemHeadID) as OP_FeeItemHead; OP_FeeItemHead feeitemHead = oldFeeitemHead.Clone() as OP_FeeItemHead; feeitemHead.FeeItemHeadID = 0; feeitemHead.ChargeEmpID = operatoreid; feeitemHead.ChargeDate = DateTime.Now; feeitemHead.ChargeFlag = 0; feeitemHead.ChargeStatus = 0; if (updateDocPres.Contains(presDetails[0].FeeItemHeadID)) { feeitemHead.DocPresHeadID = 0; feeitemHead.DocPresNO = 0; } decimal roundingMoney = 0; feeitemHead.TotalFee = NewObject <PrescMoneyCalculate>().GetPrescriptionTotalMoney(presDetails, out roundingMoney); this.BindDb(feeitemHead); feeitemHead.save(); for (int j = 0; j < balancePresc.Count; j++) { if (balancePresc[j].PrescGroupID == groupid && balancePresc[j].SubTotalFlag == 0) { OP_FeeItemDetail oldfeeDetail = NewObject <OP_FeeItemDetail>().getmodel(balancePresc[j].PresDetailID) as OP_FeeItemDetail; OP_FeeItemDetail feeDetial = oldfeeDetail.Clone() as OP_FeeItemDetail; feeDetial.PresDetailID = 0; feeDetial.Amount = balancePresc[j].Amount; feeDetial.TotalFee = balancePresc[j].TotalFee; feeDetial.FeeItemHeadID = feeitemHead.FeeItemHeadID; if (updateDocPres.Contains(presDetails[0].FeeItemHeadID)) { feeDetial.DocPresDetailID = 0; balancePresc[j].DocPresDetailID = 0; balancePresc[j].DocPresHeadID = 0; balancePresc[j].DocPresNO = 0; } feeDetial.save(); balancePresc[j].FeeItemHeadID = feeitemHead.FeeItemHeadID; balancePresc[j].PresDetailID = feeDetial.PresDetailID; balancePresc[j].FeeNo = feeitemHead.FeeNo; balancePresc[j].DocPresDate = feeDetial.DocPresDate; balancePresc[j].ModifyFlag = 0; } } } } } return(balancePresc); }
/// <summary> /// 处方退费 /// </summary> /// <param name="costHeadid">结算ID</param> /// <param name="operatoreid">操作员ID</param> /// <param name="refundPrescriptions">退处方对象</param> /// <param name="refundInvoiceNO">退费票据号</param> /// <returns> 被退后的处方对象</returns> public override List <Prescription> RefundFee(int costHeadid, int operatoreid, List <Prescription> refundPrescriptions, string refundInvoiceNO) { //先全退,再算出需退处方再退费 AllRefund(costHeadid, operatoreid, refundPrescriptions, refundInvoiceNO); List <Prescription> balancePresc = new List <Prescription>(); //返回需要补收的处方记录 foreach (Prescription refundPresc in refundPrescriptions) { if (refundPresc.Amount != refundPresc.Refundamount) { refundPresc.Amount = refundPresc.Amount - refundPresc.Refundamount; refundPresc.TotalFee = refundPresc.TotalFee - refundPresc.Refundfee; balancePresc.Add(refundPresc); } } #region 暂不用 //OP_CostHead oldCostHead = NewObject<OP_CostHead>().getmodel(costHeadid) as OP_CostHead; //bool autoProcess = false; //if (oldCostHead.TotalFee == oldCostHead.CashFee + oldCostHead.PosFee + oldCostHead.RoundingFee) //{ // autoProcess = true; //} //if (autoProcess)//全现金处理 //{ // if (_isallRefund) // { // List<OP_FeeItemHead> feeItemHeadList = NewObject<OP_FeeItemHead>().getlist<OP_FeeItemHead>(" costHeadId=" + costHeadid + " and invoiceNO!='" + RefundInvoiceNO + " and ChargeStatus=1"); // if (feeItemHeadList.Count == 0)//表示一次结算只有一张票据 // { // return balancePresc; // } // decimal allTotalFee = feeItemHeadList.Sum(p => p.TotalFee); // OP_CostHead costHead = new OP_CostHead(); // costHead.CostHeadID = 0; // costHead.TotalFee = allTotalFee; // costHead.CashFee = allTotalFee; // costHead.PosFee = 0; // costHead.PromFee = 0; // costHead.ChargeEmpID = operatoreid; // costHead.CostDate = DateTime.Now; // foreach (OP_FeeItemHead feeitemHead in feeItemHeadList) // { // } // } //} #endregion BasicDataManagement basicdata = NewObject <BasicDataManagement>(); //补收的处方数据保存到数据库 if (balancePresc.Count > 0) { OP_FeeItemHead oldFeeitemHead = NewObject <OP_FeeItemHead>().getmodel(balancePresc[0].FeeItemHeadID) as OP_FeeItemHead; OP_FeeItemHead feeitemHead = oldFeeitemHead.Clone() as OP_FeeItemHead; feeitemHead.FeeItemHeadID = 0; feeitemHead.ChargeEmpID = operatoreid; feeitemHead.ChargeDate = DateTime.Now; feeitemHead.ChargeFlag = 0; feeitemHead.ChargeStatus = 0; decimal roundingMoney = 0; feeitemHead.TotalFee = NewObject <PrescMoneyCalculate>().GetPrescriptionTotalMoney(balancePresc, out roundingMoney); this.BindDb(feeitemHead); feeitemHead.save(); for (int j = 0; j < balancePresc.Count; j++) { OP_FeeItemDetail oldfeeDetail = NewObject <OP_FeeItemDetail>().getmodel(balancePresc[j].PresDetailID) as OP_FeeItemDetail; OP_FeeItemDetail feeDetial = oldfeeDetail.Clone() as OP_FeeItemDetail; feeDetial.PresDetailID = 0; feeDetial.Amount = balancePresc[j].Amount; feeDetial.TotalFee = balancePresc[j].TotalFee; feeDetial.FeeItemHeadID = feeitemHead.FeeItemHeadID; feeDetial.save(); balancePresc[j].FeeItemHeadID = feeitemHead.FeeItemHeadID; balancePresc[j].PresDetailID = feeDetial.PresDetailID; balancePresc[j].FeeNo = feeitemHead.FeeNo; balancePresc[j].ModifyFlag = 0; } } OP_CostHead oldCostHead = NewObject <OP_CostHead>().getmodel(costHeadid) as OP_CostHead; List <OP_FeeItemHead> feeItemHeadList = NewObject <OP_FeeItemHead>().getlist <OP_FeeItemHead>(" costHeadId=" + costHeadid + " and invoiceNO!='" + refundInvoiceNO + "' and ChargeStatus=1"); int i = 1; foreach (OP_FeeItemHead oldfeeitemhead in feeItemHeadList) { OP_FeeItemHead newfeeitemhead = oldfeeitemhead.Clone() as OP_FeeItemHead; newfeeitemhead.ChargeFlag = 0; newfeeitemhead.FeeItemHeadID = 0; newfeeitemhead.ChargeStatus = 0; newfeeitemhead.ChargeEmpID = operatoreid; newfeeitemhead.CostHeadID = 0; newfeeitemhead.save(); List <OP_FeeItemDetail> feeItemDetaliList = NewObject <OP_FeeItemDetail>().getlist <OP_FeeItemDetail>(" feeitemheadid=" + oldfeeitemhead.FeeItemHeadID); foreach (OP_FeeItemDetail oldfeeItemDetail in feeItemDetaliList) { int j = 0; OP_FeeItemDetail newFeeitemDetail = oldfeeItemDetail.Clone() as OP_FeeItemDetail; newFeeitemDetail.PresDetailID = 0; newFeeitemDetail.FeeItemHeadID = newfeeitemhead.FeeItemHeadID; newfeeitemhead.save(); #region 明细 Prescription pres = new Prescription(); pres.PresDetailID = newFeeitemDetail.PresDetailID; pres.FeeItemHeadID = newFeeitemDetail.FeeItemHeadID; pres.PatListID = newFeeitemDetail.PatListID; pres.ItemID = newFeeitemDetail.ItemID; pres.ItemName = newFeeitemDetail.ItemName; pres.Spec = newFeeitemDetail.Spec; pres.PackUnit = newFeeitemDetail.PackUnit; pres.UnitNO = newFeeitemDetail.UnitNO; pres.StockPrice = newFeeitemDetail.StockPrice; pres.Amount = newFeeitemDetail.Amount; pres.PresAmount = newFeeitemDetail.PresAmount; pres.TotalFee = newFeeitemDetail.TotalFee; pres.ExamItemID = newFeeitemDetail.ExamItemID; pres.DocPresDetailID = newFeeitemDetail.DocPresDetailID; pres.MiniUnit = newFeeitemDetail.MiniUnit; pres.RetailPrice = newFeeitemDetail.RetailPrice; pres.StatID = newFeeitemDetail.StatID; pres.ItemType = newFeeitemDetail.ItemType; pres.PrescGroupID = i + 1; pres.presNO = j == 0 ? i + 1 : 0; pres.PresDeptID = newfeeitemhead.PresDeptID; pres.PresEmpID = newfeeitemhead.PresEmpID; pres.ExecDeptID = newfeeitemhead.ExecDeptID; pres.PresDocName = basicdata.GetEmpName(newfeeitemhead.PresEmpID); pres.ExecDetpName = basicdata.GetDeptName(newfeeitemhead.ExecDeptID); pres.PresType = newfeeitemhead.PresType; pres.ModifyFlag = 0; pres.Selected = 1; if (Convert.ToInt32(pres.ItemType) == (int)OP_Enum.ItemType.收费项目 || Convert.ToInt32(pres.ItemType) == (int)OP_Enum.ItemType.组合项目) { pres.MiniAmount = newFeeitemDetail.Amount; pres.PackAmount = (newFeeitemDetail.Amount - pres.MiniAmount) / pres.UnitNO; } else { pres.MiniAmount = newFeeitemDetail.Amount % newFeeitemDetail.UnitNO; pres.PackAmount = (newFeeitemDetail.Amount - pres.MiniAmount) / pres.UnitNO; } pres.DocPresHeadID = newfeeitemhead.DocPresHeadID; balancePresc.Add(pres); j += 1; #endregion } i += 1; } return(balancePresc); }