Skip to content

Commit

Permalink
Merge pull request #3933 from GeotrekCE/feat_add_workforce_to_interve…
Browse files Browse the repository at this point in the history
…ntion_issue_3824

💫 [FEAT] add workforce cost into intervention model (#3824)
  • Loading branch information
juggler31 committed Feb 14, 2024
2 parents 87b7295 + 0827795 commit 854bc2b
Show file tree
Hide file tree
Showing 18 changed files with 106 additions and 33 deletions.
2 changes: 1 addition & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ CHANGELOG

- Add missing translations for fields on ``Courses`` and ``Sites`` in APIv2 (#3569)
- Allow Apidae Trek parser to handle traces not in utf-8

- Add workforce cost into intervention model (#3824)

2.101.5 (2024-01-11)
--------------------
Expand Down
9 changes: 6 additions & 3 deletions docs/install/advanced-configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,8 @@ A (nearly?) exhaustive list of attributes available for display and export as co
"min_elevation",
"max_elevation",
"heliport_cost",
"subcontract_cost",
"contractor_cost",
"workforce_cost",
"date_update",
"date_insert",
"description",
Expand Down Expand Up @@ -1728,7 +1729,8 @@ A (nearly?) exhaustive list of attributes available for display and export as co
"date_update",
"material_cost",
"heliport_cost",
"subcontract_cost",
"contractor_cost",
"workforce_cost",
"total_cost_mandays",
"total_cost",
"cities",
Expand Down Expand Up @@ -2166,7 +2168,8 @@ An exhaustive list of form fields hideable in each module.
"project",
"material_cost",
"heliport_cost",
"subcontract_cost",
"contractor_cost",
"workforce_cost",
],
HIDDEN_FORM_FIELDS["project"] = [
"type",
Expand Down
5 changes: 3 additions & 2 deletions geotrek/maintenance/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ class InterventionForm(CommonForm):
'description',
'material_cost',
'heliport_cost',
'subcontract_cost',
'contractor_cost',
'workforce_cost',
Fieldset(_("Mandays")),
css_class="scrollable tab-pane active"
),
Expand All @@ -104,7 +105,7 @@ class Meta(CommonForm.Meta):
model = Intervention
fields = CommonForm.Meta.fields + \
['structure', 'name', 'begin_date', 'end_date', 'status', 'disorders', 'type', 'description', 'subcontracting', 'length', 'width',
'height', 'stake', 'project', 'access', 'material_cost', 'heliport_cost', 'subcontract_cost', 'topology']
'height', 'stake', 'project', 'access', 'material_cost', 'heliport_cost', 'contractor_cost', 'workforce_cost', 'topology']

def __init__(self, *args, target_type=None, target_id=None, **kwargs):
super().__init__(*args, **kwargs)
Expand Down
7 changes: 5 additions & 2 deletions geotrek/maintenance/locale/de/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-12-11 15:38+0000\n"
"POT-Creation-Date: 2024-02-13 10:26+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand Down Expand Up @@ -158,7 +158,10 @@ msgstr ""
msgid "Heliport cost"
msgstr ""

msgid "Subcontract cost"
msgid "Contractor cost"
msgstr ""

msgid "Workforce cost"
msgstr ""

msgid "3D Length"
Expand Down
7 changes: 5 additions & 2 deletions geotrek/maintenance/locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-12-11 15:38+0000\n"
"POT-Creation-Date: 2024-02-13 10:26+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand Down Expand Up @@ -158,7 +158,10 @@ msgstr ""
msgid "Heliport cost"
msgstr ""

msgid "Subcontract cost"
msgid "Contractor cost"
msgstr ""

msgid "Workforce cost"
msgstr ""

msgid "3D Length"
Expand Down
7 changes: 5 additions & 2 deletions geotrek/maintenance/locale/es/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-12-11 15:38+0000\n"
"POT-Creation-Date: 2024-02-13 10:26+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand Down Expand Up @@ -158,7 +158,10 @@ msgstr ""
msgid "Heliport cost"
msgstr ""

msgid "Subcontract cost"
msgid "Contractor cost"
msgstr ""

msgid "Workforce cost"
msgstr ""

msgid "3D Length"
Expand Down
9 changes: 6 additions & 3 deletions geotrek/maintenance/locale/fr/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-12-11 15:38+0000\n"
"POT-Creation-Date: 2024-02-13 10:26+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand Down Expand Up @@ -160,8 +160,11 @@ msgstr "Coût matériel"
msgid "Heliport cost"
msgstr "Coût héliportage"

msgid "Subcontract cost"
msgstr "Coût sous-traitance"
msgid "Contractor cost"
msgstr "Coût prestataire"

msgid "Workforce cost"
msgstr "Coût main d'oeuvre"

msgid "3D Length"
msgstr "Longueur 3D"
Expand Down
7 changes: 5 additions & 2 deletions geotrek/maintenance/locale/it/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-12-11 15:38+0000\n"
"POT-Creation-Date: 2024-02-13 10:26+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand Down Expand Up @@ -158,7 +158,10 @@ msgstr ""
msgid "Heliport cost"
msgstr ""

msgid "Subcontract cost"
msgid "Contractor cost"
msgstr ""

msgid "Workforce cost"
msgstr ""

msgid "3D Length"
Expand Down
7 changes: 5 additions & 2 deletions geotrek/maintenance/locale/nl/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-12-11 15:38+0000\n"
"POT-Creation-Date: 2024-02-13 10:26+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand Down Expand Up @@ -158,7 +158,10 @@ msgstr ""
msgid "Heliport cost"
msgstr ""

msgid "Subcontract cost"
msgid "Contractor cost"
msgstr ""

msgid "Workforce cost"
msgstr ""

msgid "3D Length"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 3.2.23 on 2024-02-12 16:16

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('maintenance', '0025_remove_intervention_date'),
]

