Beispiel #1
0
        public void Cetak(JualProduk jual, IList <HeaderNotaMiniPos> listOfHeaderNota, IList <FooterNotaMiniPos> listOfFooterNota,
                          int jumlahKarakter, int lineFeed, bool isCetakCustomer = true, bool isCetakKeteranganNota = true, int ukuranFont = 0,
                          string autocutCode = "", string openCashDrawerCode = "", string infoCopyright1 = "", string infoCopyright2 = "")
        {
            var garisPemisah         = StringHelper.PrintChar('=', jumlahKarakter);
            var isPrinterMiniPos58mm = jumlahKarakter <= 32;
            var textToPrint          = new StringBuilder();

            if (!Utils.IsRunningUnderIDE())
            {
                textToPrint.Append(ESCCommandHelper.InitializePrinter());

                if (openCashDrawerCode.Length > 0)
                {
                    textToPrint.Append(ESCCommandHelper.CustomeCode(openCashDrawerCode));
                }

                if (ukuranFont > 0)
                {
                    textToPrint.Append(ESCCommandHelper.FontNormal(ukuranFont));
                }
            }

            // cetak header
            foreach (var header in listOfHeaderNota)
            {
                if (header.keterangan.Length > 0)
                {
                    if (header.keterangan.Length > garisPemisah.Length)
                    {
                        header.keterangan = StringHelper.FixedLength(header.keterangan, garisPemisah.Length);
                    }

                    textToPrint.Append(CenterText(header.keterangan.Length, jumlahKarakter)).Append(header.keterangan).Append(ESCCommandHelper.LineFeed(1));
                }
            }

            // cetak garis
            textToPrint.Append(garisPemisah).Append(ESCCommandHelper.LineFeed(1));

            if (!Utils.IsRunningUnderIDE())
            {
                textToPrint.Append(ESCCommandHelper.LeftText());
            }

            // set tanggal, jam, user
            var tanggal = StringHelper.FixedLength(DateTimeHelper.DateToString(DateTime.Now), 10);
            var jam     = DateTimeHelper.TimeToString(DateTime.Now);

            var kasir = StringHelper.PrintChar(' ', (garisPemisah.Length - 18 - jual.Pengguna.nama_pengguna.Length) / 2) + jual.Pengguna.nama_pengguna;

            kasir = StringHelper.FixedLength(kasir, garisPemisah.Length - 18);

            // cetak tanggal, kasir, jam
            textToPrint.Append(tanggal);
            textToPrint.Append(kasir);                                    // pengguna
            textToPrint.Append(jam).Append(ESCCommandHelper.LineFeed(2)); // jam

            // cetak info nota
            textToPrint.Append("Nota   : ").Append(jual.nota).Append(ESCCommandHelper.LineFeed(1));
            textToPrint.Append("Tanggal: ").Append(DateTimeHelper.DateToString(jual.tanggal)).Append(ESCCommandHelper.LineFeed(1));

            if (jual.tanggal_tempo != null)
            {
                textToPrint.Append("Tempo  : ").Append(DateTimeHelper.DateToString(jual.tanggal_tempo)).Append(ESCCommandHelper.LineFeed(1));
            }

            if (isCetakCustomer)
            {
                textToPrint.Append(ESCCommandHelper.LineFeed(1));

                // cetak info customer
                textToPrint.Append("Kepada: ").Append(ESCCommandHelper.LineFeed(1));

                var namaCustomer = jual.is_sdac == true ? jual.Customer.nama_customer : jual.kirim_kepada;
                var alamat       = jual.is_sdac == true?jual.Customer.alamat.NullToString() : jual.kirim_alamat.NullToString();

                var telepon = jual.is_sdac == true?jual.Customer.telepon.NullToString() : jual.kirim_telepon.NullToString();

                textToPrint.Append(namaCustomer).Append(ESCCommandHelper.LineFeed(1));

                if (alamat.Length > 0)
                {
                    textToPrint.Append(alamat).Append(ESCCommandHelper.LineFeed(1));
                }

                if (telepon.Length > 0)
                {
                    textToPrint.Append("HP: " + telepon).Append(ESCCommandHelper.LineFeed(1));
                }
            }

            // cetak garis
            textToPrint.Append(garisPemisah).Append(ESCCommandHelper.LineFeed(1));

            // cetak item
            foreach (var item in jual.item_jual)
            {
                var produk = StringHelper.FixedLength(item.Produk.nama_produk, garisPemisah.Length);
                textToPrint.Append(produk).Append(ESCCommandHelper.LineFeed(1));

                if (item.keterangan.Length > 0)
                {
                    textToPrint.Append(item.keterangan).Append(ESCCommandHelper.LineFeed(1));
                }

                var jumlah = StringHelper.RightAlignment(item.jumlah.ToString(), 4);
                textToPrint.Append(jumlah);

                textToPrint.Append("  " + StringHelper.FixedLength("x", 3));

                var harga = StringHelper.RightAlignment(NumberHelper.NumberToString(item.harga_jual),
                                                        isPrinterMiniPos58mm ? 9 : 10);

                textToPrint.Append(harga);

                var diskon = StringHelper.RightAlignment(item.diskon.ToString(),
                                                         isPrinterMiniPos58mm ? 3 : 7);
                textToPrint.Append(diskon);

                var subTotal  = (item.jumlah - item.jumlah_retur) * item.harga_setelah_diskon;
                var sSubTotal = StringHelper.RightAlignment(NumberHelper.NumberToString(subTotal),
                                                            isPrinterMiniPos58mm ? garisPemisah.Length - 21 : garisPemisah.Length - 26);

                textToPrint.Append(sSubTotal).Append(ESCCommandHelper.LineFeed(1));
            }

            // cetak garis
            textToPrint.Append(garisPemisah).Append(ESCCommandHelper.LineFeed(1));

            var fixedLengthLabelFooter = 12;
            var fixedLengthValueFooter = garisPemisah.Length - fixedLengthLabelFooter - 3;

            // cetak footer
            if (jual.ongkos_kirim > 0)
            {
                textToPrint.Append(StringHelper.FixedLength("Kurir", fixedLengthLabelFooter));
                textToPrint.Append(" : " + jual.kurir).Append(ESCCommandHelper.LineFeed(1));

                textToPrint.Append(StringHelper.FixedLength("Ongkos Kirim", fixedLengthLabelFooter));
                textToPrint.Append(" : " + StringHelper.RightAlignment(NumberHelper.NumberToString(jual.ongkos_kirim), fixedLengthValueFooter)).Append(ESCCommandHelper.LineFeed(1));
            }

            textToPrint.Append(StringHelper.FixedLength("Total Item", fixedLengthLabelFooter));
            textToPrint.Append(" : " + StringHelper.RightAlignment(NumberHelper.NumberToString(jual.item_jual.Count), fixedLengthValueFooter)).Append(ESCCommandHelper.LineFeed(1));

            if (jual.diskon > 0)
            {
                textToPrint.Append(StringHelper.FixedLength("Diskon", fixedLengthLabelFooter));
                textToPrint.Append(" : " + StringHelper.RightAlignment(NumberHelper.NumberToString(jual.diskon), fixedLengthValueFooter)).Append(ESCCommandHelper.LineFeed(1));
            }

            if (jual.ppn > 0)
            {
                textToPrint.Append(StringHelper.FixedLength("PPN", fixedLengthLabelFooter));
                textToPrint.Append(" : " + StringHelper.RightAlignment(NumberHelper.NumberToString(jual.ppn), fixedLengthValueFooter)).Append(ESCCommandHelper.LineFeed(1));
            }

            textToPrint.Append(StringHelper.FixedLength("Total", fixedLengthLabelFooter));
            textToPrint.Append(" : " + StringHelper.RightAlignment(NumberHelper.NumberToString(jual.grand_total), fixedLengthValueFooter)).Append(ESCCommandHelper.LineFeed(1));

            if (jual.jumlah_bayar > 0)
            {
                textToPrint.Append(StringHelper.FixedLength("Jumlah Bayar", fixedLengthLabelFooter));
                textToPrint.Append(" : " + StringHelper.RightAlignment(NumberHelper.NumberToString(jual.jumlah_bayar), fixedLengthValueFooter)).Append(ESCCommandHelper.LineFeed(1));

                textToPrint.Append(StringHelper.FixedLength("Kembali", fixedLengthLabelFooter));
                textToPrint.Append(" : " + StringHelper.RightAlignment(NumberHelper.NumberToString(jual.jumlah_bayar - jual.grand_total), fixedLengthValueFooter)).Append(ESCCommandHelper.LineFeed(1));
            }

            // cetak garis
            textToPrint.Append(garisPemisah).Append(ESCCommandHelper.LineFeed(2));

            // cetak footer
            foreach (var footer in listOfFooterNota)
            {
                if (footer.keterangan.Length > 0)
                {
                    if (footer.keterangan.Length > garisPemisah.Length)
                    {
                        footer.keterangan = StringHelper.FixedLength(footer.keterangan, garisPemisah.Length);
                    }

                    textToPrint.Append(CenterText(footer.keterangan.Length, jumlahKarakter)).Append(footer.keterangan).Append(ESCCommandHelper.LineFeed(1));
                }
            }

            if (infoCopyright1.Length > 0)
            {
                textToPrint.Append(ESCCommandHelper.LineFeed(1));
                textToPrint.Append(CenterText(infoCopyright1.Length, jumlahKarakter)).Append(infoCopyright1).Append(ESCCommandHelper.LineFeed(1));
                textToPrint.Append(CenterText(infoCopyright2.Length, jumlahKarakter)).Append(infoCopyright2).Append(ESCCommandHelper.LineFeed(1));
            }

            textToPrint.Append(ESCCommandHelper.LineFeed(lineFeed));

            if (!Utils.IsRunningUnderIDE())
            {
                if (autocutCode.Length > 0)
                {
                    textToPrint.Append(ESCCommandHelper.CustomeCode(autocutCode));
                }

                RawPrintHelper.SendStringToPrinter(_printerName, textToPrint.ToString());
            }
            else
            {
                RawPrintHelper.SendStringToFile(textToPrint.ToString());
            }
        }
