コード例 #1
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);
        }