From ff429d51f36d1ae404bc51552c69b12198e24cda Mon Sep 17 00:00:00 2001 From: heinzel Date: Thu, 18 Jan 2018 23:46:47 +0100 Subject: [PATCH] moved charge fees from forms to config. --- dav_events/config.py | 91 +++++++++++++- dav_events/forms.py | 116 +++++------------- .../dav_events/event_create/ChargesForm.html | 8 +- 3 files changed, 127 insertions(+), 88 deletions(-) diff --git a/dav_events/config.py b/dav_events/config.py index 37a6b54..41d6d3f 100644 --- a/dav_events/config.py +++ b/dav_events/config.py @@ -1,3 +1,5 @@ +from django.utils.translation import ugettext_lazy as _ + COMMON_CHAR_FIELD_LENGTH = 250 TITLE_MAX_LENGTH = COMMON_CHAR_FIELD_LENGTH @@ -11,4 +13,91 @@ MEETING_POINT_OTHER_MAX_LENGTH = COMMON_CHAR_FIELD_LENGTH BASECAMP_MAX_LENGTH = COMMON_CHAR_FIELD_LENGTH ACCOMMODATION_OTHER_MAX_LENGTH = COMMON_CHAR_FIELD_LENGTH MEALS_OTHER_MAX_LENGTH = COMMON_CHAR_FIELD_LENGTH -ADDITIONAL_COSTS_MAX_LENGTH = COMMON_CHAR_FIELD_LENGTH \ No newline at end of file +ADDITIONAL_COSTS_MAX_LENGTH = COMMON_CHAR_FIELD_LENGTH + +FEE_MATRIX = { + '0': {'description': _(u'Keiner'), + 'trainer_fee': 0, + 'pre_meeting_fee': 0, + 'trainer_day_fee': 0, + 'participant_fee': 0, + 'participant_day_fee': 0, + }, + 'A': {'description': '', + 'trainer_fee': 20, + 'pre_meeting_fee': 20, + 'trainer_day_fee': 50, + 'participant_fee': 10, + 'participant_day_fee': 10, + }, + 'B': {'description': '', + 'trainer_fee': 40, + 'pre_meeting_fee': 20, + 'trainer_day_fee': 75, + 'participant_fee': 10, + 'participant_day_fee': 20, + }, + 'C': {'description': '', + 'trainer_fee': 10, + 'pre_meeting_fee': 20, + 'trainer_day_fee': 60, + 'participant_fee': 10, + 'participant_day_fee': 30, + }, + 'D': {'description': '', + 'trainer_fee': 30, + 'pre_meeting_fee': 20, + 'trainer_day_fee': 75, + 'participant_fee': 20, + 'participant_day_fee': 40, + }, + 'E': {'description': '', + 'trainer_fee': 60, + 'pre_meeting_fee': 20, + 'trainer_day_fee': 75, + 'participant_fee': 40, + 'participant_day_fee': 40, + }, + 'F': {'description': '', + 'trainer_fee': 60, + 'pre_meeting_fee': 20, + 'trainer_day_fee': 85, + 'participant_fee': 40, + 'participant_day_fee': 45, + }, + 'G': {'description': '', + 'trainer_fee': 60, + 'pre_meeting_fee': 20, + 'trainer_day_fee': 75, + 'participant_fee': 35, + 'participant_day_fee': 30, + }, + 'H': {'description': '', + 'trainer_fee': 60, + 'pre_meeting_fee': 20, + 'trainer_day_fee': 85, + 'participant_fee': 35, + 'participant_day_fee': 30, + }, + 'I': {'description': '', + 'trainer_fee': 60, + 'pre_meeting_fee': 20, + 'trainer_day_fee': 75, + 'participant_fee': 25, + 'participant_day_fee': 25, + }, + 'J': {'description': '', + 'trainer_fee': 60, + 'pre_meeting_fee': 20, + 'trainer_day_fee': 85, + 'participant_fee': 25, + 'participant_day_fee': 25, + }, + 'K': {'description': '', + 'trainer_fee': 60, + 'pre_meeting_fee': 20, + 'trainer_day_fee': 130, + 'participant_fee': 40, + 'participant_day_fee': 40, + }, +} \ No newline at end of file diff --git a/dav_events/forms.py b/dav_events/forms.py index 18b2637..a598d1d 100644 --- a/dav_events/forms.py +++ b/dav_events/forms.py @@ -760,27 +760,28 @@ class ChargesForm(EventCreateForm): charge_key = forms.CharField(disabled=True, label=_(u'Abrechnungsschlüssel'), ) - orga_fee = forms.FloatField(disabled=True, - label=_(u'Pauschale Trainer*in'), - ) + trainer_fee = forms.FloatField(disabled=True, + label=_(u'Pauschale Trainer*in'), + ) pre_meeting_fee = forms.FloatField(disabled=True, label=_(u'Pauschale Vortreffen'), ) - orga_day_fee = forms.FloatField(disabled=True, - label=_(u'Tagespauschale Trainer*in'), - ) - participation_fee = forms.FloatField(disabled=True, - label=_(u'Pauschale Teilnehmer*in'), - ) - participation_day_fee = forms.FloatField(disabled=True, - label=_(u'Tagepauschale Teilnehmer*in'), - ) + trainer_day_fee = forms.FloatField(disabled=True, + label=_(u'Tagespauschale Trainer*in'), + ) + participant_fee = forms.FloatField(disabled=True, + label=_(u'Pauschale Teilnehmer*in'), + ) + participant_day_fee = forms.FloatField(disabled=True, + label=_(u'Tagepauschale Teilnehmer*in'), + ) trainer_reward = forms.FloatField(disabled=True, label=_(u'Aufwandsentschädigung Trainer*in'), ) charge = forms.FloatField(label=_(u'Teilnahmegebühr')) + additional_costs = forms.CharField(required=False, max_length=config.ADDITIONAL_COSTS_MAX_LENGTH, label=_(u'Zusätzliche Kosten (Text)'), @@ -803,88 +804,28 @@ class ChargesForm(EventCreateForm): if ski_lift: charge_key = 'K' - orga_fee = 60 - pre_meeting_fee = 20 - orga_day_fee = 130 - participation_fee = 40 - participation_day_fee = 40 elif sport == 'W' and not last_day: - charge_key = _(u'Keiner') - orga_fee = 0 - pre_meeting_fee = 0 - orga_day_fee = 0 - participation_fee = 0 - participation_day_fee = 0 + charge_key = '0' elif sport == 'W' and terrain != 'alpine': charge_key = u'A' - orga_fee = 20 - pre_meeting_fee = 20 - orga_day_fee = 50 - participation_fee = 10 - participation_day_fee = 10 elif sport == 'W': charge_key = u'B' - orga_fee = 40 - pre_meeting_fee = 20 - orga_day_fee = 75 - participation_fee = 10 - participation_day_fee = 20 elif terrain != 'alpine' and not last_day: charge_key = u'C' - orga_fee = 10 - pre_meeting_fee = 20 - orga_day_fee = 60 - participation_fee = 10 - participation_day_fee = 30 elif terrain != 'alpine': charge_key = u'D' - orga_fee = 30 - pre_meeting_fee = 20 - orga_day_fee = 75 - participation_fee = 20 - participation_day_fee = 40 elif mode == 'training' and country in ('DE', 'AU'): charge_key = u'G' - orga_fee = 60 - pre_meeting_fee = 20 - orga_day_fee = 75 - participation_fee = 35 - participation_day_fee = 30 elif mode == 'training': charge_key = u'H' - orga_fee = 60 - pre_meeting_fee = 20 - orga_day_fee = 85 - participation_fee = 35 - participation_day_fee = 30 elif sport == 'K' and country in ('DE', 'AU'): charge_key = u'E' - orga_fee = 60 - pre_meeting_fee = 20 - orga_day_fee = 75 - participation_fee = 40 - participation_day_fee = 40 elif sport == 'K': charge_key = u'F' - orga_fee = 60 - pre_meeting_fee = 20 - orga_day_fee = 85 - participation_fee = 40 - participation_day_fee = 45 elif country in ('DE', 'AU'): charge_key = u'I' - orga_fee = 60 - pre_meeting_fee = 20 - orga_day_fee = 75 - participation_fee = 25 - participation_day_fee = 25 else: charge_key = u'J' - orga_fee = 60 - pre_meeting_fee = 20 - orga_day_fee = 85 - participation_fee = 25 - participation_day_fee = 25 additional_costs_text = ugettext(u'Fahrtkosten') @@ -901,21 +842,30 @@ class ChargesForm(EventCreateForm): else: n_pre_meetings = 0 - trainer_reward = orga_fee + ndays * orga_day_fee + n_pre_meetings * pre_meeting_fee - charge = participation_fee + ndays * participation_day_fee + fees = config.FEE_MATRIX[charge_key] + + trainer_reward = ( + fees['trainer_fee'] + + ndays * fees['trainer_day_fee'] + + n_pre_meetings * fees['pre_meeting_fee'] + ) + charge = ( + fees['participant_fee'] + + ndays * fees['participant_day_fee'] + ) if arrival_previous_day: - trainer_reward += orga_day_fee / 2 - charge += participation_day_fee / 2 + trainer_reward += fees['trainer_day_fee'] / 2.0 + charge += fees['participant_day_fee'] / 2.0 if charge > 0: additional_costs_text = u'%s %s' % (ugettext(u'zzgl.'), additional_costs_text) - self.fields['charge_key'].initial = charge_key - self.fields['orga_fee'].initial = orga_fee - self.fields['pre_meeting_fee'].initial = pre_meeting_fee - self.fields['orga_day_fee'].initial = orga_day_fee - self.fields['participation_fee'].initial = participation_fee - self.fields['participation_day_fee'].initial = participation_day_fee + self.fields['charge_key'].initial = fees['description'] or charge_key + self.fields['trainer_fee'].initial = fees['trainer_fee'] + self.fields['pre_meeting_fee'].initial = fees['pre_meeting_fee'] + self.fields['trainer_day_fee'].initial = fees['trainer_day_fee'] + self.fields['participant_fee'].initial = fees['participant_day_fee'] + self.fields['participant_day_fee'].initial = fees['participant_day_fee'] self.fields['trainer_reward'].initial = trainer_reward self.fields['charge'].initial = charge diff --git a/dav_events/templates/dav_events/event_create/ChargesForm.html b/dav_events/templates/dav_events/event_create/ChargesForm.html index 7624172..cc55a3f 100644 --- a/dav_events/templates/dav_events/event_create/ChargesForm.html +++ b/dav_events/templates/dav_events/event_create/ChargesForm.html @@ -11,10 +11,10 @@ {% bootstrap_field form.charge_key %}
- {% bootstrap_field form.orga_fee %} + {% bootstrap_field form.trainer_fee %}
- {% bootstrap_field form.orga_day_fee %} + {% bootstrap_field form.trainer_day_fee %}
@@ -22,10 +22,10 @@ {% bootstrap_field form.pre_meeting_fee %}
- {% bootstrap_field form.participation_fee %} + {% bootstrap_field form.participant_fee %}
- {% bootstrap_field form.participation_day_fee %} + {% bootstrap_field form.participant_day_fee %}