private void VoidPurchaseReturn_Load(object sender, EventArgs e)
        {
            labelMessage.Text = "";

            if (GlobalDataAccessor.Instance.DesktopSession.HistorySession.Trigger.Equals(Commons.TriggerTypes.VOIDBUYRETURN, StringComparison.OrdinalIgnoreCase))
            {
                voidReturnFlow = true;
            }
            else if (GlobalDataAccessor.Instance.DesktopSession.HistorySession.Trigger.Equals(Commons.TriggerTypes.VOIDSALE, StringComparison.Ordinal))
            {
                voidSaleFlow = true;
            }
            else if (GlobalDataAccessor.Instance.DesktopSession.HistorySession.Trigger.Equals(Commons.TriggerTypes.VOIDBUY, StringComparison.OrdinalIgnoreCase))
            {
                voidBuyFlow = true;
            }
            else if (GlobalDataAccessor.Instance.DesktopSession.HistorySession.Trigger.Equals(Commons.TriggerTypes.VOIDREFUND, StringComparison.OrdinalIgnoreCase))
            {
                voidSaleRefundFlow = true;
            }
            else if (GlobalDataAccessor.Instance.DesktopSession.HistorySession.Trigger.Equals(Commons.TriggerTypes.VOIDLAYAWAY, StringComparison.OrdinalIgnoreCase))
            {
                voidLayawayFlow = true;
            }


            if (voidReturnFlow)
            {
                labelHeading.Text = "Void Return";
                labelTransactionNoHeading.Text = "Return Number";
            }
            else if (voidBuyFlow)
            {
                labelHeading.Text = "Void Buy";
                labelTransactionNoHeading.Text = "Buy Number";
                //BZ # 619
                comboBoxReason.Items.Clear();
                comboBoxReason.Items.Add("Wrong Payment Method");
                comboBoxReason.Items.Add("PFI'd In Error");
                comboBoxReason.Items.Add("Wrong Customer");
                comboBoxReason.Items.Add("Incorrect Transaction Detail");
                comboBoxReason.Items.Add("Test Transaction");
                comboBoxReason.Items.Add("System Issue");
            }
            else if (voidSaleFlow)
            {
                labelHeading.Text = "Void Sale";
                labelTransactionNoHeading.Text = "MSR #";
                this.dataGridViewMdse.Columns[1].HeaderText = "Amount";
                comboBoxReason.Items.Clear();
                comboBoxReason.Items.Add("Wrong Payment Method");
                comboBoxReason.Items.Add("Wrong Customer");
                comboBoxReason.Items.Add("Wrong ICN");
                comboBoxReason.Items.Add("Customer Changed Mind");
                comboBoxReason.Items.Add("Test Transaction");
                comboBoxReason.Items.Add("System Issue");
            }
            else if (voidSaleRefundFlow)
            {
                labelHeading.Text = "Void Sale Refund";
                labelTransactionNoHeading.Text = "MSR Refund #";
            }
            else if (voidLayawayFlow)
            {
                labelHeading.Text = "Void Layaway";
                labelTransactionNoHeading.Text = "Layaway #";
            }

            maxVoidDays = 0L;
            if (!new BusinessRulesProcedures(GlobalDataAccessor.Instance.DesktopSession).GetMaxVoidDays(GlobalDataAccessor.Instance.CurrentSiteId,
                                                                                                        out maxVoidDays))
            {
                if (FileLogger.Instance.IsLogError)
                {
                    FileLogger.Instance.logMessage(LogLevel.ERROR, this,
                                                   "Cannot retrieve maximum void days. Defaulting to {0}", maxVoidDays);
                }
            }

            currentPurchase = GlobalDataAccessor.Instance.DesktopSession.ActivePurchase;
            currentSale     = GlobalDataAccessor.Instance.DesktopSession.ActiveRetail;
            if (currentPurchase != null)
            {
                if (currentPurchase.EntityType == "V")
                {
                    voidVendorBuy = true;
                }
                labelDate.Text          = currentPurchase.MadeTime.ToString();
                labelTransactionNo.Text = currentPurchase.TicketNumber.ToString();
                labelUserID.Text        = currentPurchase.CreatedBy.ToString();
                labelTotal.Text         = currentPurchase.Amount.ToString("c");
                if (currentPurchase.DateMade.AddDays(maxVoidDays) < ShopDateTime.Instance.ShopDate)
                {
                    labelMessage.Text        = INVALIDVOIDMESSAGE;
                    labelMessage.Visible     = true;
                    customButtonVoid.Enabled = false;
                }

                /* if (voidBuyFlow && (currentPurchase.CustomerNumber == null ||
                 *   currentPurchase.EntityType == "V"))
                 * {
                 *   labelMessage.Text = NOTCUSTOMERPURCHASE;
                 *   labelMessage.Visible = true;
                 *   customButtonVoid.Enabled = false;
                 * }
                 * if (voidVendorBuy && currentPurchase.EntityType != "V")
                 * {
                 *   labelMessage.Text = NOTVENDORPURCHASE;
                 *   labelMessage.Visible = true;
                 *   customButtonVoid.Enabled = false;
                 *
                 * }*/
                //if we are voiding vendor buy make sure that the items are not sold or on layaway
                if (voidBuyFlow)
                {
                    var itemData = (from item in currentPurchase.Items
                                    where item.ItemStatus == ProductStatus.SOLD ||
                                    item.ItemStatus == ProductStatus.LAY
                                    select item).FirstOrDefault();
                    if (itemData != null)
                    {
                        labelMessage.Text        = RETAILITEMS;
                        labelMessage.Visible     = true;
                        customButtonVoid.Enabled = false;
                    }
                }

                if (!voidReturnFlow)
                {
                    var itemData = (from item in currentPurchase.Items
                                    where item.ItemStatus == ProductStatus.RET
                                    select item).FirstOrDefault();
                    if (itemData != null)
                    {
                        labelMessage.Text        = RETURNEDPURCHASE;
                        labelMessage.Visible     = true;
                        customButtonVoid.Enabled = false;
                    }
                    var itemRTCData = (from item in currentPurchase.Items
                                       where item.ItemStatus == ProductStatus.RTC ||
                                       item.ItemStatus == ProductStatus.PS
                                       select item).FirstOrDefault();
                    if (itemRTCData != null)
                    {
                        labelMessage.Text        = RTCITEMS;
                        labelMessage.Visible     = true;
                        customButtonVoid.Enabled = false;
                    }
                }

                if (currentPurchase.Items != null && currentPurchase.Items.Count > 0)
                {
                    dataGridViewMdse.AutoGenerateColumns = false;
                    this.dataGridViewMdse.Columns[1].DefaultCellStyle.Format = "c";
                    foreach (Item item in currentPurchase.Items)
                    {
                        DataGridViewRow row = dataGridViewMdse.Rows.AddNew();
                        row.Cells[mdseDesc.Index].Value = item.TicketDescription;
                        row.Cells[cost.Index].Value     = item.ItemAmount;
                    }
                }
                else
                {
                    MessageBox.Show("Error in void transaction processing");
                    FileLogger.Instance.logMessage(LogLevel.ERROR, this, "No items found for purchase " + currentPurchase.TicketNumber + " to void.");
                    Close();
                }
            }
            else if (currentSale != null)
            {
                labelDate.Text          = currentSale.MadeTime.ToString();
                labelTransactionNo.Text = currentSale.TicketNumber.ToString();
                labelUserID.Text        = currentSale.CreatedBy.ToString();
                labelTotal.Text         = currentSale.Amount.ToString("c");
                if (Utilities.GetDateTimeValue(currentSale.MadeTime.ToShortDateString()).AddDays(maxVoidDays) < ShopDateTime.Instance.ShopDate)
                {
                    labelMessage.Text        = INVALIDVOIDSALEMESSAGE;
                    labelMessage.Visible     = true;
                    customButtonVoid.Enabled = false;
                }

                string rcptId = (from receipt in currentSale.Receipts
                                 where (receipt.Event == ReceiptEventTypes.SALE.ToString() &&
                                        receipt.RefNumber == currentSale.TicketNumber.ToString())
                                 select receipt).First().ReceiptDetailNumber;

                Common.Libraries.Utility.Shared.Receipt selectedReceipt = currentSale.Receipts.Find(r => r.ReceiptDetailNumber == rcptId);

                if (selectedReceipt.CreatedBy == "CONV" || currentSale.CreatedBy == "CONV")
                {
                    labelMessage.Text        = INVALIDCONVERSIONVOIDSALEMESSAGE;
                    labelMessage.Visible     = true;
                    customButtonVoid.Enabled = false;
                }

                if (voidSaleFlow)
                {
                    var itemData = (from item in currentSale.RetailItems
                                    where item.DispDoc != currentSale.TicketNumber
                                    select item).FirstOrDefault();
                    if (itemData != null)
                    {
                        labelMessage.Text        = RETURNEDSALE;
                        labelMessage.Visible     = true;
                        customButtonVoid.Enabled = false;
                    }
                    //SR 12/08/2011 Added the logic below to not allow void of cacc sales that
                    //were refunded
                    var itemCaccData = (from item in currentSale.RetailItems
                                        where item.mDocType == "5" && item.Quantity != item.RefundQuantity
                                        select item).FirstOrDefault();
                    if (itemCaccData != null)
                    {
                        labelMessage.Text        = RETURNEDSALE;
                        labelMessage.Visible     = true;
                        customButtonVoid.Enabled = false;
                    }
                }

                if (currentSale.RetailItems != null && currentSale.RetailItems.Count > 0)
                {
                    dataGridViewMdse.AutoGenerateColumns = false;
                    this.dataGridViewMdse.Columns[1].DefaultCellStyle.Format = "c";
                    foreach (RetailItem item in currentSale.RetailItems)
                    {
                        DataGridViewRow row = dataGridViewMdse.Rows.AddNew();
                        row.Cells[mdseDesc.Index].Value = item.TicketDescription;
                        row.Cells[cost.Index].Value     = item.RetailPrice * item.Quantity;
                    }
                }
                else
                {
                    MessageBox.Show("Error in void transaction processing");
                    FileLogger.Instance.logMessage(LogLevel.ERROR, this, "No items found for the transaction " + currentSale.TicketNumber + " to void.");
                    Close();
                }
            }
        }
