def __init__(self, data_provider, output, common):
        self.output = output
        self.data_provider = data_provider
        self.common = common
        self.project_name = self.data_provider.project_name
        self.session_uid = self.data_provider.session_uid
        self.session_id = self.data_provider.session_id
        self.session_info = self.data_provider[Data.SESSION_INFO]
        self.scene_info = self.data_provider[Data.SCENES_INFO]
        self.scene_results = self.data_provider[Data.SCENE_KPI_RESULTS]
        self.templates = self.data_provider[Data.TEMPLATES]
        self.products = self.data_provider[Data.PRODUCTS]
        self.all_products = self.data_provider[Data.ALL_PRODUCTS]
        self.match_product_in_scene = self.data_provider[Data.MATCHES]
        self.visit_date = self.data_provider[Data.VISIT_DATE]
        self.store_info = self.data_provider[Data.STORE_INFO]
        self.store_id = self.data_provider[Data.STORE_FK]
        self.scif = self.data_provider[Data.SCENE_ITEM_FACTS]
        self.scif['store_fk'] = self.store_id
        self.scif = self.scif[~(self.scif['product_type'].isin([Const.IRRELEVANT, Const.EMPTY]))]
        self.scif = self.scif[self.scif['facings'] > 0]
        self.rds_conn = PSProjectConnector(self.project_name, DbUsers.CalculationEng)
        self.kpis = self.load_kpis()
        self.results_values = self.load_results_values()
        self.kpi_static_data = self.common.get_kpi_static_data()
        self.manufacturer_fk = int(self.data_provider[Data.OWN_MANUFACTURER].iloc[0, 1])

        self.kpi_results = []

        self.assortment = Assortment(self.data_provider, self.output)
Example #2
0
 def __init__(self, data_provider, output, common):
     self.output = output
     self.data_provider = data_provider
     self.common = common
     self.project_name = self.data_provider.project_name
     self.session_uid = self.data_provider.session_uid
     self.products = self.data_provider[Data.PRODUCTS]
     self.all_products = self.data_provider[Data.ALL_PRODUCTS]
     self.match_product_in_scene = self.data_provider[Data.MATCHES]
     self.visit_date = self.data_provider[Data.VISIT_DATE]
     self.session_info = self.data_provider[Data.SESSION_INFO]
     self.scene_info = self.data_provider[Data.SCENES_INFO]
     self.store_id = self.data_provider[Data.STORE_FK]
     self.scif = self.data_provider[Data.SCENE_ITEM_FACTS]
     self.rds_conn = PSProjectConnector(self.project_name,
                                        DbUsers.CalculationEng)
     self.kpi_static_data = self.common.get_kpi_static_data()
     self.kpi_results_queries = []
     self.manufacturer_fk = self.products['manufacturer_fk'][
         self.products['manufacturer_name'] ==
         'MONDELEZ INTERNATIONAL INC'].iloc[0]
     self.store_assortment = pd.DataFrame()
     self.assortment = Assortment(self.data_provider, common=self.common)
     self.store_number = self.get_store_number()
     self.ps_data_provider = PsDataProvider(self.data_provider, self.output)
     self.custom_entities = self.ps_data_provider.get_custom_entities(
         Const.PPG_ENTITY_TYPE_FK)
    def __init__(self, data_provider, output):
        self.output = output
        self.data_provider = data_provider
        self.common = Common(self.data_provider)
        self.project_name = self.data_provider.project_name
        self.session_uid = self.data_provider.session_uid
        self.products = self.data_provider[Data.PRODUCTS]
        self.all_products = self.data_provider[Data.ALL_PRODUCTS]
        self.match_product_in_scene = self.data_provider[Data.MATCHES]
        self.visit_date = self.data_provider[Data.VISIT_DATE]
        self.current_date = datetime.now()
        self.session_info = self.data_provider[Data.SESSION_INFO]
        self.scene_info = self.data_provider[Data.SCENES_INFO]
        self.store_info = self.data_provider[Data.STORE_INFO]
        self.store_id = self.data_provider[Data.STORE_FK]
        self.own_manufacturer_id = int(self.data_provider[Data.OWN_MANUFACTURER][self.data_provider[Data.OWN_MANUFACTURER]['param_name'] == 'manufacturer_id']['param_value'].tolist()[0])
        self.scif = self.data_provider[Data.SCENE_ITEM_FACTS]
        self.rds_conn = PSProjectConnector(self.project_name, DbUsers.CalculationEng)
        self.toolbox = GENERALToolBox(data_provider)
        self.assortment = Assortment(self.data_provider, self.output, common=self.common)
        self.kpi_static_data = self.common.get_kpi_static_data()
        self.kpi_results_queries = []

        self.template_path = self.get_template_path()
        self.template_data = self.get_template_data()
        self.sos_store_policies = self.get_sos_store_policies(self.visit_date.strftime('%Y-%m-%d'))
        self.result_values = self.get_result_values()

        self.scores = pd.DataFrame()
