Merge branch 'fronkdev' into 'master'

sepa_date & contract_term

See merge request fronk/thetool!218
This commit is contained in:
Frank Schubert
2024-02-06 19:49:37 +00:00
17 changed files with 428 additions and 30 deletions
@@ -243,6 +243,8 @@ class AddressController extends mfBaseController {
$data['uid'] = trim($r->uid);
if($this->me->can("Fibu")) {
$data["sepa_date"] = ($r->sepa_date) ? Layout::dateToInt($r->sepa_date) : null;
$data['fibu_account_number'] = ($r->fibu_account_number) ? trim($r->fibu_account_number) : null;
$data['fibu_supplier_number'] = ($r->fibu_supplier_number) ? trim($r->fibu_supplier_number) : null;
if($r->fibu_primary_account) {
@@ -283,6 +285,13 @@ class AddressController extends mfBaseController {
if($r->billing_type == "sepa") {
$data['billing_type'] = "sepa";
if(!$r->sepa_date) {
if($mode == "add" || ($mode == "edit" && !$address->sepa_date)) {
$data['sepa_date'] = date('U');
}
} else {
$data['sepa_date'] = $r->sepa_date;
}
} else {
$data['billing_type'] = "invoice";
}
+10
View File
@@ -8,6 +8,7 @@ class AddressModel {
public $fibu_supplier_due;
public $fibu_supplier_skonto;
public $fibu_supplier_skonto_rate;
public $fibu_supplier_paymentblock;
public $fibu_primary_account;
public $spin;
public $company;
@@ -28,6 +29,7 @@ class AddressModel {
public $bank_account_owner;
public $bank_account_iban;
public $bank_account_bic;
public $sepa_date;
public $allow_contact;
public $allow_spin;
@@ -365,6 +367,14 @@ class AddressModel {
}
}
if(array_key_exists("billing_type", $filter)) {
$billing_type = FronkDB::singleton()->escape($filter["billing_type"]);
if($billing_type) {
$where .= " AND billing_type='$billing_type'";
}
}
/*
* Address Type
*/
+23 -1
View File
@@ -498,6 +498,10 @@ class OrderController extends mfBaseController {
$mode = "add";
}
/*
* Contacts/Addresses and Billing data
*/
// validate owner
$owner = false;
$owner_new = false;
@@ -642,6 +646,7 @@ class OrderController extends mfBaseController {
if($billingaddress_new) {
if($r->billing_type == "sepa") {
$billing_data['billing_type'] = "sepa";
$billing_data['sepa_date'] = date("U");
} else {
$billing_data['billing_type'] = "invoice";
}
@@ -659,6 +664,7 @@ class OrderController extends mfBaseController {
} elseif($owner_new) {
if($r->billing_type == "sepa") {
$owner_data['billing_type'] = "sepa";
$owner_data['sepa_date'] = date("U");
} else {
$owner_data['billing_type'] = "invoice";
}
@@ -685,6 +691,20 @@ class OrderController extends mfBaseController {
$techcontact = AddressModel::create($techcontact_data);
}
// set sepa date if not yet set and sepa is active
if($billingaddress) {
if($billingaddress->billing_type == "sepa" && !$billingaddress->sepa_date) {
$billingaddress->sepa_date = date("U");
$billingaddress->save();
}
} else {
if($owner->billing_type == "sepa" && !$owner->sepa_date) {
$owner->sepa_date = date("U");
$owner->save();
}
}
// create or save Order object
$order_data = [];
@@ -703,7 +723,7 @@ class OrderController extends mfBaseController {
$order_data['allow_spin'] = ($r->allow_spin) ? 1 : 0;
$order_data['note'] = $r->note;
$order_data['order_date'] = Layout::dateToInt($r->order_date);
$order_data['order_date'] = ($order_data['order_date']) ? Layout::dateToInt($r->order_date) : null;
if($r->finish_after) {
$order_data['finish_after'] = Layout::dateToInt($r->finish_after);
@@ -876,6 +896,7 @@ class OrderController extends mfBaseController {
$product_data["billing_delay"] = 6;
}
$product_data["billing_period"] = $p["billing_period"];
$product_data["contract_term"] = $p["contract_term"];
$product_data['upgrade'] = $order_data['upgrade'];
@@ -912,6 +933,7 @@ class OrderController extends mfBaseController {
$product_data['voicenumber'] = null;
}
$product_data['edit_by'] = $this->me->id;
if(!$orderproduct_id) {
$product = OrderProductModel::create($product_data);
+14
View File
@@ -284,6 +284,20 @@ class OrderModel {
}
}
if(array_key_exists("finish_date>", $filter)) {
$finish_date = $filter['finish_date>'];
if($finish_date) {
$where .= " AND `Order`.finish_date > $finish_date";
}
}
if(array_key_exists("finish_date<", $filter)) {
$finish_date = $filter['finish_date<'];
if($finish_date) {
$where .= " AND `Order`.finish_date < $finish_date";
}
}
if(array_key_exists("upgrade", $filter)) {
if($filter['upgrade'] == 1) {
$where .= " AND `Order`.upgrade = 1";
@@ -15,6 +15,7 @@ class OrderProductModel
public $price_nbe;
public $billing_delay;
public $billing_period;
public $contract_term;
public $note;
public $create_by = null;
+2 -1
View File
@@ -156,6 +156,7 @@ class ProductController extends mfBaseController {
$data['price_setup'] = ($r->price_setup) ? Layout::commaToDot($r->price_setup) : 0;
$data['billing_period'] = $r->billing_period;
$data['billing_delay'] = ($r->billing_delay) ? $r->billing_delay : 0;
$data['contract_term'] = $r->contract_term;
$data['ivt_id'] = ($r->ivt_id) ? $r->ivt_id : null;
$data['note'] = $r->note;
@@ -316,7 +317,7 @@ class ProductController extends mfBaseController {
if(!$product->id) {
return false;
}
if(is_array($product->attributes) && count($product->attributes)) {
$attributes = $product->attributes;
$product->data->attributes = [];
+19 -18
View File
@@ -1,26 +1,27 @@
<?php
class ProductModel {
public $name = null;
public $description = null;
public $sla_id = null;
public $external = null;
public $name;
public $description;
public $sla_id;
public $external;
public $external_id;
public $productgroup_id = null;
public $producttech_id = null;
public $price = null;
public $price_setup = null;
public $price_nne = null;
public $price_nbe = null;
public $billing_delay = null;
public $billing_period = null;
public $ivt_id = null;
public $productgroup_id;
public $producttech_id;
public $price;
public $price_setup;
public $price_nne;
public $price_nbe;
public $billing_delay;
public $billing_period;
public $contract_term;
public $ivt_id;
public $note = null;
public $create_by = null;
public $edit_by = null;
public $create = null;
public $edit = null;
public $note;
public $create_by;
public $edit_by;
public $create;
public $edit;
public static function create(Array $data) {