Ejemplo n.º 2
0
        private void loadReceiptData()
        {
            //this.receiptDataTextBox.Text;
            DesktopSession cds = GlobalDataAccessor.Instance.DesktopSession;
            StringBuilder  sb  = new StringBuilder();

            sb.AppendLine(StringUtilities.centerString(CASHAMERICATXT, TXTBOXWIDTH));
            sb.AppendLine(StringUtilities.centerString(ProcessTenderController.STORE_NAME, TXTBOXWIDTH));
            this.store_short_name     = ProcessTenderController.STORE_NAME;
            this.store_street_address = ProcessTenderController.STORE_ADDRESS;
            this.store_city_state_zip = ProcessTenderController.STORE_CITY + ", " +
                                        ProcessTenderController.STORE_STATE + ProcessTenderController.STORE_ZIP;
            this.store_phone = ProcessTenderController.STORE_PHONE;
            sb.AppendLine(StringUtilities.centerString(ProcessTenderController.STORE_ADDRESS, TXTBOXWIDTH));
            sb.AppendLine(StringUtilities.centerString(ProcessTenderController.STORE_CITY
                                                       + ", "
                                                       + ProcessTenderController.STORE_STATE
                                                       + " "
                                                       + ProcessTenderController.STORE_ZIP, TXTBOXWIDTH));

            sb.AppendLine();
            sb.AppendLine(StringUtilities.centerString(ProcessTenderController.STORE_PHONE, TXTBOXWIDTH));
            if (CollectionUtilities.isNotEmpty(cds.PawnReceipt))
            {
                Common.Libraries.Utility.Shared.Receipt pReceipt = cds.PawnReceipt[0];
                DateTime receiptDt = pReceipt.Date;

                //Load loan
                PawnLoan   pLoan;
                PawnAppVO  pApp;
                CustomerVO custVO;
                string     errorCode;
                string     errorText;
                try
                {
                    int receiptStore = Int32.Parse(pReceipt.StoreNumber);
                    int ticketNum    = Int32.Parse(pReceipt.RefNumber);
                    if (!CustomerLoans.GetPawnLoan(GlobalDataAccessor.Instance.DesktopSession, receiptStore, ticketNum, "0", StateStatus.BLNK, true,
                                                   out pLoan, out pApp, out custVO, out errorCode, out errorText))
                    {
                        //Do something about the error here
                        MessageBox.Show("Cannot find loan associated with receipt.");
                        NavControlBox.Action = NavBox.NavAction.CANCEL;
                        return;
                    }
                    this.pwnLoan = pLoan;
                    this.pwnApp  = pApp;

                    if (custVO == null)
                    {
                        //Do something about the error here
                        MessageBox.Show("Cannot find customer associated with receipt");
                        NavControlBox.Action = NavBox.NavAction.CANCEL;
                        return;
                    }

                    /* this.voidReceiptButton.Enabled =
                     * (this.pwnLoan.LoanStatus == PawnLoanStatus.IP);*/
                    this.printButton.Enabled = true;
                    this.f_date_and_time     = receiptDt.ToString("d", DateTimeFormatInfo.InvariantInfo) + " " +
                                               this.pwnLoan.MadeTime.ToShortTimeString();
                    sb.AppendLine(StringUtilities.centerString(this.f_date_and_time, TXTBOXWIDTH));
                    this.receipt_number = "" + pReceipt.ReceiptNumber;
                    sb.AppendLine(StringUtilities.centerString(RECEIPTNUM + pReceipt.ReceiptNumber, TXTBOXWIDTH));
                    sb.AppendLine();
                    sb.AppendLine(StringUtilities.centerString(CUSTOMERLABEL +
                                                               custVO.LastName + ", " + custVO.FirstName, TXTBOXWIDTH));
                    this.f_cust_name = custVO.LastName + ", " + custVO.FirstName.Substring(0, 1);
                    sb.AppendLine(StringUtilities.centerString(LOANLABEL +
                                                               pLoan.OrgShopNumber + pLoan.TicketNumber, TXTBOXWIDTH));
                    sb.AppendLine();
                    this.ticketAmount = this.pwnLoan.Amount.ToString("C");
                    this.ticketNumber = this.pwnLoan.TicketNumber.ToString();
                    if (this.pwnLoan.LoanStatus == ProductStatus.IP)
                    {
                        sb.AppendLine("1 Pawn Loan");
                        sb.AppendLine(BARDATA);
                        sb.AppendLine("Cash Paid TO Customer          " + pReceipt.Amount.ToString("C"));
                    }
                    else if (this.pwnLoan.LoanStatus == ProductStatus.PU)
                    {
                        sb.AppendLine("Pickup Pawn Loan");
                        sb.AppendLine(BARDATA);
                        sb.AppendLine("Cash Received FROM Customer    " + pReceipt.Amount.ToString("C"));
                    }
                    sb.AppendLine();
                    sb.AppendLine();
                    sb.AppendLine(StringUtilities.centerString(EMPLOYEELABEL + pReceipt.EntID, 40));
                    this.emp_number = pReceipt.EntID;
                    sb.AppendLine(TBARDATA);

                    //Add receipt information to text box
                    this.receiptDataTextBox.Text = sb.ToString();
                    this.receiptDataTextBox.Update();
                }
                catch (Exception)
                {
                    MessageBox.Show("Cannot find receipt.");
                    this.NavControlBox.Action = NavBox.NavAction.CANCEL;
                    this.Close();
                }
            }
        }