Exemplo n.º 1
0
 /**
  * Generates information about transaction amount.
  *
  * @param object $item
  * @param Crowdfunding\Amount $amount
  * @param Crowdfunding\Currencies $currencies
  *
  * @return string
  */
 public static function transactionAmount($item, $amount, $currencies)
 {
     $item->txn_amount = floatval($item->txn_amount);
     $item->fee = floatval($item->fee);
     $currency = null;
     if ($currencies instanceof Crowdfunding\Currencies) {
         $currency = $currencies->getCurrencyByCode($item->txn_currency);
     }
     if ($currency instanceof Crowdfunding\Currency) {
         $amount->setCurrency($currency);
         $output = $amount->setValue($item->txn_amount)->formatCurrency();
     } else {
         $output = $item->txn_amount;
     }
     if (!empty($item->fee)) {
         $fee = $currency instanceof Crowdfunding\Currency ? $amount->setValue($item->fee)->formatCurrency() : $item->fee;
         // Prepare project owner amount.
         $projectOwnerAmount = round($item->txn_amount - $item->fee, 2);
         $projectOwnerAmount = !empty($currency) ? $amount->setValue($projectOwnerAmount)->formatCurrency() : $projectOwnerAmount;
         $title = JText::sprintf("COM_CROWDFUNDING_TRANSACTION_AMOUNT_FEE", $projectOwnerAmount, $fee);
         $output .= '<a class="btn btn-micro hasTooltip" href="javascript:void(0);" title="' . addslashes($title) . '">';
         $output .= '<i class="icon-question"></i>';
         $output .= '</a>';
     }
     return $output;
 }
 /**
  * Generates information about transaction amount.
  *
  * @param stdClass $item
  * @param Prism\Money\Money $money
  * @param Crowdfunding\Currencies $currencies
  *
  * @throws \UnexpectedValueException
  *
  * @return string
  */
 public static function transactionAmount($item, Prism\Money\Money $money, Crowdfunding\Currencies $currencies)
 {
     $item->txn_amount = (double) $item->txn_amount;
     $item->fee = (double) $item->fee;
     $currency = $currencies->getCurrency($item->txn_currency);
     if ($currency !== null) {
         $money->setCurrency($currency);
         $output = $money->setAmount($item->txn_amount)->formatCurrency();
     } else {
         $output = $item->txn_amount;
     }
     if ($item->fee > 0.0) {
         $fee = $currency !== null ? $money->setAmount($item->fee)->formatCurrency() : $item->fee;
         // Prepare project owner amount.
         $projectOwnerAmount = round($item->txn_amount - $item->fee, 2);
         $projectOwnerAmount = $currency !== null ? $money->setAmount($projectOwnerAmount)->formatCurrency() : $projectOwnerAmount;
         $title = JText::sprintf('COM_CROWDFUNDING_TRANSACTION_AMOUNT_FEE', $projectOwnerAmount, $fee);
         $output .= '<a class="btn btn-micro hasTooltip" href="javascript:void(0);" title="' . addslashes($title) . '">';
         $output .= '<i class="icon-question"></i>';
         $output .= '</a>';
     }
     return $output;
 }