Esempio n. 1
0
        /// <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);
        }
Esempio n. 2
0
        /// <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);
        }
Esempio n. 3
0
        public double CheckKickbackResponse(bool response, int tillNumber, int saleNumber, string userCode, out ErrorMessage errorMessage, ref Sale sale)
        {
            object[]            CapValue        = new object[3];
            SaleSummaryResponse result          = null;
            List <Report>       transactReports = null;

            if (_policyManager.Use_KickBack && sale.Customer.PointCard_Registered && sale.Customer.Balance_Points >= _policyManager.L_RedeemPnts && sale.Sale_Totals.Gross > 0 && sale.Customer.PointsCard_AllowRedemption)
            {
                if (sale.Customer.Points_ExchangeRate != 0)
                {
                    //You have this many points. Redeem Now

                    CapValue[1] = sale.Customer.Balance_Points; // points balance

                    CapValue[2] = (sale.Customer.Balance_Points * sale.Customer.Points_ExchangeRate).ToString("0.00");
                }
                else
                {
                    CapValue[1] = sale.Customer.Balance_Points;

                    CapValue[2] = "?";
                }

                if (response == true)
                {
                    sale.Customer.Points_Redeemed = double.Parse(sale.Customer.Balance_Points.ToString("0.00"));
                    var amount = (sale.Customer.Balance_Points * sale.Customer.Points_ExchangeRate).ToString("0.00");


                    // result.Tenders = _tenderManager.UpdateTenders(sale.Sale_Num, sale.TillNumber, "Sale", userCode, false, "KICKBACK", amount, out transactReports, out errorMessage);
                }
                else
                {
                    sale.Customer.Points_Redeemed = 0;
                }
            }
            CacheManager.AddCurrentSaleForTill(tillNumber, saleNumber, sale);
            errorMessage = null;

            return(sale.Customer.Points_Redeemed);
        }
        public bool SavePSTransactionID(int TILL_NUM, int SALE_NO, int LINE_NUM, string TransID)
        {
            bool bSaved = false;

            try
            {
                Sale sale = CacheManager.GetCurrentSaleForTill(TILL_NUM, SALE_NO);
                sale.Sale_Lines[LINE_NUM].Serial_No = TransID;
                //Update current sale
                CacheManager.AddCurrentSaleForTill(TILL_NUM, SALE_NO, sale);
                //Get crrent sale after updating
                //sale = CacheManager.GetCurrentSaleForTill(TILL_NUM, SALE_NO);
                bSaved = true;
            }
            catch (Exception ex)
            {
                Performancelog.Error("PaymentSourceManager.SavePSTransactionID(): " + ex.Message);
            }

            return(bSaved);
        }
Esempio n. 5
0
        /// <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);
        }
