Fix timing between billedLastAt and billPaidUntil (#952)
This commit is contained in:
parent
b35302ccdc
commit
a22db1a6a3
|
@ -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',
|
||||
|
|
Loading…
Reference in New Issue