File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -30,6 +30,9 @@ BASE_URL=http://localhost:8000 # Also adjust this to your production url
3030# (restricts user creation endpoint to these devices)
3131CHECKOUT_BOX_SLUGS = nfckasse
3232
33+ # Optional: allow purchases when stock is 0 (stock goes negative, default: false)
34+ # ALLOW_NEGATIVE_STOCK=false
35+
3336# Currency symbol appended to all monetary amounts in API messages and PDF statements (default: €)
3437CURRENCY = €
3538
Original file line number Diff line number Diff line change 1111 require_checkout_device ,
1212 require_product_manager_user ,
1313)
14+ from app .config import settings
1415from app .auth .oidc import is_product_manager
1516from app .database import get_db
1617from app .models .machine import Machine
@@ -345,7 +346,7 @@ def purchase_product(
345346 product = _resolve_product (ean , db )
346347 if not product .active :
347348 raise HTTPException (status_code = 400 , detail = "Product is not active" )
348- if product .stock <= 0 :
349+ if product .stock <= 0 and not settings . ALLOW_NEGATIVE_STOCK :
349350 raise HTTPException (status_code = 400 , detail = "Product out of stock" )
350351
351352 user = db .execute (
Original file line number Diff line number Diff line change @@ -27,6 +27,9 @@ class Settings(BaseSettings):
2727 # Devices
2828 CHECKOUT_BOX_SLUGS : str = ""
2929
30+ # Allow purchases when stock is 0 (stock goes negative)
31+ ALLOW_NEGATIVE_STOCK : bool = False
32+
3033 # PDF statement generation (typst)
3134 # Directory containing extra fonts (e.g. albertsans.ttf). Leave empty to use system fonts only.
3235 TYPST_FONT_DIR : str = ""
You can’t perform that action at this time.
0 commit comments