예제 #1
0
        /// <summary>
        /// Called to update points when conclude a transaction.
        /// </summary>
        /// <param name="retailTransaction"></param>
        public void UpdateLoyaltyPoints(IRetailTransaction retailTransaction)
        {
            if (retailTransaction == null)
            {
                throw new ArgumentNullException("retailTransaction");
            }

            this.transaction = (RetailTransaction)retailTransaction;

            // Sending confirmation to the transactions service about earned points
            if (this.transaction.LoyaltyItem != null)
            {
                if (this.transaction.LoyaltyItem.UsageType == LoyaltyItemUsageType.UsedForLoyaltyRequest)
                {
                    UpdateIssuedLoyaltyPoints(this.transaction.LoyaltyItem);

                    if (this.transaction.LoyaltyItem.CalculatedLoyaltyPoints < 0)
                    {
                        bool    cardIsValid           = false;
                        string  comment               = string.Empty;
                        int     loyaltyTenderTypeBase = 0;
                        decimal pointsEarned          = 0M;

                        GetPointStatus(ref pointsEarned, ref cardIsValid, ref comment, ref loyaltyTenderTypeBase, this.transaction.LoyaltyItem.LoyaltyCardNumber);

                        if (cardIsValid && pointsEarned < 0)
                        {
                            string message = string.Format(LSRetailPosis.ApplicationLocalizer.Language.Translate(50500), pointsEarned);

                            using (LSRetailPosis.POSProcesses.frmMessage dialog = new LSRetailPosis.POSProcesses.frmMessage(message, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error))
                            {
                                LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSForm(dialog); // Not enough points available to complete payment
                            }
                        }
                    }
                }
                else if (this.transaction.LoyaltyItem.UsageType == LoyaltyItemUsageType.UsedForLoyaltyTender)
                {
                    // Sending confirmation to the transaction service about used points
                    foreach (ITenderLineItem tenderItem in this.transaction.TenderLines)
                    {
                        ILoyaltyTenderLineItem asLoyaltyTenderLineItem = tenderItem as ILoyaltyTenderLineItem;

                        if ((asLoyaltyTenderLineItem != null) && !asLoyaltyTenderLineItem.Voided)
                        {
                            if (asLoyaltyTenderLineItem.LoyaltyPoints != 0)
                            {
                                UpdateUsedLoyaltyPoints(asLoyaltyTenderLineItem);
                            }
                        }
                    }
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Called when used points are being voided.
        /// </summary>
        /// <param name="voided"></param>
        /// <param name="comment"></param>
        /// <param name="retailTransaction"></param>
        /// <param name="loyaltyTenderItem"></param>
        public bool VoidLoyaltyPayment(IRetailTransaction retailTransaction, ILoyaltyTenderLineItem loyaltyTenderItem)
        {
            if (retailTransaction == null)
            {
                throw new ArgumentNullException("retailTransaction");
            }

            if (loyaltyTenderItem == null)
            {
                throw new ArgumentNullException("loyaltyTenderItem");
            }

            this.transaction = (RetailTransaction)retailTransaction;

            this.transaction.VoidPaymentLine(loyaltyTenderItem.LineId);
            this.transaction.LoyaltyItem = (LoyaltyItem)this.Application.BusinessLogic.Utility.CreateLoyaltyItem();

            UpdateTransactionWithNewCustomer(null);

            return(true);
        }
예제 #3
0
        private void UpdateUsedLoyaltyPoints(ILoyaltyTenderLineItem loyaltyTenderItem)
        {
            bool   valid   = false;
            string comment = string.Empty;

            try
            {
                try
                {
                    NewMessageWindow(50053, LSPosMessageTypeButton.NoButtons, System.Windows.Forms.MessageBoxIcon.Information);

                    this.Application.TransactionServices.UpdateUsedLoyaltyPoints(
                        ref valid,
                        ref comment,
                        this.transaction.TransactionId,
                        "1",
                        this.transaction.StoreId,
                        this.transaction.TerminalId,
                        loyaltyTenderItem.CardNumber,
                        ((IPosTransactionV1)this.transaction).BeginDateTime,
                        loyaltyTenderItem.LoyaltyPoints,
                        this.transaction.ReceiptId,
                        this.transaction.OperatorId);

                    if (valid)
                    {
                        UpdateTransactionAccumulatedLoyaltyPoint();
                    }
                }
                finally
                {
                    CloseExistingMessageWindow();
                }
            }
            catch (Exception ex)
            {
                NetTracer.Warning(ex, "Loyalty::UpdateUsedLoyaltyPoints failed for loyaltyTenderItem {0}. Setting valid to false.", loyaltyTenderItem.CardNumber);
                valid = false;
            }

            if (!valid)
            {
                frmMessage errDialog = null;
                try
                {
                    if (string.IsNullOrEmpty(comment))
                    {
                        errDialog = new frmMessage(50058, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        errDialog = new frmMessage(comment, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    this.Application.ApplicationFramework.POSShowForm(errDialog);
                    loyaltyTenderItem.LoyaltyPoints = 0;
                    CloseExistingMessageWindow();
                }
                finally
                {
                    if (errDialog != null)
                    {
                        errDialog.Dispose();
                    }
                }
            }
        }