Esempio n. 1
0
 /**
  * @dataProvider dataProvider
  *
  * @param float $given
  * @param string $expected
  * @param bool $includeSymbol
  * @param string $currencyIsoCode
  *
  * @return void
  */
 public function testFormat($given, $expected, $includeSymbol, $currencyIsoCode)
 {
     $currencyManager = CurrencyManager::getInstance();
     $currencyManager->setDefaultCurrencyIso($currencyIsoCode);
     $result = $currencyManager->format($given, $includeSymbol);
     $this->assertSame($expected, $result);
 }
Esempio n. 2
0
 /**
  * @return \Spryker\Shared\Twig\TwigFilter[]
  */
 public function getFilters()
 {
     return [new TwigFilter('currency', function ($price) {
         $currencyManager = CurrencyManager::getInstance();
         $priceFilter = new PriceFilter($currencyManager);
         return $priceFilter->getConvertedPrice($price);
     }, ['is_safe' => ['html']])];
 }
Esempio n. 3
0
 /**
  * @return callable
  */
 protected function getFunction()
 {
     return function ($value, $includeSymbol = true) {
         $currencyManager = CurrencyManager::getInstance();
         $value = $currencyManager->convertCentToDecimal($value);
         return $currencyManager->format($value, $includeSymbol);
     };
 }
 /**
  * @return void
  */
 public function testGetPayolutionPaymentTransferShouldThrowExceptionIfPaymentSelectionNotFound()
 {
     $paymentHandler = new PayolutionHandler($this->getPayolutionClientMock(), CurrencyManager::getInstance());
     $request = Request::createFromGlobals();
     $quoteTransfer = new QuoteTransfer();
     $paymentTransfer = new PaymentTransfer();
     $paymentTransfer->setPaymentSelection('payolutionInvoice');
     $quoteTransfer->setPayment($paymentTransfer);
     $this->expectException(PaymentMethodNotFoundException::class);
     $paymentHandler->addPaymentToQuote($request, $quoteTransfer);
 }
Esempio n. 5
0
 /**
  * @param array|string $rangeValues
  *
  * @return void
  */
 protected function setMinMaxValues($rangeValues)
 {
     parent::setMinMaxValues($rangeValues);
     $this->minValue = $this->currencyManager->convertDecimalToCent($this->minValue);
     $this->maxValue = $this->currencyManager->convertDecimalToCent($this->maxValue);
 }
Esempio n. 6
0
 /**
  * @param \Symfony\Component\Form\FormBuilderInterface $builder
  *
  * @return $this
  */
 protected function addDefaultPriceField(FormBuilderInterface $builder)
 {
     $builder->add(self::FIELD_DEFAULT_PRICE, 'money', ['label' => 'Default price']);
     $builder->get(self::FIELD_DEFAULT_PRICE)->addModelTransformer(new CallbackTransformer(function ($originalPrice) {
         return CurrencyManager::getInstance()->convertCentToDecimal($originalPrice);
     }, function ($submittedPrice) {
         return CurrencyManager::getInstance()->convertDecimalToCent($submittedPrice);
     }));
     return $this;
 }
Esempio n. 7
0
 /**
  * @return \Spryker\Shared\Library\Currency\CurrencyManager
  */
 protected function getCurrencyManager()
 {
     return CurrencyManager::getInstance();
 }
Esempio n. 8
0
 /**
  * @param float $amount
  *
  * @return int
  */
 protected function centsToDecimal($amount)
 {
     return CurrencyManager::getInstance()->convertDecimalToCent($amount);
 }
 /**
  * @param int $amount
  *
  * @return float
  */
 protected function convertCentToDecimal($amount)
 {
     return $this->currencyManager->convertCentToDecimal($amount);
 }
Esempio n. 10
0
 /**
  * @param int $price
  *
  * @return string
  */
 public function getConvertedPrice($price)
 {
     return $this->currencyManager->format($this->currencyManager->convertCentToDecimal($price));
 }
Esempio n. 11
0
 /**
  * @param \Spryker\Zed\Kernel\Container $container
  *
  * @return \Spryker\Zed\Kernel\Container
  */
 protected function addCurrencyManager(Container $container)
 {
     $container[self::CURRENCY_MANAGER] = function () {
         return CurrencyManager::getInstance();
     };
     return $container;
 }
Esempio n. 12
0
 /**
  * @return \Spryker\Shared\Library\Currency\CurrencyManager
  */
 public function getCurrencyManager()
 {
     return CurrencyManager::getInstance();
 }