*/ #[ORM\OneToMany(mappedBy: 'template', targetEntity: InvoiceTemplateMeta::class, cascade: ['persist'])] private Collection $meta; public function __construct() { $this->meta = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function setName(string $name): void { $this->name = $name; } public function getName(): ?string { return $this->name; } public function getCustomer(): ?Customer { return $this->customer; } public function setCustomer(?Customer $customer): void { $this->customer = $customer; } // ---- trait methods below --- public function getTitle(): ?string { return $this->title; } public function setTitle(?string $title): void { $this->title = $title; } public function getAddress(): ?string { return $this->customer?->getFormattedAddress() ?? $this->address; } /** * @deprecated since 2.41 */ public function setAddress(?string $address): void { $this->address = $address; } public function getNumberGenerator(): string { return $this->numberGenerator; } public function setNumberGenerator(string $numberGenerator): void { $this->numberGenerator = $numberGenerator; } public function getDueDays(): ?int { return $this->dueDays; } public function setDueDays(?int $dueDays): void { $this->dueDays = $dueDays; } public function getVat(): ?float { return $this->vat; } public function setVat(?float $vat): void { $this->vat = $vat; } public function getCompany(): ?string { return $this->customer?->getCompany() ?? $this->customer?->getName() ?? $this->company; } /** * @deprecated since 2.41 */ public function setCompany(?string $company): void { $this->company = $company; } public function getRenderer(): string { return $this->renderer; } public function setRenderer(string $renderer): void { $this->renderer = $renderer; } public function getCalculator(): string { return $this->calculator; } public function setCalculator(string $calculator): void { $this->calculator = $calculator; } public function getPaymentTerms(): ?string { return $this->paymentTerms; } public function setPaymentTerms(?string $paymentTerms): void { $this->paymentTerms = $paymentTerms; } public function getVatId(): ?string { return $this->customer?->getVatId() ?? $this->vatId; } /** * @deprecated since 2.41 */ public function setVatId(?string $vatId): void { $this->vatId = $vatId; } public function getContact(): ?string { return $this->contact; } public function setContact(?string $contact): void { $this->contact = $contact; } public function getPaymentDetails(): ?string { return $this->paymentDetails; } public function setPaymentDetails(?string $paymentDetails): void { $this->paymentDetails = $paymentDetails; } /** * @deprecated since 2.0 */ public function isDecimalDuration(): bool { return true; } public function getLanguage(): ?string { return $this->language; } public function setLanguage(?string $language): void { $this->language = $language; } /** * @return Tax[] */ public function getTaxRates(): array { // TODO make me configurable via UI $tax = new Tax( TaxType::STANDARD, 'VAT', $this->vat ?? 0.00 ); return [$tax]; } /** * @return Collection|MetaTableTypeInterface[] */ public function getMetaFields(): Collection { return $this->meta; } /** * @return MetaTableTypeInterface[] */ public function getVisibleMetaFields(): array { $all = []; foreach ($this->meta as $meta) { if ($meta->isVisible()) { $all[] = $meta; } } return $all; } public function getMetaField(string $name): ?MetaTableTypeInterface { foreach ($this->meta as $field) { if ($field->getName() !== null && strtolower($field->getName()) === strtolower($name)) { return $field; } } return null; } public function setMetaField(MetaTableTypeInterface $meta): EntityWithMetaFields { if ($meta->getName() === null) { throw new \InvalidArgumentException('Meta-field needs to have a name'); } if (!$meta instanceof InvoiceTemplateMeta) { throw new \InvalidArgumentException('Meta-field needs to be an instanceof InvoiceTemplateMeta'); } if (null === ($current = $this->getMetaField($meta->getName()))) { $meta->setEntity($this); $this->meta->add($meta); return $this; } $current->merge($meta); return $this; } public function __toString(): string { return $this->getName(); } public function __clone() { if ($this->id) { $this->id = null; } } }