MultiUsersSalesSystem / services /tableService.js
Mahmoud7456's picture
Upload 72 files
0330133 verified
Raw History Blame Contribute Delete
628 Bytes
export const TableService = {
occupy: async (TableModel, tableId, invoiceId) => {
return TableModel.findByIdAndUpdate(
tableId,
{
status: "occupied",
currentOrderId: invoiceId || null, // ✅ track which invoice owns this table
},
{ new: true, runValidators: true }
);
},
free: async (TableModel, tableId) => {
return TableModel.findByIdAndUpdate(
tableId,
{
status: "available",
currentOrderId: null, // ✅ always clear the invoice ref when freeing
},
{ new: true, runValidators: true }
);
},
};