Esempio n. 6
0
        public GaskingKickback ValidateGasKing(int tillNumber, int saleNumber, byte registerNumber,
                                               string userCode, out ErrorMessage errorMessage, bool isCardSwipedInTenderScreen = false)
        {
            errorMessage = new ErrorMessage();
            saleObj      = _saleManager.GetCurrentSale(saleNumber, tillNumber, registerNumber, userCode, out errorMessage);
            var customer = saleObj.Customer.LoyaltyCardSwiped ?
                           _customerService.GetClientCardForGasKingCustomer(saleObj.Customer.LoyaltyCard) : null;

            if (customer == null)
            {
                // errorMessage.MessageStyle.Message = "No customer is selected";
                //errorMessage.StatusCode = HttpStatusCode.NotAcceptable;
                return(new GaskingKickback
                {
                    IsKickBackLinked = false,
                    PointsReedemed = saleObj.Customer.Balance_Points,
                    Value = (saleObj.Customer.Balance_Points * saleObj.Customer.Points_ExchangeRate).ToString("0.00")
                });
            }
            saleObj.Customer.Loyalty_Code = customer.CardNumber;
            saleObj.Customer.PointsCard_AllowRedemption = customer.AllowRedemption;
            var  arcust           = saleObj.Customer.AR_Customer;
            bool isKickBackLinked = false;

            if (_policyManager.Use_KickBack)
            {
                // if (!customer.AllowRedemption && isCardSwipedInTenderScreen)
                //if (isCardSwipedInTenderScreen)
                //{
                //    return new GaskingKickback
                //    {
                //        IsKickBackLinked = false,
                //        PointsReedemed = saleObj.Customer.Balance_Points,
                //        Value = (saleObj.Customer.Balance_Points * saleObj.Customer.Points_ExchangeRate).ToString("0.00")
                //    };
                //}

                // Shiny -This Pointcard loading should have done as part of Customer loading - Since Previous code is not done properly at Customer class I can't change it- I am forced to do this here
                var data = _kickBackService.GaskingKickback(saleObj);
                if (data.Rows.Count > 0)
                {
                    var row = data.Rows[0];
                    saleObj.Customer.PointCardNum   = CommonUtility.GetStringValue(row["PointCardNum"]);
                    saleObj.Customer.PointCardPhone = String.IsNullOrEmpty(CommonUtility.GetStringValue(row["phonenum"])) ? ""
                                    : CommonUtility.GetStringValue(row["phonenum"]);
                    saleObj.Customer.PointCardSwipe = "0"; // 0-from database based on GK card swiped, 1-from phone number, 2-swiped
                                                           //  '                            SA.Customer.PointsCard_AllowRedemption = True- we need to check the Gasking card setting
                    saleObj.Customer.PointsCard_AllowRedemption = _customerService.
                                                                  Check_Allowredemption(saleObj.Customer.LoyaltyCard);

                    //if (isCardSwipedInTenderScreen)
                    // {

                    //if (!string.IsNullOrEmpty(saleObj.Customer.PointCardNum) && !customer.AllowRedemption)
                    //{
                    //  //  ProcessKickBack((short)(1), userCode, ref saleObj, out errorMessage);

                    //    if (!isCardSwipedInTenderScreen)
                    //    {
                    //        return new GaskingKickback
                    //        {
                    //            IsKickBackLinked = true,
                    //            PointsReedemed = _policyManager.L_RedeemPnts - 1,
                    //            Value = (saleObj.Customer.Balance_Points * saleObj.Customer.Points_ExchangeRate).ToString("0.00")
                    //        };
                    //    }
                    //}
                    //else
                    if (!string.IsNullOrEmpty(saleObj.Customer.PointCardNum))
                    //&& ((saleObj.Customer.PointsCard_AllowRedemption && isCardSwipedInTenderScreen) ||
                    //(!isCardSwipedInTenderScreen)))
                    {
                        isKickBackLinked = ProcessKickBack((short)(0), userCode, ref saleObj, out errorMessage);

                        if (!isCardSwipedInTenderScreen && !customer.AllowRedemption)
                        {
                            return(new GaskingKickback
                            {
                                IsKickBackLinked = true,
                                PointsReedemed = _policyManager.L_RedeemPnts - 1,
                                Value = (saleObj.Customer.Balance_Points * saleObj.Customer.Points_ExchangeRate).ToString("0.00")
                            });
                        }

                        if (isCardSwipedInTenderScreen)
                        {
                            return(new GaskingKickback
                            {
                                IsKickBackLinked = isKickBackLinked && customer.AllowRedemption,
                                PointsReedemed = saleObj.Customer.Balance_Points,
                                Value = (saleObj.Customer.Balance_Points * saleObj.Customer.Points_ExchangeRate).ToString("0.00")
                            });
                        }
                    }
                    else
                    {
                        return(new GaskingKickback
                        {
                            IsKickBackLinked = false,
                            PointsReedemed = saleObj.Customer.Balance_Points,
                            Value = (saleObj.Customer.Balance_Points * saleObj.Customer.Points_ExchangeRate).ToString("0.00")
                        });
                    }
                    // }
                    //else
                    //{
                    //    if (!string.IsNullOrEmpty(saleObj.Customer.PointCardNum))
                    //    {
                    //        isKickBackLinked = ProcessKickBack((short)(0), userCode, ref saleObj, out errorMessage);
                    //    }
                    //}
                }

                data = null;
            }

            else
            {
                return(new GaskingKickback
                {
                    IsKickBackLinked = true,
                    PointsReedemed = _policyManager.L_RedeemPnts - 1,
                    Value = (saleObj.Customer.Balance_Points * saleObj.Customer.Points_ExchangeRate).ToString("0.00")
                });
            }
            saleObj.Customer.AR_Customer = arcust;
            CacheManager.AddCurrentSaleForTill(tillNumber, saleNumber, saleObj);

            var resp = new GaskingKickback
            {
                IsKickBackLinked = isKickBackLinked,
                PointsReedemed   = saleObj.Customer.Balance_Points,
                Value            = (saleObj.Customer.Balance_Points * saleObj.Customer.Points_ExchangeRate).ToString("0.00")
            };

            return(resp);
        }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
        public bool ProcessKickBack(short command_Renamed, string userCode, ref Sale sale, out ErrorMessage errorMessage)
        {
            //  var tender = new Tender();
            bool result   = true;
            var  kickback = new XML(_policyManager);
            var  store    = _policyManager.LoadStoreInfo();

            float timeIN      = 0;
            short TimeOut     = 0;
            bool  GotResponse = false;
            short Answer;
            var   KBComm = new Comm();

            object[] CapValue = new object[3];
            var      tender   = _tenderManager.GetAllTender(sale.Sale_Num, sale.TillNumber, "Sale", userCode, false,
                                                            "", out errorMessage);

            //   command 0 - GetPointStatus Request
            //   command 1 - FinalizeRewards Request - only from Exact Change button
            //   command 2 - Check Balance
            if (command_Renamed < 0 | command_Renamed > 2)
            {
                errorMessage.StatusCode           = HttpStatusCode.BadGateway;
                errorMessage.MessageStyle.Message = "Invalid loyalty card";
                return(false);
            }

            KBComm            = new Comm(); //'' KickBackComm
            KBComm.CommData  += KBComm_CommData;
            KBComm.CommError += KBComm_CommError;



            Comm.KBComm = KBComm;

            var xml      = new XML(_policyManager);
            var saleLine = new Sale_Line();
            var s        = new Sale();


            //  var sale = _saleManager.GetCurrentSale();
            var offSet = _policyManager.LoadStoreInfo().OffSet;

            // Write to log is done by KickBackXML class, POS only displays messages for the cashier

            if (!_xmlManager.Initialize("", "", "", (sale.Sale_Num).ToString(), System.Convert.ToString(store.Code), "", ref xml))
            {
                // Display the same error message on the screen because for cashier doesn't matter
                // if the connection cannot be made or the XML cannot be created.
                // But KickBackXML class writes the error in the log for debugging purposes

                _resourceManager.CreateMessage(offSet, 11, 42, null, MessageType.Exclamation);//Cannot communicate with Loyalty Server
                errorMessage.MessageStyle.Message = "Invalid loyalty card";
                errorMessage.StatusCode           = HttpStatusCode.NotAcceptable;
                return(false);
            }
            else
            {
                kickback.Sale = this.saleObj;

                if (!(tender == null))
                {
                    kickback.Tenders = tender;
                }
            }

            if (command_Renamed == 0 | command_Renamed == 2)
            {
                var a = xml.PosSequenceID;

                // if (!_xmlManager.FormatFinalizeRewardsRequestXML(sale.Customer.PointCardNum, System.Convert.ToString(sale.Customer.PointCardSwipe == "2" ? "SWIPE" : "MANUAL"), (sale.Customer.Points_Redeemed).ToString(), (sale.Sale_Totals.Gross).ToString(), "", "", "", System.Convert.ToString(store.Code), System.Convert.ToString(userCode), System.Convert.ToString(sale.TillNumber), "", "", "", "",ref xml,ref sale))
                if (!_xmlManager.FormatGetPointStatusRequestXML(sale.Customer.PointCardNum, System.Convert.ToString(sale.Customer.PointCardSwipe == "2" ? "SWIPE" : "MANUAL"), ref xml))
                {
                    // Display the same error massage on the screen because for cashier doesn't matter
                    // if the connection cannot be made or the XML cannot be created.
                    // But write the correct reason in the log for debugging purposes

                    _resourceManager.CreateMessage(offSet, 11, 42, null, MessageType.Information); //Cannot communicate to Loyalty TPS

                    return(false);
                }
                var sam1 = xml;
            }


            else if (command_Renamed == 1) // send finalize rewards only from Exact_Change Button
            {
                var points = (sale.Customer.Points_Redeemed == 0) ? 0 : (sale.Customer.Points_Redeemed / ExchangeRate);
                if (!_xmlManager.FormatFinalizeRewardsRequestXML(sale.Customer.PointCardNum, System.Convert.ToString(sale.Customer.PointCardSwipe == "2" ? "SWIPE" : "MANUAL"), points.ToString(), (sale.Sale_Totals.Gross).ToString(), "", "", "", System.Convert.ToString(store.Code), System.Convert.ToString(userCode), System.Convert.ToString(sale.TillNumber), "", "", "", "", ref xml, ref sale))
                // if (!_xmlManager.FormatFinalizeRewardsRequestXML(sale.Customer.PointCardNum, "SWIPE", (sale.Customer.Points_Redeemed * 100).ToString(), (sale.Sale_Totals.Gross).ToString(), "", "", "", System.Convert.ToString(store.Code), System.Convert.ToString(userCode), System.Convert.ToString(sale.TillNumber), "", "", "", "", ref xml, ref sale))
                {
                    //shiny end
                    // Display the same error massage on the screen because for cashier doesn't matter
                    // if the connection cannot be made or the XML cannot be created.
                    // But write the correct reason in the log for debugging purposes
                    //Chaps_Main.DisplayMessage(this, (short)42, MsgBoxStyle.Information, null, (byte)0); //Cannot communicate to Loyalty TPS
                    //shiny sept 14, 2009 - changed to use the common function, so apperstophe fix can do in one place
                    //             dbMaster.Execute "INSERT INTO KickBackQueue VALUES ('" & KickBack.GetRequestXMLstring & "')"
                    // modGlobalFunctions.InsertTo_KickBackQueue(Variables.KickBack.GetRequestXMLstring);
                    InsertTo_KickBackQueue(xml.GetRequestXMLstring);
                    //shiny end - sept14, 2009
                    return(false);
                }
            }


            KickBackBuffer = ""; //clear the response buffer

            Thread.Sleep(500);
            var timeout = _policyManager.KICKBACK_TMT;

            KickBackBuffer = socket.Connect(xml.GetRequestXMLstring, _policyManager.KICKBACK_IP, (short)Conversion.Val(_policyManager.KICKBACK_PRT), (short)Conversion.Val(timeout), out errorMessage);



            if (KickBackBuffer == "failed")
            {
                WriteTokickBackLogFile(" Cannot Send to Server: " + xml.GetRequestXMLstring);
                if (command_Renamed == 1)
                {
                    InsertTo_KickBackQueue(xml.GetRequestXMLstring);
                }
                return(false);
            }

            WriteTokickBackLogFile(" Connected to KickBack Server: " + $"{_policyManager.KICKBACK_IP}:{_policyManager.KICKBACK_PRT}");
            string kickBackTrimmedResponse = KickBackBuffer.Replace("\0", string.Empty);

            WriteTokickBackLogFile(" Received from Kickback Server:: " + kickBackTrimmedResponse.TrimEnd());
            var    sam3    = xml;
            string RespStr = "";

            Byte[] buff = new Byte[1000];

            GotResponse = false;

            TimeOut = System.Convert.ToInt16(_policyManager.KICKBACK_TMT);
            timeIN  = (float)DateAndTime.Timer;
            //    Debug.Print TimeOut & " " & timeIN
            while (!(DateAndTime.Timer - timeIN > TimeOut))
            {
                //        Debug.Print Timer
                System.Windows.Forms.Application.DoEvents();
                if (!string.IsNullOrEmpty(KickBackBuffer))
                {
                    GotResponse = true;
                    break;
                }
                if (DateAndTime.Timer < timeIN)
                {
                    timeIN = (float)DateAndTime.Timer;
                }
            }


            if (!GotResponse)
            {
                WriteTokickBackLogFile("No response from Loyalty Server.");
                if (command_Renamed == 1)
                {
                    InsertTo_KickBackQueue(xml.GetRequestXMLstring);
                }
                MessageType temp_VbStyle2 = (int)MessageType.Critical + MessageType.OkOnly;
                _resourceManager.CreateMessage(offSet, 11, 42, null, temp_VbStyle2);

                return(false);
            }
            _xmlManager.AnalyseKickBackResponse(KickBackBuffer, ref xml);

            if (command_Renamed == 0 | command_Renamed == 2)
            {
                //Analyze the response
                // Modified on Apr 03, 2009 to use two flags for invalid and non registered cards
                // If the card is not valid processing should continue without any KickBack redemtion or acumulation
                // If the card is not registered processing should continue with accumulation but without redemption
                if (!xml.GetLoyaltyIDValid)
                {
                    //Invalid Loyalty Card
                    _resourceManager.CreateMessage(offSet, 11, 45, null, MessageType.OkOnly);
                    // was 1145
                    sale.Customer.PointCardNum         = "";
                    sale.Customer.PointCardPhone       = "";
                    sale.Customer.PointCardSwipe       = "";
                    sale.Customer.Points_ExchangeRate  = 0;
                    sale.Customer.Points_Redeemed      = 0;
                    sale.Customer.PointsAwarded        = 0;
                    sale.Customer.PointCard_Registered = false;

                    errorMessage = new ErrorMessage();
                    errorMessage.MessageStyle = new MessageStyle
                    {
                        Message = "Invalid loyalty card"
                    };
                    errorMessage.StatusCode = HttpStatusCode.NotAcceptable;
                    result = false;
                }
                else if (command_Renamed == 0)
                {
                    if (xml.LoyaltyIDRegistered)
                    {
                        var allowredeem = sale.Customer.PointsCard_AllowRedemption;
                        var balance     = xml.Sale.Customer.Balance_Points;
                        //var saleline = sale.Sale_Lines;
                        //var saletotal = sale.Sale_Totals;
                        //var gross = sale.Sale_Totals.Gross;
                        //var till = sale.TillNumber;
                        //var cardno = sale.Customer.PointCardNum;
                        //var salenum = sale.Sale_Num;
                        //var entrymethod = sale.Customer.PointCardSwipe;
                        //var selectedCustomer = sale.Customer;
                        // sale = xml.Sale;
                        sale.Customer.PointCard_Registered = true;
                        // sale.Sale_Totals = saletotal;
                        // sale.Sale_Num = salenum;
                        // sale.TillNumber = till;
                        // sale.Sale_Lines = saleline;
                        //sale.Customer = selectedCustomer;
                        sale.Customer.PointsCard_AllowRedemption = allowredeem;
                        //sale.Customer.PointCardNum = cardno;
                        //sale.Customer.PointCardSwipe = entrymethod;
                        sale.Customer.Balance_Points = xml.Sale.Customer.Balance_Points;
                        result = true;
                    }
                    else
                    {
                        _resourceManager.CreateMessage(offSet, 11, 46, null, MessageType.OkOnly);

                        sale.Customer.PointCard_Registered = false;
                        sale.Customer.Points_Redeemed      = 0;
                    }
                }
                sale.Customer.Balance_Points = xml.Sale.Customer.Balance_Points;
                ExchangeRate = sale.Customer.Points_ExchangeRate = xml.Sale.Customer.Points_ExchangeRate;
                WriteUDPData(DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss tt") + "Inside processkickback 483 cardno value" + sale.Customer.PointCardNum);
            }
            var a10 = xml;

            CacheManager.AddCurrentSaleForTill(sale.TillNumber, sale.Sale_Num, sale);
            // _commManager.EndClass();

            //if (((string.IsNullOrEmpty(sale.Customer.CustomerCardNum) && string.IsNullOrEmpty(sale.Customer.PointCardNum))
            //    || (string.IsNullOrEmpty(sale.Customer.CustomerCardNum) && string.IsNullOrEmpty(sale.Customer.PointCardPhone)))
            //    && (string.IsNullOrEmpty(sale.Customer.PointCardNum) && string.IsNullOrEmpty(sale.Customer.LoyaltyCard)))
            //{
            //    errorMessage = new ErrorMessage();
            //    errorMessage.MessageStyle = new MessageStyle
            //    {
            //        Message = "Invalid loyalty card"

            //    };
            //    errorMessage.StatusCode = HttpStatusCode.NotAcceptable;
            //    result = false;
            //}

            //if (sale.Customer.Balance_Points == 0)
            //{
            //    errorMessage = new ErrorMessage();
            //    errorMessage.MessageStyle = new MessageStyle
            //    {
            //        Message = "Invalid loyalty card"

            //    };
            //    errorMessage.StatusCode = HttpStatusCode.NotAcceptable;
            //    result = false;
            //}
            return(result);
        }
Esempio n. 9
0
        public double VerifyKickBack(string pointCardNumber, string phoneNumber,
                                     int tillNumber, int saleNumber, byte registerNumber, string userCode, out ErrorMessage errorMessage,
                                     out Sale sale, ref bool usePhoneNumber)
        {
            short  pos               = 0;
            short  posqm             = 0;
            bool   boolIsPhoneNumber = false;
            string PointCardNumber   = "";
            string Cardnumber;
            string Code;
            Tender tender = null;
            bool   res    = false;

            sale = _saleManager.GetCurrentSale(saleNumber, tillNumber, registerNumber, userCode, out errorMessage);//all required)
            if (sale == null)
            {
                return(0);
            }
            sale.Customer.PointCardNum   = null;
            sale.Customer.Balance_Points = 0;
            if (_policyManager.Use_KickBack)
            {
                //sale= _saleManager.GetCurrentSale(saleNumber, tillNumber, registerNumber, userCode, out errorMessage);
                if (string.IsNullOrEmpty(sale.Customer.PointCardNum))
                {
                    sale.STFDNumber = !(string.IsNullOrEmpty(pointCardNumber)) ? pointCardNumber : phoneNumber;

                    // Chaps_Main.DisplayMsgForm(Policy_Renamed.LoyaltyMesg, (short)15, null, (byte)0, (byte)0, "", "", "", "");
                    if (!string.IsNullOrEmpty(sale.STFDNumber))
                    {
                        if (string.IsNullOrEmpty(sale.STFDNumber))
                        {
                            errorMessage = null;
                            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;
                        }
                        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, true);

                        usePhoneNumber = boolIsPhoneNumber;

                        if (string.IsNullOrEmpty(sale.Customer.CustomerCardNum))
                        {
                            _kickBackService.Set_Customer_KickBack_Data(sale.STFDNumber, !boolIsPhoneNumber,
                                                                        string.IsNullOrEmpty(PointCardNumber) ? sale.STFDNumber : PointCardNumber, ref sale);

                            // usePhoneNumber = !boolIsPhoneNumber;
                        }

                        var a = sale;
                        sale.STFDNumber = ""; //reset STFDNumber
                    }
                }

                //SaveMousePointer = Cursor.Current;
                //this.Enabled = false;
                var allowredemption = sale.Customer.PointsCard_AllowRedemption;

                // System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
                if (sale.Customer.PointCardNum != "")
                {
                    res = ProcessKickBack((short)(0), userCode, ref sale, out errorMessage);
                    if (res == false)
                    {
                        return(-2);
                    }
                    sale.Customer.PointCardNum = (PointCardNumber == "") ? sale.Customer.PointCardNum : PointCardNumber;
                    sale.Customer.PointsCard_AllowRedemption = (allowredemption == false) ? sale.Customer.PointsCard_AllowRedemption : allowredemption;
                }

                CacheManager.AddCurrentSaleForTill(tillNumber, saleNumber, sale);
                var samp = CacheManager.GetCurrentSaleForTill(tillNumber, saleNumber);
                //why samp?
                // System.Windows.Forms.Cursor.Current = SaveMousePointer;
                //Shiny Took it out(Discussion with Nicolette)-Aug27, 2009 - for testing for Flipping to Salemain .Me.enabled = True
            }

            //throw new NotImplementedException();
            errorMessage = null;
            if (res == true)
            {
                return(sale.Customer.Balance_Points);
            }
            return(0);
        }
