diff --git a/Layout/default/Preorder/Index.php b/Layout/default/Preorder/Index.php
index e912d9909..7d51d888d 100644
--- a/Layout/default/Preorder/Index.php
+++ b/Layout/default/Preorder/Index.php
@@ -27,6 +27,25 @@ $pagination_entity_name = "Vorbestellungen";
max-width: 650px;
}
+ .is-billed-button {
+ padding:6px;
+ padding-left: 8px;
+ padding-right: 8px;
+ background-color: #25b343;
+ color: #fff;
+ }
+
+ .set-billed-button {
+ padding:6px;
+ padding-left: 8px;
+ padding-right: 8px;
+ border: 1px solid #d0d0d0;
+ }
+ .set-billed-button:hover {
+ background-color: #007bff;
+ color: #fff;
+ }
+
@media (max-width: 1720px) {
.preorder-filters .col-sm-12 {
@@ -477,7 +496,19 @@ $pagination_entity_name = "Vorbestellungen";
=date('d.m.Y H:i', $preorder->edit)?>
-
adb_wohneinheit_id && is_array($preorder->adb_wohneinheit->rimo_workorders) && count($preorder->adb_wohneinheit->rimo_workorders)):?> |
+
+ address->hasPreorderBilling()): ?>
+ adb_wohneinheit_id && $preorder->adb_wohneinheit->enduser_setup_invoice_date): ?>
+ ">
+
+
+
+
+
+ adb_wohneinheit_id && is_array($preorder->adb_wohneinheit->rimo_workorders) && count($preorder->adb_wohneinheit->rimo_workorders)):?>
+
+
+ |
is(["preorderfront"]) && !$me->is("preorderreadonly")): ?>
@@ -595,6 +626,22 @@ $pagination_entity_name = "Vorbestellungen";
});
});
+ function setBilled(pid) {
+ if(!pid) return;
+
+ $.post("=self::getUrl("Preorder", "Api")?>", {
+ do: "setBilled",
+ id: pid
+ },
+ function(success) {
+ if(success.status == "OK") {
+ $("#preorder-" + pid + " .set-billed-button").parent().html("");
+ }
+ },
+ "json"
+ );
+ }
+
function attributeSuccess(result) {
var id = result.id
var attribute = result.attribute
diff --git a/Layout/default/PreorderBilling/Index.php b/Layout/default/PreorderBilling/Index.php
index f38e53526..942cb73bb 100644
--- a/Layout/default/PreorderBilling/Index.php
+++ b/Layout/default/PreorderBilling/Index.php
@@ -98,8 +98,7 @@ $pagination_entity_name = "Billingrecords";
-
-
+
" class="btn btn-outline-primary"> Rechnungen anzeigen
diff --git a/application/Address/Address.php b/application/Address/Address.php
index 5aaa52415..5b6785145 100644
--- a/application/Address/Address.php
+++ b/application/Address/Address.php
@@ -53,6 +53,19 @@ class Address extends mfBaseModel {
return $data;
}
+ public function hasPreorderBilling() {
+ if(!defined("TT_PREORDER_BILLING") || !is_array(TT_PREORDER_BILLING)) {
+ return false;
+ }
+ foreach(TT_PREORDER_BILLING as $conf) {
+ if(array_key_exists($this->id, $conf["netoperators"])) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
public function getCoords() {
$update_needed = false;
if($this->id) {
diff --git a/application/Preorder/PreorderController.php b/application/Preorder/PreorderController.php
index b1c223a2b..2411a9cc8 100644
--- a/application/Preorder/PreorderController.php
+++ b/application/Preorder/PreorderController.php
@@ -1067,6 +1067,9 @@ class PreorderController extends mfBaseController {
case "saveActivationdate":
$return = $this->saveActivationdateApi();
break;
+ case "setBilled":
+ $return = $this->setBilledApi();
+ break;
default:
$return = false;
}
@@ -1080,6 +1083,27 @@ class PreorderController extends mfBaseController {
$this->returnJson($data);
}
+ private function setBilledApi() {
+ $preorder_id = $this->request->id;
+
+ $preorder = new Preorder($preorder_id);
+ if(!$preorder->id) {
+ return false;
+ }
+
+ if(!$preorder->adb_wohneinheit_id) {
+ return false;
+ }
+
+ $today = new DateTime();
+ $today->setTimezone(new DateTimeZone("Europe/Vienna"));
+
+ $preorder->adb_wohneinheit->enduser_setup_invoice_date = $today->format("Y-m-d");
+ $preorder->adb_wohneinheit->save();
+
+ return ["message" => "Billed status updated", "pid" => $preorder_id, "date" => $today->format("Y-m-d")];
+ }
+
private function saveOrderdateApi() {
$preorder_id = $this->request->id;
$order_date = $this->request->order_date;
diff --git a/application/PreorderBilling/PreorderBilling.php b/application/PreorderBilling/PreorderBilling.php
index ef07d3c95..120f812b9 100644
--- a/application/PreorderBilling/PreorderBilling.php
+++ b/application/PreorderBilling/PreorderBilling.php
@@ -4,7 +4,7 @@ class PreorderBilling extends mfBaseModel {
protected $forcestr = ["product_name","product_info","matchcode"];
private $preorder;
private $invoice;
- private $vatgroup;
+ private $adb_wohneinheit;
public static $earliest_bill_date = "2025-01-01";
@@ -21,6 +21,13 @@ class PreorderBilling extends mfBaseModel {
return null;
}
+ if($name == "adb_wohneinheit") {
+ if(!$this->preorder_id) return null;
+ $preorder = $this->getProperty("preorder");
+ if(!$preorder || !$preorder->adb_wohneinheit_id) return null;
+ return $preorder->adb_wohneinheit;
+ }
+
if($name == "creator") {
$creator = mfValuecache::singleton()->get("Worker-id-".$this->create_by);
if($creator) {
@@ -77,9 +84,9 @@ class PreorderBilling extends mfBaseModel {
$model = new PreorderBilling();
$table_fields = [
- "netowner_id","invoice_id", "preorder_id", "oaid", "adb_wohneinheit_id", "order_date", "start_date", "end_date", "preorderbillingcustomer_id", "owner_id",
- "billingaddress_id", "fibu_account_number", "company", "firstname", "lastname", "street", "zip", "city", "country", "email", "uid",
- "billing_delivery", "product_id", "product_name", "product_info", "article_number", "amount", "unit", "price", "price_setup", "vatrate", "billing_period",
+ "netowner_id","invoice_id", "preorder_id", "product_type", "oaid", "adb_wohneinheit_id", "order_date", "start_date", "end_date", "preorderbillingcustomer_id",
+ "owner_id", "billingaddress_id", "fibu_account_number", "company", "firstname", "lastname", "street", "zip", "city", "country", "email", "uid", "billing_delivery",
+ "product_id", "product_type", "product_name", "product_info", "article_number", "amount", "unit", "price", "price_setup", "vatrate", "billing_period",
"create_by","edit_by","create","edit"
];
diff --git a/application/PreorderBilling/PreorderBillingController.php b/application/PreorderBilling/PreorderBillingController.php
index fbba0fbc1..d666e5fcc 100644
--- a/application/PreorderBilling/PreorderBillingController.php
+++ b/application/PreorderBilling/PreorderBillingController.php
@@ -148,7 +148,7 @@ class PreorderBillingController extends mfBaseController {
$now_day = date("d");
$today = new DateTime("$now_year-$now_month-$now_day");
- $today = new DateTime("2025-04-13");
+ //$today = new DateTime("2025-04-13");
$today->setTime(2,0,0);
$today->setTimezone(new DateTimeZone("Europe/Vienna"));
@@ -339,6 +339,7 @@ class PreorderBillingController extends mfBaseController {
"end_date" => $status_change_date->format("Y-m-d"),
"billing_delivery" => "email",
"product_id" => $product->id,
+ "product_type" => $product->type,
"product_info" => "",
"article_number" => $article_number,
"amount" => 1,
@@ -425,6 +426,11 @@ class PreorderBillingController extends mfBaseController {
die("Unknown billing type $type");
}
+ if(!$billing_data["unit"]) {
+ var_dump($billing_data);exit;
+ }
+
+
$billing = PreorderBilling::create($billing_data);
if(!$billing->save()) {
die("Billing record could not be saved!");
@@ -632,6 +638,7 @@ class PreorderBillingController extends mfBaseController {
"end_date" => $end_date->format("Y-m-d"),
"billing_delivery" => "email",
"product_id" => $product->id,
+ "product_type" => $product->type,
"product_info" => "",
"article_number" => $article_number,
"amount" => 1,
diff --git a/application/PreorderBillingInvoice/PreorderBillingInvoiceController.php b/application/PreorderBillingInvoice/PreorderBillingInvoiceController.php
index 4809b8f34..fa26ead89 100644
--- a/application/PreorderBillingInvoice/PreorderBillingInvoiceController.php
+++ b/application/PreorderBillingInvoice/PreorderBillingInvoiceController.php
@@ -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");
diff --git a/application/PreorderBillingInvoiceposition/PreorderBillingInvoiceposition.php b/application/PreorderBillingInvoiceposition/PreorderBillingInvoiceposition.php
index a07755670..993006cba 100644
--- a/application/PreorderBillingInvoiceposition/PreorderBillingInvoiceposition.php
+++ b/application/PreorderBillingInvoiceposition/PreorderBillingInvoiceposition.php
@@ -72,7 +72,7 @@ class PreorderBillingInvoiceposition extends mfBaseModel {
$model = new PreorderBillingInvoiceposition();
$table_fields = [
- "invoice_id", "billing_id", "start_date", "end_date", "product_id", "article_number", "article_name", "article_info",
+ "invoice_id", "billing_id", "start_date", "end_date", "product_id", "product_type", "article_number", "article_name", "article_info",
"amount", "unit", "price", "price_total", "price_gross", "vatrate", "billing_period",
"create_by","edit_by","create","edit"
];
diff --git a/db/migrations/20250325153459_adb_wohneinheit_add_enduser_setup_invoice_date.php b/db/migrations/20250325153459_adb_wohneinheit_add_enduser_setup_invoice_date.php
new file mode 100644
index 000000000..fa898481a
--- /dev/null
+++ b/db/migrations/20250325153459_adb_wohneinheit_add_enduser_setup_invoice_date.php
@@ -0,0 +1,33 @@
+getEnvironment() == "thetool") {
+
+ }
+
+ if($this->getEnvironment() == "addressdb") {
+ $table = $this->table("Wohneinheit");
+ $table->addColumn("enduser_setup_invoice_date", "date", ["null" => true, "default" => null, "after" => "nutzung"]);
+ $table->update();
+ }
+ }
+
+ public function down(): void
+ {
+ if($this->getEnvironment() == "thetool") {
+
+ }
+
+ if($this->getEnvironment() == "addressdb") {
+ $table = $this->table("Wohneinheit");
+ $table->removeColumn("enduser_setup_invoice_date");
+ $table->update();
+ }
+ }
+}
diff --git a/db/migrations/20250325160920_preorder_billing_add_product_type.php b/db/migrations/20250325160920_preorder_billing_add_product_type.php
new file mode 100644
index 000000000..5a91e60e4
--- /dev/null
+++ b/db/migrations/20250325160920_preorder_billing_add_product_type.php
@@ -0,0 +1,41 @@
+getEnvironment() == "thetool") {
+ $billing = $this->table("PreorderBilling");
+ $billing->addColumn("product_type", "string", ["limit" => 64, "null" => true, "after" => "product_id"]);
+ $billing->save();
+
+ $ip = $this->table("PreorderBillingInvoiceposition");
+ $ip->addColumn("product_type", "string", ["limit" => 64, "null" => true, "after" => "product_id"]);
+ $ip->save();
+ }
+
+ if($this->getEnvironment() == "addressdb") {
+
+ }
+ }
+
+ public function down(): void
+ {
+ if($this->getEnvironment() == "thetool") {
+ $billing = $this->table("PreorderBilling");
+ $billing->removeColumn("product_type");
+ $billing->save();
+
+ $invoice = $this->table("PreorderBillingInvoiceposition");
+ $invoice->removeColumn("product_type");
+ $invoice->save();
+ }
+
+ if($this->getEnvironment() == "addressdb") {
+
+ }
+ }
+}
|