fix: wrap order.change access in try-catch to prevent crash on missing rounding_method

This commit is contained in:
Suherdy Yacob 2026-06-03 20:17:04 +07:00
parent ac9b328e51
commit 7279f740cd

View File

@ -899,7 +899,13 @@ patch(PosPrinterService.prototype, {
paymentAmount = typeof order.amountPaid === 'number' ? order.amountPaid : total; paymentAmount = typeof order.amountPaid === 'number' ? order.amountPaid : total;
} }
const change = typeof order.change === 'number' ? Math.max(0, order.change) : 0; let change = 0;
try {
// Accessing order.change might throw if rounding_method is undefined in config
change = typeof order.change === 'number' ? Math.max(0, order.change) : 0;
} catch (error) {
console.warn('[BluetoothPrint] Error accessing order.change (likely asymmetricRound issue):', error);
}
const paymentData = { method: paymentMethod, amount: paymentAmount, change }; const paymentData = { method: paymentMethod, amount: paymentAmount, change };