/// <summary> /// 获取优惠部分 /// </summary> /// <param name="tbAllInvoiceList"></param> /// <returns></returns> private static FundPart GetFavorPart(DataTable tbAllInvoiceList) { FundPart favorPart = new FundPart( ); object objSum = tbAllInvoiceList.Compute("Sum(favor_fee)", ""); favorPart.TotalMoney = Convert.IsDBNull(objSum) ? 0 : Convert.ToDecimal(objSum); return(favorPart); }
/// <summary> /// 获取实收现金部分 /// </summary> /// <param name="tbAllInvoiceList"></param> /// <returns></returns> private static FundPart GetCashPart(DataTable tbAllInvoiceList, DataTable tbAllInvoiceDetailList) { FundPart cashPart = new FundPart( ); object objSum = null; //实收现金 objSum = tbAllInvoiceList.Compute("SUM(money_fee)", ""); cashPart.TotalMoney = Convert.IsDBNull(objSum) ? 0 : Convert.ToDecimal(objSum); DataTable tbChargeInvoiceDetaiList = tbAllInvoiceDetailList.Clone( ); DataTable tbRegisterInvoiceDetaiList = tbAllInvoiceDetailList.Clone( ); //分开挂号和收费的明细 for (int i = 0; i < tbAllInvoiceDetailList.Rows.Count; i++) { int flag = Convert.ToInt32(tbAllInvoiceDetailList.Rows[i]["hang_flag"]); if (flag == 0) { tbRegisterInvoiceDetaiList.Rows.Add(tbAllInvoiceDetailList.Rows[i].ItemArray); } else { tbChargeInvoiceDetaiList.Rows.Add(tbAllInvoiceDetailList.Rows[i].ItemArray); } } //处方收费 FundInfo fundCharge = new FundInfo( ); fundCharge.PayName = "处方收费"; objSum = tbAllInvoiceList.Compute("Sum(money_fee)", "hang_flag = 1"); fundCharge.Money = Convert.IsDBNull(objSum) ? 0 : Convert.ToDecimal(objSum); //挂号收费 FundInfo fundRegFee = new FundInfo( ); fundRegFee.PayName = "挂号费"; objSum = tbRegisterInvoiceDetaiList.Compute("sum(total_fee)", "stat_item_code='05' and hang_flag=0 and money_fee<>0"); fundRegFee.Money = Convert.IsDBNull(objSum) ? 0 : Convert.ToDecimal(objSum); //挂号诊金 FundInfo fundExamine = new FundInfo( ); fundExamine.PayName = "诊查费"; objSum = tbRegisterInvoiceDetaiList.Compute("sum(total_fee)", "stat_item_code='06' and hang_flag=0 and money_fee<>0"); fundExamine.Money = Convert.IsDBNull(objSum) ? 0 : Convert.ToDecimal(objSum); cashPart.Details = new FundInfo[3]; cashPart.Details[0] = fundCharge; cashPart.Details[1] = fundRegFee; cashPart.Details[2] = fundExamine; return(cashPart); }
/// <summary> /// 获取记账部分 /// </summary> /// <param name="tbAllInvoiceList"></param> /// <returns></returns> private static FundPart GetTallyPart(DataTable tbAllInvoiceList) { List <FundInfo> lstFundInfo = new List <FundInfo>( ); decimal totalTally = 0; //按病人类型获取记账 DataTable PatientTypeList = BaseDataController.BaseDataSet[BaseDataCatalog.病人类型列表]; FundInfo[] fundPatType = new FundInfo[PatientTypeList.Rows.Count]; for (int i = 0; i < PatientTypeList.Rows.Count; i++) { fundPatType[i].PayCode = PatientTypeList.Rows[i]["PATTYPECODE"].ToString( ).Trim( ); fundPatType[i].PayName = PatientTypeList.Rows[i]["NAME"].ToString( ).Trim( ) + "_记账"; } for (int i = 0; i < fundPatType.Length; i++) { DataRow[] drsInvoice = tbAllInvoiceList.Select("meditype='" + fundPatType[i].PayCode + "'"); for (int j = 0; j < drsInvoice.Length; j++) { decimal tallyMoney = Convert.ToDecimal(drsInvoice[j]["village_fee"]); if (tallyMoney != 0) { fundPatType[i].BillCount = fundPatType[i].BillCount + 1; fundPatType[i].Money = fundPatType[i].Money + tallyMoney; totalTally = totalTally + tallyMoney; } } } lstFundInfo = fundPatType.ToList( ); //POS记账 FundInfo fundPos = new FundInfo( ); fundPos.BillCount = 0; fundPos.PayName = "POS金额"; //个人记账 FundInfo fundSelfTally = new FundInfo( ); fundSelfTally.PayName = "单位记账"; for (int i = 0; i < tbAllInvoiceList.Rows.Count; i++) { decimal posMoney = Convert.ToDecimal(tbAllInvoiceList.Rows[i]["pos_fee"]); decimal selfTallyMoney = Convert.ToDecimal(tbAllInvoiceList.Rows[i]["self_tally"]); if (posMoney != 0) { fundPos.BillCount = fundPos.BillCount + 1; fundPos.Money = fundPos.Money + posMoney; totalTally = totalTally + posMoney; } if (selfTallyMoney != 0) { fundSelfTally.BillCount = fundSelfTally.BillCount + 1; fundSelfTally.Money = fundSelfTally.Money + selfTallyMoney; totalTally = totalTally + selfTallyMoney; } } lstFundInfo.Add(fundPos); lstFundInfo.Add(fundSelfTally); FundPart tallyPart = new FundPart( ); tallyPart.TotalMoney = totalTally; tallyPart.Details = lstFundInfo.ToArray( ); return(tallyPart); }
/// <summary> /// 汇总所有人账单 /// </summary> /// <param name="Books"></param> /// <returns></returns> public static CollectAccountBook CollectAllAccountBook(List <PrivyAccountBook> Books) { CollectAccountBook totalBook = new CollectAccountBook( ); List <AccountBillInfo> chargeBillinfo = new List <AccountBillInfo>( ); List <AccountBillInfo> registerBillinfo = new List <AccountBillInfo>( ); FundPart cashPart = new FundPart( ); FundPart favorPart = new FundPart( ); FundPart tallyPart = new FundPart( ); Hashtable htInvoiceItem = new Hashtable( ); foreach (PrivyAccountBook book in Books) { #region 合并发票科目部分 if (book == null || book.InvoiceItem == null) { continue; } totalBook.InvoiceItemSumTotal += book.InvoiceItemSumTotal; #region 合并收费票据部分 chargeBillinfo.Add(book.ChargeInvoiceInfo); //chargeBillinfo.Count += book.ChargeInvoiceInfo.Count; //chargeBillinfo.RefundCount += book.ChargeInvoiceInfo.RefundCount; //chargeBillinfo.RefundMoney += book.ChargeInvoiceInfo.RefundMoney; //List<Invoice> lstChargeInvoice = new List<Invoice>( ); //if ( chargeBillinfo.InvoiceList != null ) // lstChargeInvoice = chargeBillinfo.InvoiceList.ToList( ); //if ( book.ChargeInvoiceInfo.InvoiceList != null ) //{ // for ( int i = 0 ; i < book.ChargeInvoiceInfo.InvoiceList.Length ; i++ ) // lstChargeInvoice.Add( book.ChargeInvoiceInfo.InvoiceList[i] ); //} //chargeBillinfo.InvoiceList = lstChargeInvoice.ToArray( ); #endregion #region 合并挂号票据部分 //registerBillinfo.Count += book.RegisterInvoiceInfo.Count; ////if ( ( registerBillinfo.StartNumber == "" || registerBillinfo.StartNumber == null ) && book.RegisterInvoiceInfo.StartNumber != "" ) //// registerBillinfo.StartNumber = book.RegisterInvoiceInfo.StartNumber; ////if ( book.RegisterInvoiceInfo.EndNumber != "" ) //// registerBillinfo.EndNumber = book.RegisterInvoiceInfo.EndNumber; //registerBillinfo.RefundCount += book.RegisterInvoiceInfo.RefundCount; //registerBillinfo.RefundMoney += book.RegisterInvoiceInfo.RefundMoney; //List<Invoice> lstRegInvoice = new List<Invoice>( ); //if ( registerBillinfo.InvoiceList != null ) // lstRegInvoice = registerBillinfo.InvoiceList.ToList( ); //if ( book.RegisterInvoiceInfo.InvoiceList != null ) //{ // for ( int i = 0 ; i < book.RegisterInvoiceInfo.InvoiceList.Length ; i++ ) // lstRegInvoice.Add( book.RegisterInvoiceInfo.InvoiceList[i] ); //} //registerBillinfo.InvoiceList = lstRegInvoice.ToArray( ); registerBillinfo.Add(book.RegisterInvoiceInfo); #endregion for (int i = 0; i < book.InvoiceItem.Length; i++) { if (htInvoiceItem.ContainsKey(book.InvoiceItem[i].ItemCode)) { InvoiceItem invoiceItem = (InvoiceItem)htInvoiceItem[book.InvoiceItem[i].ItemCode]; invoiceItem.Cost += book.InvoiceItem[i].Cost; htInvoiceItem.Remove(book.InvoiceItem[i].ItemCode); htInvoiceItem.Add(invoiceItem.ItemCode, invoiceItem); } else { htInvoiceItem.Add(book.InvoiceItem[i].ItemCode, book.InvoiceItem[i]); } } #endregion #region 合并现金部分 cashPart.TotalMoney += book.CashPart.TotalMoney; if (cashPart.Details == null) { cashPart.Details = new FundInfo[3]; } for (int i = 0; i < book.CashPart.Details.Length; i++) { cashPart.Details[i].BillCount += book.CashPart.Details[i].BillCount; cashPart.Details[i].Money += book.CashPart.Details[i].Money; cashPart.Details[i].PayCode = book.CashPart.Details[i].PayCode; cashPart.Details[i].PayName = book.CashPart.Details[i].PayName; } #endregion #region 合并记账部分 tallyPart.TotalMoney += book.TallyPart.TotalMoney; if (tallyPart.Details == null) { tallyPart.Details = new FundInfo[book.TallyPart.Details.Length]; } for (int i = 0; i < book.TallyPart.Details.Length; i++) { tallyPart.Details[i].BillCount += book.TallyPart.Details[i].BillCount; tallyPart.Details[i].Money += book.TallyPart.Details[i].Money; tallyPart.Details[i].PayCode = book.TallyPart.Details[i].PayCode; tallyPart.Details[i].PayName = book.TallyPart.Details[i].PayName; } #endregion //合并优惠部分 favorPart.TotalMoney += book.FavorPart.TotalMoney; } totalBook.ChargeInvoiceInfo = chargeBillinfo.ToArray(); totalBook.RegisterInvoiceInfo = registerBillinfo.ToArray(); totalBook.CashPart = cashPart; totalBook.TallyPart = tallyPart; totalBook.FavorPart = favorPart; totalBook.InvoiceItem = new InvoiceItem[htInvoiceItem.Count]; int count = 0; foreach (object obj in htInvoiceItem) { totalBook.InvoiceItem[count] = (InvoiceItem)((DictionaryEntry)obj).Value; count++; } return(totalBook); }