diff --git a/configuration.py b/configuration.py
index a19b5d1..6aa6395 100644
--- a/configuration.py
+++ b/configuration.py
@@ -161,3 +161,5 @@ class ConfigurationSkill(ModelSingleton, ModelSQL, ModelView):
skill_08 = fields.Numeric('Skill 8 %', digits=(16, 2))
skill_09 = fields.Numeric('Skill 9 %', digits=(16, 2))
skill_10 = fields.Numeric('Skill 10 %', digits=(16, 2))
+ skill_11 = fields.Numeric('Skill 11 %', digits=(16, 2))
+ skill_12 = fields.Numeric('Skill 12 %', digits=(16, 2))
diff --git a/message.xml b/message.xml
index f586735..bf73996 100644
--- a/message.xml
+++ b/message.xml
@@ -19,5 +19,8 @@
Lot "%s" must be cancelled before deletion.
+
+ The start activity date is not defined.
+
diff --git a/partner.py b/partner.py
index 0173611..f9f68b8 100644
--- a/partner.py
+++ b/partner.py
@@ -1,6 +1,8 @@
# This file is part of the cooperative_ar module for Tryton.
# The COPYRIGHT file at the top level of this repository contains
# the full copyright notices and license terms.
+from datetime import datetime
+from dateutil import relativedelta
from decimal import Decimal
from trytond.model import ModelView, ModelSQL, fields
@@ -75,6 +77,11 @@ class Partner(ModelSQL, ModelView):
skill_08 = fields.Boolean('Skill 8')
skill_09 = fields.Boolean('Skill 9')
skill_10 = fields.Boolean('Skill 10')
+ skill_11 = fields.Boolean('Skill 11')
+ skill_12 = fields.Boolean('Skill 12')
+ recibo_without_seniority = fields.Function(fields.Numeric(
+ 'Amount without seniority', digits=(16, 2)),
+ 'on_change_with_recibo_without_seniority')
recibo_total = fields.Function(fields.Numeric(
'Total Amount', digits=(16, 2)), 'on_change_with_recibo_total')
@@ -149,10 +156,23 @@ def create(cls, vlist):
raise UserError(gettext('cooperative_ar.msg_unique_file'))
return super().create(vlist)
+ @classmethod
+ def get_start_activity_date(cls):
+ 'get_start_activity_date'
+ pool = Pool()
+ Company = pool.get('company.company')
+ company_id = Transaction().context.get('company')
+ if company_id:
+ company = Company(company_id)
+ if company.party.start_activity_date:
+ return company.party.start_activity_date
+
+ raise UserError(gettext('cooperative_ar.msg_start_activity_date_not_defined'))
+
@fields.depends('recibo_base', 'skill_01', 'skill_02', 'skill_03',
'skill_04', 'skill_05', 'skill_06', 'skill_07', 'skill_08',
- 'skill_09', 'skill_10')
- def on_change_with_recibo_total(self, name=None):
+ 'skill_09', 'skill_10', 'skill_11', 'skill_12', 'incorporation_date')
+ def on_change_with_recibo_without_seniority(self, name=None):
pool = Pool()
ConfigurationSkill = pool.get('cooperative_ar.configuration.skill')
@@ -160,6 +180,14 @@ def on_change_with_recibo_total(self, name=None):
if not recibo_base:
return Decimal(0)
+ incorporation_date = self.incorporation_date
+ start_activity_date = self.get_start_activity_date()
+ # convert string to date object
+ start_date = datetime.strptime(start_activity_date, "%d/%m/%Y")
+ end_date = datetime.strptime(incorporation_date, "%d/%m/%Y")
+ # Get the relativedelta between two dates
+ delta = relativedelta.relativedelta(end_date, start_date)
+
configuration = ConfigurationSkill(1)
amount = recibo_base
quantize = Decimal(10) ** -Decimal(2)
@@ -194,5 +222,39 @@ def on_change_with_recibo_total(self, name=None):
if self.skill_10 and configuration.skill_10:
amount += (recibo_base * configuration.skill_10 /
Decimal(100)).quantize(quantize)
+ # 3/4
+ if self.skill_11 and configuration.skill_11:
+ amount -= (recibo_base * configuration.skill_11 /
+ Decimal(100)).quantize(quantize)
+
+ return amount
+
+ @fields.depends('recibo_base', 'skill_01', 'skill_02', 'skill_03',
+ 'skill_04', 'skill_05', 'skill_06', 'skill_07', 'skill_08',
+ 'skill_09', 'skill_10', 'skill_11', 'skill_12', 'incorporation_date')
+ def on_change_with_recibo_total(self, name=None):
+ pool = Pool()
+ ConfigurationSkill = pool.get('cooperative_ar.configuration.skill')
+
+ recibo_base = self.recibo_base
+ if not recibo_base:
+ return Decimal(0)
+
+ incorporation_date = self.incorporation_date
+ start_activity_date = self.get_start_activity_date()
+ # convert string to date object
+ start_date = datetime.strptime(start_activity_date, "%d/%m/%Y")
+ end_date = datetime.strptime(incorporation_date, "%d/%m/%Y")
+ # Get the relativedelta between two dates
+ delta = relativedelta.relativedelta(end_date, start_date)
+
+ configuration = ConfigurationSkill(1)
+ amount = self.on_change_with_recibo_without_seniority(name)
+ quantize = Decimal(10) ** -Decimal(2)
+
+ # antiguedad
+ if self.skill_11 and configuration.skill_11:
+ amount += (recibo_base * configuration.skill_11 * delta.years /
+ Decimal(100)).quantize(quantize)
return amount
diff --git a/view/configuration_skill_form.xml b/view/configuration_skill_form.xml
index 8bd6cf2..4d19816 100644
--- a/view/configuration_skill_form.xml
+++ b/view/configuration_skill_form.xml
@@ -20,4 +20,8 @@
+
+
+
+
diff --git a/view/partner_skill_tree.xml b/view/partner_skill_tree.xml
index ad65082..870f813 100644
--- a/view/partner_skill_tree.xml
+++ b/view/partner_skill_tree.xml
@@ -12,5 +12,8 @@
+
+
+