finance: move some constants to settings, fix bug in overview

v1-0-stable
Christian Merten 3 years ago
parent fc9ae75d82
commit 6076a9c820
Signed by: christian.merten
GPG Key ID: D953D69721B948B3

@ -6,6 +6,7 @@ from django.urls import path, reverse
from functools import update_wrapper
from django.utils.translation import gettext_lazy as _
from django.shortcuts import render
from django.conf import settings
from .models import Ledger, Statement, Receipt, Transaction, Bill, StatementSubmitted, StatementConfirmed,\
StatementUnSubmitted
@ -205,21 +206,23 @@ class StatementSubmittedAdmin(admin.ModelAdmin):
opts=self.opts,
statement=statement,
transaction_issues=statement.transaction_issues,
nights=statement.excursion.night_count,
price_per_night=statement.real_night_cost,
duration=statement.excursion.duration,
staff_count=statement.real_staff_count,
kilometers_traveled=statement.excursion.kilometers_traveled,
means_of_transport=statement.excursion.get_tour_approach(),
euro_per_km=statement.euro_per_km,
allowance_per_day=statement.ALLOWANCE_PER_DAY,
total_bills=statement.total_bills,
nights_per_yl=statement.nights_per_yl,
allowance_per_yl=statement.allowance_per_yl,
transportation_per_yl=statement.transportation_per_yl,
total_per_yl=statement.total_per_yl,
total_staff=statement.total_staff,
total=statement.total)
if statement.excursion is not None:
context = dict(context,
nights=statement.excursion.night_count,
price_per_night=statement.real_night_cost,
duration=statement.excursion.duration,
staff_count=statement.real_staff_count,
kilometers_traveled=statement.excursion.kilometers_traveled,
means_of_transport=statement.excursion.get_tour_approach(),
euro_per_km=statement.euro_per_km,
allowance_per_day=settings.ALLOWANCE_PER_DAY,
nights_per_yl=statement.nights_per_yl,
allowance_per_yl=statement.allowance_per_yl,
transportation_per_yl=statement.transportation_per_yl,
total_per_yl=statement.total_per_yl,
total_staff=statement.total_staff)
return render(request, 'admin/overview_submitted_statement.html', context=context)

@ -6,6 +6,7 @@ from django.utils import timezone
from django.db import models
from django.utils.translation import gettext_lazy as _
from members.models import Member, Freizeit, OEFFENTLICHE_ANREISE, MUSKELKRAFT_ANREISE
from django.conf import settings
# Create your models here.
@ -37,8 +38,6 @@ class StatementManager(models.Manager):
class Statement(models.Model):
MISSING_LEDGER, NON_MATCHING_TRANSACTIONS, VALID = 0, 1, 2
ALLOWANCE_PER_DAY = 10
short_description = models.CharField(verbose_name=_('Short description'),
max_length=30,
blank=True)
@ -151,7 +150,7 @@ class Statement(models.Model):
for bill in self.bill_set.all():
if not bill.costs_covered:
continue
ref = "{}: {}".format(self.excursion.name, bill.short_description)
ref = "{}: {}".format(str(self), bill.short_description)
Transaction(statement=self, member=bill.paid_by, amount=bill.amount, confirmed=False, reference=ref).save()
# excursion specific
@ -216,7 +215,7 @@ class Statement(models.Model):
if self.excursion is None:
return 0
return cvt_to_decimal(self.excursion.duration * self.ALLOWANCE_PER_DAY)
return cvt_to_decimal(self.excursion.duration * settings.ALLOWANCE_PER_DAY)
@property
def total_allowance(self):
@ -228,7 +227,7 @@ class Statement(models.Model):
@property
def real_night_cost(self):
return min(self.night_cost, 11)
return min(self.night_cost, settings.MAX_NIGHT_COST)
@property
def nights_per_yl(self):

@ -400,3 +400,8 @@ DEFAULT_SENDING_MAIL = os.environ.get('EMAIL_SENDING_ADDRESS', 'christian@localh
# misc
CONGRATULATE_MEMBERS_MAX = 10
# finance
ALLOWANCE_PER_DAY = 10
MAX_NIGHT_COST = 11

Loading…
Cancel
Save