Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
- Fixed : abbreviating currencies
  • Loading branch information
Blair2004 committed Jul 30, 2021
1 parent 58dca3c commit f9465fa
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions resources/ts/filters/currency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ declare const window;
const precision = ( new Array( parseInt( ns.currency.ns_currency_precision ) ) ).fill('').map( _ => 0 ).join('');

const nsCurrency = Vue.filter( 'currency', ( value, format = 'full', locale = 'en' ) => {
console.log( format );
let numeralFormat, currencySymbol;

switch( ns.currency.ns_currency_prefered ) {
Expand All @@ -19,16 +20,23 @@ const nsCurrency = Vue.filter( 'currency', ( value, format = 'full', lo
break;
}

const config = {
decimal: ns.currency.ns_currency_decimal_separator,
separator: ns.currency.ns_currency_thousand_separator,
precision : parseInt( ns.currency.ns_currency_precision ),
symbol: ''
};
let newValue;

if ( format === 'full' ) {
const config = {
decimal: ns.currency.ns_currency_decimal_separator,
separator: ns.currency.ns_currency_thousand_separator,
precision : parseInt( ns.currency.ns_currency_precision ),
symbol: ''
};

newValue = currency( value, config ).format();
} else {
newValue = NumeralJS( value ).format( '0.0a' );
}

const currencyValue = currency( value, config );
return `${ns.currency.ns_currency_position === 'before' ? currencySymbol : '' }${ newValue }${ns.currency.ns_currency_position === 'after' ? currencySymbol : '' }`;

return `${ns.currency.ns_currency_position === 'before' ? currencySymbol : '' }${ currencyValue.format() }${ns.currency.ns_currency_position === 'after' ? currencySymbol : '' }`;
});

const nsRawCurrency = ( value ) => {
Expand Down

0 comments on commit f9465fa

Please sign in to comment.