Example #4
0
 def __init__(self, data_provider, output):
     self.output = output
     self.data_provider = data_provider
     self.common_v2 = CommonV2(self.data_provider)
     self.common_v1 = CommonV1(self.data_provider)
     self.data_provider.common_v2 = self.common_v2
     self.data_provider.common_v1 = self.common_v1
     self.project_name = self.data_provider.project_name
     self.session_uid = self.data_provider.session_uid
     self.products = self.data_provider[Data.PRODUCTS]
     self.all_products = self.data_provider[Data.ALL_PRODUCTS]
     self.match_product_in_scene = self.data_provider[Data.MATCHES]
     self.visit_date = self.data_provider[Data.VISIT_DATE]
     self.session_info = self.data_provider[Data.SESSION_INFO]
     self.scene_info = self.data_provider[Data.SCENES_INFO]
     self.store_id = self.data_provider[Data.STORE_FK]
     self.scif = self.data_provider[Data.SCENE_ITEM_FACTS]
     self.rds_conn = PSProjectConnector(self.project_name,
                                        DbUsers.CalculationEng)
     self.channel = self.get_store_channel(self.store_id)
     self.kpi_static_data = self.common_v2.get_kpi_static_data()
     self.data_provider.kpi_sheets = {}
     self.kpi_sheets = self.data_provider.kpi_sheets
     self.old_kpi_static_data = self.common_v1.get_kpi_static_data()
     for name in SHEETS_NAME:
         parsed_template = ParseTemplates.parse_template(TEMPLATE_PATH,
                                                         sheet_name=name)
         self.kpi_sheets[name] = parsed_template[parsed_template['Channel']
                                                 == self.channel]
     self.data_provider.sos = SOS(self.data_provider, output=None)
     self.data_provider.assortment = Assortment(self.data_provider,
                                                output=None)
 def __init__(self, data_provider, output):
     self.output = output
     self.data_provider = data_provider
     self.project_name = self.data_provider.project_name
     self.session_uid = self.data_provider.session_uid
     self.session_id = self.data_provider.session_id
     self.products = self.data_provider[Data.PRODUCTS]
     self.all_products = self.data_provider[Data.ALL_PRODUCTS]
     self.match_product_in_scene = self.data_provider[Data.MATCHES]
     self.visit_date = self.data_provider[Data.VISIT_DATE]
     self.session_info = self.data_provider[Data.SESSION_INFO]
     self.scene_info = self.data_provider[Data.SCENES_INFO]
     self.store_id = self.data_provider[Data.STORE_FK]
     self.scif = self.data_provider[Data.SCENE_ITEM_FACTS]
     self.rds_conn = PSProjectConnector(self.project_name,
                                        DbUsers.CalculationEng)
     # self.tools = RISPARKWINEDEGENERALToolBox(
     #     self.data_provider, self.output, rds_conn=self.rds_conn)
     # self.New_kpi_static_data = self.get_new_kpi_static_data()
     self.kpi_results_new_tables_queries = []
     # self.store_assortment = PSAssortmentDataProvider(self.data_provider).execute()
     self.store_info = self.data_provider[Data.STORE_INFO]
     self.current_date = datetime.now()
     self.assortment = Assortment(self.data_provider, self.output)
     self.store_assortment = self.assortment.store_assortment
     self.common = Common(self.data_provider)
 def __init__(self, data_provider, output):
     self.k_engine = BaseCalculationsScript(data_provider, output)
     self.output = output
     self.data_provider = data_provider
     self.project_name = self.data_provider.project_name
     self.session_uid = self.data_provider.session_uid
     self.products = self.data_provider[Data.PRODUCTS]
     self.all_products = self.data_provider[Data.ALL_PRODUCTS]
     self.match_product_in_scene = self.data_provider[Data.MATCHES]
     self.visit_date = self.data_provider[Data.VISIT_DATE]
     self.session_info = self.data_provider[Data.SESSION_INFO]
     self.scene_info = self.data_provider[Data.SCENES_INFO]
     self.store_id = self.data_provider[Data.STORE_FK]
     self.store_info = self.data_provider[Data.STORE_INFO]
     self.store_type = self.store_info['store_type'].iloc[0]
     self.scif = self.data_provider[Data.SCENE_ITEM_FACTS]
     self.rds_conn = PSProjectConnector(self.project_name, DbUsers.CalculationEng)
     self.general_tools = CCKHGENERALToolBox(self.data_provider, self.output)
     self.template = CCKHTemplateConsts()
     self.kpi_static_data = self.get_kpi_static_data()
     self.kpi_results_queries = []
     self.commonV2 = CommonV2(self.data_provider)
     self.kpi_new_static_data = self.commonV2.get_new_kpi_static_data()
     self.manufacturer = int(self.data_provider.own_manufacturer.param_value.values[0])
     self.ps_data_provider = PsDataProvider(self.data_provider, self.output)
     self.external_targets = self.ps_data_provider.get_kpi_external_targets()
     self.assortment = Assortment(self.data_provider, self.output)
     self.templates_info = self.external_targets[self.external_targets[CCKHTemplateConsts.TEMPLATE_OPERATION] ==
                                                 CCKHTemplateConsts.BASIC_SHEET]
     self.visibility_info = self.external_targets[self.external_targets[CCKHTemplateConsts.TEMPLATE_OPERATION]
                                                  == CCKHTemplateConsts.VISIBILITY_SHEET]
     self.cooler_info = self.external_targets[self.external_targets[CCKHTemplateConsts.TEMPLATE_OPERATION]
                                              == CCKHTemplateConsts.COOLER_SHEET]
