summaryrefslogtreecommitdiff
path: root/postgresqleu/plaid/models.py
diff options
context:
space:
mode:
authorMagnus Hagander2023-06-18 15:48:16 +0000
committerMagnus Hagander2023-06-18 16:14:07 +0000
commit989a343a64ab9b372c606ce0cb716dc43f7574c0 (patch)
tree67e4f74040e203261679a736a3d28d3ccf3be3a7 /postgresqleu/plaid/models.py
parent7f204cf595c5fb5a0daae20fe1f9eb809b173acb (diff)
Implement support for Plaid banktransactions
This module will use the plaid.com service to download bank transaction lists from any supported bank. If available, it will also respond to webhooks sent by plaid whenever transactions show up, but failing that will just poll twice per day.
Diffstat (limited to 'postgresqleu/plaid/models.py')
-rw-r--r--postgresqleu/plaid/models.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/postgresqleu/plaid/models.py b/postgresqleu/plaid/models.py
new file mode 100644
index 00000000..01b2fbb8
--- /dev/null
+++ b/postgresqleu/plaid/models.py
@@ -0,0 +1,32 @@
+from django.db import models
+
+from postgresqleu.invoices.models import InvoicePaymentMethod
+
+
+class PlaidTransaction(models.Model):
+ paymentmethod = models.ForeignKey(InvoicePaymentMethod, blank=False, null=False, on_delete=models.CASCADE)
+ transactionid = models.CharField(max_length=100, blank=False, null=False)
+ datetime = models.DateTimeField(null=False, blank=False)
+ amount = models.DecimalField(decimal_places=2, max_digits=20, null=False)
+ paymentref = models.CharField(max_length=200, blank=True, null=False)
+ transactionobject = models.JSONField(null=False, blank=False, default=dict)
+
+ class Meta:
+ unique_together = (
+ ('transactionid', 'paymentmethod'),
+ )
+ ordering = ('-datetime', )
+
+ def __str__(self):
+ return self.transactionid
+
+
+class PlaidWebhookData(models.Model):
+ datetime = models.DateTimeField(null=False, blank=False, auto_now_add=True, db_index=True)
+ source = models.GenericIPAddressField(null=True, blank=True)
+ signature = models.CharField(max_length=1000, null=False, blank=False)
+ hook_code = models.CharField(max_length=200, null=False, blank=False)
+ contents = models.JSONField(null=False, blank=False, default=dict)
+
+ class Meta:
+ ordering = ('-datetime', )