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 functools import update_wrapper
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from django.shortcuts import render from django.shortcuts import render
from django.conf import settings
from .models import Ledger, Statement, Receipt, Transaction, Bill, StatementSubmitted, StatementConfirmed,\ from .models import Ledger, Statement, Receipt, Transaction, Bill, StatementSubmitted, StatementConfirmed,\
StatementUnSubmitted StatementUnSubmitted
@ -205,6 +206,10 @@ class StatementSubmittedAdmin(admin.ModelAdmin):
opts=self.opts, opts=self.opts,
statement=statement, statement=statement,
transaction_issues=statement.transaction_issues, transaction_issues=statement.transaction_issues,
total_bills=statement.total_bills,
total=statement.total)
if statement.excursion is not None:
context = dict(context,
nights=statement.excursion.night_count, nights=statement.excursion.night_count,
price_per_night=statement.real_night_cost, price_per_night=statement.real_night_cost,
duration=statement.excursion.duration, duration=statement.excursion.duration,
@ -212,14 +217,12 @@ class StatementSubmittedAdmin(admin.ModelAdmin):
kilometers_traveled=statement.excursion.kilometers_traveled, kilometers_traveled=statement.excursion.kilometers_traveled,
means_of_transport=statement.excursion.get_tour_approach(), means_of_transport=statement.excursion.get_tour_approach(),
euro_per_km=statement.euro_per_km, euro_per_km=statement.euro_per_km,
allowance_per_day=statement.ALLOWANCE_PER_DAY, allowance_per_day=settings.ALLOWANCE_PER_DAY,
total_bills=statement.total_bills,
nights_per_yl=statement.nights_per_yl, nights_per_yl=statement.nights_per_yl,
allowance_per_yl=statement.allowance_per_yl, allowance_per_yl=statement.allowance_per_yl,
transportation_per_yl=statement.transportation_per_yl, transportation_per_yl=statement.transportation_per_yl,
total_per_yl=statement.total_per_yl, total_per_yl=statement.total_per_yl,
total_staff=statement.total_staff, total_staff=statement.total_staff)
total=statement.total)
return render(request, 'admin/overview_submitted_statement.html', context=context) 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.db import models
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from members.models import Member, Freizeit, OEFFENTLICHE_ANREISE, MUSKELKRAFT_ANREISE from members.models import Member, Freizeit, OEFFENTLICHE_ANREISE, MUSKELKRAFT_ANREISE
from django.conf import settings
# Create your models here. # Create your models here.
@ -37,8 +38,6 @@ class StatementManager(models.Manager):
class Statement(models.Model): class Statement(models.Model):
MISSING_LEDGER, NON_MATCHING_TRANSACTIONS, VALID = 0, 1, 2 MISSING_LEDGER, NON_MATCHING_TRANSACTIONS, VALID = 0, 1, 2
ALLOWANCE_PER_DAY = 10
short_description = models.CharField(verbose_name=_('Short description'), short_description = models.CharField(verbose_name=_('Short description'),
max_length=30, max_length=30,
blank=True) blank=True)
@ -151,7 +150,7 @@ class Statement(models.Model):
for bill in self.bill_set.all(): for bill in self.bill_set.all():
if not bill.costs_covered: if not bill.costs_covered:
continue 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() Transaction(statement=self, member=bill.paid_by, amount=bill.amount, confirmed=False, reference=ref).save()
# excursion specific # excursion specific
@ -216,7 +215,7 @@ class Statement(models.Model):
if self.excursion is None: if self.excursion is None:
return 0 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 @property
def total_allowance(self): def total_allowance(self):
@ -228,7 +227,7 @@ class Statement(models.Model):
@property @property
def real_night_cost(self): def real_night_cost(self):
return min(self.night_cost, 11) return min(self.night_cost, settings.MAX_NIGHT_COST)
@property @property
def nights_per_yl(self): def nights_per_yl(self):

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

Loading…
Cancel
Save