def save_criticals_step_1(self):
        if not self.criticals_holder_layout.children():
            db = db_manager.DB_Manager()
            db.delete_all_criticals()
            self.stored_criticals = {}
            db.close_connection()
            utils.color_criticals_in_orange_in_main_section(
                self.parent().table, self.stored_criticals
            )
            self.close()
        elif self.criticals_holder_layout.children():
            contents_of_all_line_edits = []
            for l in self.criticals_holder_layout.children():
                contents_of_all_line_edits.append(l.itemAt(0).widget().text())
                contents_of_all_line_edits.append(l.itemAt(1).widget().text())

            if tests.test_if_duplicated_first_value_in_line_items_contents(
                contents_of_all_line_edits
            ):
                WarningBox(
                    "Componentes duplicados",
                    "Borrar uno de los\ncomponentes duplicados.",
                ).exec_()
            elif all(contents_of_all_line_edits):
                self.save_criticals_step_2()
            else:
                self.fix_empty_field_mid_save()
示例#2
0
    def insert_subtraction_comps_into_db(self):
        comps_to_subtract = utils.get_line_items_contents(
            (self.comps_holder_section), as_dictionary=True
        )
        db = db_manager.DB_Manager()
        for comp_display, subtr_amount in comps_to_subtract.items():
            comp_sql = db.get_SQL_name_for_component(comp_display)
            stock_vald_pre_appl = db.get_stock_at_valdenegro_for(comp_sql)
            stock_vald_post_appl = stock_vald_pre_appl - subtr_amount
            self.final_dialog_data[comp_display] = [
                stock_vald_pre_appl,
                stock_vald_post_appl,
                subtr_amount,
            ]
            data_to_apply_subtraction = {
                "comp_sql": comp_sql,
                "subtr_amount": subtr_amount,
                "stock_vald_post_appl": stock_vald_post_appl,
            }
            db.apply_subtraction_to_valdenegro_only(data_to_apply_subtraction)
            settings = QtCore.QSettings("solutronic", "admin_stock")
            db.log_new_movement(
                movement="Egreso",
                destination="Uso interno",
                component=comp_display,
                amount=subtr_amount,
                user=settings.value("username"),
            )

        db.close_connection()
        self.close()
        SubtractionAppliedMessageBox(self).exec_()
    def __init__(self, parent=None):
        super(CriticalCompsDialog, self).__init__(parent)
        self.setWindowFlags(
            QtCore.Qt.Dialog
            | QtCore.Qt.CustomizeWindowHint
            | QtCore.Qt.WindowCloseButtonHint
        )
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
        self.setFixedWidth(300)

        header_layout = QtWidgets.QVBoxLayout()

        title = QtWidgets.QLabel("Componentes críticos")
        title.setAlignment(QtCore.Qt.AlignCenter)
        title.setStyleSheet(criticals_title_style)

        subtitle = QtWidgets.QLabel(
            "Resalta en naranja los componentes con stock total\nigual o menor al valor crítico."
        )
        subtitle.setStyleSheet(criticals_subtitle_style)
        subtitle.setAlignment(QtCore.Qt.AlignCenter)

        header_layout.addWidget(title)
        header_layout.addWidget(subtitle)

        self.criticals_holder_layout = QtWidgets.QVBoxLayout()
        criticals_button_layout = QtWidgets.QHBoxLayout()

        add_critical_button = QtWidgets.QPushButton("+ Agregar")
        add_critical_button.setShortcut("Alt+a")
        save_criticals_button = QtWidgets.QPushButton("≡ Guardar")
        save_criticals_button.setShortcut("Alt+g")
        save_criticals_button.setDefault(True)
        criticals_button_layout.addWidget(add_critical_button)
        criticals_button_layout.addWidget(save_criticals_button)

        layout = QtWidgets.QVBoxLayout()
        layout.addLayout(header_layout)
        layout.addLayout(self.criticals_holder_layout)
        layout.addLayout(criticals_button_layout)

        self.setLayout(layout)

        add_critical_button.clicked.connect(self.add_critical_holder)
        save_criticals_button.clicked.connect(self.save_criticals_step_1)

        db = db_manager.DB_Manager()
        self.stored_criticals = db.get_stored_criticals()
        self.existing_comps = db.get_all_display_names_for_components()
        db.close_connection()

        if self.stored_criticals:
            for i in self.stored_criticals.items():
                self.add_critical_holder()

            for i, l in enumerate(self.criticals_holder_layout.children()):
                l.itemAt(0).widget().setText(list(self.stored_criticals.keys())[i])
                l.itemAt(1).widget().setText(
                    str(list(self.stored_criticals.values())[i]).replace(".0", "")
                )
    def save_criticals_step_2(self):
        unrecognized_comp_alert = WarningBox(
            "Componente no reconocido", "Cargar el componente\ndesde el autocompletado."
        )
        new_criticals = {}
        for l in self.criticals_holder_layout.children():
            component = l.itemAt(0).widget().text()
            amount = float(l.itemAt(1).widget().text().replace(",", "."))
            new_criticals[component] = amount

        if not set(new_criticals).issubset(self.existing_comps):
            unrecognized_comp_alert.exec_()
        if set(new_criticals).issubset(self.existing_comps):
            if self.stored_criticals == new_criticals:
                self.close()
        if self.stored_criticals != new_criticals:
            db = db_manager.DB_Manager()
            db.delete_all_criticals()
            number_of_criticals = len(new_criticals)
            endstring = (
                "valor crítico" if number_of_criticals == 1 else "valores críticos"
            )
            config_record_details = str(number_of_criticals) + " " + endstring
            db.save_new_criticals(new_criticals)
            self.stored_criticals = new_criticals
            db.log_new_config_record(
                config="Edición de críticos", details=config_record_details
            )
            db.close_connection()
            utils.color_criticals_in_orange_in_main_section(
                self.parent().table, self.stored_criticals
            )
            self.close()
    def __init__(self, parent=None):
        super(EditRecipeDialog, self).__init__(parent)

        self.recipe_being_edited_display = ""
        self.recipe_being_edited_sql = ""
        self.stored_recipe_contents = {}

        self.setWindowFlags(QtCore.Qt.Dialog
                            | QtCore.Qt.CustomizeWindowHint
                            | QtCore.Qt.WindowCloseButtonHint)

        self.setFixedWidth(200)
        self.setFixedHeight(250)

        title = QtWidgets.QLabel("Editar receta")
        title.setAlignment(QtCore.Qt.AlignCenter)
        title.setStyleSheet(generic_title_style)

        self.searchbar = AutocapField("Buscar receta a editar...")
        self.searchbar.set_completer(source="recipes")

        self.table = QtWidgets.QTableWidget()
        self.table.setFocusPolicy(QtCore.Qt.NoFocus)
        self.table.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
        self.table.verticalHeader().setVisible(False)
        self.table.setSelectionMode(QtWidgets.QAbstractItemView.NoSelection)
        self.table.setColumnCount(1)
        self.table.setHorizontalHeaderLabels(["Producto"])
        self.table.horizontalHeaderItem(0).setTextAlignment(
            QtCore.Qt.AlignHCenter)
        self.table.horizontalHeader().setSectionResizeMode(
            0, QtWidgets.QHeaderView.Stretch)

        db = db_manager.DB_Manager()
        self.all_recipes_display = db.get_all_recipes_as_display()
        db.close_connection()
        self.table.setRowCount(len(self.all_recipes_display))
        utils.populate_table_column_with_list_of_strings(
            table=self.table, col_num=0, input_list=self.all_recipes_display)

        back_button = QtWidgets.QPushButton("« Volver")
        back_button.setShortcut("Alt+v")

        layout = QtWidgets.QVBoxLayout()
        layout.addWidget(title)
        layout.addWidget(self.searchbar)
        layout.addWidget(self.table)
        layout.addWidget(back_button)

        self.setLayout(layout)

        back_button.clicked.connect(self.close)
        self.searchbar.returnPressed.connect(self.on_searchbar_return_pressed)
        self.table.cellDoubleClicked.connect(self.on_table_item_double_clicked)

        if not self.all_recipes_display:
            InformationBox("Sin recetas",
                           "No hay recetas para editar.").exec_()
            QtCore.QTimer.singleShot(1, self.close)
