Ejemplo n.º 1
0
        /// <summary>
        /// Validate amount with tender rules.
        /// </summary>
        /// <param name="amount"></param>
        /// <exception cref="GiftCardException"></exception>
        public void ValidateTenderAmount(decimal amount)
        {
            if (!string.IsNullOrEmpty(validatedCardNumber))
            {
                // Check if the card is issued with different currency.
                if (validatedCardCurrency != ApplicationSettings.Terminal.StoreCurrency)
                {
                    throw new GiftCardException(ApplicationLocalizer.Language.Translate(4324));
                }

                // First check fo gift card balance.
                if (amount > validatedCardBalance)
                {
                    throw new GiftCardException(ApplicationLocalizer.Language.Translate(55411));
                }
                else
                {
                    TenderRequirement tenderReq = new TenderRequirement(this.tenderInfo, amount, true, TransactionAmount);
                    if (!string.IsNullOrEmpty(tenderReq.ErrorText))
                    {
                        throw new GiftCardException(tenderReq.ErrorText);
                    }

                    CardNumber = validatedCardNumber;
                    Balance    = validatedCardBalance;
                    Amount     = amount;
                    Currency   = validatedCardCurrency;
                }
            }
        }
Ejemplo n.º 2
0
        private void amtCustAmounts_AmountChanged(decimal outAmount, string currCode)
        {
            TenderRequirement tenderReq = new TenderRequirement(this.tenderInfo, outAmount, true, balanceAmount);

            if (string.IsNullOrEmpty(tenderReq.ErrorText))
            {
                controlIndex = 1;
                Action(outAmount.ToString());
            }
            else
            {
                using (frmMessage dialog = new frmMessage(tenderReq.ErrorText, MessageBoxButtons.OK, MessageBoxIcon.Stop))
                {
                    // The amount entered is higher than the maximum amount allowed
                    POSFormsManager.ShowPOSForm(dialog);
                }
            }
        }
Ejemplo n.º 3
0
        private void amountViewer1_AmountChanged(decimal outAmount, string currCode)
        {
            TenderRequirement tenderReq = new TenderRequirement(this.tenderInfo, outAmount, true, balanceAmount);

            if (string.IsNullOrEmpty(tenderReq.ErrorText))
            {
                registeredAmount  = outAmount;
                operationDone     = true;
                this.DialogResult = DialogResult.OK;
                Close();
            }
            else
            {
                using (frmMessage dialog = new frmMessage(tenderReq.ErrorText, MessageBoxButtons.OK, MessageBoxIcon.Stop)) //The amount entered is higher than the maximum amount allowed
                {
                    POSFormsManager.ShowPOSForm(dialog);
                }
            }
        }
Ejemplo n.º 4
0
        private void numPad1_EnterButtonPressed()
        {
            TenderRequirement tenderReq = new TenderRequirement(this.tenderInfo, numPad1.EnteredDecimalValue, true, balanceAmount);

            if (string.IsNullOrEmpty(tenderReq.ErrorText))
            {
                controlIndex = 1;
                Action(numPad1.EnteredValue);
            }
            else
            {
                using (frmMessage dialog = new frmMessage(tenderReq.ErrorText, MessageBoxButtons.OK, MessageBoxIcon.Stop))
                {
                    // The amount entered is higher than the maximum amount allowed
                    POSFormsManager.ShowPOSForm(dialog);
                    numPad1.TryAgain();
                }
            }
        }
Ejemplo n.º 5
0
        private void ValidateAmount(decimal amount)
        {
            TenderRequirement tenderReq = new TenderRequirement(this.tenderInfo,
                                                                PosApplication.Instance.Services.Rounding.Round(amount), true, viewModel.Balance);

            if (string.IsNullOrEmpty(tenderReq.ErrorText))
            {
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                this.Close();
            }
            else
            {
                using (frmMessage dialog = new frmMessage(tenderReq.ErrorText, MessageBoxButtons.OK, MessageBoxIcon.Stop)) //The amount entered is higher than the maximum amount allowed
                {
                    POSFormsManager.ShowPOSForm(dialog);
                }

                numCurrNumpad.TryAgain();
            }
        }
