Format currency refactoring
This commit is contained in:
parent
28071a4a92
commit
ecaefa6950
3 changed files with 10 additions and 4 deletions
|
@ -4,7 +4,7 @@ $cost = '';
|
|||
if (isset($claim->price) && $claim->price > 0) {
|
||||
$cost = $this->Amount->formatCurrency($claim->price) . ' LBC';
|
||||
} else if (isset($claim->fee) && strtolower($claim->fee_currency) === 'lbc') {
|
||||
$cost = $this->Amount->formatCurrency($claim->fee) . ' LBC';
|
||||
$cost = $this->Amount->formatLbryCurrency($claim->fee) . ' LBC';
|
||||
}
|
||||
$a = ['purple', 'orange', 'blue', 'teal', 'green', 'yellow'];
|
||||
// content type
|
||||
|
|
|
@ -44,9 +44,9 @@ $cost = 'Free';
|
|||
if (isset($claim->price) && $claim->price > 0) {
|
||||
$cost = $this->Amount->formatCurrency($claim->price) . ' LBC';
|
||||
} else if (isset($claim->fee) && strtolower($claim->fee_currency) === 'lbc') {
|
||||
$cost = (float) ($claim->fee) . ' LBC';
|
||||
$cost = $this->Amount->formatLbryCurrency($claim->fee) . ' LBC';
|
||||
}
|
||||
$effective_amount = $claim->effective_amount / 100000000;
|
||||
$effective_amount = $this->Amount->formatLbryCurrency($claim->effective_amount);
|
||||
|
||||
$desc = $claim->description;
|
||||
if (strlen(trim($desc)) == 0) {
|
||||
|
@ -111,7 +111,7 @@ if (strlen(trim($desc)) == 0) {
|
|||
<div class="half-width"><div class="label help-text" title="The sum of the claim bid and all of its active supports.">Effective amount</div></div>
|
||||
|
||||
<div class="value half-width"><?php echo (float) ($claim->claim_bid) . ' LBC'; ?></div>
|
||||
<div class="value half-width"><?php echo ($effective_amount < $claim->claim_bid) ? '<em>Synchronizing</em>' : ((float) ($claim->effective_amount / 100000000) . ' LBC'); ?></div>
|
||||
<div class="value half-width"><?php echo ($claim->effective_amount < $claim->claim_bid) ? '<em>Synchronizing</em>' : ($effective_amount . ' LBC'); ?></div>
|
||||
|
||||
<div class="clear"></div>
|
||||
|
||||
|
|
|
@ -5,6 +5,8 @@ namespace App\View\Helper;
|
|||
use Cake\View\Helper;
|
||||
|
||||
class AmountHelper extends Helper {
|
||||
const DEWIES_DIVIDER = 100000000;
|
||||
|
||||
public function format($value, $thousandsSeparator = ',') {
|
||||
$value = number_format($value, 8, '.', $thousandsSeparator);
|
||||
$dotIdx = strpos($value, '.');
|
||||
|
@ -20,6 +22,10 @@ class AmountHelper extends Helper {
|
|||
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function formatLbryCurrency($value, $thousandsSeparator = ",") {
|
||||
return formatCurrency($value / DEWIES_DIVIDER);
|
||||
}
|
||||
|
||||
public function formatCurrency($value, $thousandsSeparator = ',') {
|
||||
$dotIdx = strpos($value, '.');
|
||||
|
|
Loading…
Reference in a new issue