/// <summary> /// Method to get cash draw buttons /// </summary> /// <returns>Cash draw buttons</returns> public CashDrawButton GetCashDrawButtons(string userCode, out ErrorMessage error) { var dateStart = DateTime.Now; _performancelog.Debug($"Start,CashManager,GetCashDrawButtons,{string.Empty},{dateStart:hh.mm.ss.ffffff}"); var offSet = _policyManager.LoadStoreInfo().OffSet; error = new ErrorMessage(); var user = _loginManager.GetExistingUser(userCode); if (!Convert.ToBoolean(_policyManager.GetPol("U_TILLDRAW", user))) { MessageType temp_VbStyle3 = (int)MessageType.Exclamation + MessageType.OkOnly; error.MessageStyle = _resourceManager.CreateMessage(offSet, 38, 56, null, temp_VbStyle3); error.StatusCode = System.Net.HttpStatusCode.Forbidden; _performancelog.Debug($"End,CashManager,GetCashDrawButtons,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}"); return(null); } var cashDrawButton = new CashDrawButton { Coins = _cashService.GetCoins(), Bills = _cashService.GetBills() }; _performancelog.Debug($"End,CashManager,GetCashDrawButtons,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}"); return(cashDrawButton); }
/// <summary> /// Checks Whether User can Suspend or Unsuspend Transaction /// </summary> /// <param name="userCode"></param> /// <param name="errorMessage"></param> /// <returns></returns> private bool CanUserSuspendSale(string userCode, out ErrorMessage errorMessage) { errorMessage = new ErrorMessage(); var user = _loginManager.GetUser(userCode); if (!Convert.ToBoolean(_policyManager.GetPol("U_SUSP", user))) { errorMessage = new ErrorMessage { MessageStyle = new MessageStyle { Message = "You are not authorised to Suspend or Unsuspend the Sale", MessageType = (int)MessageType.Information + MessageType.OkOnly }, StatusCode = HttpStatusCode.Unauthorized }; return(false); } return(true); }
/// <summary> /// Method to add a stock Item /// </summary> /// <param name="userName">UserCode</param> /// <param name="stockItem">Stock Item</param> /// <param name="taxCodes">List of tax codes</param> /// <param name="error">Error message</param> public void AddStockItem(string userName, StockItem stockItem, List <string> taxCodes, out ErrorMessage error) { var dateStart = DateTime.Now; Performancelog.Debug($"Start,StockManager,AddStockItem,{string.Empty},{DateTime.Now:hh.mm.ss.ffffff}"); var offSet = _policyManager.LoadStoreInfo().OffSet; error = new ErrorMessage(); if (!string.IsNullOrEmpty(userName) && _loginManager.GetUser(userName) != null) { //var user = _userService.GetUser(userName); var user = _loginManager.GetUser(userName); var stockCode = stockItem.StockCode; var canAddStock = _policyManager.GetPol("U_AddStock", user); if (!Convert.ToBoolean(canAddStock)) { error.MessageStyle = _resourceManager.CreateMessage(offSet, 39, 91, stockCode, (MessageType)((int)MessageType.Critical + (int)MessageType.OkOnly)); error.StatusCode = HttpStatusCode.NotFound; return; } if (string.IsNullOrEmpty(stockCode)) { error.MessageStyle = new MessageStyle { Message = "Stock code is required", MessageType = MessageType.OkOnly }; error.StatusCode = HttpStatusCode.NotAcceptable; return; } if (string.IsNullOrEmpty(stockItem.Description)) { error.MessageStyle = new MessageStyle { Message = "Description is required", MessageType = MessageType.OkOnly }; error.StatusCode = HttpStatusCode.NotAcceptable; return; } if (Conversion.Val(stockItem.Price) <= 0) { error.MessageStyle = new MessageStyle { Message = "Price should be more than 0", MessageType = MessageType.OkOnly }; error.StatusCode = HttpStatusCode.NotAcceptable; return; } if (SetupTaxes(taxCodes, stockCode) == false) { error.MessageStyle = _resourceManager.CreateMessage(offSet, 39, 96, stockCode, (MessageType)((int)MessageType.Critical + (int)MessageType.OkOnly)); error.StatusCode = HttpStatusCode.Conflict; return; } if (_stockService.GetStockItemByCode(stockCode, true) != null) { error.MessageStyle = _resourceManager.CreateMessage(offSet, 39, 95, stockCode, (MessageType)((int)MessageType.Critical + (int)MessageType.OkOnly)); error.StatusCode = HttpStatusCode.Conflict; return; } if (_stockService.GetPluMast(stockCode) != null) { error.MessageStyle = _resourceManager.CreateMessage(offSet, 39, 95, stockCode, (MessageType)((int)MessageType.Critical + (int)MessageType.OkOnly)); error.StatusCode = HttpStatusCode.Conflict; return; } _stockService.AddStockItem(stockItem, _policyManager.ELG_LOY); _stockService.AddPluMast(stockCode); _stockService.AddStockBranch(stockCode); _stockService.AddStockPrice(stockCode, stockItem.Price); } else { error.MessageStyle = _resourceManager.CreateMessage(offSet, 10, 95, userName, (MessageType)((int)MessageType.Critical + (int)MessageType.OkOnly)); error.StatusCode = HttpStatusCode.Unauthorized; } Performancelog.Debug($"End,StockManager,AddStockItem,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}"); }
/// <summary> /// Save Bottle return /// </summary> /// <param name="brPayment">Br payment</param> /// <param name="userCode">User code</param> /// <param name="error">Error message</param> /// <param name="bottleReport">Report</param> /// <param name="openDrawer">Open drawer or not</param> public Sale SaveBottleReturn(BR_Payment brPayment, out ErrorMessage error, out Report bottleReport, out bool openDrawer) { bottleReport = null; openDrawer = false; var dateStart = DateTime.Now; Performancelog.Debug($"Start,BottleManager,SaveBottleReturn,{string.Empty},{DateTime.Now:hh.mm.ss.ffffff}"); error = new ErrorMessage(); var offSet = _policyManager.LoadStoreInfo().OffSet; var userCode = UserCode; var user = _loginManager.GetExistingUser(userCode); var existingSale = _saleService.GetSaleByTillNumber(brPayment.TillNumber); if (existingSale != null && existingSale.Sale_Lines.Count > 0) { error.MessageStyle = new MessageStyle { Message = "Please finish current sale before bottle return.~Bottle Return", MessageType = ExclamationOkMessageType }; error.StatusCode = HttpStatusCode.Conflict; return(null); } if (!_policyManager.GetPol("U_BOTTLERTN", user)) { error.MessageStyle = _resourceManager.CreateMessage(offSet, 38, 57, null, ExclamationOkMessageType); error.StatusCode = HttpStatusCode.Forbidden; return(null); } if (brPayment.Amount != 0) { if (string.IsNullOrEmpty(Convert.ToString(_policyManager.GetPol("BASECURR", null)))) { error.MessageStyle = _resourceManager.CreateMessage(offSet, 18, 61, null, CriticalOkMessageType); error.StatusCode = HttpStatusCode.NotFound; return(null); } if (brPayment.Amount > (decimal)Math.Abs(_policyManager.GetPol("U_BR_LIMIT", user))) { // Exceed the bottle return limit, Please get an authorized user! error.MessageStyle = _resourceManager.CreateMessage(offSet, 18, 62, null, CriticalOkMessageType); error.StatusCode = HttpStatusCode.Forbidden; return(null); } if (_policyManager.OPEN_DRAWER == "Every Sale") { openDrawer = true; } var sale = new Sale { Sale_Totals = { Net = Convert.ToDecimal(brPayment.Amount) } }; var saleTotals = sale.Sale_Totals; _saleManager.SetGross(ref saleTotals, sale.Sale_Totals.Net); sale.Sale_Totals.Gross = saleTotals.Gross; sale.Sale_Totals.TotalLabel = saleTotals.TotalLabel; sale.Sale_Totals.SummaryLabel = saleTotals.SummaryLabel; sale.Register = brPayment.RegisterNumber; sale.Sale_Change = 0; sale.TillNumber = Convert.ToByte(brPayment.TillNumber); sale.Sale_Date = DateTime.Now; sale.Sale_Tender = 0; sale.Sale_Change = 0; sale.Sale_Amount = 0; if (_policyManager.GetPol("Penny_Adj", null) && brPayment.Amount != 0) { sale.Sale_Totals.Penny_Adj = Helper.Calculate_Penny_Adj(Convert.ToDecimal(brPayment.Amount)); } else { sale.Sale_Totals.Penny_Adj = 0; } brPayment.Penny_Adj = sale.Sale_Totals.Penny_Adj; if (existingSale == null) { brPayment.Sale_Num = _saleManager.GetCurrentSaleNo(brPayment.TillNumber, userCode, out error); } var tendBr = new Tenders(); var tender = tendBr.Add(Convert.ToString(_policyManager.GetPol("BASECURR", null)), "Cash", 1, true, true, false, (short)1, Convert.ToString(_policyManager.GetPol("BASECURR", null)), false, 0, 0, 0.01, true, Convert.ToDouble(-brPayment.Amount), (short)1, true, false, "", ""); _tenderManager.Set_Amount_Entered(ref tendBr, ref sale, tender, -brPayment.Amount); sale.Sale_Num = Convert.ToInt32(brPayment.Sale_Num); sale.Sale_Type = "BTL RTN"; var shiftNumber = _tillService.GetTill(brPayment.TillNumber).Shift; bottleReport = _receiptManager.Print_BottleReturn(brPayment, user.Name, DateTime.Today, DateTime.Now, sale.Register, (short)brPayment.TillNumber, shiftNumber); bottleReport.Copies = _policyManager.BottleReturnReceiptCopies; _bottleReturnService.SaveBottleReturnsToDbTrans(brPayment); _saleManager.SaveSale(sale, userCode, ref tendBr, null); CacheManager.DeleteCurrentSaleForTill(sale.TillNumber, sale.Sale_Num); //_saleManager.Clear_Sale(sale.Sale_Num,sale.TillNumber, userCode, "", null, true, false, false, out msg); sale = _saleManager.InitializeSale(brPayment.TillNumber, brPayment.RegisterNumber, userCode, out error); //Update Sale object in Cache CacheManager.AddCurrentSaleForTill(sale.TillNumber, sale.Sale_Num, sale); Performancelog.Debug($"End,BottleManager,SaveBottleReturn,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}"); return(sale); } return(null); }
/// <summary> /// Method to update post pay /// </summary> /// <param name="newStatus">New status</param> /// <param name="error">Error message</param> public void UpdatePostPay(bool newStatus, out ErrorMessage error) { var user = _loginManager.GetExistingUser(UserCode); error = new ErrorMessage(); var blEnabled = !newStatus; var offSet = _policyManager.LoadStoreInfo().OffSet; bool stateOn; try { stateOn = TCPAgent.Instance.IsConnected; } catch { stateOn = false; } if (!stateOn) { if (blEnabled) { // MsgBox ("Communication problem, Cannot turn off PostPay!~Turn Off PostPay Error!") error.MessageStyle = _resourceManager.CreateMessage(offSet, 12, 60, null, MessageType.OkOnly); error.StatusCode = HttpStatusCode.NotFound; } else { error.MessageStyle = _resourceManager.CreateMessage(offSet, 12, 61, null, MessageType.OkOnly); error.StatusCode = HttpStatusCode.NotFound; } return; } if (!_policyManager.GetPol("U_AD_PI", user)) { error.MessageStyle = _resourceManager.CreateMessage(offSet, 12, 92, null, MessageType.OkOnly); error.StatusCode = HttpStatusCode.Forbidden; return; // Get a user who is authorized to turn on/off post pay } //cmdPostPay.Enabled = false; var strSend = blEnabled ? "Isd0" : "Isd1"; var response = ""; var timeIn = (float)DateAndTime.Timer; TCPAgent.Instance.Send_TCP(ref strSend, true); while (!(DateAndTime.Timer - timeIn > Variables.gPumps.CommunicationTimeOut)) { var strBuffer = Convert.ToString(TCPAgent.Instance.NewPortReading); WriteToLogFile("TCPAgent.PortReading: " + strBuffer + " from waiting " + strSend); if (!string.IsNullOrEmpty(strBuffer)) { var strRemain = ""; modStringPad.SplitResponse(strBuffer, strSend, ref response, ref strRemain); //strBuffer<>"" if (!string.IsNullOrEmpty(response)) //got what we are waiting { TCPAgent.Instance.PortReading = strRemain; //& ";" & TCPAgent.PortReading WriteToLogFile("modify PortReading from PostPay On/Off: " + strRemain); break; } } if (DateAndTime.Timer < timeIn) { timeIn = (float)DateAndTime.Timer; } Variables.Sleep(100); } if (Strings.Left(response, 6) != strSend + "OK") //response is not Isd0OK / Isd1OK { if (blEnabled) { error.MessageStyle = _resourceManager.CreateMessage(offSet, 12, 60, null, MessageType.OkOnly); error.StatusCode = HttpStatusCode.NotFound; } else { error.MessageStyle = _resourceManager.CreateMessage(offSet, 12, 61, null, MessageType.OkOnly); error.StatusCode = HttpStatusCode.NotFound; } // Return to current user return; } _fuelService.SavePostPayEnabled(newStatus); _fuelService.Save_PostPaySetManually(true); // cmdPostPay.Enabled = true; WriteToLogFile("PostPay was set to " + newStatus + " by the user " + user.Code + " " + user.Name + ". Return to current user " + user.Code + " " + user.Name); // Return to current user }
/// <summary> /// Method to get request string /// </summary> /// <param name="cc">Credit card</param> /// <param name="sale">Sale</param> /// <param name="trnType">Transaction type</param> /// <param name="cardType">Card type</param> /// <param name="amount">Amount</param> /// <param name="authCode">Auth code</param> /// <returns>Request string</returns> public string GetRequestString(ref Credit_Card cc, Sale sale, string trnType, string cardType, float amount, string authCode) { string str = ""; short pos = 0; //string strOptionalData; switch (trnType.Trim()) { case "SwipeInside": str = str + trnType.Trim() + "," + cardType.Trim() + ","; str = str + amount.ToString().Trim() + ",,,,,,,,,,,,,,,"; break; case "EODTerminal": //authcode as terminal ID - changed on 06/19/02 'Sajan str = str + trnType.Trim() + "," + cardType.Trim() + ",1,,,,," + authCode.Trim() + ",,,,,,,,,,,,Y,,,,,,,,,,,,,,"; break; case "CloseBatchInside": if (Strings.UCase(Convert.ToString(_policyManager.BankSystem)) == "GLOBAL") { if (cardType == "NoDebit") //Added by Mina - For no trans debit { str = str + trnType.Trim() + "," + cardType.Trim() + ",1,,,,,,,,,,,,,,,,,Y,,,,,,,,,,,,,,"; } else { str = str + trnType.Trim() + ",,1,,,,,,,,,,,,,,,,,Y,,,,,,,,,,,,,,"; } } else { str = str + trnType.Trim() + ",,1,,,,,,,,,,,,,,,,,Y,,,,,,,,,,,,,,"; } break; case "InitDebitInside": str = str + trnType.Trim() + "," + cardType.Trim() + ",,,,,,,,,,,,,,,,,"; break; default: if (trnType == "VoidInside") { str = trnType.Trim() + "," + cardType.Trim() + ",1,"; } else { str = trnType.Trim() + "," + cardType.Trim() + ",1,"; } str = str + Convert.ToString(sale.Sale_Num) + ",,,"; if (Strings.UCase(Convert.ToString(_policyManager.BankSystem)) == "GLOBAL") { if (trnType == "VoidInside" || trnType.ToUpper() == "SAFVOIDINSIDE") //Added by Mina : UCase(TrnType) = "SAFVOIDINSIDE" { str = str + Convert.ToString(sale.Void_Num) + ",,"; //void refnum } else { str = str + ",,"; //void refnum } } else { // if (trnType == "VoidInside") { str = str + Convert.ToString(sale.Void_Num) + ",,"; //void refnum } else { str = str + ",,"; //void refnum } } if (_policyManager.Version == "US") //Behriooz Oct25-05 { str = str + amount.ToString("0.00").Trim() + ","; // CStr(Int(Abs(Amount * 100)))) & "," } else { str = str + (double.Parse(amount.ToString("0.00")) * 100).ToString().Trim() + ","; // CStr(Int(Abs(Amount * 100)))) & "," } str = str + _creditCardManager.Language(ref cc).Substring(0, 1) + ",,"; //the following lines were added by Sajan if (!string.IsNullOrEmpty(cc.Track2)) { pos = (short)(cc.Track2.IndexOf("?") + 1); } var track2 = ""; if (pos != 0) { track2 = cc.Track2.Substring(0, pos - 1); } else { track2 = cc.Track2 ?? ""; } pos = (short)(track2.IndexOf(";") + 1); if (pos != 0) { track2 = track2.Substring(pos + 1 - 1); } if (string.IsNullOrEmpty(cc.Track2)) { track2 = (string.IsNullOrEmpty(cc.Cardnumber) ? string.Empty : cc.Cardnumber.Trim()) + "=" + (string.IsNullOrEmpty(cc.Expiry_Date) ? string.Empty : cc.Expiry_Date.Trim()); } str = str + track2 + ",,,"; if (!string.IsNullOrEmpty(authCode)) { if (_policyManager.EMVVersion) { str = str + authCode + ",,,,,"; } else { //shiny end - EMVVERSION str = str + authCode + ",,,,"; } } else { str = str + ",,,,,Y"; } if (cc.Crd_Type == "F") { str = str + ","; str = str + _creditCardManager.ProductCodes(sale.TillNumber) + ",,"; str = str + cc.Vechicle_Number + ","; str = Convert.ToString((string.IsNullOrEmpty(cc.ID_Number) ? str + cc.Driver_Number : str + cc.ID_Number) + ","); str = str + cc.Odometer_Number + ",,,"; str = str + cc.TerminalType + ",,"; // Terminal Type string temp_Policy_Name = "USE_PINPAD"; str = str + Convert.ToString(_policyManager.GetPol(temp_Policy_Name, null)) + ","; if (_policyManager.USE_PINPAD) { str = str + Convert.ToString(cc.AskDriverNo) + ","; str = str + Convert.ToString(cc.AskIdentificationNo) + ","; str = str + Convert.ToString(cc.AskOdometer) + ","; str = str + Convert.ToString(cc.AskVechicle) + ","; str = str + Convert.ToString(cc.AskProdRestrictCode) + ","; } else { str = str + "False,False,False,False,False,"; } str = str + cc.UsageCode + ","; // Nicolette, Jan 27 added a extra comma to match the number of commas send to STPS } else { str = str + new string(',', 16); } // Nicolette end //Shiny Nov9, 2009'EMVVERSION if (_policyManager.EMVVersion) //- only needed for credit { // str = str & IIf(cc.ManualCardProcess, "M", "") & "," str = str + Convert.ToString(cc.ManualCardProcess ? "M85" : "") + ","; // - added the POs trans timeout 85 to passing to TPS with Farhad's instruction } //shiny end // to assign optional data profile for any debit or credit card selected // for EMV version, TPS will drop th unnecessary optional data string sent by POS // debit cards are included because the cashier might select debit but the customer inserts a credit card if (cc.Crd_Type == "F" || cc.Crd_Type == "C" || cc.Crd_Type == "D") // added Or cc.Crd_Type = "C" for Crevier Visa { TenderCard tenderCard = _cardService.LoadTenderCard(cc.CardCode); Build_OptDataString(sale, ref cc, ref tenderCard); // optional data for fleet cards str = str + "," + cc.OptDataString; } else { str = str + ","; } break; } var returnValue = str; return(returnValue); }
/// <summary> /// Get all Sales /// </summary> /// <param name="pageIndex">Page index</param> /// <param name="pageSize">Page size</param> /// <returns></returns> public List <SaleHead> GetAllSales(int pageIndex, int pageSize) { var dateStart = DateTime.Now; Performancelog.Debug($"Start,ReturnSaleManager,GetAllSales,{string.Empty},{dateStart:hh.mm.ss.ffffff}"); DateTime saleDate = DateTime.Now.AddDays(-Convert.ToInt16(_policyManager.GetPol("RES_DAYS", null))); Performancelog.Debug($"End,ReturnSaleManager,GetAllSales,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}"); return(_returnSaleService.GetAllSales(saleDate, _policyManager.TIMEFORMAT, pageIndex, pageSize)); }
/// <summary> /// Checks User ID /// </summary> /// <param name="userName">Username</param> /// <param name="password">Password</param> /// <param name="posId">POS Id</param> /// <param name="unauthorizedAccess">Unauthorized access</param> /// <param name="message">Error</param> /// <returns>True or false</returns> private bool CheckUserId(string userName, string password, int posId, bool unauthorizedAccess, out ErrorMessage message) { var returnValue = true; message = new ErrorMessage(); //var user = _userService.GetUser(userName); var user = CacheManager.GetUser(userName) ?? _userService.GetUser(userName); var encryptionManager = new EncryptionManager(); if (user != null) { //Add user in Cache CacheManager.AddUser(userName, user); var offSet = _policyManager.LoadStoreInfo().OffSet; if (_policyManager.LogUnlimit == false) { //User cannot log on to more than one register unless it is a Trainer if (user.User_Group.Code != "Trainer" && !unauthorizedAccess) { var result = _loginService.CheckLoggedinUserPos(userName, posId); if (result) { message = new ErrorMessage { MessageStyle = _resourceManager.CreateMessage(offSet, 30, 95, null, CriticalOkMessageType) }; return(false); } } } if (!Convert.ToBoolean(_policyManager.GetPol("U_SELL", user))) { //TIMsgbox "You are not authorized to sell products", _ //vbCritical + vbOKOnly, "No Authorization" message = new ErrorMessage { MessageStyle = _resourceManager.CreateMessage(offSet, 30, 92, null, CriticalOkMessageType) }; } //End - SV if (!Convert.ToBoolean(_policyManager.GetPol("U_REQ_PW", user))) { return(true); } if (password != encryptionManager.DecryptText(user.epw) || string.IsNullOrEmpty(password)) { message = new ErrorMessage { MessageStyle = _resourceManager.CreateMessage(offSet, 30, 91, null, CriticalOkMessageType) }; returnValue = false; } } else { //TIMsgbox "UserID " & txtUserid.Text & " does not exist.", vbCritical + vbOKOnly, "No Such User", Me var offSet = _policyManager.LoadStoreInfo().OffSet; message = new ErrorMessage { MessageStyle = _resourceManager.CreateMessage(offSet, 30, 93, userName, CriticalOkMessageType) }; returnValue = false; } return(returnValue); }
/// <summary> /// Method to adjust lines /// </summary> /// <param name="payPump">Pay at pump</param> /// <param name="thisLine">Sale line</param> /// <param name="newLine">New line</param> /// <param name="remove">Remove or not</param> /// <returns>True or false</returns> internal bool Adjust_Lines(ref PayAtPump payPump, ref Sale_Line thisLine, bool newLine, bool remove = false) { bool returnValue = false; // Get the pricing for that many products float[,] spr = null; Sale_Line ss = default(Sale_Line); float saleQty = 0; short saleLin = 0; Sale_Line New_Line = default(Sale_Line); short n = 0; short m; short nDel = 0; bool Fd; bool Can_Combine = false; bool Combined = false; short Lines_Needed = 0; short ns; short nL; bool Combine_Policy = false; Combine_Policy = Convert.ToBoolean(_policyManager.COMBINE_LINE); returnValue = true; // If the incoming line is New then include it's quantity in the count. If it isn't // then the quantity will be included in the following loop. saleQty = Convert.ToSingle(newLine ? thisLine.Quantity : 0); if (remove) { saleQty = Convert.ToSingle(-thisLine.Quantity); } saleLin = Convert.ToInt16(newLine ? 1 : 0); // Compute the total quantity of the item in the sale and the number of lines // on which it appears. foreach (Sale_Line tempLoopVarSLine in payPump.Sale_Lines) { var sLine = tempLoopVarSLine; if (thisLine.Stock_Code != sLine.Stock_Code) { continue; } saleQty = saleQty + sLine.Quantity; saleLin++; } ns = (short)(saleQty < 0 ? -1 : 1); // Call 'PQuantity' to build the array of prices and quantities to be used for this // item. spr = PQuantity(thisLine, saleQty); saleQty = Math.Abs((short)saleQty); if (thisLine.Price_Number > 1) { // If Price_Number > 1 then it is NOT regular price. if (newLine) { foreach (Sale_Line tempLoopVarSs in payPump.Sale_Lines) { ss = tempLoopVarSs; if (ss.Stock_Code == thisLine.Stock_Code) { string temp_Policy_Name = "COMBINE_LINE"; Can_Combine = Combine_Policy && _policyManager.GetPol(temp_Policy_Name, thisLine) && (!thisLine.Gift_Certificate) && ss.price == thisLine.price & ss.Quantity > 0 & thisLine.Quantity > 0 & ss.Discount_Rate == thisLine.Discount_Rate && ss.Serial_No == "" && thisLine.Serial_No == "" && ss.Discount_Type == thisLine.Discount_Type; if (!Can_Combine) { continue; } ss.Quantity = ss.Quantity + thisLine.Quantity; ss.Amount = (decimal)(ss.Quantity * ss.price); returnValue = false; break; } } } else { thisLine.Amount = (decimal)(thisLine.Quantity * thisLine.price); } } else { // Price_Code = 1 means that this is based on regular price. if (thisLine.Price_Type == 'R') { if (newLine) { foreach (Sale_Line tempLoopVarSs in payPump.Sale_Lines) { ss = tempLoopVarSs; if (ss.Stock_Code == thisLine.Stock_Code) { var temp_Policy_Name2 = "COMBINE_LINE"; Can_Combine = Combine_Policy && _policyManager.GetPol(temp_Policy_Name2, thisLine) && (!thisLine.Gift_Certificate) && ss.price == thisLine.price & ss.Quantity > 0 & thisLine.Quantity > 0 & ss.Discount_Rate == thisLine.Discount_Rate && ss.Serial_No == "" && thisLine.Serial_No == "" && ss.Discount_Type == thisLine.Discount_Type; if (!Can_Combine) { continue; } ss.Quantity = ss.Quantity + thisLine.Quantity; ss.Amount = (decimal)(ss.Quantity * ss.price); returnValue = false; break; } } } else { thisLine.Amount = (decimal)(thisLine.Quantity * thisLine.price); } } else if (thisLine.Price_Type == 'F') { // "F" - First Unit Pricing if (newLine) { foreach (Sale_Line tempLoopVarSs in payPump.Sale_Lines) { ss = tempLoopVarSs; // Assign the computed prices to each item in the sale. if (ss.Stock_Code == thisLine.Stock_Code) { Line_Price(ref payPump, ref ss, (double)(Convert.ToDecimal(spr[1, 2]))); ss.Amount = (decimal)(ss.Quantity * ss.price); } } foreach (Sale_Line tempLoopVarSs in payPump.Sale_Lines) { ss = tempLoopVarSs; if (ss.Stock_Code == thisLine.Stock_Code) { var temp_Policy_Name3 = "COMBINE_LINE"; Can_Combine = Combine_Policy && _policyManager.GetPol(temp_Policy_Name3, thisLine) && (!thisLine.Gift_Certificate) && (decimal)ss.price == Convert.ToDecimal(spr[1, 2]) && ss.Quantity > 0 & thisLine.Quantity > 0 & ss.Discount_Rate == thisLine.Discount_Rate && ss.Serial_No == "" && thisLine.Serial_No == "" && ss.Discount_Type == thisLine.Discount_Type; Line_Price(ref payPump, ref ss, (double)(Convert.ToDecimal(spr[1, 2]))); if (Can_Combine && !Combined) { Line_Quantity(ref payPump, ref ss, ss.Quantity + thisLine.Quantity, false); Combined = true; } ss.Amount = (decimal)(ss.Quantity * ss.price); } } if (Combined) { returnValue = false; } else { thisLine.price = (double)(Convert.ToDecimal(spr[1, 2])); thisLine.Amount = (decimal)(thisLine.Quantity * thisLine.price); } } else { if (thisLine.Price_Number == 1) { thisLine.price = (double)(Convert.ToDecimal(spr[1, 2])); } thisLine.Amount = (decimal)(thisLine.Quantity * thisLine.price); } } else if (thisLine.Price_Type == 'S') { // "S" - Sale Pricing if (newLine) { Combined = false; foreach (Sale_Line tempLoopVarSs in payPump.Sale_Lines) { ss = tempLoopVarSs; if (ss.Stock_Code == thisLine.Stock_Code) { var temp_Policy_Name4 = "COMBINE_LINE"; Can_Combine = Combine_Policy && _policyManager.GetPol(temp_Policy_Name4, thisLine) && (!thisLine.Gift_Certificate) && (decimal)ss.price == Convert.ToDecimal(spr[1, 2]) && ss.Quantity > 0 & thisLine.Quantity > 0 & ss.Discount_Rate == thisLine.Discount_Rate && ss.Serial_No == "" && thisLine.Serial_No == "" && ss.Discount_Type == thisLine.Discount_Type; Line_Price(ref payPump, ref ss, (double)(Convert.ToDecimal(spr[1, 2]))); if (Can_Combine && !Combined) { Line_Quantity(ref payPump, ref ss, ss.Quantity + thisLine.Quantity, false); Combined = true; } ss.Amount = (decimal)(ss.Quantity * ss.price); } } if (Combined) { returnValue = false; } else { thisLine.price = (double)(Convert.ToDecimal(spr[1, 2])); thisLine.Amount = (decimal)(thisLine.Quantity * thisLine.price); } } else { if (thisLine.Price_Number == 1) { thisLine.price = (double)(Convert.ToDecimal(spr[1, 2])); } thisLine.Amount = (decimal)(thisLine.Quantity * thisLine.price); } } else if (thisLine.Price_Type == 'X' || thisLine.Price_Type == 'I') { // "X" - X for Pricing; "I" - Incremental Pricing // Compute how many lines are needed by counting the number of prices // that the 'PQuantity' routine set. Lines_Needed = (short)0; for (n = 1; n <= (spr.Length - 1); n++) { if (spr[n, 1] != 0) { Lines_Needed++; } else { break; } } nDel = (short)0; // Remove Lines if there are more than we need ... if (Lines_Needed < saleLin) { if (newLine) { // Don't add the incoming line. That reduces the number we need to // delete by 1. nDel = (short)1; } if (nDel < saleLin - Lines_Needed) { foreach (Sale_Line tempLoopVarSs in payPump.Sale_Lines) { ss = tempLoopVarSs; if (ss.Stock_Code == thisLine.Stock_Code) { //Me.Remove_a_Line SS.Line_Num, False nDel++; if (nDel == saleLin - Lines_Needed) { break; } } } } // Add lines if there are not enough. } else if (Lines_Needed > saleLin) { for (n = saleLin; n <= Lines_Needed - 1; n++) { nDel++; New_Line = new Sale_Line { PLU_Code = thisLine.PLU_Code, Discount_Type = thisLine.Discount_Type, Discount_Rate = thisLine.Discount_Rate, Line_Num = (short)(payPump.Sale_Lines.Count + 1) }; var user = _loginManager.GetExistingUser(payPump.UserCode); Add_a_Line(ref payPump, user, New_Line, false); } } // Set the pricing on each line n = (short)0; foreach (Sale_Line tempLoopVarSs in payPump.Sale_Lines) { ss = tempLoopVarSs; if (ss.Stock_Code == thisLine.Stock_Code) { n++; Line_Price(ref payPump, ref ss, (double)(Convert.ToDecimal(spr[n, 2]))); Line_Quantity(ref payPump, ref ss, Convert.ToInt16(spr[n, 1]), false); ss.Amount = Convert.ToDecimal(spr[n, 3]); saleQty = saleQty - System.Math.Abs(Convert.ToInt16(spr[n, 1])); } } // Set the quantity on the new line if (saleQty != 0) { n++; thisLine.Quantity = saleQty; thisLine.price = (double)(Convert.ToDecimal(spr[n, 2])); thisLine.Amount = Convert.ToDecimal(spr[n, 3]); returnValue = true; } else { returnValue = false; } } } return(returnValue); }