diff --git a/pos/src/lib/invoice-api.ts b/pos/src/lib/invoice-api.ts index f3a3e28..4513687 100644 --- a/pos/src/lib/invoice-api.ts +++ b/pos/src/lib/invoice-api.ts @@ -133,6 +133,9 @@ export async function getInvoicePrintHtml(invoiceId: string, printFormat: string name: invoiceId, print_format: printFormat, _lang: 'en', + no_letterhead: 1, + letterhead:"No Letterhead", + settings:{} } ); return response.message.html; @@ -159,13 +162,6 @@ export async function selectNetworkPrinter(orderId: string, posProfile: string, }); } -export async function printPosPage(orderId: string, printFormat: string) { - await call.post('ury.ury.api.ury_print.print_pos_page', { - doctype: 'POS Invoice', - name: orderId, - print_format: printFormat, - }); -} export async function updatePrintStatus(orderId: string) { await call.post('ury.ury.api.ury_print.qz_print_update', { invoice: orderId }); diff --git a/pos/src/lib/print.ts b/pos/src/lib/print.ts index 7976a41..2e555ee 100644 --- a/pos/src/lib/print.ts +++ b/pos/src/lib/print.ts @@ -3,7 +3,6 @@ import { getInvoicePrintHtml, networkPrint, selectNetworkPrinter, - printPosPage, updatePrintStatus } from './invoice-api'; import { PosProfileCombined } from './pos-profile-api'; @@ -33,7 +32,9 @@ export async function printOrder({ orderId, posProfile }: PrintOrderParams): Pro await updatePrintStatus(orderId); return 'network'; } else { - await printPosPage(orderId, print_format as string); + // Redirect to printview page + const url=`/printview?doctype=POS Invoice&name=${orderId}&format=${print_format}&no_letterhead=1&settings={}&letterhead=No Letterhead&trigger_print=1&_lang=en`; + window.open(url, '_blank', 'noopener,noreferrer'); return 'socket'; } -} \ No newline at end of file +} \ No newline at end of file diff --git a/urypos/src/stores/invoiceData.js b/urypos/src/stores/invoiceData.js index b196995..e784638 100644 --- a/urypos/src/stores/invoiceData.js +++ b/urypos/src/stores/invoiceData.js @@ -576,21 +576,11 @@ export const useInvoiceDataStore = defineStore("invoiceData", { }; } } else { - const sendObj = { - doctype: "POS Invoice", - name: invoiceNo, - print_format: this.print_format, - }; - this.call - .post("ury.ury.api.ury_print.print_pos_page", sendObj) - .then((result) => { - this.notification.createNotification("Print Successful"); - this.isPrinting = false - window.location.reload(); - - return result.message; - }) - .catch((error) => console.error(error)); + // Socket printing using printview redirection + const url = `/printview?doctype=POS Invoice&name=${invoiceNo}&format=${this.print_format}&no_letterhead=1&settings={}&letterhead=No Letterhead&trigger_print=1&_lang=en`; + window.open(url, "_blank", "noopener,noreferrer"); + this.notification.createNotification("Print triggered"); + this.isPrinting = false; } } catch (e) { if (e?.custom) {