WIP PreorderBilling 2025-03-26

This commit is contained in:
Frank Schubert
2025-03-26 14:06:23 +01:00
parent c73c2e2a86
commit e3a6d494ef
10 changed files with 195 additions and 10 deletions
@@ -267,6 +267,7 @@ class PreorderBillingInvoiceController extends mfBaseController {
$position_data = [];
$position_data["product_id"] = $bill->product_id;
$position_data["product_type"] = $bill->product_type;
$position_data["article_number"] = $bill->article_number;
$position_data["product_name"] = $bill->product_name;
$position_data["product_info"] = $bill->product_info;
@@ -307,6 +308,7 @@ class PreorderBillingInvoiceController extends mfBaseController {
$new_pos_data["price_gross"] += $position["total_gross"];
$new_pos_data["vatrate"] = $position_data["vatrate"];
$new_pos_data["product_id"] = $position["product_id"];
$new_pos_data["product_type"] = $position["product_type"];
$new_pos_data["article_number"] = $position["article_number"];
$new_pos_data["article_name"] = $position["product_name"];
$new_pos_data["preorder_billings"][] = $position["billing_id"];
@@ -420,8 +422,20 @@ class PreorderBillingInvoiceController extends mfBaseController {
$invoice->rollbackTransaction();
die("Bill for Invoiceposition not found");
}
$pbill->invoice_id = $invoice->id;
if($position->product_type == "enduser_setup") {
if(!$pbill->adb_wohneinheit) {
$invoice->rollbackTransaction();
die("Keine Wohneinheit für Preorder " . $pbill->preorder_id . " / bill " . $pbill->id);
}
$pbill->adb_wohneinheit->enduser_setup_invoice_date = $today->format("Y-m-d");
if(!$pbill->adb_wohneinheit->save()) {
$invoice->rollbackTransaction();
die("Error saving enduser_setup_invoice_date");
}
}
$pbill->invoice_id = $invoice->id;
if (!$pbill->save()) {
$invoice->rollbackTransaction();
die("error saving invoice_id to bill");