/**
  * This is another unit test
  */
 public function testOddCalculation()
 {
     // call a different method this time
     $util = new NumberUtil();
     $isOdd = $util->IsOdd(2);
     // this time check that the return value is false
     $this->assertFalse($isOdd);
 }
 public static function renderNonEditableStatically($model, $attribute)
 {
     if ($model instanceof RedBeanModel && $model->isAttributeFormattedAsProbability($attribute)) {
         $resolvedValue = NumberUtil::divisionForZero($model->{$attribute}, 100);
         return Yii::app()->numberFormatter->formatPercentage($resolvedValue);
     } else {
         return Yii::app()->numberFormatter->formatDecimal((int) $model->{$attribute});
     }
 }
예제 #3
0
 /**
  * Renders the attribute from the model.
  * @return The element's content.
  */
 protected function renderControlNonEditable()
 {
     if ($this->model instanceof RedBeanModel && $this->model->isAttributeFormattedAsProbability($this->attribute)) {
         $resolvedValue = NumberUtil::divisionForZero($this->model->{$this->attribute}, 100);
         return Yii::app()->numberFormatter->formatPercentage($resolvedValue);
     } else {
         return Yii::app()->numberFormatter->formatDecimal((int) $this->model->{$this->attribute});
     }
 }
 public function testSimpleNumberToWords()
 {
     $util = new NumberUtil();
     $this->assertEquals('seven', $util->GetWords(7), 'Test words for number 7');
     $this->assertEquals('two hundred and twenty-five', $util->GetWords(225), 'Test words for number 255');
     $this->assertEquals('negative two hundred and twenty-five', $util->GetWords(-225), 'Test words for negative number -255');
     $this->assertEquals('negative two hundred and twenty-five', $util->GetWords(-225), 'Test words for negative number -255');
     $this->assertEquals('five hundred point two five', $util->GetWords(500.25), 'Test words for float 500.25');
     $this->assertEquals('fifty thousand and one', $util->GetWords(50001), 'Test words for large number 50001');
 }