Example #7
0
 def __init__(self, data_provider, output):
     self.output = output
     self.data_provider = data_provider
     self.ps_data_provider = PsDataProvider(data_provider)
     self.kpi_result_values = self.ps_data_provider.get_result_values()
     self.common_v2 = Common(self.data_provider)
     self.store_id = self.data_provider[Data.STORE_FK]
     self.scif = self.data_provider[Data.SCENE_ITEM_FACTS]
     self.assortment = Assortment(self.data_provider)
     self.own_manufacturer_fk = int(
         self.data_provider.own_manufacturer.param_value.values[0])
     self.kpi_static_data = self.common_v2.kpi_static_data[[
         'pk', StaticKpis.TYPE
     ]]
     # self.custom_entity = self.ps_data_provider.get_custom_entities(Consts.PRODUCT_GROUP)
     self.visit_date = self.data_provider[Data.VISIT_DATE]
     self.project_name = self.data_provider.project_name
     self.rds_conn = PSProjectConnector(self.project_name,
                                        DbUsers.CalculationEng)
     self.external_targets = self._retrieve_completeness_external_targets()
     self.products_trax_cat = self._get_products_with_trax_categories()
     self.ass_groups_present = {
         Consts.DISTR_SNACKS: 0,
         Consts.DISTR_SABRA: 0
     }
    def __init__(self, data_provider, output):
        self.output = output
        self.data_provider = data_provider
        self.common = Common(self.data_provider)
        self.common_v2 = CommonV2(self.data_provider)
        self.project_name = self.data_provider.project_name
        self.session_uid = self.data_provider.session_uid
        self.products = self.data_provider[Data.PRODUCTS]
        self.all_products = self.data_provider[Data.ALL_PRODUCTS]
        self.match_product_in_scene = self.data_provider[Data.MATCHES]
        self.visit_date = self.data_provider[Data.VISIT_DATE]
        self.session_info = self.data_provider[Data.SESSION_INFO]
        self.scene_info = self.data_provider[Data.SCENES_INFO]
        self.store_id = self.data_provider[Data.STORE_FK]
        self.scif = self.data_provider[Data.SCENE_ITEM_FACTS]
        self.template_info = self.data_provider.all_templates
        self.rds_conn = ProjectConnector(self.project_name,
                                         DbUsers.CalculationEng)
        self.ps_data_provider = PsDataProvider(self.data_provider)
        self.thresholds_and_results = {}
        self.result_df = []
        self.writing_to_db_time = datetime.timedelta(0)
        self.kpi_results_queries = []
        self.potential_products = {}
        self.shelf_square_boundaries = {}
        self.average_shelf_values = {}
        self.kpi_static_data = self.common.get_kpi_static_data()
        self.kpi_results_queries = []
        self.all_template_data = parse_template(TEMPLATE_PATH, "KPI")
        self.spacing_template_data = parse_template(TEMPLATE_PATH, "Spacing")
        self.fixture_width_template = pd.read_excel(FIXTURE_WIDTH_TEMPLATE,
                                                    "Fixture Width",
                                                    dtype=pd.Int64Dtype())
        self.facings_to_feet_template = pd.read_excel(FIXTURE_WIDTH_TEMPLATE,
                                                      "Conversion Table",
                                                      dtype=pd.Int64Dtype())
        self.header_positions_template = pd.read_excel(FIXTURE_WIDTH_TEMPLATE,
                                                       "Header Positions")
        self.flip_sign_positions_template = pd.read_excel(
            FIXTURE_WIDTH_TEMPLATE, "Flip Sign Positions")
        self.custom_entity_data = self.ps_data_provider.get_custom_entities(
            1005)
        self.ignore_stacking = False
        self.facings_field = 'facings' if not self.ignore_stacking else 'facings_ign_stack'
        self.INCLUDE_FILTER = 1
        self.assortment = Assortment(self.data_provider,
                                     output=self.output,
                                     ps_data_provider=self.ps_data_provider)
        self.store_assortment = self.assortment.get_lvl3_relevant_ass()

        self.kpi_new_static_data = self.common.get_new_kpi_static_data()
        try:
            self.mpis = self.match_product_in_scene.merge(self.products, on='product_fk', suffixes=['', '_p']) \
                        .merge(self.scene_info, on='scene_fk', suffixes=['', '_s']) \
                          .merge(self.template_info, on='template_fk', suffixes=['', '_t'])
        except KeyError:
            Log.warning('MPIS cannot be generated!')
            return
        self.adp = AltriaDataProvider(self.data_provider)
