summaryrefslogtreecommitdiff
path: root/indoteknik_api/controllers/api_v1/sale_order.py
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2023-06-15 16:48:29 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2023-06-15 16:48:29 +0700
commitbc6bc85f455c4b8bc9f73b779b521faa5fcdcf96 (patch)
tree08c434bd0d6935945c95c81eae29b3b4c8aacafb /indoteknik_api/controllers/api_v1/sale_order.py
parent55c67c71b04fce80c635b3a58d91c8bcb02e17c8 (diff)
Update user cart model and API
Diffstat (limited to 'indoteknik_api/controllers/api_v1/sale_order.py')
-rw-r--r--indoteknik_api/controllers/api_v1/sale_order.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/indoteknik_api/controllers/api_v1/sale_order.py b/indoteknik_api/controllers/api_v1/sale_order.py
index 35361ba4..9df710ec 100644
--- a/indoteknik_api/controllers/api_v1/sale_order.py
+++ b/indoteknik_api/controllers/api_v1/sale_order.py
@@ -218,6 +218,26 @@ class SaleOrder(controller.Controller):
data = sale_order.id
return self.response(data)
+ @http.route(prefix + 'user/<user_id>/sale_order/checkout', auth='public', method=['GET', 'OPTIONS'], csrf=False)
+ @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'] for x in products)
+ total_discount = sum((x['price']['price'] - x['price']['price_discount']) for x in products)
+ subtotal = total_purchase - total_discount
+ tax = round(subtotal * 0.11)
+ grand_total = subtotal + tax
+ result = {
+ 'total_purchase': total_purchase,
+ 'total_discount': total_discount,
+ 'subtotal': subtotal,
+ 'tax': tax,
+ 'grand_total': round(grand_total),
+ 'products': products
+ }
+ return self.response(result)
+
@http.route(PREFIX_PARTNER + 'sale_order/checkout', auth='public', method=['POST', 'OPTIONS'], csrf=False)
@controller.Controller.must_authorized(private=True, private_key='partner_id')
def create_partner_sale_order(self, **kw):