chore: add new logic for the quota

This commit is contained in:
mahyargdz
2025-07-12 09:45:07 +03:30
parent a350f8af5a
commit 344bf1de0a
12 changed files with 169 additions and 39 deletions
@@ -85,4 +85,25 @@ export class BusinessesService {
if (!staff) throw new BadRequestException(BusinessMessage.STAFF_NOT_FOUND);
return staff;
}
//************************************************** */
async getBusinessQuota(businessId: string) {
const business = await this.businessRepository.findOne({ id: businessId, deletedAt: null });
if (!business) throw new BadRequestException(BusinessMessage.NOT_FOUND);
return {
quota: {
total: Number(business.quota),
used: Number(business.usedQuota),
remaining: Number(business.remainingQuota),
totalInMB: Math.round(Number(business.quota) / (1024 * 1024)),
totalInGB: Math.round(Number(business.quota) / (1024 * 1024 * 1024)),
usedInMB: Math.round(Number(business.usedQuota) / (1024 * 1024)),
usedInGB: Math.round(Number(business.usedQuota) / (1024 * 1024 * 1024)),
remainingInMB: Math.round(Number(business.remainingQuota) / (1024 * 1024)),
remainingInGB: Math.round(Number(business.remainingQuota) / (1024 * 1024 * 1024)),
usagePercentage: Math.round((Number(business.usedQuota) / Number(business.quota)) * 100),
},
};
}
}