Example #9
0
 def main_calculation(self):
     """
     This function calculates the KPI results.
     """
     self.calculate_share_of_shelf()
     self.calculate_count_of_display()
     Assortment(self.data_provider, self.output,
                common=self.common).main_assortment_calculation()
 def __init__(self, data_provider, output):
     GlobalSessionToolBox.__init__(self, data_provider, output)
     self.assortment = Assortment(data_provider)
     self.ps_data = PsDataProvider(data_provider)
     self.display_in_scene = data_provider.match_display_in_scene
     self.static_display = data_provider.static_display
     self.manufacturer_fk = int(self.manufacturer_fk)
     self._add_display_data_to_scif()
     self._add_client_name_and_sub_brand_data()
Example #11
0
 def __init__(self, data_provider, output):
     GlobalSessionToolBox.__init__(self, data_provider, output)
     self.own_manufacturer_fk = int(self.data_provider.own_manufacturer.param_value.values[0])
     self.parser = Parser
     self.all_products = self.data_provider[Data.ALL_PRODUCTS]
     self.assortment = Assortment(self.data_provider, self.output)
     self.ps_data = PsDataProvider(self.data_provider, self.output)
     self.kpi_external_targets = self.ps_data.get_kpi_external_targets(key_fields=Consts.KEY_FIELDS,
                                                                       data_fields=Consts.DATA_FIELDS)
