private List<UndeclaredCollectionRecord> GetUndeclaredPartCollectionByCollectionNo(int collectionNo, DeclarationFilterBy filterBy, string filterValue) { var undeclaredCollectionRecords = new List<UndeclaredCollectionRecord>(); var regionSettingValue = string.Empty; var isAutodeclaration = "true"; var i = 0; decimal handpay, jackpot = 0, ticketsIn, ticketsOut, shortpay = 0, refund = 0, refill = 0, winloss; decimal sumOfhandpay = 0, sumOfjackpot = 0, sumOfticketsIn = 0, sumOfticketsOut = 0, sumOfshortpay = 0, sumOfrefund = 0, sumOfrefill = 0, sumOfWinloss = 0; _collectionDataContext.GetSetting(0, "REGION", "US", ref regionSettingValue); _collectionDataContext.GetSetting(0, "Auto_Declare_Monies", "true", ref isAutodeclaration); foreach (var collection in _collectionDataContext.GetUndeclaredPartCollectionByCollectionNo(collectionNo, (int)filterBy, filterValue)) { i++; ticketsIn = Convert.ToDecimal((float)collection.TicketsIn); ticketsOut = Convert.ToDecimal((float)collection.TicketsOut); var undeclaredCollectionRecord = new UndeclaredCollectionRecord { ReferenceID = i, Position = collection.Bar_Pos_Name, AssetNo = collection.AssetNo, GameTitle = collection.Name, Installation_Token_Value = (int)collection.Installation_Token_Value, CollectionNo = (int)collection.Collection_No, CollectionBatchNo = collection.Collection_Batch_No, CollectionDate = (DateTime)collection.Date, CollectionTime = (DateTime)collection.Date, InstallationNo = collection.Installation_No, P100000 = (int)(collection.Cash_Collected_100000P), P50000 = (int)(collection.Cash_Collected_50000P), P20000 = (int)(collection.Cash_Collected_20000P), P10000 = (int)(collection.Cash_Collected_10000P), P5000 = (int)(collection.Cash_Collected_5000P), P2000 = (int)(collection.Cash_Collected_2000p), P1000 = (int)(collection.Cash_Collected_1000P), P500 = (int)(collection.Cash_Collected_500P), P200 = (int)(collection.Cash_Collected_200P), P100 = (int)(collection.Cash_Collected_100P), P50 = (decimal)(collection.Cash_Collected_50p), P20 = (decimal)(collection.Cash_Collected_20p), P10 = (decimal)(collection.Cash_Collected_10p), P5 = (decimal)(collection.Cash_Collected_5p), P2 = (decimal)(collection.Cash_Collected_2p), P1 = (decimal)(collection.Cash_Collected_1p), BackColor = "Black", Type = "Part", TicketsInValue = ticketsIn, TicketsOutValue = ticketsOut }; if (collection.Zone_No == null || collection.Zone_No == 0) undeclaredCollectionRecord.Zone = "N/A"; else undeclaredCollectionRecord.Zone = collection.Zone_Name; if (regionSettingValue == "US") undeclaredCollectionRecord.Region = "US"; if (isAutodeclaration.ToLower() == "true") { //Added by Anil to fix CR 88038 shortpay = Convert.ToDecimal(collection.ShortPay); handpay = Convert.ToDecimal(collection.Handpay); refund = Convert.ToDecimal(collection.Refunds); refill = Convert.ToDecimal(collection.Refills); jackpot = Convert.ToDecimal(collection.HandpayJackpot); //handpay = Convert.ToDecimal(collection.DeclaredHandpay); undeclaredCollectionRecord.ShortPayValue = shortpay; undeclaredCollectionRecord.HandpayValue = handpay; undeclaredCollectionRecord.RefundValue = refund; undeclaredCollectionRecord.RefillsValue = refill; undeclaredCollectionRecord.JackpotValue = jackpot; } else { shortpay = Convert.ToDecimal(collection.ShortPay); handpay = Convert.ToDecimal(collection.Handpay); refund = Convert.ToDecimal(collection.Refunds); refill = Convert.ToDecimal(collection.Refills); jackpot = Convert.ToDecimal(collection.HandpayJackpot); undeclaredCollectionRecord.ShortPayValue = shortpay; undeclaredCollectionRecord.HandpayValue = handpay; undeclaredCollectionRecord.RefundValue = refund; undeclaredCollectionRecord.RefillsValue = refill; undeclaredCollectionRecord.JackpotValue = jackpot; } winloss = (undeclaredCollectionRecord.TotalCoinsValue + undeclaredCollectionRecord.TotalBillValue + ticketsIn - ticketsOut - handpay - shortpay - refill - refund - jackpot); sumOfticketsIn += ticketsIn; sumOfticketsOut += ticketsOut; sumOfshortpay += shortpay; sumOfhandpay += handpay; sumOfrefund += refund; sumOfrefill += refill; sumOfjackpot += jackpot; sumOfWinloss += winloss; undeclaredCollectionRecord.WinLossValue = winloss; undeclaredCollectionRecords.Add(undeclaredCollectionRecord); } if (undeclaredCollectionRecords.Count == 0) return null; var uc = (from collectionRecord in undeclaredCollectionRecords group collectionRecord by collectionRecord.Region into collectiongroup select new UndeclaredCollectionRecord { // Added bool to handle sort in datagrid IsTotalRow = true, Zone = "Total", BackColor = "Blue", CollectionDate = DateTime.MinValue, CollectionTime = DateTime.MinValue, GameTitle = "", HandpayValue = sumOfhandpay, P1 = collectiongroup.Sum(c => c.P1), P2 = collectiongroup.Sum(c => c.P2), P5 = collectiongroup.Sum(c => c.P5), P10 = collectiongroup.Sum(c => c.P10), P20 = collectiongroup.Sum(c => c.P20), P50 = collectiongroup.Sum(c => c.P50), P100 = collectiongroup.Sum(c => c.P100), P200 = collectiongroup.Sum(c => c.P200), P500 = collectiongroup.Sum(c => c.P500), P1000 = collectiongroup.Sum(c => c.P1000), P2000 = collectiongroup.Sum(c => c.P2000), P5000 = collectiongroup.Sum(c => c.P5000), P10000 = collectiongroup.Sum(c => c.P10000), P20000 = collectiongroup.Sum(c => c.P20000), P50000 = collectiongroup.Sum(c => c.P50000), P100000 = collectiongroup.Sum(c => c.P100000), JackpotValue = sumOfjackpot, Meters = "", Position = "", AssetNo = "", RefillsValue = sumOfrefill, RefundValue = sumOfrefund, ShortPayValue = sumOfshortpay, TicketsInValue = sumOfticketsIn, TicketsOutValue = sumOfticketsOut, Type = "Total", WinLossValue = sumOfWinloss, Collection_Batch_Name = "" }).FirstOrDefault(); var returnCollection = new List<UndeclaredCollectionRecord> { uc }; returnCollection.AddRange(undeclaredCollectionRecords); return returnCollection; }
// private List<UndeclaredCollectionRecord> GetUndeclaredFullCollection(int batchNo, DeclarationFilterBy filterBy, string filterValue) { var undeclaredCollectionRecords = new List<UndeclaredCollectionRecord>(); var regionSettingValue = string.Empty; var isAutodeclaration = "true"; decimal handpay, jackpot, ticketsIn, ticketsOut, shortpay, refund, refill, EftIn, EFTOut, winloss, CoinOut, CoinIn, AttendantPay; decimal sumOfhandpay = 0, sumOfjackpot = 0, sumOfticketsIn = 0, sumOfticketsOut = 0, sumOfshortpay = 0, sumOfrefund = 0, sumOfrefill = 0, sumOfWinloss = 0, sumOfEftin = 0, sumOfEftout = 0, sumOfCoinOut = 0, sumOfCoinIn = 0, sumOfAttendantPay = 0; string Coll_Batch_Name = string.Empty; var i = 0; try { regionSettingValue = Common.Utilities.ExtensionMethods.CurrentSiteCulture; _collectionDataContext.GetSetting(0, "Auto_Declare_Monies", "true", ref isAutodeclaration); foreach (var collection in _collectionDataContext.GetFilteredUndeclaredCollectionByBatchNo(batchNo, (int)filterBy, filterValue)) { i++; ticketsIn = Convert.ToDecimal((float)collection.TicketsIn); //Include shortpay to voucher out if AddShortpayInVoucherOut is set if (Settings.AddShortpayInVoucherOut) { ticketsOut = (Settings.Client == "SGVI" & Settings.TicketDeclaration == "AUTO") ? Convert.ToDecimal((float)collection.TicketsOut) : Convert.ToDecimal((float)collection.TicketsOut) + Convert.ToDecimal(collection.ShortPay); } else { ticketsOut = Convert.ToDecimal((float)collection.TicketsOut); } Coll_Batch_Name = collection.Collection_Batch_Name; handpay = Convert.ToDecimal((float)collection.Handpay); CoinOut = Convert.ToDecimal((float)collection.CoinOut); CoinIn = Convert.ToDecimal((float)collection.CoinIn); EftIn = (decimal)(_collectionDataContext.GetEftIn(collection.Collection_No)); EFTOut = (decimal)(_collectionDataContext.GetEftOut(collection.Collection_No)); AttendantPay = Convert.ToDecimal(collection.AttendantPay); sumOfticketsIn += ticketsIn; sumOfticketsOut += ticketsOut; sumOfEftin += (EftIn / 100); sumOfEftout += (EFTOut / 100); sumOfCoinOut += CoinOut; sumOfCoinIn += CoinIn; var undeclaredCollectionRecord = new UndeclaredCollectionRecord { TicketsInValue = ticketsIn, TicketsOutValue = ticketsOut, CoinOutValue = CoinOut, CoinInValue = CoinIn, AssetNo = collection.AssetNo, ReferenceID = i, Position = collection.Bar_Pos_Name, GameTitle = collection.Name, CollectionDate = (DateTime)collection.Date, CollectionTime = (DateTime)collection.Date, CollectionNo = collection.Collection_No, InstallationNo = collection.Installation_No, CollectionBatchNo = (int)collection.Collection_Batch_No, P100000 = (int)(collection.Cash_Collected_100000P), P50000 = (int)(collection.Cash_Collected_50000P), P20000 = (int)(collection.Cash_Collected_20000P), P10000 = (int)(collection.Cash_Collected_10000P), P5000 = (int)(collection.Cash_Collected_5000P), P2000 = (int)(collection.Cash_Collected_2000p), P1000 = (int)(collection.Cash_Collected_1000P), P500 = (int)(collection.Cash_Collected_500P), P200 = (int)(collection.Cash_Collected_200P), P100 = (int)(collection.Cash_Collected_100P), P50 = (decimal)(collection.Cash_Collected_50p), P20 = (decimal)(collection.Cash_Collected_20p), P10 = (decimal)(collection.Cash_Collected_10p), P5 = (decimal)(collection.Cash_Collected_5p), P2 = (decimal)(collection.Cash_Collected_2p), P1 = (decimal)(collection.Cash_Collected_1p), EFTInValue = EftIn / 100, EFTOutValue = EFTOut / 100, Installation_Token_Value = (int)collection.Installation_Token_Value, Collection_Batch_Name=Coll_Batch_Name }; if (collection.Zone_No == null || collection.Zone_No == 0) undeclaredCollectionRecord.Zone = "N/A"; else undeclaredCollectionRecord.Zone = collection.Zone_Name; if (collection.Collection_Defloat_Collection == null || collection.Collection_Defloat_Collection == false) { undeclaredCollectionRecord.BackColor = "Red"; undeclaredCollectionRecord.Type = "Full"; } else { undeclaredCollectionRecord.BackColor = "Blue"; undeclaredCollectionRecord.Type = "Defloat"; } //if (regionSettingValue.ToUpper().Contains("US")) undeclaredCollectionRecord.Region = Settings.Region;//"US"; if (isAutodeclaration.ToUpper() == "TRUE") { //Added by Anil to fix CR 88038 shortpay = Convert.ToDecimal(collection.ShortPay); handpay = Convert.ToDecimal(collection.Handpay); refund = Convert.ToDecimal(collection.Refunds); refill = Convert.ToDecimal(collection.Refills); jackpot = Convert.ToDecimal(collection.HandpayJackpot); AttendantPay = Convert.ToDecimal(collection.AttendantPay); //shortpay = 0; //handpay = Convert.ToDecimal(collection.DeclaredHandpay); //refund = 0; //refill = 0; //jackpot = 0; sumOfshortpay += shortpay; sumOfhandpay += handpay; sumOfrefill += refill; sumOfrefund += refund; sumOfjackpot += jackpot; sumOfAttendantPay += AttendantPay; undeclaredCollectionRecord.ShortPayValue = shortpay; undeclaredCollectionRecord.HandpayValue = handpay; undeclaredCollectionRecord.RefundValue = refund; undeclaredCollectionRecord.RefillsValue = refill; undeclaredCollectionRecord.JackpotValue = jackpot; undeclaredCollectionRecord.AttendantPayValue = AttendantPay ; } else { shortpay = Convert.ToDecimal(collection.ShortPay); handpay = Convert.ToDecimal(collection.Handpay); refund = Convert.ToDecimal(collection.Refunds); refill = Convert.ToDecimal(collection.Refills); jackpot = Convert.ToDecimal(collection.HandpayJackpot); AttendantPay = Convert.ToDecimal(collection.AttendantPay); //durga // AttendantPay = Convert.ToDecimal(collection.AttendantPay) + Convert.ToDecimal(collection.HandpayJackpot); sumOfshortpay += shortpay; sumOfhandpay += handpay; sumOfrefill += refill; sumOfrefund += refund; sumOfjackpot += jackpot; sumOfAttendantPay += AttendantPay; undeclaredCollectionRecord.ShortPayValue = shortpay; undeclaredCollectionRecord.HandpayValue = handpay; undeclaredCollectionRecord.RefundValue = refund; undeclaredCollectionRecord.RefillsValue = refill; undeclaredCollectionRecord.JackpotValue = jackpot; undeclaredCollectionRecord.AttendantPayValue = AttendantPay; } //Reset shortpay only if addshortpayvoucher is set shortpay = Settings.AddShortpayInVoucherOut ? 0 : shortpay; //Deducted Coin out from total in for WinLoss Calculation winloss = (undeclaredCollectionRecord.TotalCoinsValue + undeclaredCollectionRecord.TotalBillValue + ticketsIn - CoinOut - ticketsOut - handpay - shortpay - refill - refund - jackpot); sumOfWinloss += winloss; undeclaredCollectionRecord.WinLossValue = winloss; undeclaredCollectionRecords.Add(undeclaredCollectionRecord); } if (undeclaredCollectionRecords.Count == 0) return null; var uc = (from collectionRecord in undeclaredCollectionRecords group collectionRecord by collectionRecord.Region into collectiongroup select new UndeclaredCollectionRecord { // Added bool to handle sort in datagrid IsTotalRow=true, Zone = "Total", BackColor = "Blue", AssetNo = "", CollectionDate = DateTime.MinValue, CollectionTime = DateTime.MinValue, GameTitle = "", HandpayValue = sumOfhandpay, P1 = collectiongroup.Sum(c => c.P1), P2 = collectiongroup.Sum(c => c.P2), P5 = collectiongroup.Sum(c => c.P5), P10 = collectiongroup.Sum(c => c.P10), P20 = collectiongroup.Sum(c => c.P20), P50 = collectiongroup.Sum(c => c.P50), P100 = collectiongroup.Sum(c => c.P100), P200 = collectiongroup.Sum(c => c.P200), P500 = collectiongroup.Sum(c => c.P500), P1000 = collectiongroup.Sum(c => c.P1000), P2000 = collectiongroup.Sum(c => c.P2000), P5000 = collectiongroup.Sum(c => c.P5000), P10000 = collectiongroup.Sum(c => c.P10000), P20000 = collectiongroup.Sum(c => c.P20000), P50000 = collectiongroup.Sum(c => c.P50000), P100000 = collectiongroup.Sum(c => c.P100000), JackpotValue = sumOfjackpot, Meters = "", Position = "", RefillsValue = sumOfrefill, RefundValue = sumOfrefund, ShortPayValue = sumOfshortpay, TicketsInValue = sumOfticketsIn, TicketsOutValue = sumOfticketsOut, EFTInValue = sumOfEftin, EFTOutValue = sumOfEftout, CoinOutValue = sumOfCoinOut, CoinInValue = sumOfCoinIn, AttendantPayValue = sumOfAttendantPay, Type = "Total", WinLossValue = sumOfWinloss, Region = regionSettingValue.ToUpper().Contains("US") ? "US" : "IT", Collection_Batch_Name = Coll_Batch_Name }).FirstOrDefault(); var returnCollection = new List<UndeclaredCollectionRecord> { uc }; returnCollection.AddRange(undeclaredCollectionRecords); return returnCollection; } catch (Exception ex) { ExceptionManager.Publish(ex); return null; } }
public bool SaveFullCollection(UndeclaredCollectionRecord undeclaredCollectionRecord, int userId) { var collectionType = undeclaredCollectionRecord.Type == "Defloat" ? "DC" : "FC"; if (InsertCollectionDeclaration(collectionType, undeclaredCollectionRecord.InstallationNo, undeclaredCollectionRecord.CollectionNo, userId, undeclaredCollectionRecord.TotalAmountValue > 0 ? true : false, false, false, 0.175, false, undeclaredCollectionRecord.TotalCoinsValue, 0, 0, undeclaredCollectionRecord.HandpayValue, 0, 0, 0, 0, 0, 0, 0, undeclaredCollectionRecord.P1, undeclaredCollectionRecord.P2, undeclaredCollectionRecord.P5, undeclaredCollectionRecord.P10, undeclaredCollectionRecord.P20, undeclaredCollectionRecord.P50, undeclaredCollectionRecord.P100, undeclaredCollectionRecord.P200, undeclaredCollectionRecord.P500, undeclaredCollectionRecord.P1000, undeclaredCollectionRecord.P2000, undeclaredCollectionRecord.P5000, undeclaredCollectionRecord.P10000, undeclaredCollectionRecord.P20000, undeclaredCollectionRecord.P50000, undeclaredCollectionRecord.P100000, undeclaredCollectionRecord.TicketsInValue, 0, 0, 0, 0, 0, 0, 0, 0, 0) == 0) { LogManager.WriteLog("InsertCollectonDeclaration", LogManager.enumLogLevel.Info); var lockHelper = new LockHandler(exchangeConnectionString); lockHelper.DeleteLockRecord(userId, Dns.GetHostName(), "COLLECT", "INST", undeclaredCollectionRecord.InstallationNo.ToString()); return true; } return false; }