Beispiel #1
0
        public void ReceiptToStringHasEntriesSalesTaxesAndTotal()
        {
            const string  article1Name  = "Article ABC";
            const decimal article1Price = 32.54M;
            const string  article2Name  = "Article ABC";
            const decimal article2Price = 32.54M;
            var           article1      = new Article(1, Country.Usa, Category.ArtsAndCrafts, article1Name, article1Price);
            var           article2      = new Article(1, Country.Usa, Category.Baby, article2Name, article2Price);
            var           receipt       = new Receipt();
            var           tax           = new NoBasicTax();
            var           item1         = new Item(Country.Ita, article1, 1, tax);
            var           item2         = new Item(Country.Ita, article2, 1, tax);

            receipt.Add(item1);
            receipt.Add(item2);
            var entry1 = new Entry(item1);
            var entry2 = new Entry(item2);
            var sb     = new StringBuilder();

            sb.AppendLine(entry1.ToString());
            sb.AppendLine(entry2.ToString());
            sb.AppendLine($"Sales Taxes: {receipt.Taxes}");
            sb.AppendLine($"Total: {receipt.Total}");
            Assert.Equal(sb.ToString(), receipt.ToString());
        }
        private Receipt FormatTransactionCountReport(List <DailyCountModel> ReportData, DateTime When, String Period, String ByWhat)
        {
            Receipt Rpt = new Receipt();

            Rpt.AddCentered("Transaction Count Report");
            Rpt.AddCentered("For " + Period + " Ending " + When.ToShortDateString());
            Rpt.Add("");
            Rpt.Add(ByWhat);
            foreach (DailyCountModel DC in ReportData)
            {
                Rpt.Add(CountLineFormat(DC.Level, DC.EntityName, DC.TotalCount));
            }
            return(Rpt);
        }
Beispiel #3
0
        Receipt ITransactionService.FormatCloseBatch(DateTime LocalTime)
        {
            Receipt aRep = new Receipt();


            // format the date & time line

            String TransactionDate;
            String TransactionTime;

            if (LocalTime != null)
            {
                TransactionDate = LocalTime.ToShortDateString();
                TransactionTime = LocalTime.ToShortTimeString();
                aRep.JustifyBoth(TransactionDate, TransactionTime);
                //aRep.AddCentered("System time: " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString());
            }
            else
            {
                TransactionDate = DateTime.Now.ToShortDateString();
                TransactionTime = DateTime.Now.ToShortTimeString();
                aRep.JustifyBoth(TransactionDate, TransactionTime);
            }

            // format the transaction type

            aRep.Add("");
            aRep.AddCentered("Close Batch");//Utils.getMappedMessage("Activate"));

            return(aRep);
        }
Beispiel #4
0
        Receipt ITransactionService.FormatDetailReport(DetailReportInformation ReportInfo)
        {
            Receipt aRep = new Receipt();

            // format the date & time line

            String TransactionDate;
            String TransactionTime;

            if (ReportInfo.LocalTime != null)
            {
                TransactionDate = ReportInfo.LocalTime.ToShortDateString();
                TransactionTime = ReportInfo.LocalTime.ToShortTimeString();
                aRep.JustifyBoth(TransactionDate, TransactionTime);
                //aRep.AddCentered("System time: " + ReportInfo.When.ToShortDateString() + " " + ReportInfo.When.ToShortTimeString());
            }
            else
            {
                TransactionDate = ReportInfo.When.ToShortDateString();
                TransactionTime = ReportInfo.When.ToShortTimeString();
                aRep.JustifyBoth(TransactionDate, TransactionTime);
            }

            // format the transaction type

            aRep.Add("");
            aRep.AddCentered("Detail Report");//Utils.getMappedMessage("Activate"));


            int linelen = ("cardActivations" + " -       " + ReportInfo.SummaryInformation.GiftActivationAmount.ToString()).Length + 9;

            aRep.Add("");
            aRep.Add(String.Format(
                         "{0,5} {1,5} {2,4}  {3,10}   {4, 10} {5,8}",
                         " ID  ", "Clerk", "Type", "Card Num", "Inv#", "Amount"));
            aRep.Add("--------------------------------------------------");

            foreach (TransactionDetailInformation TDI in ReportInfo.Details)
            {
                aRep.Add(String.Format(
                             "{0,5} {1,4}  {2,4}  ******{3,4}   {4, 10} {5,8:C}",
                             TDI.ID, TDI.Clerk, TDI.TransType, TDI.CardNumber, TDI.InvoiceNumber, TDI.Amount));
                //aRep.Add(transactionnumber + Clerk + transactionType + cardnumber +  amount);
                if (TDI.TransType == "LEVT")
                {
                    aRep.Add(TDI.Text);
                }
            }



            aRep.Add(" ");
            FormatSummarySection(aRep, ReportInfo.SummaryInformation);

            return(aRep);
        }
