105 lines
2.9 KiB
PHP
105 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Scopes\CommonModel;
|
|
use App\Support\Text;
|
|
|
|
/**
|
|
* @property string $slug
|
|
* @property string $local_group
|
|
* @property string $email
|
|
* @property string $url
|
|
* @property string $account_name
|
|
* @property string $account_iban
|
|
* @property string $account_bic
|
|
* @property string|null $invoice_sender_name
|
|
* @property string|null $address_1
|
|
* @property string|null $address_2
|
|
* @property string|null $address_3
|
|
* @property string|null $phone
|
|
* @property string|null $tax_number
|
|
* @property string|null $vat_id
|
|
* @property string|null $invoice_prefix
|
|
* @property string $city
|
|
* @property string $postcode
|
|
* @property boolean $download_exports
|
|
* @property boolean $upload_exports
|
|
* @property string $gdpr_text
|
|
* @property string $impress_text
|
|
* @property string $url_participation_rules
|
|
* @property boolean $events_allowed
|
|
* @property boolean $has_active_instance
|
|
* @property boolean $tax_liable
|
|
* @property int $vat_rate
|
|
* @property string|null $tax_exemption_reason
|
|
* @property string|null $tax_exemption_note
|
|
* @property string $vat_pricing_mode
|
|
*/
|
|
class Tenant extends CommonModel
|
|
{
|
|
/**
|
|
* Ohne ausdrückliche Angabe ist das Präfix der Rechnungsnummer der großgeschriebene Slug
|
|
* (`wm` -> `WM`). Hier und nicht als DB-Default, weil er sich aus einer anderen Spalte ableitet.
|
|
*/
|
|
protected static function booted(): void
|
|
{
|
|
static::creating(static function (self $tenant): void {
|
|
$tenant->invoice_prefix ??= strtoupper((string) $tenant->slug);
|
|
});
|
|
}
|
|
|
|
public static function getTempDirectory() : string {
|
|
return app('tenant')->slug . '/temp-data/';
|
|
}
|
|
|
|
/**
|
|
* Bezeichnung des Rechnungsstellers.
|
|
*
|
|
* `name` ist ein internes Kürzel ("Wilde Möhre"); auf einer Rechnung steht die vollständige
|
|
* Bezeichnung mit Rechtsform. Ohne eigene Angabe bleibt es beim Namen des Mandanten.
|
|
*/
|
|
public function invoiceSenderName() : string {
|
|
return Text::nullIfBlank($this->invoice_sender_name) ?? (string) $this->name;
|
|
}
|
|
public const PRIMARY_TENANT_NAME = 'LV';
|
|
|
|
protected $fillable = [
|
|
'slug',
|
|
'name',
|
|
'invoice_sender_name',
|
|
'address_1',
|
|
'address_2',
|
|
'address_3',
|
|
'email',
|
|
'email_finance',
|
|
'phone',
|
|
'url',
|
|
'account_name',
|
|
'account_iban',
|
|
'account_bic',
|
|
'city',
|
|
'postcode',
|
|
'download_exports',
|
|
'upload_exports',
|
|
'gdpr_text',
|
|
'impress_text',
|
|
'url_participation_rules',
|
|
'is_active_local_group',
|
|
'has_active_instance',
|
|
'tax_liable',
|
|
'vat_rate',
|
|
'tax_exemption_reason',
|
|
'tax_exemption_note',
|
|
'vat_pricing_mode',
|
|
'tax_number',
|
|
'vat_id',
|
|
'invoice_prefix',
|
|
];
|
|
|
|
protected $casts = [
|
|
'tax_liable' => 'boolean',
|
|
'vat_rate' => 'integer',
|
|
];
|
|
}
|