示例#6
0
    def __init__(self, parent=None):
        super(ExcludedCompsDialog, self).__init__(parent)
        self.setWindowFlags(
            QtCore.Qt.Dialog
            | QtCore.Qt.CustomizeWindowHint
            | QtCore.Qt.WindowCloseButtonHint
        )
        self.setFixedWidth(200)
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)

        self.settings = QtCore.QSettings("solutronic", "admin_stock")

        layout = QtWidgets.QVBoxLayout()

        checkbox_layout = QtWidgets.QVBoxLayout()
        checkbox_layout.setAlignment(QtCore.Qt.AlignCenter)

        title = QtWidgets.QLabel("Componentes excluidos")
        subtitle = QtWidgets.QLabel("Componentes no integrados\na ninguna receta:")
        title.setAlignment(QtCore.Qt.AlignCenter)
        title.setStyleSheet(excluded_dialog_title_style)
        subtitle.setAlignment(QtCore.Qt.AlignCenter)
        subtitle.setStyleSheet(excluded_dialog_subtitle_style)

        self.checkbox = QtWidgets.QCheckBox("Resaltar excluidos en amarillo")

        if self.settings.value("excluded_checkbox") == "on":
            self.checkbox.setChecked(True)

        db = db_manager.DB_Manager()
        self.unused_components = db.get_components_not_in_use()
        db.close_connection()

        unused_components_string = ""
        for i in self.unused_components:
            unused_components_string += f"• {i}\n"

        if not self.unused_components:
            unused_components_string = "No hay excluidos."

        excluded_data = QtWidgets.QLabel(unused_components_string)
        excluded_data.setAlignment(QtCore.Qt.AlignCenter)

        checkbox_layout.addWidget(self.checkbox)

        self.back_button = QtWidgets.QPushButton("« Volver")
        self.back_button.setShortcut("Alt+v")
        self.back_button.setDefault(True)

        layout.addWidget(title)
        layout.addWidget(subtitle)
        layout.addWidget(excluded_data)
        layout.addLayout(checkbox_layout)
        layout.addWidget(self.back_button)

        self.setLayout(layout)

        self.back_button.clicked.connect(self.close)
        self.checkbox.clicked.connect(self.on_checkbox_checked)
示例#7
0
 def open_component_details(self, row, col):
     if col == 0:
         self.selected_comp_display = self.table.item(row, col).text()
         db = db_manager.DB_Manager()
         self.selected_comp_SQL = db.get_SQL_name_for_component(
             self.selected_comp_display)
         db.close_connection()
     ComponentDetailsDialog(self).exec_()
    def test_if_edited_recipe_is_equal_to_original(self):
        db = db_manager.DB_Manager()
        original_recipe_contents = db.get_recipe_contents(
            self.recipe_being_edited_sql)
        db.close_connection()

        if self.recipe_being_edited_contents == original_recipe_contents:
            self.close()
            self.parent().close()
示例#9
0
 def delete_movements(self):
     box = QuestionBox("Confirmación", "¿Borrar historial de configuraciones?")
     box.exec_()
     if box.clickedButton() == box.button(QtWidgets.QMessageBox.Yes):
         db = db_manager.DB_Manager()
         db.delete_all_configs()
         db.close_connection()
         self.close()
         statusbar = self.parent().parent().parent().parent().statusbar
         statusbar.show_quick_message("Historial de configuraciones borrado")
     elif box.clickedButton() == box.button(QtWidgets.QMessageBox.No):
         pass
示例#10
0
    def test_if_there_are_unrecognized_components(self):
        db = db_manager.DB_Manager()
        existing_comps = db.get_all_display_names_for_components()
        db.close_connection()

        if self.search_field.text() not in existing_comps:
            WarningBox(
                "Componente extraño",
                "Componente no reconocido. Cargar el\ncomponente desde el autocompletado.",
            ).exec_()
            return True
        else:
            return False
示例#11
0
 def set_completer(self, **kwargs):
     source = kwargs.get("source")
     db = db_manager.DB_Manager()
     if source == "comps in stock":
         string_list = db.get_all_display_names_for_components()
     elif source == "comps in movements":
         string_list = db.get_components_mentioned_in_movements()
     elif source == "recipes":
         string_list = db.get_all_recipes_as_display()
     db.close_connection()
     model = QtCore.QStringListModel()
     model.setStringList(string_list)
     completer = QtWidgets.QCompleter()
     completer.setModel(model)
     self.setCompleter(completer)
示例#12
0
 def test_if_there_are_unrecognized_components(self):
     contents = utils.get_line_items_contents(self.comps_holder_section)
     incoming_comps = contents[0::2]
     db = db_manager.DB_Manager()
     existing_comps = db.get_all_display_names_for_components()
     db.close_connection()
     unrecognized_comps = not set(incoming_comps).issubset(existing_comps)
     if unrecognized_comps:
         WarningBox(
             "Componente extraño",
             "Componente no reconocido. Cargar el\ncomponente desde el autocompletado.",
         ).exec_()
         return True
     else:
         return False
