Don't error on invalid unit price, etc.
This commit is contained in:
parent
5c8c4750a5
commit
98a163f63a
@ -1,5 +1,5 @@
|
||||
# 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
|
||||
# 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):
|
||||
total = Decimal(0)
|
||||
for item in self.revenue:
|
||||
total += Decimal(item['Unit price']) * Decimal(item['Units'])
|
||||
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']
|
||||
try:
|
||||
total += Decimal(item['Unit price']) * Decimal(item['Units'])
|
||||
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']
|
||||
except TypeError:
|
||||
# Invalid unit price, etc.
|
||||
pass
|
||||
return total
|
||||
|
||||
def get_expense_total(self):
|
||||
total = Decimal(0)
|
||||
for item in self.expense:
|
||||
total += Decimal(item['Unit price']) * Decimal(item['Units'])
|
||||
try:
|
||||
total += Decimal(item['Unit price']) * Decimal(item['Units'])
|
||||
except TypeError:
|
||||
# Invalid unit price, etc.
|
||||
pass
|
||||
if not self.expense_no_emergency_fund:
|
||||
total *= Decimal('1.05')
|
||||
return total
|
||||
@ -240,7 +248,11 @@ class ReimbursementClaim(models.Model):
|
||||
def get_total(self):
|
||||
total = Decimal(0)
|
||||
for item in self.items:
|
||||
total += Decimal(item['Unit price']) * Decimal(item['Units'])
|
||||
try:
|
||||
total += Decimal(item['Unit price']) * Decimal(item['Units'])
|
||||
except TypeError:
|
||||
# Invalid unit price, etc.
|
||||
pass
|
||||
return total
|
||||
|
||||
def update_state(self, user, state):
|
||||
|
Loading…
Reference in New Issue
Block a user