Example #12
0
    def __init__(self, output, data_provider):
        super(PepsicoUtil, self).__init__(data_provider)
        self.output = output
        self.common = Common(self.data_provider)
        # self.common_v1 = CommonV1(self.data_provider)
        self.project_name = self.data_provider.project_name
        self.session_uid = self.data_provider.session_uid
        self.products = self.data_provider[Data.PRODUCTS]
        self.all_products = self.data_provider[Data.ALL_PRODUCTS]
        self.match_product_in_scene = self.data_provider[Data.MATCHES]
        self.visit_date = self.data_provider[Data.VISIT_DATE]
        self.session_info = self.data_provider[Data.SESSION_INFO]
        self.scene_info = self.data_provider[Data.SCENES_INFO]
        self.store_id = self.data_provider[Data.STORE_FK] if self.data_provider[Data.STORE_FK] is not None \
                                                            else self.session_info['store_fk'].values[0]
        self.scif = self.data_provider[Data.SCENE_ITEM_FACTS]
        self.rds_conn = PSProjectConnector(self.project_name, DbUsers.CalculationEng)
        self.display_scene = self.get_match_display_in_scene()
        self.kpi_static_data = self.common.get_kpi_static_data()
        self.kpi_results_queries = []

        self.probe_groups = self.get_probe_group()
        self.match_product_in_scene = self.match_product_in_scene.merge(self.probe_groups, on='probe_match_fk',
                                                                        how='left')

        self.toolbox = GENERALToolBox(self.data_provider)
        self.commontools = PEPSICOUKCommonToolBox(self.data_provider, self.rds_conn)

        self.all_templates = self.commontools.all_templates
        self.custom_entities = self.commontools.custom_entities
        self.on_display_products = self.commontools.on_display_products
        self.exclusion_template = self.commontools.exclusion_template
        self.filtered_scif = self.commontools.filtered_scif.copy()
        self.filtered_matches = self.commontools.filtered_matches.copy()
        self.filtered_matches = self.filtered_matches.merge(self.probe_groups, on='probe_match_fk', how='left')

        self.filtered_scif_secondary = self.commontools.filtered_scif_secondary.copy()
        self.filtered_matches_secondary = self.commontools.filtered_matches_secondary.copy()

        self.scene_bay_shelf_product = self.commontools.scene_bay_shelf_product
        self.ps_data = PsDataProvider(self.data_provider, self.output)
        self.full_store_info = self.commontools.full_store_info.copy()
        self.external_targets = self.commontools.external_targets
        self.assortment = Assortment(self.commontools.data_provider, self.output)
        self.lvl3_ass_result = self.get_lvl3_relevant_assortment_result()
        self.own_manuf_fk = self.all_products[self.all_products['manufacturer_name'] == self.PEPSICO]['manufacturer_fk'].values[0]

        self.scene_kpi_results = self.get_results_of_scene_level_kpis()
        self.kpi_results_check = pd.DataFrame(columns=['kpi_fk', 'numerator', 'denominator', 'result', 'score',
                                                       'context'])
        self.sos_vs_target_targets = self.construct_sos_vs_target_base_df()

        self.all_targets_unpacked = self.commontools.all_targets_unpacked.copy()
        self.block_results = pd.DataFrame(columns=['Group Name', 'Score'])
        self.hero_type_custom_entity_df = self.get_hero_type_custom_entity_df()
Example #13
0
 def __init__(self, data_provider, output):
     self.output = output
     self.data_provider = data_provider
     self.common_v2 = Common(self.data_provider)
     self.all_products = self.data_provider[Data.ALL_PRODUCTS]
     self.store_id = self.data_provider[Data.STORE_FK]
     self.scif = self.data_provider[Data.SCENE_ITEM_FACTS]
     self.assortment = Assortment(self.data_provider, self.output)
     self.own_manufacturer_fk = int(self.data_provider.own_manufacturer.param_value.values[0])
     self.db_handler = DBHandler(self.data_provider.project_name, self.data_provider.session_uid)
     self.previous_oos_results = self.db_handler.get_last_session_oos_results()
     self.kpi_result_types = self.db_handler.get_kpi_result_value()
     self.oos_store_results = list()
     self.initial_scif = self.scif.copy()
    def __init__(self, data_provider, output):
        self.output = output
        self.data_provider = data_provider
        self.project_name = self.data_provider.project_name
        self.commonV2 = CommonV2(self.data_provider)
        self.common = Common(self.data_provider)
        self.assortment = Assortment(self.data_provider, self.output)

        self.own_manuf_fk = int(
            self.data_provider.own_manufacturer.param_value.values[0])
        self.store_info = self.data_provider[Data.STORE_INFO]
        self.new_kpi_static_data = self.commonV2.get_new_kpi_static_data()
        self.all_products_include_deleted = self.data_provider[
            Data.ALL_PRODUCTS_INCLUDING_DELETED]
        self.visit_date = self.data_provider[Data.VISIT_DATE]