示例#13
0
    def create_component(self):
        if self.compname_field.text() == "":
            message_boxes.WarningBox(
                "Sin nombre",
                "Dar nombre al componente\nantes de ejecutar.").exec_()
            self.compname_field.setFocus()
            return

        db = db_manager.DB_Manager()
        component_names_display = db.get_all_display_names_for_components()

        if self.compname_field.text() in component_names_display:
            message_boxes.WarningBox(
                "Nombre ya existente",
                "El nombre tiene que ser\ndiferente de los existentes.",
            ).exec_()
            self.compname_field.clear()
            self.compname_field.setFocus()
            return

        newcomp_display_name = self.compname_field.text()
        newcomp_sql_name = utils.format_display_name_into_sql_name(
            newcomp_display_name)

        initstock = 0
        if self.initstock_field.text() != "":
            initstock = utils.format_number_for_calculation(
                self.initstock_field.text())

        db.create_new_component(newcomp_sql_name, newcomp_display_name,
                                initstock)
        db.log_new_config_record(config="Creación de componente",
                                 details=newcomp_display_name)
        db.close_connection()

        admin_window = self.parent().parent().parent()
        admin_window.statusbar.show_quick_message("Componente creado: " +
                                                  newcomp_display_name)
        admin_window.start_screen.rebuild_main_section()

        QtWidgets.QApplication.processEvents()  # enables scrolling
        table = admin_window.start_screen.main_section.table
        utils.scroll_to_row_in_table(table, newcomp_display_name)

        self.compname_field.clear()
        self.initstock_field.clear()
        self.close()
    def populate_recipe_data(self):
        db = db_manager.DB_Manager()
        self.recipe_being_edited_sql = utils.format_display_name_into_sql_name(
            self.recipe_being_edited_display)
        self.stored_recipe_contents = db.get_recipe_contents(
            self.recipe_being_edited_sql)
        db.close_connection()

        for _ in self.stored_recipe_contents.items():
            self.add_recipe_item_line()

        for i, layout in enumerate(self.comps_holder_section.children()):
            component = list(self.stored_recipe_contents.keys())[i]
            amount = list(self.stored_recipe_contents.values())[i]
            amount = utils.format_number_for_display(amount)
            layout.itemAt(0).widget().setText(component)
            layout.itemAt(1).widget().setText(amount)
示例#15
0
    def on_yes_at_confirmation(self):
        db = db_manager.DB_Manager()
        db.enable_foreign_keys()

        comp_being_deleted_sql_name = db.get_SQL_name_for_component(
            self.comp_being_deleted_display_name)

        db.delete_comp_name_everywhere(comp_being_deleted_sql_name)

        db.log_new_config_record(config="Borrado de componente",
                                 details=self.comp_being_deleted_display_name)

        db.close_connection()

        admin_window = self.parent().parent().parent().parent()
        admin_window.statusbar.show_quick_message(
            "Componente borrado: " + self.comp_being_deleted_display_name)
        admin_window.start_screen.rebuild_main_section()

        self.close()
        self.parent().close()
    def delete_empty_recipe(self):
        box = QuestionBox(
            "Confirmación",
            f"¿Borrar receta {self.recipe_being_edited_display}?\n\nNo puede existir una receta vacía.",
        )
        box.exec_()

        if box.clickedButton() == box.button(QtWidgets.QMessageBox.No):
            pass
        elif box.clickedButton() == box.button(QtWidgets.QMessageBox.Yes):
            db = db_manager.DB_Manager()
            db.delete_recipe(self.recipe_being_edited_sql)
            db.log_new_config_record(config="Borrado de receta",
                                     details=self.recipe_being_edited_display)
            db.close_connection()
            admin_window = self.parent().parent().parent()
            admin_window.statusbar.show_quick_message(
                "Receta guardada: " + self.recipe_being_edited_display)
            admin_window.start_screen.rebuild_main_section()
            self.close()
            self.parent().close()
示例#17
0
    def on_checkbox_checked(self):
        update = ""
        number_of_excluded_comps = len(self.unused_components)
        endstring = (
            "componente excluido"
            if number_of_excluded_comps == 1
            else "componentes excluidos"
        )
        number_of_excluded_comps_string = (
            str(number_of_excluded_comps) + " " + endstring
        )
        if self.checkbox.isChecked():
            self.settings.setValue("excluded_checkbox", "on")
            update = "Activado de excluidos"
        elif not self.checkbox.isChecked():
            self.settings.setValue("excluded_checkbox", "off")
            update = "Desactivado de excluidos"

        db = db_manager.DB_Manager()
        db.log_new_config_record(config=update, details=number_of_excluded_comps_string)
        db.close_connection()
        self.set_excluded_state_at_parent_and_recolor()
示例#18
0
    def delete_recipe_from_db(self):
        self.recipe_being_deleted_sql = utils.format_display_name_into_sql_name(
            self.recipe_being_deleted_display)
        box = QuestionBox(
            "Confirmación",
            f"¿Borrar receta {self.recipe_being_deleted_display}?")
        box.exec_()

        if box.clickedButton() == box.button(QtWidgets.QMessageBox.No):
            pass
        elif box.clickedButton() == box.button(QtWidgets.QMessageBox.Yes):
            db = db_manager.DB_Manager()
            db.delete_recipe(self.recipe_being_deleted_sql)
            db.log_new_config_record(config="Borrado de receta",
                                     details=self.recipe_being_deleted_display)
            db.close_connection()
            admin_window = self.parent().parent().parent()
            admin_window.statusbar.show_quick_message(
                "Receta borrada: " + self.recipe_being_deleted_display)
            admin_window.start_screen.rebuild_main_section()

            self.close()
    def insert_edited_recipe_into_db(self):
        fields_contents = utils.get_line_items_contents(
            self.comps_holder_section)
        components = fields_contents[0::2]
        amounts = fields_contents[1::2]

        self.test_if_edited_recipe_is_equal_to_original()

        self.recipe_being_edited_contents = dict(zip(components, amounts))
        db = db_manager.DB_Manager()
        db.edit_recipe(self.recipe_being_edited_sql,
                       self.recipe_being_edited_contents)
        db.log_new_config_record(config="Edición de receta",
                                 details=self.recipe_being_edited_display)
        db.close_connection()

        admin_window = self.parent().parent().parent().parent()
        admin_window.statusbar.show_quick_message(
            "Receta guardada: " + self.recipe_being_edited_display)

        self.close()
        self.parent().close()
