/// <summary>
        /// Method to get overlimit details
        /// </summary>
        /// <param name="tillNumber">Till number</param>
        /// <param name="saleNumber">Sale number</param>
        /// <param name="error">Error message</param>
        /// <returns>Over limit response</returns>
        public OverLimitResponse GetOverLimitDetails(int tillNumber, int saleNumber, out ErrorMessage error)
        {
            error = new ErrorMessage();
            var result = new OverLimitResponse
            {
                GasReasons     = new List <TaxExemptReasonResponse>(),
                TobaccoReasons = new List <TaxExemptReasonResponse>(),
                PropaneReasons = new List <TaxExemptReasonResponse>()
            };

            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);
            }

            mPrivateGlobals.theSystem = CacheManager.GetTeSystemForTill(tillNumber, saleNumber);
            if (mPrivateGlobals.theSystem == null)
            {
                error = new ErrorMessage
                {
                    MessageStyle = new MessageStyle {
                        Message = "Request is Invalid", MessageType = 0
                    },
                    StatusCode = HttpStatusCode.BadRequest
                };
                return(null);
            }

            var oTeSale = CacheManager.GetTaxExemptSaleForTill(tillNumber, saleNumber);

            if (oTeSale == null)
            {
                error = new ErrorMessage
                {
                    MessageStyle = new MessageStyle {
                        Message = "Request is Invalid", MessageType = 0
                    },
                    StatusCode = HttpStatusCode.BadRequest
                };
                return(null);
            }

            _teSystemManager.GetAllReasons(ref mPrivateGlobals.theSystem);
            _teSystemManager.GetAllLimits(ref mPrivateGlobals.theSystem);
            TaxExemptReason ter;

            if (oTeSale.GasOverLimit)
            {
                if (mPrivateGlobals.theSystem.GasReasons.Count > 0)
                {
                    foreach (TaxExemptReason tempLoopVarTer in mPrivateGlobals.theSystem.GasReasons)
                    {
                        ter = tempLoopVarTer;
                        result.GasReasons.Add(
                            new TaxExemptReasonResponse
                        {
                            Reason          = ter.Code + "-" + ter.Description,
                            ExplanationCode = ter.ExplanationCode
                        });
                    }
                }
                result.IsGasReasons = true;
            }


            if (oTeSale.TobaccoOverLimit)
            {
                foreach (TaxExemptReason tempLoopVarTer in mPrivateGlobals.theSystem.TobaccoReasons)
                {
                    ter = tempLoopVarTer;
                    result.TobaccoReasons.Add(
                        new TaxExemptReasonResponse
                    {
                        Reason          = ter.Code + "-" + ter.Description,
                        ExplanationCode = ter.ExplanationCode
                    });
                }
                result.IsTobaccoReasons = true;
            }


            if (oTeSale.PropaneOverLimit)
            {
                foreach (TaxExemptReason tempLoopVarTer in mPrivateGlobals.theSystem.PropaneReasons)
                {
                    ter = tempLoopVarTer;
                    result.PropaneReasons.Add(
                        new TaxExemptReasonResponse
                    {
                        Reason          = ter.Code + "-" + ter.Description,
                        ExplanationCode = ter.ExplanationCode
                    });
                }
                result.IsPropaneReasons = true;
            }
            CacheManager.AddTaxExemptSaleForTill(tillNumber, saleNumber, oTeSale);
            CacheManager.AddTeSystemForTill(tillNumber, saleNumber, mPrivateGlobals.theSystem);
            result.TaxExemptSale = GetTaxExemptSaleModel(oTeSale);

            return(result);
        }
        /// <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);
        }