Beispiel #5
0
        Receipt ITransactionService.FormatDailyReport(DailySalesInformation ReportInfo)
        {
            Receipt aRep = new Receipt();


            // format the date & time line

            String TransactionDate = ReportInfo.When.ToShortDateString();
            String TransactionTime = ReportInfo.When.ToShortTimeString();

            aRep.JustifyBoth(TransactionDate, TransactionTime);

            // format the transaction type

            aRep.Add("");
            aRep.AddCentered("Daily Sales Report");//Utils.getMappedMessage("Activate"));

            aRep.Add(" ");
            FormatSummarySection(aRep, ReportInfo);
            return(aRep);
        }
Beispiel #6
0
        public void FormatSummarySection(Receipt aRep, DailySalesInformation ReportInfo)
        {
            int linelen  = ("cardActivations" + " -     " + ReportInfo.GiftActivationAmount.ToString()).Length + 12;
            int ValueLen = ReportInfo.GiftSalesAmount.ToString().Length + 3;

            aRep.Add(" ");
            if (ReportInfo.GiftActive)
            {
                aRep.Add(formatReportLine("Card Activations", " -     ", ReportInfo.GiftActivations.ToString(), linelen, ValueLen));
                aRep.Add(formatReportLine("Amount", " $", formatAmount(ReportInfo.GiftActivationAmount.ToString()), linelen, ValueLen));
                aRep.Add(formatReportLine("Sales From Cards", " -     ", ReportInfo.GiftSales.ToString(), linelen, ValueLen));
                aRep.Add(formatReportLine("Amount", " $", formatAmount(ReportInfo.GiftSalesAmount.ToString()), linelen, ValueLen));
                aRep.Add(formatReportLine("Credits To Cards", " -     ", ReportInfo.GiftCredits.ToString(), linelen, ValueLen));
                aRep.Add(formatReportLine("Amount", " $", formatAmount(ReportInfo.GiftCreditAmount.ToString()), linelen, ValueLen));
                aRep.Add(formatReportLine("netTotal", " $", formatAmount(ReportInfo.NetGiftAmount.ToString()), linelen, ValueLen));
                aRep.Add(" ");
            }
        }
