-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
310 lines (275 loc) · 14.4 KB
/
Copy pathmain.py
File metadata and controls
310 lines (275 loc) · 14.4 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
"""
Loan Payment Manager - USA & CANADA
Complete loan payment management system for multiple loan types
"""
from src.payment import CreditCardLoanPayment, PersonalLoanPayment, HomeLoanPayment, AutoLoanPayment
from src.bank_linking import BankLink
from src.utils import validate_email, validate_phone, format_currency
class LoanPaymentManager:
"""Main application class for loan payment management"""
def __init__(self):
self.credit_card_loans = CreditCardLoanPayment()
self.personal_loans = PersonalLoanPayment()
self.mortgages = HomeLoanPayment()
self.auto_loans = AutoLoanPayment()
self.bank_link = BankLink()
def display_main_menu(self):
"""Display main menu"""
print("\n" + "="*60)
print("LOAN PAYMENT MANAGER - USA & CANADA")
print("="*60)
print("1. Credit Card Loan Payments")
print("2. Personal Loan Payments")
print("3. Home Loan (Mortgage) Payments")
print("4. Auto Loan Payments")
print("5. Bank Account Linking")
print("6. View Payment History")
print("7. Exit")
print("="*60)
def handle_credit_card_loans(self):
"""Handle credit card loan payments"""
while True:
print("\n--- Credit Card Loan Payments ---")
print("1. Add Credit Card Loan Account")
print("2. Make Payment")
print("3. View Balance")
print("4. Back to Main Menu")
choice = input("Select option: ").strip()
if choice == "1":
issuer = input("Card Issuer (e.g., Visa, Mastercard): ").strip()
card_last4 = input("Last 4 digits of card: ").strip()
balance = float(input("Current balance: $"))
min_payment = float(input("Minimum payment: $"))
interest_rate = float(input("Interest rate (%): "))
due_date = input("Due date (MM/DD): ").strip()
self.credit_card_loans.add_credit_card_loan(issuer, card_last4, balance, min_payment, interest_rate, due_date)
print(f"✓ {issuer} card added successfully!")
elif choice == "2":
issuer = input("Card Issuer: ").strip()
amount = float(input("Payment amount: $"))
result = self.credit_card_loans.process_payment(issuer, amount)
print(f"✓ Payment Status: {result['status']}")
if result['status'] == 'success':
print(f" Remaining Balance: ${result['remaining_balance']:,.2f}")
elif choice == "3":
issuer = input("Card Issuer: ").strip()
loan = self.credit_card_loans.get_loan_details(issuer)
if loan:
print(f"\nCard: {loan['card_issuer']} ****{loan['card_last_4']}")
print(f"Balance: ${loan['balance']:,.2f}")
print(f"Min Payment: ${loan['min_payment']:,.2f}")
print(f"Interest Rate: {loan['interest_rate']}%")
print(f"Due Date: {loan['due_date']}")
else:
print("Card not found.")
elif choice == "4":
break
else:
print("Invalid option.")
def handle_personal_loans(self):
"""Handle personal loan payments"""
while True:
print("\n--- Personal Loan Payments ---")
print("1. Set Up Bank Account")
print("2. Add Personal Loan")
print("3. Make Payment")
print("4. View Loan Details")
print("5. Back to Main Menu")
choice = input("Select option: ").strip()
if choice == "1":
country = input("Country (USA/Canada): ").strip().upper()
if country == "USA":
bank_name = input("Bank Name: ").strip()
acc_type = input("Account Type (Checking/Savings): ").strip()
acc_number = input("Account Number: ").strip()
routing = input("Routing Number: ").strip()
owner = input("Account Owner Name: ").strip()
address = input("Address: ").strip()
balance = float(input("Available Balance: $"))
self.personal_loans.set_usa_bank_account(bank_name, acc_type, acc_number, routing, owner, address, balance)
print("✓ USA bank account configured!")
else:
bank_name = input("Bank Name: ").strip()
acc_type = input("Account Type: ").strip()
acc_number = input("Account Number: ").strip()
institution = input("Institution: ").strip()
transit = input("Transit Number: ").strip()
owner = input("Account Owner Name: ").strip()
address = input("Address: ").strip()
balance = float(input("Available Balance: $"))
self.personal_loans.set_canada_bank_account(bank_name, acc_type, acc_number, institution, transit, owner, address, balance)
print("✓ Canada bank account configured!")
elif choice == "2":
loan_id = input("Loan ID: ").strip()
lender = input("Lender Name: ").strip()
balance = float(input("Loan Balance: $"))
monthly = float(input("Monthly Payment: $"))
rate = float(input("Interest Rate (%): "))
due = input("Due Date (MM/DD): ").strip()
self.personal_loans.add_personal_loan(loan_id, lender, balance, monthly, rate, due)
print("✓ Personal loan added!")
elif choice == "3":
loan_id = input("Loan ID: ").strip()
amount = float(input("Payment Amount: $"))
result = self.personal_loans.process_payment(loan_id, amount)
print(f"✓ {result['status'].upper()}")
if result['status'] == 'success':
print(f" Remaining Balance: ${result['remaining_balance']:,.2f}")
else:
print(f" Error: {result['message']}")
elif choice == "4":
loan_id = input("Loan ID: ").strip()
loan = self.personal_loans.get_loan_details(loan_id)
if loan:
print(f"\nLoan ID: {loan['loan_id']}")
print(f"Lender: {loan['lender_name']}")
print(f"Balance: ${loan['balance']:,.2f}")
print(f"Monthly Payment: ${loan['monthly_payment']:,.2f}")
print(f"Interest Rate: {loan['interest_rate']}%")
else:
print("Loan not found.")
elif choice == "5":
break
def handle_mortgages(self):
"""Handle mortgage payments"""
while True:
print("\n--- Home Loan (Mortgage) Payments ---")
print("1. Add Mortgage")
print("2. Set Payment Method")
print("3. Make Payment")
print("4. View Mortgage Details")
print("5. Back to Main Menu")
choice = input("Select option: ").strip()
if choice == "1":
loan_id = input("Loan ID: ").strip()
lender = input("Lender Name: ").strip()
property_addr = input("Property Address: ").strip()
principal = float(input("Principal Balance: $"))
monthly = float(input("Monthly Payment: $"))
rate = float(input("Interest Rate (%): "))
months = int(input("Months Remaining: "))
due = input("Due Date (MM/DD): ").strip()
self.mortgages.add_mortgage(loan_id, lender, property_addr, principal, monthly, rate, months, due)
print("✓ Mortgage added!")
elif choice == "2":
method = input("Payment Method (bank/check): ").strip().lower()
if method == "bank":
acc_num = input("Account Number: ").strip()
routing = input("Routing Number (USA) or Transit (Canada): ").strip()
self.mortgages.set_payment_method_bank(acc_num, routing_number=routing if len(routing)==9 else None, transit_number=routing if len(routing)!=9 else None)
print("✓ Bank payment method set!")
else:
name = input("Payer Name: ").strip()
addr = input("Address: ").strip()
phone = input("Phone: ").strip()
email = input("Email: ").strip()
self.mortgages.set_payment_method_check(name, addr, phone, email)
print("✓ Check payment method set!")
elif choice == "3":
loan_id = input("Loan ID: ").strip()
amount = float(input("Payment Amount: $"))
result = self.mortgages.process_payment(loan_id, amount)
print(f"✓ {result['status'].upper()}")
if result['status'] == 'success':
print(f" Remaining Balance: ${result['remaining_balance']:,.2f}")
print(f" Months Remaining: {result['remaining_term']}")
elif choice == "4":
loan_id = input("Loan ID: ").strip()
mortgage = self.mortgages.get_mortgage_details(loan_id)
if mortgage:
print(f"\nLoan ID: {mortgage['loan_id']}")
print(f"Lender: {mortgage['lender_name']}")
print(f"Property: {mortgage['property_address']}")
print(f"Principal Balance: ${mortgage['principal_balance']:,.2f}")
print(f"Monthly Payment: ${mortgage['monthly_payment']:,.2f}")
print(f"Interest Rate: {mortgage['interest_rate']}%")
print(f"Months Remaining: {mortgage['remaining_term_months']}")
else:
print("Mortgage not found.")
elif choice == "5":
break
def handle_auto_loans(self):
"""Handle auto loan payments"""
while True:
print("\n--- Auto Loan Payments ---")
print("1. Add Auto Loan")
print("2. Make Payment")
print("3. View Loan Details")
print("4. View Payment History")
print("5. Back to Main Menu")
choice = input("Select option: ").strip()
if choice == "1":
loan_id = input("Loan ID: ").strip()
lender = input("Lender Name: ").strip()
make = input("Vehicle Make: ").strip()
model = input("Vehicle Model: ").strip()
year = input("Vehicle Year: ").strip()
vin = input("VIN: ").strip()
amount = float(input("Loan Amount: $"))
monthly = float(input("Monthly Payment: $"))
rate = float(input("Interest Rate (%): "))
months = int(input("Months Remaining: "))
due = input("Due Date (MM/DD): ").strip()
vehicle = {"make": make, "model": model, "year": year, "vin": vin}
self.auto_loans.add_auto_loan(loan_id, lender, vehicle, amount, monthly, rate, months, due)
print("✓ Auto loan added!")
elif choice == "2":
loan_id = input("Loan ID: ").strip()
amount = float(input("Payment Amount: $"))
result = self.auto_loans.process_payment(loan_id, amount)
print(f"✓ {result['status'].upper()}")
if result['status'] == 'success':
print(f" Remaining Balance: ${result['remaining_balance']:,.2f}")
print(f" Months Remaining: {result['months_remaining']}")
elif choice == "3":
loan_id = input("Loan ID: ").strip()
loan = self.auto_loans.get_loan_details(loan_id)
if loan:
print(f"\nLoan ID: {loan['loan_id']}")
print(f"Lender: {loan['lender_name']}")
print(f"Vehicle: {loan['vehicle_info']['year']} {loan['vehicle_info']['make']} {loan['vehicle_info']['model']}")
print(f"Loan Amount: ${loan['loan_amount']:,.2f}")
print(f"Monthly Payment: ${loan['monthly_payment']:,.2f}")
print(f"Interest Rate: {loan['interest_rate']}%")
print(f"Months Remaining: {loan['months_remaining']}")
else:
print("Loan not found.")
elif choice == "4":
loan_id = input("Loan ID: ").strip()
history = self.auto_loans.get_payment_history(loan_id)
if history:
print(f"\nPayment History for {loan_id}:")
for payment in history:
print(f" - ${payment['amount']:,.2f} on {payment['date']} (Remaining: ${payment['remaining_balance']:,.2f})")
else:
print("No payment history found.")
elif choice == "5":
break
def run(self):
"""Run the main application loop"""
print("\n" + "="*60)
print("Welcome to Loan Payment Manager!")
print("="*60)
while True:
self.display_main_menu()
choice = input("\nSelect an option (1-7): ").strip()
if choice == "1":
self.handle_credit_card_loans()
elif choice == "2":
self.handle_personal_loans()
elif choice == "3":
self.handle_mortgages()
elif choice == "4":
self.handle_auto_loans()
elif choice == "5":
print("\nBank Linking feature coming soon!")
elif choice == "6":
print("\nPayment history feature coming soon!")
elif choice == "7":
print("\nThank you for using Loan Payment Manager. Goodbye!")
break
else:
print("Invalid choice. Please try again.")
if __name__ == "__main__":
app = LoanPaymentManager()
app.run()