Don't error on invalid unit price, etc.
This commit is contained in:
parent
5c8c4750a5
commit
98a163f63a
@ -1,5 +1,5 @@
|
|||||||
# Society Self-Service
|
# Society Self-Service
|
||||||
# Copyright © 2018–2020 Yingtong Li (RunasSudo)
|
# Copyright © 2018–2022 Yingtong Li (RunasSudo)
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU Affero General Public License as published by
|
# it under the terms of the GNU Affero General Public License as published by
|
||||||
@ -100,15 +100,23 @@ class BudgetRevision(models.Model):
|
|||||||
def get_revenue_total(self):
|
def get_revenue_total(self):
|
||||||
total = Decimal(0)
|
total = Decimal(0)
|
||||||
for item in self.revenue:
|
for item in self.revenue:
|
||||||
|
try:
|
||||||
total += Decimal(item['Unit price']) * Decimal(item['Units'])
|
total += Decimal(item['Unit price']) * Decimal(item['Units'])
|
||||||
if item['IWT'] and item['Unit price'] > 0:
|
if item['IWT'] and item['Unit price'] > 0:
|
||||||
total -= (Decimal(item['Unit price']) - (Decimal(item['Unit price']) - Decimal('0.8133')) / Decimal('1.01884')) * item['Units']
|
total -= (Decimal(item['Unit price']) - (Decimal(item['Unit price']) - Decimal('0.8133')) / Decimal('1.01884')) * item['Units']
|
||||||
|
except TypeError:
|
||||||
|
# Invalid unit price, etc.
|
||||||
|
pass
|
||||||
return total
|
return total
|
||||||
|
|
||||||
def get_expense_total(self):
|
def get_expense_total(self):
|
||||||
total = Decimal(0)
|
total = Decimal(0)
|
||||||
for item in self.expense:
|
for item in self.expense:
|
||||||
|
try:
|
||||||
total += Decimal(item['Unit price']) * Decimal(item['Units'])
|
total += Decimal(item['Unit price']) * Decimal(item['Units'])
|
||||||
|
except TypeError:
|
||||||
|
# Invalid unit price, etc.
|
||||||
|
pass
|
||||||
if not self.expense_no_emergency_fund:
|
if not self.expense_no_emergency_fund:
|
||||||
total *= Decimal('1.05')
|
total *= Decimal('1.05')
|
||||||
return total
|
return total
|
||||||
@ -240,7 +248,11 @@ class ReimbursementClaim(models.Model):
|
|||||||
def get_total(self):
|
def get_total(self):
|
||||||
total = Decimal(0)
|
total = Decimal(0)
|
||||||
for item in self.items:
|
for item in self.items:
|
||||||
|
try:
|
||||||
total += Decimal(item['Unit price']) * Decimal(item['Units'])
|
total += Decimal(item['Unit price']) * Decimal(item['Units'])
|
||||||
|
except TypeError:
|
||||||
|
# Invalid unit price, etc.
|
||||||
|
pass
|
||||||
return total
|
return total
|
||||||
|
|
||||||
def update_state(self, user, state):
|
def update_state(self, user, state):
|
||||||
|
Loading…
Reference in New Issue
Block a user