diff --git a/src/DI/InvoiceExtension.php b/src/DI/InvoiceExtension.php index 33f9fcd..2030d78 100755 --- a/src/DI/InvoiceExtension.php +++ b/src/DI/InvoiceExtension.php @@ -4,7 +4,6 @@ use Contributte\Invoice\Data\Account; use Contributte\Invoice\Data\Company; -use Contributte\Invoice\Data\Currency; use Contributte\Invoice\Invoice; use Contributte\Invoice\Provider\InvoiceDataProvider; use Nette\DI\CompilerExtension; @@ -31,10 +30,6 @@ public function getConfigSchema(): Schema 'accounts' => Expect::arrayOf(Expect::structure([ 'iban' => Expect::string(), ])), - 'currency' => Expect::structure([ - 'currency' => Expect::string()->required(), - 'template' => Expect::string()->default(':currency:price'), - ]), ]); } @@ -46,7 +41,6 @@ public function loadConfiguration(): void ->setFactory(InvoiceDataProvider::class, [ $this->getCompany(), $this->getAccounts(), - $this->getCurrency(), ]); $builder->addDefinition($this->prefix('invoice')) @@ -93,19 +87,4 @@ private function getAccounts(): array return $accounts; } - private function getCurrency(): ?Statement - { - /** @var stdClass $config */ - $config = $this->getConfig(); - - /** @var stdClass $currency */ - $currency = $config->currency; - - if (!$currency->currency) { - return null; - } - - return new Statement(Currency::class, [$currency->currency, $currency->template]); - } - } diff --git a/src/Data/Currency.php b/src/Data/Currency.php deleted file mode 100644 index 9a95e25..0000000 --- a/src/Data/Currency.php +++ /dev/null @@ -1,28 +0,0 @@ -currency; - } - - public function toString(string $price): string - { - return strtr($this->template, [ - ':currency' => $this->currency, - ':price' => $price, - ]); - } - -} diff --git a/src/Data/ICurrency.php b/src/Data/ICurrency.php deleted file mode 100644 index 44c2b2d..0000000 --- a/src/Data/ICurrency.php +++ /dev/null @@ -1,10 +0,0 @@ -currency = $currency ?? new Currency('$'); } public function addItem(IItem $item): IItem @@ -71,9 +67,4 @@ public function getItems(): array return $this->items; } - public function getCurrency(): ICurrency - { - return $this->currency; - } - } diff --git a/src/Preview/PreviewFactory.php b/src/Preview/PreviewFactory.php index e3646b2..7f78028 100644 --- a/src/Preview/PreviewFactory.php +++ b/src/Preview/PreviewFactory.php @@ -4,7 +4,6 @@ use Contributte\Invoice\Data\Account; use Contributte\Invoice\Data\Company; -use Contributte\Invoice\Data\Currency; use Contributte\Invoice\Data\Customer; use Contributte\Invoice\Data\International\Czech\CzechAccount; use Contributte\Invoice\Data\International\Czech\CzechPaymentInformation; @@ -22,7 +21,7 @@ public static function createOrder(?int $itemCount = null): IOrder { $order = new Order( date('Y') . '0001', - '15.000,00', + '$ 15.000,00', new Company('Contributte', 'Prague', 'U haldy', '110 00', 'Czech Republic', 'CZ08304431', '08304431'), new Customer('John Doe', 'Los Angeles', 'Cavetown', '720 55', 'USA', 'CZ08304431', '08304431'), new PaymentInformation( @@ -43,7 +42,7 @@ public static function createCzechOrder(?int $itemCount = null): IOrder { $order = new Order( date('Y') . '0001', - '15.000,00', + '15.000,00 Kč', new Company('Contributte', 'Prague', 'U haldy', '110 00', 'Czech Republic', 'CZ08304431', '08304431'), new Customer('John Doe', 'Los Angeles', 'Cavetown', '720 55', 'USA', 'CZ08304431', '08304431'), new CzechPaymentInformation( @@ -56,23 +55,23 @@ public static function createCzechOrder(?int $itemCount = null): IOrder (new DateTime())->format('Y-m-d'), (new DateTime('+ 1 week'))->format('Y-m-d'), ), - new Currency('Kč', ':price :currency'), ); - self::addItems($order, $itemCount); + self::addItems($order, $itemCount, ':value Kč'); return $order; } - private static function addItems(IOrder $order, ?int $itemCount = null): void + private static function addItems(IOrder $order, ?int $itemCount = null, string $format = '$ :value'): void { + $format = fn (string $money) => str_replace(':value', $money, $format); $items = [ - new Item('Logitech G700s Rechargeable Gaming Mouse', '1.790,00', 4, '7.160,00'), - new Item('ASUS Z380KL 8" - 16GB, LTE', '6.490,00', 1, '6.490,00'), - new Item('Philips 48PFS6909 - 121cm', '13.990,00', 1, '13.990,00'), - new Item('HP Deskjet 3545 Advantage', '1.799,00', 1, '1.799,00'), - new Item('LG 105UC9V - 266cm', '11.599,00', 1, '11.599,00'), - new Item('Samsung Galaxy S21 Ultra 5G, 12GB/128GB', '31.490,00', 1, '31.490,00'), + new Item('Logitech G700s Rechargeable Gaming Mouse', $format('1.790,00'), 4, $format('7.160,00')), + new Item('ASUS Z380KL 8" - 16GB, LTE', $format('6.490,00'), 1, $format('6.490,00')), + new Item('Philips 48PFS6909 - 121cm', $format('13.990,00'), 1, $format('13.990,00')), + new Item('HP Deskjet 3545 Advantage', $format('1.799,00'), 1, $format('1.799,00')), + new Item('LG 105UC9V - 266cm', $format('11.599,00'), 1, $format('11.599,00')), + new Item('Samsung Galaxy S21 Ultra 5G, 12GB/128GB', $format('31.490,00'), 1, $format('31.490,00')), ]; $count = count($items); diff --git a/src/Provider/InvoiceDataProvider.php b/src/Provider/InvoiceDataProvider.php index 4fa1e6f..1168da0 100644 --- a/src/Provider/InvoiceDataProvider.php +++ b/src/Provider/InvoiceDataProvider.php @@ -4,7 +4,6 @@ use Contributte\Invoice\Data\IAccount; use Contributte\Invoice\Data\ICompany; -use Contributte\Invoice\Data\ICurrency; final class InvoiceDataProvider { @@ -15,7 +14,6 @@ final class InvoiceDataProvider public function __construct( private ICompany $company, private array $accounts = [], - private ?ICurrency $currency = null, ) { } @@ -33,9 +31,4 @@ public function getAccounts(): array return $this->accounts; } - public function getCurrency(): ?ICurrency - { - return $this->currency; - } - } diff --git a/src/Templates/templates/paraiso.phtml b/src/Templates/templates/paraiso.phtml index f445e88..3bee812 100644 --- a/src/Templates/templates/paraiso.phtml +++ b/src/Templates/templates/paraiso.phtml @@ -6,7 +6,6 @@ use Contributte\Invoice\Templates\Template\ParaisoTemplateObject; use WebChemistry\SvgPdf\Utility\TemplateUtility; /** @var $template ParaisoTemplateObject */ -$formatMoney = $template->formatMoneyCallback(); $order = $template->getOrder(); $payment = $order->getPayment(); @@ -66,7 +65,7 @@ echo ''; translate('Total price')) ?>: - getTotalPrice())) ?> + getTotalPrice()) ?> @@ -89,7 +88,7 @@ echo '';

getQuantity()) ?>

- getUnitPrice())) ?> + getUnitPrice()) ?> @@ -103,7 +102,7 @@ echo '';

getTotalPrice()) ?>

- getTotalPrice())) ?> + getTotalPrice()) ?>
increment(); endforeach; ?> @@ -119,18 +118,18 @@ echo ''; Sub Total: - getPriceBeforeTax())) ?> + getPriceBeforeTax()) ?> Tax: - getTax())) ?> + getTax()) ?> translate('Discount')) ?>: - getDiscount())) ?> + getDiscount()) ?> - Total + translate('Total')) ?> $ 4500.00