largest credit/debit can now return None
This commit is contained in:
parent
6638ee2dab
commit
9284a55825
@ -135,8 +135,8 @@ def calculateStats(transactions, yearRangeVal=None, monthRangeVal=None, otherFel
|
||||
stats = {
|
||||
"totalCredits" : round(sum([abs(x[2]) for x in periodTransactions if x[2] > 0]), 2) if len([abs(x[2]) for x in periodTransactions if x[2] > 0]) > 0 else float(0),
|
||||
"totalDebits" : round(sum([abs(x[2]) for x in periodTransactions if x[2] < 0]), 2) if len([abs(x[2]) for x in periodTransactions if x[2] < 0]) > 0 else float(0),
|
||||
"largestCredit" : max(periodTransactions, key=lambda x: x[2]) if len(periodTransactions) > 0 else (datetime.now(), datetime.now(), 0, "", 0, "", ""),
|
||||
"largestDebit" : min(periodTransactions, key=lambda x: x[2]) if len(periodTransactions) > 0 else (datetime.now(), datetime.now(), 0, "", 0, "", ""),
|
||||
"largestCredit" : max(periodTransactions, key=lambda x: x[2]) if len(periodTransactions) > 0 else None,
|
||||
"largestDebit" : min(periodTransactions, key=lambda x: x[2]) if len(periodTransactions) > 0 else None,
|
||||
"averageCredit" : round(statistics.fmean([abs(x[2]) for x in periodTransactions if x[2] > 0]), 2) if len([abs(x[2]) for x in periodTransactions if x[2] > 0]) > 0 else float(0),
|
||||
"averageDebit" : round(statistics.fmean([abs(x[2]) for x in periodTransactions if x[2] < 0]), 2) if len([abs(x[2]) for x in periodTransactions if x[2] < 0]) > 0 else float(0),
|
||||
"netBalance" : round(sum([x[2] for x in periodTransactions]), 2) if len(periodTransactions) > 0 else float(0),
|
||||
|
Loading…
x
Reference in New Issue
Block a user