Exemple #1
0
 def Checkout(self):
     if self.CurrentUser:
         FB.RemoveOtp(self.CurrentUser)
         Invoice.generate(self.Items, self.TotalAmount)
         FB.MoveCartToOrders(self.CurrentUser)
         #Clear Table For Checkout
         table = self.CreateEmptyTable()
         self.TBox.addWidget(table)
         self.TotalVal.setText("INR 0")
         self.WeightVal.setText("0 g")
         self.TotalVal.adjustSize()
         self.WeightVal.adjustSize()
Exemple #2
0
 def charge(self, vmcountdict, groupname, dbname):
     """
     Charge the user for OpenStack inventory
     :param vmcountdict:
     :type vmcountdict:
     :param groupname:
     :type groupname:
     :param dbname:
     :type dbname:
     :return:
     :rtype:
     """
     i = Invoice()
     price = i.calculate_price(vmcountdict)
     self.interpreterServer.updateBalance(dbname, groupname, price)
Exemple #3
0
 def charge(self, vmcountdict, groupname, dbname):
     """
     Charge the user for OpenStack inventory
     :param vmcountdict:
     :type vmcountdict:
     :param groupname:
     :type groupname:
     :param dbname:
     :type dbname:
     :return:
     :rtype:
     """
     i = Invoice()
     price = i.calculate_price(vmcountdict)
     self.interpreterServer.updateBalance(dbname, groupname, price)
Exemple #4
0
def main():
#main function begins here
    try:
        
        products = Product() # create object products from class Product. Starts as blank dict.
        #'HD01': {'Name': 'Seagate HDD 80 GB', 'Units': 'PCS'},
        # 'HD02': {'Name': 'IBM HDD 60 GB', 'Units': 'PCS'},
        # 'INT01': {'Name': 'Intel Pentium IV 3.6 GHz', 'Units': 'PCS'}}
        
        create_product(products, "HD01", "Seagate HDD 80 GB", "PCS")
        create_product(products, "HD02", "IBM HDD 60 GB", "PCS")
        create_product(products, "INT01", "Intle Pentium IV 3.6 GHz", "PCS")
        create_product(products, "INT99", "Intle Pentium V 4.2 GHz", "PCS")
        report_list_products(products)
        waitKeyPress("Above are results for creating 4 products.")
        
        read_product(products, "HD01")
        read_product(products, "HD99") #error
        #correct the spelling error of "Intle":
        
        update_product(products, newName = "Intel Pentium IV 3.6 GHz", newUnits = "PCS",
                        code = "INT01")
        update_product(products, "INT99", "Intel Pentium V 4.2 GHz", "PCS")
        report_list_products (products)
        waitKeyPress("Results after 2 reads, 2 updates to correct Intle spelling.")
        
        delete_product(products, "INT33") #error
        delete_product(products, "INT99")
        report_list_products(products)
        waitKeyPress("Results after deleting INT33 (not exist error) and INT99.")
        
        # pretty print a dictionary (in helper functions):
        #printDictData(products.dict)
        #waitKeyPress("Above is dictionary printed in better format.")

        # pretty print in column format a dictionary (in helper functions):
        #printDictInCSVFormat(products.dict, ('Code',), ('Name', 'Units'))
        #waitKeyPress("Above is dictionary printed in csv format for copy/paste to excel.")
        
        customers = Customer()
        create_customer(customers, "Sam", "Sam Co., Ltd.", "122 Bangkok", 500000, "Thailand")
        create_customer(customers, "CP", "Charoen Pokaphan", "14 Sukhumvit, Bangkok", 2000000, "Thailand")

        report_list_all_customers(customers)
        waitKeyPress("Above are results for creating 2 customers.")
        
        read_customer(customers, "IT City")#error
        read_customer(customers, "Sam")
        update_customer(customers, newCustomerName = "CPALL", newAddress = "123 Bangkok", newCreditLimit = 100000, newCountry = "Thailand", customerCode = "CP")
        delete_customer(customers, "CP1")#not found
        #delete_customer(customers, "CP")
        report_list_all_customers(customers)
        waitKeyPress("Results after 2 reads, and update and delete customer CP")
        
        invoices = Invoice()
        create_invoice(invoices, invoiceNo="INT100/20", invoiceDate="2020-01-02", customerCode="Sam", dueDate=None, invoiceLineTuplesList=[{"Product Code":"HD01","Quantity":2,"Unit Price":3000},{"Product Code":"HD02","Quantity":1,"Unit Price":2000}])
        create_invoice(invoices, "INT101/20", "2020-01-04", "CP", None, [{"Product Code":"HD02","Quantity":1,"Unit Price":2000}])
        report_list_all_invoices(invoices, customers, products)
        waitKeyPress("Above are results for creating 2 invoices and line item.")
        
        read_invoice(invoices, "INT100/20")
        
        update_invoice(invoices, invoiceNo="INT100/20", newInvoiceDate="2020-01-03", newCustomerCode="Sam", newDueDate=None, newInvoiceLineTuplesList=[{"Product Code":"HD01","Quantity":2,"Unit Price":3000},{"Product Code":"HD02","Quantity":1,"Unit Price":2000}])
        #delete_invoice(invoices, "INT101/20")
        report_list_all_invoices(invoices, customers, products)
        waitKeyPress("Results after read, update and delete Invoice")
        
        update_invoice_line(invoices, "INT100/20", "HD02", 8, 1000)
        report_list_all_invoices(invoices, customers, products)
        waitKeyPress("Results after update Invoice Line Item")

        #delete_invoice_line(invoices, "INT101/20", "HD02")
        report_list_all_invoices(invoices, customers, products)
        waitKeyPress("Results after delete Invoice Line Item")
        
        #print ("\nTest Report")
        report_products_sold(invoices, products, '2020-01-01', '2020-01-31')
        
        report_customer_products_sold_list(invoices, products, customers, '2020-01-01', '2020-01-31')
        
        report_customer_products_sold_total(invoices, products, customers, '2020-01-01', '2020-01-31') 
        
    except: #this traps for unexpected system errors
        print ("Unexpected error:", sys.exc_info()[0])
        raise # this line can be erased. It is here to raise another error so you can see which line to debug.
    else:
        print("Normal Termination.   Goodbye!")
