Example #1
0
        public void AuthorizeCustomerAccountPayment(ref bool valid, ref string comment, ref string manualAuthenticationCode, string customerId, decimal amount, DE.IRetailTransaction retailTransaction)
        {
            try
            {
                LSRetailPosis.ApplicationLog.Log(this.ToString(), "Customer.AuthorizeCustomerAccountPayment()", LSRetailPosis.LogTraceLevel.Trace);
                //Get the customer information for the customer
                DM.CustomerDataManager customerDataManager = new DM.CustomerDataManager(
                    ApplicationSettings.Database.LocalConnection, ApplicationSettings.Database.DATAAREAID);
                DE.ICustomer tempCust = customerDataManager.GetTransactionalCustomer(customerId);

                if (!string.IsNullOrEmpty(tempCust.InvoiceAccount))
                {
                    DE.ICustomer tempInvCust = customerDataManager.GetTransactionalCustomer(tempCust.InvoiceAccount);
                    if (tempInvCust.Blocked == DE.BlockedEnum.All)
                    {
                        tempCust.Blocked = tempInvCust.Blocked;
                    }
                    else if (tempInvCust.Blocked == DE.BlockedEnum.Invoice && tempCust.Blocked != DE.BlockedEnum.All)
                    {
                        tempCust.Blocked = DE.BlockedEnum.Invoice;
                    }
                }

                valid = true;

                if (LSRetailPosis.Settings.ApplicationSettings.Terminal.Standalone == true)
                {
                    decimal balance = customerDataManager.GetBalance(tempCust.CustomerId);
                    if (((balance * -1) + Convert.ToDecimal(amount)) > tempCust.CreditLimit)
                    {
                        valid   = false;
                        comment = LSRetailPosis.ApplicationLocalizer.Language.Translate(51007);  // The amount charged is higher than existing creditlimit
                    }
                    return;
                }

                // Using the transaction services to validate the transaction
                this.Application.TransactionServices.ValidateCustomerStatus(ref valid, ref comment, customerId, amount, retailTransaction.StoreCurrencyCode);
                if (comment.Length > 0)
                {
                    if (comment.Substring(0, 1) == "\t")
                    {
                        comment = comment.Remove(0, 1);
                    }
                }
            }
            catch (LSRetailPosis.PosisException px)
            {
                LSRetailPosis.ApplicationExceptionHandler.HandleException(this.ToString(), px);
                throw;
            }
            catch (Exception x)
            {
                LSRetailPosis.ApplicationExceptionHandler.HandleException(this.ToString(), x);
                throw;
            }
        }
Example #2
0
        /// <summary>
        /// Updates the customer information in the database
        /// </summary>
        /// <param name="customerId">The customer id</param>
        /// <returns>Returns the updated customer if succeded, null otherwise</returns>
        public DE.ICustomer UpdateCustomer(string customerId)
        {
            DM.CustomerDataManager customerDataManager = new DM.CustomerDataManager(
                ApplicationSettings.Database.LocalConnection, ApplicationSettings.Database.DATAAREAID);

            DE.ICustomer customer = customerDataManager.GetTransactionalCustomer(customerId);
            DE.IAddress  address  = customerDataManager.GetAddress(customer.PrimaryAddress.Id);

            using (frmNewCustomer newCustDialog = new frmNewCustomer(customer, address))
            {
                this.Application.ApplicationFramework.POSShowForm(newCustDialog);

                if (newCustDialog.DialogResult == DialogResult.OK)
                {
                    return(customer);
                }
            }

            return(null);
        }
