def adhoc_error_search(self, Ticket_Uid, START_DATE, TPID):
     so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo)
     so.click_element_by_id(LocalElementLocator.ERROR_HOSPITAL_TAB_ID)
     so.send_text_by_id(LocalElementLocator.TICKET_UID_ID, Ticket_Uid)
     so.send_text_by_id(LocalElementLocator.TITLE_ID,
                        LocalElementLocator.ADHOC_ERROR_TITLE)
     so.send_text_by_id(
         LocalElementLocator.DESCRIPTION_ID,
         '%No entry in the web trading partnership table%' + TPID + '%')
     so.send_text_by_id(LocalElementLocator.START_DATE_ID, START_DATE)
     so.click_element_by_id(LocalElementLocator.SEARCH_BUTTON_ID)
 def document_rejected_error_search(self, v_ticket_uid, v_start_date,
                                    v_TPID, v_error_title, v_doc_type):
     selenium_operation_object = SeleniumOperations(self.v_task_type,
                                                    self.v_driver,
                                                    self.log_file_object)
     selenium_operation_object.click_element_by_id(
         LocalElementLocator.ERROR_HOSPITAL_TAB_ID1)
     selenium_operation_object.send_text_by_id(
         LocalElementLocator.TICKET_UID_ID, v_ticket_uid)
     selenium_operation_object.send_text_by_id(LocalElementLocator.TITLE_ID,
                                               v_error_title)
     selenium_operation_object.send_text_by_id(
         LocalElementLocator.DESCRIPTION_ID,
         '%No entry in the web trading partnership table%' + v_TPID + '%')
     selenium_operation_object.send_text_by_id(
         LocalElementLocator.START_DATE_ID, v_start_date)
     selenium_operation_object.send_text_by_id(
         LocalElementLocator.EH_DOC_TYPE_ID, v_doc_type)
     selenium_operation_object.click_element_by_id(
         LocalElementLocator.SEARCH_BUTTON_ID)