Exemple #5
0
import Employee, Product, Sale, Customer, Vendor, Invoice
from secret_data import PASSWORD, USER_NAME, HOSTNAME
import mysql.connector
import datetime

from mysql.connector import ProgrammingError

emp_connector = Employee.Employee(USER_NAME, PASSWORD, HOSTNAME)
prod_connector = Product.Product(USER_NAME, PASSWORD, HOSTNAME)
sale_handler = Sale.Sale(USER_NAME, PASSWORD, HOSTNAME)
cust_connector = Customer.Customer(USER_NAME, PASSWORD, HOSTNAME)
vend_connector = Vendor.Vendor(USER_NAME, PASSWORD, HOSTNAME)
invoice_connector = Invoice.Invoice(USER_NAME, PASSWORD, HOSTNAME)


def debug_reset():
    # added for debugging purposes to reset the database to master without having to open MySQL
    # can still be called by running the hidden command 'R' in the main menu

    # read the script and clean it up
    with open('reset.sql', 'r') as reset:
        commands = reset.read().split(';\n')
    # connect to mysql and execute
    with mysql.connector.connect(host=HOSTNAME,
                                 user=USER_NAME,
                                 password=PASSWORD) as mysql_connection:
        with mysql_connection.cursor() as mysql_cursor:
            mysql_cursor.execute('drop database if exists shapes_r_us')
            for line in commands:
                mysql_cursor.execute(line.strip())
            mysql_connection.commit()