Ejemplo n.º 6
0
        private void numPad1_EnterButtonPressed()
        {
            TenderRequirement tenderReq = new TenderRequirement(this.tenderInfo, numCashNumpad.EnteredDecimalValue, true, balanceAmount);

            if (string.IsNullOrEmpty(tenderReq.ErrorText))
            {
                registeredAmount  = numCashNumpad.EnteredDecimalValue;
                registeredAmount  = PosApplication.Instance.Services.Rounding.RoundAmount(registeredAmount, ApplicationSettings.Terminal.StoreId, tenderInfo.TenderID.ToString());
                operationDone     = true;
                this.DialogResult = DialogResult.OK;
                Close();
            }
            else
            {
                using (frmMessage dialog = new frmMessage(tenderReq.ErrorText, MessageBoxButtons.OK, MessageBoxIcon.Stop)) //The amount entered is higher than the maximum amount allowed
                {
                    POSFormsManager.ShowPOSForm(dialog);
                }
                numCashNumpad.TryAgain();
            }
        }
Ejemplo n.º 7
0
        public void AddLoyaltyPayment(IRetailTransaction retailTransaction, ICardInfo cardInfo, decimal amount)
        {
            try
            {
                try
                {
                    NewMessageWindow(50051, LSPosMessageTypeButton.NoButtons, System.Windows.Forms.MessageBoxIcon.Information);

                    this.transaction = (RetailTransaction)retailTransaction;

                    // Getting the loyalty info for the card, how many points have previously been earned
                    LoyaltyItem paymentLoyaltyItem = GetLoyaltyItem(ref cardInfo);

                    if (paymentLoyaltyItem != null)
                    {
                        //customerData.
                        if (this.transaction.Customer == null || string.Equals(this.transaction.Customer.CustomerId, paymentLoyaltyItem.CustID, StringComparison.OrdinalIgnoreCase) == false)
                        {
                            UpdateTransactionWithNewCustomer(paymentLoyaltyItem.CustID);
                        }

                        // if the amount is higher than the "new" NetAmountWithTax, then it is acceptable to lower the amount
                        if (Math.Abs(amount) > Math.Abs(this.transaction.TransSalePmtDiff))
                        {
                            amount = this.transaction.TransSalePmtDiff;
                        }

                        // Getting all possible loyalty posssiblities for the found scheme id
                        DataTable loyaltyPointsTable = GetLoyaltyPointsSchemeFromDB(paymentLoyaltyItem.SchemeID);

                        decimal totalNumberOfPoints = 0;
                        bool    tenderRuleFound     = false;

                        // now we add the points needed to pay current tender
                        totalNumberOfPoints = CalculatePointsForTender(ref tenderRuleFound, cardInfo.TenderTypeId, amount, loyaltyPointsTable);

                        if (tenderRuleFound)
                        {
                            bool    cardIsValid           = false;
                            string  comment               = string.Empty;
                            int     loyaltyTenderTypeBase = 0;
                            decimal pointsEarned          = 0;

                            // check to see if the user can afford so many points
                            GetPointStatus(ref pointsEarned, ref cardIsValid, ref comment, ref loyaltyTenderTypeBase, paymentLoyaltyItem.LoyaltyCardNumber);

                            if ((cardIsValid) && ((LoyaltyTenderTypeBase)loyaltyTenderTypeBase != LoyaltyTenderTypeBase.NoTender))
                            {
                                if (pointsEarned >= (totalNumberOfPoints * -1))
                                {
                                    //customerData.
                                    if (this.transaction.Customer == null || string.Equals(this.transaction.Customer.CustomerId, paymentLoyaltyItem.CustID, StringComparison.OrdinalIgnoreCase) == false)
                                    {
                                        UpdateTransactionWithNewCustomer(paymentLoyaltyItem.CustID);
                                    }

                                    //Add loyalty item to transaction.
                                    this.transaction.LoyaltyItem           = paymentLoyaltyItem;
                                    this.transaction.LoyaltyItem.UsageType = LoyaltyItemUsageType.UsedForLoyaltyTender;

                                    // Gathering tender information
                                    TenderData tenderData = new TenderData(ApplicationSettings.Database.LocalConnection, ApplicationSettings.Database.DATAAREAID);
                                    ITender    tenderInfo = tenderData.GetTender(cardInfo.TenderTypeId, ApplicationSettings.Terminal.StoreId);

                                    // this is the grand total
                                    decimal totalAmountDue = this.transaction.TransSalePmtDiff - amount;

                                    TenderRequirement tenderRequirement = new TenderRequirement((Tender)tenderInfo, amount, true, this.transaction.TransSalePmtDiff);
                                    if (!string.IsNullOrWhiteSpace(tenderRequirement.ErrorText))
                                    {
                                        using (LSRetailPosis.POSProcesses.frmMessage dialog = new LSRetailPosis.POSProcesses.frmMessage(tenderRequirement.ErrorText, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error))
                                        {
                                            LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSForm(dialog);
                                        }
                                    }

                                    //Add a loyalty tender item to transaction.
                                    LoyaltyTenderLineItem loyaltyTenderItem = (LoyaltyTenderLineItem)this.Application.BusinessLogic.Utility.CreateLoyaltyTenderLineItem();
                                    loyaltyTenderItem.CardNumber = paymentLoyaltyItem.LoyaltyCardNumber;
                                    loyaltyTenderItem.CardTypeId = cardInfo.CardTypeId;
                                    loyaltyTenderItem.Amount     = amount;

                                    //tenderInfo.
                                    loyaltyTenderItem.Description   = tenderInfo.TenderName;
                                    loyaltyTenderItem.TenderTypeId  = cardInfo.TenderTypeId;
                                    loyaltyTenderItem.LoyaltyPoints = totalNumberOfPoints;

                                    //convert from the store-currency to the company-currency...
                                    loyaltyTenderItem.CompanyCurrencyAmount = this.Application.Services.Currency.CurrencyToCurrency(
                                        ApplicationSettings.Terminal.StoreCurrency,
                                        ApplicationSettings.Terminal.CompanyCurrency,
                                        amount);

                                    // the exchange rate between the store amount(not the paid amount) and the company currency
                                    loyaltyTenderItem.ExchrateMST = this.Application.Services.Currency.ExchangeRate(
                                        ApplicationSettings.Terminal.StoreCurrency) * 100;

                                    // card tender processing and printing require an EFTInfo object to be attached.
                                    // however, we don't want loyalty info to show up where other EFT card info would on the receipt
                                    //  because loyalty has its own receipt template fields, so we just assign empty EFTInfo object
                                    loyaltyTenderItem.EFTInfo = Application.BusinessLogic.Utility.CreateEFTInfo();
                                    // we don't want Loyalty to be 'captured' by payment service, so explicitly set not to capture to be safe
                                    loyaltyTenderItem.EFTInfo.IsPendingCapture = false;

                                    loyaltyTenderItem.SignatureData = LSRetailPosis.POSProcesses.TenderOperation.ProcessSignatureCapture(tenderInfo, loyaltyTenderItem);

                                    this.transaction.Add(loyaltyTenderItem);
                                }
                                else
                                {
                                    using (LSRetailPosis.POSProcesses.frmMessage dialog = new LSRetailPosis.POSProcesses.frmMessage(50057, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error))
                                    {
                                        LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSForm(dialog);
                                    } // Not enough points available to complete payment
                                }
                            }
                            else
                            {
                                LSRetailPosis.POSProcesses.frmMessage dialog = null;
                                try
                                {
                                    if (string.IsNullOrEmpty(comment))
                                    {
                                        dialog = new LSRetailPosis.POSProcesses.frmMessage(50058, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                                    }
                                    else
                                    {
                                        dialog = new LSRetailPosis.POSProcesses.frmMessage(comment, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                                    }

                                    LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSForm(dialog);    // Invalid loyaltycard
                                }
                                finally
                                {
                                    if (dialog != null)
                                    {
                                        dialog.Dispose();
                                    }
                                }
                            }
                        }
                        else
                        {
                            using (LSRetailPosis.POSProcesses.frmMessage dialog = new LSRetailPosis.POSProcesses.frmMessage(50059, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error))
                            {
                                LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSForm(dialog); // Not enough points available to complete payment
                            }
                        }
                    }
                }
                finally
                {
                    CloseExistingMessageWindow();
                }
            }
            catch (Exception ex)
            {
                NetTracer.Error(ex, "Loyalty::AddLoyaltyPayment failed for retailTransaction {0} cardInfo {1} amount {2}", retailTransaction.TransactionId, cardInfo.CardNumber, amount);
                LSRetailPosis.ApplicationExceptionHandler.HandleException(this.ToString(), ex);
                throw;
            }
        }