示例#20
0
    def insert_new_recipe_into_db(self):
        recipe_being_created_display = (self.product_field.text() + "-" +
                                        self.model_field.text())
        recipe_being_created_sql = utils.format_display_name_into_sql_name(
            recipe_being_created_display)
        fields_contents = utils.get_line_items_contents(
            self.comps_holder_section)
        components = fields_contents[0::2]
        amounts = fields_contents[1::2]
        recipe_contents = dict(zip(components, amounts))

        db = db_manager.DB_Manager()
        db.create_recipe(recipe_being_created_sql)
        db.populate_recipe(recipe_being_created_sql, recipe_contents)
        db.log_new_config_record(config="Creación de receta",
                                 details=recipe_being_created_display)
        db.close_connection()

        admin_window = self.parent().parent().parent()
        admin_window.statusbar.show_quick_message("Receta creada: " +
                                                  recipe_being_created_display)

        self.close()
示例#21
0
    def on_yes_at_confirmation(self):
        db = db_manager.DB_Manager()
        db.enable_foreign_keys()
        db.edit_comp_name_everywhere(
            comp_old_sql_name=self.comp_old_sql_name,
            comp_new_sql_name=self.comp_new_sql_name,
            comp_old_display_name=self.comp_old_display_name,
            comp_new_display_name=self.comp_new_display_name,
        )
        message = f"{self.comp_old_display_name} a {self.comp_new_display_name}"
        db.log_new_config_record(config="Edición de componente", details=message)
        db.close_connection()
        admin_window = self.parent().parent().parent().parent().parent()
        admin_window.statusbar.show_quick_message("Componente editado: " + message)
        admin_window.start_screen.rebuild_main_section()

        QtWidgets.QApplication.processEvents()  # enables scrolling
        table = admin_window.start_screen.main_section.table
        utils.scroll_to_row_in_table(table, self.comp_new_display_name)

        self.close()
        self.parent().close()
        self.parent().parent().close()
示例#22
0
    def __init__(self):
        super(StatusBar, self).__init__()

        self.setSizeGripEnabled(False)
        self.setStyleSheet(statusbar_style)

        self.settings = QtCore.QSettings("solutronic", "admin_stock")
        self.db_location = self.settings.value("db_location")
        self.username = self.settings.value("username")

        db = db_manager.DB_Manager()
        component_total, recipe_total = db.get_totals_for_components_and_recipes(
        )
        db.close_connection()

        statusbar_label_text_and_style = {
            "Base:": statusbar_first_label_style,
            self.db_location: "",
            "Componentes:": statusbar_bold_label_style,
            component_total: "",
            "Recetas:": statusbar_bold_label_style,
            recipe_total: "",
            "Usuario:": statusbar_bold_label_style,
            self.username: statusbar_last_label_style,
        }

        for text, style in statusbar_label_text_and_style.items():
            label = QtWidgets.QLabel(text)
            label.setStyleSheet(style)
            if text == "Base:" or text == self.db_location:
                self.addWidget(label)
            elif text != "Base:":
                self.addPermanentWidget(label)

        for i in self.layout().children():
            i.setSpacing(0)
示例#23
0
    def insert_incoming_comps_into_db(self):
        fields_contents = utils.get_line_items_contents(
            self.comps_holder_section)
        incoming_components = fields_contents[0::2]
        incoming_amounts = fields_contents[1::2]
        incoming_components_and_amounts_for_display = dict(
            zip(incoming_components, incoming_amounts))

        db = db_manager.DB_Manager()

        for k, v in incoming_components_and_amounts_for_display.items():
            self.incoming_comps_and_amounts_for_operation[
                db.get_SQL_name_for_component(
                    k)] = utils.format_number_for_calculation(v)

        for component_display in incoming_components_and_amounts_for_display.keys(
        ):
            for (
                    comp_sql,
                    amount,
            ) in self.incoming_comps_and_amounts_for_operation.items():
                stock_vald_pre_application = db.get_stock_at_valdenegro_for(
                    comp_sql)
                stock_vald_post_application = stock_vald_pre_application + amount
                self.data_for_final_dialog[component_display] = [
                    stock_vald_pre_application,
                    stock_vald_post_application,
                ]
                data = {
                    "comp_sql":
                    comp_sql,
                    "amount":
                    amount,
                    "packing_list":
                    self.packing_list_field.text(),
                    "supplier":
                    self.supplier_field.text(),
                    "note":
                    self.note_field.text()
                    if self.note_field.text() else "---",
                    "stock_vald_post_application":
                    stock_vald_post_application,
                    "stock_karina":
                    db.get_stock_at_assembler_for(comp_sql, "karina"),
                    "stock_brid":
                    db.get_stock_at_assembler_for(comp_sql, "brid"),
                    "stock_tercero":
                    db.get_stock_at_assembler_for(comp_sql, "tercero"),
                }
                db.apply_incoming_to_valdenegro(data)

        start_screen = self.parent().parent().parent().start_screen
        start_screen.rebuild_main_section()
        settings = QtCore.QSettings("solutronic", "admin_stock")
        for component, amount in incoming_components_and_amounts_for_display.items(
        ):
            db.log_new_movement(
                movement="Ingreso",
                destination="Depósito",
                component=component,
                amount=amount,
                user=settings.value("username"),
            )

        db.close_connection()
        IncomingAppliedMessageBox(self).exec_()
示例#24
0
    def insert_outgoing_comps_into_db(self):
        self.outgoing_comps_amts_needs = dict(
            zip(
                self.outgoing_comps.keys(),
                list(zip(self.outgoing_comps.values(), self.outgoing_needs.values())),
            )
        )

        db = db_manager.DB_Manager()
        assemblers = {"K": "karina", "B": "brid", "T": "tercero"}

        self.assembler = assemblers[self.code[0]]

        for comp_display, amt_and_need in self.outgoing_comps_amts_needs.items():
            comp_sql = db.get_SQL_name_for_component(comp_display)
            comp_outgoing_amt = amt_and_need[0]
            comp_outgoing_need = amt_and_need[1]
            stock_vald_pre_appl = db.get_stock_at_valdenegro_for(comp_sql)
            stock_assembler_pre_appl = db.get_stock_at_assembler_for(
                comp_sql, self.assembler
            )
            stock_vald_post_appl = stock_vald_pre_appl - comp_outgoing_amt
            stock_assembler_post_appl = (
                stock_assembler_pre_appl + comp_outgoing_amt - comp_outgoing_need
            )
            self.final_data_vald[comp_display] = [
                stock_vald_pre_appl,
                stock_vald_post_appl,
            ]
            self.final_data_assembler[comp_display] = [
                stock_assembler_pre_appl,
                stock_assembler_post_appl,
            ]

            data = {
                "assembler": self.assembler,
                "comp_sql": comp_sql,
                "comp_outgoing_amt": comp_outgoing_amt,
                "comp_outgoing_need": comp_outgoing_need,
                "stock_vald_post_appl": stock_vald_post_appl,
                "stock_assembler_post_appl": stock_assembler_post_appl,
                "stock_karina": db.get_stock_at_assembler_for(comp_sql, "karina"),
                "stock_brid": db.get_stock_at_assembler_for(comp_sql, "brid"),
                "stock_tercero": db.get_stock_at_assembler_for(comp_sql, "tercero"),
            }

            db.apply_outgoing_to_valdenegro_and_assembler(data)
            settings = QtCore.QSettings("solutronic", "admin_stock")
            db.log_new_movement(
                movement="Egreso",
                destination=self.assembler.capitalize(),
                component=comp_display,
                amount=comp_outgoing_amt,
                user=settings.value("username"),
            )

        db.close_connection()

        self.close()

        OutgoingAppliedMessageBox(self).exec_()