Exemple #6
0
def main():
#main function begins here
    try:
        
        products = Product() # create object products from class Product. Starts as blank dict.
        #'HD01': {'Name': 'Seagate HDD 80 GB', 'Units': 'PCS'},
        # 'HD02': {'Name': 'IBM HDD 60 GB', 'Units': 'PCS'},
        # 'INT01': {'Name': 'Intel Pentium IV 3.6 GHz', 'Units': 'PCS'}}

        create_product(products, "HD01", "Seagate HDD 80 GB", "PCS")
        create_product(products, "HD02", "IBM HDD 60 GB", "PCS")
        create_product(products, "INT01", "Intle Pentium IV 3.6 GHz", "PCS")
        create_product(products, "INT99", "Intle Pentium V 4.2 GHz", "PCS")
        report_list_products(products)
        waitKeyPress("Above are results for creating 4 products.")
        
        read_product(products, "HD01")
        read_product(products, "HD99") #error
        #correct the spelling error of "Intle":
        update_product(products, newName = "Intel Pentium IV 3.6 GHz", newUnits = "PCS",
                        code = "INT01")
        update_product(products, "INT99", "Intel Pentium V 4.2 GHz", "PCS")
        report_list_products (products)
        waitKeyPress("Results after 2 reads, 2 updates to correct Intle spelling.")

        delete_product(products, "INT33") #error
        delete_product(products, "INT99")
        report_list_products(products)
        waitKeyPress("Results after deleting INT33 (not exist error) and INT99.")

        # pretty print a dictionary (in helper functions):
        printDictData(products.dict)
        waitKeyPress("Above is dictionary printed in better format.")

        # pretty print in column format a dictionary (in helper functions):
        printDictInCSVFormat(products.dict, ('Code',), ('Name', 'Units'))
        waitKeyPress("Above is dictionary printed in csv format for copy/paste to excel.")

        """
        #shows in case of untrapped exception:
        result = products.dict["HDD5"]
        waitKeyPress("There will be error and exit before you see this.")
        """

        customers = Customer()
        create_customer(customers, "Sam", "Sam Co., Ltd.", "122 Bangkok", 500000, "Thailand")
        create_customer(customers, "CP", "Charoen Pokaphan", "14 Sukhumvit, Bangkok", 2000000, "Thailand")
        report_list_all_customers(customers)
        waitKeyPress("Above are results for creating 2 customers.")
        
        read_customer(customers, "IT City")#error
        read_customer(customers, "Sam")
        update_customer(customers, newCustomerName = "CPALL", newAddress = "123 Bangkok", newCreditLimit = 100000, newCountry = "Thailand", customerCode = "CP")
        delete_customer(customers, "CP1")#not found
        #delete_customer(customers, "CP")
        report_list_all_customers(customers)
        waitKeyPress("Results after 2 reads, and update and delete customer CP")

        
        invoices = Invoice()
        create_invoice(invoices, invoiceNo="INT100/20", invoiceDate="2020-01-02", customerCode="Sam", dueDate=None, invoiceLineTuplesList=[{"Product Code":"HD01","Quantity":2,"Unit Price":3000},{"Product Code":"HD02","Quantity":1,"Unit Price":2000}])
        create_invoice(invoices, "INT101/20", "2020-01-04", "CP", None, [{"Product Code":"HD02","Quantity":1,"Unit Price":2000}])
        report_list_all_invoices(invoices, customers, products)
        waitKeyPress("Above are results for creating 2 invoices and line item.")
        
        read_invoice(invoices, "INT100/20")
        update_invoice(invoices, invoiceNo="INT100/20", newInvoiceDate="2020-01-03", newCustomerCode="Sam", newDueDate=None, newInvoiceLineTuplesList=[{"Product Code":"HD01","Quantity":2,"Unit Price":3000},{"Product Code":"HD02","Quantity":1,"Unit Price":2000}])
        #delete_invoice(invoices, "INT101/19")
        report_list_all_invoices(invoices, customers, products)
        waitKeyPress("Results after read, update and delete Invoice")

        
        update_invoice_line(invoices, "INT100/20", "HD02", 8, 1000)
        report_list_all_invoices(invoices, customers, products)
        waitKeyPress("Results after update Invoice Line Item")

        #delete_invoice_line(invoices, "INT101/20", "HD02")
        report_list_all_invoices(invoices, customers, products)
        waitKeyPress("Results after delete Invoice Line Item")

        #Test receipt functions
        receipts = Receipt()
        #Create receipt
        create_receipt(receipts,'RCT1001/20','2020-02-04','CP','Cash','Nothing','Paid all invoices partially',[{'Invoice No':'INT100/20','Amount Paid Here':100},{'Invoice No':'INT101/20','Amount Paid Here':200}])
        create_receipt(receipts,'RCT1002/20','2020-02-05','Sam','Credit Card','Master Card, Citibank','Partially paid on INT101/20',[{'Invoice No':'INT100/20','Amount Paid Here':8560},{'Invoice No':'INT101/20','Amount Paid Here':1440}])
        create_receipt(receipts,'RCT1003/20','2020-02-06','CP','Debit Card','Debit Card','This will later be deleted',[{'Invoice No':'INT100/20','Amount Paid Here':10},{'Invoice No':'INT101/20','Amount Paid Here':20}])
        report_list_all_receipt(receipts,invoices,customers)
        waitKeyPress("Results of creating 3 receipts: RCT1001/20, RCT1002/20, and RCT1003/20")
        
        #Read receipt
        read_receipt(receipts,'RCT1001/20')
        read_receipt(receipts,'RCT1003/20')
        read_receipt(receipts,'RCT1005/20')
        report_list_all_receipt(receipts,invoices,customers)
        waitKeyPress("Results of reading 3 receipts: RCT1001/20 (successfully), RCT1003/20 (successfully), and RCT1005/20 (unsuccessfully)")
        
        #Update receipt
        update_receipt(receipts,'RCT1002/20','2020-02-06','Sam','Debit Card','VISA card','Partially paid on INT100/20 and INT101/20',[{'Invoice No':'INT100/20','Amount Paid Here':8000},{'Invoice No':'INT101/20','Amount Paid Here':1400}])
        update_receipt(receipts,'RCT1004/20','1999-12-31','Sam','Credit Card','Master Card, Citibank','Partially paid on INT101/20',[{'Invoice No':'INT100/20','Amount Paid Here':8560},{'Invoice No':'INT101/20','Amount Paid Here':1440}])
        report_list_all_receipt(receipts,invoices,customers)
        waitKeyPress("Results of updating 2 receipts: RCT1002/20 (successfully) and RCT1004/20 (unsuccessfully)")
        
        #Delete receipt
        delete_receipt(receipts,'RCT1003/20')
        delete_receipt(receipts,'RCT1005/20')
        report_list_all_receipt(receipts,invoices,customers)
        waitKeyPress("Results of deleting 2 receipts: RCT1003/20 (successfully) and RCT1005/20 (unsuccessfully)")

        #Report unpaid invoice 1
        report_unpaid_invoices(invoices,customers,receipts)
        waitKeyPress("Report unpaid invoice 1")

        #Update receipt line
        update_receipt_line(receipts,'RCT1001/20','INT100/20',200)
        update_receipt_line(receipts,'RCT1005/20','INT100/20',2000)
        update_receipt_line(receipts,'RCT1001/20','INT103/20',5000)
        report_list_all_receipt(receipts,invoices,customers)
        waitKeyPress("Result of updating 3 receipt line, first successfully, others unsuccessfully")

        #Delete receipt line
        delete_receipt_line(receipts,'RCT1001/20','INT101/20')
        delete_receipt_line(receipts,'RCT1003/20','INT100/20')
        delete_receipt_line(receipts,'RCT1001/20','INT103/20')
        report_list_all_receipt(receipts,invoices,customers)
        waitKeyPress("Result of deleting 3 receipt line, first successfully, others unsuccessfully")

        #print ("\nTest Report")
        #report_products_sold(invoices, products, '2020-01-01', '2020-01-31')
        #report_customer_products_sold_list(invoices, products, customers, '2020-01-01', '2020-01-31')
        #report_customer_products_sold_total(invoices, products, customers, '2020-01-01', '2020-01-31')
        report_unpaid_invoices(invoices,customers,receipts)
        
    except: #this traps for unexpected system errors
        print ("Unexpected error:", sys.exc_info()[0])
        raise # this line can be erased. It is here to raise another error so you can see which line to debug.
    else:
        print("Normal Termination.   Goodbye!")
