bidankita invoice print example
unknown
javascript
4 years ago
9.7 kB
4
Indexable
async function printInvoice(data){ await BluetoothEscposPrinter.printerInit(); await BluetoothEscposPrinter.printerLeftSpace(0); await BluetoothEscposPrinter.printerLineSpace(0); await BluetoothEscposPrinter.printerUnderLine(0); await BluetoothEscposPrinter.setBlob(0); let base64logo = "/9j/4AAQSkZJRgABAQIAdgB2AAD/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/wAALCAAqAJYBAREA/8QAHQAAAQQDAQEAAAAAAAAAAAAAAAQFBggCAwcBCf/EADAQAAEDAwQABQMDBAMAAAAAAAECAwQFBhEABxIhCBMiMUEUFVEWI2EkMnGBUpGh/9oACAEBAAA/APqno14pSUpKlEAAZJPsBqhfiX8ZO4lvbrSLc2ruamt0SjBpKnY7TUpMx4pCnApZB6BPHCSP7T3q4Gzm5FP3V28ot3xZcJyVLiNLnsRXgsRpJSObagDlJBz0e9TXRo0aNGjRo0aNGjRo0arh4ybmu6RT7V2bseYYVRv6c5GkSeZR5cRsJLmVD2T6sqP/ABSofOqR3ZtIxWK4/G2Iod1XZRaSwmPOqiaepbb8pJPmLa4A4bPXEHvH+c67HtUqlbRXFaG6m01bqrltVepxrXu+iVEcX4MxwAZWkdYJytB9wQRnsgXK3r3PkbS2Ym6YlBFYfdqEantRTJ8gKW8viklfE4wf40yW1vLdSL/pm3O523Jtmo16O+/SpEaptzo8ksjk42VJSkoUE99jvU3otw16pXVXKNNtcw6XTQx9DU/rG3EzitJLgDafU3wIx376Yt590DtdZMq6IESLUZUWVEjqiLf4YDz6Gyo4yRgLz7fGpy9MiRggypTLPmHCfMWE8j+Bn31sK0JxyUByOBk+51gzKjSFLQxIacU2eKwhYJSfwce2uPWn4lrerFt39ddx0z7JT7Eqj9NeWqQHTKKOklI4jClHACe+z76V0neS9qxsw7upG2qk/XyAHaZQhOBflMFSQlwkoHHIJVxAJ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BBGU4UoL9CeSic5x1lwk3DfM+rU6nw7e+3MvTHVmRKX6Vx0tlSAUpyQVZGQeOCMd9nWup3FelNuyoxqbQHalHSy0pDZKkoKQypSlIUfSP3CEkdqV8D0k68qF7XwiLmn2HLU9IIMZa28owGeWFp5BSVFwKSOXEAYJOTx1sp91XWqt1B1Vo1RynGW2wlLhSlxsGOlQKEZxxK88iVdFQ/BwrqtcuaBdChBoUubCbhRVyEIV6UFbrgX5fX7jgAScdelP8gFnqd5X5Miy2qZasiJ9S9HjxH5DRa+nC3S24pztRUpOUEYTx7PZAzqU2rVZ9QbfanUmZFeZddD6nivy/M8wgBor7UgpAUCPSAQAT3h/1qkxo8thcaWw28y4MLbcSFJUPwQejrNtttltLTSEoQgBKUpGAkD2AHxrLRpOuDCcltznIbC5LSSlt5TYK0A+4CvcaUaNGjRo0aNGjRo0a/9k=" await BluetoothEscposPrinter.printPic(base64logo, {width: 300, left: 25}); await BluetoothEscposPrinter.printText('\n\r', {}); await BluetoothEscposPrinter.printerAlign( BluetoothEscposPrinter.ALIGN.CENTER, ); await BluetoothEscposPrinter.printText('Jl. Piere Tendean No. 20,\n\r', {}); await BluetoothEscposPrinter.printText('Sidowayah, Klaten, Jawa Tengah\n\r', {}); await BluetoothEscposPrinter.printText('\n\r', {}); await BluetoothEscposPrinter.printerAlign( BluetoothEscposPrinter.ALIGN.LEFT, ); await BluetoothEscposPrinter.printText(moment(data.so_complete_datetime).format('dddd, DD MMMM YYYY H:mm:ss') + '\n\r', {}); await BluetoothEscposPrinter.printText('Kasir: ' + data.so_complete_admin_name + '\n\r', {}); await BluetoothEscposPrinter.printText('No Invoice: ' + data.so_number + '\n\r', {}, ); await BluetoothEscposPrinter.printText('No Trans.: ' + data.so_trans_number + '\n\r', {}, ); await BluetoothEscposPrinter.printText('Pelanggan: ' + data.so_customer_name + '\n\r', {}, ); if(data.so_is_wa !== undefined && data.so_is_wa === 'Y') { await BluetoothEscposPrinter.printText('Pembelian: Via WhatsApp\n\r', {}, ); } await BluetoothEscposPrinter.printText('--------------------------------\n\r',{},); let columnWidthsProduct = [10, 11, 11]; let columnAlignsProduct = [BluetoothEscposPrinter.ALIGN.LEFT, BluetoothEscposPrinter.ALIGN.RIGHT, BluetoothEscposPrinter.ALIGN.RIGHT] for(let i = 0 ; i < data.so_detail.length; i++){ let qty = data.so_detail[i].so_detail_product_qty let discount = MyHelpers.formatNumber(data.so_detail[i].so_detail_product_discount_value); let price = MyHelpers.formatNumber(data.so_detail[i].so_detail_product_unit_selling_price); let subTotalBeforeDisc = MyHelpers.formatNumber(data.so_detail[i].so_detail_product_unit_selling_price * qty); let priceNett = data.so_detail[i].so_detail_product_unit_selling_price - data.so_detail[i].so_detail_product_discount_value let subTotal = MyHelpers.formatNumber(priceNett * qty) await BluetoothEscposPrinter.printText(data.so_detail[i].so_detail_product_name + '\n\r', {}, ); await BluetoothEscposPrinter.printColumn( columnWidthsProduct, columnAlignsProduct, [`${MyHelpers.formatNumber(qty)} ${data.so_detail[i].so_detail_product_unit}`, `@${price}`, `${subTotalBeforeDisc}`], {}, ); if(data.so_detail[i].so_detail_product_discount_value > 0){ await BluetoothEscposPrinter.printColumn( columnWidthsProduct, columnAlignsProduct,[``, `Diskon`, `(${discount})`], {}); } } await BluetoothEscposPrinter.printText('--------------------------------\n\r', {}, ); let columnWidthsTotal = [17, 15] let columnAlignsTotal = [BluetoothEscposPrinter.ALIGN.RIGHT, BluetoothEscposPrinter.ALIGN.RIGHT] await BluetoothEscposPrinter.printColumn( columnWidthsTotal, columnAlignsTotal, [`Sub Total:`, `${MyHelpers.formatNumber(data.so_total_product_price, 'idr')}`], {}, ); await BluetoothEscposPrinter.printColumn(columnWidthsTotal, columnAlignsTotal, [`Diskon (${data.so_total_discount_percent}%):`, `${MyHelpers.formatNumber(data.so_total_discount_value, 'idr')}`], {}, ); await BluetoothEscposPrinter.printText('\n\r', {}); await BluetoothEscposPrinter.printColumn(columnWidthsTotal, columnAlignsTotal, [`Total:`, `${MyHelpers.formatNumber(data.so_grand_total, 'idr')}`], {}, ); await BluetoothEscposPrinter.printText('--------------------------------\n\r', {}, ); if (data.so_payment_method == 'cash') { await BluetoothEscposPrinter.printText('\n\r', {}); await BluetoothEscposPrinter.printColumn(columnWidthsTotal, columnAlignsTotal, [`Tunai:`, `${MyHelpers.formatNumber(data.so_grand_total, 'idr')}`], {}, ); await BluetoothEscposPrinter.printColumn(columnWidthsTotal, columnAlignsTotal, [`Kembalian:`, `${MyHelpers.formatNumber("0", 'idr')}`], {}, ); await BluetoothEscposPrinter.printText('--------------------------------\n\r', {}, ); }else{ if(data.so_payment_method == 'transfer') { await BluetoothEscposPrinter.printerAlign( BluetoothEscposPrinter.ALIGN.LEFT, ); await BluetoothEscposPrinter.printText('\n\r', {}); await BluetoothEscposPrinter.printText('Transfer Bank\n\r', {}); await BluetoothEscposPrinter.printText('Dari Bank: ' + data.so_transfer_bank_from_name + '\n\r', {}); await BluetoothEscposPrinter.printText('Ke Bank: ' + data.so_transfer_bank_to_name + '\n\r', {}); await BluetoothEscposPrinter.printText('--------------------------------\n\r', {}, ); } else { await BluetoothEscposPrinter.printerAlign( BluetoothEscposPrinter.ALIGN.LEFT, ); await BluetoothEscposPrinter.printText('\n\r', {}); await BluetoothEscposPrinter.printText('Bank: ' + data.so_edc_bank_name + '\n\r', {}); await BluetoothEscposPrinter.printText('Card: ' + data.so_card_number + '\n\r', {}); await BluetoothEscposPrinter.printText('--------------------------------\n\r', {}, ); } } await BluetoothEscposPrinter.printerAlign( BluetoothEscposPrinter.ALIGN.CENTER, ); await BluetoothEscposPrinter.printText('Bidan Kita\n\r', {}); await BluetoothEscposPrinter.printText('(www.bidankita.com)\n\r', {}); await BluetoothEscposPrinter.printText('\n\r\n\r\n\r\n\r', {}); }
Editor is loading...