/// <summary> /// Suspend Sale /// </summary> /// <param name="tillNumber">Till number</param> /// <param name="saleNumber">Sale number</param> /// <param name="userCode">User code</param> /// <param name="errorMessage">Error</param> /// <returns>Sale</returns> public Sale SuspendSale(int tillNumber, int saleNumber, string userCode, out ErrorMessage errorMessage) { var dateStart = DateTime.Now; Performancelog.Debug($"Start,SuspendedSaleManager,SuspendSale,{string.Empty},{dateStart:hh.mm.ss.ffffff}"); if (!CanUserSuspendSale(userCode, out errorMessage)) { return(new Sale()); } var sale = _saleManager.GetCurrentSale(saleNumber, tillNumber, 0, userCode, out errorMessage); var offSet = _policyManager.LoadStoreInfo().OffSet; if (!string.IsNullOrEmpty(errorMessage.MessageStyle.Message)) { return(null); } //Added for checking delete prepay crash recovery if (sale.DeletePrepay) { //Please complete delete prepay first!~Comlete current transaction. errorMessage = new ErrorMessage { MessageStyle = _resourceManager.CreateMessage(offSet, 11, 50, null), StatusCode = HttpStatusCode.PreconditionFailed }; return(null); } if (sale.Sale_Lines.Count == 0 && !_policyManager.SUSPEND_MT) { errorMessage = new ErrorMessage { MessageStyle = _resourceManager.CreateMessage(offSet, 11, 80, null, MessageType.OkOnly), StatusCode = HttpStatusCode.BadRequest }; return(null); } //Added checking not allowing suspend sale with prepay if (_prepayManager.PrepayItemId(ref sale) > 0) { //MsgBox ("Cannot suspend sale with prepay, Please remove the prepay sale before suspend!~Suspend a Sale.") errorMessage = new ErrorMessage { MessageStyle = _resourceManager.CreateMessage(offSet, 11, 57, null, CriticalOkMessageType), StatusCode = HttpStatusCode.BadRequest }; return(null); } var sharePolicy = _policyManager.SHARE_SUSP; _suspendedSaleService.SuspendSale("SUSPEND", sharePolicy, sale, userCode); CacheManager.DeleteCurrentSaleForTill(sale.TillNumber, sale.Sale_Num); sale = _saleManager.InitializeSale(tillNumber, sale.Register, userCode, out errorMessage); //Update Sale object in Cache CacheManager.AddCurrentSaleForTill(sale.TillNumber, sale.Sale_Num, sale); Performancelog.Debug($"End,SuspendedSaleManager,SuspendSale,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}"); return(sale); }
/// <summary> /// Method to update the tenders selected /// </summary> /// <param name="tenders">Tenders</param> /// <param name="saleNumber">Sale number</param> /// <param name="tillNumber">Till number</param> /// <param name="userCode">User code</param> /// <param name="reason">Reason code</param> /// <param name="errorMessage">Error Message</param> /// <returns></returns> public Tenders UpdateCashDropTendered(List <Tender> tenders, string reason, int saleNumber, int tillNumber, string userCode, out ErrorMessage errorMessage) { var dateStart = DateTime.Now; _performancelog.Debug($"Start,CashManager,UpdateCashDropTendered,{string.Empty},{dateStart:hh.mm.ss.ffffff}"); errorMessage = new ErrorMessage(); if (!IsValidReason(reason)) { errorMessage.MessageStyle = new MessageStyle { Message = "Invalid reason" }; errorMessage.StatusCode = System.Net.HttpStatusCode.NotFound; return(null); } var allTenders = _tenderManager.Load(null, "CashDrop", false, reason, out errorMessage); var sale = _saleManager.GetCurrentSale(saleNumber, tillNumber, 0, userCode, out errorMessage); decimal saleTotals = 0; if (sale != null) { saleTotals = sale.Sale_Totals.Gross; } var cashDropTenders = GetCashDropTenders(tenders, allTenders, saleTotals, out errorMessage); _performancelog.Debug($"End,CashManager,UpdateCashDropTendered,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}"); return(cashDropTenders); }
public HttpResponseMessage CheckResponse(bool response, int tillNumber, byte registerNumber, int saleNumber) { ErrorMessage errorMessage; string userCode; HttpResponseMessage httpResponseMessage; var dateStart = DateTime.Now; _performancelog.Debug($"Start,KickBackController,CheckResponse,{string.Empty},{dateStart:hh.mm.ss.ffffff}"); if (GetUserCode(out userCode, out httpResponseMessage)) { return(httpResponseMessage); } var result = false; //var sale = CacheManager.GetCurrentSaleForTill(tillNumber, saleNumber); sale = _saleManager.GetCurrentSale(saleNumber, tillNumber, registerNumber, userCode, out errorMessage); var points = _kickBackManager.CheckKickbackResponse(response, tillNumber, saleNumber, userCode, out errorMessage, ref sale); if (points != 0) { sale.Customer.Points_Redeemed = points; _performancelog.Debug($"End,KickBackController,CheckResponse,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}"); result = true; } if (!string.IsNullOrEmpty(errorMessage?.MessageStyle?.Message)) { return(Request.CreateResponse(errorMessage.StatusCode, new ErrorResponse { Error = errorMessage.MessageStyle } )); } _performancelog.Debug($"End,KickBackController,CheckResponse,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}"); return(Request.CreateResponse(HttpStatusCode.OK, new SuccessReponse { Success = result })); }
/// <summary> /// Adjust Givex Card with the new amount /// </summary> /// <param name="givexCardNumber">givexCardNumber</param> /// <param name="amount">amount</param> /// <param name="userCode">userCode</param> /// <param name="tillNumber">tillNumber</param> /// <param name="saleNumber">saleNumber</param> /// <param name="stockCode">stockCode</param> /// <param name="givexReceipt"></param> /// <param name="errorMessage">errorMessage</param> /// <returns>Sale</returns> public Sale AdjustGivexCard(string givexCardNumber, decimal amount, string userCode, int tillNumber, int saleNumber, string stockCode, out Report givexReceipt, out ErrorMessage errorMessage) { var dateStart = DateTime.Now; Performancelog.Debug($"Start,GivexManager,AdjustGivexCard,{string.Empty},{DateTime.Now:hh.mm.ss.ffffff}"); decimal newBalance = 0; var refNum = ""; var expDate = ""; string result = ""; givexReceipt = null; var newLine = _saleLineManager.CreateNewSaleLine(); var sale = new Sale(); GiveXReceiptType givexReceiptType; if (!IsValidPrice(2, amount, out errorMessage)) { return(null); } if (_givexClientManager.AdjustGiveX(givexCardNumber, amount, saleNumber, ref newBalance, ref refNum, ref expDate, ref result, userCode, out errorMessage, out givexReceiptType)) { givexReceipt = _receiptManager.Print_GiveX_Receipt(givexReceiptType); sale = _saleManager.GetCurrentSale(saleNumber, tillNumber, 0, userCode, out errorMessage); if (string.IsNullOrEmpty(errorMessage.MessageStyle.Message)) { _saleLineManager.SetPluCode(ref sale, ref newLine, stockCode, out errorMessage); if (string.IsNullOrEmpty(errorMessage.MessageStyle.Message)) { newLine.Line_Num = (short)(sale.Sale_Lines.Count + 1); newLine.Regular_Price = Conversion.Val(amount); _saleLineManager.SetPrice(ref newLine, Conversion.Val(amount)); newLine.Gift_Num = givexCardNumber.Trim(); _saleManager.Add_a_Line(ref sale, newLine, userCode, tillNumber, out errorMessage, true); //Update Sale object in Cache CacheManager.AddCurrentSaleForTill(tillNumber, saleNumber, sale); } } } Performancelog.Debug($"End,GivexManager,AdjustGivexCard,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}"); return(sale); }
public tePurchaseList GetPurchaseList(int saleNumber, int tillNumber, string userCode, string treatyNumber, string treatyName, out ErrorMessage error) { var sale = _saleManager.GetCurrentSale(saleNumber, tillNumber, 0, userCode, out error); var oTreatyNo = new teTreatyNo() { TreatyNumber = treatyNumber, Name = treatyName }; var offSet = _policyManager.LoadStoreInfo().OffSet; double originalPrice = 0; double taxIncldAmount = 0; sale.TreatyNumber = oTreatyNo.TreatyNumber; sale.TreatyName = oTreatyNo.Name; error = null; var oPurchaseList = new tePurchaseList(); oPurchaseList.Init(oTreatyNo, sale.Sale_Num, sale.TillNumber); var y = oPurchaseList.GetTreatyNo(); foreach (Sale_Line tempLoopVarSl in sale.Sale_Lines) { var sl = tempLoopVarSl; string strError; if (sl.Amount < 0 && sl.IsTaxExemptItem) { taxIncldAmount = -1 * sl.TaxInclPrice; //shiny - Dec9, 2009 - Squamish nation // OriginalPrice = sl.Regular_Price if (_policyManager.TE_ByRate == false) // Regualr Site customers SITE , TE_By rate = no { originalPrice = sl.Regular_Price; // - editing the price for TE is keeping different price in purchaseitem and saleline'SL.price } else if (_policyManager.TE_ByRate) //squamish SITE , TE_By rate = yes { originalPrice = sl.price; } } else { //shiny - Dec9, 2009 - Squamish nation // OriginalPrice = sl.Regular_Price if (_policyManager.TE_ByRate == false) // Regualr Site customers SITE , TE_By rate = no { originalPrice = sl.Regular_Price; // - editing the price for TE is keeping different price in purchaseitem and saleline'SL.price } else if (_policyManager.TE_ByRate) //squamish SITE , TE_By rate = yes { originalPrice = sl.price; } } if (sl.ProductIsFuel && !sl.IsPropane) { if (_policyManager.USE_FUEL) { if (Variables.gPumps == null) { Variables.gPumps = _fuelPumpService.InitializeGetProperty(PosId, _policyManager.TAX_EXEMPT, _policyManager.TE_ByRate, _policyManager.TE_Type, _policyManager.AuthPumpPOS); } string tempSProductKey = _teSystemManager.TeMakeFuelKey(sl.GradeID, Convert.ToInt16(Variables.gPumps.get_Pump(sl.pumpID).TierID), Convert.ToInt16(Variables.gPumps.get_Pump(sl.pumpID).LevelID)); double tempDQuantity = sl.Quantity; var tempIRowNumberInSalesMainForm = sl.Line_Num; bool tempIsFuelItem = true; string tempStockCode = sl.Stock_Code; if (!AddItem(ref oPurchaseList, ref sale, ref oTreatyNo, ref tempSProductKey, ref tempDQuantity, ref originalPrice, ref tempIRowNumberInSalesMainForm, ref tempStockCode, ref taxIncldAmount, ref tempIsFuelItem)) { strError = oPurchaseList.GetLastError(); if (strError == "2") { //MsgBox ("Cannot load Tax Exempt price, Please set Tax Exempt Category for Grade-" & SL.GradeID & " first in the BackOffice system! ") //_resourceManager.CreateMessage(offSet,this, 17, temp_VbStyle, sl.GradeID, 0); error = new ErrorMessage { MessageStyle = _resourceManager.CreateMessage(offSet, 11, 17, sl.GradeID, CriticalOkMessageType), StatusCode = HttpStatusCode.Conflict }; return(null); } if (!string.IsNullOrEmpty(strError) && strError.ToUpper() != "NO ERROR") { //MsgBox ("Error(" & strError & ") for getting Tax Exempt price, will use original price for this sale!") //_resourceManager.CreateMessage(offSet,this, 18, temp_VbStyle2, strError, 0); error = new ErrorMessage { MessageStyle = _resourceManager.CreateMessage(offSet, 11, 18, strError, CriticalOkMessageType), StatusCode = HttpStatusCode.Conflict }; return(null); } break; } } else { var tempSProductKey2 = sl.Stock_Code; double tempDQuantity2 = sl.Quantity; var tempIRowNumberInSalesMainForm2 = sl.Line_Num; bool tempIsFuelItem2 = false; var tempStockCode = sl.Stock_Code; if (!AddItem(ref oPurchaseList, ref sale, ref oTreatyNo, ref tempSProductKey2, ref tempDQuantity2, ref originalPrice, ref tempIRowNumberInSalesMainForm2, ref tempStockCode, ref taxIncldAmount, ref tempIsFuelItem2)) { strError = oPurchaseList.GetLastError(); if (!string.IsNullOrEmpty(strError) && strError.ToUpper() != "NO ERROR") { //_resourceManager.CreateMessage(offSet,this, 18, temp_VbStyle3, strError, 0); error = new ErrorMessage { MessageStyle = _resourceManager.CreateMessage(offSet, 11, 18, strError, CriticalOkMessageType), StatusCode = HttpStatusCode.Conflict }; return(null); } } } } else { var tempSProductKey3 = sl.Stock_Code; double tempDQuantity3 = sl.Quantity; short tempIRowNumberInSalesMainForm3 = sl.Line_Num; bool tempIsFuelItem3 = false; var tempStockCode = sl.Stock_Code; if (!AddItem(ref oPurchaseList, ref sale, ref oTreatyNo, ref tempSProductKey3, ref tempDQuantity3, ref originalPrice, ref tempIRowNumberInSalesMainForm3, ref tempStockCode, ref taxIncldAmount, ref tempIsFuelItem3)) { strError = oPurchaseList.GetLastError(); if (!string.IsNullOrEmpty(strError) && strError.ToUpper() != "NO ERROR") { //_resourceManager.CreateMessage(offSet,this, 18, temp_VbStyle4, strError, 0); error = new ErrorMessage { MessageStyle = _resourceManager.CreateMessage(offSet, 11, 18, strError, CriticalOkMessageType), StatusCode = HttpStatusCode.Conflict }; return(null); } } } } var x = oPurchaseList.GetTreatyNo(); CacheManager.AddPurchaseListSaleForTill(tillNumber, saleNumber, oPurchaseList); return(oPurchaseList); }
public double CheckBalance(string pointCardNum, int saleNumber, int tillNumber, string userCode, out ErrorMessage errorMessage) { var sale = _saleManager.GetCurrentSale(saleNumber, tillNumber, 1, userCode, out errorMessage); short pos = 0; short posqm = 0; bool boolIsPhoneNumber = false; string PointCardNumber = ""; if (pointCardNum.Trim().Length > 0) { sale.STFDNumber = pointCardNum; // Chaps_Main.DisplayMsgForm(Policy_Renamed.LoyaltyMesg, (short)15, null, (byte)0, (byte)0, "", "", "", ""); if (!string.IsNullOrEmpty(sale.STFDNumber)) { if (string.IsNullOrEmpty(sale.STFDNumber)) { return(0); } boolIsPhoneNumber = true; // May 26, 2009: Nicolette changed to fix the crash for track1 being enabled // look for "?" after the ";" to consider only track2. If any of ";" or "?" // are not found, system assumes that is a phone number pos = (short)(sale.STFDNumber.IndexOf(";") + 1); // posqm = InStr(1, InputValue, "?") ' May 26, 2009: Nicolette see comment if (pos > 0) { //posqm = (short)(pos.ToString().IndexOf(sale.STFDNumber) + 1); posqm = (short)(sale.STFDNumber.ToString().IndexOf("?") + 1); } else { posqm = (short)0; PointCardNumber = sale.STFDNumber; } if (posqm > 0 & pos > 0) { boolIsPhoneNumber = false; pos = (short)(sale.STFDNumber.IndexOf(";") + 1); // If pos < 0 Then Exit Sub ' May 26, 2009: Nicolette see comment PointCardNumber = sale.STFDNumber.Substring(pos + 1 - 1, posqm - pos - 1); } // CacheManager.GetCurrentSaleForTill.mvrCustomer.Set_Customer_KickBack_Data(Variables.STFDNumber); _kickBackService.Set_Customer_KickBack_Data(sale.STFDNumber, boolIsPhoneNumber, PointCardNumber, ref sale); if (string.IsNullOrEmpty(sale.Customer.CustomerCardNum)) { _kickBackService.Set_Customer_KickBack_Data(sale.STFDNumber, !boolIsPhoneNumber, PointCardNumber, ref sale); } sale.STFDNumber = ""; //reset STFDNumber } else { pointCardNum = ""; errorMessage.MessageStyle = new MessageStyle { Message = Utilities.Constants.CheckKickbackBalance, }; errorMessage.StatusCode = HttpStatusCode.NotFound; return(-1); } } if (sale.Customer.PointCardNum != "") { var kickBackResponse = ProcessKickBack((short)2, userCode, ref sale, out errorMessage); if (!kickBackResponse) { if (!string.IsNullOrEmpty(errorMessage?.MessageStyle?.Message)) { errorMessage.MessageStyle = new MessageStyle { Message = errorMessage.MessageStyle.Message, }; errorMessage.StatusCode = HttpStatusCode.NotFound; } return(-1); } } WriteUDPData(DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss tt") + "Inside checkbalance 132 cardno value" + sale.Customer.PointCardNum); CacheManager.AddCurrentSaleForTill(saleNumber, tillNumber, sale); return(sale.Customer.Balance_Points); }
/// <summary> /// Method to close batch /// </summary> /// <param name="posId">Pos Id</param> /// <param name="tillNumber">Till number</param> /// <param name="saleNumber">Sale number</param> /// <param name="registerNumber">Register number</param> /// <param name="error">Error message</param> /// <returns>List of report</returns> public List <Report> CloseBatch(byte posId, int tillNumber, int saleNumber, byte registerNumber, out ErrorMessage error) { var reports = new List <Report>(); short termNos = 0; string[,] Terminals = new string[3, 3]; short i = 0; string rFileName = ""; DateTime batchDate = default(DateTime); bool blnNoDebitTrans = false; var emvProcess = _policyManager.EMVVersion; var offSet = _policyManager.LoadStoreInfo().OffSet; var sale = _saleManager.GetCurrentSale(saleNumber, tillNumber, registerNumber, UserCode, out error); if (!string.IsNullOrEmpty(error?.MessageStyle?.Message)) { return(null); } var rFileNumber = (short)(FileSystem.FreeFile()); try { if (GetConnection()) { var terminals = _maintenanceService.GetTerminalIds(posId); if (terminals == null) { WriteToLogFile("***PROBLEM WITH CLOSE BATCH*** " + " " + _resourceManager.GetResString(offSet, 1287)); // Shiny Mar6, 2008 -EKO //MsgBoxStyle temp_VbStyle = (int)MsgBoxStyle.Critical + MsgBoxStyle.OkOnly; //Chaps_Main.DisplayMessage(12, (short)87, temp_VbStyle, null, (byte)0); error = new ErrorMessage { MessageStyle = _resourceManager.CreateMessage(offSet, 12, 87, null, CriticalOkMessageType) }; return(null); } //ButtonsEnabled(false); rFileName = Path.GetTempPath() + "BankEod_ " + PosId + ".txt"; FileSystem.FileOpen(rFileNumber, rFileName, OpenMode.Append); termNos = 0; foreach (Terminal terminal in terminals) { if (string.IsNullOrEmpty(terminal.TerminalType) || string.IsNullOrEmpty(terminal.TerminalId)) { WriteToLogFile("***PROBLEM WITH CLOSE BATCH***" + " " + _resourceManager.GetResString(offSet, 1287)); // Shiny Mar6, 2008 -EKO //MsgBoxStyle temp_VbStyle2 = (int)MsgBoxStyle.Critical + MsgBoxStyle.OkOnly; //Chaps_Main.DisplayMessage(this, (short)87, temp_VbStyle2, null, (byte)0); error = new ErrorMessage { MessageStyle = _resourceManager.CreateMessage(offSet, 12, 87, null, CriticalOkMessageType) }; FileSystem.FileClose(rFileNumber); return(null); } modTPS.cc = new Credit_Card(); WriteToLogFile("EMVprocess:" + Convert.ToString(emvProcess)); SendToTps(_cardManager.GetRequestString(ref modTPS.cc, sale, "EODTerminal", terminal.TerminalType, 0, terminal.TerminalId), ref modTPS.cc, emvProcess); var eodTimer = DateAndTime.Timer; while (Convert.ToInt32(DateAndTime.Timer - Convert.ToDouble(eodTimer)) < 120) // shiny changed this waiting to 2 minutes- 4 is too much 240) { if (modTPS.cc.Response.Length > 0) { break; } } if (modTPS.cc.Response.ToUpper() == "APPROVED") { termNos++; Terminals[termNos, 1] = modTPS.cc.TerminalID; Terminals[termNos, 2] = modTPS.cc.Sequence_Number; FileSystem.PrintLine(rFileNumber, modTPS.cc.Report); batchDate = modTPS.cc.Trans_Date; WriteToLogFile("SUCCESS WITH CLOSE BATCH"); // Shiny Mar6, 2008 -EKO // - added as part of Datawire Integeration (added by Mina) //#:5:TPS does handshake after sending EOD for debit. If there weren’t any debit transactions between closes batches, POS has to send special indication that there weren’t any debit transactions. Having gotten that flag, TPS doesn’t do handshake. if (Strings.UCase(Convert.ToString(_policyManager.BankSystem)) == "GLOBAL") { blnNoDebitTrans = modTPS.cc.Report.IndexOf("No Transactions", StringComparison.Ordinal) + 1 > 0; } _maintenanceService.SetCloseBatchNumber(modTPS.cc); } else // Behrooz Jan-09 { if (modTPS.cc.Receipt_Display.Length > 0) { WriteToLogFile("***PROBLEM WITH CLOSE BATCH***" + " " + modTPS.cc.Receipt_Display); // Shiny Mar6, 2008 -EKO //Chaps_Main.DisplayMsgForm(modTPS.cc.Receipt_Display, (short)100, null, (byte)0, (byte)0, "", "", "", ""); error = new ErrorMessage { MessageStyle = new MessageStyle { Message = modTPS.cc.Receipt_Display, MessageType = MessageType.OkOnly } }; FileSystem.FileClose(rFileNumber); return(null); } else { WriteToLogFile("***PROBLEM WITH CLOSE BATCH***" + " " + _resourceManager.GetResString(offSet, 1284)); // Shiny Mar6, 2008 -EKO //Chaps_Main.DisplayMsgForm((Convert.ToDouble(12)) * 100 + 84, (short)99, null, (byte)0, (byte)0, "", "", "", ""); error = new ErrorMessage { MessageStyle = new MessageStyle { Message = _resourceManager.GetResString(offSet, 1284), MessageType = MessageType.OkOnly } }; FileSystem.FileClose(rFileNumber); return(null); } } modTPS.cc = null; i++; } } else { WriteToLogFile("***PROBLEM WITH CLOSE BATCH***" + " " + _resourceManager.GetResString(offSet, 1296)); // Shiny Mar6, 2008 -EKO //Chaps_Main.DisplayMsgForm((Convert.ToDouble(12)) * 100 + 96, (short)99, null, (byte)0, (byte)0, "", "", "", ""); error = new ErrorMessage { MessageStyle = new MessageStyle { Message = _resourceManager.GetResString(offSet, 1296), MessageType = MessageType.OkOnly } }; //return; } FileSystem.FileClose(rFileNumber); if (!string.IsNullOrEmpty(rFileName)) { var stream = File.OpenRead(rFileName); FileSystem.FileClose(rFileNumber); var bytes = new byte[stream.Length]; stream.Read(bytes, 0, Convert.ToInt32(stream.Length)); stream.Close(); var content = Convert.ToBase64String(bytes); reports.Add(new Report { ReportName = "BankEod.txt", ReportContent = content, Copies = 1 }); } if (termNos == i) { if (GetConnection()) //Nancy { // - Datawire Integration (Added by Mina) //#5: TPS does handshake after sending EOD for debit. If there weren’t any debit transactions between closes batches, POS has to send special indication that there weren’t any debit transactions. Having gotten that flag, TPS doesn’t do handshake. if (Strings.UCase(Convert.ToString(_policyManager.BankSystem)) == "GLOBAL") { if (blnNoDebitTrans) //Added by Mina { SendToTps(_cardManager.GetRequestString(ref modTPS.cc, sale, "CloseBatchInside", "NoDebit", 0, ""), ref modTPS.cc, emvProcess); } else { SendToTps(_cardManager.GetRequestString(ref modTPS.cc, sale, "CloseBatchInside", "Credit", 0, ""), ref modTPS.cc, emvProcess); } } else { SendToTps(_cardManager.GetRequestString(ref modTPS.cc, sale, "CloseBatchInside", "Credit", 0, ""), ref modTPS.cc, emvProcess); } } else { return(null); //Call DisplayMsgForm(Me.Tag * 100 + 96, 99) } } if (termNos > 0) { //modPrint.Dump_To_Printer(RFileName, (short)1, true, true, false); //FileStream fs = new FileStream(RFileName, FileMode.Open, FileAccess.Read); var date = DateTime.Parse("12:00:00 AM"); var eodReport = _tillCloseManager.PrintEodDetails(tillNumber, ref date, ref date, Terminals[1, 1], Terminals[1, 2], Terminals[2, 1], Terminals[2, 2], false, batchDate); reports.Add(eodReport); } return(reports); } finally { if (!string.IsNullOrEmpty(rFileName)) { FileSystem.Kill(rFileName); } } }
/// <summary> /// Method to add propane sale /// </summary> /// <param name="gradeId">Grade Id</param> /// <param name="pumpId">Pump Id</param> /// <param name="saleNumber">Sale number</param> /// <param name="tillNumber">Till number</param> /// <param name="registerNumber">Register number</param> /// <param name="isAmount">Is amount</param> /// <param name="propaneValue">Propane value</param> /// <param name="error">Error message</param> /// <returns>Sale</returns> public Sale AddPropaneSale(int gradeId, int pumpId, int saleNumber, int tillNumber, byte registerNumber, bool isAmount, decimal propaneValue, out ErrorMessage error) { var sale = _saleManager.GetCurrentSale(saleNumber, tillNumber, registerNumber, UserCode, out error); var offSet = _policyManager.LoadStoreInfo().OffSet; if (!string.IsNullOrEmpty(error?.MessageStyle?.Message)) { return(null); } var grades = CacheManager.GetPropaneGrades(); if (grades == null) { error = new ErrorMessage { MessageStyle = _resourceManager.CreateMessage(offSet, 38, 76, null) }; return(null); } var firstOrdDefault = grades.FirstOrDefault(p => p.Id == gradeId); if (firstOrdDefault == null) { error = new ErrorMessage { MessageStyle = new MessageStyle { Message = "Invalid Request", MessageType = MessageType.Critical } }; return(null); } var pumps = _fuelPumpService.GetPumpsByPropaneGradeId(gradeId); if (pumps == null || !pumps.Any(p => p.Id == pumpId)) { error = new ErrorMessage { MessageStyle = new MessageStyle { Message = "Invalid Request", MessageType = MessageType.Critical } }; return(null); } var stockCode = firstOrdDefault.StockCode; if (sale.DeletePrepay) { // "There's no Pump set for " & Stock_Code(index) & ". Please set it in Fuel Control at first.", vbinformation+vbokonly error = new ErrorMessage { MessageStyle = _resourceManager.CreateMessage(offSet, 0, 1150, null, InformationOkMessageType) }; return(null); } var slProp = new Sale_Line(); _saleLineManager.SetPluCode(ref sale, ref slProp, stockCode, out error); slProp.GradeID = (byte)gradeId; if (slProp.Regular_Price == 0) { // "There's no price for " & Stock_Code(Index) & ". Please set it in BackOffice at first.", vbInformation + vbOKOnly //MsgBoxStyle temp_VbStyle = (int)MsgBoxStyle.Information + MsgBoxStyle.OkOnly; //Chaps_Main.DisplayMessage(this, (short)11, temp_VbStyle, Stock_Code[Index], (byte)0); error = new ErrorMessage { MessageStyle = _resourceManager.CreateMessage(offSet, 48, 11, stockCode, InformationOkMessageType) }; return(null); } slProp.pumpID = (byte)pumpId; slProp.PositionID = (byte)_fuelPumpService.GetPositionId(pumpId, gradeId); SetQuantity(ref slProp, isAmount, propaneValue, out error); if (!string.IsNullOrEmpty(error?.MessageStyle?.Message)) { return(null); } if (_policyManager.USE_CUST) { if (_policyManager.USE_LOYALTY && Strings.UCase(System.Convert.ToString(_policyManager.LOYAL_TYPE)) == "PRICES" && sale.Customer.Loyalty_Code.Length > 0 && sale.Customer.CL_Status == "A" && (!slProp.LOY_EXCLUDE)) { var loyalPricecode = System.Convert.ToInt16(_policyManager.LOYAL_PRICE); if (loyalPricecode > 0) { _saleLineManager.SetPriceNumber(ref slProp, loyalPricecode); } else { _saleLineManager.SetPriceNumber(ref slProp, sale.Customer.Price_Code != 0 ? sale.Customer.Price_Code : (short)1); } } else { _saleLineManager.SetPriceNumber(ref slProp, sale.Customer.Price_Code != 0 ? sale.Customer.Price_Code : (short)1); } } else { //SL_Prop.Price_Number = (short)1; _saleLineManager.SetPriceNumber(ref slProp, (short)1); } _saleManager.Add_a_Line(ref sale, slProp, UserCode, sale.TillNumber, out error, true); CacheManager.AddCurrentSaleForTill(tillNumber, saleNumber, sale); return(sale); }
/// <summary> /// Method to save vendor payout /// </summary> /// <param name="po">Payout</param> /// <param name="tillNumber">Till number</param> /// <param name="userCode">User code</param> /// <param name="registerNumber">Register number</param> /// <param name="taxes">Taxes</param> /// <param name="openDrawer">Open cash drawer</param> /// <param name="error">Error message</param> /// <returns>Report</returns> public Report SaveVendorPayout(Payout po, int tillNumber, string userCode, byte registerNumber, List <Tax> taxes, out bool openDrawer, out ErrorMessage error) { openDrawer = false; var sale = _saleManager.GetCurrentSale(po.Sale_Num, tillNumber, 0, userCode, out error); var offSet = _policyManager.LoadStoreInfo().OffSet; if (!string.IsNullOrEmpty(error.MessageStyle.Message)) { return(null); } if (!_policyManager.DO_PAYOUTS || (sale != null && sale.Sale_Lines.Count > 0)) { MessageType temp_VbStyle8 = (int)MessageType.Exclamation + MessageType.OkOnly; error.MessageStyle = _resourceManager.CreateMessage(offSet, 38, 54, null, temp_VbStyle8); return(null); } if (po.Gross > (decimal)214748.3647) { error = new ErrorMessage { MessageStyle = new MessageStyle { Message = "Maximum payout amount is 214748.3647" } }; return(null); } var salePo = new Sale(); var tendPo = new Tenders(); var curr = Convert.ToString(_policyManager.BASECURR); if (string.IsNullOrEmpty(curr)) { MessageType temp_VbStyle = (int)MessageType.OkOnly + MessageType.Critical; error.MessageStyle = _resourceManager.CreateMessage(offSet, 23, 94, null, temp_VbStyle); return(null); } var poTaxes = _taxService.GetAllTaxes(); float sumTaxes = 0; foreach (var tax in taxes) { if (poTaxes.Any(p => p.TaxName == tax.Code)) { po.Payout_Taxes.Add(tax.Code, "", tax.Amount, true, tax.Code); salePo.Sale_Totals.Sale_Taxes.Add(tax.Code, "I", 0, 0, 0, tax.Amount, po.Gross, 0, 0, ""); sumTaxes = (float)(sumTaxes + Conversion.Val(tax.Amount)); } else { MessageType temp_VbStyle8 = (int)MessageType.Exclamation + MessageType.OkOnly; error.MessageStyle = new MessageStyle { Message = "Invalid tax entered", MessageType = temp_VbStyle8 }; return(null); } } if (!string.IsNullOrEmpty(po.Vendor.Code)) { po.Vendor = _stockService.GetVendorByCode(po.Vendor.Code); if (po.Vendor.Code == null) { MessageType temp_VbStyle2 = (int)MessageType.Critical + MessageType.OkOnly; error.MessageStyle = new MessageStyle { Message = "Invalid vendor code", MessageType = temp_VbStyle2 }; return(null); } } // Nicoolette changed next line on Nov 13,2007 to allow negative payouts, based on Mr. Gas requirement if (po.Gross == 0) { // If PO.Gross <= 0 Then //You must specify the Payout Amount, vbCritical + vbOKOnly MessageType temp_VbStyle2 = (int)MessageType.Critical + MessageType.OkOnly; error.MessageStyle = _resourceManager.CreateMessage(offSet, 23, 91, null, temp_VbStyle2); return(null); } if (_policyManager.PO_REASON) { po.Return_Reason = _reasonService.GetReturnReason(po.Return_Reason.Reason, (char)ReasonType.Payouts); if (po.Return_Reason == null) { MessageType temp_VbStyle2 = (int)MessageType.Critical + MessageType.OkOnly; error.MessageStyle = _resourceManager.CreateMessage(offSet, 23, 92, null, temp_VbStyle2); return(null); } salePo.Return_Reason = po.Return_Reason; } var till = _tillService.GetTill(tillNumber); till.Cash = till.Cash - po.Gross; _tillService.UpdateTill(till); if (_policyManager.OPEN_DRAWER == "Every Sale") { openDrawer = true; } tendPo.Add(curr, "Cash", 1, true, true, false, 1, curr, false, 0, 0, 0.01, true, Convert.ToDouble((object)-po.Gross), 1, true, false, "", ""); _tenderManager.Set_Amount_Entered(ref tendPo, ref salePo, tendPo[1], -po.Gross, -1); // payout if (_policyManager.PENNY_ADJ && po.Gross != 0) { salePo.Sale_Totals.Penny_Adj = modGlobalFunctions.Calculate_Penny_Adj(po.Gross); } else { salePo.Sale_Totals.Penny_Adj = 0; } po.Penny_Adj = salePo.Sale_Totals.Penny_Adj; // end salePo.Sale_Totals.Net = po.Gross; // - Sum_Taxes Nicolette commented out, // once for payout all taxes are included, don't subtract the taxes, // this will afect Sale_Amt in SaleHead, March 07, 2003 var saleTotals = salePo.Sale_Totals; _saleManager.SetGross(ref saleTotals, salePo.Sale_Totals.Net); salePo.Sale_Totals.Gross = saleTotals.Gross; salePo.Sale_Totals.TotalLabel = saleTotals.TotalLabel; salePo.Sale_Totals.SummaryLabel = saleTotals.SummaryLabel; salePo.Register = Convert.ToByte(registerNumber); salePo.Sale_Change = 0; salePo.TillNumber = Convert.ToByte(tillNumber); salePo.Sale_Date = DateTime.Now; salePo.Sale_Tender = 0; salePo.Sale_Totals.PayOut = po.Gross; salePo.Sale_Change = 0; salePo.Sale_Amount = 0; if (po.Sale_Num == 0) { salePo.Sale_Num = _saleManager.GetSaleNo(tillNumber, userCode, out error); } else { salePo.Sale_Num = po.Sale_Num; } po.Penny_Adj = salePo.Sale_Totals.Penny_Adj; // salePo.Sale_Type = "PAYOUT"; salePo.Vendor = po.Vendor.Code; var user = _userService.GetUser(userCode); var stream = _receiptManager.Print_Payout(po, userCode, user.Name, DateTime.Today, salePo.Sale_Date, registerNumber, till); stream.Copies = _policyManager.PayoutReceiptCopies; _saleManager.SaveSale(salePo, userCode, ref tendPo, null); _saleManager.Clear_Sale(salePo, po.Sale_Num, salePo.TillNumber, userCode, "", null, false, false, false, out error); return(stream); }
/// <summary> /// Get Stock Price details /// </summary> /// <param name="stockCode">Stock code</param> /// <param name="tillNumber">Till number</param> /// <param name="saleNumber">Sale number</param> /// <param name="registerNumber">Register number</param> /// <param name="userCode">User code</param> /// <param name="error">Error message</param> /// <returns>Stock price</returns> public StockPriceCheck GetStockPriceDetails(string stockCode, int tillNumber, int saleNumber, byte registerNumber, string userCode, out ErrorMessage error) { StockPriceCheck result = new StockPriceCheck { SpecialPriceTypes = GetSpecialPriceTypes() }; Sale_Line slPrices = new Sale_Line(); string txtCode = stockCode; var offSet = _policyManager.LoadStoreInfo().OffSet; var sale = _saleManager.GetCurrentSale(saleNumber, tillNumber, registerNumber, userCode, out error); if (!string.IsNullOrEmpty(error.MessageStyle.Message)) { return(null); } slPrices.PriceCheck = true; //Stock_Br.Requery ' - To have the latest numbers; form // SLPrices.PLU_Code = cStock; //updated PLU setter _saleLineManager.SetPluCode(ref sale, ref slPrices, stockCode, out error); // - For alternate codes change to the real stock code stockCode = slPrices.Stock_Code; float tePrice = 0; if (!string.IsNullOrEmpty(slPrices.Stock_Code)) { var pd = slPrices.PRICE_DEC; result.IsPriceVisible = true; if ((slPrices.Stock_Type == 'V' || slPrices.Stock_Type == 'O') && !slPrices.ProductIsFuel) { result.IsAvQtyVisible = true; result.AvailableQuantity = slPrices.AvailItems.ToString(CultureInfo.InvariantCulture); } var productTaxExempt = _stockService.GetProductTaxExemptByProductCode(stockCode); if (productTaxExempt != null) { result.TaxExemptPrice = GetTaxFreePrice(stockCode, (float)slPrices.Regular_Price, slPrices.ProductIsFuel, ref tePrice) ? tePrice.ToString(CultureInfo.InvariantCulture) : ""; // // If Policy.TE_Type = "AITE" Then ' Shiny added the if condition we are tracking separate inventory for TE product only for AITE if (_policyManager.TAX_EXEMPT && _policyManager.TAX_EXEMPT && (_policyManager.TE_Type == "AITE" || (_policyManager.TE_Type != "AITE" && _policyManager.TRACK_TEINV))) // - Only for AITE we need to track inventory separately for TE products 'If TaxExempt Then { if ((slPrices.Stock_Type == 'V' || slPrices.Stock_Type == 'O') && !slPrices.ProductIsFuel) { result.TaxExemptAvailable = productTaxExempt.Available.ToString(); } } result.IsTaxExemptVisible = true; } else { result.IsTaxExemptVisible = false; } result.StockCode = stockCode; result.Description = slPrices.Description; result.RegularPriceText = slPrices.Regular_Price.ToString("#,##0." + new string('0', pd)); var intSpPrices = (short)slPrices.SP_Prices.Count; if (intSpPrices != 0) { result.FromDate = (slPrices.SP_Prices[1].FromDate).ToString("MM/dd/yyyy"); if (slPrices.SP_Prices[1].ToDate != System.DateTime.FromOADate(0)) { result.IsToDateVisible = true; result.ToDate = (slPrices.SP_Prices[1].ToDate).ToString("MM/dd/yyyy"); result.IsEndDateChecked = false; } else { result.IsToDateVisible = false; result.IsEndDateChecked = true; } if (slPrices.Price_Units == '$') { result.IsPerDollarChecked = true; } else { result.IsPerPercentageChecked = true; } } // Get the active vendor used to pick the prices and the price type result.VendorId = slPrices.Vendor; result.IsActiveVendorPrice = _stockService.IsActiveVendorPrice(stockCode, result.VendorId); var type = slPrices.Price_Units == '$' ? 1 : 2; SP_Price sp; switch (slPrices.Price_Type) { case 'R': result.PriceTypeText = _resourceManager.CreateCaption(offSet, 3, 39, null, 2); // "R - Regular Price" break; case 'S': result.SalePrice = new SalePriceType { Columns = 1, SalePrices = new List <PriceGrid>() }; result.PriceTypeText = _resourceManager.CreateCaption(offSet, 3, 39, null, 3);// "S - Sale Price" result.SalePrice.ColumnText = _resourceManager.CreateCaption(offSet, 4, 39, null, (short)type); foreach (SP_Price tempLoopVarSp in slPrices.SP_Prices) { sp = tempLoopVarSp; result.SalePrice.SalePrices.Add(new PriceGrid { Column1 = sp.Price.ToString("#,##0." + new string('0', pd)) }); } result.IsAddButtonVisible = false; result.IsRemoveButtonVisible = false; break; case 'F': result.FirstUnitPrice = new FirstUnitPriceType { Columns = 2, FirstUnitPriceGrids = new List <PriceGrid>() }; result.PriceTypeText = _resourceManager.CreateCaption(offSet, 3, 39, null, 4); // "F - First Unit Price" result.FirstUnitPrice.ColumnText = _resourceManager.GetResString(offSet, 230); // Quantity result.FirstUnitPrice.ColumnText2 = _resourceManager.CreateCaption(offSet, 4, 39, null, (short)type); // Prices foreach (SP_Price tempLoopVarSp in slPrices.SP_Prices) { sp = tempLoopVarSp; result.FirstUnitPrice.FirstUnitPriceGrids.Add(new PriceGrid { Column1 = sp.From_Quantity.ToString(CultureInfo.InvariantCulture), Column2 = sp.Price.ToString("#,##0." + new string('0', pd)) }); } result.IsAddButtonVisible = true; result.IsRemoveButtonVisible = true; break; case 'I': result.IncrementalPrice = new IncrementalPriceType { Columns = 3, IncrementalPriceGrids = new List <PriceGrid>() }; result.PriceTypeText = _resourceManager.CreateCaption(offSet, 3, 39, null, 5); // "I - Incremental Price" result.IncrementalPrice.ColumnText = _resourceManager.CreateCaption(offSet, 4, 39, null, 3); //From result.IncrementalPrice.ColumnText2 = _resourceManager.CreateCaption(offSet, 4, 39, null, 4); // To result.IncrementalPrice.ColumnText3 = _resourceManager.CreateCaption(offSet, 4, 39, null, (short)type); // Prices foreach (SP_Price tempLoopVarSp in slPrices.SP_Prices) { sp = tempLoopVarSp; result.IncrementalPrice.IncrementalPriceGrids.Add(new PriceGrid { Column1 = sp.From_Quantity.ToString(CultureInfo.InvariantCulture), Column2 = sp.To_Quantity.ToString(CultureInfo.InvariantCulture), Column3 = sp.Price.ToString("#,##0." + new string('0', pd)) }); } result.IsAddButtonVisible = true; result.IsRemoveButtonVisible = true; break; case 'X': result.XForPrice = new XForPriceType { Columns = 2, XForPriceGrids = new List <PriceGrid>() }; result.PriceTypeText = _resourceManager.CreateCaption(offSet, 3, 39, null, 6); // "X - 'X' for Price" result.XForPrice.ColumnText = _resourceManager.GetResString(offSet, 230); // Quantity result.XForPrice.ColumnText2 = _resourceManager.CreateCaption(offSet, 4, 39, null, (short)type); // Prices foreach (SP_Price tempLoopVarSp in slPrices.SP_Prices) { sp = tempLoopVarSp; result.XForPrice.XForPriceGrids.Add(new PriceGrid { Column1 = sp.From_Quantity.ToString(CultureInfo.InvariantCulture), Column2 = sp.Price.ToString("#,##0." + new string('0', pd)) }); } result.IsAddButtonVisible = true; result.IsRemoveButtonVisible = true; break; } if (slPrices.Group_Price == false && _policyManager.U_CHGPRICE) { result.IsChangePriceEnable = true; } else { result.IsChangePriceEnable = false; } result.RegularPriceText = string.Format(result.RegularPriceText, "#,##0." + new string('0', pd)); Register register = new Register(); _mainManager.SetRegister(ref register, registerNumber); if (register.Customer_Display) { result.CustomerDisplay = _mainManager.DisplayMsgLcd(register, _mainManager.FormatLcdString(register, result.Description, result.RegularPriceText), System.Convert.ToString(intSpPrices != 0 ? _mainManager.FormatLcdString(register, _resourceManager.GetResString(offSet, 362), "") : "")); } // - If sell inactive product policy is true , even if the product is inactive we can sell the same. It is only for inactive for Purchase and ordering) var days = _stockService.IsStockByDayAvailable(slPrices.Stock_Code); if (days.Count != 0) { // processing var dayOfWeek = Convert.ToString(DateAndTime.Weekday(DateAndTime.Today)); if (!days.Contains(dayOfWeek)) { slPrices.Active_StockCode = true; // to avoid inactive stock item message in the main screen, saleLine item is not added to the sale anyway slPrices.Active_DayOfWeek = false; //PM to fix the issue related to Hot Buttons on August 27, 2012 var msg = _resourceManager.CreateMessage(offSet, 0, 8890, txtCode.Trim()); result.Message = msg.Message; result.IsChangePriceEnable = false; // no Else required, if it is found the product can be sold today, continue processing } } else { slPrices.Active_DayOfWeek = true; //PM on August 27, 2012 } if (!slPrices.Active_StockCode || (!slPrices.Active_StockCode && !_policyManager.Sell_Inactive)) { error.MessageStyle = _resourceManager.CreateMessage(offSet, 0, 1141, txtCode.Trim()); error.StatusCode = HttpStatusCode.NotFound; return(null); } if (slPrices.Price_Type == 'R') { result.IsSpecialPricingVisible = false; result.IsAddButtonVisible = false; result.IsRemoveButtonVisible = false; return(result); } result.IsSpecialPricingVisible = true; } else // not a valid stock code { //Chaps_Main.DisplayMessage(this, (short)91, temp_VbStyle2, txtCode.Trim(), (byte)0); error.MessageStyle = _resourceManager.CreateMessage(offSet, 39, 91, txtCode.Trim()); error.StatusCode = HttpStatusCode.NotFound; return(null); } return(result); }