Esempio n. 10
0
        /// <summary>
        /// Void sale
        /// </summary>
        /// <param name="userCode">User code</param>
        /// <param name="saleNumber">Sale number</param>
        /// <param name="tillNumber">Till number</param>
        /// <param name="voidReason">Void reason</param>
        /// <param name="errorMessage">Error</param>
        /// <param name="fs">Report content</param>
        /// <returns>Sale</returns>
        public Sale VoidSale(string userCode, int saleNumber, int tillNumber, string voidReason,
                             out ErrorMessage errorMessage, out Report fs)
        {
            fs = null;
            var dateStart = DateTime.Now;

            Performancelog.Debug($"Start,SuspendedSaleManager,VoidSale,{string.Empty},{dateStart:hh.mm.ss.ffffff}");

            var sale = _saleManager.GetCurrentSale(saleNumber, tillNumber, 0, userCode, out errorMessage);

            if (!string.IsNullOrEmpty(errorMessage.MessageStyle.Message))
            {
                return(null);
            }
            var offSet = _policyManager.LoadStoreInfo().OffSet;

            //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)
            {
                errorMessage = new ErrorMessage
                {
                    MessageStyle = _resourceManager.CreateMessage(offSet, 11, 77, null, MessageType.OkOnly),
                    StatusCode   = HttpStatusCode.BadRequest
                };
                return(null);
            }


            if (CountFuelLines(sale) > 1) // if there are more then 1 line with fuel do not allow to void this sale
            {
                errorMessage = new ErrorMessage
                {
                    MessageStyle = _resourceManager.CreateMessage(offSet, 11, 82, null, MessageType.OkOnly),
                    StatusCode   = HttpStatusCode.BadRequest
                };
                return(null);
            }

            //Added, not allow to void sale with prepay line

            if (_prepayManager.PrepayItemId(ref sale) > 0)
            {
                errorMessage = new ErrorMessage
                {
                    MessageStyle = _resourceManager.CreateMessage(offSet, 11, 82, null, MessageType.OkOnly),
                    StatusCode   = HttpStatusCode.BadRequest
                };
                return(null);
            }

            //crash recovery' if there is partial/ full payment donot allow void
            if (sale.Payment)
            {
                errorMessage = new ErrorMessage
                {
                    MessageStyle = _resourceManager.CreateMessage(offSet, 11, 14, null, MessageType.OkOnly),
                    StatusCode   = HttpStatusCode.BadRequest
                };
                return(null);
            }

            //Added to control void GiveX items
            string lineNumber = string.Empty;

            if (modGlobalFunctions.HasGivexSale(sale, ref lineNumber))
            {
                errorMessage = new ErrorMessage
                {
                    MessageStyle = _resourceManager.CreateMessage(offSet, 11, 22, null, CriticalOkMessageType),
                    StatusCode   = HttpStatusCode.BadRequest
                };
                return(null);
            }
            if (!CanUserVoidSale(userCode, out errorMessage))
            {
                return(null);
            }


            //added to print receipt for Void sales
            if (_policyManager.PRINT_VOID)
            {
                sale.Sale_Type = "VOID";
                Tenders nullTenders = null;
                var     fileName    = string.Empty;
                var     rePrint     = false;
                Stream  signature;
                fs = _receiptManager.Print_Receipt(sale.TillNumber, null, ref sale, ref nullTenders,
                                                   true, ref fileName, ref rePrint, out signature, userCode);
            }

            var newSale = new Sale
            {
                Sale_Num =
                    _saleManager.Clear_Sale(sale, sale.Sale_Num, sale.TillNumber, userCode, "VOID", null, true, true,
                                            false, out errorMessage)
            };

            CacheManager.DeleteCurrentSaleForTill(sale.TillNumber, sale.Sale_Num);
            newSale.TillNumber = sale.TillNumber;
            newSale.Customer   = _customerManager.LoadCustomer(string.Empty);
            newSale.Register   = sale.Register;
            newSale.SaleHead   = new SaleHead();
            newSale.Payment    = false;
            _saleHeadManager.SetSalePolicies(ref newSale);
            _saleManager.SaveTemp(ref newSale, newSale.TillNumber);
            Register register = null;

            _mainManager.SetRegister(ref register, newSale.Register);
            if (register.Customer_Display)
            {
                newSale.CustomerDisplay = _mainManager.DisplayMsgLcd(register,
                                                                     _mainManager.FormatLcdString(register, _resourceManager.GetResString(offSet, 414) + "#:",
                                                                                                  Conversion.Str(newSale.Sale_Num).Trim()), "");
            }
            CacheManager.AddCurrentSaleForTill(newSale.TillNumber, newSale.Sale_Num, newSale);
            Performancelog.Debug($"End,SuspendedSaleManager,VoidSale,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");
            return(newSale);
        }
