def try_total_payments(cust_num): total = get_total_payments_for_customer(cust_num) #print("payments for customer {} are {:.2f}".format(cust_num, total)) return total
import db_access_web import db_utility fmt = "{0:^10} {1:<35} {2:>15} {3:>15} {4:>20} {5:>20} " cust_num = "CustNum" cust_name = "Customer Name" pay = "Payments" ord = "Orders" lim = "Credit Limit" avail = "Available Credit" print(fmt.format(cust_num, cust_name, pay, ord, lim, avail)) cust = db_access_web.get_all_customers() for row in cust: cust_number = row["customerNumber"] customer_name = row["customerName"] credit_limit = float(row["creditLimit"]) total_payments = float(db_utility.get_total_payments_for_customer(cust_number)) total_orders = float(db_utility.get_total_orders_for_customer(cust_number)) available_credit = credit_limit + total_payments - total_orders if available_credit < 0: print(fmt.format(cust_number, customer_name, total_payments, total_orders, credit_limit, available_credit))
order = {'orderNumber': 0, 'orderDate': 1, 'requiredDate': 2, 'shippedDate': 3, 'status': 3, 'comments': 5, 'customerNumber': 6} order_details = {'orderNumber': 0, 'productCode': 1, 'quantityOrdered': 2, 'priceEach': 3, 'orderLineNumber': 4} customer_info = db_access.get_all_customers() while customer_info[row] is not None: for row in range(len(customer_info)): customer_number = row[0].format(row) customer_name = row[1].format(row) credit_limit = row[12].format(row) total_payments = db_utility.get_total_payments_for_customer(customer_number) total_orders = db_utility.get_total_orders_for_customer(customer_number) avail_credit = credit_limit + total_payments - total_orders fmt = "{0:<10} {1:<20} {2:<10} {3:<10} {4:<20} {5:<20} " cust_num = "CustNum" cust_name = "Customer Name" pay = "Payments" ord = "Orders" lim = "Credit Limit" avail = "Available Credit" print(fmt.format(cust_num, cust_name, pay, ord, lim, avail)) for row in customer_info: