Last active
July 13, 2020 11:40
-
-
Save Lunberg88/8af031d426c841e2ca46237663deed60 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//** | |
// src/lang/numeralLocales.js | |
import numeral from 'numeral'; | |
export const register = (localeName = 'ch', currency) => numeral.register('locale', localeName, { | |
delimiters: { | |
thousands: ' ', | |
decimal: ',' | |
}, | |
abbreviations: { | |
thousand: 'k', | |
million: 'm', | |
billion: 'b', | |
trillion: 't' | |
}, | |
ordinal: function (number) { | |
return '.'; | |
}, | |
currency: { | |
symbol: currency | |
} | |
}); | |
//** | |
// Hotel.js entity | |
static afterCreate(model) { | |
let locale = model.countryCode.toLowerCase(); | |
register(locale, model.propertyCurrency); | |
numeral.locale(locale); | |
numeral.defaultFormat('$0,0.00'); | |
} | |
//** | |
// | |
computed: { | |
totalPrice() { | |
const booking = Booking.query().first(); | |
return this.$numeral(roundUp((booking && booking.totalPrice) || 0,2)).format(); | |
}, | |
} | |
//** | |
// Output: Price total: CHF177,23 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment