コード例 #1
0
 def get_contract_from_zaznam(zaznam) -> Contract:
     """
     Extrahuje informace o smlouve jako celku.
     Vytvoří nový contract, do kteréhouloží všechny informace.
     :param zaznam: xml objekt, ze kterého chceme informace extrahovat
     :return: contract do kterého jsou doplněny všechny informace
     """
     contract = Contract()
     for attrib in zaznam:
         tag = ContractProviderRegistr.trim_tag_name(attrib.tag)
         if tag == "identifikator":
             contract = ContractProviderRegistr.get_identifikator_from_zaznam(
                 attrib, contract)
         elif tag == "odkaz":
             contract.link = attrib.text
         elif tag == "casZverejneni":
             contract.date_published = datetime.strptime(
                 attrib.text[0:19], '%Y-%m-%dT%H:%M:%S')
         elif tag == "smlouva":
             contract = ContractProviderRegistr.get_attributes_from_smlouva(
                 attrib, contract)
         elif tag == "prilohy":
             contract = ContractProviderRegistr.get_attachments_from_prilohy(
                 attrib, contract)
         elif tag == "platnyZaznam":
             contract.valid = attrib.text
         else:
             raise Exception(f"Unknown attribute in Zaznam: {tag}")
     return contract
コード例 #2
0
    def test_sanitize_contract_empty_values(self):
        test_case = ContractSanitizer.sanitize_contract(
            Contract(supplier_ico="",
                     supplier_name="",
                     ministry_ico="",
                     ministry_name=""))
        res = Contract(supplier_ico=None,
                       supplier_name=None,
                       ministry_ico=None,
                       ministry_name=None)
        self.assertEqual(res.supplier_name, test_case.supplier_name)
        self.assertEqual(res.supplier_ico, test_case.supplier_ico)
        self.assertEqual(res.ministry_name, test_case.ministry_name)
        self.assertEqual(res.ministry_ico, test_case.ministry_ico)

        test_case = ContractSanitizer.sanitize_contract(
            Contract(supplier_ico="",
                     supplier_name=None,
                     ministry_ico=None,
                     ministry_name=""))
        res = Contract(supplier_ico=None,
                       supplier_name=None,
                       ministry_ico=None,
                       ministry_name=None)
        self.assertEqual(res.supplier_name, test_case.supplier_name)
        self.assertEqual(res.supplier_ico, test_case.supplier_ico)
        self.assertEqual(res.ministry_name, test_case.ministry_name)
        self.assertEqual(res.ministry_ico, test_case.ministry_ico)
コード例 #3
0
 def test_sanitize_ministry_name_part(self):
     test_case = ContractSanitizer._sanitize_ministry_name(
         Contract(ministry_ico="00023671", ministry_name='Ministerstvo'))
     res = Contract(ministry_ico='00023671',
                    ministry_name='Ministerstvo kultury')
     self.assertEqual(res.ministry_name, test_case.ministry_name)
     self.assertEqual(res.ministry_ico, test_case.ministry_ico)
コード例 #4
0
 def test_sanitize_contract_names(self):
     test_case = ContractSanitizer.sanitize_contract(
         Contract(supplier_name="      Ministerstvo    kultury    ",
                  ministry_name="      Ministerstvo    vnitra     "))
     res = Contract(supplier_name="Ministerstvo kultury",
                    ministry_name="Ministerstvo vnitra")
     self.assertEqual(res.supplier_name, test_case.supplier_name)
     self.assertEqual(res.ministry_name, test_case.ministry_name)
コード例 #5
0
 def test_sanitize_ministry_name_with_additional_text(self):
     test_case = ContractSanitizer._sanitize_ministry_name(
         Contract(ministry_ico="00023671",
                  ministry_name='Česká republika - Ministerstvo kultury'))
     res = Contract(ministry_ico='00023671',
                    ministry_name='Ministerstvo kultury')
     self.assertEqual(res.ministry_name, test_case.ministry_name)
     self.assertEqual(res.ministry_ico, test_case.ministry_ico)
