Merge pull request #5686 from expsa/kch_dev_odex25_benefit

[IMP] odex_benefit: IMP benefit
This commit is contained in:
kchyounes19 2025-12-10 08:53:55 +01:00 committed by GitHub
commit 78f145b0c1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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."))