Exemple #7
0
def main():
    try:

        invoices = Invoice()
        receipts = Receipt()
        create_receipt(receipts, "RCT1002/20", "Sam", "2020-02-05", "CC",
                       "Master Card, Citibank", "Partially paid on IN101/20",
                       [{
                           "invoice_no": "INT100/20",
                           "aph": 8560.00
                       }, {
                           "invoice_no": "INT101/20",
                           "aph": 1440.00
                       }])
        report_list_all_receipt()
        waitKeyPress("Results after create receipt")

        read_receipt(receipts, "RCT1002/20")
        waitKeyPress("Results read receipt")

        update_receipt(receipts, "RCT1002/20", "Sam", "2020-02-05", "PP",
                       "Master Card, Citibank", "Partially paid on IN101/20",
                       [{
                           "invoice_no": "INT100/20",
                           "aph": 8560.00
                       }, {
                           "invoice_no": "INT101/20",
                           "aph": 1440.00
                       }])
        report_list_all_receipt()
        waitKeyPress("Results update receipt")

        update_receipt_line(receipts, "RCT1002/20", "INT100/20", 2000.00)
        report_list_all_receipt()
        waitKeyPress("Results update receipt line item")

        delete_receipt_line(receipts, "RCT1002/20", "INT100/20")
        report_list_all_receipt()
        waitKeyPress("Results delete receipt line item")

        delete_receipt(receipts, "RCT1002/20")
        report_list_all_receipt()
        waitKeyPress("Results delete receipt")

        create_receipt(receipts, "RCT1002/20", "Sam", "2020-02-05", "CC",
                       "Master Card, Citibank", "Partially paid on IN101/20",
                       [{
                           "invoice_no": "INT100/20",
                           "aph": 8560.00
                       }, {
                           "invoice_no": "INT101/20",
                           "aph": 1440.00
                       }])
        report_list_all_receipt()
        waitKeyPress("Results after create receipt")

        report_unpaid_invoices()
        waitKeyPress("Results after report unpaid invoice")

    except:
        print("Unexpected error:", sys.exc_info()[0])
        raise
    else:
        print("Normal Termination.   Goodbye!")