Example #15
0
    def __init__(self, data_provider, common, output, template_path):
        self.output = output
        self.data_provider = data_provider
        self.common = common
        self.project_name = self.data_provider.project_name
        self.session_uid = self.data_provider.session_uid
        self.session_id = self.data_provider.session_id
        self.session_info = self.data_provider[Data.SESSION_INFO]
        self.scene_info = self.data_provider[Data.SCENES_INFO]
        self.scene_results = self.data_provider[Data.SCENE_KPI_RESULTS]
        self.templates = self.data_provider[Data.TEMPLATES]
        self.products = self.data_provider[Data.PRODUCTS]
        self.all_products = self.data_provider[Data.ALL_PRODUCTS]
        self.match_product_in_scene = self.data_provider[Data.MATCHES]
        self.mpis = self.make_mpis()
        self.visit_date = self.data_provider[Data.VISIT_DATE]
        self.store_info = self.data_provider[Data.STORE_INFO]
        self.store_id = self.data_provider[Data.STORE_FK]
        self.jump_shelves = pd.read_excel(template_path).T.to_dict('index')
        self.scif = self.generate_scif()
        self.scif['store_fk'] = self.store_id
        self.scif = self.scif[~(self.scif['product_type'] == Const.IRRELEVANT)]
        self.rds_conn = PSProjectConnector(self.project_name,
                                           DbUsers.CalculationEng)
        self.kpis = self.load_kpis()
        self.kpi_static_data = self.common.get_kpi_static_data()
        self.dist_oos = self.dist_kpi_to_oos_kpi()
        self.manufacturer_fk = int(
            self.data_provider[Data.OWN_MANUFACTURER].iloc[0, 1])
        self.gp_manufacturer = self.get_gp_manufacturer()
        self.gp_categories = self.get_gp_categories()
        self.gp_brands = self.get_gp_brands()
        self.all_man = self.scif[['manufacturer_name', 'manufacturer_fk']].set_index('manufacturer_name') \
                                                                          ['manufacturer_fk'].to_dict()
        self.all_brands = self.scif[[
            'brand_name', 'brand_fk'
        ]].set_index('brand_name')['brand_fk'].to_dict()
        self.man_fk_filter = {
            'manufacturer_name': list(self.gp_manufacturer.keys())
        }
        self.cat_filter = {'category': list(self.gp_categories.keys())}
        self.brand_filter = {'brand_name': list(self.gp_brands.keys())}
        self.all_brands_filter = {'brand_name': list(self.all_brands.keys())}
        self.all_man_filter = {'manufacturer_name': list(self.all_man.keys())}
        self.kpi_results = []

        self.assortment = Assortment(self.data_provider, self.output)
        self.assortment.scif = self.scif
