mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-15 11:34:24 +03:00
d16a8781a9
closes https://github.com/TryGhost/Team/issues/1319 Due to how JS implements numbers, it's possible that when we multiple a number with 2 decimal places by 100 that we do not end up with an integer e.g. 9.95 * 100 = 994.999... This is not a valid price for the API and so we must round it to the nearest integer. We round off prices both at source as well as in ties serializer to make sure we never send non integer prices to API.
18 lines
484 B
JavaScript
18 lines
484 B
JavaScript
import ApplicationSerializer from './application';
|
|
|
|
export default class ProductSerializer extends ApplicationSerializer {
|
|
serialize() {
|
|
let json = super.serialize(...arguments);
|
|
|
|
if (json?.monthly_price?.amount) {
|
|
json.monthly_price.amount = Math.round(json.monthly_price.amount);
|
|
}
|
|
|
|
if (json?.yearly_price?.amount) {
|
|
json.yearly_price.amount = Math.round(json.yearly_price.amount);
|
|
}
|
|
|
|
return json;
|
|
}
|
|
}
|