|
|
@ -151,17 +151,17 @@ class Aggregator(models.Model):
|
|
|
|
Then, join them all together.
|
|
|
|
Then, join them all together.
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
return Platform.objects.filter(link_group=self.link_group)
|
|
|
|
return Platform.objects.filter(link_group=self.link_group)
|
|
|
|
# platforms = []
|
|
|
|
|
|
|
|
# linkgroups = LinkGroup.objects.filter(
|
|
|
|
|
|
|
|
# aggregators=self,
|
|
|
|
|
|
|
|
# enabled=True,
|
|
|
|
|
|
|
|
# )
|
|
|
|
|
|
|
|
# for link in linkgroups:
|
|
|
|
|
|
|
|
# for platform in link.platforms.all():
|
|
|
|
|
|
|
|
# if platform not in platforms:
|
|
|
|
|
|
|
|
# platforms.append(platform)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# return platforms
|
|
|
|
@property
|
|
|
|
|
|
|
|
def requisitions(self):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Get requisitions for this aggregator.
|
|
|
|
|
|
|
|
Do this by looking up LinkGroups with the aggregator.
|
|
|
|
|
|
|
|
Then, join them all together.
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
return Requisition.objects.filter(
|
|
|
|
|
|
|
|
aggregator=self,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
@classmethod
|
|
|
|
def get_currencies_for_platform(cls, platform):
|
|
|
|
def get_currencies_for_platform(cls, platform):
|
|
|
@ -187,7 +187,12 @@ class Aggregator(models.Model):
|
|
|
|
account_info[bank].append(account)
|
|
|
|
account_info[bank].append(account)
|
|
|
|
return account_info
|
|
|
|
return account_info
|
|
|
|
|
|
|
|
|
|
|
|
def add_transaction(self, account_id, tx_data):
|
|
|
|
def add_transaction(self, requisition_id, account_id, tx_data):
|
|
|
|
|
|
|
|
requisition = Requisition.objects.filter(
|
|
|
|
|
|
|
|
aggregator=self, requisition_id=requisition_id
|
|
|
|
|
|
|
|
).first()
|
|
|
|
|
|
|
|
if 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,
|
|
|
@ -426,22 +431,23 @@ class Platform(models.Model):
|
|
|
|
Do this by looking up LinkGroups with the platform.
|
|
|
|
Do this by looking up LinkGroups with the platform.
|
|
|
|
Then, join them all together.
|
|
|
|
Then, join them all together.
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
# aggregators = []
|
|
|
|
|
|
|
|
# linkgroups = LinkGroup.objects.filter(
|
|
|
|
|
|
|
|
# platforms=self,
|
|
|
|
|
|
|
|
# enabled=True,
|
|
|
|
|
|
|
|
# )
|
|
|
|
|
|
|
|
# for link in linkgroups:
|
|
|
|
|
|
|
|
# for aggregator in link.aggregators.all():
|
|
|
|
|
|
|
|
# if aggregator not in aggregators:
|
|
|
|
|
|
|
|
# aggregators.append(aggregator)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# return aggregators
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return Aggregator.objects.filter(
|
|
|
|
return Aggregator.objects.filter(
|
|
|
|
link_group=self.link_group,
|
|
|
|
link_group=self.link_group,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
|
|
|
def platforms(self):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Get all platforms in this link group.
|
|
|
|
|
|
|
|
Do this by looking up LinkGroups with the platform.
|
|
|
|
|
|
|
|
Then, join them all together.
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return Platform.objects.filter(
|
|
|
|
|
|
|
|
link_group=self.link_group,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def get_requisition(self, aggregator_id, requisition_id):
|
|
|
|
def get_requisition(self, aggregator_id, requisition_id):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Get a Requisition object with the provided values.
|
|
|
|
Get a Requisition object with the provided values.
|
|
|
@ -524,6 +530,9 @@ class Transaction(models.Model):
|
|
|
|
|
|
|
|
|
|
|
|
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
|
|
|
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
|
|
|
aggregator = models.ForeignKey(Aggregator, on_delete=models.CASCADE)
|
|
|
|
aggregator = models.ForeignKey(Aggregator, on_delete=models.CASCADE)
|
|
|
|
|
|
|
|
requisition = models.ForeignKey(
|
|
|
|
|
|
|
|
"core.Requisition", null=True, on_delete=models.CASCADE
|
|
|
|
|
|
|
|
)
|
|
|
|
account_id = models.CharField(max_length=255)
|
|
|
|
account_id = models.CharField(max_length=255)
|
|
|
|
transaction_id = models.CharField(max_length=255)
|
|
|
|
transaction_id = models.CharField(max_length=255)
|
|
|
|
|
|
|
|
|
|
|
|