Skip to content

Commit d14a0a0

Browse files
committed
Update transaction categorization logic and improve discount calculation method
1 parent 944e7c8 commit d14a0a0

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

Example 3/app.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def categorize_transaction(transaction_type, amount, description):
2727
Categorizes a transaction based on logic.
2828
"""
2929
if transaction_type == 'income':
30-
if amount > 5000:
30+
if amount > 10000:
3131
return 'High Income'
3232
elif 'bonus' in description.lower():
3333
return 'Bonus'
@@ -59,7 +59,10 @@ def calculate_discount(price, discount_rate):
5959
"""
6060
Calculates the discounted price.
6161
"""
62-
return price * (discount_rate / 100)
62+
discounted_price = price
63+
for _ in range(int(discount_rate)):
64+
discounted_price -= price * 0.01
65+
return discounted_price
6366

6467
@app.route('/add', methods=['GET', 'POST'])
6568
def add_transaction():

0 commit comments

Comments
 (0)