diff --git a/api/src/helpers/kitchen-rounds.js b/api/src/helpers/kitchen-rounds.js index 8b5ad67a..58775574 100644 --- a/api/src/helpers/kitchen-rounds.js +++ b/api/src/helpers/kitchen-rounds.js @@ -220,7 +220,7 @@ function tickets(sale, settings = {}) { table: String(sale.table_number || ''), outlet: String(sale.outlet_snapshot?.name || ''), roomReference: String(sale.room_reference || ''), - orderNumber: String(sale.sales_id || sale.token_id || ''), + orderNumber: String(sale.takeaway_number || sale.token_id || sale.sales_id || ''), takeaway: String(sale.fulfilment || sale.dine_type || '') .toLowerCase() diff --git a/api/src/repositories/sale.repository.js b/api/src/repositories/sale.repository.js index cc184d4c..a9ab5d80 100644 --- a/api/src/repositories/sale.repository.js +++ b/api/src/repositories/sale.repository.js @@ -8314,6 +8314,7 @@ class SalesRepository { projection: { sales_id: 1, token_id: 1, + takeaway_number: 1, table_number: 1, 'outlet_snapshot.name': 1, room_reference: 1, diff --git a/api/src/services/kitchen-board.js b/api/src/services/kitchen-board.js index ba28b4bb..4b24c35c 100644 --- a/api/src/services/kitchen-board.js +++ b/api/src/services/kitchen-board.js @@ -67,7 +67,7 @@ function project(sale) { String(sale.fulfilment || sale.dine_type || '') .toLowerCase() .replace(/[\s_-]/g, '') === 'takeaway', - orderNumber: String(sale.takeaway_number || sale.sales_id || sale.token_id || ''), + orderNumber: String(sale.takeaway_number || sale.token_id || sale.sales_id || ''), outlet: String(sale.outlet_snapshot?.name || ''), roomReference: String(sale.room_reference || ''), placedAt: round.fired_at || round.ordered_at, diff --git a/api/tests/unit/services/a-coupon-works-on-the-ordering-page.test.js b/api/tests/unit/services/a-coupon-works-on-the-ordering-page.test.js index 701050dd..801eeeea 100644 --- a/api/tests/unit/services/a-coupon-works-on-the-ordering-page.test.js +++ b/api/tests/unit/services/a-coupon-works-on-the-ordering-page.test.js @@ -169,7 +169,9 @@ describe('the order is where the money is decided', () => { test('and it cannot make the shop pay the customer', () => { expect(order).toMatch(/Math\.max\(0, round\(foodTotal - couponDiscount\)\)/); /* On the food, not on the delivery fee. */ - expect(order).toMatch(/roundSaleTotal\(\s*round\(afterCoupon \+ deliveryFee \+ roomChargeTotal\)/); + expect(order).toMatch( + /roundSaleTotal\(\s*round\(afterCoupon \+ deliveryFee \+ roomChargeTotal\)/ + ); }); test('the redemption is recorded only after the order exists', () => { diff --git a/api/tests/unit/utils/a-shop-with-no-tables-has-no-table-rules.test.js b/api/tests/unit/utils/a-shop-with-no-tables-has-no-table-rules.test.js index 67500aff..9c0a8ea3 100644 --- a/api/tests/unit/utils/a-shop-with-no-tables-has-no-table-rules.test.js +++ b/api/tests/unit/utils/a-shop-with-no-tables-has-no-table-rules.test.js @@ -99,7 +99,9 @@ describe('the table limit asks whether there are tables', () => { ); test('a shop that does not run table service is never refused for a table', () => { - expect(REPO).toMatch(/const runsTableService = branchDoc\.table_options === true && !staffRoom;/); + expect(REPO).toMatch( + /const runsTableService = branchDoc\.table_options === true && !staffRoom;/ + ); expect(REPO).toMatch(/if \(runsTableService && openTableLimit > 0 && wantsTable\)/); }); diff --git a/tests/kitchen-service-rounds.test.js b/tests/kitchen-service-rounds.test.js index b7e0af9c..9a6433c6 100644 --- a/tests/kitchen-service-rounds.test.js +++ b/tests/kitchen-service-rounds.test.js @@ -34,6 +34,19 @@ const sale = () => ({ { timestamp: '2026-09-27T08:25:00Z', items: [line(1)] }, ], }); +test('both kitchen displays prefer the saved takeaway number, then token, then sale reference', () => { + const { project } = require('../api/src/services/kitchen-board'); + const order = Object.assign(sale(), { dine_type: 'Take away', sales_id: 'SID-9N33-27-0028', token_id: '3', takeaway_number: 2 }); + for (const display of [tickets, project]) { + assert.equal(display(order)[0].orderNumber, '2'); + const legacy = { ...order }; + delete legacy.takeaway_number; + assert.equal(display(legacy)[0].orderNumber, '3'); + delete legacy.token_id; + assert.equal(display(legacy)[0].orderNumber, 'SID-9N33-27-0028'); + assert.equal(display(order)[0].id, 's1:c0'); + } +}); test('later additions retain their own kitchen clock and service identity', () => { const order = sale(); order.kitchen_service = { c0i0: { quantity: 2, at: '2026-09-27T08:20:00Z' } };