diff --git a/odex25_ensan/odex_benefit/models/benefit.py b/odex25_ensan/odex_benefit/models/benefit.py index 410ba4a92..6baa40384 100644 --- a/odex25_ensan/odex_benefit/models/benefit.py +++ b/odex25_ensan/odex_benefit/models/benefit.py @@ -1753,7 +1753,6 @@ class GrantBenefitProfile(models.Model): def get_total_income(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: @@ -1764,13 +1763,15 @@ class GrantBenefitProfile(models.Model): total = 0.0 existing_mother_salary = salary_ids.filtered(lambda x: x.is_mother_salary == True) should_have_salary_line = (status == 'benefit' and income > max_income_for_mother) + income_type = self.env['attachments.settings'].search([('is_mother_salary','=',True)],limit=1) if should_have_salary_line: if not existing_mother_salary: salary_ids.create({ 'benefit_id': rec.id, 'is_mother_salary': True, 'salary_amount': income, - 'state': 'accepted', + 'income_type': income_type and income_type.id or False, + 'approved': True, }) elif existing_mother_salary: existing_mother_salary.write({'salary_amount': income}) @@ -1778,11 +1779,11 @@ class GrantBenefitProfile(models.Model): if existing_mother_salary: existing_mother_salary.unlink() if status == 'non_benefit': - total = sum(salary_ids.filtered(lambda e: e.state == 'accepted' and not e.is_mother_salary).mapped( + total = sum(salary_ids.filtered(lambda e: e.approved and not e.is_mother_salary).mapped( 'salary_amount')) elif status == 'benefit': total = sum( - salary_ids.filtered(lambda e: e.state == 'accepted').mapped('salary_amount')) + salary_ids.filtered(lambda e: e.approved).mapped('salary_amount')) return total if not rec.add_replacement_mother: # Calculate total income for mother @@ -1792,6 +1793,10 @@ class GrantBenefitProfile(models.Model): rec.total_income += calculate_income(rec.replacement_mother_income, rec.replacement_mother_status, rec.salary_ids) + # total_income = mother_income + sum(approved salarys) + # approved_salarys = fillter + # mother_inocme = if replacement_mother : income else mother.income income > max + def get_mother_name(self): for rec in self: @@ -2030,22 +2035,11 @@ class GrantBenefitProfile(models.Model): else: ben.non_member_count = 0.0 - @api.depends('salary_ids', 'expenses_ids', 'family_debits_ids.monthly_installment','mother_income','member_ids','family_debits_ids.state','expenses_ids.state','salary_ids.state') + @api.depends('salary_ids', 'expenses_ids', 'family_debits_ids.monthly_installment','mother_income','replacement_mother_income','member_ids','family_debits_ids.state','expenses_ids.state','salary_ids.approved') def get_member_income(self): - validation_setting = self.env["family.validation.setting"].search([], limit=1) - # max_income_for_mother = validation_setting.max_income_for_mother - # total = 0 for ben in self: ben.get_total_income() ben.get_total_expenses() - # if ben.mother_income >= max_income_for_mother and ben.family_debits_ids: - # family_income = ben.total_income - ben.total_expenses - # elif ben.mother_income >= max_income_for_mother: - # family_income = ben.total_income - ben.total_expenses - # elif ben.family_debits_ids: - # family_income = ben.total_income - ben.total_expenses - # else: - # family_income = ben.total_income - ben.total_expenses family_income = ben.total_income - ben.total_expenses if ben.benefit_member_count: if ben.benefit_member_count > 3: diff --git a/odex25_ensan/odex_benefit/models/benefit_config.py b/odex25_ensan/odex_benefit/models/benefit_config.py index 5efa098cd..dc775ba08 100644 --- a/odex25_ensan/odex_benefit/models/benefit_config.py +++ b/odex25_ensan/odex_benefit/models/benefit_config.py @@ -291,6 +291,7 @@ class Salary(models.Model): benefit_id = fields.Many2one( 'grant.benefit') + currency_id = fields.Many2one('res.currency', related='benefit_id.currency_id') salary_type = fields.Char() income_type = fields.Many2one('attachments.settings',string='Income Type',domain="[('attach_type','=','income_attach')]") salary_amount = fields.Float( @@ -301,8 +302,9 @@ class Salary(models.Model): attach_end_date = fields.Date(string='Attach End Date') is_required = fields.Boolean(string='Is Required?') is_mother_salary = fields.Boolean(string="Is Mother Salary", default=False) + approved = fields.Boolean(string="Is Approved", default=False) is_default = fields.Boolean(string='Is Default?') - state = fields.Selection(string='Status',selection=[('waiting', 'Waiting'),('accepted', 'Accepted'),('refused', 'Refused')],default="waiting") + state = fields.Selection(string='Status',selection=[('waiting', 'Waiting'),('accepted', 'Accepted'),('refused', 'Refused')],default="accepted") # total_salary = fields.Float(string="Total Salary", compute='_compute_total_salary',store=True) # @api.depends('salary_amount','state') @@ -758,6 +760,7 @@ class AttachmentsSettings(models.Model): family_appearance_seq = fields.Integer(string='Appearance Sequence') member_appearance_seq = fields.Integer(string='Appearance Sequence') income_appearance_seq = fields.Integer(string='Appearance Sequence') + is_mother_salary = fields.Boolean(string="Is Mother Salary", default=False) class EducationIlliterateReason(models.Model): _name = 'education.illiterate.reason' diff --git a/odex25_ensan/odex_benefit/views/benefit_config_view.xml b/odex25_ensan/odex_benefit/views/benefit_config_view.xml index e0dd5e659..2807b9a72 100644 --- a/odex25_ensan/odex_benefit/views/benefit_config_view.xml +++ b/odex25_ensan/odex_benefit/views/benefit_config_view.xml @@ -1046,6 +1046,7 @@ + diff --git a/odex25_ensan/odex_benefit/views/benefit_view.xml b/odex25_ensan/odex_benefit/views/benefit_view.xml index 5510d93b2..12a57d450 100644 --- a/odex25_ensan/odex_benefit/views/benefit_view.xml +++ b/odex25_ensan/odex_benefit/views/benefit_view.xml @@ -273,7 +273,8 @@ attrs="{'invisible': [('action_type', '!=', 'exception')]}"/>

- - + + -

@@ -1083,14 +1084,17 @@ - - + + + +