diff --git a/core/views.py b/core/views.py index fd6251a..0236a76 100644 --- a/core/views.py +++ b/core/views.py @@ -1254,6 +1254,13 @@ def create_receipt(request): # Save the receipt header (but don't commit yet — need to set user) receipt = form.save(commit=False) receipt.user = request.user + # Set temporary zero values so the first save doesn't fail. + # (subtotal and total_amount have no default in the model, + # so they'd be NULL — which MariaDB rejects.) + # We'll recalculate these properly after saving line items. + receipt.subtotal = Decimal('0.00') + receipt.vat_amount = Decimal('0.00') + receipt.total_amount = Decimal('0.00') receipt.save() # Save line items — link them to this receipt