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 }) {
|
async function createSub (parent, data, { me, models, lnd, hash, hmac }) {
|
||||||
const { billingType } = data
|
const { billingType } = data
|
||||||
let billingCost = TERRITORY_COST_MONTHLY
|
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') {
|
if (billingType === 'ONCE') {
|
||||||
billingCost = TERRITORY_COST_ONCE
|
billingCost = TERRITORY_COST_ONCE
|
||||||
billPaidUntil = null
|
billPaidUntil = null
|
||||||
} else if (billingType === 'YEARLY') {
|
} else if (billingType === 'YEARLY') {
|
||||||
billingCost = TERRITORY_COST_YEARLY
|
billingCost = TERRITORY_COST_YEARLY
|
||||||
billPaidUntil = datePivot(new Date(), { years: 1 })
|
billPaidUntil = datePivot(billedLastAt, { years: 1 })
|
||||||
}
|
}
|
||||||
|
|
||||||
const cost = BigInt(1000) * BigInt(billingCost)
|
const cost = BigInt(1000) * BigInt(billingCost)
|
||||||
|
@ -429,6 +430,7 @@ async function createSub (parent, data, { me, models, lnd, hash, hmac }) {
|
||||||
models.sub.create({
|
models.sub.create({
|
||||||
data: {
|
data: {
|
||||||
...data,
|
...data,
|
||||||
|
billedLastAt,
|
||||||
billPaidUntil,
|
billPaidUntil,
|
||||||
billingCost,
|
billingCost,
|
||||||
rankingType: 'WOT',
|
rankingType: 'WOT',
|
||||||
|
|
Loading…
Reference in New Issue