public HttpResponseMessage PaymentByAccount(UpdateAccountTenderModel tenderModel)
        {
            var dateStart = DateTime.Now;

            _performancelog.Debug($"Start,PaymentController,PaymentByAccount,{string.Empty},{dateStart:hh.mm.ss.ffffff}");

            ErrorMessage        errorMessage;
            string              userCode;
            HttpResponseMessage httpResponseMessage;

            if (GetUserCode(out userCode, out httpResponseMessage))
            {
                return(httpResponseMessage);
            }
            var updatedTenders = _paymentManager.ByAccount(tenderModel.SaleNumber,
                                                           tenderModel.TillNumber, tenderModel.TransactionType,
                                                           tenderModel.Tender.AmountEntered.HasValue ? tenderModel.Tender.AmountEntered.ToString() : null,
                                                           tenderModel.TillClose, tenderModel.Tender.TenderCode, userCode, tenderModel.PurchaseOrder,
                                                           tenderModel.OverrideArLimit, out errorMessage);

            if (!string.IsNullOrEmpty(errorMessage.MessageStyle.Message))
            {
                return(Request.CreateResponse(errorMessage.StatusCode, new ErrorResponse
                {
                    Error = errorMessage.MessageStyle
                }));
            }

            TenderSummaryModel tenderSummary = GetTenderSummary(updatedTenders);

            _performancelog.Debug($"End,PaymentController,PaymentByAccount,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");

            return(Request.CreateResponse(HttpStatusCode.OK, tenderSummary));
        }
        public HttpResponseMessage PaymentByVendorCoupon([FromBody] PaymentByVCouponModel vendorCouponModel)
        {
            var dateStart = DateTime.Now;

            _performancelog.Debug($"Start,PaymentController,PaymentByVCoupon,{string.Empty},{dateStart:hh.mm.ss.ffffff}");
            ErrorMessage        errorMessage;
            string              userCode;
            HttpResponseMessage httpResponseMessage;

            if (GetUserCode(out userCode, out httpResponseMessage))
            {
                return(httpResponseMessage);
            }
            var updatedTenders = _paymentManager.PaymentByVCoupon(vendorCouponModel.SaleNumber,
                                                                  vendorCouponModel.TillNumber, vendorCouponModel.TenderCode, userCode, out errorMessage);

            if (!string.IsNullOrEmpty(errorMessage.MessageStyle.Message))
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, new ErrorResponse
                {
                    Error = errorMessage.MessageStyle
                }));
            }
            TenderSummaryModel tenderSummary = GetTenderSummary(updatedTenders);

            _performancelog.Debug($"End,PaymentController,PaymentByVCoupon,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");

            return(Request.CreateResponse(HttpStatusCode.OK, tenderSummary));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Tender summary mapper
        /// </summary>
        /// <param name="updatedTenders"></param>
        /// <param name="issueStoreCreditMessage"></param>
        /// <param name="selectedTenders"></param>
        /// <returns></returns>
        public static TenderSummaryModel GetTenderSummaryModel(Tenders updatedTenders, string issueStoreCreditMessage,
                                                               IEnumerable <Tender> selectedTenders)
        {
            var tenderSummary = new TenderSummaryModel
            {
                Summary1          = updatedTenders.Summary1,
                Summary2          = updatedTenders.Summary2,
                OutstandingAmount = Math.Round(Convert.ToDouble(updatedTenders.Tend_Totals.Change), 2) > 0.0D
                    ? updatedTenders.Tend_Totals.Change.ToString(Constants.ChangeFormat)
                    : 0.ToString(Constants.ChangeFormat),
                EnableCompletePayment   = updatedTenders.EnableCompletePayment,
                DisplayNoReceiptButton  = updatedTenders.DisplayNoReceiptButton,
                IssueStoreCreditMessage = issueStoreCreditMessage,
                EnableRunAway           = updatedTenders.EnableRunAway,
                EnablePumpTest          = updatedTenders.EnablePumpTest,
                Tenders = (from tender in selectedTenders
                           select new TenderResponseModel
                {
                    TenderCode = tender.Tender_Code,
                    TenderName = tender.Tender_Name,
                    TenderClass = tender.Tender_Class,
                    AmountEntered = tender.Amount_Entered == 0 ? "" : tender.Amount_Entered.ToString(Constants.CurrencyFormat),
                    AmountValue = tender.Amount_Used == 0 ? "" : tender.Amount_Used.ToString(Constants.CurrencyFormat),
                    IsEnabled = string.IsNullOrEmpty(tender.Credit_Card.Cardnumber),
                    MaximumValue = tender.MaxAmount,
                    MinimumValue = tender.MinAmount,
                    Image = tender.Image
                }).ToList(),
                CustomerDisplay = updatedTenders.CustomerDisplay
            };

            return(tenderSummary);
        }
        public HttpResponseMessage PaymentByCoupon([FromBody] PaymentModel paymentModel)
        {
            var dateStart = DateTime.Now;

            _performancelog.Debug($"Start,PaymentController,PaymentByCoupon,{string.Empty},{dateStart:hh.mm.ss.ffffff}");

            ErrorMessage        errorMessage;
            string              userCode;
            HttpResponseMessage httpResponseMessage;

            if (GetUserCode(out userCode, out httpResponseMessage))
            {
                return(httpResponseMessage);
            }
            var updatedTenders = _paymentManager.ByCoupon(paymentModel.SaleNumber,
                                                          paymentModel.TillNumber, paymentModel.TransactionType, paymentModel.CouponNumber,
                                                          paymentModel.TillClose, paymentModel.TenderCode, userCode,
                                                          out errorMessage);

            //Added scenario when "Amount Cannot Exceed value of sale."
            //should be displayed and countinue to use the coupon amount
            var store        = CacheManager.GetStoreInfo();
            var offSet       = store?.OffSet ?? 0;
            var messageStyle = _resourceManager.CreateMessage(offSet, 14, 88, null, MessageType.OkOnly);
            var messages     = new List <object>();

            if (messageStyle.Message.Equals(errorMessage.MessageStyle.Message))
            {
                var msg = new
                {
                    error = messageStyle
                };
                messages.Add(msg);
            }
            else
            {
                if (!string.IsNullOrEmpty(errorMessage.MessageStyle.Message))
                {
                    return(Request.CreateResponse(errorMessage.StatusCode, new ErrorResponse
                    {
                        Error = errorMessage.MessageStyle
                    }));
                }
            }
            TenderSummaryModel tenderSummary = GetTenderSummary(updatedTenders);

            tenderSummary.Messages = messages;
            _performancelog.Debug($"End,PaymentController,PaymentByCoupon,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");

            return(Request.CreateResponse(HttpStatusCode.OK, tenderSummary));
        }
        public HttpResponseMessage PaymentByCard([FromBody] PaymentModel paymentModel)
        {
            var dateStart = DateTime.Now;

            _performancelog.Debug($"Start,PaymentController,PaymentByCard,{string.Empty},{dateStart:hh.mm.ss.ffffff}");

            ErrorMessage        errorMessage;
            string              userCode;
            HttpResponseMessage httpResponseMessage;

            if (GetUserCode(out userCode, out httpResponseMessage))
            {
                return(httpResponseMessage);
            }
            Report merchantStream = null;
            Report customerStream = null;
            var    updatedTenders = _paymentManager.ByCard(paymentModel.SaleNumber,
                                                           paymentModel.TillNumber,
                                                           paymentModel.CardNumber,
                                                           userCode,
                                                           paymentModel.TransactionType,
                                                           paymentModel.PONumber,
                                                           paymentModel.AmountUsed,
                                                           ref merchantStream,
                                                           ref customerStream,
                                                           out errorMessage);

            if (!string.IsNullOrEmpty(errorMessage.MessageStyle.Message))
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, new ErrorResponse
                {
                    Error = errorMessage.MessageStyle
                }));
            }

            TenderSummaryModel tenderSummary = GetTenderSummary(updatedTenders);

            if (merchantStream != null || customerStream != null)
            {
                tenderSummary.Receipts = new List <ReportModel>();
                if (merchantStream != null)
                {
                    tenderSummary.Receipts.Add(new ReportModel
                    {
                        ReportName    = merchantStream.ReportName,
                        ReportContent = merchantStream.ReportContent,
                        Copies        = 1
                    });
                }
                if (customerStream != null)
                {
                    tenderSummary.Receipts.Add(new ReportModel
                    {
                        ReportName    = customerStream.ReportName,
                        ReportContent = customerStream.ReportContent,
                        Copies        = 1
                    });
                }
            }
            _performancelog.Debug($"End,PaymentController,PaymentByCard,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");

            return(Request.CreateResponse(HttpStatusCode.OK, tenderSummary));
        }