Example #3
0
        /// <summary>
        /// Validating the payment transaction from database.
        /// Print the transaction report in a specific format.
        /// </summary>
        /// <param name="customerId"></param>
        /// <param name="numberOfMonths"></param>
        public void Print(string customerId, int numberOfMonths)
        {
            const string returnSign = "\r\n";

            try
            {
                //Find the start date
                DateTime fromDate = DateTime.Now;
                if (numberOfMonths == -1)
                {
                    fromDate = fromDate.AddYears(-100);
                }
                else
                {
                    fromDate = fromDate.AddMonths(-1 * numberOfMonths + 1);
                }

                fromDate = fromDate.AddDays(-1 * fromDate.Day + 1);
                fromDate = fromDate.AddHours(-1 * fromDate.Hour);
                fromDate = fromDate.AddMinutes(-1 * fromDate.Minute);
                fromDate = fromDate.AddSeconds(-1 * fromDate.Second);

                //Get the transactions
                customerData         = new CustomerData(LSRetailPosis.Settings.ApplicationSettings.Database.LocalConnection, LSRetailPosis.Settings.ApplicationSettings.Database.DATAAREAID);
                customerTransactions = customerData.GetCustomerTransactions(customerId, fromDate);

                if (customerTransactions.Rows.Count > 0)
                {
                    //Get customer information
                    DM.CustomerDataManager customerDataManager = new DM.CustomerDataManager(
                        ApplicationSettings.Database.LocalConnection, ApplicationSettings.Database.DATAAREAID);
                    ICustomer customerInfo = customerDataManager.GetTransactionalCustomer(customerId);

                    string line = "--------------------------------------------" + returnSign;
                    #region Create the report
                    //Print header information

                    string report = "\n" + LSRetailPosis.ApplicationLocalizer.Language.Translate(51040) + " " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + returnSign + returnSign; //Report printed
                    report += LSRetailPosis.ApplicationLocalizer.Language.Translate(51041).PadRight(15, '.').Substring(0, 15) + ": " + customerId + returnSign;                                                      //Customer Id
                    report += LSRetailPosis.ApplicationLocalizer.Language.Translate(51042).PadRight(15, '.').Substring(0, 15) + ": " + customerInfo.Name + returnSign + returnSign;                                  //Name

                    //ReceiptId         //Date          //Type          //Amount
                    report += LSRetailPosis.ApplicationLocalizer.Language.Translate(51043).PadRight(10).Substring(0, 10) + " " + LSRetailPosis.ApplicationLocalizer.Language.Translate(51044).PadRight(10).Substring(0, 10) + " " + LSRetailPosis.ApplicationLocalizer.Language.Translate(51045).PadRight(8) + " " + LSRetailPosis.ApplicationLocalizer.Language.Translate(51046).PadLeft(13) + returnSign;
                    report += line;

                    Decimal  subTotal        = 0;
                    Decimal  total           = 0;
                    Decimal  amount          = 0;
                    int      prevMonthNumber = 0;
                    string   prevMonthName   = string.Empty;
                    DateTime transDate;
                    string   receiptId       = string.Empty;
                    string   transactionType = string.Empty;
                    string   subTotalText    = string.Empty;

                    //Loop throug the customer transactions
                    foreach (DataRow row in customerTransactions.Select())
                    {
                        transDate       = (DateTime)row["TRANSDATE"];
                        amount          = (Decimal)row["AMOUNT"];
                        transactionType = (String)row["TRANSACTIONTYPE"];

                        if (row["RECEIPTID"] == DBNull.Value)
                        {
                            receiptId = string.Empty;
                        }
                        else
                        {
                            receiptId = (String)row["RECEIPTID"];
                        }

                        if (prevMonthNumber == 0)
                        {
                            prevMonthNumber = transDate.Month;
                        }

                        if (transDate.Month != prevMonthNumber)
                        {
                            //Print subtotals
                            report      += line;
                            subTotalText = LSRetailPosis.ApplicationLocalizer.Language.Translate(51047) + " " + prevMonthName.ToUpper() + ": ";
                            report      += subTotalText.PadLeft(32) + subTotal.ToString("n2").PadLeft(12) + returnSign;
                            report      += line;
                            subTotal     = 0;
                        }

                        subTotal += amount;
                        total    += amount;

                        //Print tranactions
                        report += receiptId.PadRight(10) + " " + transDate.ToShortDateString().PadRight(10) + " " + transactionType.PadRight(8) + amount.ToString("n2").PadLeft(14) + returnSign;

                        prevMonthNumber = transDate.Month;
                        prevMonthName   = transDate.ToString("MMMM");
                    }

                    report += line;

                    //Print subtotals for the last month if more than one.
                    if (numberOfMonths > 1)
                    {
                        subTotalText = LSRetailPosis.ApplicationLocalizer.Language.Translate(51047) + " " + prevMonthName.ToUpper() + ": ";
                        report      += subTotalText.PadLeft(32) + subTotal.ToString("n2").PadLeft(12) + returnSign;
                        report      += "============================================" + returnSign;;
                    }

                    //Print totals
                    report += LSRetailPosis.ApplicationLocalizer.Language.Translate(51048).PadLeft(27) + ": " + total.ToString("n2").PadLeft(15) + returnSign + returnSign;
                    decimal balanceNow = customerDataManager.GetBalance(customerId);
                    report += LSRetailPosis.ApplicationLocalizer.Language.Translate(51049).PadRight(15, '.') + ": " + balanceNow.ToString("n2") + returnSign + returnSign + returnSign;
                    //Send the report to the printer
                    #endregion

                    //System.Windows.Forms.DialogResult result = System.Windows.Forms.DialogResult.No;

                    using (frmReportList reportPreview = new frmReportList(report))
                    {
                        POSFormsManager.ShowPOSForm(reportPreview);
                        if (reportPreview.DialogResult == DialogResult.OK)
                        {
                            if (Customer.InternalApplication.Services.Printing is Microsoft.Dynamics.Retail.Pos.Contracts.Services.IPrintingV2)
                            {   // Print to the default printer
                                Customer.InternalApplication.Services.Printing.PrintDefault(true, report);
                            }
                            else
                            {   // Legacy support - direct print to printer #1
                                NetTracer.Warning("TransactionReport.Print - Printing service does not support default printer.  Using printer #1");
                                Customer.InternalApplication.Services.Peripherals.Printer.PrintReceipt(report);
                            }


                            Customer.InternalApplication.Services.Peripherals.Printer.PrintReceipt(report);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                NetTracer.Error(ex, "TransactionReport::Print failed for customerId {0} numberOfMonths {1}", customerId, numberOfMonths);
                throw;
            }
        }
        public void PrintApprovalVoucher(string sOrderNo, DataTable dtItemdetails, IPosTransaction posTransaction, string Title, DataTable dtIngr = null)
        {
            //PageSettings ps = new PageSettings { Landscape = false, PaperSize = new PaperSize { RawKind = (int)PaperKind.A4 }, Margins = new Margins { Top = 0, Right = 0, Bottom = 0, Left = 0 } };
            sCurrencySymbol = oBlank.GetCurrencySymbol();
            //datasources
            List <ReportDataSource> rds = new List <ReportDataSource>();

            rds.Add(new ReportDataSource("HEADERINFO", (DataTable)GetHeaderInfo(sOrderNo)));
            //dtItemDetails = dtItemdetails;
            //rds.Add(new ReportDataSource("DETAILSINFO", (DataTable)GetDetailInfo(sOrderNo, dtItemdetails)));

            rds.Add(new ReportDataSource("DETAILSINFO", (DataTable)GetDetailInfo(sOrderNo, dtItemdetails, dtIngr)));
            rds.Add(new ReportDataSource("DETAILSFOOTERINFO", (DataTable)GetDetailFooterInfo(dtItemDetails_Main)));

            //parameters
            List <ReportParameter> rps = new List <ReportParameter>();
            decimal dTotalAmt          = 0;
            decimal dRoweTotal         = 0;


            foreach (DataRow dr in dtItemDetails_Main.Rows)
            {
                decimal dVatAmt = 0;
                if (!string.IsNullOrEmpty(Convert.ToString(dr["VATAMOUNT"])))
                {
                    dVatAmt = Convert.ToDecimal(dr["VATAMOUNT"]);
                }

                if (!string.IsNullOrEmpty(Convert.ToString(dr["ROWTOTALAMOUNT"])))
                {
                    dTotalAmt += Convert.ToDecimal(dr["ROWTOTALAMOUNT"]) + dVatAmt;
                }
                //dTotalAmt += Convert.ToDecimal(dr["ROWTOTALAMOUNT"]);
            }


            Currency = GetCurrencyText(GetHeaderInfo(sOrderNo).Rows[0]["Currency"].ToString());
            string            sAmtInWords = Currency + " " + Amtinwds(Math.Abs(Convert.ToDouble(dTotalAmt)));
            RetailTransaction retailTrans = posTransaction as RetailTransaction;

            if (retailTrans != null)
            {
                sCPinCode = Convert.ToString(retailTrans.Customer.PostalCode);
            }
            else
            {
                var SelectedCust = customerDataManager.GetTransactionalCustomer(GetHeaderInfo(sOrderNo).Rows[0]["CUSTACCOUNT"].ToString());
                sCPinCode = SelectedCust.PostalCode;
            }
            string sCompanyName = GetCompanyName();

            rps.Add(new ReportParameter("prmTransactionId", string.IsNullOrEmpty(posTransaction.TransactionId) ? " " : posTransaction.TransactionId, true));
            rps.Add(new ReportParameter("prmTotalInWrd", string.IsNullOrEmpty(sAmtInWords) ? " " : sAmtInWords, true));
            string sDate = string.Empty;


            rps.Add(new ReportParameter("prmPinCode", string.IsNullOrEmpty(sCPinCode) ? " " : sCPinCode, true));
            rps.Add(new ReportParameter("prmCompany", string.IsNullOrEmpty(sCompanyName) ? " " : sCompanyName, true));
            rps.Add(new ReportParameter("prmTitle", Title, true));
            rps.Add(new ReportParameter("Remarks", sRemarks, true));

            if (Title == "INWARD")
            {
                rps.Add(new ReportParameter("prmSubTiltle", "", true));
                sDate = System.DateTime.Now.ToShortDateString();
                rps.Add(new ReportParameter("prmApprDt", string.IsNullOrEmpty(sDate) ? " " : sDate, true));
                // rds.Add(new ReportDataSource("BARCODEIMGTABLE", (DataTable)GetBarcodeInfo(Title, "")));
                rps.Add(new ReportParameter("prmBarcode", string.IsNullOrEmpty("") ? " " : "", true));
                rps.Add(new ReportParameter("pIsVisibleTentative", "0", true));
            }
            else
            {
                sDate = Convert.ToString(GetHeaderInfo(sOrderNo).Rows[0]["ApprovalDate"]);
                rps.Add(new ReportParameter("prmApprDt", string.IsNullOrEmpty(sDate) ? " " : sDate, true));
                rps.Add(new ReportParameter("prmSubTiltle", "SUSPENSE ITEM ON APPROVAL", true));
                //rds.Add(new ReportDataSource("BARCODEIMGTABLE", (DataTable)GetBarcodeInfo(Title, sOrderNo)));
                rps.Add(new ReportParameter("prmBarcode", string.IsNullOrEmpty(sOrderNo) ? " " : sOrderNo, true));
                rps.Add(new ReportParameter("pIsVisibleTentative", "1", true));
            }
            rps.Add(new ReportParameter("cs", string.IsNullOrEmpty(sCurrencySymbol) ? " " : sCurrencySymbol, true));

            string reportName = @"rptApprvDeliveryNote";
            //string reportName = @"Copy of rptCustOrdVoucher";
            string reportPath = @"Microsoft.Dynamics.Retail.Pos.BlankOperations.Report." + reportName + ".rdlc";
            //RdlcViewer rptView = new RdlcViewer("Approval Sale Voucher", reportPath, rds, rps, null,2);
            //rptView.ShowDialog();
            //rptView.Close();
        }