Beispiel #7
0
        public static void CreateOrders()
        {
            try
            {
                using (var context = new POSStagingContext())
                {
                    Properties.Settings setting = new Properties.Settings();
                    var      loc        = context.SAPMappings.ToList();
                    var      Terminals  = context.POSTerminals.ToList();
                    string   dateString = setting.DateStart;
                    DateTime date1      = DateTime.Parse(dateString,
                                                         System.Globalization.CultureInfo.InvariantCulture);

                    var Orders = context.Orders.Include("Order_Lines").Include("OrderPayments2")
                                 .Where(o => o.DocNum == 0 && o.Order_Status_Code == 4 && o.Order_Date >= date1)
                                 .OrderBy(o => o.Order_Date).ThenBy(o => o.Location_Code).ThenBy(o => o.Order_Number);

                    int count;
                    int x = 0;

                    var countNum = (from c in context.Orders
                                    where c.DocNum == 0 && c.Order_Status_Code == 4 && c.Order_Date >= date1
                                    select c.id).Count();

                    count = countNum;
                    int TranCount = 0;
                    //context.
                    foreach (var OINV in Orders.ToList())
                    {
                        //count = Orders.Count();
                        Console.WriteLine("Creating doc." + x.ToString() + " of " + count.ToString());
                        x++;
                        SAPbobsCOM.Documents Invoice;

                        Invoice   = (SAPbobsCOM.Documents)oCompany.GetBusinessObject(BoObjectTypes.oInvoices);
                        TranCount = 0;


                        if (OINV.Order_Status_Code != 4)
                        {
                            continue;
                        }
                        OINV.ErrMsg     = "";
                        Invoice.DocDate = OINV.Order_Date;

                        Invoice.DocDueDate = OINV.Order_Date;
                        Invoice.Project    = "DominoPizza";
                        string CardCode       = "";
                        string CostCenter     = "";
                        string cashGL         = "";
                        string BankGL         = "";
                        bool   ConsumptionTax = true;

                        foreach (var Location in loc)
                        {
                            if (Location.Location_Code == OINV.Location_Code)
                            {
                                CardCode   = Location.BPCode;
                                CostCenter = Location.PrcCode;
                                cashGL     = Location.CashGL;
                                //BankGL = Location.BankGL;
                                ConsumptionTax = Location.ConsumptionTax;
                                break;
                            }
                            else
                            {
                                continue;
                            }
                        }


                        Invoice.CardCode = CardCode;
                        Invoice.UserFields.Fields.Item("U_POSNumber").Value     = OINV.Order_Number;
                        Invoice.UserFields.Fields.Item("U_Location_Code").Value = OINV.Location_Code;

                        int i = 0;
                        foreach (var OrderLines in OINV.Order_Lines)
                        {
                            if (i != 0)
                            {
                                Invoice.Lines.Add();
                            }
                            Invoice.Lines.SetCurrentLine(i);
                            Invoice.Lines.ItemCode = OrderLines.ProductCode;
                            Invoice.Lines.Quantity = OrderLines.Quantity;
                            Invoice.Lines.Price    = (Double)(OrderLines.OrdLineTaxableSales / OrderLines.Quantity);
                            Invoice.Lines.TaxCode  = "X0";
                            Invoice.Lines.UserFields.Fields.Item("U_IdealFood").Value = (Double)OrderLines.OrdLineIdealFoodOptionQty;
                            Invoice.Lines.CostingCode5     = "CM0002";
                            Invoice.Lines.CostingCode2     = CostCenter;
                            Invoice.Lines.COGSCostingCode5 = "CM0002";
                            Invoice.Lines.COGSCostingCode2 = CostCenter;

                            Invoice.Lines.ProjectCode = "DominoPizza";

                            i++;
                        }

                        Invoice.Lines.Add();
                        Invoice.Lines.SetCurrentLine(i);



                        Invoice.Lines.ItemCode    = "VAT";
                        Invoice.Lines.Quantity    = 1;
                        Invoice.Lines.Price       = (Double)(OINV.Taxable_Sales1) * .05;
                        Invoice.Lines.TaxCode     = "X0";
                        Invoice.Lines.ProjectCode = "DominoPizza";
                        Invoice.Lines.AccountCode = "211501";
                        if (ConsumptionTax)
                        {
                            i++;
                            Invoice.Lines.Add();
                            Invoice.Lines.SetCurrentLine(i);

                            Invoice.Lines.ItemCode    = "Consumption";
                            Invoice.Lines.Quantity    = 1;
                            Invoice.Lines.Price       = (Double)(OINV.Taxable_Sales1) * .05;
                            Invoice.Lines.TaxCode     = "X0";
                            Invoice.Lines.ProjectCode = "DominoPizza";
                            Invoice.Lines.AccountCode = "211505";
                        }


                        //oCompany.StartTransaction();
                        if (Invoice.Add() != 0)
                        {
                            oCompany.GetLastError(out errCode, out errMsg);
                            Console.WriteLine(errMsg);
                            OINV.ErrMsg += "-" + errMsg;
                            //oCompany.Disconnect();
                            //if (oCompany.InTransaction)
                            //{
                            //    oCompany.EndTransaction(BoWfTransOpt.wf_RollBack);
                            //}
                        }
                        else
                        {
                            Console.WriteLine("Invoice for " + OINV.Location_Code + " - " + OINV.Order_Number + " - " + OINV.Order_Date.ToShortDateString() + " - created successfully ");

                            var invNum = (from c in context.InvoiceNumbers
                                          select c.DocNum).Max();

                            OINV.DocNum = invNum;
                            SAPbobsCOM.Payments Receipt;
                            Receipt = (SAPbobsCOM.Payments)oCompany.GetBusinessObject(BoObjectTypes.oIncomingPayments);

                            foreach (var OrderPayment in OINV.OrderPayments2)
                            {
                                Receipt.CardCode = CardCode;
                                Receipt.DocDate  = OrderPayment.Order_Date;
                                //Receipt.Reference1 = OrderPayment.OrdPayEPayRefNumber;
                                Receipt.Invoices.InvoiceType = BoRcptInvTypes.it_Invoice;
                                Receipt.Invoices.DocEntry    = invNum;
                                Receipt.Invoices.SumApplied  = (Double)OrderPayment.OrdPayAmt;
                                Receipt.ProjectCode          = "DominoPizza";

                                Receipt.UserFields.Fields.Item("U_POSNumber").Value     = OINV.Order_Number;
                                Receipt.UserFields.Fields.Item("U_Location_Code").Value = OINV.Location_Code;

                                switch (OrderPayment.Order_Pay_Type_Code)
                                {
                                case 1:
                                    Receipt.CashAccount = cashGL;
                                    Receipt.CashSum     = (Double)OINV.OrderFinalPrice;
                                    break;

                                case 4:
                                    BankGL = "";
                                    foreach (var Term in Terminals)
                                    {
                                        if (OrderPayment.Credit_Card_ID == Term.Credit_Card_ID &&
                                            OrderPayment.Location_Code == Term.Location_Code)
                                        {
                                            BankGL = Term.GLCode.ToString().TrimEnd();
                                            break;
                                        }
                                    }
                                    if (BankGL == "")
                                    {
                                        BankGL = "124211";
                                    }

                                    Receipt.TransferAccount = BankGL;
                                    Receipt.TransferDate    = OrderPayment.Order_Date;
                                    Receipt.TransferSum     = (Double)OrderPayment.OrdPayAmt;
                                    if (OrderPayment.OrdPayEPayRefNumber.Length < 27)
                                    {
                                        Receipt.TransferReference = OrderPayment.OrdPayEPayRefNumber;
                                    }
                                    else
                                    {
                                        Receipt.TransferReference = OrderPayment.OrdPayEPayRefNumber.ToString().Substring(0, 26);
                                    }


                                    break;

                                default:
                                    break;
                                }
                                if (Receipt.Add() != 0)
                                {
                                    oCompany.GetLastError(out errCode, out errMsg);
                                    Console.WriteLine(errMsg);
                                    oCompany.Disconnect();
                                    OINV.ReceiptErrMsg += errMsg;
                                    //if (oCompany.InTransaction)
                                    //{
                                    //    oCompany.EndTransaction(BoWfTransOpt.wf_RollBack);
                                    //}
                                }
                                else
                                {
                                    Console.WriteLine("Receipt for " + OrderPayment.Order_Number + " - " + OrderPayment.Location_Code + " - " + OrderPayment.Order_Date.ToShortDateString() + " - created successfully ");
                                    var RecNum = (from c in context.InvoiceNumbers
                                                  select c.ReceiptDocNum).Max();

                                    OINV.ReceiptDocNum = RecNum;
                                }
                                System.Runtime.InteropServices.Marshal.FinalReleaseComObject(Receipt);
                                break;
                            }
                        }

                        //if (oCompany.InTransaction)
                        //{
                        //    oCompany.EndTransaction(BoWfTransOpt.wf_Commit);
                        //}
                        string strSql = "Update Orders Set DocNum = " + OINV.DocNum.ToString() + ", errMsg = '" + OINV.ErrMsg +
                                        "', ReceiptDocNum = " + OINV.ReceiptDocNum.ToString() + ", ReceiptErrMsg = '" + OINV.ReceiptErrMsg + "'";
                        ;
                        strSql += " Where id = " + OINV.id.ToString();
                        int noOfRowsAffected = context.Database.ExecuteSqlCommand(strSql);

                        Console.WriteLine(OINV.Order_Number.ToString());
                        //using (var Context1 = new POSStagingContext())
                        //{
                        //    var Orders1 = context.Orders.Where(o => o.id == OINV.id).FirstOrDefault<Order>();
                        //    Orders1.DocNum = OINV.DocNum;

                        //    Context1.SaveChanges();
                        //}

                        System.Runtime.InteropServices.Marshal.FinalReleaseComObject(Invoice);
                    }

                    //context.SaveChanges();
                    //Console.WriteLine(" ");
                    //Console.WriteLine("Context saved successfully");
                }
            }
            catch (Exception ex)
            {
                //if (oCompany.InTransaction)
                //{
                //    oCompany.EndTransaction(BoWfTransOpt.wf_RollBack);
                //}
                Console.WriteLine(ex.Message);
            }
        }
