Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/src/helpers/kitchen-rounds.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions api/src/repositories/sale.repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion api/src/services/kitchen-board.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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\)/);
});

Expand Down
13 changes: 13 additions & 0 deletions tests/kitchen-service-rounds.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' } };
Expand Down
Loading