Support decimal rupee prices (paise after the point)

PB number fields are float64 with onlyInt unset, so storage already
accepted decimals — verified 449.5 round-trips via API with no migration.
Cards now format fractional prices as ₹449.50 (whole rupees stay ₹449);
docs and type comments updated.
This commit is contained in:
2026-09-03 18:42:07 +05:30
parent bea6710d38
commit e3444dbc60
4 changed files with 13 additions and 4 deletions
+2 -1
View File
@@ -174,7 +174,8 @@ new) and touches nothing else.
- `name` / `variant` — variants are **separate products** whenever their price differs
("Penne Arrabiata" + variant "Veg" ₹589 / "Chicken" ₹639); the POS can group by `name`
- `description`
- `price` — number, whole rupees (449 = ₹449)
- `price` — number, rupees with optional paise after the decimal point
(449 = ₹449, 449.5 = ₹449.50)
- `diet` — select: `veg` / `nonveg` / `mixed` (a bool can't be null in PocketBase, so mixed
items like Caesar Salad use `mixed`; the site renders no badge for it)
- `pairing` — optional beer pairing
+8 -1
View File
@@ -62,6 +62,11 @@ export function MenuBrowser({
)
}
/** ₹449 for whole rupees, ₹449.50 when paise are set. */
function formatPrice(price: number): string {
return Number.isInteger(price) ? String(price) : price.toFixed(2)
}
function MenuCard({ item }: { item: MenuItem }) {
const icon = CATEGORY_ICONS[item.category] ?? 'restaurant'
const showFooter = Boolean(item.pairing || item.tag)
@@ -93,7 +98,9 @@ function MenuCard({ item }: { item: MenuItem }) {
<span className="text-on-surface-variant"> {item.variant}</span>
) : null}
</h3>
<span className="shrink-0 font-headline-md text-primary">{item.price}</span>
<span className="shrink-0 font-headline-md text-primary">
{formatPrice(item.price)}
</span>
</div>
{item.description ? (
<p className="text-body-md text-on-surface-variant">{item.description}</p>
+2 -1
View File
@@ -10,7 +10,8 @@
* - Variants are separate products whenever their price differs
* ("Penne Arrabiata" + variant "Veg" 589 / "Chicken" 639).
* - Same-price choice lists (flavours, sauces) stay on one item in `tag`.
* - price: number, whole rupees (449 = 449).
* - price: number, rupees with optional paise after the decimal point
* (449 = 449, 449.5 = 449.50).
* - diet: 'veg' | 'nonveg' | 'mixed' (PB bools can't be null, so a select is used).
* - sku: stable GB-<CAT>-<NNN> code for POS mapping.
* - tax_category: default "food-5-gst" adjust per item if the POS needs it.
+1 -1
View File
@@ -73,7 +73,7 @@ export interface MenuItem {
/** "Veg", "Chicken", "Basa", "Half"… — same dish, different product. */
variant?: string
description?: string
/** Whole rupees (449 = ₹449). */
/** Rupees as a decimal number; paise after the point (449.5 = ₹449.50). */
price: number
/** Dietary status; 'mixed' items (e.g. Caesar Salad) get no badge. */
diet?: 'veg' | 'nonveg' | 'mixed'