Exemple #8
0
def main():
    #main function begins here
    try:

        products = Product(
        )  # create object products from class Product. Starts as blank dict.
        #'HD01': {'Name': 'Seagate HDD 80 GB', 'Units': 'PCS'},
        # 'HD02': {'Name': 'IBM HDD 60 GB', 'Units': 'PCS'},
        # 'INT01': {'Name': 'Intel Pentium IV 3.6 GHz', 'Units': 'PCS'}}

        create_product(products, "HD01", "Seagate HDD 80 GB", "PCS")
        create_product(products, "HD02", "IBM HDD 60 GB", "PCS")
        create_product(products, "INT01", "Intle Pentium IV 3.6 GHz", "PCS")
        create_product(products, "INT99", "Intle Pentium V 4.2 GHz", "PCS")
        report_list_products(products)
        waitKeyPress("Above are results for creating 4 products.")
        """ 
        read_product(products, "HD01")
        read_product(products, "HD99") #error
        #correct the spelling error of "Intle":
        update_product(products, newName = "Intel Pentium IV 3.6 GHz", newUnits = "PCS",
                        code = "INT01")
        update_product(products, "INT99", "Intel Pentium V 4.2 GHz", "PCS")
        report_list_products (products)
        waitKeyPress("Results after 2 reads, 2 updates to correct Intle spelling.")

        delete_product(products, "INT33") #error
        delete_product(products, "INT99")
        report_list_products(products)
        waitKeyPress("Results after deleting INT33 (not exist error) and INT99.")

        # pretty print a dictionary (in helper functions):
        printDictData(products.dict)
        waitKeyPress("Above is dictionary printed in better format.")

        # pretty print in column format a dictionary (in helper functions):
        printDictInCSVFormat(products.dict, ('Code',), ('Name', 'Units'))
        waitKeyPress("Above is dictionary printed in csv format for copy/paste to excel.")

        
        #shows in case of untrapped exception:
        result = products.dict["HDD5"]
        waitKeyPress("There will be error and exit before you see this.")
        
        """
        customers = Customer()
        create_customer(customers, "Sam", "Sam Co., Ltd.", "122 Bangkok",
                        500000, "Thailand")
        create_customer(customers, "CP", "Charoen Pokaphan",
                        "14 Sukhumvit, Bangkok", 2000000, "Thailand")
        report_list_all_customers(customers)
        waitKeyPress("Above are results for creating 2 customers.")
        """
        read_customer(customers, "IT City")#error
        read_customer(customers, "Sam")
        #update_customer(customers, newCustomerName = "CPALL", newAddress = "123 Bangkok", newCreditLimit = 100000, newCountry = "Thailand", customerCode = "CP")
        #delete_customer(customers, "CP1")#not found
        #delete_customer(customers, "CP")
        report_list_all_customers(customers)
        waitKeyPress("Results after 2 reads, and update and delete customer CP")
        """

        invoices = Invoice()
        create_invoice(invoices,
                       invoiceNo="IN100/20",
                       invoiceDate="2020-01-02",
                       customerCode="Sam",
                       dueDate=None,
                       invoiceLineTuplesList=[{
                           "Product Code": "HD01",
                           "Quantity": 2,
                           "Unit Price": 3000
                       }, {
                           "Product Code": "HD02",
                           "Quantity": 1,
                           "Unit Price": 2000
                       }])
        create_invoice(invoices, "IN101/20", "2020-01-04", "Sam", None,
                       [{
                           "Product Code": "HD02",
                           "Quantity": 1,
                           "Unit Price": 2000
                       }])
        report_list_all_invoices(invoices, customers, products)
        waitKeyPress(
            "Above are results for creating 2 invoices and line item.")
        """
        read_invoice(invoices, "IN100/20")

        #print ("\nTest Report")
        report_products_sold(invoices, products, '2020-01-01', '2020-01-31')
        report_customer_products_sold_list(invoices, products, customers, '2020-01-01', '2020-01-31')
        report_customer_products_sold_total(invoices, products, customers, '2020-01-01', '2020-01-31')
        
        """

        #Create_receipt
        print("*" * 50, "Create", "*" * 50)
        receipt = Receipt()
        create_receipt(receipt, "RCT1002/20", '2020-02-05', "Sam",
                       "Credit Card", "Master Card, Citibank",
                       "Partially paid on IN101/20", [{
                           "Invoice No": 'IN100/20',
                           "Amount Paid Here": 8560
                       }, {
                           "Invoice No": 'IN101/20',
                           "Amount Paid Here": 1440
                       }])
        read_receipt(receipt, "RCT1002/20")
        print("")

        #update_receipt
        print("*" * 50, "Update", "*" * 50)
        update_receipt(receipt, "RCT1002/20", "2020-02-06", "Sam",
                       "Credit Card", "Master Card, Citibank",
                       "Partially paid on IN101/20", [{
                           "Invoice No": 'IN100/20',
                           "Amount Paid Here": 8560
                       }, {
                           "Invoice No": 'IN101/20',
                           "Amount Paid Here": 1440
                       }])
        read_receipt(receipt, "RCT1002/20")
        print("")

        #update_receipt_line
        print("*" * 50, "update_receipt_line ", "*" * 50)
        update_receipt_line(receipt, "RCT1002/20", "IN100/20", 8000)
        read_receipt(receipt, "RCT1002/20")
        print("")

        #delete_receipt_line
        print("*" * 50, "delete_receipt_line ", "*" * 50)
        delete_receipt_line(receipt, "RCT1002/20", "IN100/20")
        read_receipt(receipt, "RCT1002/20")
        print("")

        #delete_receipt
        print("*" * 50, "delete_receipt ", "*" * 50)
        delete_receipt(receipt, "RCT1002/20")
        report_list_all_receipt(receipt, invoices, customers)
        print("")

        #Create_receipt
        print("*" * 50, "Create receipt", "*" * 50)
        receipt = Receipt()
        create_receipt(receipt, "RCT1002/20", '2020-02-05', "Sam",
                       "Credit Card", "Master Card, Citibank",
                       "Partially paid on IN101/20", [{
                           "Invoice No": 'IN100/20',
                           "Amount Paid Here": 8560
                       }, {
                           "Invoice No": 'IN101/20',
                           "Amount Paid Here": 1440
                       }])
        read_receipt(receipt, "RCT1002/20")
        print("")

        #ข้อ 3
        print("*" * 50, "3 is report list all receipt", "*" * 50)
        report_list_all_receipt(receipt, invoices, customers)

        #ข้อ 4
        print("*" * 50, "4 is report unpaid invoices", "*" * 50)
        report_unpaid_invoices(invoices, customers, receipt)
        print("")

        waitKeyPress(
            "Above are results for creating 2 invoices and line item.")

    except:  #this traps for unexpected system errors
        print("Unexpected error:", sys.exc_info()[0])
        raise  # this line can be erased. It is here to raise another error so you can see which line to debug.
    else:
        print("Normal Termination.   Goodbye!")