示例#25
0
    def __init__(self):
        super(MainSection, self).__init__()

        self.selected_comp_display = ""
        self.selected_comp_SQL = ""

        title = QtWidgets.QLabel("Resumen de componentes")
        title.setStyleSheet(main_section_title_style)
        title.setAlignment(QtCore.Qt.AlignCenter)

        self.searchbar = AutocapField("Buscar componente...")
        self.searchbar.set_completer(source="comps in stock")

        sb_shortcut = QtWidgets.QShortcut(QtGui.QKeySequence("Alt+b"),
                                          self.searchbar)
        sb_shortcut.activated.connect(self.searchbar.setFocus)

        self.update_button = QtWidgets.QPushButton("Actualizado")
        self.update_button.setShortcut("Alt+a")
        self.update_button.setFixedWidth(110)
        self.update_button.setEnabled(False)

        primary_button = QtWidgets.QToolButton()
        primary_button.setIcon(qta.icon("mdi.view-list"))
        primary_button.setText("Cuadro de inventario")
        primary_button.setShortcut("Alt+p")

        secondary_button = QtWidgets.QToolButton()
        secondary_button.setIcon(qta.icon("mdi.file-tree"))
        secondary_button.setText("Cuadros secundarios")
        secondary_button.setShortcut("Alt+s")

        for i in [primary_button, secondary_button]:
            i.setIconSize(QtCore.QSize(42, 42))
            i.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
            i.setSizePolicy(QtWidgets.QSizePolicy.Preferred,
                            QtWidgets.QSizePolicy.Expanding)
            i.setPopupMode(QtWidgets.QToolButton.InstantPopup)
            i.setFixedHeight(70)
            i.setFixedWidth(126)

        primary_menu = QtWidgets.QMenu()
        primary_menu_item_1 = primary_menu.addAction("Resaltar críticos")
        primary_menu_item_2 = primary_menu.addAction("Resaltar excluidos")
        primary_menu_item_3 = primary_menu.addAction("Exportar datos")
        primary_menu.setStyleSheet(main_section_menu_style)
        primary_button.setMenu(primary_menu)

        secondary_menu = QtWidgets.QMenu()
        secondary_menu.setStyleSheet(main_section_menu_style)
        secondary_menu_item_1 = secondary_menu.addAction("Movimientos")
        secondary_menu_item_2 = secondary_menu.addAction("Configuraciones")
        secondary_button.setMenu(secondary_menu)

        horizontal_section_layout = QtWidgets.QHBoxLayout()
        horizontal_section_layout.addWidget(self.searchbar)
        horizontal_section_layout.addWidget(self.update_button)

        table_layout = QtWidgets.QVBoxLayout()
        self.table = QtWidgets.QTableWidget()
        self.table.setStyleSheet(main_section_table_style)
        self.table.setColumnCount(6)
        self.table.setFixedHeight(355)
        self.table.setFocusPolicy(QtCore.Qt.NoFocus)
        self.table.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
        self.table.setSelectionMode(QtWidgets.QAbstractItemView.NoSelection)
        self.table.verticalHeader().setVisible(False)
        self.main_section_header_labels = [
            "Componente",
            "Total",
            "Depósito",
            "Karina",
            "Brid",
            "Tercero",
        ]
        self.table.setHorizontalHeaderLabels(self.main_section_header_labels)
        self.table.horizontalHeader().setDefaultSectionSize(70)

        self.table.horizontalHeader().setSectionResizeMode(
            0, QtWidgets.QHeaderView.Stretch)
        self.table.horizontalHeader().setSectionResizeMode(
            1, QtWidgets.QHeaderView.Fixed)
        self.table.horizontalHeader().setSectionResizeMode(
            2, QtWidgets.QHeaderView.Fixed)
        self.table.horizontalHeader().setSectionResizeMode(
            3, QtWidgets.QHeaderView.Fixed)
        self.table.horizontalHeader().setSectionResizeMode(
            4, QtWidgets.QHeaderView.Fixed)
        self.table.horizontalHeader().setSectionResizeMode(
            5, QtWidgets.QHeaderView.Fixed)

        for i in range(6):
            self.table.horizontalHeaderItem(i).setTextAlignment(
                QtCore.Qt.AlignHCenter)

        table_layout.addWidget(self.table)
        layout = QtWidgets.QVBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)

        header_layout = QtWidgets.QHBoxLayout()
        header_left_layout = QtWidgets.QVBoxLayout()
        header_right_layout = QtWidgets.QHBoxLayout()
        header_left_layout.addWidget(title)
        header_left_layout.addLayout(horizontal_section_layout)
        header_right_layout.addWidget(primary_button)
        header_right_layout.addWidget(secondary_button)
        header_layout.addLayout(header_left_layout)
        header_layout.addLayout(header_right_layout)

        layout.addLayout(header_layout)
        layout.addLayout(table_layout)

        self.setLayout(layout)

        db = db_manager.DB_Manager()
        total_table_count = db.get_total_table_count()
        stocks_1 = db.get_stocks_for_owner("stock_valdenegro")
        stocks_2 = db.get_stocks_for_owner("stock_karina")
        stocks_3 = db.get_stocks_for_owner("stock_brid")
        stocks_4 = db.get_stocks_for_owner("stock_tercero")
        self.all_components_display = db.get_all_display_names_for_components()
        self.stored_criticals = db.get_stored_criticals()
        self.unused_comps = db.get_components_not_in_use()
        db.close_connection()

        settings = QtCore.QSettings("solutronic", "admin_stock")
        self.excluded_state = settings.value("excluded_checkbox")

        stocks_g = []
        for i in range(total_table_count):
            result = stocks_1[i] + stocks_2[i] + stocks_3[i] + stocks_4[i]
            stocks_g.append(result)

        self.table.setRowCount(total_table_count)

        stocks_g_display = [
            utils.format_number_for_display(i) for i in stocks_g
        ]
        stocks_1_display = [
            utils.format_number_for_display(i) for i in stocks_1
        ]
        stocks_2_display = [
            utils.format_number_for_display(i) for i in stocks_2
        ]
        stocks_3_display = [
            utils.format_number_for_display(i) for i in stocks_3
        ]
        stocks_4_display = [
            utils.format_number_for_display(i) for i in stocks_4
        ]

        for count, value in enumerate([
                self.all_components_display,
                stocks_g_display,
                stocks_1_display,
                stocks_2_display,
                stocks_3_display,
                stocks_4_display,
        ]):
            utils.populate_table_column_with_list_of_strings(table=self.table,
                                                             col_num=count,
                                                             input_list=value)

        utils.color_criticals_in_orange_in_main_section(
            self.table, self.stored_criticals)
        utils.color_zeros_in_grey_in_main_section(self.table,
                                                  self.stored_criticals)
        utils.color_excluded_in_yellow_in_main_section(self.table,
                                                       self.excluded_state,
                                                       self.unused_comps)

        self.searchbar.returnPressed.connect(self.get_searched_component)
        primary_menu_item_1.triggered.connect(
            lambda: CriticalCompsDialog(self).exec_())
        primary_menu_item_2.triggered.connect(
            lambda: ExcludedCompsDialog(self).exec_())
        primary_menu_item_3.triggered.connect(self.export_to_spreadsheet)
        secondary_menu_item_1.triggered.connect(
            lambda: MovementsDialog(self).exec_())
        secondary_menu_item_2.triggered.connect(
            lambda: ConfigsDialog(self).exec_())
        self.table.horizontalHeader().sortIndicatorChanged.connect(
            self.sort_components_alphabetically)
        self.table.cellDoubleClicked.connect(self.open_component_details)
