[IMP] odex_benefit: IMP benefit

This commit is contained in:
younes 2025-12-10 08:51:15 +01:00
parent 402e9e1445
commit 0a14f4b671
1 changed files with 6 additions and 2 deletions

View File

@ -800,8 +800,12 @@ class ServiceRequest(models.Model):
elif rec.max_limit_period == "individual":
rec.service_max_amount *= rec.service_benefit_count
elif rec.max_limit_period == "recurrence_period":
pass
prev_requests = Service.search(base_domain)
total_spent = sum(prev_requests.mapped('requested_service_amount'))
remaining = rec.service_cat.max_amount - total_spent
if remaining < 0:
remaining = 0
rec.service_max_amount = remaining
if rec.service_cat.service_type == 'marriage':
if rec.member_id.relationn.relation_type == 'son' and not rec.member_id.is_work:
raise ValidationError(_("This service is not eligible because the son is not working."))