Skip to content

Commit 69fd249

Browse files
committed
Add print comments checkbox, fix mobile layout, fix Capacitor dev banner
1 parent 449e801 commit 69fd249

7 files changed

Lines changed: 55 additions & 5 deletions

File tree

www/css/billing.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ select:focus, input:focus {
203203
margin: 12px 0;
204204
box-shadow: var(--shadow);
205205
display: flex;
206+
flex-wrap: nowrap;
206207
justify-content: space-around;
207208
gap: 16px;
208209
border: 1px solid var(--border-color);
@@ -211,6 +212,7 @@ select:focus, input:focus {
211212
.summary-item {
212213
text-align: center;
213214
flex: 1;
215+
white-space: nowrap;
214216
}
215217

216218
.summary-item span {

www/firebaseConfig.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,17 @@ const getEnvironment = () => {
2626
// 2. Check localStorage (persists across sessions)
2727
if (localStorage.getItem('appEnv')) return localStorage.getItem('appEnv');
2828

29-
// 3. Check if running on localhost
30-
if (window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1') {
29+
// 3. Check if running on localhost in a BROWSER (not Capacitor app)
30+
// Capacitor apps run from capacitor:// or file:// protocol, not http://localhost
31+
const isCapacitorApp = window.location.protocol === 'capacitor:' ||
32+
window.location.protocol === 'file:' ||
33+
window.Capacitor?.isNativePlatform?.();
34+
35+
if (!isCapacitorApp && (window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1')) {
3136
return 'development';
3237
}
3338

34-
// 4. Default to production
39+
// 4. Default to production (including Capacitor apps)
3540
return 'production';
3641
};
3742

www/js/modules/billing.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,6 +1038,7 @@ const BillingManager = {
10381038
const saleDue = Helpers.getInputInt('saleDueAmount');
10391039
const saleCustomer = Helpers.getInputText('saleCustomerName');
10401040
const saleComments = Helpers.getInputText('saleComments');
1041+
const printComments = document.getElementById('salePrintComments')?.checked || false;
10411042

10421043
const updatedSale = {
10431044
...bill,
@@ -1050,6 +1051,7 @@ const BillingManager = {
10501051
dueAmount: saleDue,
10511052
customerName: saleCustomer,
10521053
comments: saleComments,
1054+
printComments: printComments,
10531055
payment: {
10541056
online: saleOnline,
10551057
cash: saleCash,

www/js/modules/purchase.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,7 @@ const PurchaseManager = {
476476
const dueAmount = Helpers.getInputInt('dueAmount');
477477
const customerName = Helpers.getInputText('customerName');
478478
const comments = Helpers.getInputText('billComments');
479+
const printComments = document.getElementById('billPrintComments')?.checked || false;
479480

480481
if (onlinePayment === 0 && cashPayment === 0 && dueAmount === 0) {
481482
UIManager.showToast('Please enter at least one payment method (Cash, Online, or Due)');
@@ -506,6 +507,7 @@ const PurchaseManager = {
506507
dueAmount,
507508
customerName,
508509
comments,
510+
printComments,
509511
type: 'purchase',
510512
isPurchase: true,
511513
date: new Date().toISOString(),

www/js/modules/retail-sale.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,7 @@ const RetailSaleManager = {
453453
const saleDue = Helpers.getInputInt('saleDueAmount');
454454
const saleCustomer = Helpers.getInputText('saleCustomerName');
455455
const saleComments = Helpers.getInputText('saleComments');
456+
const printComments = document.getElementById('salePrintComments')?.checked || false;
456457

457458
if (saleOnline === 0 && saleCash === 0 && saleDue === 0) {
458459
UIManager.showToast('Please enter at least one payment method (Cash, Online, or Due)');
@@ -474,6 +475,7 @@ const RetailSaleManager = {
474475
dueAmount: saleDue,
475476
customerName: saleCustomer,
476477
comments: saleComments,
478+
printComments: printComments,
477479
type: 'retail',
478480
isPurchase: false,
479481
date: new Date().toISOString(),

www/js/services/printer.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,35 @@ class BluetoothPrinterManager {
367367
y += config.spacing.line;
368368
}
369369

370+
// Comments (टिप्पणी) - Only print if printComments flag is true and comments exist
371+
if (billData.printComments && billData.comments && billData.comments.trim()) {
372+
y += 8; // Gap before comments
373+
ctx.font = `${config.fonts.body.size}px Arial`;
374+
ctx.fillText('नोट:', config.padding.left, y);
375+
y += config.spacing.line;
376+
377+
// Word wrap comments to fit width
378+
const maxWidth = config.width - (config.padding.left * 2) - 10;
379+
const words = billData.comments.trim().split(' ');
380+
let line = '';
381+
382+
for (const word of words) {
383+
const testLine = line + (line ? ' ' : '') + word;
384+
const testWidth = ctx.measureText(testLine).width;
385+
if (testWidth > maxWidth && line) {
386+
ctx.fillText(line, config.padding.left + 5, y);
387+
y += config.spacing.line - 4;
388+
line = word;
389+
} else {
390+
line = testLine;
391+
}
392+
}
393+
if (line) {
394+
ctx.fillText(line, config.padding.left + 5, y);
395+
y += config.spacing.line;
396+
}
397+
}
398+
370399
return y;
371400
}
372401

www/templates/billing.html

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,11 @@ <h3>Bill Items</h3>
132132

133133
<div class="form-row" style="margin-top: 16px;">
134134
<label style="width: 100px;">Comments:</label>
135-
<input type="text" id="billComments" placeholder="GPay name, payment date, notes, etc. (Optional)" />
135+
<input type="text" id="billComments" placeholder="GPay name, payment date, notes, etc. (Optional)" style="flex: 1;" />
136+
<label style="display: flex; align-items: center; gap: 4px; margin-left: 8px; font-size: 12px; color: var(--text-secondary); white-space: nowrap;">
137+
<input type="checkbox" id="billPrintComments" style="width: 16px; height: 16px;" />
138+
Print
139+
</label>
136140
</div>
137141

138142
<!-- Canvas Debug Preview -->
@@ -255,7 +259,11 @@ <h3>Bill Items</h3>
255259

256260
<div class="form-row" style="margin-top: 16px;">
257261
<label style="width: 100px;">Comments:</label>
258-
<input type="text" id="saleComments" placeholder="GPay name, payment date, notes, etc. (Optional)" />
262+
<input type="text" id="saleComments" placeholder="GPay name, payment date, notes, etc. (Optional)" style="flex: 1;" />
263+
<label style="display: flex; align-items: center; gap: 4px; margin-left: 8px; font-size: 12px; color: var(--text-secondary); white-space: nowrap;">
264+
<input type="checkbox" id="salePrintComments" style="width: 16px; height: 16px;" />
265+
Print
266+
</label>
259267
</div>
260268

261269
<div style="display: flex; gap: 12px; margin-top: 16px;">

0 commit comments

Comments
 (0)