Allow checking pending transactions

master
Mark Veidemanis 2 years ago
parent 04f5595a86
commit cfffc6c904
Signed by: m
GPG Key ID: 5ACFCEED46C0904F

@ -305,12 +305,25 @@ class NordigenClient(BaseClient, AggregatorClient):
""" """
path = f"accounts/{account_id}/transactions" path = f"accounts/{account_id}/transactions"
response = await self.call(path, schema="Transactions") response = await self.call(path, schema="Transactions")
parsed = response["booked"]
self.normalise_transactions(parsed, state="booked") source = "booked"
# If requisition is specified, try to get the object
# If present, take the transaction source from there,
# pending or booked.
if req:
requisition = self.instance.get_requisition(req)
if requisition:
source = requisition.transaction_source
parsed = response[source]
self.normalise_transactions(parsed, state=source)
if process: if process:
await self.process_transactions(account_id, parsed, req=req) await self.process_transactions(account_id, parsed, req=req)
if pending: if pending:
if process:
raise Exception("Cannot process and get pending")
parsed_pending = response["pending"] parsed_pending = response["pending"]
self.normalise_transactions(parsed_pending, state="pending") self.normalise_transactions(parsed_pending, state="pending")
parsed_pending.extend(parsed) parsed_pending.extend(parsed)

@ -10,7 +10,7 @@ from core.util import logs
log = logs.get_logger("scheduling") log = logs.get_logger("scheduling")
INTERVAL_AGGREGATOR = 5 INTERVAL_AGGREGATOR = 10
INTERVALS_PLATFORM = [x[0] for x in INTERVAL_CHOICES] INTERVALS_PLATFORM = [x[0] for x in INTERVAL_CHOICES]

@ -163,6 +163,12 @@ class Aggregator(models.Model):
aggregator=self, aggregator=self,
) )
def get_requisition(self, requisition_id):
return Requisition.objects.filter(
aggregator=self,
requisition_id=requisition_id,
).first()
@classmethod @classmethod
def get_currencies_for_platform(cls, platform): def get_currencies_for_platform(cls, platform):
# aggregators = Aggregator.get_for_platform(platform) # aggregators = Aggregator.get_for_platform(platform)
@ -191,12 +197,13 @@ class Aggregator(models.Model):
requisition = Requisition.objects.filter( requisition = Requisition.objects.filter(
aggregator=self, requisition_id=requisition_id aggregator=self, requisition_id=requisition_id
).first() ).first()
if requisition: # if requisition:
tx_data["requisition"] = requisition # tx_data["requisition"] = requisition
return Transaction.objects.create( return Transaction.objects.create(
aggregator=self, aggregator=self,
account_id=account_id, account_id=account_id,
reconciled=False, reconciled=False,
requisition=requisition,
**tx_data, **tx_data,
) )

Loading…
Cancel
Save