示例#26
0
    def __init__(self, parent=None):
        super(EditComponentDialog, self).__init__(parent)
        self.setWindowFlags(
            QtCore.Qt.Dialog
            | QtCore.Qt.CustomizeWindowHint
            | QtCore.Qt.WindowCloseButtonHint
        )
        self.setFixedWidth(200)
        self.setFixedHeight(250)

        self.comp_being_edited = ""

        title = QtWidgets.QLabel("Editar componente")
        title.setAlignment(QtCore.Qt.AlignCenter)
        title.setStyleSheet(generic_title_style)

        self.searchbar = AutocapField("Buscar componente a editar...")
        self.searchbar.set_completer(source="comps in stock")

        self.comps_table = QtWidgets.QTableWidget()
        self.comps_table.setColumnCount(1)
        self.comps_table.setHorizontalHeaderLabels(["Componente"])
        self.comps_table.setFocusPolicy(QtCore.Qt.NoFocus)
        self.comps_table.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
        self.comps_table.setSelectionMode(QtWidgets.QAbstractItemView.NoSelection)
        self.comps_table.verticalHeader().setVisible(False)
        self.comps_table.horizontalHeaderItem(0).setTextAlignment(
            QtCore.Qt.AlignHCenter
        )
        self.comps_table.horizontalHeader().setSectionResizeMode(
            0, QtWidgets.QHeaderView.Stretch
        )

        db = db_manager.DB_Manager()
        self.existing_comps = db.get_all_display_names_for_components()

        self.comps_table.setRowCount(len(self.existing_comps))
        utils.populate_table_column_with_list_of_strings(
            table=self.comps_table, col_num=0, input_list=self.existing_comps
        )
        self.comps_table.setSortingEnabled(True)
        self.comps_table.horizontalHeader().setSortIndicator(
            0, QtCore.Qt.AscendingOrder
        )
        self.comps_table.horizontalHeader().setSortIndicatorShown(False)

        back_button = QtWidgets.QPushButton("« Volver")
        back_button.setShortcut("Alt+v")

        layout = QtWidgets.QVBoxLayout()
        layout.addWidget(title)
        layout.addWidget(self.searchbar)
        layout.addWidget(self.comps_table)
        layout.addWidget(back_button)

        self.setLayout(layout)

        self.searchbar.returnPressed.connect(self.on_searchbar_return_pressed)
        self.comps_table.cellDoubleClicked.connect(self.on_table_item_double_clicked)
        back_button.clicked.connect(self.close)

        if not self.existing_comps:
            InformationBox("Sin componentes", "No hay componentes para editar.").exec_()
            QtCore.QTimer.singleShot(1, self.close)
示例#27
0
    def __init__(self, parent=None):
        super(ComponentDetailsDialog, self).__init__(parent)

        self.selected_comp_display = self.parent().selected_comp_display
        self.selected_comp_SQL = self.parent().selected_comp_SQL

        self.setWindowFlags(QtCore.Qt.Dialog
                            | QtCore.Qt.CustomizeWindowHint
                            | QtCore.Qt.WindowCloseButtonHint)

        self.categories_excluded_from_table = [
            "current_stock_valdenegro",
            "current_stock_karina",
            "current_stock_brid",
            "current_stock_tercero",
        ]

        title = QtWidgets.QLabel(self.selected_comp_display)
        title.setAlignment(QtCore.Qt.AlignCenter)
        title.setStyleSheet(comp_details_dialog_title_style)

        subtitles_layout = QtWidgets.QHBoxLayout()
        subtitle = QtWidgets.QLabel()
        subtitle.setStyleSheet(comp_details_dialog_title_style)

        db = db_manager.DB_Manager()
        self.comp_details = db.get_comp_details(self.selected_comp_SQL)
        db.close_connection()

        current_main = self.comp_details["current_stock_valdenegro"]
        current_first = self.comp_details["current_stock_karina"]
        current_second = self.comp_details["current_stock_brid"]
        current_third = self.comp_details["current_stock_tercero"]
        current_stocks = [
            current_main, current_first, current_second, current_third
        ]
        subtitles = ["Stock Valdenegro", "Stock Karina", "Stock Brid"]
        stocks_and_subtitles = dict(zip(subtitles, current_stocks))
        subtitles_layout.addStretch()

        for subtitle, stock in stocks_and_subtitles.items():
            subtitle = QtWidgets.QLabel(subtitle + ": " + stock)
            subtitles_layout.addWidget(subtitle)
            subtitles_layout.addStretch()

        self.table = QtWidgets.QTableWidget()
        self.table.setFocusPolicy(QtCore.Qt.NoFocus)
        self.table.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
        self.table.verticalHeader().setVisible(False)
        self.table.setSelectionMode(QtWidgets.QAbstractItemView.NoSelection)
        self.table.setRowCount(len(self.comp_details["fecha"]))
        self.table.setStyleSheet(movements_dialog_table_view_style)
        self.table.setColumnCount(16)
        self.fill_up_table()
        self.format_table()
        self.color_table()

        back_button = QtWidgets.QPushButton("« Volver")
        back_button.setShortcut("Alt+v")

        self.export_button = QtWidgets.QPushButton("Exportar detalles »")
        self.export_button.setShortcut("Alt+x")

        table_layout = QtWidgets.QVBoxLayout()
        table_layout.addWidget(self.table)

        bottom_section = QtWidgets.QHBoxLayout()
        bottom_section.addWidget(back_button)
        bottom_section.addWidget(self.export_button)

        layout = QtWidgets.QVBoxLayout()
        layout.addWidget(title)
        layout.addLayout(subtitles_layout)
        layout.addLayout(table_layout)
        layout.addLayout(bottom_section)

        self.setLayout(layout)

        back_button.clicked.connect(self.close)
        self.export_button.clicked.connect(self.export_to_spreadsheet)
