Exemplo n.º 1
0
def getOnlyCustomersID():
    customersID = []
    customers = Customer.getCustomerList()
    for row in customers:
        customersID.append (row[0])
       # quote = quote + str(key) + "    " + products[key].name + "\n"
    return customersID
Exemplo n.º 2
0
def getAllCustomersNames():
    customerNames = {}
    customers = Customer.getCustomerList()
    quote ="USER ID      NAME\n"
    for row in customers:
        quote = quote + row[0] + "    " +  row[1] +  "\n"
        #quote = quote + str(key) + "    " +  customers[key].customerName +  "\n"
    return quote
Exemplo n.º 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