WIP PreorderBilling 2025-03-26
This commit is contained in:
@@ -27,6 +27,25 @@ $pagination_entity_name = "Vorbestellungen";
|
|||||||
max-width: 650px;
|
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) {
|
@media (max-width: 1720px) {
|
||||||
.preorder-filters .col-sm-12 {
|
.preorder-filters .col-sm-12 {
|
||||||
@@ -477,7 +496,19 @@ $pagination_entity_name = "Vorbestellungen";
|
|||||||
<span id="update-<?=$preorder->id?>"><?=date('d.m.Y H:i', $preorder->edit)?></span>
|
<span id="update-<?=$preorder->id?>"><?=date('d.m.Y H:i', $preorder->edit)?></span>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td><?php if($preorder->adb_wohneinheit_id && is_array($preorder->adb_wohneinheit->rimo_workorders) && count($preorder->adb_wohneinheit->rimo_workorders)):?><i class="fas fa-r" title="Rimo Workorder erstellt"></i><?php endif; ?></td>
|
<td class="text-nowrap">
|
||||||
|
<?php if(!$me->address->hasPreorderBilling()): ?>
|
||||||
|
<?php if($preorder->adb_wohneinheit_id && $preorder->adb_wohneinheit->enduser_setup_invoice_date): ?>
|
||||||
|
<i class="fas fa-euro is-billed-button" title="Herstellungsentgelt verrechnet am <?=(new DateTime($preorder->adb_wohneinheit->enduser_setup_invoice_date))->format("d.m.Y")?>"></i>
|
||||||
|
<?php else: ?>
|
||||||
|
<a href="#" class="text-muted" onclick="setBilled(<?=$preorder->id?>)"><i class="fas fa-euro set-billed-button" title="Herstellungsentgelt als verrechnet markieren"></i></a>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php if($preorder->adb_wohneinheit_id && is_array($preorder->adb_wohneinheit->rimo_workorders) && count($preorder->adb_wohneinheit->rimo_workorders)):?>
|
||||||
|
<i class="fas fa-r p-1" title="Rimo Workorder erstellt"></i>
|
||||||
|
<?php endif; ?>
|
||||||
|
</td>
|
||||||
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
|
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
|
||||||
<div class="preorder-campaign-table-actions">
|
<div class="preorder-campaign-table-actions">
|
||||||
<?php if(!$me->is(["preorderfront"]) && !$me->is("preorderreadonly")): ?>
|
<?php if(!$me->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("<i class='fas fa-euro is-billed-button' title='Herstellungsentgelt verrechnet am " + success.result.date + "'></i>");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"json"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function attributeSuccess(result) {
|
function attributeSuccess(result) {
|
||||||
var id = result.id
|
var id = result.id
|
||||||
var attribute = result.attribute
|
var attribute = result.attribute
|
||||||
|
|||||||
@@ -98,8 +98,7 @@ $pagination_entity_name = "Billingrecords";
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body mb-3">
|
<div class="card-body">
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<a href="<?=self::getUrl("PreorderBillingInvoice")?>" class="btn btn-outline-primary"><i class="fas fa-fw fa-list"></i> Rechnungen anzeigen</a>
|
<a href="<?=self::getUrl("PreorderBillingInvoice")?>" class="btn btn-outline-primary"><i class="fas fa-fw fa-list"></i> Rechnungen anzeigen</a>
|
||||||
|
|||||||
@@ -53,6 +53,19 @@ class Address extends mfBaseModel {
|
|||||||
return $data;
|
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() {
|
public function getCoords() {
|
||||||
$update_needed = false;
|
$update_needed = false;
|
||||||
if($this->id) {
|
if($this->id) {
|
||||||
|
|||||||
@@ -1067,6 +1067,9 @@ class PreorderController extends mfBaseController {
|
|||||||
case "saveActivationdate":
|
case "saveActivationdate":
|
||||||
$return = $this->saveActivationdateApi();
|
$return = $this->saveActivationdateApi();
|
||||||
break;
|
break;
|
||||||
|
case "setBilled":
|
||||||
|
$return = $this->setBilledApi();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
$return = false;
|
$return = false;
|
||||||
}
|
}
|
||||||
@@ -1080,6 +1083,27 @@ class PreorderController extends mfBaseController {
|
|||||||
$this->returnJson($data);
|
$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() {
|
private function saveOrderdateApi() {
|
||||||
$preorder_id = $this->request->id;
|
$preorder_id = $this->request->id;
|
||||||
$order_date = $this->request->order_date;
|
$order_date = $this->request->order_date;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ class PreorderBilling extends mfBaseModel {
|
|||||||
protected $forcestr = ["product_name","product_info","matchcode"];
|
protected $forcestr = ["product_name","product_info","matchcode"];
|
||||||
private $preorder;
|
private $preorder;
|
||||||
private $invoice;
|
private $invoice;
|
||||||
private $vatgroup;
|
private $adb_wohneinheit;
|
||||||
|
|
||||||
public static $earliest_bill_date = "2025-01-01";
|
public static $earliest_bill_date = "2025-01-01";
|
||||||
|
|
||||||
@@ -21,6 +21,13 @@ class PreorderBilling extends mfBaseModel {
|
|||||||
return null;
|
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") {
|
if($name == "creator") {
|
||||||
$creator = mfValuecache::singleton()->get("Worker-id-".$this->create_by);
|
$creator = mfValuecache::singleton()->get("Worker-id-".$this->create_by);
|
||||||
if($creator) {
|
if($creator) {
|
||||||
@@ -77,9 +84,9 @@ class PreorderBilling extends mfBaseModel {
|
|||||||
$model = new PreorderBilling();
|
$model = new PreorderBilling();
|
||||||
|
|
||||||
$table_fields = [
|
$table_fields = [
|
||||||
"netowner_id","invoice_id", "preorder_id", "oaid", "adb_wohneinheit_id", "order_date", "start_date", "end_date", "preorderbillingcustomer_id", "owner_id",
|
"netowner_id","invoice_id", "preorder_id", "product_type", "oaid", "adb_wohneinheit_id", "order_date", "start_date", "end_date", "preorderbillingcustomer_id",
|
||||||
"billingaddress_id", "fibu_account_number", "company", "firstname", "lastname", "street", "zip", "city", "country", "email", "uid",
|
"owner_id", "billingaddress_id", "fibu_account_number", "company", "firstname", "lastname", "street", "zip", "city", "country", "email", "uid", "billing_delivery",
|
||||||
"billing_delivery", "product_id", "product_name", "product_info", "article_number", "amount", "unit", "price", "price_setup", "vatrate", "billing_period",
|
"product_id", "product_type", "product_name", "product_info", "article_number", "amount", "unit", "price", "price_setup", "vatrate", "billing_period",
|
||||||
"create_by","edit_by","create","edit"
|
"create_by","edit_by","create","edit"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ class PreorderBillingController extends mfBaseController {
|
|||||||
$now_day = date("d");
|
$now_day = date("d");
|
||||||
|
|
||||||
$today = new DateTime("$now_year-$now_month-$now_day");
|
$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->setTime(2,0,0);
|
||||||
$today->setTimezone(new DateTimeZone("Europe/Vienna"));
|
$today->setTimezone(new DateTimeZone("Europe/Vienna"));
|
||||||
|
|
||||||
@@ -339,6 +339,7 @@ class PreorderBillingController extends mfBaseController {
|
|||||||
"end_date" => $status_change_date->format("Y-m-d"),
|
"end_date" => $status_change_date->format("Y-m-d"),
|
||||||
"billing_delivery" => "email",
|
"billing_delivery" => "email",
|
||||||
"product_id" => $product->id,
|
"product_id" => $product->id,
|
||||||
|
"product_type" => $product->type,
|
||||||
"product_info" => "",
|
"product_info" => "",
|
||||||
"article_number" => $article_number,
|
"article_number" => $article_number,
|
||||||
"amount" => 1,
|
"amount" => 1,
|
||||||
@@ -425,6 +426,11 @@ class PreorderBillingController extends mfBaseController {
|
|||||||
die("Unknown billing type $type");
|
die("Unknown billing type $type");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!$billing_data["unit"]) {
|
||||||
|
var_dump($billing_data);exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$billing = PreorderBilling::create($billing_data);
|
$billing = PreorderBilling::create($billing_data);
|
||||||
if(!$billing->save()) {
|
if(!$billing->save()) {
|
||||||
die("Billing record could not be saved!");
|
die("Billing record could not be saved!");
|
||||||
@@ -632,6 +638,7 @@ class PreorderBillingController extends mfBaseController {
|
|||||||
"end_date" => $end_date->format("Y-m-d"),
|
"end_date" => $end_date->format("Y-m-d"),
|
||||||
"billing_delivery" => "email",
|
"billing_delivery" => "email",
|
||||||
"product_id" => $product->id,
|
"product_id" => $product->id,
|
||||||
|
"product_type" => $product->type,
|
||||||
"product_info" => "",
|
"product_info" => "",
|
||||||
"article_number" => $article_number,
|
"article_number" => $article_number,
|
||||||
"amount" => 1,
|
"amount" => 1,
|
||||||
|
|||||||
@@ -267,6 +267,7 @@ class PreorderBillingInvoiceController extends mfBaseController {
|
|||||||
$position_data = [];
|
$position_data = [];
|
||||||
|
|
||||||
$position_data["product_id"] = $bill->product_id;
|
$position_data["product_id"] = $bill->product_id;
|
||||||
|
$position_data["product_type"] = $bill->product_type;
|
||||||
$position_data["article_number"] = $bill->article_number;
|
$position_data["article_number"] = $bill->article_number;
|
||||||
$position_data["product_name"] = $bill->product_name;
|
$position_data["product_name"] = $bill->product_name;
|
||||||
$position_data["product_info"] = $bill->product_info;
|
$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["price_gross"] += $position["total_gross"];
|
||||||
$new_pos_data["vatrate"] = $position_data["vatrate"];
|
$new_pos_data["vatrate"] = $position_data["vatrate"];
|
||||||
$new_pos_data["product_id"] = $position["product_id"];
|
$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_number"] = $position["article_number"];
|
||||||
$new_pos_data["article_name"] = $position["product_name"];
|
$new_pos_data["article_name"] = $position["product_name"];
|
||||||
$new_pos_data["preorder_billings"][] = $position["billing_id"];
|
$new_pos_data["preorder_billings"][] = $position["billing_id"];
|
||||||
@@ -420,8 +422,20 @@ class PreorderBillingInvoiceController extends mfBaseController {
|
|||||||
$invoice->rollbackTransaction();
|
$invoice->rollbackTransaction();
|
||||||
die("Bill for Invoiceposition not found");
|
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()) {
|
if (!$pbill->save()) {
|
||||||
$invoice->rollbackTransaction();
|
$invoice->rollbackTransaction();
|
||||||
die("error saving invoice_id to bill");
|
die("error saving invoice_id to bill");
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ class PreorderBillingInvoiceposition extends mfBaseModel {
|
|||||||
$model = new PreorderBillingInvoiceposition();
|
$model = new PreorderBillingInvoiceposition();
|
||||||
|
|
||||||
$table_fields = [
|
$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",
|
"amount", "unit", "price", "price_total", "price_gross", "vatrate", "billing_period",
|
||||||
"create_by","edit_by","create","edit"
|
"create_by","edit_by","create","edit"
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Phinx\Migration\AbstractMigration;
|
||||||
|
|
||||||
|
final class AdbWohneinheitAddEnduserSetupInvoiceDate extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
if($this->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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Phinx\Migration\AbstractMigration;
|
||||||
|
|
||||||
|
final class PreorderBillingAddProductType extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
if($this->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") {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user