summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models
diff options
context:
space:
mode:
Diffstat (limited to 'indoteknik_custom/models')
-rw-r--r--indoteknik_custom/models/website_user_cart.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/indoteknik_custom/models/website_user_cart.py b/indoteknik_custom/models/website_user_cart.py
index 802dbd37..29bf4291 100644
--- a/indoteknik_custom/models/website_user_cart.py
+++ b/indoteknik_custom/models/website_user_cart.py
@@ -45,17 +45,22 @@ class WebsiteUserCart(models.Model):
products = carts.get_products()
return products
- def get_user_checkout(self, user_id):
+ def get_user_checkout(self, user_id, voucher=False):
products = self.get_product_by_user(user_id=user_id, selected=True)
total_purchase = sum(x['price']['price'] * x['quantity'] for x in products)
total_discount = sum((x['price']['price'] - x['price']['price_discount']) * x['quantity'] for x in products)
subtotal = total_purchase - total_discount
+ discount_voucher = 0
+ if voucher:
+ discount_voucher = voucher.calculate_discount(subtotal)
+ subtotal -= discount_voucher
tax = round(subtotal * 0.11)
grand_total = subtotal + tax
total_weight = sum(x['weight'] * x['quantity'] for x in products)
result = {
'total_purchase': total_purchase,
'total_discount': total_discount,
+ 'discount_voucher': discount_voucher,
'subtotal': subtotal,
'tax': tax,
'grand_total': round(grand_total),