mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
fix(subscriptions): use correct termination date field and add extra check when it is missing
This commit is contained in:
@@ -18,6 +18,12 @@ export default function calculateSubscriptionTerminationDate (
|
||||
|
||||
const calculatedTerminationDate = moment().startOf('day').add({ days: remaining + extraDays });
|
||||
|
||||
return calculatedTerminationDate.isBefore(purchasedPlan.terminationDate)
|
||||
? purchasedPlan.terminationDate : calculatedTerminationDate.toDate();
|
||||
// If a termination date is already set, use the one further in the future
|
||||
if (purchasedPlan.dateTerminated) {
|
||||
return calculatedTerminationDate.isBefore(purchasedPlan.dateTerminated)
|
||||
? purchasedPlan.dateTerminated : calculatedTerminationDate.toDate();
|
||||
}
|
||||
|
||||
// Otherwise the calculated one
|
||||
return calculatedTerminationDate.toDate();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user