Added Sepa Mandats stuff

This commit is contained in:
Frank Schubert
2024-07-08 20:09:47 +02:00
parent 1888dd71e5
commit 40b1ea8605
9 changed files with 176 additions and 17 deletions
+26 -8
View File
@@ -95,7 +95,7 @@ class BillingController extends mfBaseController {
$r = $this->request;
$last_run_ts = new mfConfig("voicecallhistory.contact-job.ts");
if($last_run_ts->value() < date("U") - 43200) {
if($last_run_ts->value() < date("U") - 86400) {
$this->layout()->setFlash("Voicecall History Contract Job ist heute noch nicht gelaufen", "error");
$this->redirect("Billing");
}
@@ -370,6 +370,11 @@ class BillingController extends mfBaseController {
$billing_delivery = $billingaddress->billing_delivery;
}
$fibu_account_num = $contract->billingaddress->fibu_account_number;
if(!$fibu_account_num) {
die("Keine Fibu Account Nummer in Rechnungskontakt in Contract ID ".$contract->id);
}
$data = [];
$data["contract_id"] = $contract->id;
$data["start_date"] = $start_date->format("Y-m-d");
@@ -377,7 +382,7 @@ class BillingController extends mfBaseController {
$data["owner_id"] = $contract->owner_id;
$data["billingaddress_id"] = ($contract->billingaddress_id) ? $contract->billingaddress_id : $contract->owner_id;
$data["customer_number"] = $contract->owner->customer_number;
$data["fibu_account_number"] = $contract->owner->fibu_account_number; // TODO: fibu_account_number von billingaddress
$data["fibu_account_number"] = $fibu_account_num;
$data["company"] = $billingaddress->company;
$data["firstname"] = $billingaddress->firstname;
$data["lastname"] = $billingaddress->lastname;
@@ -400,12 +405,7 @@ class BillingController extends mfBaseController {
$data["price_setup"] = $price_setup;
$data["billing_period"] = $contract->billing_period;
$matchcode = $contract->matchcode;
// if voice product and matchcode consists of phonenumbers only, remove matchcode
if(array_key_exists("needs_number", $contract->product->attributes) && $contract->product->attributes["needs_number"] == 1 && preg_match('/^[0-9, ]+$]/', $matchcode)) {
$matchcode = "";
}
$data["matchcode"] = $matchcode;
$data["matchcode"] = $contract->matchcode;
if(!$contract->billingaddress->country_id) {
$billcountry = CountryModel::getFirst(["isocode" => TT_HOMECOUNTRY_ISOCODE]);
@@ -426,6 +426,24 @@ class BillingController extends mfBaseController {
$data["vatgroup_id"] = $contract->vatgroup_id;
$data["vatarea"] = $vatarea;
if($billing_type == "sepa") {
if($contract->billingaddress->sepa_date) {
$sepa_date = new DateTime("@".$contract->billingaddress->sepa_date);
$sepa_date->setTimezone(new DateTimeZone("Europe/Vienna"));
$data["sepa_date"] = $sepa_date->format("Y-m-d");
}
if($contract->billingaddress->last_invoice_date) {
$sepa_last_date = new DateTime("@".$contract->billingaddress->last_invoice_date);
$sepa_last_date->setTimezone(new DateTimeZone("Europe/Vienna"));
$data["sepa_last_date"] = $sepa_last_date->format("Y-m-d");
}
$data["sepa_id"] = "R".$fibu_account_num;
}
$billing = BillingModel::create($data);
if (!$billing->save()) {