Complete billedToTenant server action implementation

Implemented full server-side persistence for the billedToTenant property:

- Extract billedToTenant from formData in updateOrAddBill action
- Add to MongoDB $set operations for updating existing bills
- Include in new bill creation with value from form
- Set default value (true) for bills added to subsequent months
- Handle undefined values from existing database records using destructuring defaults

This completes the feature - bills can now track whether they should be
paid by the tenant, with backward compatibility for existing data.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Knee Cola
2025-11-17 13:30:47 +01:00
parent 0ae5140487
commit c3b555189b
2 changed files with 6 additions and 1 deletions

View File

@@ -29,7 +29,7 @@ export const BillEditForm:FC<BillEditFormProps> = ({ location, bill }) => {
const t = useTranslations("bill-edit-form");
const locale = useLocale();
const { _id: billID, name, paid, billedToTenant, attachment, notes, payedAmount: initialPayedAmount, barcodeImage: initialBarcodeImage } = bill ?? { _id:undefined, name:"", paid:false, billedToTenant:true, notes:"" };
const { _id: billID, name, paid, billedToTenant = true, attachment, notes, payedAmount: initialPayedAmount, barcodeImage: initialBarcodeImage } = bill ?? { _id:undefined, name:"", paid:false, notes:"" };
const { yearMonth:{year: billYear, month: billMonth}, _id: locationID } = location;