removed cron job that made rentals active. Now whether or not the rental is active is determined on the fly
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
const { ConditionCheck, Rental, User } = require("../models");
|
||||
const { Op } = require("sequelize");
|
||||
const { isActive } = require("../utils/rentalStatus");
|
||||
|
||||
class ConditionCheckService {
|
||||
/**
|
||||
@@ -70,7 +71,7 @@ class ConditionCheckService {
|
||||
canSubmit =
|
||||
now >= timeWindow.start &&
|
||||
now <= timeWindow.end &&
|
||||
rental.status === "active";
|
||||
isActive(rental);
|
||||
break;
|
||||
|
||||
case "rental_end_renter":
|
||||
@@ -80,7 +81,7 @@ class ConditionCheckService {
|
||||
canSubmit =
|
||||
now >= timeWindow.start &&
|
||||
now <= timeWindow.end &&
|
||||
rental.status === "active";
|
||||
isActive(rental);
|
||||
break;
|
||||
|
||||
case "post_rental_owner":
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
const { Rental, Item, ConditionCheck, User } = require("../models");
|
||||
const LateReturnService = require("./lateReturnService");
|
||||
const emailServices = require("./email");
|
||||
const { isActive } = require("../utils/rentalStatus");
|
||||
|
||||
class DamageAssessmentService {
|
||||
/**
|
||||
@@ -34,7 +35,7 @@ class DamageAssessmentService {
|
||||
throw new Error("Only the item owner can report damage");
|
||||
}
|
||||
|
||||
if (rental.status !== "active") {
|
||||
if (!isActive(rental)) {
|
||||
throw new Error("Can only assess damage for active rentals");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
const { Rental, Item, User } = require("../models");
|
||||
const emailServices = require("./email");
|
||||
const { isActive } = require("../utils/rentalStatus");
|
||||
|
||||
class LateReturnService {
|
||||
/**
|
||||
@@ -71,7 +72,7 @@ class LateReturnService {
|
||||
throw new Error("Rental not found");
|
||||
}
|
||||
|
||||
if (rental.status !== "active") {
|
||||
if (!isActive(rental)) {
|
||||
throw new Error("Can only process late returns for active rentals");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
const { Rental } = require("../models");
|
||||
const StripeService = require("./stripeService");
|
||||
const { isActive } = require("../utils/rentalStatus");
|
||||
|
||||
class RefundService {
|
||||
/**
|
||||
@@ -69,8 +70,8 @@ class RefundService {
|
||||
};
|
||||
}
|
||||
|
||||
// Check if rental is active
|
||||
if (rental.status === "active") {
|
||||
// Check if rental is active (computed from confirmed + start time passed)
|
||||
if (isActive(rental)) {
|
||||
return {
|
||||
canCancel: false,
|
||||
reason: "Cannot cancel active rental",
|
||||
|
||||
Reference in New Issue
Block a user