Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PMP] To change the logic of the system to NOT calculate the planned PVs for canceled PDs #3734

Merged
merged 1 commit into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/etools/applications/partners/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,14 @@ def update_planned_visits_to_hact(self):
year = datetime.date.today().year
if self.partner_type != 'Government':
pv = InterventionPlannedVisits.objects.filter(
intervention__agreement__partner=self, year=year).exclude(intervention__status=Intervention.DRAFT)
intervention__agreement__partner=self,
year=year,
).exclude(
intervention__status__in=[
Intervention.DRAFT,
Intervention.CANCELLED,
],
)
pvq1 = pv.aggregate(models.Sum('programmatic_q1'))['programmatic_q1__sum'] or 0
pvq2 = pv.aggregate(models.Sum('programmatic_q2'))['programmatic_q2__sum'] or 0
pvq3 = pv.aggregate(models.Sum('programmatic_q3'))['programmatic_q3__sum'] or 0
Expand Down
20 changes: 20 additions & 0 deletions src/etools/applications/partners/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,14 @@ def test_planned_visits_non_gov(self):
agreement=self.pca_signed1,
status=models.Intervention.ACTIVE
)
cancelled_intervention = InterventionFactory(
agreement=self.pca_signed1,
status=models.Intervention.CANCELLED
)
draft_intervention = InterventionFactory(
agreement=self.pca_signed1,
status=models.Intervention.DRAFT
)
InterventionPlannedVisitsFactory(
intervention=intervention,
year=year - 1,
Expand All @@ -410,6 +418,18 @@ def test_planned_visits_non_gov(self):
programmatic_q1=1,
programmatic_q3=3,
)
InterventionPlannedVisitsFactory(
intervention=draft_intervention,
year=year,
programmatic_q1=1,
programmatic_q3=3,
)
InterventionPlannedVisitsFactory(
intervention=cancelled_intervention,
year=year,
programmatic_q1=1,
programmatic_q3=3,
)
self.partner_organization.update_planned_visits_to_hact()
self.assertEqual(
self.partner_organization.hact_values['programmatic_visits']['planned']['total'],
Expand Down