Esempio n. 11
0
        /// <summary>
        /// Unsuspend Sale
        /// </summary>
        /// <param name="saleNumber">Sale number</param>
        /// <param name="tillNumber">Till number</param>
        /// <param name="userCode">User code</param>
        /// <param name="errorMessage">Error</param>
        /// <returns>Sale</returns>
        public Sale UnsuspendSale(int saleNumber, int tillNumber, string userCode, out ErrorMessage errorMessage)
        {
            var dateStart = DateTime.Now;

            Performancelog.Debug($"Start,SuspendedSaleManager,UnsuspendSale,{string.Empty},{dateStart:hh.mm.ss.ffffff}");

            if (!CanUserSuspendSale(userCode, out errorMessage))
            {
                return(new Sale());
            }

            string sqlQuery;
            var    shareSusp = _policyManager.SHARE_SUSP;

            if (shareSusp)
            {
                sqlQuery = "SELECT * FROM   SusHead  WHERE  SusHead.Sale_No = " + Convert.ToString(saleNumber);
            }
            else
            {
                sqlQuery = "SELECT * FROM   SusHead  WHERE  SusHead.Sale_No = " + Convert.ToString(saleNumber) + " AND SusHead.TILL=" + tillNumber;
            }

            var susHead = _suspendedSaleService.GetAllSuspendedSale(sqlQuery);
            var offSet  = _policyManager.LoadStoreInfo().OffSet;

            if (susHead == null || susHead.Count == 0)
            {
                //"Not a Suspended Sale"
                errorMessage = new ErrorMessage
                {
                    MessageStyle = _resourceManager.CreateMessage(offSet, 0, 8107, saleNumber),
                    StatusCode   = HttpStatusCode.NotFound
                };
                return(null);
            }

            _suspendedSaleService.UpdateCardSaleForUnSuspend(shareSusp, tillNumber, saleNumber);
            var sale = _suspendedSaleService.GetSuspendedSale(tillNumber, saleNumber, shareSusp);

            sale.Customer = _customerManager.LoadCustomer(sale.Customer.Code);
            if (string.IsNullOrEmpty(sale.CouponID))
            {
                _saleManager.ReCompute_Coupon(ref sale);
            }
            var saleLines = sale.Sale_Lines;

            if (sale.Sale_Totals.Sale_Taxes != null)
            {
                _saleHeadManager.Load_Taxes(ref sale);
            }
            sale.Sale_Lines = new Sale_Lines();
            _suspendedSaleService.RemovePreviousTransactionFromDbTemp(tillNumber);
            foreach (Sale_Line saleLine in saleLines)
            {
                var          sl           = saleLine;
                var          quantity     = saleLine.Quantity;
                var          price        = saleLine.price;
                var          amount       = saleLine.Amount;
                var          discountRate = saleLine.Discount_Rate;
                var          discountType = saleLine.Discount_Type;
                ErrorMessage error;
                _saleLineManager.SetPluCode(ref sale, ref sl, sl.PLU_Code, out error);

                if (sl.ProductIsFuel && !sl.IsPropane)
                {
                    sl.Regular_Price = Convert.ToDouble(sl.price);
                }

                if (sl.Gift_Certificate && sl.GiftType == "LocalGift")
                {
                    sl.Description = _resourceManager.GetResString(offSet, 8124) + sl.Gift_Num;
                }
                if (sale.Void_Num != 0)
                {
                    _saleManager.Add_a_Line(ref sale, sl, userCode, tillNumber, out errorMessage, adjust: false, tableAdjust: false, forRefund: true);
                }
                else
                {
                    _saleManager.Add_a_Line(ref sale, sl, userCode, tillNumber, out errorMessage, false, false);
                }

                sl.No_Loading = false;
                if (sl.ScalableItem)
                {
                    sl.Regular_Price = sl.price;
                }

                _saleLineManager.SetPrice(ref sl, price);
                _saleLineManager.SetQuantity(ref sl, quantity);
                _saleLineManager.SetAmount(ref sl, amount);
                saleLine.Discount_Type = discountType;
                _saleLineManager.SetDiscountRate(ref sl, discountRate);
                sl.No_Loading = false; // It has to be set back to false, otherwise if the user changes the qty or price in the POS screen after unsuspend, the amount will not be right

                if (shareSusp)
                {
                    // modGlobalFunctions.Load_CardSales(Chaps_Main.dbTill, (short)0, saleNumber, SL.Line_Num);
                }
            }

            _saleManager.Sale_Discount(ref sale, Convert.ToDecimal(sale.Sale_Totals.Invoice_Discount),
                                       Convert.ToString(sale.Sale_Totals.Invoice_Discount_Type), false);
            _suspendedSaleService.DeleteUnsuspend(shareSusp, tillNumber, saleNumber);
            _suspendedSaleService.DeleteCardSaleFromDbTemp(saleNumber);
            sale.Sale_Type = "CANCEL";
            //Update Sale object in Cache
            CacheManager.AddCurrentSaleForTill(tillNumber, sale.Sale_Num, sale);
            Performancelog.Debug($"End,SuspendedSaleManager,UnsuspendSale,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");
            Register register = new Register();

            _mainManager.SetRegister(ref register, sale.Register);
            //Added to display invoice# to customer display
            if (register.Customer_Display)
            {
                sale.CustomerDisplay = _mainManager.DisplayMsgLcd(register,
                                                                  _mainManager.FormatLcdString(register, _resourceManager.GetResString(offSet, 414) + "#:",
                                                                                               Conversion.Str(saleNumber).Trim()), "");
            }
            return(sale);
        }