Beispiel #8
0
        // F o r m a t  L o y a l t y  R e c e i p t

        Receipt ITransactionService.FormatLoyaltyReceipt(ReceiptInformation RecInfo)
        {
            Merchant Merch;
            Receipt  aRec = new Receipt();

            using (GiftEntities GiftEntity = new GiftEntities())
            {
                IMerchantDAO MerchantData = new MerchantDAO(GiftEntity);
                Merch = MerchantData.GetMerchant(RecInfo.MerchantID);


                // format the header lines

                aRec.AddCentered(Merch.ReceiptHeaderLine1);
                aRec.AddCentered(Merch.ReceiptHeaderLine2);
                aRec.AddCentered(Merch.ReceiptHeaderLine3);
                aRec.AddCentered(Merch.ReceiptHeaderLine4);
                aRec.AddCentered(Merch.ReceiptHeaderLine5);

                // format the date & time line

                String TransactionDate;
                String TransactionTime;

                if (RecInfo.LocalTime != null)
                {
                    TransactionDate = RecInfo.LocalTime.ToShortDateString();
                    TransactionTime = RecInfo.LocalTime.ToShortTimeString();
                }
                else
                {
                    TransactionDate = RecInfo.When.ToShortDateString();
                    TransactionTime = RecInfo.When.ToShortTimeString();
                }
                aRec.JustifyBoth(TransactionDate, TransactionTime);
                if (RecInfo.TransactionNumber > 0)
                {
                    aRec.AddCentered("#: " + RecInfo.TransactionNumber.ToString());
                }

                // format the transaction type

                aRec.Add("");
                aRec.AddCentered(RecInfo.TransactionType);//Utils.getMappedMessage("Activate"));
                if (RecInfo.ApprovalMessage != null)
                {
                    if (RecInfo.ApprovalMessage.Length > 0)
                    {
                        aRec.AddCentered(RecInfo.ApprovalMessage);
                    }
                }

                aRec.Add("");
                if (RecInfo.CardNumber != null)
                {
                    if (RecInfo.CardNumber.Length > 0)
                    {
                        aRec.AddCentered("Account " + //Utils.getMappedMessage("Account") + " "
                                         aRec.GetPrintableCardNumber(RecInfo.CardNumber));
                    }
                    else
                    {
                        aRec.AddCentered("Phone: " + //Utils.getMappedMessage("Phone:") + " "
                                         RecInfo.PhoneNumber);
                    }
                }
                else
                {
                    aRec.AddCentered("Phone: " + //Utils.getMappedMessage("Phone:") + " "
                                     RecInfo.PhoneNumber);
                }


                // format the amount line

                if (RecInfo.Amount != null)
                {
                    aRec.Add("");
                    aRec.AddCentered("Amount: " + RecInfo.Amount); //Utils.getMappedMessage("Amount") + amount);
                }
                if (RecInfo.Description != null)
                {
                    if (RecInfo.Description.Length > 0)
                    {
                        aRec.Add("");
                        aRec.AddCentered(RecInfo.Description);
                    }
                }
                if (RecInfo.AdditionalMessage != null)
                {
                    if (RecInfo.AdditionalMessage.Length > 0)
                    {
                        aRec.Add("");
                        aRec.AddCentered(RecInfo.AdditionalMessage);
                    }
                }

                // add the footer lines

                aRec.Add("");
                aRec.Add(Merch.ReceiptFooterLine1);
                aRec.Add(Merch.ReceiptFooterLine2);
            }
            return(aRec);
        }