예제 #5
0
 private function calcularCarteira($bivas)
 {
     $carteira["valorTotalBruto"] = NumberUtil::toDecimalBrFormat($this->calcularTotalBruto($bivas));
     $carteira["valorTotalLiquido"] = NumberUtil::toDecimalBrFormat($this->calcularTotalLiquido($bivas));
     $carteira["valorTotalInvestido"] = NumberUtil::toDecimalBrFormat($this->calcularTotalInvestido($bivas));
     $carteira["valorTotalLucroBruto"] = NumberUtil::toDecimalBrFormat($this->calcularTotalLucroBruto($bivas));
     $carteira["valorTotalLucroLiquido"] = NumberUtil::toDecimalBrFormat($this->calcularTotalLucroLiquido($bivas));
     $carteira["totalPercLucroBruto"] = NumberUtil::toDecimalBrFormat($this->calcularTotalLucroBruto($bivas) / $this->calcularTotalInvestido($bivas) * 100);
     $carteira["totalPercLucroLiquido"] = NumberUtil::toDecimalBrFormat($this->calcularTotalLucroLiquido($bivas) / $this->calcularTotalInvestido($bivas) * 100);
     $carteira["rendaMensalMedia"] = NumberUtil::toDecimalBrFormat($this->calcularRendaMensalMedia($bivas));
     $carteira["rendaAnualMedia"] = NumberUtil::toDecimalBrFormat($this->calcularRendaAnualMedia($bivas));
     $carteira["percTotalRendaMensal"] = NumberUtil::toDecimalBrFormat($this->calcularPercTotalRendaMensal($bivas));
     $carteira["percTotalRendaAnual"] = NumberUtil::toDecimalBrFormat($this->calcularPercTotalRendaAnual($bivas));
     return $carteira;
 }
 public function renderDataCellContent($data, $row)
 {
     assert('$data instanceof ReportResultsRowData');
     if (null === ($displayAttributeKey = $data::resolveKeyByAttributeName($this->attribute))) {
         return $data->{$this->attribute};
     }
     $displayAttributes = $data->getDisplayAttributes();
     $displayAttribute = $displayAttributes[$displayAttributeKey];
     $realAttributeName = $displayAttribute->getResolvedAttribute();
     if ($data->getModel($this->attribute) instanceof RedBeanModel && $data->getModel($this->attribute)->isAttributeFormattedAsProbability($realAttributeName)) {
         $resolvedValue = NumberUtil::divisionForZero($data->{$this->attribute}, 100);
         return Yii::app()->numberFormatter->formatPercentage($resolvedValue);
     } else {
         return $this->renderValue($data->{$this->attribute});
     }
 }
 public static function renderNonEditableStatically($model, $attribute)
 {
     assert('$model instanceof ReportResultsRowData');
     if (null === ($displayAttributeKey = $model::resolveKeyByAttributeName($attribute))) {
         return $model->{$attribute};
     }
     $displayAttributes = $model->getDisplayAttributes();
     $displayAttribute = $displayAttributes[$displayAttributeKey];
     $realAttributeName = $displayAttribute->getResolvedAttribute();
     if ($model->getModel($attribute) instanceof RedBeanModel && $model->getModel($attribute)->isAttributeFormattedAsProbability($realAttributeName)) {
         $resolvedValue = NumberUtil::divisionForZero($model->{$attribute}, 100);
         return Yii::app()->numberFormatter->formatPercentage($resolvedValue);
     } else {
         return Yii::app()->format->formatNumber((int) $model->{$attribute});
     }
 }
 /**
  * @return array
  */
 public function getChartData()
 {
     $chartData = $this->resolveChartDataStructure();
     $rows = $this->makeCombinedData();
     foreach ($rows as $row) {
         $chartIndexToCompare = $row[$this->resolveIndexGroupByToUse()];
         if (isset($chartData[$chartIndexToCompare])) {
             $uniqueOpenRate = NumberUtil::divisionForZero($row[self::UNIQUE_OPENS], $row[self::COUNT]);
             $uniqueClickThroughRate = NumberUtil::divisionForZero($row[self::UNIQUE_CLICKS], $row[self::COUNT]);
             $chartData[$chartIndexToCompare][self::UNIQUE_OPEN_RATE] = round($uniqueOpenRate * 100, 2);
             $chartData[$chartIndexToCompare][self::UNIQUE_CLICK_THROUGH_RATE] = round($uniqueClickThroughRate * 100, 2);
         }
     }
     $newChartData = array();
     foreach ($chartData as $data) {
         $newChartData[] = $data;
     }
     return $newChartData;
 }
 protected static function renderMetricsContent(Autoresponder $autoresponder)
 {
     $dataProvider = new AutoresponderGroupedChartDataProvider($autoresponder);
     $data = $dataProvider->getChartData();
     $sentQuantity = Yii::app()->format->formatNumber((int) $data[MarketingChartDataProvider::SENT]);
     $openQuantity = Yii::app()->format->formatNumber((int) $data[MarketingChartDataProvider::UNIQUE_OPENS]);
     $openRate = round(NumberUtil::divisionForZero($openQuantity, $sentQuantity) * 100, 2);
     $clickQuantity = Yii::app()->format->formatNumber((int) $data[MarketingChartDataProvider::UNIQUE_CLICKS]);
     $clickRate = round(NumberUtil::divisionForZero($clickQuantity, $sentQuantity) * 100, 2);
     $unsubscribedQuantity = Yii::app()->format->formatNumber((int) $data[MarketingChartDataProvider::UNSUBSCRIBED]);
     $unsubscribedRate = round(NumberUtil::divisionForZero($unsubscribedQuantity, $sentQuantity) * 100, 2);
     $bouncedQuantity = Yii::app()->format->formatNumber((int) $data[MarketingChartDataProvider::BOUNCED]);
     $bouncedRate = round(NumberUtil::divisionForZero($bouncedQuantity, $sentQuantity) * 100, 2);
     $content = null;
     $content .= ZurmoHtml::tag('div', array('class' => 'autoresponder-stats'), Zurmo::t('MarketingModule', '{quantity} sent', array('{quantity}' => ZurmoHtml::tag('strong', array(), $sentQuantity))));
     $content .= ZurmoHtml::tag('div', array('class' => 'autoresponder-stats'), Zurmo::t('MarketingModule', '{quantity} opens ({openRate}%)', array('{quantity}' => ZurmoHtml::tag('strong', array(), $openQuantity), '{openRate}' => ZurmoHtml::tag('span', array(), $openRate))));
     $content .= ZurmoHtml::tag('div', array('class' => 'autoresponder-stats'), Zurmo::t('MarketingModule', '{quantity} unique clicks ({clickRate}%)', array('{quantity}' => ZurmoHtml::tag('strong', array(), $clickQuantity), '{clickRate}' => ZurmoHtml::tag('span', array(), $clickRate))));
     $content .= ZurmoHtml::tag('div', array('class' => 'autoresponder-stats'), Zurmo::t('MarketingModule', '{quantity} Unsubscribed ({unsubscribedRate}%)', array('{quantity}' => ZurmoHtml::tag('strong', array(), $unsubscribedQuantity), '{unsubscribedRate}' => ZurmoHtml::tag('span', array(), $unsubscribedRate))));
     $content .= ZurmoHtml::tag('div', array('class' => 'autoresponder-stats'), Zurmo::t('MarketingModule', '{quantity} Bounces ({bouncedRate}%)', array('{quantity}' => ZurmoHtml::tag('strong', array(), $bouncedQuantity), '{bouncedRate}' => ZurmoHtml::tag('span', array(), $bouncedRate))));
     return $content;
 }