コード例 #6
0
    def test_sanitize_contract_icos(self):
        test_case = ContractSanitizer.sanitize_contract(Contract(supplier_ico="1234", ministry_ico="1234"))
        res = Contract(supplier_ico="00001234", ministry_ico="00001234")
        self.assertEqual(res.supplier_ico, test_case.supplier_ico)
        self.assertEqual(res.ministry_ico, test_case.ministry_ico)

        test_case = ContractSanitizer.sanitize_contract(
            Contract(supplier_ico="    as da sd 12 34    ", ministry_ico="   ?>><>\/==\'':123   "))
        res = Contract(supplier_ico="00001234", ministry_ico="00000123")
        self.assertEqual(res.supplier_ico, test_case.supplier_ico)
        self.assertEqual(res.ministry_ico, test_case.ministry_ico)
コード例 #7
0
class ManagerControl(User):
    m_Login = Login()

    def __init__(self, ID):
        super().__init__()
        self.__ID = ID
        self.m_Statement = Statement()
        self.__contractCon = Contract()
        self.__applitionCon = Application()

    def get_all_contracts(self):
        return self.m_Statement.contracts

    def get_all_receipts(self):
        return self.m_Statement.receipts

    def get_all_receivable(self):
        return self.m_Statement.receivable

    def create_contract(self, ID, shopNum, userName, userTelContract,
                        contractInformation, rentTimeManager):
        self.__contractCon.add_new_contract_info(ID, shopNum, userName,
                                                 userTelContract,
                                                 contractInformation,
                                                 rentTimeManager)

    def delete_application(self, ID):
        self.__applitionCon.delete_application(ID)

    def get_applications(self):
        """
        获取所有申请信息
        :return:
        """
        return self.m_Statement.applications

    def enter_contract(self):
        pass

    def enter_fee(self):
        pass

    def login(self, name, password, identity):
        super().login(name, password, identity)

    def registration(self):
        pass

    def remind_arrearage(self):
        pass

    def remind_expiration_con(self):
        pass
コード例 #8
0
 def test_get_currency_from_mena(self):
     xml_text = """<ciziMena><hodnota>8866</hodnota><mena>EUR</mena></ciziMena>"""
     root = ET.fromstring(xml_text)
     contract = Contract()
     res = ContractProviderRegistr.get_currency_from_mena(root, contract)
     self.assertEqual("EUR", res.currency)
     self.assertEqual(8866, res.amount_different_currency)
コード例 #9
0
 def __init__(self):
     self.instance_list = []
     list(
         map(
             lambda contract: self.instance_list.append(
                 Contract(contract['id'], contract['employee_code'],
                          contract['data_contract'], contract[
                              'sum_contract'])), Contracts))
コード例 #10
0
 def test_get_identifikator_from_zaznam(self):
     xml_text = "<identifikator><idSmlouvy>9104775</idSmlouvy><idVerze>11241768</idVerze></identifikator>"
     root = ET.fromstring(xml_text)
     contract = Contract()
     res = ContractProviderRegistr.get_identifikator_from_zaznam(
         root, contract)
     self.assertEqual("9104775", res.external_id)
     self.assertEqual("11241768", res.version_id)
コード例 #11
0
class CEOControl(User):


    def __init__(self,ID):
        super().__init__()
        self.__identity = 'ceo'
        self.__ID = ID
        self.m_Statement = Statement()
        self.__contractCon = Contract()

    def set_contract_ceoaffirm_by_id(self,user_id, ceoaffirm):
        self.__contractCon.set_contract_ceoaffirm_by_id(user_id, ceoaffirm)

    def set_contract_ceosign_by_id(self,user_id, ceosign):
        self.__contractCon.set_contract_ceosign_by_id(user_id, ceosign)


    def check_all_information(self):
        pass

    def get_all_contracts(self):
        return self.m_Statement.contracts

    def get_all_receipts(self):
        return self.m_Statement.receipts

    def get_all_receivable(self):
        return self.m_Statement.receivable

    def confirm_contract(self):
        pass

    def login(self,name,password,identity):
        super().login(name,password,identity)

    def registration(self):
        pass

    def remind_arrearage(self):
        pass

    def remind_expiration_con(self):
        pass

    def sign_contract(self):
        pass
