diff --git a/core/clients/aggregator.py b/core/clients/aggregator.py index c075d96..3e1c14e 100644 --- a/core/clients/aggregator.py +++ b/core/clients/aggregator.py @@ -76,7 +76,9 @@ class AggregatorClient(ABC): ) # New transaction 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) else: diff --git a/core/clients/aggregators/nordigen.py b/core/clients/aggregators/nordigen.py index 877aa1c..a073124 100644 --- a/core/clients/aggregators/nordigen.py +++ b/core/clients/aggregators/nordigen.py @@ -124,7 +124,7 @@ class NordigenClient(BaseClient, AggregatorClient): # ownernames = loads(settings.Nordigen.OwnerNames) # return ownernames - async def get_account(self, account_id): + async def get_account(self, req_id, account_id): """ Get details of an account. :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 parsed["account_id"] = account_id parsed["aggregator_id"] = str(self.instance.id) + parsed["requisition_id"] = str(req_id) return parsed async def get_all_account_info(self, requisition=None, store=False): @@ -157,10 +158,11 @@ class NordigenClient(BaseClient, AggregatorClient): else: requisitions = [await self.get_requisition(requisition)] + print("REQS", requisitions) for req in requisitions: accounts = req["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: continue if req["institution_id"] in to_return: diff --git a/core/models.py b/core/models.py index 4dabe59..ce04f20 100644 --- a/core/models.py +++ b/core/models.py @@ -25,6 +25,11 @@ INTERVAL_CHOICES = ( (86400, "Every day"), ) +TRANSACTION_SOURCE_CHOICES = ( + ("booked", "Booked"), + ("pending", "Pending"), +) + class User(AbstractUser): 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) withdrawal_trigger = models.FloatField(default=200) + # payees = models.ManyToManyField(Wallet, blank=True) + enabled = models.BooleanField(default=True) def __str__(self): @@ -471,6 +478,33 @@ class Trade(models.Model): 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 = { "XMR": "Monero", "BTC": "Bitcoin", diff --git a/core/templates/partials/aggregator-info.html b/core/templates/partials/aggregator-info.html index 28aa55b..61ccaef 100644 --- a/core/templates/partials/aggregator-info.html +++ b/core/templates/partials/aggregator-info.html @@ -17,7 +17,7 @@
{{ bank.1 }}