Example #16
0
 def __init__(self, data_provider, output):
     self.output = output
     self.data_provider = data_provider
     self.common = Common(self.data_provider)
     self.project_name = self.data_provider.project_name
     self.session_uid = self.data_provider.session_uid
     self.products = self.data_provider[Data.PRODUCTS]
     self.all_products = self.data_provider[Data.ALL_PRODUCTS]
     self.match_product_in_scene = self.data_provider[Data.MATCHES]
     self.visit_date = self.data_provider[Data.VISIT_DATE]
     self.session_info = self.data_provider[Data.SESSION_INFO]
     self.scene_info = self.data_provider[Data.SCENES_INFO]
     self.store_id = self.data_provider[Data.STORE_FK]
     self.scif = self.data_provider[Data.SCENE_ITEM_FACTS]
     self.rds_conn = PSProjectConnector(self.project_name,
                                        DbUsers.CalculationEng)
     self.kpi_static_data = self.common.get_new_kpi_static_data()
     self.kpi_results_queries = []
     self.assortment = Assortment(self.data_provider, self.output)
    def __init__(self, data_provider, common, output):
        self.output = output
        self.data_provider = data_provider
        self.common = common
        self.project_name = self.data_provider.project_name
        self.session_uid = self.data_provider.session_uid
        self.session_info = self.data_provider[Data.SESSION_INFO]
        self.scene_info = self.data_provider[Data.SCENES_INFO]
        self.scene = self.scene_info.loc[0, 'scene_fk']
        self.templates = self.data_provider[Data.TEMPLATES]
        self.products = self.data_provider[Data.PRODUCTS]
        self.all_products = self.data_provider[Data.ALL_PRODUCTS]
        self.match_product_in_scene = self.data_provider[Data.MATCHES]

        self.visit_date = self.data_provider[Data.VISIT_DATE]
        self.store_id = self.data_provider[Data.STORE_FK]
        self.store_info = self.data_provider[Data.STORE_INFO]
        self.scif = self.data_provider[Data.SCENE_ITEM_FACTS]
        # self.scif = self.scif[~(self.scif['product_type'] == 'Irrelevant')]
        self.rds_conn = PSProjectConnector(self.project_name,
                                           DbUsers.CalculationEng)
        self.kpi_static_data = self.common.get_kpi_static_data()
        self.mdis = self.get_match_display_in_scene()
        self.mpis = self.get_mpis()
        self.manufacturer_fk = self.products['manufacturer_fk'][
            self.products['manufacturer_name'] ==
            'MONDELEZ INTERNATIONAL INC'].iloc[0]
        self.static_task_area_location = self.get_store_task_area()
        # self.vtw_points_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', 'Data',
        #                                 "VTW_POINTS_SCORE.xlsx")

        self.dmi_template = os.path.join(
            os.path.dirname(os.path.realpath(__file__)), '..', 'Data',
            "MondelezDMI_KPITemplatev7.1.xlsx")
        self.points_template = pd.read_excel(self.dmi_template,
                                             sheetname='VTW_POINTS')
        self.goldzone_template = pd.read_excel(self.dmi_template,
                                               sheetname='GOLD_ZONE')

        self.assortment = Assortment(self.data_provider, common=self.common)
        # self.ps_data_provider = PsDataProvider(self.data_provider, self.output)
        self.store_areas = self.get_store_area_df()