示例#28
0
    def __init__(self, parent=None):
        super(DateSelectionSubdialog, self).__init__(parent)
        self.setWindowFlags(
            QtCore.Qt.Dialog
            | QtCore.Qt.CustomizeWindowHint
            | QtCore.Qt.WindowCloseButtonHint
        )
        self.setFixedWidth(270)

        self.selected_date = ""

        groupbox = QtWidgets.QGroupBox("Período")
        groupbox.setStyleSheet(movements_dialog_date_selection_subdialog_style)

        self.combobox_month = QtWidgets.QComboBox()
        self.combobox_month.setFixedWidth(85)
        self.combobox_month.addItem("Mes")

        months = [
            "Enero",
            "Febrero",
            "Marzo",
            "Abril",
            "Mayo",
            "Junio",
            "Julio",
            "Agosto",
            "Septiembre",
            "Octubre",
            "Noviembre",
            "Diciembre",
        ]

        for i in months:
            self.combobox_month.addItem(i)

        self.combobox_year = QtWidgets.QComboBox()
        self.combobox_year.addItem("Año")
        self.combobox_year.setFixedWidth(85)

        years = []
        db = db_manager.DB_Manager()
        if self.parent().title.text() == "Historial de movimientos":
            years = db.get_years_from_movements()
        elif self.parent().title.text() == "Historial de configuraciones":
            years = db.get_years_from_configs()
        for i in years:
            self.combobox_year.addItem(i)

        combobox_layout = QtWidgets.QHBoxLayout()
        combobox_layout.addWidget(self.combobox_month)
        combobox_layout.addWidget(self.combobox_year)

        groupbox_inner_layout = QtWidgets.QVBoxLayout()
        groupbox_inner_layout.addLayout(combobox_layout)
        groupbox.setLayout(groupbox_inner_layout)

        self.back_button = QtWidgets.QPushButton("« Volver")
        self.back_button.setShortcut("Alt+v")

        if self.parent().date_button.text() != "Período":
            self.back_button.setText("× Cancelar")
            self.back_button.setShortcut("Alt+c")

        self.select_button = QtWidgets.QPushButton("Seleccionar »")
        self.select_button.setShortcut("Alt+s")
        self.select_button.setEnabled(False)

        bottom_section = QtWidgets.QHBoxLayout()
        bottom_section.addWidget(self.back_button)
        bottom_section.addWidget(self.select_button)

        layout = QtWidgets.QVBoxLayout()
        layout.addWidget(groupbox)
        layout.addLayout(bottom_section)

        self.setLayout(layout)

        self.back_button.clicked.connect(self.on_back)
        self.select_button.clicked.connect(self.on_select_button_clicked)
        self.combobox_month.currentTextChanged.connect(self.on_combobox_change)
        self.combobox_year.currentTextChanged.connect(self.on_combobox_change)
示例#29
0
    def __init__(self, parent=None):
        super(ConfigsDialog, self).__init__(parent)
        self.setWindowFlags(
            QtCore.Qt.Dialog
            | QtCore.Qt.CustomizeWindowHint
            | QtCore.Qt.WindowCloseButtonHint
        )
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
        self.setFixedWidth(800)
        self.setFixedHeight(403)

        self.df = ""
        self.date_selection_dialog = ""

        self.title = QtWidgets.QLabel("Historial de configuraciones")
        self.title.setStyleSheet(movements_dialog_title_style)
        self.title.setAlignment(QtCore.Qt.AlignCenter)

        self.groupbox = QtWidgets.QGroupBox("Filtros")
        self.groupbox.setStyleSheet(generic_groupbox_normal_style)
        self.groupbox.setMinimumWidth(400)

        self.date_button = QtWidgets.QPushButton("Período")
        self.date_button.setMaximumHeight(22)
        self.date_button.setFocusPolicy(QtCore.Qt.NoFocus)

        self.comp_field = QtWidgets.QLineEdit()
        self.comp_field.setPlaceholderText("Detalle...")
        self.comp_field.setFixedWidth(200)
        self.comp_field.setFocus()

        self.config_combobox = QtWidgets.QComboBox()
        self.config_combobox.addItem("Configuración")

        configs = [
            "Creación de componente",
            "Edición de componente",
            "Borrado de componente",
            "Creación de receta",
            "Edición de receta",
            "Borrado de receta",
            "Edición de críticos",
            "Activado de excluidos",
            "Desactivado de excluidos",
        ]

        for config in configs:
            self.config_combobox.addItem(config)

        self.config_combobox.setFixedWidth(150)

        self.user_combobox = QtWidgets.QComboBox()
        self.user_combobox.addItem("Usuario")

        self.db = db_manager.DB_Manager()

        users = self.db.get_all_admin_users()
        for user in users:
            self.user_combobox.addItem(user)

        self.user_combobox.setFixedWidth(100)

        filters_layout = QtWidgets.QHBoxLayout()
        filters_layout.addWidget(self.date_button)
        filters_layout.addWidget(self.config_combobox)
        filters_layout.addWidget(self.comp_field)
        filters_layout.addWidget(self.user_combobox)

        groupbox_inner_layout = QtWidgets.QVBoxLayout()
        groupbox_inner_layout.addLayout(filters_layout)

        self.groupbox.setLayout(groupbox_inner_layout)
        groupbox_section = QtWidgets.QHBoxLayout()
        groupbox_section.addStretch()
        groupbox_section.addWidget(self.groupbox)
        groupbox_section.addStretch()

        back_button = QtWidgets.QPushButton("« Volver")
        back_button.setShortcut("Alt+v")
        back_button.setFocusPolicy(QtCore.Qt.NoFocus)

        self.delete_button = QtWidgets.QPushButton("× Borrar historial")
        self.delete_button.setShortcut("Alt+b")
        self.delete_button.setFocusPolicy(QtCore.Qt.NoFocus)

        self.export_button = QtWidgets.QPushButton("Exportar historial »")
        self.export_button.setShortcut("Alt+x")
        self.export_button.setFocusPolicy(QtCore.Qt.NoFocus)

        bottom_section = QtWidgets.QHBoxLayout()
        bottom_section.addWidget(back_button)
        bottom_section.addWidget(self.delete_button)
        bottom_section.addWidget(self.export_button)

        table_layout = QtWidgets.QVBoxLayout()

        self.table_view = QtWidgets.QTableView()
        self.table_view.verticalHeader().setVisible(False)
        table_layout.addWidget(self.table_view)
        layout = QtWidgets.QVBoxLayout()
        layout.addWidget(self.title)
        layout.addLayout(groupbox_section)
        layout.addLayout(table_layout)
        layout.addLayout(bottom_section)

        self.setLayout(layout)

        self.build_table_view()

        back_button.clicked.connect(self.close)
        self.delete_button.clicked.connect(self.delete_movements)
        self.export_button.clicked.connect(self.export_to_spreadsheet)
        self.date_button.clicked.connect(self.create_date_selection_subdialog)
        self.comp_field.returnPressed.connect(self.on_comp_field_return_press)
        self.config_combobox.currentIndexChanged.connect(self.on_combobox_change)
        self.user_combobox.currentIndexChanged.connect(self.on_combobox_change)
