Skip to content

Commit 2fd3701

Browse files
committed
Add info of the source of a transaction
1 parent 85d719c commit 2fd3701

File tree

6 files changed

+36
-0
lines changed

6 files changed

+36
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Generated by Django 5.2.10 on 2026-03-06 20:45
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("bookkeeping", "0020_remove_categorymatchrule_priority"),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name="transaction",
15+
name="source",
16+
field=models.CharField(
17+
blank=True,
18+
default="",
19+
help_text="Source of the transaction (e.g. manual, paypal-webhook, etc.)",
20+
),
21+
),
22+
]

thebook/bookkeeping/models.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,11 @@ class Transaction(models.Model):
244244
amount = models.DecimalField(max_digits=10, decimal_places=2)
245245
notes = models.TextField(blank=True)
246246

247+
source = models.CharField(
248+
blank=True,
249+
default="",
250+
help_text="Source of the transaction (e.g. manual, paypal-webhook, etc.)",
251+
)
247252
created_at = models.DateTimeField(auto_now_add=True)
248253
updated_at = models.DateTimeField(auto_now=True)
249254

thebook/webhooks/managers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,6 @@ def fetch_transactions(start_date: datetime.date, end_date: datetime.date):
8888
amount=amount,
8989
bank_account=bank_account,
9090
category=bank_account_transfer_category,
91+
source="paypal-fetch-transactions",
9192
created_by=user,
9293
)

thebook/webhooks/models.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ def process(self, bank_account=None, user=None):
112112
description=description,
113113
amount=amount,
114114
bank_account=bank_account,
115+
source="openpix-webhook",
115116
created_by=user,
116117
)
117118
Transaction.objects.create(
@@ -121,6 +122,7 @@ def process(self, bank_account=None, user=None):
121122
amount=openpix_fee,
122123
bank_account=bank_account,
123124
category=bank_fee_category,
125+
source="openpix-webhook",
124126
created_by=user,
125127
)
126128

@@ -277,6 +279,7 @@ def process(self, bank_account=None, user=None):
277279
description=description,
278280
amount=amount,
279281
bank_account=bank_account,
282+
source="paypal-webhook",
280283
created_by=user,
281284
)
282285

@@ -288,6 +291,7 @@ def process(self, bank_account=None, user=None):
288291
amount=fee,
289292
bank_account=bank_account,
290293
category=bank_fee_category,
294+
source="paypal-webhook",
291295
created_by=user,
292296
)
293297

thebook/webhooks/openpix/services.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ def fetch_transactions(start_date: datetime.date, end_date: datetime.date):
8888
amount=decimal.Decimal(str(transaction_amount)),
8989
bank_account=bank_account,
9090
category=transaction_category,
91+
source="openpix-fetch-transactions",
9192
created_by=user,
9293
)
9394
)
@@ -104,6 +105,7 @@ def fetch_transactions(start_date: datetime.date, end_date: datetime.date):
104105
amount=transaction_fee_amount,
105106
bank_account=bank_account,
106107
category=bank_fee_category,
108+
source="openpix-fetch-transactions",
107109
created_by=user,
108110
)
109111
)

thebook/webhooks/paypal/services.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ def fetch_transactions(start_date: datetime.date, end_date: datetime.date):
104104
amount=transaction_amount + transaction_fee_amount,
105105
bank_account=bank_account,
106106
category=transaction_category,
107+
source="paypal-fetch-transactions",
107108
created_by=user,
108109
)
109110
)
@@ -117,6 +118,7 @@ def fetch_transactions(start_date: datetime.date, end_date: datetime.date):
117118
amount=transaction_fee_amount,
118119
bank_account=bank_account,
119120
category=bank_fee_category,
121+
source="paypal-fetch-transactions",
120122
created_by=user,
121123
)
122124
)

0 commit comments

Comments
 (0)