Validate payees

This commit is contained in:
Mark Veidemanis 2023-03-20 14:44:57 +00:00
parent 607eaef264
commit 1dd254a3a7
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
1 changed files with 30 additions and 28 deletions

View File

@ -62,36 +62,38 @@ class LinkGroupInfo(LoginRequiredMixin, OTPRequiredMixin, ObjectRead):
pay_list = {} pay_list = {}
platform_pay_list = [] platform_pay_list = []
for payee in payees["platform"]: if "platform" in payees:
cast = { for payee in payees["platform"]:
"name": payee.name, cast = {
"address": payee.address, "name": payee.name,
"amount": profit_platform / len(payees["platform"]), "address": payee.address,
"max": profit_platform, "amount": profit_platform / len(payees["platform"]),
} "max": profit_platform,
if payee not in pay_list: }
pay_list[payee] = {} if payee not in pay_list:
if "amount" in pay_list[payee]: pay_list[payee] = {}
pay_list[payee]["amount"] += cast["amount"] if "amount" in pay_list[payee]:
else: pay_list[payee]["amount"] += cast["amount"]
pay_list[payee] = dict(cast) else:
platform_pay_list.append(cast) pay_list[payee] = dict(cast)
platform_pay_list.append(cast)
requisition_pay_list = [] requisition_pay_list = []
for payee in payees["requisition"]: if "requisition" in payees:
cast = { for payee in payees["requisition"]:
"name": payee.name, cast = {
"address": payee.address, "name": payee.name,
"amount": profit_requisition / len(payees["requisition"]), "address": payee.address,
"max": profit_requisition, "amount": profit_requisition / len(payees["requisition"]),
} "max": profit_requisition,
if payee not in pay_list: }
pay_list[payee] = {} if payee not in pay_list:
if "amount" in pay_list[payee]: pay_list[payee] = {}
pay_list[payee]["amount"] += cast["amount"] if "amount" in pay_list[payee]:
else: pay_list[payee]["amount"] += cast["amount"]
pay_list[payee] = dict(cast) else:
requisition_pay_list.append(cast) pay_list[payee] = dict(cast)
requisition_pay_list.append(cast)
simulation[("Platform", profit_platform)] = platform_pay_list simulation[("Platform", profit_platform)] = platform_pay_list
simulation[("Requisition", profit_requisition)] = requisition_pay_list simulation[("Requisition", profit_requisition)] = requisition_pay_list