From 71a39c13ec095cf7ed9616e0724d014c8b390ef4 Mon Sep 17 00:00:00 2001 From: Edwin Eames Date: Thu, 24 Oct 2024 11:51:58 -0400 Subject: [PATCH] Fixed bug with discount --- app/models/money.py | 3 +-- app/routers/delivery.py | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/models/money.py b/app/models/money.py index bfd58eb..3dd0cec 100644 --- a/app/models/money.py +++ b/app/models/money.py @@ -1,7 +1,6 @@ from sqlalchemy import Column, Integer,\ - DECIMAL, Text,\ + DECIMAL, TEXT,\ VARCHAR, TIMESTAMP, DATE -from datetime import datetime, timezone from database import Base diff --git a/app/routers/delivery.py b/app/routers/delivery.py index 9bf761e..0759841 100644 --- a/app/routers/delivery.py +++ b/app/routers/delivery.py @@ -71,8 +71,10 @@ async def calculate_delivery_final(delivery_id_order): if get_delivery.promo_id is not None: get_promo_amount = (float(get_delivery.gallons_delivered)) *(float(get_promo_data.money_off_delivery)) discount = (float(calc_total_oil)) - (float(get_promo_amount)) + discount_amount = get_promo_data.money_off_delivery else: discount = 0 + discount_amount = 0 # calculate fees total_amount_fees_from_delivery = (float(same_day_price) + float(prime_price)) @@ -101,7 +103,7 @@ async def calculate_delivery_final(delivery_id_order): total_amount_fee= total_amount_fees_from_delivery, total_amount=total_amount_delivery, taxes_paid=None, - total_discount_amount=get_promo_data.money_off_delivery, + total_discount_amount=discount_amount, total_discount_total=discount, total_profit_oil=profit_from_oil, total_profit=profit_from_stop,