feat(backend,waiter,manager): prices changed by hand are on the record
Owner 2026-11-23 (plan 6F.3). services/price_changes.py: the venue's switch orders.price_change (off | before_sending | anytime, default anytime as before), orders.price_change_reason and its quick reasons; keys ordering.prices.modify (the cart), new modify_sent (a sent or served line) and view_changes (who sees them). Every by-hand price (waiter cart, a sent line, the counter's % discount) writes a manual_price PriceEventLog row (before, after, quantity, who, approving manager, stage, reason) plus a PRICE_CHANGED audit row; before, the sent-line change overwrote the price with no record. Alembic 0047: event columns; modify_sent for everyone holding modify (and the venues' role overrides), view_changes for owners and store managers. Waiter: the reason picker when the venue asks, a sent line's price on modify_sent and the venue's switch, the line's price history. Manager: Settings -> Operation 'Prices changed by hand', the changes on the order's lines and history, Reports -> Cancellations, discounts and price changes (+ export). Counter: no discount when the venue turned price changes off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// Order lines: what POST /api/orders/{id}/items and POST /api/orders/quote take (plan step 4.4).
|
||||
//
|
||||
// An app never sends a price. A line says what was chosen, by id (sub-choices by name):
|
||||
// { product_id, quantity, notes?, course_id?, price_adjustment?, is_service_item?,
|
||||
// { product_id, quantity, notes?, course_id?, price_adjustment?, price_reason?, is_service_item?,
|
||||
// quick: [{id, qty?}], options: [{id, qty?, subs: [name]}],
|
||||
// prefs: [{set_id, choices: [{id, qty?, sub?}], shared?}], removed: [ingredient_id] }
|
||||
// and the server prices it (local_backend/services/pos_cart.py; the counter POS builds the
|
||||
@@ -108,6 +108,7 @@ export function wireLine(item, product) {
|
||||
if (item.notes?.trim()) line.notes = item.notes.trim()
|
||||
if (item.course_id != null) line.course_id = item.course_id
|
||||
if (item.price_adjustment) line.price_adjustment = cents(item.price_adjustment)
|
||||
if (item.price_adjustment && item.price_reason) line.price_reason = String(item.price_reason).slice(0, 200) // 6F.3
|
||||
if (item.is_service_item) line.is_service_item = true
|
||||
return line
|
||||
}
|
||||
|
||||
@@ -64,6 +64,12 @@ test('a price changed by hand and a service item travel with the line; nothing e
|
||||
assert.deepEqual(line, { product_id: 1, quantity: 1, price_adjustment: -1, is_service_item: true })
|
||||
})
|
||||
|
||||
test('the reason for a price changed by hand travels with it, never alone (6F.3)', () => {
|
||||
assert.deepEqual(wireLine({ product_id: 1, quantity: 1, price_adjustment: -0.5, price_reason: 'Regular customer' }, burger),
|
||||
{ product_id: 1, quantity: 1, price_adjustment: -0.5, price_reason: 'Regular customer' })
|
||||
assert.deepEqual(wireLine({ product_id: 1, quantity: 1, price_reason: 'nothing changed' }, burger), { product_id: 1, quantity: 1 })
|
||||
})
|
||||
|
||||
test('what is not on the menu any more is refused, not dropped', () => {
|
||||
assert.throws(() => lineFromOptions(burger, { selected_options: [e('extra', 99, 'Truffle')] }), LineError)
|
||||
assert.throws(() => lineFromOptions(burger, { selected_options: [e('quick', null, 'Bacon')] }), LineError)
|
||||
|
||||
@@ -102,7 +102,10 @@
|
||||
"discounts_off": "Οι εκπτώσεις είναι απενεργοποιημένες σε αυτό το κατάστημα.",
|
||||
"no_customer": "Ορίστε πρώτα πελάτη στην παραγγελία.",
|
||||
"item_not_tabbable": "Αυτό το είδος είναι ήδη {{status}}: δεν μπαίνει σε καρτέλα.",
|
||||
"product_unavailable": "Το προϊόν {{product_id}} δεν είναι διαθέσιμο."
|
||||
"product_unavailable": "Το προϊόν {{product_id}} δεν είναι διαθέσιμο.",
|
||||
"price_change_off": "Η αλλαγή τιμής με το χέρι είναι κλειστή σε αυτό το κατάστημα.",
|
||||
"price_change_sent_off": "Οι τιμές αλλάζουν μόνο πριν σταλούν τα είδη.",
|
||||
"price_reason_required": "Γράψτε γιατί αλλάζει η τιμή."
|
||||
},
|
||||
"notification": {
|
||||
"not_found": "Η ειδοποίηση {{notification_id}} δεν βρέθηκε."
|
||||
|
||||
@@ -739,6 +739,25 @@
|
||||
"spoof": "Προσποιητή εκτύπωση",
|
||||
"spoofHint": "Κάθε εκτύπωση απορρίπτεται· οι εφαρμογές συμπεριφέρονται σαν να τυπώθηκε.",
|
||||
"spoofOn": "Ενεργό: οι εκτυπωτές δεν τυπώνουν τίποτα."
|
||||
},
|
||||
"prices": {
|
||||
"title": "Τιμές που αλλάζουν με το χέρι",
|
||||
"intro": "Πότε το προσωπικό γράφει δική του τιμή σε μια γραμμή και αν πρέπει να πει γιατί. Κάθε αλλαγή κρατιέται: ποιος, πότε, από πόσο σε πόσο, γιατί.",
|
||||
"when": "Το προσωπικό αλλάζει τιμή",
|
||||
"whenHint": "Ποιος: «Τι επιτρέπεται σε κάθε ρόλο» και τα δικαιώματα κάθε ατόμου.",
|
||||
"whenTip": "Ποτέ: κανείς δεν γράφει τιμή, ούτε οι ιδιοκτήτες. Πριν την αποστολή: μόνο στο καλάθι, πριν πάει η παραγγελία στην κουζίνα. Οποτεδήποτε: και σε γραμμή που έχει σταλεί ή σερβιριστεί (θέλει δικό του δικαίωμα, «ήδη σταλμένο ή σερβιρισμένο»).",
|
||||
"modes": {
|
||||
"off": "Ποτέ",
|
||||
"before_sending": "Μόνο πριν την αποστολή",
|
||||
"anytime": "Οποτεδήποτε"
|
||||
},
|
||||
"reason": "Να ζητείται αιτία",
|
||||
"reasonHint": "Μια τιμή που αλλάζει με το χέρι δεν αποθηκεύεται χωρίς αιτία.",
|
||||
"reasonTip": "Η αιτία κρατιέται με την αλλαγή και φαίνεται στο ιστορικό της παραγγελίας και στις Αναφορές → Ακυρώσεις, εκπτώσεις και αλλαγές τιμών. Οι εκπτώσεις % του ταμείου δεν ζητούν: η έκπτωση λέει τι είναι.",
|
||||
"reasons": "Γρήγορες αιτίες",
|
||||
"reasonsHint": "Με ένα πάτημα· το προσωπικό μπορεί και να γράψει δική του. Καμία: οι έτοιμες.",
|
||||
"reasonItem": "Γρήγορη αιτία",
|
||||
"newReason": "Νέα γρήγορη αιτία…"
|
||||
}
|
||||
},
|
||||
"logs": {
|
||||
@@ -2290,7 +2309,8 @@
|
||||
"event": {
|
||||
"waiter_discount": "Έκπτωση",
|
||||
"free_item_added": "Δωρεάν",
|
||||
"modifier_applied": "Τροποποιητής"
|
||||
"modifier_applied": "Τροποποιητής",
|
||||
"manual_price": "Τιμή με το χέρι"
|
||||
}
|
||||
},
|
||||
"orderStatus": {
|
||||
@@ -3368,7 +3388,9 @@
|
||||
"PAYMENT_OFFLINE": "Πληρωμή (offline)",
|
||||
"ORDER_CLOSED": "Κλείσιμο",
|
||||
"ORDER_CANCELLED": "Ακύρωση",
|
||||
"ITEM_CANCELLED": "Ακύρωση γραμμής"
|
||||
"ITEM_CANCELLED": "Ακύρωση γραμμής",
|
||||
"PRICE_CHANGED": "Αλλαγή τιμής",
|
||||
"PRICE_SET_BY_HAND": "Τιμή με το χέρι (εγκρίθηκε)"
|
||||
},
|
||||
"price": {
|
||||
"modifier_applied": "Κανόνας τιμής",
|
||||
@@ -3377,7 +3399,14 @@
|
||||
"deal_offer_accepted": "Προσφορά (αποδεκτή)",
|
||||
"deal_offer_dismissed": "Προσφορά (απορρίφθηκε)",
|
||||
"waiter_discount": "Έκπτωση",
|
||||
"free_item_added": "Δωρεάν προϊόν"
|
||||
"free_item_added": "Δωρεάν προϊόν",
|
||||
"manual_price": "Τιμή με το χέρι"
|
||||
},
|
||||
"approvedBy": "με έγκριση {{name}}",
|
||||
"stage": {
|
||||
"cart": "πριν την αποστολή",
|
||||
"sent": "μετά την αποστολή",
|
||||
"served": "μετά το σερβίρισμα"
|
||||
}
|
||||
},
|
||||
"add": {
|
||||
@@ -4069,7 +4098,7 @@
|
||||
}
|
||||
},
|
||||
"misc": {
|
||||
"title": "Ακυρώσεις και εκπτώσεις",
|
||||
"title": "Ακυρώσεις, εκπτώσεις και αλλαγές τιμών",
|
||||
"cancellations": "Ακυρώσεις",
|
||||
"discounts": "Εκπτώσεις",
|
||||
"when": "Πότε",
|
||||
@@ -4093,7 +4122,18 @@
|
||||
"discountTotal": "Σύνολο εκπτώσεων",
|
||||
"alreadyOff": "έχουν ήδη αφαιρεθεί από τα έσοδα",
|
||||
"times_one": "{{count}} φορά",
|
||||
"times_other": "{{count}} φορές"
|
||||
"times_other": "{{count}} φορές",
|
||||
"priceChanges": "Αλλαγές τιμών",
|
||||
"priceWas": "Ήταν",
|
||||
"priceNow": "Έγινε",
|
||||
"stage": "Πότε",
|
||||
"changedBy": "Άλλαξε από",
|
||||
"approvedBy": "Ενέκρινε",
|
||||
"changes": "Αλλαγές τιμών",
|
||||
"changesValue": "Διαφορά",
|
||||
"changesValueTip": "Τι πρόσθεσαν (+) ή αφαίρεσαν (−) οι αλλαγές, για την ποσότητα κάθε γραμμής τη στιγμή της αλλαγής.",
|
||||
"changesCount_one": "{{count}} αλλαγή",
|
||||
"changesCount_other": "{{count}} αλλαγές"
|
||||
},
|
||||
"tech": {
|
||||
"title": "Τεχνικά",
|
||||
|
||||
@@ -454,7 +454,9 @@
|
||||
"cancel": "Ακύρωση ειδών που έχουν σταλεί"
|
||||
},
|
||||
"prices": {
|
||||
"modify": "Αλλαγή τιμής είδους"
|
||||
"modify": "Αλλαγή τιμής είδους πριν σταλεί",
|
||||
"modify_sent": "Αλλαγή τιμής είδους που έχει ήδη σταλεί ή σερβιριστεί",
|
||||
"view_changes": "Προβολή τιμών που άλλαξαν με το χέρι (ποιος, πότε, γιατί)"
|
||||
},
|
||||
"business_day": {
|
||||
"manage": "Άνοιγμα και κλείσιμο της εργάσιμης ημέρας"
|
||||
|
||||
@@ -528,7 +528,8 @@
|
||||
"merge": "Σφάλμα συγχώνευσης",
|
||||
"moveItems": "Σφάλμα μεταφοράς αντικειμένων",
|
||||
"flags": "Σφάλμα αποθήκευσης σημαιών",
|
||||
"combine": "Σφάλμα συνδυασμού"
|
||||
"combine": "Σφάλμα συνδυασμού",
|
||||
"price": "Η τιμή δεν άλλαξε."
|
||||
},
|
||||
"openOrder": "Άνοιγμα Παραγγελίας",
|
||||
"noPaid": "Δεν υπάρχουν πληρωμένα αντικείμενα",
|
||||
@@ -857,5 +858,27 @@
|
||||
"accepted": "Στάλθηκε στην κουζίνα",
|
||||
"declined": "Απορρίφθηκε",
|
||||
"note": "Σημείωση: {{note}}"
|
||||
},
|
||||
"price": {
|
||||
"reason": "Γιατί αλλάζει η τιμή;",
|
||||
"reasonMissing": "Γράψτε γιατί αλλάζει η τιμή",
|
||||
"reasons": {
|
||||
"regular": "Τακτικός πελάτης",
|
||||
"mistake": "Λάθος τιμή στο μενού",
|
||||
"compensation": "Αποζημίωση για πρόβλημα",
|
||||
"manager": "Απόφαση υπευθύνου",
|
||||
"happyHour": "Προσφορά ημέρας",
|
||||
"other": "Άλλο"
|
||||
},
|
||||
"history": "Ιστορικό τιμής",
|
||||
"historySub": "Ποιος την άλλαξε, πότε και γιατί",
|
||||
"historyNone": "Καμία αλλαγή τιμής σε αυτή τη γραμμή.",
|
||||
"historyFailed": "Το ιστορικό τιμής δεν φόρτωσε.",
|
||||
"stage": {
|
||||
"cart": "πριν την αποστολή",
|
||||
"sent": "μετά την αποστολή",
|
||||
"served": "μετά το σερβίρισμα"
|
||||
},
|
||||
"approvedBy": "με έγκριση {{name}}"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +102,10 @@
|
||||
"discounts_off": "Discounts are turned off for this venue.",
|
||||
"no_customer": "Give the order a customer first.",
|
||||
"item_not_tabbable": "This item is already {{status}}: it can't go on a tab.",
|
||||
"product_unavailable": "Product {{product_id}} isn't available."
|
||||
"product_unavailable": "Product {{product_id}} isn't available.",
|
||||
"price_change_off": "Changing prices by hand is turned off for this venue.",
|
||||
"price_change_sent_off": "Prices can only be changed before the items are sent.",
|
||||
"price_reason_required": "Say why the price changes."
|
||||
},
|
||||
"notification": {
|
||||
"not_found": "Notification {{notification_id}} not found."
|
||||
|
||||
@@ -739,6 +739,25 @@
|
||||
"spoof": "Pretend to print",
|
||||
"spoofHint": "Every print job is dropped; the apps behave as if it printed.",
|
||||
"spoofOn": "On: the printers print nothing."
|
||||
},
|
||||
"prices": {
|
||||
"title": "Prices changed by hand",
|
||||
"intro": "When staff may type a line's own price, and whether they must say why. Every change is kept: who, when, from what to what, why.",
|
||||
"when": "Staff may change a price",
|
||||
"whenHint": "Who may: \"What each role may do\" and each person's permissions.",
|
||||
"whenTip": "Never: nobody types a price, owners included. Before sending: only in the cart, before the order goes to the kitchen. Any time: also a line already sent or served (needs its own permission, \"already sent or served\").",
|
||||
"modes": {
|
||||
"off": "Never",
|
||||
"before_sending": "Before sending only",
|
||||
"anytime": "Any time"
|
||||
},
|
||||
"reason": "Ask for a reason",
|
||||
"reasonHint": "A price changed by hand can't be saved without one.",
|
||||
"reasonTip": "The reason is kept with the change and shown in the order's history and in Reports → Cancellations, discounts and price changes. The counter's % discounts don't ask: the discount says what it is.",
|
||||
"reasons": "Quick reasons",
|
||||
"reasonsHint": "Offered with one tap; staff can still type their own. None: the built-in ones.",
|
||||
"reasonItem": "Quick reason",
|
||||
"newReason": "A new quick reason…"
|
||||
}
|
||||
},
|
||||
"logs": {
|
||||
@@ -2290,7 +2309,8 @@
|
||||
"event": {
|
||||
"waiter_discount": "Discount",
|
||||
"free_item_added": "Free",
|
||||
"modifier_applied": "Price change"
|
||||
"modifier_applied": "Price change",
|
||||
"manual_price": "Price changed by hand"
|
||||
}
|
||||
},
|
||||
"orderStatus": {
|
||||
@@ -3368,7 +3388,9 @@
|
||||
"PAYMENT_OFFLINE": "Payment (offline)",
|
||||
"ORDER_CLOSED": "Closed",
|
||||
"ORDER_CANCELLED": "Cancelled",
|
||||
"ITEM_CANCELLED": "Line cancelled"
|
||||
"ITEM_CANCELLED": "Line cancelled",
|
||||
"PRICE_CHANGED": "Price changed",
|
||||
"PRICE_SET_BY_HAND": "Price set by hand (approved)"
|
||||
},
|
||||
"price": {
|
||||
"modifier_applied": "Price rule",
|
||||
@@ -3377,7 +3399,14 @@
|
||||
"deal_offer_accepted": "Deal accepted",
|
||||
"deal_offer_dismissed": "Deal declined",
|
||||
"waiter_discount": "Discount",
|
||||
"free_item_added": "Free item"
|
||||
"free_item_added": "Free item",
|
||||
"manual_price": "Price changed by hand"
|
||||
},
|
||||
"approvedBy": "approved by {{name}}",
|
||||
"stage": {
|
||||
"cart": "before sending",
|
||||
"sent": "after sending",
|
||||
"served": "after serving"
|
||||
}
|
||||
},
|
||||
"add": {
|
||||
@@ -4069,7 +4098,7 @@
|
||||
}
|
||||
},
|
||||
"misc": {
|
||||
"title": "Cancellations and discounts",
|
||||
"title": "Cancellations, discounts and price changes",
|
||||
"cancellations": "Cancellations",
|
||||
"discounts": "Discounts",
|
||||
"when": "When",
|
||||
@@ -4093,7 +4122,18 @@
|
||||
"discountTotal": "Total off",
|
||||
"alreadyOff": "already taken off the revenue",
|
||||
"times_one": "{{count}} time",
|
||||
"times_other": "{{count}} times"
|
||||
"times_other": "{{count}} times",
|
||||
"priceChanges": "Price changes",
|
||||
"priceWas": "Was",
|
||||
"priceNow": "Became",
|
||||
"stage": "When",
|
||||
"changedBy": "Changed by",
|
||||
"approvedBy": "Approved by",
|
||||
"changes": "Prices changed",
|
||||
"changesValue": "Difference",
|
||||
"changesValueTip": "What the changes added (+) or took off (−), for each line's quantity at the time of the change.",
|
||||
"changesCount_one": "{{count}} change",
|
||||
"changesCount_other": "{{count}} changes"
|
||||
},
|
||||
"tech": {
|
||||
"title": "Technical",
|
||||
|
||||
@@ -454,7 +454,9 @@
|
||||
"cancel": "Cancel items already sent"
|
||||
},
|
||||
"prices": {
|
||||
"modify": "Change an item's price"
|
||||
"modify": "Change an item's price before it is sent",
|
||||
"modify_sent": "Change the price of an item already sent or served",
|
||||
"view_changes": "See prices changed by hand (who, when, why)"
|
||||
},
|
||||
"business_day": {
|
||||
"manage": "Open and close the business day"
|
||||
|
||||
@@ -528,7 +528,8 @@
|
||||
"merge": "Couldn't merge",
|
||||
"moveItems": "Couldn't move the items",
|
||||
"flags": "Couldn't save the flags",
|
||||
"combine": "Couldn't combine the lines"
|
||||
"combine": "Couldn't combine the lines",
|
||||
"price": "The price didn't change."
|
||||
},
|
||||
"openOrder": "Open an order",
|
||||
"noPaid": "No paid items",
|
||||
@@ -857,5 +858,27 @@
|
||||
"accepted": "Sent to the kitchen",
|
||||
"declined": "Declined",
|
||||
"note": "Note: {{note}}"
|
||||
},
|
||||
"price": {
|
||||
"reason": "Why does the price change?",
|
||||
"reasonMissing": "Say why the price changes",
|
||||
"reasons": {
|
||||
"regular": "Regular customer",
|
||||
"mistake": "Wrong price on the menu",
|
||||
"compensation": "Making up for a problem",
|
||||
"manager": "Manager's decision",
|
||||
"happyHour": "Offer of the day",
|
||||
"other": "Other"
|
||||
},
|
||||
"history": "Price history",
|
||||
"historySub": "Who changed it, when and why",
|
||||
"historyNone": "No price changes on this line.",
|
||||
"historyFailed": "The price history didn't load.",
|
||||
"stage": {
|
||||
"cart": "before sending",
|
||||
"sent": "after sending",
|
||||
"served": "after serving"
|
||||
},
|
||||
"approvedBy": "approved by {{name}}"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user