diff --git a/public/pos/epos-print.js b/public/pos/epos-print.js
index 702ebbe..0b929ec 100644
--- a/public/pos/epos-print.js
+++ b/public/pos/epos-print.js
@@ -137,5 +137,30 @@ window.EposPrint = (function () {
}
}
- return { getSettings, setSettings, imageToRaster, buildEposXml, printViaNetwork };
+ // Mirrors the delivery-note ESC/POS builder in receipt.html's
+ // printDelivery() — same fields, same "Include prices" toggle.
+ function buildEposDeliveryXml(s, showPrices) {
+ const parts = [];
+ parts.push('WFSALES POS
');
+ parts.push('Delivery Note
');
+ if (s.customer && s.customer.company) parts.push(`Company: ${xmlEscape(s.customer.company)}
`);
+ parts.push(`Customer: ${xmlEscape((s.customer && s.customer.name) || '—')}
`);
+ const d = new Date(s.createdAt);
+ parts.push(`Date: ${xmlEscape(d.toLocaleDateString('en-ZA'))}
`);
+ parts.push('--------------------------------
');
+ const itemLines = s.items.map(it => {
+ const qtyLine = ` ${it.qty} ${it.unit || 'ea'}`;
+ const priceSuffix = showPrices ? ` R ${((it.selling_price || 0) * it.qty).toFixed(2)}` : '';
+ return `${xmlEscape(it.description || it.sku)}
${xmlEscape(qtyLine + priceSuffix)}
`;
+ }).join('');
+ parts.push(`${itemLines}`);
+ parts.push('--------------------------------
');
+ if (showPrices) parts.push(`TOTAL: R ${s.total.toFixed(2)}
`);
+ parts.push('Received by: __________ Driver: __________
');
+ parts.push('');
+ parts.push('');
+ return `${parts.join('')}`;
+ }
+
+ return { getSettings, setSettings, imageToRaster, buildEposXml, printViaNetwork, buildEposDeliveryXml };
})();
diff --git a/public/pos/receipt.html b/public/pos/receipt.html
index dd1d0ff..412cae4 100644
--- a/public/pos/receipt.html
+++ b/public/pos/receipt.html
@@ -651,6 +651,28 @@ async function printDelivery(){
errBox.classList.remove('err');
btn.disabled = true;
status.textContent = 'Printing delivery note…';
+ const printerSettings = window.EposPrint.getSettings();
+ if(printerSettings.type === 'network'){
+ if(!printerSettings.ip){
+ status.textContent = 'Set the printer IP address in Printer settings first.';
+ errBox.classList.add('err');
+ btn.disabled = false;
+ return;
+ }
+ const dnToggleNet = document.getElementById('dnShowPrices');
+ const showPricesNet = dnToggleNet ? !!dnToggleNet.checked : true;
+ try{
+ const xml = window.EposPrint.buildEposDeliveryXml(sale, showPricesNet);
+ await window.EposPrint.printViaNetwork(printerSettings.ip, xml);
+ status.textContent = 'Delivery note printed · ' + printerSettings.ip;
+ }catch(e){
+ errBox.classList.add('err');
+ status.textContent = 'DN print failed: ' + e.message;
+ }finally{
+ btn.disabled = false;
+ }
+ return;
+ }
if(!btChar){
status.textContent = 'Pair a Bluetooth printer first to print.';
errBox.classList.add('err');