Fix timing between billedLastAt and billPaidUntil (#952)

This commit is contained in:
ekzyis 2024-03-21 01:52:38 +01:00 committed by GitHub
parent b35302ccdc
commit a22db1a6a3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 2 deletions

View File

@ -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',