-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimulation.py
More file actions
71 lines (52 loc) · 2.79 KB
/
simulation.py
File metadata and controls
71 lines (52 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import datetime
from engine import KeepCardSimulator
# Create a simulator instance
# Statement cycle starts on 1st of each month
simulator = KeepCardSimulator(statement_cycle_start=3)
print("Generating transactions with FIXED payment impact on Balance Due...")
# Month 1: New card with purchases
simulator.add_transaction('PURCHASE', 200.00, '2025-01-05', '2025-01-05')
simulator.add_transaction('PURCHASE', 300.00, '2025-01-10', '2025-01-10')
simulator.add_transaction('PURCHASE', 100.00, '2025-01-20', '2025-01-20')
simulator.add_transaction('PURCHASE', 150.00, '2025-01-28', '2025-01-28')
# First statement period ends on Jan 31, due date is Feb 1
# Balance at this point is $750
# Month 2: A payment is made - this should affect both balance and balance due
print("\nAdding payment of $200 on Feb 10 - this should reduce both balance and balance due")
simulator.add_transaction('PAYMENT', 200.00, '2025-02-10', '2025-02-10')
# Add some more purchases
simulator.add_transaction('PURCHASE', 150.00, '2025-02-15', '2025-02-15')
# On the due date (Mar 1), customer can't pay the remaining balance, so creates an extension
# First, get the current balance due amount
calculated_balance_due = simulator.calculate_period_balance_due(
datetime.date(2025, 3, 1))
print(f"\nBalance due on March 1, 2025: ${calculated_balance_due:.2f}")
simulator.add_transaction('PAYMENT', 200.00, '2025-03-01', '2025-03-01')
# Create extension for the full balance due amount on the due date
ext_id = simulator.create_statement_extension(
calculated_balance_due, '2025-03-01', 6)
print(
f"Created statement extension {ext_id} for ${calculated_balance_due:.2f} with 6-month term")
# Month 3: After extension, customer makes more purchases and payments
simulator.add_transaction('PURCHASE', 200.00, '2025-03-10', '2025-03-10')
simulator.add_transaction('PAYMENT', 150.00, '2025-03-20', '2025-03-20')
# Calculate the monthly extension payment amount
monthly_payment = simulator.extension_factory.get_next_due_amount(
'2025-04-01')
print(f"\nMonthly extension payment amount: ${monthly_payment:.2f}")
# Make the first extension payment on the due date
simulator.make_extension_payment(ext_id, monthly_payment, '2025-04-01')
simulator.make_extension_payment(ext_id, 275, '2025-04-20')
# 1. Show the unified timeline with properly calculated Balance Due
print("\n===== UNIFIED TIMELINE WITH CORRECTED BALANCE DUE =====")
# Note: Now payments properly affect both balance and balance due
simulator.display_timeline()
# 2. Show the transaction ledger
print("\n===== TRANSACTION LEDGER =====")
simulator.show_transactions()
# 3. Show the statement summaries
print("\n===== STATEMENT SUMMARIES =====")
simulator.display_side_by_side()
# 4. Show the extension product details
print("\n===== EXTENSION PRODUCT DETAILS =====")
simulator.show_extensions()