askrobots / dbbasic-object-server
Public
Runs live, versioned Python application objects on one VM, with a suite of apps: projects, notes, tasks, files and more.
rules.json · 15.7 KB · 58 lines
| 1 | { |
| 2 | "rules": [ |
| 3 | {"effect": "deny", "principal": "owner_fallback", "actions": ["update", "delete"], "collection": "correction_reasons", "reason": "reason codes are cited by voids, refunds, goodwill, remakes and waste records; a code deleted or renamed by whoever seeded it would leave those records citing nothing. Retire a code by marking it inactive (a manager's update grant below). This switches the owner fallback off; admins and in-process writers are unaffected"}, |
| 4 | {"effect": "allow", "principal": "role:cashier", "actions": ["read"], "collection": "correction_reasons", "reason": "a cashier picks a reason code when voiding or refunding"}, |
| 5 | {"effect": "allow", "principal": "role:shift_lead", "actions": ["read"], "collection": "correction_reasons", "reason": "a shift lead picks and approves reason codes"}, |
| 6 | {"effect": "allow", "principal": "role:manager", "actions": ["create", "read", "update"], "collection": "correction_reasons", "reason": "the codes are data a shop extends: a manager adds a code or retires one (active false), never deletes one a record cites"}, |
| 7 | {"effect": "allow", "principal": "role:owner", "actions": ["create", "read", "update"], "collection": "correction_reasons", "reason": "the owner extends the shop's reason codes, as a manager does"}, |
| 8 | {"effect": "allow", "principal": "role:cashier", "actions": ["execute"], "object_id": "action_counter_void", "reason": "taking an item off an UNPAID sale is till work: a cashier voids with a reason code, and the void changes the order and its invoice together. After payment the action refuses and a correction (with its approvals) is the only route"}, |
| 9 | {"effect": "allow", "principal": "role:shift_lead", "actions": ["execute"], "object_id": "action_counter_void", "reason": "a shift lead does the till work a cashier does"}, |
| 10 | {"effect": "allow", "principal": "role:manager", "actions": ["execute"], "object_id": "action_counter_void", "reason": "a manager does the till work a cashier does"}, |
| 11 | {"effect": "allow", "principal": "role:owner", "actions": ["execute"], "object_id": "action_counter_void", "reason": "the owner does the till work a cashier does"}, |
| 12 | {"effect": "deny", "principal": "owner_fallback", "actions": ["update", "delete"], "collection": "counter_approvals", "reason": "an approval is a manager's yes, given once: the approver (its owner) does not edit or remove it afterwards, or a refund could cite an approval for more than was approved. A mistaken one is never used. The action that spends it writes used_at in process; admins are unaffected"}, |
| 13 | {"effect": "allow", "principal": "role:cashier", "actions": ["read"], "collection": "counter_approvals", "reason": "a cashier reads the approval a manager gave them, to cite it"}, |
| 14 | {"effect": "allow", "principal": "role:shift_lead", "actions": ["create", "read"], "collection": "counter_approvals", "reason": "approving a correction a cashier may not make alone (over the store threshold, a needs-manager reason, goodwill, a remake) is shift lead, manager and owner work; whoever may create an approval also approves their own corrections"}, |
| 15 | {"effect": "allow", "principal": "role:manager", "actions": ["create", "read"], "collection": "counter_approvals", "reason": "approving a correction a cashier may not make alone (over the store threshold, a needs-manager reason, goodwill, a remake) is shift lead, manager and owner work; whoever may create an approval also approves their own corrections"}, |
| 16 | {"effect": "allow", "principal": "role:owner", "actions": ["create", "read"], "collection": "counter_approvals", "reason": "approving a correction a cashier may not make alone (over the store threshold, a needs-manager reason, goodwill, a remake) is shift lead, manager and owner work; whoever may create an approval also approves their own corrections"}, |
| 17 | {"effect": "allow", "principal": "role:cashier", "actions": ["execute"], "object_id": "action_counter_correct", "reason": "correcting a paid sale by a line refund or credit note citing the item: a cashier up to the store threshold, above it with a manager's approval, which the action checks; the ledger's locked checks cap the amount and the quantity whoever asks"}, |
| 18 | {"effect": "allow", "principal": "role:shift_lead", "actions": ["execute"], "object_id": "action_counter_correct", "reason": "correcting a paid sale by a line refund or credit note citing the item: a cashier up to the store threshold, above it with a manager's approval, which the action checks; the ledger's locked checks cap the amount and the quantity whoever asks"}, |
| 19 | {"effect": "allow", "principal": "role:manager", "actions": ["execute"], "object_id": "action_counter_correct", "reason": "correcting a paid sale by a line refund or credit note citing the item: a cashier up to the store threshold, above it with a manager's approval, which the action checks; the ledger's locked checks cap the amount and the quantity whoever asks"}, |
| 20 | {"effect": "allow", "principal": "role:owner", "actions": ["execute"], "object_id": "action_counter_correct", "reason": "correcting a paid sale by a line refund or credit note citing the item: a cashier up to the store threshold, above it with a manager's approval, which the action checks; the ledger's locked checks cap the amount and the quantity whoever asks"}, |
| 21 | {"effect": "allow", "principal": "role:cashier", "actions": ["execute"], "object_id": "action_counter_pay", "reason": "taking payment at the counter is a cashier's job; the action records a payment for a bill the caller may read, and the ledger's locked check refuses anything over the open balance"}, |
| 22 | {"effect": "allow", "principal": "role:shift_lead", "actions": ["execute"], "object_id": "action_counter_pay", "reason": "taking payment at the counter is a cashier's job; the action records a payment for a bill the caller may read, and the ledger's locked check refuses anything over the open balance"}, |
| 23 | {"effect": "allow", "principal": "role:manager", "actions": ["execute"], "object_id": "action_counter_pay", "reason": "taking payment at the counter is a cashier's job; the action records a payment for a bill the caller may read, and the ledger's locked check refuses anything over the open balance"}, |
| 24 | {"effect": "allow", "principal": "role:owner", "actions": ["execute"], "object_id": "action_counter_pay", "reason": "taking payment at the counter is a cashier's job; the action records a payment for a bill the caller may read, and the ledger's locked check refuses anything over the open balance"}, |
| 25 | {"effect": "allow", "principal": "role:cashier", "actions": ["execute"], "object_id": "action_counter_hand_over", "reason": "handing an order over the counter (served, or collected at pickup) is till work; the action moves the goods off the shelf and then marks the order collected, for an order the caller may read, and refuses one with money still owed unless it was booked to pay at pickup"}, |
| 26 | {"effect": "allow", "principal": "role:shift_lead", "actions": ["execute"], "object_id": "action_counter_hand_over", "reason": "handing an order over the counter (served, or collected at pickup) is till work; the action moves the goods off the shelf and then marks the order collected, for an order the caller may read, and refuses one with money still owed unless it was booked to pay at pickup"}, |
| 27 | {"effect": "allow", "principal": "role:manager", "actions": ["execute"], "object_id": "action_counter_hand_over", "reason": "handing an order over the counter (served, or collected at pickup) is till work; the action moves the goods off the shelf and then marks the order collected, for an order the caller may read, and refuses one with money still owed unless it was booked to pay at pickup"}, |
| 28 | {"effect": "allow", "principal": "role:owner", "actions": ["execute"], "object_id": "action_counter_hand_over", "reason": "handing an order over the counter (served, or collected at pickup) is till work; the action moves the goods off the shelf and then marks the order collected, for an order the caller may read, and refuses one with money still owed unless it was booked to pay at pickup"}, |
| 29 | {"effect": "deny", "principal": "owner_fallback", "actions": ["update", "delete"], "collection": "goodwill", "reason": "goodwill once given is a fact about what the customer was told and given; the manager who approved it (its owner) does not rewrite or remove it, and a refund paying it out is capped by its value. A mistake is a further record. Admins and in-process writers are unaffected"}, |
| 30 | {"effect": "deny", "principal": "owner_fallback", "actions": ["update", "delete"], "collection": "remakes", "reason": "a remake links a sold line, a waste move and a kitchen ticket line; the person who made it does not edit or remove the link afterwards. Written only by action_counter_remake"}, |
| 31 | {"effect": "allow", "principal": "role:shift_lead", "actions": ["create", "read"], "collection": "goodwill", "reason": "giving goodwill (something given although the charge was right) is a shift lead's, manager's or owner's call, and the giver is recorded as its approver; they also read the goodwill history to answer complaints"}, |
| 32 | {"effect": "allow", "principal": "role:manager", "actions": ["create", "read"], "collection": "goodwill", "reason": "giving goodwill (something given although the charge was right) is a shift lead's, manager's or owner's call, and the giver is recorded as its approver; they also read the goodwill history to answer complaints"}, |
| 33 | {"effect": "allow", "principal": "role:owner", "actions": ["create", "read"], "collection": "goodwill", "reason": "giving goodwill (something given although the charge was right) is a shift lead's, manager's or owner's call, and the giver is recorded as its approver; they also read the goodwill history to answer complaints"}, |
| 34 | {"effect": "allow", "principal": "role:cashier", "actions": ["read"], "collection": "remakes", "reason": "staff see what the kitchen remade and why"}, |
| 35 | {"effect": "allow", "principal": "role:cashier", "actions": ["execute"], "object_id": "action_counter_remake", "reason": "remaking a dish is kitchen and till work: the action writes a zero-priced ticket line, the waste move and the record linking them; a reason marked needs_manager needs an approval"}, |
| 36 | {"effect": "allow", "principal": "role:shift_lead", "actions": ["read"], "collection": "remakes", "reason": "staff see what the kitchen remade and why"}, |
| 37 | {"effect": "allow", "principal": "role:shift_lead", "actions": ["execute"], "object_id": "action_counter_remake", "reason": "remaking a dish is kitchen and till work: the action writes a zero-priced ticket line, the waste move and the record linking them; a reason marked needs_manager needs an approval"}, |
| 38 | {"effect": "allow", "principal": "role:manager", "actions": ["read"], "collection": "remakes", "reason": "staff see what the kitchen remade and why"}, |
| 39 | {"effect": "allow", "principal": "role:manager", "actions": ["execute"], "object_id": "action_counter_remake", "reason": "remaking a dish is kitchen and till work: the action writes a zero-priced ticket line, the waste move and the record linking them; a reason marked needs_manager needs an approval"}, |
| 40 | {"effect": "allow", "principal": "role:owner", "actions": ["read"], "collection": "remakes", "reason": "staff see what the kitchen remade and why"}, |
| 41 | {"effect": "allow", "principal": "role:owner", "actions": ["execute"], "object_id": "action_counter_remake", "reason": "remaking a dish is kitchen and till work: the action writes a zero-priced ticket line, the waste move and the record linking them; a reason marked needs_manager needs an approval"}, |
| 42 | {"effect": "deny", "principal": "owner_fallback", "actions": ["update", "delete"], "collection": "waste_logs", "reason": "a waste record is what was thrown away and where it went, including a licence the shop said it held; the person who recorded it does not rewrite or remove it afterwards. A mistake is a further record. Written only by action_counter_waste"}, |
| 43 | {"effect": "allow", "principal": "role:cashier", "actions": ["read"], "collection": "waste_logs", "reason": "staff read the shop's waste log"}, |
| 44 | {"effect": "allow", "principal": "role:cashier", "actions": ["execute"], "object_id": "action_counter_waste", "reason": "recording waste is kitchen and counter work: by count (with a waste stock move) or by weight per bin (an estimated cost), where it went and to whom, and the licence the shop holds for it; the reason code is checked"}, |
| 45 | {"effect": "allow", "principal": "role:shift_lead", "actions": ["read"], "collection": "waste_logs", "reason": "staff read the shop's waste log"}, |
| 46 | {"effect": "allow", "principal": "role:shift_lead", "actions": ["execute"], "object_id": "action_counter_waste", "reason": "recording waste is kitchen and counter work: by count (with a waste stock move) or by weight per bin (an estimated cost), where it went and to whom, and the licence the shop holds for it; the reason code is checked"}, |
| 47 | {"effect": "allow", "principal": "role:manager", "actions": ["read"], "collection": "waste_logs", "reason": "staff read the shop's waste log"}, |
| 48 | {"effect": "allow", "principal": "role:manager", "actions": ["execute"], "object_id": "action_counter_waste", "reason": "recording waste is kitchen and counter work: by count (with a waste stock move) or by weight per bin (an estimated cost), where it went and to whom, and the licence the shop holds for it; the reason code is checked"}, |
| 49 | {"effect": "allow", "principal": "role:owner", "actions": ["read"], "collection": "waste_logs", "reason": "staff read the shop's waste log"}, |
| 50 | {"effect": "allow", "principal": "role:owner", "actions": ["execute"], "object_id": "action_counter_waste", "reason": "recording waste is kitchen and counter work: by count (with a waste stock move) or by weight per bin (an estimated cost), where it went and to whom, and the licence the shop holds for it; the reason code is checked"}, |
| 51 | {"effect": "allow", "principal": "role:shift_lead", "actions": ["execute"], "object_id": "action_counter_history", "reason": "a shift lead or manager answers for the shop's sales and corrections and needs to see who changed what and why, without the admin token; the action shows only the shop's sale collections and only entries for records the caller may read"}, |
| 52 | {"effect": "allow", "principal": "role:shift_lead", "actions": ["execute"], "object_id": "action_counter_customer_history", "reason": "deciding goodwill and spotting a refund pattern needs a customer's complaints per month (disputes, line refunds, goodwill, remakes), folded from rows the caller may read"}, |
| 53 | {"effect": "allow", "principal": "role:manager", "actions": ["execute"], "object_id": "action_counter_history", "reason": "a shift lead or manager answers for the shop's sales and corrections and needs to see who changed what and why, without the admin token; the action shows only the shop's sale collections and only entries for records the caller may read"}, |
| 54 | {"effect": "allow", "principal": "role:manager", "actions": ["execute"], "object_id": "action_counter_customer_history", "reason": "deciding goodwill and spotting a refund pattern needs a customer's complaints per month (disputes, line refunds, goodwill, remakes), folded from rows the caller may read"}, |
| 55 | {"effect": "allow", "principal": "role:owner", "actions": ["execute"], "object_id": "action_counter_history", "reason": "a shift lead or manager answers for the shop's sales and corrections and needs to see who changed what and why, without the admin token; the action shows only the shop's sale collections and only entries for records the caller may read"}, |
| 56 | {"effect": "allow", "principal": "role:owner", "actions": ["execute"], "object_id": "action_counter_customer_history", "reason": "deciding goodwill and spotting a refund pattern needs a customer's complaints per month (disputes, line refunds, goodwill, remakes), folded from rows the caller may read"} |
| 57 | ] |
| 58 | } |