82 lines
5.0 KiB
PHP
82 lines
5.0 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
use Phinx\Migration\AbstractMigration;
|
|
|
|
final class CreateInvoiceTables extends AbstractMigration
|
|
{
|
|
public function up(): void
|
|
{
|
|
if($this->getEnvironment() == "thetool") {
|
|
$invoice = $this->table("Invoice");
|
|
|
|
$invoice->addColumn("invoice_number", "string", ["null" => true, "default" => null]); // RN2024-X000001
|
|
$invoice->addColumn("invoice_date", "integer", ["default" => 0]);
|
|
$invoice->addColumn("owner_id", "integer", ["null" => false]);
|
|
$invoice->addColumn("billingaddress_id", "integer", ["null" => false]);
|
|
$invoice->addColumn("customer_number", "integer", ["null" => false]);
|
|
$invoice->addColumn("company", "string", ["null" => true, "default" => null, "length" => 1024]);
|
|
$invoice->addColumn("firstname", "string", ["null" => true, "default" => null, "length" => 1024]);
|
|
$invoice->addColumn("lastname", "string", ["null" => true, "default" => null, "length" => 1024]);
|
|
$invoice->addColumn("street", "string", ["null" => false, "length" => 1024]);
|
|
$invoice->addColumn("zip", "string", ["null" => false, "length" => 1024]);
|
|
$invoice->addColumn("city", "string", ["null" => false, "length" => 1024]);
|
|
$invoice->addColumn("country", "string", ["null" => true, "default" => null, "length" => 1024]);
|
|
$invoice->addColumn("email", "string", ["null" => true, "default" => null, "length" => 1024]);
|
|
$invoice->addColumn("uid", "string", ["null" => true, "default" => null, "length" => 1024]);
|
|
$invoice->addColumn("billing_type", "enum", ["null" => false, "values" => "invoice,sepa"]);
|
|
$invoice->addColumn("billing_delivery", "enum", ["null" => false, "values" => "email,paper"]);
|
|
$invoice->addColumn("bank_account_bank", "string", ["null" => true, "default" => null, "length" => 255]);
|
|
$invoice->addColumn("bank_account_owner", "string", ["null" => true, "default" => null, "length" => 255]);
|
|
$invoice->addColumn("bank_account_iban", "string", ["null" => true, "default" => null, "length" => 255]);
|
|
$invoice->addColumn("bank_account_bic", "string", ["null" => true, "default" => null, "length" => 255]);
|
|
$invoice->addColumn("total", "decimal", ["null" => false, "precision" => 14, "scale" => 4]);
|
|
$invoice->addColumn("total_gross", "decimal", ["null" => false, "precision" => 14, "scale" => 4]);
|
|
$invoice->addColumn("vatrate", "decimal", ["null" => false, "default" => 0, "precision" => 6, "scale" => 2]);
|
|
$invoice->addColumn("create_by", "integer", ["null" => false]);
|
|
$invoice->addColumn("edit_by", "integer", ["null" => false]);
|
|
$invoice->addColumn("create", "integer", ["null" => false]);
|
|
$invoice->addColumn("edit", "integer", ["null" => false]);
|
|
$invoice->create();
|
|
|
|
$ip = $this->table("Invoiceposition");
|
|
$ip->addColumn("invoice_id", "integer", ["null" => true, "default" => null]);
|
|
$ip->addColumn("billing_id", "integer", ["null" => true, "default" => null]);
|
|
$ip->addColumn("contract_id", "integer", ["null" => false]);
|
|
$ip->addColumn("start_date", "date", ["null" => false]);
|
|
$ip->addColumn("end_date", "date", ["null" => true, "default" => null]);
|
|
$ip->addColumn("matchcode", "string", ["null" => true, "default" => null, "length" => 255]);
|
|
$ip->addColumn("product_id", "integer", ["null" => false]);
|
|
$ip->addColumn("product_name", "string", ["null" => false, "length" => 255]);
|
|
$ip->addColumn("product_info", "text", ["null" => true, "default" => null]);
|
|
$ip->addColumn("amount", "decimal", ["null" => false, "precision" => 9, "scale" => 6]);
|
|
$ip->addColumn("price", "decimal", ["null" => false, "precision" => 14, "scale" => 4]);
|
|
$ip->addColumn("price_total", "decimal", ["null" => false, "precision" => 14, "scale" => 4]);
|
|
$ip->addColumn("price_gross", "decimal", ["null" => false, "precision" => 14, "scale" => 4]);
|
|
$ip->addColumn("vatrate", "decimal", ["null" => false, "default" => 0, "precision" => 6, "scale" => 2]);
|
|
$ip->addColumn("billing_period", "integer", ["null" => false, "default" => 0]);
|
|
$ip->addColumn("create_by", "integer", ["null" => false]);
|
|
$ip->addColumn("edit_by", "integer", ["null" => false]);
|
|
$ip->addColumn("create", "integer", ["null" => false]);
|
|
$ip->addColumn("edit", "integer", ["null" => false]);
|
|
$ip->create();
|
|
}
|
|
|
|
if($this->getEnvironment() == "addressdb") {
|
|
|
|
}
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
if($this->getEnvironment() == "thetool") {
|
|
$this->table("InvoicePosition")->drop()->save();
|
|
$this->table("Invoice")->drop()->save();
|
|
}
|
|
|
|
if($this->getEnvironment() == "addressdb") {
|
|
|
|
}
|
|
}
|
|
}
|