def display_cart(self, cart): itemData = list() items = cart["items"] for item in items: sub_total = Common.get_currency(item["sub_total"]) price = Common.get_currency(item["price"]) original_price = Common.get_currency(item["original_price"]) discount = Common.get_discount(item["discount_rate"]) quantity = Common.get_whole_number(item["quantity"]) data = { "item_id": item["item_id"], "name": item["name"], "description": item["description"], "brand": item["brand"], "model": item["model"], "warranty_period": item["warranty_period"], "warranty_type": item["warranty_type"], "images": item["images"], "quantity": quantity, "original_price": original_price, "discount": discount, "price": price, "sub_total": sub_total } itemData.append(data) tax_rate = Common.get_tax(cart["tax_rate"] * 100) tax_amount = Common.get_currency(cart["tax_amount"]) total = Common.get_currency(cart["total"]) sub_total = Common.get_currency(cart["sub_total"]) number_of_items = Common.get_whole_number(cart["number_of_items"]) shipping_fee = Common.get_currency(cart["shipping_fee"]) response = { "items_count": len(items), "items": itemData, "order_summary": { "sub_total": sub_total, "number_of_items": number_of_items, "shipping_fee": shipping_fee, "tax_rate": tax_rate, "tax_amount": tax_amount, "total": total } } return response
def display_details(self, order): tax_rate = Common.get_tax(order["tax_rate"]) tax_amount = Common.get_currency(order["tax_amount"]) total = Common.get_currency(order["total"]) sub_total = Common.get_currency(order["sub_total"]) shipping_fee = Common.get_currency(order["shipping_fee"]) payment_date = Common.get_date(order["payment_date"]) delivery_date = Common.get_date(order["delivery_date"]) return { "orders": { "order_id": order["order_id"], "transaction_date": order["transaction_date"], "payment_date": payment_date, "payment_method": order["payment_method"], "payment_status": order["payment_status"], "items": order["items"] }, "delivery_info": { "tracking_id": order["tracking_id"], "delivery_status": order["delivery_status"], "delivery_date": delivery_date, }, "customer_info": { "customer_name": order["customer_name"], "phone_number": order["phone_number"], "shipping_address": order["shipping_address"], "billing_address": order["billing_address"] }, "order_summary": { "number_of_items": order['number_of_items'], "sub_total": sub_total, "shipping_fee": shipping_fee, "tax_rate": tax_rate, "tax_amount": tax_amount, "total": total } }