summaryrefslogtreecommitdiff
path: root/indoteknik_api/controllers/api_v1
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2023-07-20 10:42:32 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2023-07-20 10:42:32 +0700
commit7b76facc6b7fdbff83a98a1b3251f1d3dad48937 (patch)
treecca89faa184b6b1162e418fc08b39448c6a40176 /indoteknik_api/controllers/api_v1
parentc7389ec4ab18ee7ad993f1ec4d29da9d677ee431 (diff)
Add get_user_checkout on user cart
Diffstat (limited to 'indoteknik_api/controllers/api_v1')
-rw-r--r--indoteknik_api/controllers/api_v1/sale_order.py21
1 files changed, 1 insertions, 20 deletions
diff --git a/indoteknik_api/controllers/api_v1/sale_order.py b/indoteknik_api/controllers/api_v1/sale_order.py
index 8135da33..29649315 100644
--- a/indoteknik_api/controllers/api_v1/sale_order.py
+++ b/indoteknik_api/controllers/api_v1/sale_order.py
@@ -236,26 +236,7 @@ class SaleOrder(controller.Controller):
@controller.Controller.must_authorized(private=True, private_key='user_id')
def get_user_checkout_so(self, user_id):
cart = request.env['website.user.cart']
- products = cart.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
- 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,
- 'subtotal': subtotal,
- 'tax': tax,
- 'grand_total': round(grand_total),
- 'total_weight': {
- 'kg': total_weight,
- 'g': total_weight * 1000
- },
- 'has_product_without_weight': any(not product.get('weight') or product.get('weight') == 0 for product in products),
- 'products': products
- }
+ result = cart.get_user_checkout(user_id)
return self.response(result)
@http.route(PREFIX_PARTNER + 'sale_order/checkout', auth='public', method=['POST', 'OPTIONS'], csrf=False)