コード例 #12
0
 def test_get_attributes_from_smluvni_strana(self):
     xml_text = """<smluvniStrana><nazev>CARDION s.r.o.</nazev><ico>60719877</ico><adresa>Rybnická 136, BRNO</adresa></smluvniStrana>"""
     root = ET.fromstring(xml_text)
     contract = Contract()
     res = ContractProviderRegistr.get_attributes_from_smluvni_strana(
         root, contract)
     self.assertEqual("CARDION s.r.o.", res.supplier_name)
     self.assertEqual("60719877", res.supplier_ico)
     self.assertEqual("Rybnická 136, BRNO", res.supplier_address)
コード例 #13
0
    def test_ic_test_purpose(self):
        contract = Contract(purpose="Úprava kanceláří 115 a 116 Sociálního oddělení ÚMČ Brno - Komín částečná odhlučněná příčka")
        invoice = Invoice(purpose=None)
        self.assertIsNone(ic_test_purpose(invoice, contract).result)

        invoice = Invoice(purpose="Úprava")
        self.assertEqual(6/77, ic_test_purpose(invoice, contract).result)

        invoice = Invoice(purpose="Úprava kanceláří 115 a 116 Sociálního oddělení ÚMČ Brno - Komín částečná odhlučněná příčka")
        self.assertEqual(1, ic_test_purpose(invoice, contract).result)

        invoice = Invoice(purpose="Úprava Brno 115 Komín")
        self.assertEqual(18/77, ic_test_purpose(invoice, contract).result)

        invoice = Invoice(purpose="kancelář")
        self.assertEqual(8/77, ic_test_purpose(invoice, contract).result)

        contract = Contract(purpose=None)
        invoice = Invoice(purpose="kancelář")
        self.assertEqual(None, ic_test_purpose(invoice, contract).result)
コード例 #14
0
 def register(self, form):
     """Passes a new contract through a form filler before passing it
     onto the data API"""
     new_form = contract_filler(form)
     if new_form == False:
         self.logicAPI.ui.display_error(
             'Vehicle is not available during selected time period. Contract was not registered'
         )
         return
     new_contract = Contract(**new_form)
     self.dataAPI.append_contract(new_contract)
コード例 #15
0
 def isValidContract(self, asset, endOfContract, takeProfit, stopLoss,
                     numberOfContracts):
     if (Contract.isAssetType(self, asset)):
         y, m, d = endOfContract.split("-")
         if (Contract.isValidDate(self, y, m, d)):
             if (int(takeProfit) > 0):
                 if (int(stopLoss) > 0):
                     if (int(numberOfContracts) > 0):
                         return True
                     else:
                         message = "Number of Contracts Invalid"
                 else:
                     message = "Stop Loss Invalid"
             else:
                 message = "Take Profit Invalid"
         else:
             message = "End Of Contract Invalid"
     else:
         message = "Asset Invalid"
     return message
コード例 #16
0
def contract():
    """Returns contract with random data in it from Dummy()"""
    date, _ = datetime.now().replace(microsecond=0,
                                     second=0).isoformat().split('T')
    return Contract(randint(1, 10), D.make_vehicle_state(),
                    D.make_vehicle_status(), D.make_licence(), D.make_type(),
                    D.make_country(), randint(1, 10), D.make_name(),
                    D.make_phone(), D.make_email(), D.make_address(),
                    D.make_licence(), randint(1, 10), D.make_airport(),
                    D.make_airport(), 'N/A', 'N/A', 'N/A', 'N/A',
                    D.make_early_date(), D.make_later_date(),
                    D.make_contract_state(), randint(100, 1000),
                    randint(0, 300), 0, date)
コード例 #17
0
 def test_get_attributes_from_subjekt(self):
     xml_text = "<subjekt><datovaSchranka>tj8vfp3</datovaSchranka><nazev>Dům zahraniční spolupráce</nazev><ico>61386839</ico><adresa> ,  Na poříčí 1035 / 4 Nové Město 11006, Praha Hlavní město Praha, </adresa><utvar>310 - Oddělení mobilit mládeže</utvar></subjekt>"
     root = ET.fromstring(xml_text)
     contract = Contract()
     res = ContractProviderRegistr.get_attributes_from_subjekt(
         root, contract)
     self.assertEqual("tj8vfp3", res.ministry_data_box)
     self.assertEqual("Dům zahraniční spolupráce", res.ministry_name)
     self.assertEqual("61386839", res.ministry_ico)
     self.assertEqual(
         " ,  Na poříčí 1035 / 4 Nové Město 11006, Praha Hlavní město Praha, ",
         res.ministry_address)
     self.assertEqual("310 - Oddělení mobilit mládeže",
                      res.ministry_department)