예제 #10
0
파일: Biva.php 프로젝트: joaoabvs/projeto
 public function jsonSerialize()
 {
     return array('codigo' => $this->codigo, 'empresa' => $this->empresa, 'data' => DateUtil::dateBdToDateBr($this->data), 'valorInvestido' => NumberUtil::toDecimalBrFormat($this->valorInvestido), 'duracao' => $this->duracao, 'juros' => $this->juros, 'valorFinalBruto' => NumberUtil::toDecimalBrFormat($this->valorFinalBruto), 'valorFinalLiquido' => NumberUtil::toDecimalBrFormat($this->valorFinalLiquido), 'lucroBruto' => NumberUtil::toDecimalBrFormat($this->calcularLucroBruto()), 'lucroLiquido' => NumberUtil::toDecimalBrFormat($this->calcularLucroLiquido()), 'percLucroBruto' => NumberUtil::toDecimalBrFormat($this->calcularPercLucroBruto()), 'percLucroLiquido' => NumberUtil::toDecimalBrFormat($this->calcularPercLucroLiquido()), 'rendaMensal' => NumberUtil::toDecimalBrFormat($this->calcularRendaMensal()), 'rendaAnual' => NumberUtil::toDecimalBrFormat($this->calcularRendaAnual()), 'percRendaMensal' => NumberUtil::toDecimalBrFormat($this->calcularPercRendaMensal()), 'percRendaAnual' => NumberUtil::toDecimalBrFormat($this->calcularPercRendaAnual()));
 }
예제 #11
0
 public function jsonSerialize()
 {
     return array('codigo' => $this->codigo, 'biva' => $this->biva, 'dataPrevista' => DateUtil::dateBdToDateBr($this->dataPrevista), 'dataRecebida' => DateUtil::dateBdToDateBr($this->dataRecebida), 'valorBruto' => NumberUtil::toDecimalBrFormat($this->valorBruto), 'valorLiquido' => NumberUtil::toDecimalBrFormat($this->valorLiquido), 'valorRecebido' => NumberUtil::toDecimalBrFormat($this->valorRecebido), 'isAtrasada' => $this->isAtrasada());
 }
예제 #12
0
 public function jsonSerialize()
 {
     return array('codigo' => $this->codigo, 'dataInicio' => DateUtil::dateBdToDateBr($this->dataInicio), 'valorInvestido' => NumberUtil::toDecimalBrFormat($this->valorInvestido), 'jurosAnual' => NumberUtil::toDecimalBrFormat($this->jurosAnual));
 }
<?php

require_once '../libs/NumberUtil.php';
$number = strip_tags(isset($_REQUEST['number']) ? $_REQUEST['number'] : '');
$numUtil = new NumberUtil();
$result = new stdClass();
$result->number = $number;
try {
    $result->text = $numUtil->GetWords($number);
} catch (Exception $ex) {
    $result->error = $ex->getMessage();
}
echo json_encode($result);