Begin implementing better payment simulation
This commit is contained in:
@@ -47,6 +47,7 @@ class Money(object):
|
||||
"""
|
||||
Run all the balance checks that output into ES in another thread.
|
||||
"""
|
||||
# TODO: pass link group instead
|
||||
if not all([user, nordigen, agora]):
|
||||
raise Exception
|
||||
|
||||
@@ -559,10 +560,16 @@ class Money(object):
|
||||
# Add the platform payment
|
||||
for platform in platforms:
|
||||
# Get ratio of platform.throughput to the total platform throughput
|
||||
ratio = platform.throughput / total_throughput_platform
|
||||
if total_throughput_platform == 0:
|
||||
ratio = 0
|
||||
else:
|
||||
ratio = platform.throughput / total_throughput_platform
|
||||
platform_payment = cut_platform * ratio
|
||||
payees_length = len(platform.payees.all())
|
||||
payment_per_payee = platform_payment / payees_length
|
||||
if payees_length == 0:
|
||||
payment_per_payee = 0
|
||||
else:
|
||||
payment_per_payee = platform_payment / payees_length
|
||||
for wallet in platform.payees.all():
|
||||
if wallet not in pay_list:
|
||||
pay_list[wallet] = []
|
||||
@@ -575,10 +582,16 @@ class Money(object):
|
||||
# Add the requisition payment
|
||||
for requisition in requisitions:
|
||||
# Get ratio of requisition.throughput to the requisition cut
|
||||
ratio = requisition.throughput / total_throughput_requisition
|
||||
if total_throughput_requisition == 0:
|
||||
ratio = 0
|
||||
else:
|
||||
ratio = requisition.throughput / total_throughput_requisition
|
||||
req_payment = cut_req * ratio
|
||||
payees_length = len(requisition.payees.all())
|
||||
payment_per_payee = req_payment / payees_length
|
||||
if payees_length == 0:
|
||||
payment_per_payee = 0
|
||||
else:
|
||||
payment_per_payee = req_payment / payees_length
|
||||
for wallet in requisition.payees.all():
|
||||
if wallet not in pay_list:
|
||||
pay_list[wallet] = []
|
||||
@@ -590,5 +603,15 @@ class Money(object):
|
||||
|
||||
return pay_list
|
||||
|
||||
def collapse_pay_list(self, pay_list):
|
||||
"""
|
||||
Collapse the pay list into a single dict of wallet: amount.
|
||||
"""
|
||||
collapsed = {}
|
||||
for wallet, payments in pay_list.items():
|
||||
collapsed[wallet] = sum([x[0] for x in payments])
|
||||
|
||||
return collapsed
|
||||
|
||||
|
||||
money = Money()
|
||||
|
||||
Reference in New Issue
Block a user