Skip to content

Commit 6c800e3

Browse files
Merge pull request #21 from VedantPatel04/frontEnd
Front-End functionally complete
2 parents f670027 + 43009e6 commit 6c800e3

73 files changed

Lines changed: 7423 additions & 114 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ coverage.xml
2525
# Environment / secrets
2626
.env
2727
backend/.env
28+
frontend/.env
2829
.env.*
2930
!backend/.env.example
31+
!frontend/.env.example
3032

3133
# OS / editor cruft
3234
.DS_Store
0 Bytes
Binary file not shown.
428 Bytes
Binary file not shown.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
from django.db import migrations, models
2+
3+
4+
def backfill_chase_payment_thank_you(apps, schema_editor):
5+
"""
6+
Existing rows never stored Chase Type. Mark the common Chase bill-payment
7+
label so summaries stop treating those credits as spend without a re-upload.
8+
9+
Statement credits / adjustments are NOT guessed here — re-upload those files
10+
so the adapter can read Type=Adjustment.
11+
"""
12+
Transactions = apps.get_model("transactions", "Transactions")
13+
Transactions.objects.filter(description__icontains="Payment Thank You").update(
14+
entry_type="payment"
15+
)
16+
17+
18+
def noop_reverse(apps, schema_editor):
19+
# Irreversible data fix; schema reverse still drops the column.
20+
pass
21+
22+
23+
class Migration(migrations.Migration):
24+
25+
dependencies = [
26+
("transactions", "0009_globalmerchantalias_transactions_confidence_and_more"),
27+
]
28+
29+
operations = [
30+
migrations.AddField(
31+
model_name="transactions",
32+
name="entry_type",
33+
field=models.CharField(
34+
choices=[
35+
("spend", "Spend"),
36+
("refund", "Refund"),
37+
("payment", "Payment"),
38+
("adjustment", "Adjustment"),
39+
],
40+
db_index=True,
41+
default="spend",
42+
max_length=16,
43+
),
44+
),
45+
migrations.RunPython(backfill_chase_payment_thank_you, noop_reverse),
46+
]

backend/apps/transactions/models.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,19 @@
1111
SOURCE_BANK = "bank" # adapter's bank category (tier 4)
1212
SOURCE_NONE = "" # genuinely unresolved or categorizedto "other"
1313

14+
ENTRY_SPEND = "spend"
15+
ENTRY_REFUND = "refund"
16+
ENTRY_PAYMENT = "payment"
17+
ENTRY_ADJUSTMENT = "adjustment"
18+
ENTRY_TYPE_CHOICES = (
19+
(ENTRY_SPEND, "Spend"),
20+
(ENTRY_REFUND, "Refund"),
21+
(ENTRY_PAYMENT, "Payment"),
22+
(ENTRY_ADJUSTMENT, "Adjustment"),
23+
)
24+
# Rows that count toward by_category spending AKA ottal_spend
25+
SPEND_SUMMARY_ENTRY_TYPES = (ENTRY_SPEND, ENTRY_REFUND)
26+
1427

1528
class Transactions(models.Model):
1629
class Meta:
@@ -35,6 +48,14 @@ class Meta:
3548
# 0.0–1.0: user=1.0, global=0.9, bank=0.7, unresolved=0.0
3649
confidence = models.FloatField(default=0.0)
3750

51+
#spend, refund, payment, adjustment — see module constants above
52+
entry_type = models.CharField(
53+
max_length=16,
54+
choices=ENTRY_TYPE_CHOICES,
55+
default=ENTRY_SPEND,
56+
db_index=True,
57+
)
58+
3859
# sign convention: positive = spend, negative = refund / credit
3960
amount = models.DecimalField(max_digits=10, decimal_places=2)
4061
transaction_date = models.DateField()

backend/apps/transactions/views.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ def transaction_list(request):
8686
"normalized_description": row.normalized_description,
8787
"merchant_key": row.merchant_key,
8888
"category": row.category,
89+
"entry_type": row.entry_type,
8990
"resolution_source": row.resolution_source,
9091
"confidence": row.confidence,
9192
}
@@ -236,13 +237,17 @@ def summary_view(request):
236237
237238
All-time spend totals across all wallet cards, by rewards category.
238239
239-
Returns net spend (refunds reduce category totals). Unresolved rows
240-
(category="") are excluded from by_category and reported separately in
240+
Returns purchase spend (entry_type spend + refund). Refunds reduce
241+
category totals. Bill payments and statement adjustments are excluded
242+
from by_category / total_spend but still appear on the transaction list
243+
and still count toward statement-cycle months_covered.
244+
245+
Unresolved rows (category="") among spend/refund are reported in
241246
unresolved_count / unresolved_amount.
242247
243-
All 7 category buckets are always present even if zero. Negative totals
244-
(e.g. other when card payments outweigh real spend) are not clamped —
245-
the Day 6 Confidence Check (Stage 5) handles distortion detection.
248+
All 7 category buckets are always present even if zero.
249+
months_breakdown is calendar months (display); months_covered is
250+
statement-cycle evidence used for annualize / signup.
246251
247252
The Day 6 recommendation engine calls get_spend_summary() directly as a
248253
service; this view serialises the same output for the HTTP API.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)