Example #18
0
 def __init__(self, output, data_provider):
     super(StraussfritolayilUtil, self).__init__(data_provider)
     self.output = output
     self.common = Common(self.data_provider)
     self.project_name = self.data_provider.project_name
     self.session_uid = self.data_provider.session_uid
     self.ps_data = PsDataProvider(self.data_provider, self.output)
     self.products = self.data_provider[Data.PRODUCTS]
     self.all_products = self.data_provider[Data.ALL_PRODUCTS]
     self.scif = self.data_provider[Data.SCENE_ITEM_FACTS]
     self.brand_mix_df = self.get_brand_mix_df()
     self.add_sub_brand_to_scif()
     self.add_brand_mix_to_scif()
     self.match_probe_in_scene = self.ps_data.get_product_special_attribute_data(self.session_uid)
     self.match_product_in_scene = self.data_provider[Data.MATCHES]
     if not self.match_product_in_scene.empty:
         self.match_product_in_scene = self.match_product_in_scene.merge(self.scif[Consts.RELEVENT_FIELDS],
                                                                         on=["scene_fk", "product_fk"], how="left")
         self.filter_scif_and_mpis_to_contain_only_primary_shelf()
     else:
         unique_fields = [ele for ele in Consts.RELEVENT_FIELDS if ele not in ["product_fk", "scene_fk"]]
         self.match_product_in_scene = pd.concat([self.match_product_in_scene,
                                                  pd.DataFrame(columns=unique_fields)], axis=1)
     self.match_product_in_scene_wo_hangers = self.exclude_special_attribute_products(df=self.match_product_in_scene)
     self.visit_date = self.data_provider[Data.VISIT_DATE]
     self.session_info = self.data_provider[Data.SESSION_INFO]
     self.scene_info = self.data_provider[Data.SCENES_INFO]
     self.store_info = self.data_provider[Data.STORE_INFO]
     self.additional_attribute_2 = self.store_info[Consts.ADDITIONAL_ATTRIBUTE_2].values[0]
     self.additional_attribute_3 = self.store_info[Consts.ADDITIONAL_ATTRIBUTE_3].values[0]
     self.additional_attribute_4 = self.store_info[Consts.ADDITIONAL_ATTRIBUTE_4].values[0]
     self.store_id = self.store_info['store_fk'].values[0] if self.store_info['store_fk'] is not None else 0
     self.rds_conn = PSProjectConnector(self.project_name, DbUsers.CalculationEng)
     self.toolbox = GENERALToolBox(self.data_provider)
     self.kpi_external_targets = self.ps_data.get_kpi_external_targets(key_fields=Consts.KEY_FIELDS,
                                                                       data_fields=Consts.DATA_FIELDS)
     self.filter_external_targets()
     self.assortment = Assortment(self.data_provider, self.output)
     self.lvl3_assortment = self.set_updated_assortment()
     self.own_manuf_fk = int(self.data_provider.own_manufacturer.param_value.values[0])
     self.own_manufacturer_matches_wo_hangers = self.match_product_in_scene_wo_hangers[
         self.match_product_in_scene_wo_hangers['manufacturer_fk'] == self.own_manuf_fk]
 def __init__(self, data_provider, output):
     self.output = output
     self.data_provider = data_provider
     self.common = Common(self.data_provider)
     self.common_v1 = CommonV1(self.data_provider)
     self.project_name = self.data_provider.project_name
     self.session_uid = self.data_provider.session_uid
     self.products = self.data_provider[Data.PRODUCTS]
     self.all_products = self.data_provider[Data.ALL_PRODUCTS]
     self.match_product_in_scene = self.data_provider[Data.MATCHES]
     self.visit_date = self.data_provider[Data.VISIT_DATE]
     self.session_info = self.data_provider[Data.SESSION_INFO]
     self.scene_info = self.data_provider[Data.SCENES_INFO]
     self.store_id = self.data_provider[Data.STORE_FK]
     self.store_info = self.data_provider[Data.STORE_INFO]
     self.visit_type = self.store_info[
         Const.ADDITIONAL_ATTRIBUTE_2].values[0]
     self.all_templates = self.data_provider[Data.ALL_TEMPLATES]
     self.scif = self.data_provider[Data.SCENE_ITEM_FACTS]
     self.scif = self.scif.loc[~(self.scif[Const.PRODUCT_TYPE]
                                 == Const.IRRELEVANT)]  # Vitaly's request
     self.rds_conn = PSProjectConnector(self.project_name,
                                        DbUsers.CalculationEng)
     self.kpi_static_data = self.common.get_kpi_static_data()
     self.kpi_results_queries = []
     self.k_engine = BaseCalculationsGroup(data_provider, output)
     self.toolbox = GENERALToolBox(data_provider)
     self.assortment = Assortment(self.data_provider,
                                  self.output,
                                  common=self.common_v1)
     if not self.scif.empty:
         self.pepsico_fk = self.get_relevant_pk_by_name(
             Const.MANUFACTURER, Const.PEPSICO)
         self.categories_to_calculate = self.get_relevant_categories_for_session(
         )
         self.main_shelves = self.get_main_shelves()
Example #20
0
 def get_relevant_assortment_instance(self, assortment):
     # upon recalculation products with OOS reasons are added to scif for assortment calculation
     if self.data_provider.session_info.status.values[0] == Consts.COMPLETED_STATUS:
         self.update_scif_for_assortment()
         assortment = Assortment(self.data_provider, self.output)
     return assortment
 def __init__(self, data_provider, output):
     GlobalSessionToolBox.__init__(self, data_provider, output)
     self.assortment = Assortment(self.data_provider, self.output)
 def __init__(self, data_provider, output):
     GlobalSessionToolBox.__init__(self, data_provider, output)
     self.assortment = Assortment(self.data_provider)
     self.ps_data = PsDataProvider(self.data_provider, self.output)
     self.result_values = self.ps_data.get_result_values()
     self.db_handler = DBHandler(self.data_provider.project_name, self.data_provider.session_uid)
Example #23
0
 def get_relevant_assortment_instance(self, assortment):
     if self.data_provider.session_info.status.values[0] == Consts.COMPLETED_STATUS:
         self.update_scif_for_assortment()
         assortment = Assortment(self.data_provider, self.output)
     return assortment