Пример #1
0
 def __init__(self,
              customer_name='',
              phone_number='',
              shipping_address='',
              billing_address='',
              delivery_date='',
              payment_method='',
              payment_date='',
              shipping_fee='',
              tax_rate='',
              items='',
              customer_id=''):
     self.order_id = Common.generate_id()
     self.transaction_date = Common.set_date(Date.today())
     self.customer_name = customer_name
     self.phone_number = phone_number
     self.shipping_address = shipping_address
     self.billing_address = billing_address
     self.tracking_id = Common.generate_tracking_number()
     self.delivery_status = "Pending"
     self.delivery_date = delivery_date
     self.payment_date = payment_date
     self.payment_status = "Pending"
     self.payment_method = payment_method
     self.shipping_fee = shipping_fee
     self.tax_rate = tax_rate
     self.items = items
     self.customer_id = customer_id
     self.sub_total = 0.00
     self.number_of_items = 0
Пример #2
0
    def display_list(self, products):
        response = list()

        for product in products:
            original_price = Common.get_currency(product["original_price"])
            price = Common.get_currency(product["price"])
            discount = Common.get_discount(product["discount_rate"])

            data = {
                "id": product["product_id"],
                "name": product["name"],
                "original_price": original_price,
                "discount": discount,
                "price": price
            }

            response.append(data)

        return response
Пример #3
0
    def display_details(self, product):
        original_price = Common.get_currency(product["original_price"])
        price = Common.get_currency(product["price"])
        discount = Common.get_discount(product["discount_rate"])

        return {
            "name": product["name"],
            "description": product["description"],
            "product_type": product["product_type"],
            "brand": product["brand"],
            "model": product["model"],
            "warranty_period": product["warranty_period"],
            "warranty_type": product["warranty_type"],
            "inside_box": product["inside_box"],
            "images": product["images"],
            "original_price": original_price,
            "discount": discount,
            "price": price
        }
Пример #4
0
    def display_list(self, orders):
        response = list()

        for order in orders:
            total = Common.get_currency(order["total"])
            payment_date = Common.get_date(order["payment_date"])
            delivery_date = Common.get_date(order["delivery_date"])

            data = {
                "order_id": order["order_id"],
                "transaction_date": order["transaction_date"],
                "delivery_status": order["delivery_status"],
                "delivery_date": delivery_date,
                "payment_date": payment_date,
                "payment_status": order["payment_status"],
                "total": total
            }

            response.append(data)

        return response
Пример #5
0
 def __init__(self,
              email='',
              password='',
              first_name='',
              middle_name='',
              last_name='',
              phone_number='',
              billing_address='',
              shipping_address=''):
     self.customer_id = Common.generate_id()
     self.email = email
     self.password = password
     self.first_name = first_name
     self.middle_name = middle_name
     self.last_name = last_name
     self.phone_number = phone_number
     self.billing_address = billing_address
     self.shipping_address = shipping_address
     self.middle_initial = ''
     self.full_name = ''
Пример #6
0
    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
            }
        }
Пример #7
0
from api.v1.common import Common

import bcrypt
from validate_email import validate_email

customers = []
Common = Common()


class Customer:
    def __init__(self,
                 email='',
                 password='',
                 first_name='',
                 middle_name='',
                 last_name='',
                 phone_number='',
                 billing_address='',
                 shipping_address=''):
        self.customer_id = Common.generate_id()
        self.email = email
        self.password = password
        self.first_name = first_name
        self.middle_name = middle_name
        self.last_name = last_name
        self.phone_number = phone_number
        self.billing_address = billing_address
        self.shipping_address = shipping_address
        self.middle_initial = ''
        self.full_name = ''
Пример #8
0
    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
Пример #9
0
 def find_by_item(self, item_id, cart):
     item = Common.filter_result('item_id', item_id, cart["items"])
     return next(item, None)
Пример #10
0
 def find_by_name(self, products, _name):
     product_name = _name.replace('_', ' ')
     product = Common.filter_result('name', product_name, products)
     return next(product, None)
Пример #11
0
 def find_by(self, _id):
     orders = self.find_all()
     order = Common.filter_result('order_id', _id, orders)
     return next(order, None)
Пример #12
0
 def search_by(self, customer_id, order_id):
     customer_orders = self.find_by_customer(customer_id)
     order = Common.filter_result('order_id', order_id, customer_orders)
     return next(order, None)
Пример #13
0
 def find_by_customer(self, _id):
     orders = self.find_all()
     customer_orders = Common.filter_result('customer_id', _id, orders)
     return list(customer_orders)
Пример #14
0
 def find_by(self, _id):
     customers = self.find_all()
     if customers:
         customer = Common.filter_result('customer_id', _id, customers)
         return next(customer, None)
     return None
Пример #15
0
 def find_by_customer(self, customer_id):
     carts = self.find_all()
     customer = Common.filter_result('customer_id', customer_id, carts)
     return next(customer, None)
Пример #16
0
 def find_by_email(self, _email):
     customers = self.find_all()
     if customers:
         customer = Common.filter_result('email', _email, customers)
         return next(customer, None)
     return None
Пример #17
0
 def find_by(self, products, _id):
     product = Common.filter_result('product_id', _id, products)
     return next(product, None)