Added Fibu payment due and skonto to Billing

This commit is contained in:
Frank Schubert
2025-08-05 19:32:50 +02:00
parent 8f2b627706
commit b4cdbd0b6b
4 changed files with 101 additions and 3 deletions

View File

@@ -164,6 +164,14 @@ class BillingController extends mfBaseController {
//$now_month = 11;
//$now_day = 3;
$locked = new mfConfig("billing.running");
if($locked->value()) {
$this->layout()->setFlash("Läuft schon seit ".date("d.m.Y H:i", $locked->edit));
$this->redirect("Billing");
}
$locked->value(1);
$locked->save();
// XXX only for 1st Billing after IVT Import
// Locking to July 2024 and keeping it for now
$yearly_not_before = new DateTime("2024-07-01");
@@ -467,6 +475,12 @@ class BillingController extends mfBaseController {
$data["billingaddress_id"] = ($contract->billingaddress_id) ? $contract->billingaddress_id : $contract->owner_id;
$data["customer_number"] = $contract->owner->customer_number;
$data["fibu_account_number"] = $fibu_account_num;
// TODO: Zahlungsziel / Skonto muss in Zukuft vom Contract übernommen werden
$data["fibu_payment_due"] = $owner->fibu_payment_due ?: TT_ADDRESS_DEFAULT_PAYMENT_DUE;
$data["fibu_payment_skonto"] = $owner->fibu_payment_skonto ?: 0;
$data["fibu_payment_skonto_rate"] = $owner->fibu_payment_skonto_rate ?: 0;
$data["company"] = $billingaddress->company;
$data["firstname"] = $billingaddress->firstname;
$data["lastname"] = $billingaddress->lastname;
@@ -758,6 +772,10 @@ class BillingController extends mfBaseController {
}
$locked->value(0);
$locked->save();
$this->layout()->setFlash("$i Contract Billing records generiert. $v Voicenumber Billing records generiert");
$this->redirect("Billing");

View File

@@ -9,6 +9,9 @@ class BillingModel {
public $billingaddress_id;
public $customer_number;
public $fibu_account_number;
public $fibu_payment_due;
public $fibu_payment_skonto;
public $fibu_payment_skonto_rate;
public $sepa_date;
public $sepa_id;
public $sepa_last_date;

View File

@@ -483,9 +483,9 @@ class InvoiceController extends mfBaseController {
$invoice_data["billingaddress_id"] = $billingaddress_id;
$invoice_data["customer_number"] = $bill->customer_number;
$invoice_data["fibu_account_number"] = $bill->fibu_account_number;
$invoice_data["fibu_payment_due"] = $bill->fibu_payment_due;
$invoice_data["fibu_payment_skonto"] = $bill->fibu_payment_skonto;
$invoice_data["fibu_payment_skonto_rate"] = $bill->fibu_payment_skonto_rate;
$invoice_data["fibu_payment_due"] = $bill->fibu_payment_due ?: 14;
$invoice_data["fibu_payment_skonto"] = $bill->fibu_payment_skonto ?: 0;
$invoice_data["fibu_payment_skonto_rate"] = $bill->fibu_payment_skonto_rate ?: 0;
$invoice_data["sepa_date"] = $bill->sepa_date;

View File

@@ -0,0 +1,77 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class BillingAddPaymentDue extends AbstractMigration
{
public function up(): void
{
if($this->getEnvironment() == "thetool") {
$billing = $this->table("Billing");
$billing->addColumn("fibu_payment_due", "integer", ["null" => true, "default" => null, "after" => "fibu_account_number"]);
$billing->addColumn("fibu_payment_skonto", "integer", ["null" => false, "default" => 0, "after" => "fibu_payment_due"]);
$billing->addColumn("fibu_payment_skonto_rate", "integer", ["null" => false, "default" => 0, "after" => "fibu_payment_skonto"]);
$billing->addIndex("invoice_id");
$billing->addIndex("contract_id");
$billing->addIndex("start_date");
$billing->addIndex("end_date");
$billing->update();
$bv = $this->table("BillingVoicenumber");
$bv->addIndex("contract_id");
$bv->addIndex("voicenumber");
$bv->addIndex("start_date");
$bv->addIndex("end_date");
$bv->update();
$invoice = $this->table("Invoice");
$invoice->addIndex("invoice_number");
$invoice->addIndex("invoice_date");
$invoice->addIndex("owner_id");
$invoice->addIndex("billingaddress_id");
$invoice->addIndex("customer_number");
$invoice->save();
}
if($this->getEnvironment() == "addressdb") {
}
}
public function down(): void
{
if($this->getEnvironment() == "thetool") {
$this->table("Billing")
->removeColumn("fibu_payment_skonto_rate")
->removeColumn("fibu_payment_skonto")
->removeColumn("fibu_payment_due")
->removeIndex("end_date")
->removeIndex("start_date")
->removeIndex("contract_id")
->removeIndex("invoice_id")
->update();
$this->table("BillingVoicenumber")
->removeIndex("end_date")
->removeIndex("start_date")
->removeIndex("voicenumber")
->removeIndex("contract_id")
->update();
$this->table("Invoice")
->removeIndex("customer_number")
->removeIndex("billingaddress_id")
->removeIndex("owner_id")
->removeIndex("invoice_date")
->removeIndex("invoice_number")
->update();
}
if($this->getEnvironment() == "addressdb") {
}
}
}