Group currency list by requisition

This commit is contained in:
Mark Veidemanis 2023-03-14 14:06:54 +00:00
parent a855e7e5b5
commit 4211d3c10a
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
8 changed files with 49 additions and 10 deletions

View File

@ -76,7 +76,9 @@ class AggregatorClient(ABC):
) )
# New transaction # New transaction
await notify.sendmsg( await notify.sendmsg(
f"New transaction: {orjson.dumps(tx_cast)}", title="New transaction" self.instance.user,
f"New transaction: {orjson.dumps(tx_cast)}",
title="New transaction",
) )
await self.transaction(platforms, tx_obj) await self.transaction(platforms, tx_obj)
else: else:

View File

@ -124,7 +124,7 @@ class NordigenClient(BaseClient, AggregatorClient):
# ownernames = loads(settings.Nordigen.OwnerNames) # ownernames = loads(settings.Nordigen.OwnerNames)
# return ownernames # return ownernames
async def get_account(self, account_id): async def get_account(self, req_id, account_id):
""" """
Get details of an account. Get details of an account.
:param account_id: account ID""" :param account_id: account ID"""
@ -148,6 +148,7 @@ class NordigenClient(BaseClient, AggregatorClient):
# Let's add the account ID so we can reference it later # Let's add the account ID so we can reference it later
parsed["account_id"] = account_id parsed["account_id"] = account_id
parsed["aggregator_id"] = str(self.instance.id) parsed["aggregator_id"] = str(self.instance.id)
parsed["requisition_id"] = str(req_id)
return parsed return parsed
async def get_all_account_info(self, requisition=None, store=False): async def get_all_account_info(self, requisition=None, store=False):
@ -157,10 +158,11 @@ class NordigenClient(BaseClient, AggregatorClient):
else: else:
requisitions = [await self.get_requisition(requisition)] requisitions = [await self.get_requisition(requisition)]
print("REQS", requisitions)
for req in requisitions: for req in requisitions:
accounts = req["accounts"] accounts = req["accounts"]
for account_id in accounts: for account_id in accounts:
account_info = await self.get_account(account_id) account_info = await self.get_account(req["id"], account_id)
if not account_info: if not account_info:
continue continue
if req["institution_id"] in to_return: if req["institution_id"] in to_return:

View File

@ -25,6 +25,11 @@ INTERVAL_CHOICES = (
(86400, "Every day"), (86400, "Every day"),
) )
TRANSACTION_SOURCE_CHOICES = (
("booked", "Booked"),
("pending", "Pending"),
)
class User(AbstractUser): class User(AbstractUser):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
@ -187,6 +192,8 @@ class Platform(models.Model):
base_usd = models.FloatField(default=2800) base_usd = models.FloatField(default=2800)
withdrawal_trigger = models.FloatField(default=200) withdrawal_trigger = models.FloatField(default=200)
# payees = models.ManyToManyField(Wallet, blank=True)
enabled = models.BooleanField(default=True) enabled = models.BooleanField(default=True)
def __str__(self): def __str__(self):
@ -471,6 +478,33 @@ class Trade(models.Model):
release_response = models.JSONField(default=dict) release_response = models.JSONField(default=dict)
# class BankAccount(models.Model):
# """
# Extra information for an account.
# """
# account_id = models.CharField(max_length=255)
# payment_details = models.TextField()
# enabled = models.BooleanField(default=True)
class Requisition(models.Model):
"""
A requisition for an Aggregator
"""
aggregator = models.ForeignKey(Aggregator, on_delete=models.CASCADE)
requisition_id = models.CharField(max_length=255)
payment_details = models.TextField()
transaction_source = models.CharField(
max_length=255, choices=TRANSACTION_SOURCE_CHOICES
)
# throughput = models.FloatField(default=0)
# payees = models.ManyToManyField(Wallet, blank=True)
assets = { assets = {
"XMR": "Monero", "XMR": "Monero",
"BTC": "Bitcoin", "BTC": "Bitcoin",

View File

@ -17,7 +17,7 @@
<td> <td>
<a <a
class="has-text-grey" class="has-text-grey"
onclick="window.prompt('Copy to clipboard: Ctrl+C, Enter', '{{ item.id }}/');"> onclick="window.prompt('Copy to clipboard: Ctrl+C, Enter', '{{ item.id }}');">
<span class="icon" data-tooltip="Copy to clipboard"> <span class="icon" data-tooltip="Copy to clipboard">
<i class="fa-solid fa-copy" aria-hidden="true"></i> <i class="fa-solid fa-copy" aria-hidden="true"></i>
</span> </span>

View File

@ -23,7 +23,7 @@
<td> <td>
<a <a
class="has-text-grey" class="has-text-grey"
onclick="window.prompt('Copy to clipboard: Ctrl+C, Enter', '{{ item.id }}/');"> onclick="window.prompt('Copy to clipboard: Ctrl+C, Enter', '{{ item.id }}');">
<span class="icon" data-tooltip="Copy to clipboard"> <span class="icon" data-tooltip="Copy to clipboard">
<i class="fa-solid fa-copy" aria-hidden="true"></i> <i class="fa-solid fa-copy" aria-hidden="true"></i>
</span> </span>

View File

@ -7,7 +7,7 @@
{# cache 600 objects_banks_currencies request.user.id object_list type last #} {# cache 600 objects_banks_currencies request.user.id object_list type last #}
{% for bank, accounts in object_list.items %} {% for bank, accounts in object_list.items %}
<h1 class="title is-4">{{ bank }}</h1> <h1 class="title is-4">{{ bank.0 }} <code>{{ bank.1 }}</code></h1>
<table <table
class="table is-fullwidth is-hoverable" class="table is-fullwidth is-hoverable"
hx-target="#{{ bank }}-table" hx-target="#{{ bank }}-table"

View File

@ -23,7 +23,7 @@
<td> <td>
<a <a
class="has-text-grey" class="has-text-grey"
onclick="window.prompt('Copy to clipboard: Ctrl+C, Enter', '{{ item.id }}/');"> onclick="window.prompt('Copy to clipboard: Ctrl+C, Enter', '{{ item.id }}');">
<span class="icon" data-tooltip="Copy to clipboard"> <span class="icon" data-tooltip="Copy to clipboard">
<i class="fa-solid fa-copy" aria-hidden="true"></i> <i class="fa-solid fa-copy" aria-hidden="true"></i>
</span> </span>

View File

@ -44,10 +44,11 @@ class BanksCurrencies(LoginRequiredMixin, OTPRequiredMixin, ObjectList):
account_info = {} account_info = {}
for agg in aggregators: for agg in aggregators:
for bank, accounts in agg.account_info.items(): for bank, accounts in agg.account_info.items():
if bank not in account_info:
account_info[bank] = []
for account in accounts: for account in accounts:
account_info[bank].append(account) ident = (bank, account["requisition_id"])
if ident not in account_info:
account_info[ident] = []
account_info[ident].append(account)
return account_info return account_info