Also makes some checks safe.
Reviewed-on: #155
Reviewed-by: Christian Merten <christian@merten.dev>
Co-authored-by: marius.klein <marius.klein@alpenverein-heidelberg.de>
Co-committed-by: marius.klein <marius.klein@alpenverein-heidelberg.de>
# org fee should be collected if participants are older than 26
self.assertEqual(self.st5.excursion.old_participant_count,3,'Calculation of number of old people in excursion is incorrect.')
total_org=4*3*20# 4 days, 3 old people, 20€ per day
self.assertEqual(self.st5.total_org_fee_theoretical,total_org,'Theoretical org_fee should equal to amount per day per person * n_persons * n_days if there are old people.')
self.assertEqual(self.st5.total_org_fee,0,'Paid org fee should be 0 if no allowance and subsidies are paid if there are old people.')
self.assertIsNone(self.st5.org_fee_payant)
# now collect subsidies
self.st5.subsidy_to=self.fritz
self.assertEqual(self.st5.total_org_fee,total_org,'Paid org fee should equal to amount per day per person * n_persons * n_days if subsidies are paid.')
# now collect allowances
self.st5.allowance_to.add(self.fritz)
self.st5.subsidy_to=None
self.assertEqual(self.st5.total_org_fee,total_org,'Paid org fee should equal to amount per day per person * n_persons * n_days if allowances are paid.')
# now collect both
self.st5.subsidy_to=self.fritz
self.assertEqual(self.st5.total_org_fee,total_org,'Paid org fee should equal to amount per day per person * n_persons * n_days if subsidies and allowances are paid.')
self.assertEqual(self.st5.org_fee_payant,self.fritz,'Org fee payant should be the receiver allowances and subsidies.')
self.assertEqual(self.st5.excursion.total_intervention_hours,expected_intervention_hours,'Calculation of total intervention hours is incorrect.')
self.assertEqual(self.st5.excursion.total_seminar_days,expected_seminar_days,'Calculation of total seminar days is incorrect.')
self.assertEqual(self.st5.paid_ljp_contributions,0,'No LJP contributions should be paid if no receiver is set.')
# now we want to pay out the LJP contributions
self.st5.ljp_to=self.fritz
self.assertEqual(self.st5.paid_ljp_contributions,expected_ljp,'LJP contributions should be paid if a receiver is set.')
# now the total costs paid by trip organisers is lower than expected ljp contributions, should be reduced automatically
self.b2.amount=100
self.b2.save()
self.assertEqual(self.st5.total_bills_not_covered,100,'Changes in bills should be reflected in the total costs paid by trip organisers')
self.assertGreaterEqual(self.st5.total_bills_not_covered,self.st5.paid_ljp_contributions,'LJP contributions should be less than or equal to the costs paid by trip organisers')