Esempio n. 12
0
        /// <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);
        }
Esempio n. 13
0
        /// <summary>
        /// Deactivate Givex Card
        /// </summary>
        /// <param name="givexCardNumber">givexCardNumber</param>
        /// <param name="givexPrice">givexPrice</param>
        /// <param name="userCode">userCode</param>
        /// <param name="tillNumber">tillNumber</param>
        /// <param name="saleNumber">saleNumber</param>
        /// <param name="stockCode">stockCode</param>
        /// <param name="givexReceipt">Givex receipt</param>
        /// <param name="errorMessage">errorMessage</param>
        /// <returns>Sale</returns>
        public Sale DeactivateGivexCard(string givexCardNumber, decimal givexPrice, string userCode,
                                        int tillNumber, int saleNumber, string stockCode, out Report givexReceipt, out ErrorMessage errorMessage)
        {
            var dateStart = DateTime.Now;

            Performancelog.Debug($"Start,GivexManager,DeactivateGivexCard,{string.Empty},{DateTime.Now:hh.mm.ss.ffffff}");
            givexReceipt = null;
            var sale = _saleManager.GetCurrentSale(saleNumber, tillNumber, 0, userCode, out errorMessage);

            if (!string.IsNullOrEmpty(errorMessage.MessageStyle.Message))
            {
                return(null);
            }
            var firstOrDefault = sale.Sale_Lines.FirstOrDefault(x => x.Gift_Num == givexCardNumber);

            if (firstOrDefault == null)
            {
                var   store  = CacheManager.GetStoreInfo();
                short offSet = store?.OffSet ?? (short)0;
                errorMessage.MessageStyle = _resourceManager.CreateMessage(offSet, 32, 93, null, CriticalOkMessageType);
                errorMessage.StatusCode   = HttpStatusCode.NotAcceptable;
                return(null);
            }

            short lineNumber = firstOrDefault.Line_Num;// _saleService.GetSaleLineFromDbTemp(givexCardNumber);

            var saleLine = sale.Sale_Lines[lineNumber];

            var newLine = _saleLineManager.CreateNewSaleLine();


            var amount = saleLine.Amount;
            var refNum = saleLine.Serial_No;

            if (!IsValidPrice(2, givexPrice, out errorMessage))
            {
                return(null);
            }
            GiveXReceiptType givex;

            if (_givexClientManager.DeactivateGiveX(givexCardNumber.Trim(), amount, saleNumber, refNum, userCode, out errorMessage, out givex))
            {
                givexReceipt = _receiptManager.Print_GiveX_Receipt(givex);

                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(0 - amount);

                        _saleLineManager.SetPrice(ref newLine, Conversion.Val(0 - 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,DeactivateGivexCard,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");
            return(sale);
        }
        /// <summary>
        /// Return Sale Items
        /// </summary>
        /// <param name="tillNumber">Till number</param>
        /// <param name="loggedInTillNumber">Logged till number</param>
        /// <param name="saleNumber">Sale number</param>
        /// <param name="saleLines">Sale lines</param>
        /// <param name="isCorrection">Correction sale or not</param>
        /// <param name="user">User</param>
        /// <param name="reasonCode">Reason code</param>
        /// <param name="message">Error</param>
        /// <param name="saleLineMessages">Sale line messages</param>
        /// <param name="reasonType">Reason type</param>
        /// <returns>Sale</returns>
        public Sale ReturnSaleItems(User user, int tillNumber, int loggedInTillNumber, int saleNumber, int[] saleLines, bool isCorrection, string reasonType, string reasonCode, out ErrorMessage message, out List <ErrorMessage> saleLineMessages)
        {
            var      sale     = new Sale();
            DateTime saleDate = DateTime.Now.AddDays(-Convert.ToInt16(_policyManager.GetPol("RES_DAYS", null)));

            saleLineMessages = new List <ErrorMessage>();

            if (!IsUserAbleToReturn(user, out message))
            {
                return(sale);
            }
            Sale_Line sl;
            bool      blnRecReason = false;
            bool      isReturnable;
            bool      isSaleFound;

            sale = _returnSaleService.GetSaleBySaleNumber(saleNumber, tillNumber, saleDate, _policyManager.TE_Type, _policyManager.TE_GETNAME, _policyManager.TAX_EXEMPT_GA, _policyManager.DefaultCust, _policyManager.DEF_CUST_CODE, out isSaleFound, out isReturnable);
            var offSet = _policyManager.LoadStoreInfo().OffSet;

            if (!isSaleFound)
            {
                message = new ErrorMessage
                {
                    MessageStyle = _resourceManager.CreateMessage(offSet, 40, 98, null)
                };
                return(sale);
            }

            if (!isReturnable)
            {
                message = new ErrorMessage
                {
                    MessageStyle = _resourceManager.CreateMessage(offSet, 40, 98, saleDate)
                };
                return(sale);
            }

            var sal = _saleService.GetSaleByTillNumber(tillNumber);// _saleService.GetSalesFromDbTemp(tillNumber);

            if (sal == null)
            {
                sale.Sale_Num = _saleManager.GetCurrentSaleNo(tillNumber, user.Code, out message);
            }
            else
            {
                sale.Sale_Num = sal.Sale_Num;
            }
            sale.TillNumber = (byte)loggedInTillNumber;
            _saleHeadManager.SetSalePolicies(ref sale);
            var sLines = _returnSaleService.GetSaleLineBySaleNumber(saleNumber, tillNumber, saleDate, sale.Customer.DiscountType, _policyManager.TE_Type, _policyManager.TAX_EXEMPT);

            //_suspendedSaleService.RemovePreviousTransactionFromDbTemp(tillNumber);
            foreach (var saleLine in sLines)
            {
                saleLine.PRICE_DEC  = CommonUtility.GetShortValue(_policyManager.GetPol("PRICE_DEC", saleLine));
                saleLine.QUANT_DEC  = CommonUtility.GetShortValue(_policyManager.GetPol("QUANT_DEC", saleLine));
                saleLine.RET_REASON = _policyManager.GetPol("RET_REASON", saleLine);
                if (saleLines.ToList().Exists(x => x == CommonUtility.GetIntergerValue(saleLine.Line_Num)))
                {
                    if (_policyManager.GetPol("ACCEPT_RET", saleLine) && saleLine.GiftType != "GiveX")
                    {
                        var          newSaleLine  = saleLine;
                        var          quantity     = saleLine.Quantity;
                        var          price        = saleLine.price;
                        var          amount       = saleLine.Amount;
                        var          discountRate = saleLine.Discount_Rate;
                        var          discountType = saleLine.Discount_Type;
                        ErrorMessage error;
                        _saleLineManager.SetPluCode(ref sale, ref newSaleLine, newSaleLine.PLU_Code, out error);

                        if (newSaleLine.ProductIsFuel && !newSaleLine.IsPropane)
                        {
                            newSaleLine.Regular_Price = Convert.ToDouble(newSaleLine.price);
                        }

                        if (newSaleLine.Gift_Certificate && newSaleLine.GiftType == "LocalGift")
                        {
                            newSaleLine.Description = _resourceManager.GetResString(offSet, 8124) + newSaleLine.Gift_Num;
                        }
                        _saleManager.Add_a_Line(ref sale, saleLine, user.Code, sale.TillNumber, out message, adjust: false, tableAdjust: false,
                                                forRefund: true);

                        newSaleLine.No_Loading = false;
                        if (newSaleLine.ScalableItem)
                        {
                            newSaleLine.Regular_Price = newSaleLine.price;
                        }

                        _saleLineManager.SetPrice(ref newSaleLine, price);
                        _saleLineManager.SetQuantity(ref newSaleLine, quantity);
                        _saleLineManager.SetAmount(ref newSaleLine, amount);
                        saleLine.Discount_Type = discountType;
                        _saleLineManager.SetDiscountRate(ref newSaleLine, discountRate);
                        newSaleLine.No_Loading = false; // It has to be set back to false, otherwise if the user changes the qty or price in the POS screen after unsuspend, the amount will not be right
                    }
                    else
                    {
                        saleLineMessages.Add(new ErrorMessage
                        {
                            MessageStyle = _resourceManager.CreateMessage(offSet, 0, 8109, saleLine.Stock_Code + " " + saleLine.Description,
                                                                          CriticalOkMessageType)
                        });
                    }
                }
            }
            sale.ForCorrection = isCorrection; // 06/24/05 Nancy added ForCorrection
                                               //    CL = "" ' code
                                               //SaleMain.Default.lblCustName.Text = sale.Customer.Name;
            foreach (var tempLoopVarSl in sLines)
            {
                sl            = tempLoopVarSl;
                sl.No_Loading = false;
            }
            sale.LoadingTemp = false;

            foreach (var tempLoopVarSl in sLines)
            {
                sl = tempLoopVarSl;
                if (_policyManager.GetPol("RET_REASON", sl))
                {
                    blnRecReason = true;
                    break;
                }
            }

            if (blnRecReason)
            {
                ReasonType rType;
                Enum.TryParse(reasonType, true, out rType);
                var returnReason = (char)rType != '\0' ? _reasonService.GetReturnReason(reasonCode, (char)rType)
                    : new Return_Reason {
                    RType = "R"
                };

                foreach (var tempLoopVarSl in sLines)
                {
                    sl = tempLoopVarSl;
                    _saleManager.Line_Reason(ref sale, ref sl, returnReason);
                }
            }
            CacheManager.AddCurrentSaleForTill(sale.TillNumber, sale.Sale_Num, sale);
            return(sale);
        }
        /// <summary>
        /// Return Sale
        /// </summary>
        /// <param name="user">User</param>
        /// <param name="saleNumber">Sale number</param>
        /// <param name="tillNumber">Till number</param>
        /// <param name="saleTillNumber"></param>
        /// <param name="correction">Correction sale or not</param>
        /// <param name="reasonCode">Reason code</param>
        /// <param name="message">Error</param>
        /// <param name="reasonType">Reason type</param>
        /// <param name="saleLineMessages">Sale line messages</param>
        /// <param name="report"></param>
        /// <param name="fileName"></param>
        /// <returns>Sale</returns>
        public Sale ReturnSale(User user, int saleNumber, int tillNumber, int saleTillNumber, bool correction,
                               string reasonType, string reasonCode, out ErrorMessage message, out List <ErrorMessage>
                               saleLineMessages, out Report report, out string fileName)
        {
            Sale     sale     = new Sale();
            DateTime saleDate = DateTime.Now.AddDays(-Convert.ToInt16(_policyManager.GetPol("RES_DAYS", null)));

            saleLineMessages = new List <ErrorMessage>();
            report           = null;
            fileName         = string.Empty;
            if (!IsUserAbleToReturn(user, out message))
            {
                return(sale);
            }

            Sale_Line sl;
            var       blnRecReason = false;
            bool      isReturnable;
            bool      isSaleFound;

            sale = _returnSaleService.GetSaleBySaleNumber(saleNumber, saleTillNumber, saleDate, _policyManager.TE_Type, _policyManager.TE_GETNAME, _policyManager.TAX_EXEMPT_GA, _policyManager.DefaultCust, _policyManager.DEF_CUST_CODE, out isSaleFound, out isReturnable);
            var offSet = _policyManager.LoadStoreInfo().OffSet;

            if (!isSaleFound)
            {
                message = new ErrorMessage
                {
                    MessageStyle = _resourceManager.CreateMessage(offSet, 40, 98, null)
                };
                return(sale);
            }

            if (!isReturnable)
            {
                message = new ErrorMessage
                {
                    MessageStyle = _resourceManager.CreateMessage(offSet, 40, 95, saleDate)
                };
                return(sale);
            }
            var sal = _saleService.GetSaleByTillNumber(tillNumber);// _saleService.GetSalesFromDbTemp(tillNumber);

            sale.Sale_Num   = sal?.Sale_Num ?? _saleManager.GetCurrentSaleNo(tillNumber, user.Code, out message);
            sale.TillNumber = (byte)tillNumber;
            _saleHeadManager.SetSalePolicies(ref sale);
            var saleLines = _returnSaleService.GetSaleLineBySaleNumber(saleNumber, saleTillNumber, saleDate, sale.Customer.DiscountType, _policyManager.TE_Type, _policyManager.TAX_EXEMPT);

            //_suspendedSaleService.RemovePreviousTransactionFromDbTemp(tillNumber);

            foreach (var saleLine in saleLines)
            {
                saleLine.PRICE_DEC = CommonUtility.GetShortValue(_policyManager.GetPol("PRICE_DEC", saleLine));
                saleLine.QUANT_DEC = CommonUtility.GetShortValue(_policyManager.GetPol("QUANT_DEC", saleLine));
                if (_policyManager.GetPol("ACCEPT_RET", saleLine) && saleLine.GiftType != "GiveX")
                {
                    var newSaleLine = saleLine;
                    newSaleLine.Till_Num = sale.TillNumber;
                    var          quantity     = saleLine.Quantity;
                    var          price        = saleLine.price;
                    var          amount       = saleLine.Amount;
                    var          discountRate = saleLine.Discount_Rate;
                    var          discountType = saleLine.Discount_Type;
                    ErrorMessage error;
                    _saleLineManager.SetPluCode(ref sale, ref newSaleLine, newSaleLine.PLU_Code, out error);

                    if (newSaleLine.ProductIsFuel && !newSaleLine.IsPropane)
                    {
                        newSaleLine.Regular_Price = Convert.ToDouble(newSaleLine.price);
                    }

                    if (newSaleLine.Gift_Certificate && newSaleLine.GiftType == "LocalGift")
                    {
                        newSaleLine.Description = _resourceManager.GetResString(offSet, 8124) + newSaleLine.Gift_Num;
                    }
                    _saleManager.Add_a_Line(ref sale, newSaleLine, user.Code, sale.TillNumber, out message, adjust: false, tableAdjust: false,
                                            forRefund: true);

                    newSaleLine.No_Loading = false;
                    if (newSaleLine.ScalableItem)
                    {
                        newSaleLine.Regular_Price = newSaleLine.price;
                    }

                    _saleLineManager.SetPrice(ref newSaleLine, price);
                    _saleLineManager.SetQuantity(ref newSaleLine, quantity);
                    _saleLineManager.SetAmount(ref newSaleLine, amount);
                    saleLine.Discount_Type = discountType;
                    _saleLineManager.SetDiscountRate(ref newSaleLine, discountRate);
                    newSaleLine.No_Loading = false; // It has to be set back to false, otherwise if the user changes the qty or price in the POS screen after unsuspend, the amount will not be right
                }
                else
                {
                    saleLineMessages.Add(new ErrorMessage
                    {
                        MessageStyle = _resourceManager.CreateMessage(offSet, 0, 8109, saleLine.Stock_Code + " " + saleLine.Description,
                                                                      CriticalOkMessageType)
                    });
                }
            }

            _saleManager.Sale_Discount(ref sale, Convert.ToDecimal(sale.Sale_Totals.Invoice_Discount),
                                       Convert.ToString(sale.Sale_Totals.Invoice_Discount_Type), false);
            sale.ForCorrection = correction; // 06/24/05 Nancy added ForCorrection
                                             //    CL = "" ' code
                                             //SaleMain.Default.lblCustName.Text = sale.Customer.Name;
            foreach (var tempLoopVarSl in saleLines)
            {
                sl            = tempLoopVarSl;
                sl.No_Loading = false;
            }
            sale.LoadingTemp = false;

            foreach (var tempLoopVarSl in saleLines)
            {
                sl = tempLoopVarSl;
                if (!_policyManager.GetPol("RET_REASON", sl))
                {
                    continue;
                }
                blnRecReason = true;
                break;
            }

            if (blnRecReason)
            {
                ReasonType rType;
                Enum.TryParse(reasonType, true, out rType);
                var returnReason = (char)rType != '\0' ? _reasonService.GetReturnReason(reasonCode, (char)rType) : new Return_Reason {
                    RType = "R"
                };
                foreach (var tempLoopVarSl in saleLines)
                {
                    sl = tempLoopVarSl;
                    _saleManager.Line_Reason(ref sale, ref sl, returnReason);
                }
            }
            _saleManager.SaveTemp(ref sale, tillNumber);
            //Update Sale object in Cache
            sale.ReverseRunaway  = sale.Sale_Type == "RUNAWAY" && sale.Sale_Amount > 0;  //
            sale.ReversePumpTest = sale.Sale_Type == "PUMPTEST" && sale.Sale_Amount > 0; //
            if (sale.ReverseRunaway)
            {
                var newLineMessage = new ErrorMessage
                {
                    MessageStyle = _resourceManager.CreateMessage(offSet, 11, 25, null)
                };
                saleLineMessages.Add(newLineMessage);
                Tenders nullTenders = null;
                fileName = Constants.RunAwayFile;
                var    file    = "Runaway";
                var    rePrint = false;
                Stream signature;
                sale.Sale_Type = "RUNAWAY";
                report         = _receiptManager.Print_Receipt(tillNumber, null, ref sale, ref nullTenders, true, ref file,
                                                               ref rePrint, out signature, user.Code);
                _saleManager.Clear_Sale(sale, sale.Sale_Num, sale.TillNumber, user.Code, "RUNAWAY", null, false, true, false, out message);

                ErrorMessage error;
                sale = _saleManager.InitializeSale(tillNumber, sale.Register, user.Code, out error);
            }
            if (sale.ReversePumpTest)
            {
                var newLineMessage = new ErrorMessage
                {
                    MessageStyle = _resourceManager.CreateMessage(offSet, 11, 27, null)
                };
                saleLineMessages.Add(newLineMessage);
                Tenders nullTenders = null;
                fileName = Constants.PumpTestFile;
                var    file    = "PumpTest";
                var    rePrint = false;
                Stream signature;
                sale.Sale_Type = "PUMPTEST";
                report         = _receiptManager.Print_Receipt(tillNumber, null, ref sale, ref nullTenders, true, ref file, ref rePrint, out signature, user.Code);
                _saleManager.Clear_Sale(sale, sale.Sale_Num, sale.TillNumber, user.Code, "PUMPTEST", null, false, true, false, out message);
                ErrorMessage error;
                sale = _saleManager.InitializeSale(tillNumber, sale.Register, user.Code, out error);
            }
            CacheManager.AddCurrentSaleForTill(sale.TillNumber, sale.Sale_Num, sale);
            return(sale);
        }