public PSRefund GetPSRefund(int TILL_NUM, int SALE_NO, string TransactionID)
        {
            var dateStart = DateTime.Now;

            Performancelog.Debug($"Start,PaymentSourceManager,GetPSRefund,{string.Empty},{DateTime.Now:hh.mm.ss.ffffff}");
            PSRefund psr;
            Sale     sale = CacheManager.GetCurrentSaleForTill(TILL_NUM, SALE_NO);

            if (sale != null)
            {
                foreach (Sale_Line sl in sale.Sale_Lines)
                {
                    if (sl.Serial_No == TransactionID)
                    {
                        psr           = new PSRefund();
                        psr.UpcNumber = sl.Stock_Code;
                        psr.Amount    = string.Format("{0:0.00}", sl.Amount);
                        psr.Name      = sl.Description;
                        return(psr);
                    }
                }
            }
            psr = _PaymentSourceService.GetPSRefund(TransactionID);
            Performancelog.Debug($"End,PaymentSourceManager,GetPSRefund,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");
            return(psr);
        }
        public List <PSTransaction> GetPSTransactions(int TILL_NUM, int SALE_NO, int PastDays)
        {
            List <PSTransaction> olist = new List <PSTransaction>();

            try
            {
                var sale = CacheManager.GetCurrentSaleForTill(TILL_NUM, SALE_NO);
                if (sale != null)
                {
                    olist = (from c in sale.Sale_Lines
                             where !string.IsNullOrEmpty(c.Serial_No)
                             select new PSTransaction()
                    {
                        TransactionID = c.Serial_No,
                        SALE_DATE = string.Format("{0:MM-dd-yyyy}", DateTime.Now),
                        STOCK_CODE = c.Stock_Code,
                        DESCRIPT = c.Description,
                        Amount = string.Format("{0:0.00}", c.Amount)
                    }).ToList();
                }
                List <PSTransaction> olist1 = _PaymentSourceService.GetPSTransactions(PastDays);
                olist = olist.Union(olist1).ToList();
            }
            catch (Exception ex)
            {
                Performancelog.Error("PaymentSourceManager.GetCurTransactions(): " + ex.Message);
            }
            return(olist);
        }
        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);
        }
Exemple #4
0
        /// <summary>
        /// Method to delete uncomplete prepay
        /// </summary>
        /// <param name="pumpId">Pump Id</param>
        /// <param name="saleNumber">Sale number</param>
        /// <param name="tillNumber">Till number</param>
        /// <param name="error">Error</param>
        /// <returns>Sale</returns>
        public Sale DeleteUnCompletePrepay(int pumpId, int saleNumber, int tillNumber, out ErrorMessage error)
        {
            var sale   = CacheManager.GetCurrentSaleForTill(tillNumber, saleNumber);
            var offSet = _policyManager.LoadStoreInfo().OffSet;

            if (sale?.Sale_Lines?.Count > 0)
            {
                //Chaps_Main.DisplayMessage(this, (short)60, temp_VbStyle, null, (byte)0);
                error = new ErrorMessage
                {
                    MessageStyle = _resourceManager.CreateMessage(offSet, 36, 60, null, CriticalOkMessageType)
                };
                return(null);
            }

            sale = _saleService.GetSaleBySaleNoFromDbTill(ref sale, tillNumber, saleNumber);
            var saleLine = _saleService.GetPrepaySaleLine(saleNumber, tillNumber);

            if (sale == null || saleLine == null)
            {
                //MsgBoxStyle temp_VbStyle2 = (int)MsgBoxStyle.Critical + MsgBoxStyle.OkOnly;
                //Chaps_Main.DisplayMessage(this, (short)61, temp_VbStyle2, null, (byte)0);
                error = new ErrorMessage
                {
                    MessageStyle = _resourceManager.CreateMessage(offSet, 36, 61, null, CriticalOkMessageType)
                };
                return(null);
            }
            _saleService.UpdateDiscountTender(ref sale);



            var sl = new Sale_Line
            {
                No_Loading = true,
                Dept       = saleLine.Dept,
                Sub_Dept   = saleLine.Sub_Dept,
                Stock_Code = saleLine.Stock_Code,
                Amount     = saleLine.Amount
            };

            _saleLineManager.SetSubDetail(ref sl, saleLine.Sub_Detail);
            _saleLineManager.SetPluCode(ref sale, ref sl, saleLine.PLU_Code, out error);
            _saleLineManager.SetPrice(ref sl, saleLine.price);
            _saleLineManager.SetQuantity(ref sl, saleLine.Quantity * -1);
            sl.Regular_Price = saleLine.Regular_Price;


            if (sale.Customer.GroupID != "" && _policyManager.FuelLoyalty)
            {
                if (sale.Customer.DiscountType == "%")
                {
                    _saleLineManager.SetAmount(ref sl, (saleLine.Amount - Convert.ToDecimal(saleLine.Amount * Convert.ToDecimal(sale.Customer.DiscountRate)) / 100) * (-1));
                }
                else if (sale.Customer.DiscountType == "$")
                {
                    _saleLineManager.SetAmount(ref sl, saleLine.Amount - Convert.ToDecimal(saleLine.Quantity * sale.Customer.DiscountRate) * (-1));
                }
                else
                {
                    _saleLineManager.SetAmount(ref sl, saleLine.Amount * (-1));
                }
            }
            else
            {
                _saleLineManager.SetAmount(ref sl, saleLine.Amount * (-1));
            }

            sl.pumpID     = (byte)pumpId;
            sl.PositionID = saleLine.PositionID;
            sl.GradeID    = saleLine.GradeID;

            sl.User        = UserCode;
            sl.Description = saleLine.Description;
            sale.Sale_Type = "Delete Prepay";

            _saleManager.Add_a_Line(ref sale, sl, "", tillNumber, out error, true);

            return(sale);
        }