Exemple #3
0
 def company_search_by_TPID(self, TPID):
     so = SeleniumOperations(self.v_task_type, self.v_driver, self.lo)
     so.click_element_by_id(AppConstants.DC4_COMPANY_SEARCH_BY_TPID_TAB)
     so.send_text_by_id(AppConstants.DC4_COMPANY_SEARCH_BY_TPID_TEXT_FIELD, TPID)
     so.click_element_by_id(AppConstants.DC4_COMPANY_SEARCH_BY_TPID_SEARCH_TAB)
    def add_web_company(self, sender, v_status):
        flag = 0
        selenium_operation_object = SeleniumOperations(self.v_task_type,
                                                       self.v_driver,
                                                       self.log_file_object)
        time.sleep(2)
        default_handle = self.v_driver.current_window_handle
        self.v_driver.switch_to.window(self.v_driver.window_handles[-1])
        time.sleep(2)
        self.v_driver.switch_to.frame(0)
        time.sleep(2)
        #Check in library for web company uid
        web_uid = self.error_hospital_machine_learning_object.get_supplier_info(
            sender)
        if web_uid != False:
            selenium_operation_object.send_text_by_id(
                LocalElementLocator.DC4_ADD_TRADING_PARTNERSHIP_COMPANYUID_ID,
                web_uid)
            selenium_operation_object.click_element_by_xpath(
                LocalElementLocator.
                DC4_ADD_TRADING_PARTNERSHIP_COMPANY_NAME_SEARCH_BUTTON)
            time.sleep(3)
            if selenium_operation_object.check_exists_by_xpath(
                    LocalElementLocator.
                    DC4_ADD_TRADING_PARTNERSHIP_FIRST_WEB_COMPANY):
                selenium_operation_object.click_element_by_xpath(
                    LocalElementLocator.
                    DC4_ADD_TRADING_PARTNERSHIP_SELECT_BUTTON)
                flag = 1
                v_status = v_status + '\nFound web company from previous results'
                self.v_driver.switch_to.window(self.v_driver.window_handles[0])
                time.sleep(2)
                return v_status, flag

        selenium_operation_object.send_text_by_id(
            LocalElementLocator.
            DC4_ADD_TRADING_PARTNERSHIP_COMPANY_NAME_SEARCH_ID, sender)
        selenium_operation_object.click_element_by_xpath(
            LocalElementLocator.
            DC4_ADD_TRADING_PARTNERSHIP_COMPANY_NAME_SEARCH_BUTTON)
        time.sleep(2)
        if selenium_operation_object.check_exists_by_xpath(
                LocalElementLocator.
                DC4_ADD_TRADING_PARTNERSHIP_FIRST_WEB_COMPANY):
            i = 2
            web_id = ' '
            path = '//*[@id="_idJsp13"]/table/tbody/tr[2]/td/table/tbody/tr[' + str(
                i) + ']/td[2]'
            while (1):
                if selenium_operation_object.check_exists_by_xpath(path):
                    temp_web_id = selenium_operation_object.get_text_by_xpath(
                        path)
                    if temp_web_id != web_id and flag == 0:
                        web_id = temp_web_id
                        flag = 1
                    elif temp_web_id != web_id:
                        flag = 2
                        break
                else:
                    break
                i = i + 1
                path = '//*[@id="_idJsp13"]/table/tbody/tr[2]/td/table/tbody/tr[' + str(
                    i) + ']/td[2]'
            if flag == 2:
                v_status = v_status + '\nMultiple web companies'
            else:
                selenium_operation_object.click_element_by_xpath(
                    LocalElementLocator.
                    DC4_ADD_TRADING_PARTNERSHIP_SELECT_BUTTON)
        else:
            sender = '%' + sender.replace(' ', '%') + '%'
            selenium_operation_object.send_text_by_id(
                LocalElementLocator.
                DC4_ADD_TRADING_PARTNERSHIP_COMPANY_NAME_SEARCH_ID, sender)
            selenium_operation_object.click_element_by_xpath(
                LocalElementLocator.
                DC4_ADD_TRADING_PARTNERSHIP_COMPANY_NAME_SEARCH_BUTTON)
            time.sleep(2)
            if selenium_operation_object.check_exists_by_xpath(
                    LocalElementLocator.
                    DC4_ADD_TRADING_PARTNERSHIP_FIRST_WEB_COMPANY):
                i = 2
                web_id = ' '
                path = '//*[@id="_idJsp13"]/table/tbody/tr[2]/td/table/tbody/tr[' + str(
                    i) + ']/td[2]'
                while (1):
                    if selenium_operation_object.check_exists_by_xpath(path):
                        temp_web_id = selenium_operation_object.get_text_by_xpath(
                            path)
                        if temp_web_id != web_id and flag == 0:
                            web_id = temp_web_id
                            flag = 1
                        elif temp_web_id != web_id:
                            flag = 2
                            break
                    else:
                        break
                    i = i + 1
                    path = '//*[@id="_idJsp13"]/table/tbody/tr[2]/td/table/tbody/tr[' + str(
                        i) + ']/td[2]'
                if flag == 2:
                    v_status = v_status + '\nMultiple web companies'
                else:
                    selenium_operation_object.click_element_by_xpath(
                        LocalElementLocator.
                        DC4_ADD_TRADING_PARTNERSHIP_SELECT_BUTTON)
            else:
                v_status = v_status + "No web company found"

        if flag == 0 or flag == 2:

            if easygui.ynbox(
                    "Deadpool is unable to find web company. Do you want to add it manually?\n\nNote:- Add correct web comapany manually then select 'Yes' else 'No'"
            ):
                flag = 1
                selenium_operation_object.click_element_by_xpath(
                    LocalElementLocator.
                    DC4_ADD_TRADING_PARTNERSHIP_SELECT_BUTTON)
            else:
                handles = list(self.v_driver.window_handles)
                handles.remove(default_handle)
                self.v_driver.close()
                time.sleep(2)

                self.v_driver.switch_to.window(default_handle)

        if flag == 1:
            self.v_driver.switch_to.window(self.v_driver.window_handles[0])
        time.sleep(2)
        return v_status, flag
    def add_trading_partnership(self, v_error_tiltle, v_TPID, doc_type_list,
                                sender, receiver, v_status):
        selenium_operation_object = SeleniumOperations(self.v_task_type,
                                                       self.v_driver,
                                                       self.log_file_object)
        v_present = 0
        supplier_web_id = ''
        retailer_web_id = ''
        selenium_operation_object.click_element_by_id(
            LocalElementLocator.DC4_WEBFORM_TAB_ID)
        selenium_operation_object.click_element_by_xpath(
            LocalElementLocator.DC4_SEARCH_TRADING_PARTNERSHIP_LINK_XPATH)
        selenium_operation_object.send_text_by_id(
            LocalElementLocator.DC4_EVISION_KEY_ID, v_TPID)
        selenium_operation_object.click_element_by_id(
            LocalElementLocator.DC4_TRADING_PARTNERSHIP_SEARCH_BUTTON_ID)
        #Check for existing trading partnership
        if selenium_operation_object.check_exists_by_xpath(
                LocalElementLocator.DC4_FIRST_TRADING_PARTNERSHIP_XPATH):
            v_present = 1
            doc_type_list, supplier_web_id, retailer_web_id = self.validate_existing_trading_partnership(
                v_error_tiltle, doc_type_list)

        if len(doc_type_list) == 0:
            v_status = v_status + 'Trading Partnership is already v_present'
            selenium_operation_object.click_element_by_id(
                LocalElementLocator.ERROR_HOSPITAL_TAB_ID2)
            flag = 1
            return v_status, flag

        if LocalElementLocator.ADHOC_ERROR_TITLE == v_error_tiltle:
            #Determine supplier and retailer
            sender, receiver = self.check_supplier_retailer(
                sender, receiver, doc_type_list[0])
        #If Valid Trading Partnership is not present
        if len(doc_type_list) != 0:

            if supplier_web_id == '':
                if v_present == 1:
                    selenium_operation_object.click_element_by_xpath(
                        LocalElementLocator.
                        DC4_CREATE_TRADING_PARTNERSHIP_BUTTON1)
                else:
                    selenium_operation_object.click_element_by_xpath(
                        LocalElementLocator.
                        DC4_CREATE_TRADING_PARTNERSHIP_BUTTON2)

                selenium_operation_object.click_element_by_xpath(
                    LocalElementLocator.
                    DC4_ADD_TRADING_PARTNERSHIP_SENDER_TORCH)

                v_status, flag = self.add_web_company(sender, v_status)
                if flag == 0 or flag == 2:
                    selenium_operation_object.click_element_by_xpath(
                        LocalElementLocator.ERROR_HOSPITAL_TAB_XPATH)
                    return v_status, flag

                selenium_operation_object.click_element_by_xpath(
                    LocalElementLocator.
                    DC4_ADD_TRADING_PARTNERSHIP_RECEIVER_TORCH)
                v_status, flag = self.add_web_company(receiver, v_status)

                if flag == 0 or flag == 2:
                    selenium_operation_object.click_element_by_xpath(
                        LocalElementLocator.ERROR_HOSPITAL_TAB_XPATH)
                    return v_status, flag

                if flag == 1:
                    supp_web_id = self.v_driver.find_element_by_id(
                        LocalElementLocator.
                        DC4_ADD_TRADING_PARTNERSHIP_SENDER_TEXT_ID
                    ).get_attribute('value')
                    ret_web_id = self.v_driver.find_element_by_id(
                        LocalElementLocator.
                        DC4_ADD_TRADING_PARTNERSHIP_RECEIVER_TEXT_ID
                    ).get_attribute('value')
                    self.error_hospital_machine_learning_object.add_to_library(
                        sender, supp_web_id)
                    self.error_hospital_machine_learning_object.add_to_library(
                        receiver, ret_web_id)
                    selenium_operation_object.send_text_by_id(
                        LocalElementLocator.
                        DC4_ADD_TRADING_PARTNERSHIP_EVISION_KEY_ID, v_TPID)
                    selenium_operation_object.send_text_by_id(
                        LocalElementLocator.
                        DC4_ADD_TRADING_PARTNERSHIP_FORM_NUMBER_ID,
                        (', ').join(doc_type_list))
                    if LocalElementLocator.ADHOC_ERROR_TITLE == v_error_tiltle:
                        selenium_operation_object.click_element_by_xpath(
                            LocalElementLocator.
                            DC4_ADD_TRADING_PARTNERSHIP_BILLING_CODE_ZERO)
                    else:
                        selenium_operation_object.click_element_by_xpath(
                            LocalElementLocator.
                            DC4_ADD_TRADING_PARTNERSHIP_BILLING_CODE_ONE)
                    selenium_operation_object.click_element_by_xpath(
                        LocalElementLocator.
                        DC4_ADD_TRADING_PARTNERSHIP_CREATE_BUTTON)
                    selenium_operation_object.click_element_by_xpath(
                        LocalElementLocator.ERROR_HOSPITAL_TAB_XPATH)
                    v_status = v_status + '\nAdded web trading partnership'
                    return v_status, 1
            else:
                selenium_operation_object.click_element_by_xpath(
                    LocalElementLocator.DC4_CREATE_TRADING_PARTNERSHIP_BUTTON1)
                if v_error_tiltle == LocalElementLocator.ADHOC_ERROR_TITLE:
                    selenium_operation_object.send_text_by_id(
                        LocalElementLocator.
                        DC4_ADD_TRADING_PARTNERSHIP_SENDER_TEXT_ID,
                        retailer_web_id)
                    selenium_operation_object.send_text_by_id(
                        LocalElementLocator.
                        DC4_ADD_TRADING_PARTNERSHIP_RECEIVER_TEXT_ID,
                        supplier_web_id)
                else:
                    if doc_type_list[0] == '810' or doc_type_list[
                            0] == '846' or doc_type_list[
                                0] == '855' or doc_type_list[
                                    0] == '856' or doc_type_list[0] == '940':
                        selenium_operation_object.send_text_by_id(
                            LocalElementLocator.
                            DC4_ADD_TRADING_PARTNERSHIP_SENDER_TEXT_ID,
                            supplier_web_id)
                        selenium_operation_object.send_text_by_id(
                            LocalElementLocator.
                            DC4_ADD_TRADING_PARTNERSHIP_RECEIVER_TEXT_ID,
                            retailer_web_id)
                    else:
                        selenium_operation_object.send_text_by_id(
                            LocalElementLocator.
                            DC4_ADD_TRADING_PARTNERSHIP_SENDER_TEXT_ID,
                            retailer_web_id)
                        selenium_operation_object.send_text_by_id(
                            LocalElementLocator.
                            DC4_ADD_TRADING_PARTNERSHIP_RECEIVER_TEXT_ID,
                            supplier_web_id)
                selenium_operation_object.send_text_by_id(
                    LocalElementLocator.
                    DC4_ADD_TRADING_PARTNERSHIP_EVISION_KEY_ID, v_TPID)
                selenium_operation_object.send_text_by_id(
                    LocalElementLocator.
                    DC4_ADD_TRADING_PARTNERSHIP_FORM_NUMBER_ID,
                    (', ').join(doc_type_list))
                if LocalElementLocator.ADHOC_ERROR_TITLE == v_error_tiltle:
                    selenium_operation_object.click_element_by_xpath(
                        LocalElementLocator.
                        DC4_ADD_TRADING_PARTNERSHIP_BILLING_CODE_ZERO)
                else:
                    selenium_operation_object.click_element_by_xpath(
                        LocalElementLocator.
                        DC4_ADD_TRADING_PARTNERSHIP_BILLING_CODE_ONE)

                selenium_operation_object.click_element_by_xpath(
                    LocalElementLocator.
                    DC4_ADD_TRADING_PARTNERSHIP_CREATE_BUTTON)
                selenium_operation_object.click_element_by_xpath(
                    LocalElementLocator.ERROR_HOSPITAL_TAB_XPATH)
                v_status = v_status + '\nAdded web trading partnership'
                return v_status, 1