コード例 #18
0
 def test_get_attachments_from_prilohy(self):
     xml_text = """<prilohy><priloha><nazevSouboru>D2020001_AEC_EPS Plavecký areál Klíše.pdf</nazevSouboru><hash algoritmus="sha256">6e49d36ef1e0142df82346d03b25c157c50529b5d6773aae93db65154a30ba83</hash><odkaz>https://smlouvy.gov.cz/smlouva/soubor/14623880/D2020001_AEC_EPS%20Plaveck%C3%BD%20are%C3%A1l%20Kl%C3%AD%C5%A1e.pdf</odkaz></priloha></prilohy>"""
     root = ET.fromstring(xml_text)
     contract = Contract()
     res = ContractProviderRegistr.get_attachments_from_prilohy(
         root, contract)
     self.assertEqual(1, len(res.attachments))
     self.assertEqual(
         "6e49d36ef1e0142df82346d03b25c157c50529b5d6773aae93db65154a30ba83",
         res.attachments[0].hash_value)
     self.assertEqual(
         "https://smlouvy.gov.cz/smlouva/soubor/14623880/D2020001_AEC_EPS%20Plaveck%C3%BD%20are%C3%A1l%20Kl%C3%AD%C5%A1e.pdf",
         res.attachments[0].link)
     self.assertEqual("D2020001_AEC_EPS Plavecký areál Klíše.pdf",
                      res.attachments[0].name)
コード例 #19
0
    def __init__(self, lapi, ui):
        self.logicAPI = lapi
        self.ui = ui
        self.verify = Input_Verifiers(lapi)

        # Get the number of required parameters to the init method of the class
        self.contract = [
            Contract(
                *[None for i in range(len(signature(Contract).parameters))]),
            lapi.contract
        ]
        self.customer = [
            Customer(
                *[None for i in range(len(signature(Customer).parameters))]),
            lapi.customer
        ]
        self.destination = [
            Destination(
                *[None
                  for i in range(len(signature(Destination).parameters))]),
            lapi.destination
        ]
        self.employee = [
            Employee(
                *[None for i in range(len(signature(Employee).parameters))]),
            lapi.employee
        ]
        self.vehicle = [
            Vehicle(*[None
                      for i in range(len(signature(Vehicle).parameters))]),
            lapi.vehicle
        ]
        self.vehicle_type = [
            Vehicle_Type(
                *
                [None
                 for i in range(len(signature(Vehicle_Type).parameters))]),
            lapi.vehicle_type
        ]
        self.display = Display()
コード例 #20
0
    def test_ic_test_amount(self):
        contract = Contract(amount_different_currency=1000, amount_with_dph=2000, amount_without_dph=3000)

        invoice = Invoice(amount_in_diff_currency=1000, amount=2000, amount_without_tax=3000)
        self.assertEqual(1, ic_test_amount(invoice, contract).result)

        invoice = Invoice(amount_in_diff_currency=None, amount=None, amount_without_tax=None)
        self.assertIsNone(ic_test_amount(invoice, contract).result)

        invoice = Invoice(amount_in_diff_currency=1000, amount=None, amount_without_tax=None)
        self.assertEqual(1, ic_test_amount(invoice, contract).result)

        invoice = Invoice(amount_in_diff_currency=500, amount=None, amount_without_tax=None)
        self.assertEqual(0.5, ic_test_amount(invoice, contract).result)

        invoice = Invoice(amount_in_diff_currency=None, amount=4000, amount_without_tax=None)
        self.assertEqual(0.5, ic_test_amount(invoice, contract).result)

        invoice = Invoice(amount_in_diff_currency=None, amount=None, amount_without_tax=0)
        self.assertEqual(0, ic_test_amount(invoice, contract).result)

        invoice = Invoice(amount_in_diff_currency=500, amount=0, amount_without_tax=None)
        self.assertEqual(0.25, ic_test_amount(invoice, contract).result)
