diff --git a/api/resolvers/sub.js b/api/resolvers/sub.js index e7a63fa9..2ac36160 100644 --- a/api/resolvers/sub.js +++ b/api/resolvers/sub.js @@ -400,14 +400,15 @@ export default { async function createSub (parent, data, { me, models, lnd, hash, hmac }) { const { billingType } = data let billingCost = TERRITORY_COST_MONTHLY - let billPaidUntil = datePivot(new Date(), { months: 1 }) + const billedLastAt = new Date() + let billPaidUntil = datePivot(billedLastAt, { months: 1 }) if (billingType === 'ONCE') { billingCost = TERRITORY_COST_ONCE billPaidUntil = null } else if (billingType === 'YEARLY') { billingCost = TERRITORY_COST_YEARLY - billPaidUntil = datePivot(new Date(), { years: 1 }) + billPaidUntil = datePivot(billedLastAt, { years: 1 }) } const cost = BigInt(1000) * BigInt(billingCost) @@ -429,6 +430,7 @@ async function createSub (parent, data, { me, models, lnd, hash, hmac }) { models.sub.create({ data: { ...data, + billedLastAt, billPaidUntil, billingCost, rankingType: 'WOT',