82 lines
2.7 KiB
PHP
82 lines
2.7 KiB
PHP
<?php
|
|
|
|
class ManualInvoiceModel extends TTCrudBaseModel {
|
|
public int $id;
|
|
public ?string $invoice_number;
|
|
public int $invoice_date;
|
|
public ?string $leistungszeitraum;
|
|
public ?string $einleitender_text;
|
|
public ?string $externe_referenz;
|
|
public float $gesamtrabatt;
|
|
public int $owner_id;
|
|
public int $billingaddress_id;
|
|
public int $customer_number;
|
|
public ?int $fibu_account_number;
|
|
public ?int $fibu_payment_due;
|
|
public int $fibu_payment_skonto;
|
|
public int $fibu_payment_skonto_rate;
|
|
public ?string $sepa_date;
|
|
public ?string $sepa_id;
|
|
public ?string $sepa_last_date;
|
|
public ?string $fibu_cost_area;
|
|
public ?int $fibu_cost_account;
|
|
public ?int $fibu_cost_account_legacy;
|
|
public ?int $fibu_taxcode;
|
|
public ?string $tax_text;
|
|
public ?string $company;
|
|
public ?string $firstname;
|
|
public ?string $lastname;
|
|
public string $street;
|
|
public string $zip;
|
|
public string $city;
|
|
public ?string $country;
|
|
public ?string $email;
|
|
public ?string $uid;
|
|
public string $billing_type;
|
|
public string $billing_delivery;
|
|
public ?string $bank_account_bank;
|
|
public ?string $bank_account_owner;
|
|
public ?string $bank_account_iban;
|
|
public ?string $bank_account_bic;
|
|
public float $total;
|
|
public float $total_gross;
|
|
public int $vatgroup_id;
|
|
public ?int $bmd_export_date;
|
|
public ?int $date_delivered;
|
|
public string $status;
|
|
public int $lock = 0;
|
|
public int $exported = 0;
|
|
public ?int $credit_for_invoice_id;
|
|
public int $create_by;
|
|
public int $edit_by;
|
|
public int $create;
|
|
public int $edit;
|
|
|
|
public static function getNextInvoiceNumber() {
|
|
$invoices = parent::getAll(['invoice_number' => '!NULL'], 1, 0, ['key' => 'invoice_number', 'order' => 'DESC']);
|
|
$last = $invoices[0]->invoice_number ?? null;
|
|
$year = date("Y");
|
|
|
|
if ($last && preg_match('/^RN(\d+)-C(\d+)$/', $last, $m)) {
|
|
$num = ($m[1] == $year) ? $m[2] + 1 : 1;
|
|
} else {
|
|
$num = 1;
|
|
}
|
|
|
|
return sprintf("RN%s-C%06d", $year, $num);
|
|
}
|
|
|
|
public function getProperty($name) {
|
|
if (!$this->id) return null;
|
|
|
|
switch ($name) {
|
|
case 'positions': return ManualInvoicepositionModel::search(['manualinvoice_id' => $this->id]);
|
|
case 'creator': return $this->create_by ? new User($this->create_by) : null;
|
|
case 'editor': return $this->edit_by ? new User($this->edit_by) : null;
|
|
default:
|
|
$classname = ucfirst($name);
|
|
$idfield = $name . '_id';
|
|
return (property_exists($this, $idfield) && class_exists($classname)) ? new $classname($this->$idfield) : null;
|
|
}
|
|
}
|
|
} |