Пример #1
0
 def create_individual(self):
     individual = Individual()
     individual.set_cnp(input("Cnp: "))
     individual.set_first_name(input("First Name: "))
     individual.set_last_name(input("Last Name: "))
     individual.set_phone_number(input("Phone Number: "))
     individual.set_email_address(input("Email Address: "))
     address = input("Give address: ")
     county = input("Give county: ")
     postal_code = input("Give postal code: ")
     country = input("Give country: ")
     customer_address = Address()
     customer_address.set_address(address)
     customer_address.set_county(county)
     customer_address.set_country(country)
     customer_address.set_postal_code(postal_code)
     individual.set_address(address)
     return individual
Пример #2
0
 def test_service(self):
     service = Service("json_test.json", "json_test.json", "json_test.json",
                       "json_test.json")
     # Customer Options
     company = Company()
     address = Address()
     address.set_address("Strada Academiei nr. 7")
     address.set_county("Bucuresti")
     address.set_country("Romania")
     address.set_postal_code("010011")
     company.set_id(1)
     company.set_address(address)
     company.set_company_name("La Geani")
     company.set_registration_number("RO0123")
     company.set_fiscal_no("0000231523647")
     company.set_email_address("*****@*****.**")
     company.set_first_name("Ion")
     company.set_last_name("Bogdan")
     company.set_phone_number("0752314567")
     company.set_fiscal_no("0000012345678")
     company.set_registration_number("RO01923")
     service.create_customer(company)
     self.assertEqual(service.get_company_customer(1), company)
     company.set_company_name("Marketplex")
     service.modify_customer(1, company)
     self.assertEqual(service.get_company_customer(1), company)
     service.delete_customer(company)
     self.assertEqual(service.view_all_company_customer(), [])
     individual = Individual()
     individual.set_cnp("1971209075425")
     individual.set_id(1)
     individual.set_first_name("Petre")
     individual.set_last_name("Vasile")
     individual.set_phone_number("0745321784")
     individual.set_email_address("*****@*****.**")
     service.create_customer(individual)
     self.assertEqual(service.get_individual_customer(1), individual)
     individual.set_last_name("Gigel")
     service.modify_customer(1, individual)
     self.assertEqual(service.get_individual_customer(1), individual)
     service.delete_customer(individual)
     self.assertEqual(service.view_all_individual_customer(), [])
     individual.set_address(address)
     # Currency Options
     currency = Currency("$", "Dollar", "USD")
     currency.set_id(1)
     currency.set_exchange_rate(4.5)
     service.create_currency(currency)
     self.assertEqual(currency, service.get_currency(1))
     currency.set_exchange_rate(4.2)
     service.modify_currency(1, currency)
     self.assertEqual(currency, service.get_currency(1))
     service.delete_currency(1)
     self.assertEqual(service.view_currency(), [])
     # Item Options
     item = Item()
     item.set_id(1)
     item.set_currency(currency)
     item.set_name("McChicken")
     item.set_description("Chicken hamburger")
     item.set_price(2)
     item.set_discount(0)
     service.create_item(item)
     self.assertEqual(item, service.choose_item(1))
     item.set_price(3)
     service.modify_item(1, item)
     self.assertEqual(item, service.choose_item(1))
     service.delete_item(1)
     self.assertEqual(service.view_items(), [])
     # Bill Options
     bill_item = BillItem()
     bill_item.set_id(1)
     bill_item.set_currency(currency)
     bill_item.set_name("McChicken")
     bill_item.set_description("Chicken hamburger")
     bill_item.set_price(3)
     bill_item.set_discount(0)
     bill = Invoice()
     bill.set_customer(individual)
     bill.set_currency(currency)
     bill.set_items([bill_item])
     bill.set_id(1)
     bill.set_issuer(company)
     bill.set_issue_date("24.01.2021")
     bill.set_due_date("10.02.2021")
     bill.set_notes("Platiti la Banca Transilvania")
     service.create_item(item)
     service.create_bill(bill)
     self.assertEqual(service.get_invoice(1), bill)
     bill.set_notes("asdfge")
     service.modify_bill(1, bill)
     self.assertEqual(service.get_invoice(1), bill)
     service.add_item_to_bill(1, bill)
     bill.add_items(bill_item)
     self.assertEqual(service.get_invoice(1), bill)
     service.invoice_to_fiscal(1)
     fiscal_bill = FiscalBill()
     fiscal_bill.set_customer(individual)
     fiscal_bill.set_currency(currency)
     bill_item.set_quantity(2)
     fiscal_bill.set_total(3.0)
     fiscal_bill.set_items([bill_item])
     fiscal_bill.set_id(1)
     fiscal_bill.set_issuer(company)
     fiscal_bill.set_issue_date("24.01.2021")
     fiscal_bill.set_due_date("10.02.2021")
     fiscal_bill.set_notes("asdfge")
     self.assertEqual(fiscal_bill, service.get_fiscal(1))
     service.delete_bill(bill)
     file = open("json_test.json", "w")
     file.truncate(0)
     file.write("{}")
     file.close()