示例#30
0
    def __init__(self, parent=None):
        super(DeletionConfirmationBox, self).__init__(parent)
        self.setWindowTitle("Confirmación")
        self.setWindowFlags(QtCore.Qt.Dialog
                            | QtCore.Qt.CustomizeWindowHint
                            | QtCore.Qt.WindowTitleHint
                            | QtCore.Qt.WindowCloseButtonHint)

        self.comp_being_deleted_display_name = (
            self.parent().comp_being_deleted_display_name)

        db = db_manager.DB_Manager()
        relevant_recipes = db.get_recipes_containing_component(
            self.comp_being_deleted_display_name)
        db.close_connection()

        label_1 = QtWidgets.QLabel("¿Borrar este componente...?")
        label_2 = QtWidgets.QLabel(self.comp_being_deleted_display_name)
        label_2.setStyleSheet(delete_component_dialog_label_bold_style)
        label_3 = QtWidgets.QLabel("Se borrará también de estas recetas:")
        label_4 = QtWidgets.QLabel("No está integrado a ninguna receta.")

        for i in [label_1, label_3, label_4]:
            i.setStyleSheet(delete_component_dialog_label_normal_style)

        for i in [label_1, label_2, label_3, label_4]:
            i.setAlignment(QtCore.Qt.AlignCenter)

        recipes_table = QtWidgets.QTableWidget()
        recipes_table.setFixedWidth(400)
        recipes_table.setFocusPolicy(QtCore.Qt.NoFocus)
        recipes_table.setEditTriggers(
            QtWidgets.QAbstractItemView.NoEditTriggers)
        recipes_table.verticalHeader().setVisible(False)
        recipes_table.setSelectionMode(QtWidgets.QAbstractItemView.NoSelection)
        recipes_table.setColumnCount(3)
        recipes_table.setHorizontalHeaderLabels(
            ["Receta", "Componente", "Cantidad"])
        recipes_table.horizontalHeaderItem(0).setTextAlignment(
            QtCore.Qt.AlignHCenter)
        recipes_table.horizontalHeaderItem(1).setTextAlignment(
            QtCore.Qt.AlignHCenter)
        recipes_table.horizontalHeaderItem(2).setTextAlignment(
            QtCore.Qt.AlignHCenter)
        recipes_table.horizontalHeader().setDefaultSectionSize(90)
        recipes_table.horizontalHeader().setSectionResizeMode(
            0, QtWidgets.QHeaderView.Fixed)
        recipes_table.horizontalHeader().setSectionResizeMode(
            1, QtWidgets.QHeaderView.Stretch)
        recipes_table.horizontalHeader().setSectionResizeMode(
            2, QtWidgets.QHeaderView.Fixed)
        recipes_table.setRowCount(len(relevant_recipes.items()))

        if recipes_table.rowCount() <= 5:
            custom_height = recipes_table.rowCount() * 30 + 25
            recipes_table.setMaximumHeight(custom_height)
            recipes_table.setFixedHeight(custom_height)
        elif recipes_table.rowCount() > 5:
            recipes_table.setMaximumHeight(171)
            recipes_table.setFixedHeight(171)

        utils.populate_table_column_with_list_of_strings(
            table=recipes_table, col_num=0, input_list=relevant_recipes.keys())

        list_of_comp_being_deleted_repeated_row_times = [
            self.comp_being_deleted_display_name
            for i in range(len(relevant_recipes))
        ]

        utils.populate_table_column_with_list_of_strings(
            table=recipes_table,
            col_num=1,
            input_list=list_of_comp_being_deleted_repeated_row_times,
        )

        for row_number, amt_used in enumerate(relevant_recipes.values()):
            if len(str(amt_used).split(".")[1]) == 3:
                amt_used = utils.format_number_for_display(amt_used)
            else:
                amt_used = utils.format_number_for_display(amt_used)
            item = QtWidgets.QTableWidgetItem(amt_used)
            recipes_table.setItem(row_number, 2, item)
            item.setTextAlignment(QtCore.Qt.AlignCenter)

        no_button = QtWidgets.QPushButton("No")
        yes_button = QtWidgets.QPushButton("Sí")

        layout = QtWidgets.QVBoxLayout()
        layout.addWidget(label_1)
        layout.addWidget(label_2)

        if relevant_recipes != {}:
            layout.addWidget(label_3)
            layout.addWidget(recipes_table)
            self.related_records = True
        else:
            layout.addWidget(label_4)
            self.related_records = False

        bottom_section = QtWidgets.QHBoxLayout()
        bottom_section.addWidget(no_button)
        bottom_section.addWidget(yes_button)

        layout.addLayout(bottom_section)

        self.layout().addLayout(layout, 0, 0, 0, 0, QtCore.Qt.AlignCenter)
        self.setStyleSheet(generic_messagebox_style)

        no_button.clicked.connect(self.on_no_at_confirmation)
        yes_button.clicked.connect(self.on_yes_at_confirmation)