Exemple #5
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);
        }
        /// <summary>
        /// Method to save overrlimit
        /// </summary>
        /// <param name="tillNumber">Till number</param>
        /// <param name="saleNumber">Sale number</param>
        /// <param name="userCode">User code</param>
        /// <param name="cobReason">Reason</param>
        /// <param name="txtExplanation">Explaination</param>
        /// <param name="txtLocation">Loaction</param>
        /// <param name="dtpDate">Date</param>
        /// <param name="error">Error</param>
        /// <returns>Aite response</returns>
        public AiteCardResponse DoneOverLimit(int tillNumber, int saleNumber, string userCode, string cobReason, string txtExplanation, string txtLocation, DateTime dtpDate, out ErrorMessage error)
        {
            AiteCardResponse result = new AiteCardResponse();
            var oTeSale             = CacheManager.GetTaxExemptSaleForTill(tillNumber, saleNumber);

            mPrivateGlobals.theSystem = CacheManager.GetTeSystemForTill(tillNumber, saleNumber);

            var sale = CacheManager.GetCurrentSaleForTill(tillNumber, saleNumber);

            if (!_policyManager.USE_OVERRIDE || _policyManager.TE_Type != "AITE")
            {
                error = new ErrorMessage
                {
                    MessageStyle = new MessageStyle
                    {
                        Message     = "Please select AITE Tax Exempt and enable Use override policy in BackOffice",
                        MessageType = 0
                    },
                    StatusCode = HttpStatusCode.BadRequest
                };
                return(result);
            }

            if (sale == null)
            {
                error = new ErrorMessage
                {
                    MessageStyle = new MessageStyle
                    {
                        Message     = "The request is invalid.",
                        MessageType = 0
                    },
                    StatusCode = HttpStatusCode.BadRequest
                };
                return(null);
            }
            if (oTeSale.TobaccoOverLimit)
            {
                if (!ValidExplanation(ref oTeSale, (byte)TeProductType.Tobacco, cobReason, txtExplanation, txtLocation, dtpDate))
                {
                    var offSet = _policyManager.LoadStoreInfo().OffSet;
                    error = new ErrorMessage
                    {
                        MessageStyle = _resourceManager.CreateMessage(offSet, 54, 61, null, YesNoQuestionMessageType),
                        StatusCode   = HttpStatusCode.Forbidden
                    };
                    return(null);
                }
            }

            if (oTeSale.GasOverLimit)
            {
                if (!ValidExplanation(ref oTeSale, (byte)TeProductType.Gas, cobReason, txtExplanation, txtLocation, dtpDate))
                {
                    var offSet = _policyManager.LoadStoreInfo().OffSet;
                    error = new ErrorMessage
                    {
                        MessageStyle = _resourceManager.CreateMessage(offSet, 54, 62, null, YesNoQuestionMessageType),
                        StatusCode   = HttpStatusCode.Forbidden
                    };
                    return(null);
                }
            }

            if (oTeSale.PropaneOverLimit)
            {
                if (!ValidExplanation(ref oTeSale, (byte)TeProductType.Propane, cobReason, txtExplanation, txtLocation, dtpDate))
                {
                    var offSet = _policyManager.LoadStoreInfo().OffSet;
                    error = new ErrorMessage
                    {
                        MessageStyle = _resourceManager.CreateMessage(offSet, 54, 63, null, YesNoQuestionMessageType),
                        StatusCode   = HttpStatusCode.Forbidden
                    };
                    return(null);
                }
            }

            if (oTeSale.Te_Sale_Lines.Count > 0)
            {
                foreach (TaxExemptSaleLine tempLoopVarTesl in oTeSale.Te_Sale_Lines)
                {
                    var tesl      = tempLoopVarTesl;
                    var rowNumber = tesl.Line_Num;
                    var saleLine  = sale.Sale_Lines[rowNumber];


                    if (!(tesl.Amount < 0 && saleLine.IsTaxExemptItem))
                    {
                        saleLine.IsTaxExemptItem = true;
                        _saleLineManager.SetPrice(ref saleLine, tesl.TaxFreePrice);
                        _saleLineManager.SetAmount(ref saleLine, (decimal)tesl.Amount);
                        //saleLine.price = tesl.TaxFreePrice;
                        //saleLine.Amount = (decimal)tesl.Amount;
                    }
                }
                //_saleManager.ReCompute_Totals(ref sale);
            }
            _saleManager.ReCompute_Totals(ref sale);
            var tenders = _tenderManager.GetAllTender(sale.Sale_Num, sale.TillNumber, "Sale", userCode, false, "", out error);

            result.SaleSummary = SaleSummary(sale);

            result.Tenders = tenders;
            return(result);
        }