Skip to content
This repository was archived by the owner on Oct 24, 2024. It is now read-only.

Commit 0479000

Browse files
author
Søren Howe Gersager
committed
Merge branch 'hotfix/3.6.2' into 'master'
hotfix/3.6.2 - master See merge request bevillingsplatform/bevillingsplatform!1167
2 parents 577ce26 + bf9b182 commit 0479000

File tree

6 files changed

+115
-7
lines changed

6 files changed

+115
-7
lines changed

NEWS.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
Version 3.6.2, 2021-11-30
2+
-------------------------
3+
4+
Hotfix release
5+
6+
Bug fixes
7+
^^^^^^^^^
8+
9+
* Correct end modified activities with no end date.
10+
* Correct setting main activities for an appropriation.
11+
12+
113
Version 3.6.1, 2021-11-25
214
-------------------------
315

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.6.1
1+
3.6.2

backend/core/models.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1904,12 +1904,14 @@ def grant(self, approval_level, approval_note, approval_user):
19041904
self.save()
19051905
old_activity.delete()
19061906
# "Merge" by ending current activity the day before the new
1907-
# start_date if end_date overlaps with the new start_date.
1908-
#
1909-
if (
1910-
self.modifies
1911-
and self.modifies.end_date
1912-
and self.modifies.end_date >= self.start_date
1907+
# start_date if end_date overlaps with the new start_date
1908+
# or it has no end_date.
1909+
if self.modifies and (
1910+
not self.modifies.end_date
1911+
or (
1912+
self.modifies.end_date
1913+
and self.modifies.end_date >= self.start_date
1914+
)
19131915
):
19141916
self.modifies.end_date = self.start_date - timedelta(
19151917
days=1

backend/core/tests/test_models.py

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,88 @@ def test_appropriation_grant_on_already_granted_daily(self):
676676
[start_date + timedelta(days=x) for x in range(25)],
677677
)
678678

679+
def test_appropriation_grant_on_already_granted_daily_no_end_date(self):
680+
approval_level = ApprovalLevel.objects.create(name="egenkompetence")
681+
682+
case = create_case(self.case_worker, self.municipality, self.district)
683+
section = create_section()
684+
appropriation = create_appropriation(case=case, section=section)
685+
now = timezone.now().date()
686+
start_date = now - timedelta(days=6)
687+
# create an already granted activity with no end_date.
688+
activity = create_activity(
689+
case=case,
690+
appropriation=appropriation,
691+
activity_type=MAIN_ACTIVITY,
692+
status=STATUS_GRANTED,
693+
start_date=start_date,
694+
end_date=None,
695+
)
696+
create_payment_schedule(
697+
payment_amount=Decimal("500.0"),
698+
payment_frequency=PaymentSchedule.DAILY,
699+
activity=activity,
700+
)
701+
activity.details.main_activity_for.add(section)
702+
703+
modified_start_date = now + timedelta(days=3)
704+
modified_end_date = now + timedelta(days=6)
705+
# let the granted activity be modified by another expected activity.
706+
modifies_activity = create_activity(
707+
case=case,
708+
appropriation=appropriation,
709+
activity_type=MAIN_ACTIVITY,
710+
start_date=modified_start_date,
711+
status=STATUS_EXPECTED,
712+
end_date=modified_end_date,
713+
modifies=activity,
714+
)
715+
create_payment_schedule(
716+
payment_amount=Decimal("600.0"),
717+
payment_frequency=PaymentSchedule.DAILY,
718+
activity=modifies_activity,
719+
)
720+
user = get_user_model().objects.create(username="Anders And")
721+
appropriation.grant(
722+
Activity.objects.filter(pk=modifies_activity.pk),
723+
approval_level.id,
724+
"note til bevillingsgodkendelse",
725+
user,
726+
)
727+
activity.refresh_from_db()
728+
modifies_activity.refresh_from_db()
729+
# the old activity with no end_date should expire the day before
730+
# the start_date of the new one.
731+
self.assertEqual(
732+
activity.end_date, modified_start_date - timedelta(days=1)
733+
)
734+
# expected status should be granted with the
735+
# start_date of the new activity.
736+
self.assertEqual(modifies_activity.status, STATUS_GRANTED)
737+
self.assertEqual(modifies_activity.start_date, modified_start_date)
738+
# the payments of the old activity should expire
739+
# before the new end_date.
740+
activity_payments = activity.payment_plan.payments
741+
self.assertTrue(
742+
activity_payments.order_by("date").first().date
743+
< modified_start_date
744+
)
745+
# the payments of the new activity should start after today.
746+
modifies_payments = modifies_activity.payment_plan.payments
747+
748+
self.assertTrue(
749+
modifies_payments.order_by("date").first().date
750+
>= modified_start_date
751+
)
752+
# assert payments are generated correctly.
753+
self.assertCountEqual(
754+
[
755+
x.date
756+
for x in (activity_payments.all() | modifies_payments.all())
757+
],
758+
[start_date + timedelta(days=x) for x in range(13)],
759+
)
760+
679761
def test_appropriation_grant_on_already_granted_weekly(self):
680762
approval_level = ApprovalLevel.objects.create(name="egenkompetence")
681763

frontend/src/components/activities/edittypes/Activity.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ export default {
102102
actList = `main_activity_for=${ this.appropriation.section }`
103103
} else {
104104
actList = `supplementary_activity_for=${ this.appropriation.section }`
105+
// this.appr_main_acts, which maps to a store property, will not have been populated if user enters the path /activity/create directly in their browser. It will only populate when the user creates a new activity from within an appropriation.
105106
if (this.appr_main_acts) {
106107
actList += `&main_activities=${ this.appr_main_acts.activities[0].details }`
107108
}

frontend/src/components/appropriations/Appropriation.vue

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,12 @@
226226
edges {
227227
node {
228228
pk,
229+
activityType,
230+
startDate,
231+
endDate,
232+
details {
233+
pk
234+
},
229235
modifies {
230236
pk
231237
}
@@ -250,6 +256,10 @@
250256
activities: [...a.activities.edges.map(e => {
251257
return {
252258
id: Number(e.node.pk),
259+
activity_type: e.node.activityType,
260+
start_date: e.node.startDate,
261+
end_date: e.node.endDate,
262+
details: Number(e.node.details.pk),
253263
modifies: e.node.modifies ? e.node.modifies.pk : null
254264
}
255265
})],
@@ -265,6 +275,7 @@
265275
paying_municipality: a.case.payingMunicipality.name,
266276
acting_municipality: a.case.actingMunicipality.name
267277
}
278+
this.$store.dispatch("fetchMainActivities", new_appr.activities)
268279
this.$store.commit('setAppropriation', new_appr)
269280
this.$store.commit('setCase', new_case)
270281
this.updateBreadCrumb(new_appr, new_case)

0 commit comments

Comments
 (0)