Beispiel #2
0
        public void Cetak(IList <ReportMesinKasir> listOfMesinKasir, IList <HeaderNotaMiniPos> listOfHeaderNota, int jumlahKarakter, int lineFeed, int ukuranFont = 0,
                          string autocutCode = "", string infoCopyright1 = "", string infoCopyright2 = "")
        {
            var garisPemisah         = StringHelper.PrintChar('=', jumlahKarakter);
            var isPrinterMiniPos58mm = jumlahKarakter <= 32;
            var textToPrint          = new StringBuilder();

            var totalSaldoAwal  = 0d;
            var totalItem       = 0;
            var totalDiskon     = 0d;
            var totalPPN        = 0d;
            var grandTotal      = 0d;
            var maxFormatNumber = isPrinterMiniPos58mm ? 9 : 10;

            if (!Utils.IsRunningUnderIDE())
            {
                textToPrint.Append(ESCCommandHelper.InitializePrinter());

                if (ukuranFont > 0)
                {
                    textToPrint.Append(ESCCommandHelper.FontNormal(ukuranFont));
                }
            }

            // cetak header
            foreach (var header in listOfHeaderNota)
            {
                if (header.keterangan.Length > 0)
                {
                    if (header.keterangan.Length > garisPemisah.Length)
                    {
                        header.keterangan = StringHelper.FixedLength(header.keterangan, garisPemisah.Length);
                    }

                    textToPrint.Append(CenterText(header.keterangan.Length, jumlahKarakter)).Append(header.keterangan).Append(ESCCommandHelper.LineFeed(1));
                }
            }

            textToPrint.Append(ESCCommandHelper.LineFeed(1));

            textToPrint.Append("Laporan Penjualan Per Kasir").Append(ESCCommandHelper.LineFeed(1));
            textToPrint.Append("Per tanggal: ").Append(DateTimeHelper.DateToString(DateTime.Today)).Append(ESCCommandHelper.LineFeed(2));

            if (!Utils.IsRunningUnderIDE())
            {
                textToPrint.Append(ESCCommandHelper.LeftText());
            }

            var kasir = listOfMesinKasir[0].Pengguna.nama_pengguna;

            textToPrint.Append("Kasir      : ").Append(kasir).Append(ESCCommandHelper.LineFeed(1));
            textToPrint.Append(garisPemisah).Append(ESCCommandHelper.LineFeed(2));

            var isAdaTransaksi = false;

            foreach (var mesin in listOfMesinKasir.Where(f => f.saldo_awal > 0 || (f.jual != null && f.jual.total_nota > 0)))
            {
                isAdaTransaksi = true;

                textToPrint.Append("Login      : "******"dd/MM/yyyy HH:mm:ss")).Append(ESCCommandHelper.LineFeed(1));
                textToPrint.Append("Saldo Awal : ").Append(StringHelper.RightAlignment(NumberHelper.NumberToString(mesin.saldo_awal), maxFormatNumber)).Append(ESCCommandHelper.LineFeed(1));
                textToPrint.Append(garisPemisah).Append(ESCCommandHelper.LineFeed(1));

                if (mesin.jual.total_nota > 0)
                {
                    foreach (var produk in mesin.item_jual)
                    {
                        textToPrint.Append(StringHelper.FixedLength(produk.nama_produk, garisPemisah.Length)).Append(ESCCommandHelper.LineFeed(1));

                        var jumlah = StringHelper.RightAlignment(produk.jumlah.ToString(), 4);
                        textToPrint.Append(jumlah);

                        textToPrint.Append("  " + StringHelper.FixedLength("x", 3));

                        var harga = StringHelper.RightAlignment(NumberHelper.NumberToString(produk.harga_jual), maxFormatNumber);
                        textToPrint.Append(harga);

                        var diskon = StringHelper.RightAlignment(produk.diskon.ToString(),
                                                                 isPrinterMiniPos58mm ? 3 : 7);

                        textToPrint.Append(diskon);

                        var subTotal  = produk.jumlah * produk.harga_jual_setelah_diskon;
                        var sSubTotal = StringHelper.RightAlignment(NumberHelper.NumberToString(subTotal),
                                                                    isPrinterMiniPos58mm ? garisPemisah.Length - 21 : garisPemisah.Length - 26);

                        textToPrint.Append(sSubTotal).Append(ESCCommandHelper.LineFeed(1));
                    }

                    textToPrint.Append(garisPemisah).Append(ESCCommandHelper.LineFeed(1));
                    textToPrint.Append("Total item : ").Append(StringHelper.RightAlignment(NumberHelper.NumberToString(mesin.item_jual.Count), maxFormatNumber)).Append(ESCCommandHelper.LineFeed(1));

                    if (mesin.jual.diskon > 0)
                    {
                        textToPrint.Append("Diskon     : ").Append(StringHelper.RightAlignment(NumberHelper.NumberToString(mesin.jual.diskon), maxFormatNumber)).Append(ESCCommandHelper.LineFeed(1));
                    }

                    if (mesin.jual.ppn > 0)
                    {
                        textToPrint.Append("PPN        : ").Append(StringHelper.RightAlignment(NumberHelper.NumberToString(mesin.jual.ppn), maxFormatNumber)).Append(ESCCommandHelper.LineFeed(1));
                    }

                    textToPrint.Append("Total      : ").Append(StringHelper.RightAlignment(NumberHelper.NumberToString(mesin.jual.grand_total), maxFormatNumber)).Append(ESCCommandHelper.LineFeed(1));
                    textToPrint.Append(garisPemisah).Append(ESCCommandHelper.LineFeed(1));

                    totalItem   += mesin.item_jual.Count;
                    totalDiskon += mesin.jual.diskon;
                    totalPPN    += mesin.jual.ppn;
                    grandTotal  += mesin.jual.grand_total;
                }
                else
                {
                    textToPrint.Append(">> Belum ada transaksi <<").Append(ESCCommandHelper.LineFeed(1));
                }

                textToPrint.Append(ESCCommandHelper.LineFeed(1));

                totalSaldoAwal += mesin.saldo_awal;
            }

            if (isAdaTransaksi)
            {
                textToPrint.Append("Grand Total:").Append(ESCCommandHelper.LineFeed(1));
                textToPrint.Append("Saldo Awal : ").Append(StringHelper.RightAlignment(NumberHelper.NumberToString(totalSaldoAwal), maxFormatNumber)).Append(ESCCommandHelper.LineFeed(1));
                textToPrint.Append("Total item : ").Append(StringHelper.RightAlignment(NumberHelper.NumberToString(totalItem), maxFormatNumber)).Append(ESCCommandHelper.LineFeed(1));

                if (totalDiskon > 0)
                {
                    textToPrint.Append("Diskon     : ").Append(StringHelper.RightAlignment(NumberHelper.NumberToString(totalDiskon), maxFormatNumber)).Append(ESCCommandHelper.LineFeed(1));
                }

                if (totalPPN > 0)
                {
                    textToPrint.Append("PPN        : ").Append(StringHelper.RightAlignment(NumberHelper.NumberToString(totalPPN), maxFormatNumber)).Append(ESCCommandHelper.LineFeed(1));
                }

                textToPrint.Append("Total      : ").Append(StringHelper.RightAlignment(NumberHelper.NumberToString(grandTotal), maxFormatNumber)).Append(ESCCommandHelper.LineFeed(1));
            }
            else
            {
                textToPrint.Append(">> Belum ada transaksi <<").Append(ESCCommandHelper.LineFeed(1));
            }

            if (infoCopyright1.Length > 0)
            {
                textToPrint.Append(ESCCommandHelper.LineFeed(1));
                textToPrint.Append(CenterText(infoCopyright1.Length, jumlahKarakter)).Append(infoCopyright1).Append(ESCCommandHelper.LineFeed(1));
                textToPrint.Append(CenterText(infoCopyright2.Length, jumlahKarakter)).Append(infoCopyright2).Append(ESCCommandHelper.LineFeed(1));
            }

            textToPrint.Append(ESCCommandHelper.LineFeed(lineFeed));

            if (!Utils.IsRunningUnderIDE())
            {
                if (autocutCode.Length > 0)
                {
                    textToPrint.Append(ESCCommandHelper.CustomeCode(autocutCode));
                }
            }

            if (!Utils.IsRunningUnderIDE())
            {
                RawPrintHelper.SendStringToPrinter(_printerName, textToPrint.ToString());
            }
            else
            {
                RawPrintHelper.SendStringToFile(textToPrint.ToString());
            }
        }
        public void Cetak(JualProduk jual, IList <HeaderNota> listOfHeaderNota, int jumlahBaris = 29, int jumlahKarakter = 80)
        {
            var garisPemisah = StringHelper.PrintChar('=', jumlahKarakter);

            var textToPrint = new StringBuilder();

            var rowCount = 0; // jumlah baris yang tercetak

            if (!Utils.IsRunningUnderIDE())
            {
                textToPrint.Append(ESCCommandHelper.InitializePrinter());
                textToPrint.Append(ESCCommandHelper.CenterText());
            }

            // cetak header
            foreach (var header in listOfHeaderNota)
            {
                if (header.keterangan.Length > 0)
                {
                    if (header.keterangan.Length > garisPemisah.Length)
                    {
                        header.keterangan = StringHelper.FixedLength(header.keterangan, garisPemisah.Length);
                    }

                    textToPrint.Append(header.keterangan).Append(ESCCommandHelper.LineFeed(1));

                    rowCount++;
                }
            }

            textToPrint.Append(ESCCommandHelper.LineFeed(1));
            rowCount++;

            if (!Utils.IsRunningUnderIDE())
            {
                textToPrint.Append(ESCCommandHelper.LeftText());
            }

            // cetak informasi nota
            textToPrint.Append("Nota   : ").Append(jual.nota).Append(ESCCommandHelper.LineFeed(1));
            textToPrint.Append("Tanggal: ").Append(DateTimeHelper.DateToString(jual.tanggal));

            if (jual.tanggal_tempo != null)
            {
                textToPrint.Append(StringHelper.PrintChar(' ', 4));
                textToPrint.Append("Tempo: ").Append(DateTimeHelper.DateToString(jual.tanggal_tempo)).Append(ESCCommandHelper.LineFeed(2));
            }
            else
            {
                textToPrint.Append(ESCCommandHelper.LineFeed(2));
            }

            rowCount += 4;

            // cetak informasi customer
            var namaCustomer = string.Empty;

            if (jual.is_sdac)
            {
                if (jual.Customer != null)
                {
                    namaCustomer = StringHelper.FixedLength(jual.Customer.nama_customer.NullToString(), jumlahKarakter - 10);
                }
            }
            else
            {
                namaCustomer = StringHelper.FixedLength(jual.kirim_kepada.NullToString(), jumlahKarakter - 10);
            }

            if (namaCustomer.Length > 0)
            {
                var alamat1 = jual.is_sdac ? jual.Customer.alamat.NullToString() : jual.kirim_alamat.NullToString();

                var gabungAlamat2 = jual.Customer.kecamatan.NullToString();
                gabungAlamat2 += gabungAlamat2.Length > 0 ? " - " + jual.Customer.kelurahan.NullToString() : jual.Customer.kelurahan.NullToString();
                gabungAlamat2 += gabungAlamat2.Length > 0 ? " - " + jual.Customer.kota.NullToString() : jual.Customer.kota.NullToString();
                gabungAlamat2 += gabungAlamat2.Length > 0 ? " - " + jual.Customer.kode_pos.NullToString() : jual.Customer.kode_pos.NullToString();

                var alamat2 = jual.is_sdac ? gabungAlamat2 : jual.kirim_kecamatan.NullToString();
                var alamat3 = jual.is_sdac ? jual.Customer.telepon.NullToString() : jual.kirim_kelurahan.NullToString();

                textToPrint.Append("Kepada : ").Append(namaCustomer).Append(ESCCommandHelper.LineFeed(1));
                rowCount++;

                textToPrint.Append("Alamat : ");

                var isAddLineFeed = true;

                if (alamat1.Length > 0)
                {
                    textToPrint.Append(StringHelper.FixedLength(alamat1, jumlahKarakter - 10)).Append(ESCCommandHelper.LineFeed(1));
                    rowCount++;
                    isAddLineFeed = false;
                }

                if (alamat2.Length > 0)
                {
                    textToPrint.Append(StringHelper.PrintChar(' ', 9)).Append(StringHelper.FixedLength(alamat2, jumlahKarakter - 10)).Append(ESCCommandHelper.LineFeed(1));
                    rowCount++;
                    isAddLineFeed = false;
                }

                if (alamat3.Length > 0)
                {
                    textToPrint.Append(StringHelper.PrintChar(' ', 9)).Append(StringHelper.FixedLength(alamat3, jumlahKarakter - 10)).Append(ESCCommandHelper.LineFeed(1));
                    rowCount++;
                    isAddLineFeed = false;
                }

                if (isAddLineFeed)
                {
                    textToPrint.Append(ESCCommandHelper.LineFeed(1));
                }
            }

            textToPrint.Append(garisPemisah).Append(ESCCommandHelper.LineFeed(1));

            // header tabel
            textToPrint.Append("NO");
            textToPrint.Append(StringHelper.PrintChar(' ', 2));
            textToPrint.Append("PRODUK");
            textToPrint.Append(StringHelper.PrintChar(' ', 34));
            textToPrint.Append("JUMLAH");
            textToPrint.Append(StringHelper.PrintChar(' ', 2));
            textToPrint.Append("HARGA");
            textToPrint.Append(StringHelper.PrintChar(' ', 4));
            textToPrint.Append("DISC (%)");
            textToPrint.Append(StringHelper.PrintChar(' ', 2));
            textToPrint.Append("SUB TOTAL").Append(ESCCommandHelper.LineFeed(1));

            textToPrint.Append(garisPemisah).Append(ESCCommandHelper.LineFeed(1));

            rowCount += 3;

            var lengthProduk   = 37;
            var lengthJumlah   = 5;
            var lengthHarga    = 9;
            var lengthDisc     = 5;
            var lengthSubTotal = 11;

            // cetak item
            var noUrut = 1;

            foreach (var item in jual.item_jual)
            {
                var strNoUrut = StringHelper.RightAlignment(noUrut.ToString(), 2);
                textToPrint.Append(strNoUrut).Append(StringHelper.PrintChar(' ', 2));

                var produk = StringHelper.FixedLength(item.Produk.nama_produk, lengthProduk);
                textToPrint.Append(produk).Append(StringHelper.PrintChar(' ', 2));

                var strJumlah = StringHelper.RightAlignment((item.jumlah - item.jumlah_retur).ToString(), lengthJumlah);
                textToPrint.Append(strJumlah).Append(StringHelper.PrintChar(' ', 2));

                var strHarga = StringHelper.RightAlignment(NumberHelper.NumberToString(item.harga_setelah_diskon), lengthHarga);
                textToPrint.Append(strHarga).Append(StringHelper.PrintChar(' ', 2));

                var strDisc = StringHelper.RightAlignment((item.diskon).ToString(), lengthDisc);
                textToPrint.Append(strDisc).Append(StringHelper.PrintChar(' ', 3));

                var subTotal    = (item.jumlah - item.jumlah_retur) * item.harga_setelah_diskon;
                var strSubTotal = StringHelper.RightAlignment(NumberHelper.NumberToString(subTotal), lengthSubTotal);
                textToPrint.Append(strSubTotal).Append(ESCCommandHelper.LineFeed(1));

                noUrut++;
                rowCount++;
            }

            // cetak footer
            textToPrint.Append(garisPemisah).Append(ESCCommandHelper.LineFeed(1));

            var lengthOngkosKirim = 11;

            if (jual.ongkos_kirim > 0)
            {
                textToPrint.Append(StringHelper.PrintChar(' ', 56));
                var strOngkosKirim = StringHelper.RightAlignment(NumberHelper.NumberToString(jual.ongkos_kirim), lengthOngkosKirim);
                textToPrint.Append("Ongkos Kirim:").Append(strOngkosKirim).Append(ESCCommandHelper.LineFeed(1));

                rowCount++;
            }

            if (jual.diskon > 0)
            {
                var strDiscNota = StringHelper.RightAlignment(NumberHelper.NumberToString(jual.diskon), lengthOngkosKirim);

                textToPrint.Append(StringHelper.PrintChar(' ', 56));
                textToPrint.Append("Diskon      :").Append(strDiscNota).Append(ESCCommandHelper.LineFeed(1));

                rowCount++;
            }

            if (jual.ppn > 0)
            {
                var strPPN = StringHelper.RightAlignment(NumberHelper.NumberToString(jual.ppn), lengthOngkosKirim);

                textToPrint.Append(StringHelper.PrintChar(' ', 56));
                textToPrint.Append("PPN         :").Append(strPPN).Append(ESCCommandHelper.LineFeed(1));

                rowCount++;
            }

            var strGrandTotal = StringHelper.RightAlignment(NumberHelper.NumberToString(jual.grand_total), lengthOngkosKirim);

            textToPrint.Append(StringHelper.PrintChar(' ', 56));
            textToPrint.Append("Total       :").Append(strGrandTotal).Append(ESCCommandHelper.LineFeed(1));

            textToPrint.Append(garisPemisah).Append(ESCCommandHelper.LineFeed(1));

            textToPrint.Append(StringHelper.PrintChar(' ', 8)).Append("Penerima");
            textToPrint.Append(StringHelper.PrintChar(' ', 40)).Append("Hormat Kami");
            textToPrint.Append(ESCCommandHelper.LineFeed(3));

            textToPrint.Append(StringHelper.PrintChar(' ', 6)).Append("------------");
            textToPrint.Append(StringHelper.PrintChar(' ', 37)).Append("-------------");

            rowCount += 6;

            // perhitungan sisa kertas untuk keperluan line feed
            var listOfMaxRow = new Dictionary <int, int>();

            for (int i = 1; i < 11; i++)
            {
                var key   = jumlahBaris * i;
                var value = key + 4;

                listOfMaxRow.Add(key, value);
            }

            var maxJumlahBaris = 0; // maksimal jumlah baris tercetak dalam satu halaman

            foreach (var item in listOfMaxRow)
            {
                maxJumlahBaris = item.Value;

                if (rowCount <= item.Key)
                {
                    break;
                }
            }

            var lineFeed = maxJumlahBaris - rowCount;

            textToPrint.Append(ESCCommandHelper.LineFeed(lineFeed));

            if (!Utils.IsRunningUnderIDE())
            {
                RawPrintHelper.SendStringToPrinter(_printerName, textToPrint.ToString());
            }
            else
            {
                RawPrintHelper.SendStringToFile(textToPrint.ToString());
            }
        }