Exemple #1
0
def getOnlyProductsSKU():
    productSKU = []
    products = Product.getProductList()
    for row in products:
        productSKU.append (row[0])
       # quote = quote + str(key) + "    " + products[key].name + "\n"
    return productSKU
Exemple #2
0
def getAllProductsNames():
    productNames = {}
    products = Product.getProductList()
    quote ="Product SKU      NAME\n"
    for row in products:
        quote = quote + row[0] + "    " +  row[1] + "\n"
       # quote = quote + str(key) + "    " + products[key].name + "\n"
    return quote
Exemple #3
0
def addSale(customerID , productSKU , cc , amount):
        customerID = str(customerID).split(' ', 1)[0]
        productSKU = str(productSKU).split(' ' ,1)[0]
        #Do some logic here and then send it to Sale(Product,PayMethod,Customer , total)
        result = {}
        result['error'] = False
        result['message'] = ""

        #Get the customer
        customer = Customer.searchCustomerByID(customerID)
        if(customer == False):
             customer = Customer.searchCustomerByID(0)

        #Get the product
        productSKU = int(productSKU)


        #pass the product row to the Sale module
        product = Product.getProductBySKU(productSKU)
        if(product != False and str(amount) != ""):
            total = int(amount) * product[2]
        else:
            result['error'] = True
            if(product == False):
                result['message'] = " Wrong SKU "
            else:
                result['message'] ="NO Amount :( a unicorn just died </3"

        if(cc==1):
            payMethod = "Credit Card"
        else:
            payMethod = "Cash"

        #Create the Sale object
        if(result['error'] != True):
            Sale(product , payMethod , customer , total)
            result['message'] = "Sale Added Successfuly. VIVAAA Pythunicorns"
            return result
        else:
            return result