changed model to allow missing subsidy receiver

pull/112/head
mariusrklein 11 months ago committed by marius.klein
parent aaa43b9ae1
commit 6c2cc0b5c2

@ -0,0 +1,25 @@
# Generated by Django 4.0.1 on 2025-01-23 22:16
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('members', '0033_freizeit_approved_extra_youth_leader_count'),
('finance', '0007_alter_statement_allowance_to'),
]
operations = [
migrations.AlterField(
model_name='statement',
name='allowance_to',
field=models.ManyToManyField(blank=True, help_text='The youth leaders to which an allowance should be paid.', related_name='receives_allowance_for_statements', to='members.Member', verbose_name='Pay allowance to'),
),
migrations.AlterField(
model_name='statement',
name='subsidy_to',
field=models.ForeignKey(blank=True, help_text='The person that should receive the subsidy for night and travel costs. Typically the person who paid for them.', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='receives_subsidy_for_statements', to='members.member', verbose_name='Pay subsidy to'),
),
]

@ -62,9 +62,10 @@ class Statement(CommonModel):
allowance_to = models.ManyToManyField(Member, verbose_name=_('Pay allowance to'), allowance_to = models.ManyToManyField(Member, verbose_name=_('Pay allowance to'),
related_name='receives_allowance_for_statements', related_name='receives_allowance_for_statements',
blank=True, blank=True,
help_text=_('The youth leaders to which an allowance should be paid. The count must match the number of permitted youth leaders.')) help_text=_('The youth leaders to which an allowance should be paid.'))
subsidy_to = models.ForeignKey(Member, verbose_name=_('Pay subsidy to'), subsidy_to = models.ForeignKey(Member, verbose_name=_('Pay subsidy to'),
null=True, null=True,
blank=True,
on_delete=models.SET_NULL, on_delete=models.SET_NULL,
related_name='receives_subsidy_for_statements', related_name='receives_subsidy_for_statements',
help_text=_('The person that should receive the subsidy for night and travel costs. Typically the person who paid for them.')) help_text=_('The person that should receive the subsidy for night and travel costs. Typically the person who paid for them.'))
@ -341,7 +342,10 @@ class Statement(CommonModel):
The total amount of subsidies excluding the allowance, i.e. the transportation The total amount of subsidies excluding the allowance, i.e. the transportation
and night costs per youth leader multiplied with the real number of youth leaders. and night costs per youth leader multiplied with the real number of youth leaders.
""" """
return (self.transportation_per_yl + self.nights_per_yl) * self.real_staff_count if self.subsidy_to:
return (self.transportation_per_yl + self.nights_per_yl) * self.real_staff_count
else:
return cvt_to_decimal(0)
@property @property
def total_staff(self): def total_staff(self):

Loading…
Cancel
Save