feat(contracts): lazily expire lapsed contracts and price fuel surcharge

This commit is contained in:
Marshal
2026-08-12 11:23:04 +00:00
parent a02d24806b
commit 3dbda745dd
5 changed files with 112 additions and 17 deletions

View File

@@ -811,6 +811,16 @@ export class ContractsService {
throw new NotFoundException(`Contract ${id} not found`);
}
// Lazy expiry flip: the nightly cron only sweeps once a day, so a
// contract can be past contract_valid_until for hours before it shows
// EXPIRED. Flip it here so the detail page never shows a stale status.
if (isEffectivelyExpired(contract) && contract.status !== 'EXPIRED') {
const flipped = await this.contractsRepository.expireIfLapsed(id);
if (flipped) {
contract.status = 'EXPIRED';
}
}
if (contract.files && contract.files.length > 0) {
contract.files = await Promise.all(
contract.files.map(async (file: FileRecord) => {