def file():  #Creating a function to write a file
    a = str(random.randint(12000, 100000))
    d = str(datetime.datetime.now())
    Invoice.file_write(a, name, choice, d, t_price, discount_p, quantity_p)
Exemple #10
0
def main():
    #main function begins here
    try:
        products = Product()
        create_product(products, "HD01", "Seagate HDD 80 GB", "PCS")
        create_product(products, "HD02", "IBM HDD 60 GB", "PCS")
        create_product(products, "INT01", "Intel Pentium IV 3.6 GHz", "PCS")
        report_list_products(products)
        waitKeyPress("These are 3 products in the database")

        customers = Customer()
        create_customer(customers, "Sam", "Sam Co., Ltd.", "122 Bangkok",
                        500000, "Thailand")
        create_customer(customers, "CP", "CPALL", "123 Bangkok", 100000,
                        "Thailand")
        report_list_all_customers(customers)
        waitKeyPress("These are 2 customers in the database")

        invoices = Invoice()
        create_invoice(invoices,
                       invoiceNo="INT100/20",
                       invoiceDate="2020-01-03",
                       customerCode="Sam",
                       dueDate=None,
                       invoiceLineTuplesList=[{
                           "Product Code": "HD01",
                           "Quantity": 2,
                           "Unit Price": 3000
                       }, {
                           "Product Code": "HD02",
                           "Quantity": 8,
                           "Unit Price": 1000
                       }])
        create_invoice(invoices, "INT101/20", "2020-01-04", "CP", None,
                       [{
                           "Product Code": "HD02",
                           "Quantity": 1,
                           "Unit Price": 2000
                       }])
        create_invoice(invoices, "INT102/20", "2020-01-04", "CP", None,
                       [{
                           "Product Code": "HD02",
                           "Quantity": 1,
                           "Unit Price": 2500
                       }])
        report_list_all_invoices(invoices, customers, products)
        waitKeyPress("These are 2 invoices in the database")
        delete_invoice(invoices, "INT104/20")
        delete_invoice(invoices, "INT105/20")

        receipts = Receipt()
        create_receipt(receipts, 'RCT1001/20', '2020-02-04', 'CP', 'Cash',
                       'Nothing', 'Paid all invoices partially',
                       [{
                           'Invoice No': 'INT100/20',
                           'Amount Paid Here': 100
                       }, {
                           'Invoice No': 'INT101/20',
                           'Amount Paid Here': 200
                       }])
        create_receipt(receipts, 'RCT1002/20', '2020-02-05', 'Sam',
                       'Credit Card', 'Master Card, Citibank',
                       'Partially paid on INT101/20', [{
                           'Invoice No': 'INT100/20',
                           'Amount Paid Here': 8560
                       }, {
                           'Invoice No': 'INT101/20',
                           'Amount Paid Here': 1440
                       }])
        create_receipt(receipts, 'RCT1003/20', '2020-02-06', 'CP',
                       'Debit Card', 'Debit Card',
                       'This will later be deleted', [{
                           'Invoice No': 'INT100/20',
                           'Amount Paid Here': 10
                       }, {
                           'Invoice No': 'INT102/20',
                           'Amount Paid Here': 1000
                       }])
        report_list_all_receipts(receipts, invoices, customers)
        waitKeyPress(
            "Results of creating 3 receipts: RCT1001/20, RCT1002/20, and RCT1003/20"
        )

        #Read receipt
        read_receipt(receipts, 'RCT1003/20')
        read_receipt(receipts, 'RCT1005/20')
        report_list_all_receipts(receipts, invoices, customers)
        waitKeyPress(
            "Results of reading 2 receipts: RCT1003/20 (successfully), and RCT1005/20 (unsuccessfully)"
        )

        #Update receipt
        update_receipt(receipts, 'RCT1002/20', '2020-02-06', 'Sam',
                       'Debit Card', 'VISA card',
                       'Partially paid on INT100/20 and INT101/20',
                       [{
                           'Invoice No': 'INT100/20',
                           'Amount Paid Here': 8000
                       }, {
                           'Invoice No': 'INT101/20',
                           'Amount Paid Here': 1400
                       }])
        update_receipt(receipts, 'RCT1004/20', '1999-12-31', 'Sam',
                       'Credit Card', 'Master Card, Citibank',
                       'Partially paid on INT101/20', [{
                           'Invoice No': 'INT100/20',
                           'Amount Paid Here': 8560
                       }, {
                           'Invoice No': 'INT101/20',
                           'Amount Paid Here': 1440
                       }])
        report_list_all_receipts(receipts, invoices, customers)
        waitKeyPress(
            "Results of updating 2 receipts: RCT1002/20 (successfully) and RCT1004/20 (unsuccessfully)"
        )

        #Delete receipt
        delete_receipt(receipts, 'RCT1005/20')
        report_list_all_receipts(receipts, invoices, customers)
        waitKeyPress(
            "Results of deleting 2 receipts: RCT1003/20 (successfully) and RCT1005/20 (unsuccessfully)"
        )

        #Report unpaid invoice 1
        report_unpaid_invoices(invoices, customers, receipts)
        waitKeyPress("Report unpaid invoice 1")

        #Update receipt line
        update_receipt_line(receipts, 'RCT1001/20', 'INT100/20', 200)
        update_receipt_line(receipts, 'RCT1005/20', 'INT100/20', 2000)
        update_receipt_line(receipts, 'RCT1001/20', 'INT103/20', 3000)
        report_list_all_receipts(receipts, invoices, customers)
        waitKeyPress(
            "Result of updating 3 receipt line, first successfully, others unsuccessfully"
        )

        #Delete receipt line
        delete_receipt_line(receipts, 'RCT1001/20', 'INT101/20')
        delete_receipt_line(receipts, 'RCT1003/20', 'INT100/20')
        delete_receipt_line(receipts, 'RCT1001/20', 'INT103/20')
        report_list_all_receipts(receipts, invoices, customers)
        waitKeyPress(
            "Result of deleting 3 receipt line, first successfully, others unsuccessfully"
        )

        #print ("\nTest Report")
        #report_products_sold(invoices, products, '2020-01-01', '2020-01-31')
        #report_customer_products_sold_list(invoices, products, customers, '2020-01-01', '2020-01-31')
        #report_customer_products_sold_total(invoices, products, customers, '2020-01-01', '2020-01-31')
        report_unpaid_invoices(invoices, customers, receipts)

    except:  #this traps for unexpected system errors
        print("Unexpected error:", sys.exc_info()[0])
        raise  # this line can be erased. It is here to raise another error so you can see which line to debug.
    else:
        print("Normal Termination.   Goodbye!")
Exemple #11
0
def invoice():
    invoice = Invoice()
    return invoice
Exemple #12
0
def test_CanCalc():
    invoice = Invoice()
    invoice.totalImpure(products)
    assert invoice.totalImpure(products) == 75
Exemple #13
0
def test_CanFind_InvoiceClass():
    invoice = Invoice()