コード例 #21
0
 def test_get_attributes_from_smlouva(self):
     xml_text = "<smlouva><subjekt><datovaSchranka>5gueuef</datovaSchranka><nazev>Krajská zdravotní, a.s.</nazev><ico>25488627</ico><adresa>Sociální péče 3316/12a, 40011 Ústí nad Labem, CZ</adresa></subjekt><smluvniStrana><nazev>Bio-Rad spol. s r.o.</nazev><ico>49243764</ico><adresa>Pikrtova 1737/1a 140 00 Praha 4 -  Nusle</adresa><utvar>Obchodní oddělení</utvar><prijemce>0</prijemce></smluvniStrana><predmet>2LEK-K309647-Bio-Rad spol. s r.o.</predmet><datumUzavreni>2019-12-31</datumUzavreni><cisloSmlouvy>2LEK-K309647</cisloSmlouvy><hodnotaBezDph>433773</hodnotaBezDph><hodnotaVcetneDph>501949</hodnotaVcetneDph></smlouva>"
     root = ET.fromstring(xml_text)
     contract = Contract()
     res = ContractProviderRegistr.get_attributes_from_smlouva(
         root, contract)
     self.assertEqual("5gueuef", res.ministry_data_box)
     self.assertEqual("Krajská zdravotní, a.s.", res.ministry_name)
     self.assertEqual("25488627", res.ministry_ico)
     self.assertEqual("Sociální péče 3316/12a, 40011 Ústí nad Labem, CZ",
                      res.ministry_address)
     self.assertEqual("Bio-Rad spol. s r.o.", res.supplier_name)
     self.assertEqual("49243764", res.supplier_ico)
     self.assertEqual("Pikrtova 1737/1a 140 00 Praha 4 -  Nusle",
                      res.supplier_address)
     self.assertEqual("Obchodní oddělení", res.supplier_department)
     self.assertEqual("0", res.supplier_receiver_flag)
     self.assertEqual(datetime(year=2019, month=12, day=31),
                      res.date_agreed)
     self.assertEqual("2LEK-K309647", res.contract_number)
     self.assertEqual("2LEK-K309647-Bio-Rad spol. s r.o.", res.purpose)
     self.assertEqual(433773, res.amount_without_dph)
     self.assertEqual(501949, res.amount_with_dph)
コード例 #22
0
 def __init__(self,ID):
     super().__init__()
     self.__identity = 'ceo'
     self.__ID = ID
     self.m_Statement = Statement()
     self.__contractCon = Contract()
コード例 #23
0
 def edit(self, form, id):
     """Passes an edited contract through a form editor before passing it
     onto the data API"""
     new_form = contract_editor(form)
     new_contract = Contract(**new_form)
     self.dataAPI.edit_contract(new_contract, id)
コード例 #24
0
 def __init__(self, ID):
     super().__init__()
     self.__ID = ID
     self.m_Statement = Statement()
     self.__contractCon = Contract()
     self.__applitionCon = Application()
コード例 #25
0
 def test_sanitize_ministry_name_not_ministry(self):
     test_case = ContractSanitizer._sanitize_ministry_name(
         Contract(ministry_ico="00023600", ministry_name='Test s.r.o.'))
     res = Contract(ministry_ico='00023600', ministry_name='Test s.r.o.')
     self.assertEqual(res.ministry_name, test_case.ministry_name)
     self.assertEqual(res.ministry_ico, test_case.ministry_ico)
コード例 #26
0
 def test_sanitize_ministry_name_ico_none(self):
     test_case = ContractSanitizer._sanitize_ministry_name(
         Contract(ministry_ico=None, ministry_name='Test s.r.o.'))
     res = Contract(ministry_ico=None, ministry_name='Test s.r.o.')
     self.assertEqual(res.ministry_name, test_case.ministry_name)
     self.assertEqual(res.ministry_ico, test_case.ministry_ico)