diff --git a/examples/createSelfEmployedReceipt.php b/examples/createSelfEmployedReceipt.php index 20d834d..7f21c3f 100644 --- a/examples/createSelfEmployedReceipt.php +++ b/examples/createSelfEmployedReceipt.php @@ -12,35 +12,19 @@ //die(); $invoice = SelfEmployedReceiptModel::new( - tarih : '20/10/2022', // Opsiyonel @string (dd/mm/yyyy) @default=now - saat : '14:25:34', // Opsiyonel @string (hh/mm/ss) @default=now - paraBirimi : Currency::USD, // Opsiyonel @Currency @default=Currency::TRY - dovizKuru : 18.56, // Opsiyonel @float @default=0 - vknTckn : '32669381008', // Zorunlu @string - aliciAdi : 'Mert', // Zorunlu @string - aliciSoyadi : 'Levent', // Zorunlu @string - aliciUnvan : '', // Opsiyonel @string - adres : '', // Opsiyonel @string - binaAdi : '', // Opsiyonel @string - binaNo : '', // Opsiyonel @string - kapiNo : '', // Opsiyonel @string - kasabaKoy : '', // Opsiyonel @string - mahalleSemtIlce: '', // Opsiyonel @string - sehir : '', // Opsiyonel @string - postaKodu : '', // Opsiyonel @string - ulke : 'Türkiye', // Zorunlu @string - vergiDairesi : '', // Opsiyonel @string - aciklama : '', // Opsiyonel @string - kdvTahakkukIcin: false, // Opsiyonel @boolean @default=false + vknTckn : '32669381008', + aliciAdi : 'Mert', + aliciSoyadi: 'Levent', + ulke : 'Türkiye', ); $invoice->addItem( SelfEmployedReceiptItemModel::new( - neIcinAlindigi : 'Dava Vekilliği', // Zorunlu @string - brutUcret : 100, // Zorunlu @float - kdvOrani : 18, // Zorunlu @int - gvStopajOrani : 20, // Opsiyonel @int - kdvTevkifatOrani: 40, // Opsiyonel @int + neIcinAlindigi : 'Dava Vekilliği', + brutUcret : 100, + kdvOrani : 18, + gvStopajOrani : 20, + kdvTevkifatOrani: 40, ) ); diff --git a/src/Models/AbstractModel.php b/src/Models/AbstractModel.php index 5141472..735937d 100644 --- a/src/Models/AbstractModel.php +++ b/src/Models/AbstractModel.php @@ -77,7 +77,7 @@ public function __constuct() if (!$this->isImported() && $items = $this->getItems()) { $this->clearItems()->addItem(...array_map( - fn ($item) => new InvoiceItemModel(...$item), $items + fn ($item) => new (substr(get_called_class(), 0, -5) . 'ItemModel')(...$item), $items )); } } diff --git a/src/Models/ProducerReceiptItemModel.php b/src/Models/ProducerReceiptItemModel.php index bd553be..3940aa2 100644 --- a/src/Models/ProducerReceiptItemModel.php +++ b/src/Models/ProducerReceiptItemModel.php @@ -66,7 +66,8 @@ public function addTax(Tax $tax, int $rate, float $amount = 0): self */ public function prepare(ModelInterface $parent): self { - return $this->exportTaxes(true); + $this->calculateTaxes(); + return $this; } /** @@ -89,7 +90,7 @@ public function getTotals(): array */ public function export(): array { - return $this->keyMapper(array_merge($this->toArray(), $this->getTotals(), [ + return $this->keyMapper(array_merge($this->toArray(), $this->getTotals(), $this->exportTaxes(true), [ 'birim' => $this->birim->value, ])); }