[IMP] odex_benefit: IMP benefit
This commit is contained in:
parent
9e0935d67b
commit
c74cb8f89d
|
|
@ -750,10 +750,6 @@ class GrantBenefitProfile(models.Model):
|
||||||
@api.depends('is_mother_work','mother_salary_ids','mother_expenses_ids','mother_debits_ids')
|
@api.depends('is_mother_work','mother_salary_ids','mother_expenses_ids','mother_debits_ids')
|
||||||
def _compute_mother_net_income(self):
|
def _compute_mother_net_income(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
if not rec.is_mother_work:
|
|
||||||
rec.mother_net_income = 0.0
|
|
||||||
continue
|
|
||||||
|
|
||||||
deductions = (
|
deductions = (
|
||||||
sum(rec.mother_expenses_ids.filtered('deduct_from_family_income').mapped('amount')) +
|
sum(rec.mother_expenses_ids.filtered('deduct_from_family_income').mapped('amount')) +
|
||||||
sum(rec.mother_debits_ids.filtered('deduct_from_family_income').mapped('monthly_installment'))
|
sum(rec.mother_debits_ids.filtered('deduct_from_family_income').mapped('monthly_installment'))
|
||||||
|
|
@ -1424,30 +1420,28 @@ class GrantBenefitProfile(models.Model):
|
||||||
return status, reasons
|
return status, reasons
|
||||||
|
|
||||||
def check_replacement_mother_status(self):
|
def check_replacement_mother_status(self):
|
||||||
validation_setting = self.env["family.validation.setting"].search([], limit=1)
|
|
||||||
mini_income_for_mother = validation_setting.mini_income_for_mother
|
|
||||||
max_income_for_mother = validation_setting.max_income_for_mother
|
|
||||||
for rec in self:
|
for rec in self:
|
||||||
reasons = []
|
reasons = []
|
||||||
status = 'benefit'
|
status = 'benefit'
|
||||||
if not rec.add_replacement_mother:
|
if not rec.add_replacement_mother:
|
||||||
continue
|
continue
|
||||||
if not rec.replacement_mother_location_conf.is_benefit or not rec.replacement_mother_marital_conf.is_benefit or rec.state in ['suspended_second_approve','refused']:
|
if rec.state in ['suspended_second_approve', 'refused']:
|
||||||
status = 'non_benefit'
|
status = 'non_benefit'
|
||||||
reasons.append(_("The replacement mother's marital or location conditions are not eligible."))
|
reasons.append(_("Family is suspended or refused."))
|
||||||
elif rec.replacement_mother_marital_conf.is_benefit:
|
return status, reasons
|
||||||
if rec.replacement_is_mother_work and rec.replacement_mother_country_id.code == 'SA' or (
|
|
||||||
rec.replacement_mother_country_id.code != 'SA' and rec.father_country_id.code == 'SA'):
|
if not rec.replacement_mother_marital_conf or not rec.replacement_mother_location_conf:
|
||||||
if mini_income_for_mother < rec.replacement_mother_income <= max_income_for_mother:
|
|
||||||
status = 'non_benefit'
|
status = 'non_benefit'
|
||||||
reasons.append(_("The replacement mother's income is between minimum and maximum thresholds."))
|
reasons.append(_("Replacement mother marital or location information is missing."))
|
||||||
elif rec.replacement_mother_income <= mini_income_for_mother:
|
return status, reasons
|
||||||
status = 'benefit'
|
|
||||||
elif rec.replacement_mother_income > max_income_for_mother:
|
if not rec.replacement_mother_marital_conf.replacement_mother_is_benefit:
|
||||||
status = 'benefit'
|
status = 'non_benefit'
|
||||||
elif not rec.replacement_is_mother_work and rec.replacement_mother_country_id.code == 'SA' or (
|
reasons.append(_("The replacement mother's marital status is not eligible for benefits."))
|
||||||
rec.replacement_mother_country_id.code != 'SA' and rec.father_country_id.code == 'SA'):
|
|
||||||
status = 'benefit'
|
if not rec.replacement_mother_location_conf.replacement_mother_is_benefit:
|
||||||
|
status = 'non_benefit'
|
||||||
|
reasons.append(_("The replacement mother's location is not eligible for benefits."))
|
||||||
return status, reasons
|
return status, reasons
|
||||||
|
|
||||||
def delete_from_db(self):
|
def delete_from_db(self):
|
||||||
|
|
@ -2212,18 +2206,11 @@ class GrantBenefitProfile(models.Model):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
total = 0.0
|
total = 0.0
|
||||||
rec.total_income = 0.0
|
rec.total_income = 0.0
|
||||||
if not rec.add_replacement_mother:
|
|
||||||
if rec.mother_status == 'non_benefit':
|
if rec.mother_status == 'non_benefit':
|
||||||
total = sum(rec.salary_ids.filtered(lambda e: e.approved).mapped('salary_amount'))
|
total = sum(rec.salary_ids.filtered(lambda e: e.approved).mapped('salary_amount'))
|
||||||
elif rec.mother_status == 'benefit':
|
elif rec.mother_status == 'benefit':
|
||||||
total = sum(rec.salary_ids.filtered(lambda e: e.approved).mapped('salary_amount')) + rec.mother_income
|
total = sum(rec.salary_ids.filtered(lambda e: e.approved).mapped('salary_amount')) + rec.mother_income
|
||||||
rec.total_income = total
|
rec.total_income = total
|
||||||
if rec.add_replacement_mother:
|
|
||||||
if rec.replacement_mother_status == 'non_benefit':
|
|
||||||
total = sum(rec.salary_ids.filtered(lambda e: e.approved).mapped('salary_amount'))
|
|
||||||
elif rec.replacement_mother_status == 'benefit':
|
|
||||||
total = sum(rec.salary_ids.filtered(lambda e: e.approved).mapped('salary_amount')) + rec.replacement_mother_income
|
|
||||||
rec.total_income += total
|
|
||||||
|
|
||||||
def get_mother_name(self):
|
def get_mother_name(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
|
|
@ -2655,7 +2642,7 @@ class GrantBenefitProfile(models.Model):
|
||||||
'message': _('Not Benefit')}
|
'message': _('Not Benefit')}
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@api.onchange('replacement_mother_marital_conf', 'replacement_mother_location_conf', 'replacement_mother_income')
|
@api.onchange('replacement_mother_marital_conf', 'replacement_mother_location_conf')
|
||||||
def _onchange_replacement_mother_info(self):
|
def _onchange_replacement_mother_info(self):
|
||||||
res = {}
|
res = {}
|
||||||
for rec in self:
|
for rec in self:
|
||||||
|
|
|
||||||
|
|
@ -806,6 +806,7 @@ class LocationSettings(models.Model):
|
||||||
location_type = fields.Selection([('member', _('Member')), ('mother_location', _('Mother Location'))])
|
location_type = fields.Selection([('member', _('Member')), ('mother_location', _('Mother Location'))])
|
||||||
is_benefit = fields.Boolean(string='Is Benefit?')
|
is_benefit = fields.Boolean(string='Is Benefit?')
|
||||||
is_far_from_family = fields.Boolean(string='Is Far From Family?')
|
is_far_from_family = fields.Boolean(string='Is Far From Family?')
|
||||||
|
replacement_mother_is_benefit = fields.Boolean(string="Replacement Mother Is Benefit?", default=True, )
|
||||||
|
|
||||||
class AttachmentsSettings(models.Model):
|
class AttachmentsSettings(models.Model):
|
||||||
_name = 'attachments.settings'
|
_name = 'attachments.settings'
|
||||||
|
|
@ -897,6 +898,7 @@ class MaritalStatus(models.Model):
|
||||||
name = fields.Char(string="Name")
|
name = fields.Char(string="Name")
|
||||||
is_benefit = fields.Boolean(string='Is Benefit?')
|
is_benefit = fields.Boolean(string='Is Benefit?')
|
||||||
is_dead = fields.Boolean(string='Is Dead?')
|
is_dead = fields.Boolean(string='Is Dead?')
|
||||||
|
replacement_mother_is_benefit = fields.Boolean(string="Replacement Mother Is Benefit?",default=True,)
|
||||||
|
|
||||||
class AgeCategory(models.Model):
|
class AgeCategory(models.Model):
|
||||||
_name = 'age.category'
|
_name = 'age.category'
|
||||||
|
|
|
||||||
|
|
@ -1016,9 +1016,13 @@
|
||||||
<group>
|
<group>
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="location_type"/>
|
<field name="location_type"/>
|
||||||
<field name="is_benefit"/>
|
|
||||||
<field name="is_far_from_family"/>
|
<field name="is_far_from_family"/>
|
||||||
</group>
|
</group>
|
||||||
|
<group>
|
||||||
|
<field name="is_benefit"/>
|
||||||
|
<field name="replacement_mother_is_benefit"/>
|
||||||
|
</group>
|
||||||
</group>
|
</group>
|
||||||
</sheet>
|
</sheet>
|
||||||
</form>
|
</form>
|
||||||
|
|
@ -1033,6 +1037,7 @@
|
||||||
<field name="location_type"/>
|
<field name="location_type"/>
|
||||||
<field name="is_benefit"/>
|
<field name="is_benefit"/>
|
||||||
<field name="is_far_from_family"/>
|
<field name="is_far_from_family"/>
|
||||||
|
<field name="replacement_mother_is_benefit"/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
@ -1333,9 +1338,13 @@
|
||||||
<group>
|
<group>
|
||||||
<group>
|
<group>
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="is_benefit"/>
|
|
||||||
<field name="is_dead"/>
|
<field name="is_dead"/>
|
||||||
</group>
|
</group>
|
||||||
|
<group>
|
||||||
|
<field name="is_benefit"/>
|
||||||
|
<field name="replacement_mother_is_benefit"/>
|
||||||
|
</group>
|
||||||
</group>
|
</group>
|
||||||
</sheet>
|
</sheet>
|
||||||
</form>
|
</form>
|
||||||
|
|
@ -1348,6 +1357,7 @@
|
||||||
<tree>
|
<tree>
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="is_benefit"/>
|
<field name="is_benefit"/>
|
||||||
|
<field name="replacement_mother_is_benefit"/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
|
||||||
|
|
@ -909,7 +909,7 @@
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</page>
|
</page>
|
||||||
<page string="Mother Expenses" attrs="{'invisible':[('is_mother_work','=',False)]}">
|
<page string="Mother Expenses">
|
||||||
<field name="mother_expenses_ids" context="{'default_state': 'accepted'}"
|
<field name="mother_expenses_ids" context="{'default_state': 'accepted'}"
|
||||||
attrs="{'readonly':[('state','not in',['draft','new','complete_info'])]}">
|
attrs="{'readonly':[('state','not in',['draft','new','complete_info'])]}">
|
||||||
<tree editable="top">
|
<tree editable="top">
|
||||||
|
|
@ -929,7 +929,7 @@
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</page>
|
</page>
|
||||||
<page string="Mother Income" attrs="{'invisible':[('is_mother_work','=',False)]}">
|
<page string="Mother Income">
|
||||||
<field name="mother_salary_ids"
|
<field name="mother_salary_ids"
|
||||||
context="{'default_state': 'accepted','default_is_mother_salary': True}"
|
context="{'default_state': 'accepted','default_is_mother_salary': True}"
|
||||||
mode="tree"
|
mode="tree"
|
||||||
|
|
@ -955,7 +955,7 @@
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</page>
|
</page>
|
||||||
<page string="Mother Debts" attrs="{'invisible':[('is_mother_work','=',False)]}">
|
<page string="Mother Debts">
|
||||||
<field name="mother_debits_ids" context="{'default_state': 'accepted'}"
|
<field name="mother_debits_ids" context="{'default_state': 'accepted'}"
|
||||||
attrs="{'readonly':[('state','not in',['draft','new','complete_info'])]}">
|
attrs="{'readonly':[('state','not in',['draft','new','complete_info'])]}">
|
||||||
<form>
|
<form>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue