/** * {@inheritdoc} */ public function build(BuilderInterface $builder) { if (!$this->_transaction) { throw new \LogicException('Transaction must be set before receipt template can be built'); } // So we can use the variables in closures $transaction = $this->_transaction; $voucherCode = $this->_voucherPayment->reference; $paymentAmount = $this->_voucherPayment->amount; $builder->justify($builder::JUSTIFY_CENTER, function ($builder) use($voucherCode) { $builder->append('VOUCHER ADJUSTMENT' . "\n\n"); $builder->append(chr(29) . '!' . chr(34) . "\r\r"); // I think this makes font big $builder->append(strtoupper($voucherCode) . "\n\n"); $builder->append(chr(27) . '@'); // ESC @ / RESET $builder->barcode($voucherCode, $builder::BARCODE_CODE39, false); }); $builder->append("\n\n"); $builder->split('Previous balance:', number_format($this->_voucher->getBalance() + $paymentAmount, 2)); $builder->split('Adjustment:', number_format(-$paymentAmount, 2)); $builder->bold(function ($builder) { $builder->split('New balance:', number_format($this->_voucher->getBalance(), 2)); }); }
/** * {@inheritdoc} */ public function build(BuilderInterface $builder) { if (!$this->_voucher) { throw new \LogicException('Voucher must be set before receipt template can be built'); } // So we can use the variables in closures $voucher = $this->_voucher; $builder->justify($builder::JUSTIFY_CENTER, function ($builder) use($voucher) { $builder->append(number_format($voucher->amount, 2) . $voucher->currencyID . ' Voucher' . "\n\n"); $builder->append(chr(29) . '!' . chr(34) . "\r\r"); // I think this makes font big $builder->append(strtoupper($voucher->id) . "\n\n"); $builder->append(chr(27) . '@'); // ESC @ / RESET $builder->barcode($voucher->id, $builder::BARCODE_CODE39, false); }); if ($voucher->expiresAt) { $builder->append("\n\n"); $builder->split('Expires at:', $voucher->expiresAt->format('h:ia d/m/Y')); } }