operations = [
migrations.RenameField(
model_name='intervention',
old_name='subcontract_cost',
new_name='contractor_cost',
),
migrations.AlterField(
model_name='intervention',
name='contractor_cost',
field=models.FloatField(blank=True, default=0.0, null=True, verbose_name='Contractor cost'),
),
]
18 changes: 18 additions & 0 deletions geotrek/maintenance/migrations/0027_intervention_workforce_cost.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.23 on 2024-02-12 16:28

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('maintenance', '0026_rename_subcontract_cost_intervention_contractor_cost'),
]

operations = [
migrations.AddField(
model_name='intervention',
name='workforce_cost',
field=models.FloatField(blank=True, default=0.0, null=True, verbose_name='Workforce cost'),
),
]
6 changes: 4 additions & 2 deletions geotrek/maintenance/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ class Intervention(ZoningPropertiesMixin, AddPropertyMixin, GeotrekMapEntityMixi
# Costs
material_cost = models.FloatField(default=0.0, blank=True, null=True, verbose_name=_("Material cost"))
heliport_cost = models.FloatField(default=0.0, blank=True, null=True, verbose_name=_("Heliport cost"))
subcontract_cost = models.FloatField(default=0.0, blank=True, null=True, verbose_name=_("Subcontract cost"))
contractor_cost = models.FloatField(default=0.0, blank=True, null=True, verbose_name=_("Contractor cost"))
workforce_cost = models.FloatField(default=0.0, blank=True, null=True, verbose_name=_("Workforce cost"))

# AltimetryMixin for denormalized fields from related topology, updated via trigger.
length = models.FloatField(editable=True, default=0.0, null=True, blank=True, verbose_name=_("3D Length"))
Expand Down Expand Up @@ -222,7 +223,8 @@ def total_cost(self):
return self.total_cost_mandays + \
(self.material_cost or 0) + \
(self.heliport_cost or 0) + \
(self.subcontract_cost or 0)
(self.contractor_cost or 0) + \
(self.workforce_cost or 0)

@classproperty
def total_cost_verbose_name(cls):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,12 @@
<td>{{ intervention.heliport_cost|floatformat:2 }} &euro;</td>
</tr>
<tr>
<th>{{ intervention|verbose:"subcontract_cost" }}</th>
<td>{{ intervention.subcontract_cost|floatformat:2 }} &euro;</td>
<th>{{ intervention|verbose:"contractor_cost" }}</th>
<td>{{ intervention.contractor_cost|floatformat:2 }} &euro;</td>
</tr>
<tr>
<th>{{ intervention|verbose:"workforce_cost" }}</th>
<td>{{ intervention.workforce_cost|floatformat:2 }} &euro;</td>
</tr>
<tr>
<th>{% trans "Mandays cost" %}</th>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ SELECT a.id,
i.disorder AS "Disorders",
a.material_cost AS "Material cost",
a.heliport_cost AS "Heliport cost",
a.subcontract_cost AS "Subcontract cost",
a.contractor_cost AS "Contractor cost",
a.workforce_cost AS "Workforce cost",
j.job AS "Job",
j.cost AS "Mandays",
j.nb_days AS "Cost",
(a.material_cost+a.heliport_cost+a.subcontract_cost)::float AS "Total cost",
(a.material_cost+a.heliport_cost+a.contractor_cost+a.workforce_cost)::float AS "Total cost",
h.name AS "Project",
CASE
WHEN k.app_label = 'core' THEN 'Tronçons'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ ALTER TABLE maintenance_intervention ALTER COLUMN height SET DEFAULT 0.0;
ALTER TABLE maintenance_intervention ALTER COLUMN area SET DEFAULT 0;
ALTER TABLE maintenance_intervention ALTER COLUMN material_cost SET DEFAULT 0.0;
ALTER TABLE maintenance_intervention ALTER COLUMN heliport_cost SET DEFAULT 0.0;
ALTER TABLE maintenance_intervention ALTER COLUMN subcontract_cost SET DEFAULT 0.0;
ALTER TABLE maintenance_intervention ALTER COLUMN contractor_cost SET DEFAULT 0.0;
ALTER TABLE maintenance_intervention ALTER COLUMN workforce_cost SET DEFAULT 0.0;
-- stake
-- status
--type
Expand Down
5 changes: 3 additions & 2 deletions geotrek/maintenance/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,11 @@ def test_total_cost(self):
interv = InfrastructureInterventionFactory.create(
material_cost=1,
heliport_cost=2,
subcontract_cost=4
contractor_cost=4,
workforce_cost=6
# implicit 1 manday x 500 €
)
self.assertEqual(interv.total_cost, 507)
self.assertEqual(interv.total_cost, 513)

def test_disorders_display(self):
interv = InterventionFactory.create()
Expand Down
9 changes: 5 additions & 4 deletions geotrek/maintenance/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ class InterventionViewsTest(CommonTest):
model = Intervention
modelfactory = InterventionFactory
userfactory = PathManagerFactory
extra_column_list = ['heliport_cost', 'subcontract_cost', 'disorders', 'jobs']
expected_column_list_extra = ['id', 'name', 'heliport_cost', 'subcontract_cost', 'disorders', 'jobs']
expected_column_formatlist_extra = ['id', 'heliport_cost', 'subcontract_cost', 'disorders', 'jobs']
extra_column_list = ['heliport_cost', 'contractor_cost', 'workforce_cost', 'disorders', 'jobs']
expected_column_list_extra = ['id', 'name', 'heliport_cost', 'contractor_cost', 'workforce_cost', 'disorders', 'jobs']
expected_column_formatlist_extra = ['id', 'heliport_cost', 'contractor_cost', 'workforce_cost', 'disorders', 'jobs']
expected_json_geom = {'coordinates': [[3.0, 46.5],
[3.001304, 46.5009004]],
'type': 'LineString'}
Expand Down Expand Up @@ -80,7 +80,8 @@ def get_good_data(self):
'comments': '',
'slope': 0,
'area': 0,
'subcontract_cost': 0.0,
'contractor_cost': 0.0,
'workforce_cost': 0.0,
'stake': StakeFactory.create().pk,
'height': 0.0,
'project': '',
Expand Down
2 changes: 1 addition & 1 deletion geotrek/maintenance/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def get_mandatory_columns(cls):
'disorders', 'total_manday', 'project', 'subcontracting',
'width', 'height', 'area', 'structure',
'description', 'date_insert', 'date_update',
'material_cost', 'heliport_cost', 'subcontract_cost',
'material_cost', 'heliport_cost', 'contractor_cost', 'workforce_cost',
'total_cost_mandays', 'total_cost',
'cities', 'districts', 'areas',
] + AltimetryMixin.COLUMNS
Expand Down

0 comments on commit 854bc2b

Please sign in to comment.