Beispiel #1
0
        public static void Print(Transaction tran, bool isReprint, bool isVoid, PrintingType ej = PrintingType.NormalPrinting)
        {
            if (ej == PrintingType.NormalPrinting)
            {
                RawPrinterHelper.OpenCashDrawer(true);
            }

            PrintReceipt(null, null, null, tran, isVoid, isReprint, false, ej);
        }
Beispiel #2
0
        public static Graphics PrintReceipt(object sender, PrintPageEventArgs e, Bitmap bmp, Transaction tran, bool isvoid, bool isreprint, bool customercopy, PrintingType ej = PrintingType.NormalPrinting)
        {
            // This actually doesnt use Graphics
            DataTable tempDataTable;
            int       value = 64;

            if (globalvariables.PrintReceiptFormat == PrintFormat.Custom_76mm_journal)
            {
                value = 40;
            }
            else if (globalvariables.PrintReceiptFormat == PrintFormat.Custom_JNF_57mm)
            {
                value = 42;
            }
            ReceiptPrinterHelper printer = new ReceiptPrinterHelper(value);

            if (globalvariables.PrintReceiptBuffer != 0)
            {
                printer.StringBufferWidth = globalvariables.PrintReceiptBuffer;
            }
            if (globalvariables.PrintReceiptActual != 0)
            {
                printer.StringFullWidth = globalvariables.PrintReceiptActual;
            }
            if (globalvariables.PrintReceiptLimit != 0)
            {
                printer.StringWidth = globalvariables.PrintReceiptLimit;
            }
            if (globalvariables.PrintReceiptLinespacing != 0)
            {
                printer.LineSpacing = globalvariables.PrintReceiptLinespacing;
            }

            // Header
            printer.LargeFont();
            printer.CPI12();
            if (globalvariables.BusinessName != "")
            {
                printer.WriteLines(globalvariables.BusinessName);
            }
            printer.NormalFont();
            printer.CPI12();
            if (globalvariables.Owner != "")
            {
                printer.WriteLines(globalvariables.Owner);
            }
            printer.WriteLines(((globalvariables.IsVatable) ?
                                "VAT REG. " : "NON VAT REG. ") + globalvariables.TIN);
            if (globalvariables.MIN != "")
            {
                printer.WriteLines(globalvariables.MIN);
            }
            if (globalvariables.Serial != "")
            {
                printer.WriteLines(globalvariables.Serial);
            }
            if (globalvariables.Address != "")
            {
                printer.WriteLines(globalvariables.Address);
            }
            if (globalvariables.TelNo != "")
            {
                printer.WriteLines("Tel.#: " + globalvariables.TelNo);
            }
            if (customercopy)
            {
                printer.WriteLines("Customer's Copy");
            }

            // Transaction Info
            tempDataTable = new DataTable();
            tempDataTable.Columns.Add();
            tempDataTable.Columns.Add();
            tempDataTable.Rows.Add("TERMINAL#: " + globalvariables.Terminal, "REF#:" + tran.ID.ToString());
            tempDataTable.Rows.Add("SI#: " + tran.InvoiceNumber, "TRAN#: " + tran.TransactionNo);
            tempDataTable.Rows.Add("DATE: " + tran.Date.ToShortDateString(), "TIME: " + tran.Date.ToLongTimeString());

            printer.WriteRepeatingCharacterLine('=');
            printer.WriteTable(
                tempDataTable,
                new StringAlignment[] { StringAlignment.Near, StringAlignment.Near },
                new int[] { printer.StringWidth / 2, printer.StringWidth / 2 }
                );

            tempDataTable = new DataTable();
            tempDataTable.Columns.Add();
            tempDataTable.Columns.Add();
            tempDataTable.Columns.Add();
            tempDataTable.Columns.Add();
            tempDataTable.Rows.Add("QTY", "", "DESCRIPTION", "AMOUNT");
            foreach (Product prod in tran.productlist)
            {
                string proddesc = prod.Name;
                tempDataTable.Rows.Add(prod.Qty.ToString("0.####"), "", proddesc, prod.Price.ToString("N2"));
            }
            printer.WriteRepeatingCharacterLine('=');
            printer.WriteTable(
                tempDataTable,
                new StringAlignment[] { StringAlignment.Far, StringAlignment.Far, StringAlignment.Near, StringAlignment.Far },
                new int[] { (int)(printer.StringWidth * 0.15), 1, (int)(printer.StringWidth * 0.6), (int)(printer.StringWidth * 0.25) }
                );

            printer.WriteRepeatingCharacterLine('=');
            // Discount Breakdown
            decimal total_sale  = tran.GetTotalAmountDue();
            decimal total_gross = tran.GetTotalAmountDue();

            // Sub-Total Info
            tempDataTable = new DataTable();
            tempDataTable.Columns.Add();
            tempDataTable.Columns.Add();
            decimal totalQuantity = tran.GetTotalQty();

            //totalQuantity -= tran.get_gcexcessamt() > 0 ? 1 : 0;
            tempDataTable.Rows.Add("Total QTY:", totalQuantity.ToString("0.####"));
            printer.WriteTable(
                tempDataTable,
                new StringAlignment[] { StringAlignment.Near, StringAlignment.Far },
                new int[] { printer.StringWidth / 2, printer.StringWidth / 2 }
                );
            printer.LargeFont();
            printer.CPI12();
            printer.WriteRow(
                new string[] { "AMOUNT DUE:", total_sale.ToString("N2") },
                new StringAlignment[] { StringAlignment.Near, StringAlignment.Far },
                new int[] { printer.StringWidth / 2, printer.StringWidth / 2 }
                );
            printer.NormalFont();
            printer.CPI12();

            // Payment
            decimal tendered_cash   = tran.TenderAmount;
            decimal tendered_change = tran.GetChange();

            tempDataTable = new DataTable();
            tempDataTable.Columns.Add(); tempDataTable.Columns.Add();
            int cnt_item_t = 0;

            //totalAmountDue -= gcexcessamt > 0 ? gcexcessamt : 0;
            printer.NormalFont();
            printer.CPI12();

            if (tendered_cash != 0)
            {
                tempDataTable.Rows.Add("Cash:", tendered_cash.ToString("N2"));
            }
            cnt_item_t++;


            tempDataTable.Rows.Add("Change:", tendered_change.ToString("N2"));


            printer.WriteTable(
                tempDataTable,
                new StringAlignment[] { StringAlignment.Near, StringAlignment.Far },
                new int[] { printer.StringWidth / 2, printer.StringWidth / 2 }
                );

            // Sub-Total Info
            tempDataTable = new DataTable();
            tempDataTable.Columns.Add();
            tempDataTable.Columns.Add();
            if (globalvariables.IsVatable)
            {
                decimal vat     = (total_sale / 1.12M) * 0.12M;
                decimal vatable = total_sale / 1.12M;
                tempDataTable.Rows.Add("VATABLE SALE:", vatable.ToString("N2"));
                printer.WriteRepeatingCharacterLine('=');
                // VAT
                tempDataTable.Rows.Add("VAT AMOUNT:", vat.ToString("N2"));
            }
            //gcexcess value is 0 if transaction is vatable for vat exempt breakdown
            printer.WriteTable(
                tempDataTable,
                new StringAlignment[] { StringAlignment.Near, StringAlignment.Far },
                new int[] { printer.StringWidth / 2, printer.StringWidth / 2 }
                );
            // POS Provider Info
            // Based on BIR Revenue Regulations No. 10-2015
            printer.WriteRepeatingCharacterLine('=');
            if (globalvariables.PosProviderName != "")
            {
                printer.WriteLines(globalvariables.PosProviderName);
            }
            if (globalvariables.PosProviderAddress != "")
            {
                printer.WriteLines(globalvariables.PosProviderAddress);
            }
            if (globalvariables.PosProviderTIN != "")
            {
                printer.WriteLines(globalvariables.PosProviderTIN);
            }
            if (globalvariables.Acc != "")
            {
                printer.WriteLines(globalvariables.Acc);
            }
            if (globalvariables.AccDate != "")
            {
                string validUntil = GetValidUntilDate(true);
                printer.WriteLines(globalvariables.AccDate);
                if (validUntil != "")
                {
                    printer.WriteLines("Valid Until: " + validUntil);
                }
            }
            if (globalvariables.PermitNo != "")
            {
                printer.WriteLines(globalvariables.PermitNo);
            }
            if (globalvariables.ApprovalDate != "")
            {
                string validUntil = GetValidUntilDate(false);
                printer.WriteLines("Date Issued: " + globalvariables.ApprovalDate);
                if (validUntil != "")
                {
                    printer.WriteLines("Valid Until: " + validUntil);
                }
            }
            printer.WriteLines("THIS INVOICE/RECEIPT SHALL BE VALID FOR FIVE(5) YEARS FROM THE DATE OF THE PERMIT TO USE.");

            // Footers
            printer.WriteRepeatingCharacterLine('=');
            if (globalvariables.OrFooter1 != "")
            {
                printer.WriteLines(globalvariables.OrFooter1);
            }
            if (globalvariables.OrFooter2 != "")
            {
                printer.WriteLines(globalvariables.OrFooter2);
            }
            if (globalvariables.OrFooter3 != "")
            {
                printer.WriteLines(globalvariables.OrFooter3);
            }
            if (globalvariables.OrFooter4 != "")
            {
                printer.WriteLines(globalvariables.OrFooter4);
            }

            // Based on BIR Revenue Regulations No. 10-2015
            printer.LargeFont();
            printer.CPI12();
            if (!globalvariables.IsVatable)
            {
                printer.WriteLines("THIS DOCUMENT IS NOT VALID FOR CLAIM OF INPUT TAX.");
            }
            printer.NormalFont();
            printer.CPI12();

            // Reprint/Voided Tag
            if (isvoid)
            {
                printer.WriteLines("VOIDED RECEIPT!");
            }
            if (isreprint)
            {
                printer.WriteLines("REPRINTED RECEIPT!");
            }
            else
            {
                DateTime now = DateTime.Now;
                printer.WriteLines("PRINTED: " + now.ToShortDateString() + " " + now.ToLongTimeString());
            }

            if (bmp == null)
            {
                printer.Print();
                if (ej == PrintingType.EJournalHardCopy || ej == PrintingType.NormalPrinting)
                {
                    printer.ActivateCutter();
                }
            }
            else
            {
                printer.PreviewOR(e, bmp);
            }

            return(null);
        }