2021-01-27 04:38:33 -05:00
|
|
|
import EmberObject, { computed } from "@ember/object";
|
2020-05-28 11:32:57 -04:00
|
|
|
import discourseComputed from "discourse-common/utils/decorators";
|
2019-10-08 04:37:22 -04:00
|
|
|
|
2019-12-17 00:31:58 -05:00
|
|
|
const Plan = EmberObject.extend({
|
2020-11-30 11:35:21 -05:00
|
|
|
amountDollars: computed("unit_amount", {
|
2019-10-30 22:29:11 -04:00
|
|
|
get() {
|
2020-07-15 09:44:40 -04:00
|
|
|
return parseFloat(this.get("unit_amount") / 100).toFixed(2);
|
2019-10-30 22:29:11 -04:00
|
|
|
},
|
|
|
|
set(key, value) {
|
|
|
|
const decimal = parseFloat(value) * 100;
|
2020-07-15 09:44:40 -04:00
|
|
|
this.set("unit_amount", decimal);
|
2019-10-30 22:29:11 -04:00
|
|
|
return value;
|
2020-09-16 10:53:50 -04:00
|
|
|
},
|
2019-10-30 22:29:11 -04:00
|
|
|
}),
|
2020-07-15 09:44:40 -04:00
|
|
|
@discourseComputed("recurring.interval")
|
|
|
|
billingInterval(interval) {
|
|
|
|
return interval || "one-time";
|
|
|
|
},
|
2019-10-30 20:41:01 -04:00
|
|
|
|
2020-07-15 09:44:40 -04:00
|
|
|
@discourseComputed("amountDollars", "currency", "billingInterval")
|
2019-10-30 20:41:01 -04:00
|
|
|
subscriptionRate(amountDollars, currency, interval) {
|
2020-04-23 06:36:02 -04:00
|
|
|
return `${amountDollars} ${currency.toUpperCase()} / ${interval}`;
|
2020-09-16 10:53:50 -04:00
|
|
|
},
|
2019-10-30 19:44:46 -04:00
|
|
|
});
|
2019-10-08 04:37:22 -04:00
|
|
|
|
|
|
|
export default Plan;
|