insert into businessunit_properties 
SELECT tenant_no,company_no,department_no,businessunit_no,'CRS_Client_Id','0'
FROM businessunits
WHERE NOT EXISTS (
	SELECT * 
     FROM businessunit_properties 
     WHERE property = 'CRS_Client_Id'
);

insert into businessunit_properties 
SELECT tenant_no,company_no,department_no,businessunit_no,'CRS_Direct_Url','0'
FROM businessunits
WHERE NOT EXISTS (
	SELECT * 
     FROM businessunit_properties 
     WHERE property = 'CRS_Direct_Url'
);

insert into businessunit_properties 
SELECT tenant_no,company_no,department_no,businessunit_no,'CRS_Saloon_No','0'
FROM businessunits
WHERE NOT EXISTS (
	SELECT * 
     FROM businessunit_properties 
     WHERE property = 'CRS_Saloon_No'
);

insert into businessunit_properties 
SELECT tenant_no,company_no,department_no,businessunit_no,'Disable_CheckIn_CheckOut','0'
FROM businessunits
WHERE NOT EXISTS (
	SELECT * 
     FROM businessunit_properties 
     WHERE property = 'Disable_CheckIn_CheckOut'
);

insert into businessunit_properties 
SELECT tenant_no,company_no,department_no,businessunit_no,'Hide_Customer_Export','0'
FROM businessunits
WHERE NOT EXISTS (
	SELECT * 
     FROM businessunit_properties 
     WHERE property = 'Hide_Customer_Export'
);

insert into businessunit_properties 
SELECT tenant_no,company_no,department_no,businessunit_no,'Protocol_For_DayClosure_Required','0'
FROM businessunits
WHERE NOT EXISTS (
	SELECT * 
     FROM businessunit_properties 
     WHERE property = 'Protocol_For_DayClosure_Required'
);

insert into businessunit_properties 
SELECT tenant_no,company_no,department_no,businessunit_no,'Sales_Payment_Transfer_Deactivated','0'
FROM businessunits
WHERE NOT EXISTS (
	SELECT * 
     FROM businessunit_properties 
     WHERE property = 'Sales_Payment_Transfer_Deactivated'
);

insert into businessunit_properties 
SELECT tenant_no,company_no,department_no,businessunit_no,'Book_On_Credit_Deactivated','0'
FROM businessunits
WHERE NOT EXISTS (
	SELECT * 
     FROM businessunit_properties 
     WHERE property = 'Book_On_Credit_Deactivated'
);

insert into businessunit_properties 
SELECT tenant_no,company_no,department_no,businessunit_no,'SALES_PRINT_OPTION','IMMEDIATE_PRINT'
FROM businessunits
WHERE NOT EXISTS (
	SELECT * 
     FROM businessunit_properties 
     WHERE property = 'SALES_PRINT_OPTION'
);

insert into businessunit_properties 
SELECT tenant_no,company_no,department_no,businessunit_no,'SORT_ITEMS','0'
FROM businessunits
WHERE NOT EXISTS (
	SELECT * 
     FROM businessunit_properties 
     WHERE property = 'SORT_ITEMS'
);

insert into businessunit_properties 
SELECT tenant_no,company_no,department_no,businessunit_no,'Scanable_FastInputs','0'
FROM businessunits
WHERE NOT EXISTS (
	SELECT * 
     FROM businessunit_properties 
     WHERE property = 'Scanable_FastInputs'
);

insert into businessunit_properties 
SELECT tenant_no,company_no,department_no,businessunit_no,'Search_Items','NON_STRICT'
FROM businessunits
WHERE NOT EXISTS (
	SELECT * 
     FROM businessunit_properties 
     WHERE property = 'Search_Items'
);

insert into businessunit_properties 
SELECT tenant_no,company_no,department_no,businessunit_no,'Enable_Voucher_For_Voucher_Overpay','0'
FROM businessunits
WHERE NOT EXISTS (
	SELECT * 
     FROM businessunit_properties 
     WHERE property = 'Enable_Voucher_For_Voucher_Overpay'
);

insert into businessunit_properties 
SELECT tenant_no,company_no,department_no,businessunit_no,'Disable_Immediate_CashDifference','0'
FROM businessunits
WHERE NOT EXISTS (
	SELECT * 
     FROM businessunit_properties 
     WHERE property = 'Disable_Immediate_CashDifference'
);

insert into businessunit_properties 
SELECT tenant_no,company_no,department_no,businessunit_no,'Focus_Card_On_Note_Search','0'
FROM businessunits
WHERE NOT EXISTS (
	SELECT * 
     FROM businessunit_properties 
     WHERE property = 'Focus_Card_On_Note_Search'
);

insert into businessunit_properties 
SELECT tenant_no,company_no,department_no,businessunit_no,'Disable_Ec_Payment_Overpay','0'
FROM businessunits
WHERE NOT EXISTS (
	SELECT * 
     FROM businessunit_properties 
     WHERE property = 'Disable_Ec_Payment_Overpay'
);

insert into businessunit_properties 
SELECT tenant_no,company_no,department_no,businessunit_no,'Requires_No_Parked_SalesInvs_On_DayClosure','1'
FROM businessunits
WHERE NOT EXISTS (
	SELECT * 
     FROM businessunit_properties 
     WHERE property = 'Requires_No_Parked_SalesInvs_On_DayClosure'
);

insert into simple_accounts
SELECT tenant_no,company_no,department_no,'K+New',19,0,0,'','',CAST(NULL AS DECIMAL),'Kassendifferenz +','',''
from businessunits
WHERE NOT EXISTS (
	SELECT * 
     FROM simple_accounts 
     WHERE simple_acct_type = 19
);

insert into simple_accounts
SELECT tenant_no,company_no,department_no,'K-New',20,0,0,'','',CAST(NULL AS DECIMAL),'Kassendifferenz -','',''
from businessunits
WHERE NOT EXISTS (
	SELECT * 
     FROM simple_accounts 
     WHERE simple_acct_type = 20
);


update businessunits set pos_cd_hint = (Select pos_cd from points_of_sale);

INSERT INTO CANCEL_PAYMENT_REASONS
SELECT TENANT_NO, COMPANY_NO, DEPARTMENT_NO, BUSINESSUNIT_NO, '1', 'falsche Zahlart'
FROM BUSINESSUNITS
WHERE NOT EXISTS (
	SELECT * 
     FROM CANCEL_PAYMENT_REASONS 
     WHERE payment_cancel_cd = '1'
);
INSERT INTO CANCEL_PAYMENT_REASONS
SELECT TENANT_NO, COMPANY_NO, DEPARTMENT_NO, BUSINESSUNIT_NO, '2', 'falscher Betrag'
FROM BUSINESSUNITS
WHERE NOT EXISTS (
	SELECT * 
     FROM CANCEL_PAYMENT_REASONS 
     WHERE payment_cancel_cd = '2'
);

INSERT INTO CANCEL_NOTE_REASONS
SELECT TENANT_NO, COMPANY_NO, DEPARTMENT_NO, BUSINESSUNIT_NO, '1', 'Reklamation'
FROM BUSINESSUNITS
WHERE NOT EXISTS (
	SELECT * 
     FROM CANCEL_NOTE_REASONS 
     WHERE note_cancel_cd = '1'
);
INSERT INTO CANCEL_NOTE_REASONS
SELECT TENANT_NO, COMPANY_NO, DEPARTMENT_NO, BUSINESSUNIT_NO, '2', 'falscher Mitarbeiter'
FROM BUSINESSUNITS
WHERE NOT EXISTS (
	SELECT * 
     FROM CANCEL_NOTE_REASONS 
     WHERE note_cancel_cd = '2'
);
INSERT INTO CANCEL_NOTE_REASONS
SELECT TENANT_NO, COMPANY_NO, DEPARTMENT_NO, BUSINESSUNIT_NO, '3', 'falsches Produkt'
FROM BUSINESSUNITS
WHERE NOT EXISTS (
	SELECT * 
     FROM CANCEL_NOTE_REASONS 
     WHERE note_cancel_cd = '3'
);

INSERT INTO EMPLOYEE_GROUPS
SELECT TENANT_NO, COMPANY_NO, 'Umsatzbarometer','Umsatzbarometer'
FROM BUSINESSUNITS
WHERE NOT EXISTS (
	SELECT * 
     FROM EMPLOYEE_GROUPS 
     WHERE employee_group_cd = 'Umsatzbarometer'
);
INSERT INTO EMPLOYEE_GROUPS
SELECT TENANT_NO, COMPANY_NO, 'Statistiken','Statistiken'
FROM BUSINESSUNITS
WHERE NOT EXISTS (
	SELECT * 
     FROM EMPLOYEE_GROUPS 
     WHERE employee_group_cd = 'Statistiken'
);

INSERT INTO EMPLOYEE_GROUP_PERMISSIONS
SELECT TENANT_NO, COMPANY_NO, 'Umsatzbarometer','P_REV_DASHBOARD','Umsatzbarometer'
FROM BUSINESSUNITS
WHERE NOT EXISTS (
	SELECT * 
     FROM EMPLOYEE_GROUP_PERMISSIONS 
     WHERE employee_group_cd = 'Umsatzbarometer'
);
INSERT INTO EMPLOYEE_GROUP_PERMISSIONS
SELECT TENANT_NO, COMPANY_NO, 'Statistiken','P_STATISTICS','Statistiken'
FROM BUSINESSUNITS
WHERE NOT EXISTS (
	SELECT * 
     FROM EMPLOYEE_GROUP_PERMISSIONS 
     WHERE employee_group_cd = 'Statistiken'
);

INSERT INTO item_report_categories select tenant_no,company_no, department_no, 'damen', 'Damen' FROM BUSINESSUNITS WHERE NOT EXISTS (SELECT * FROM item_report_categories      WHERE item_report_category_cd = 'damen');
INSERT INTO item_report_categories select tenant_no,company_no, department_no, 'herren', 'Herren' FROM BUSINESSUNITS WHERE NOT EXISTS (SELECT * FROM item_report_categories      WHERE item_report_category_cd = 'herren');
INSERT INTO item_report_categories select tenant_no,company_no, department_no, 'kinder', 'Kinder' FROM BUSINESSUNITS WHERE NOT EXISTS (SELECT * FROM item_report_categories      WHERE item_report_category_cd = 'kinder');
INSERT INTO item_report_categories select tenant_no,company_no, department_no, 'kosmetik', 'Kosmetik' FROM BUSINESSUNITS WHERE NOT EXISTS (SELECT * FROM item_report_categories      WHERE item_report_category_cd = 'kosmetik');
INSERT INTO item_report_categories select tenant_no,company_no, department_no, 'laser', 'Laser' FROM BUSINESSUNITS WHERE NOT EXISTS (SELECT * FROM item_report_categories      WHERE item_report_category_cd = 'laser');

INSERT INTO item_report_groups select tenant_no,company_no, department_no, 'damen','waschenlegen','Dwaschenlegen' FROM BUSINESSUNITS WHERE NOT EXISTS (SELECT * FROM item_report_groups      WHERE item_report_category_cd = 'damen' and  item_report_group_cd = 'waschenlegen');
INSERT INTO item_report_groups select tenant_no,company_no, department_no, 'damen','waschenfoenen','Dwaschenfoenen' FROM BUSINESSUNITS WHERE NOT EXISTS (SELECT * FROM item_report_groups      WHERE item_report_category_cd = 'damen' and  item_report_group_cd = 'waschenfoenen');
INSERT INTO item_report_groups select tenant_no,company_no, department_no, 'damen','dauerwelle','Ddauerwelle' FROM BUSINESSUNITS WHERE NOT EXISTS (SELECT * FROM item_report_groups      WHERE item_report_category_cd = 'damen' and  item_report_group_cd = 'dauerwelle');
INSERT INTO item_report_groups select tenant_no,company_no, department_no, 'damen','faerben','Dfaerben' FROM BUSINESSUNITS WHERE NOT EXISTS (SELECT * FROM item_report_groups      WHERE item_report_category_cd = 'damen' and  item_report_group_cd = 'faerben');
INSERT INTO item_report_groups select tenant_no,company_no, department_no, 'damen','straehnen','Dstraehnen' FROM BUSINESSUNITS WHERE NOT EXISTS (SELECT * FROM item_report_groups      WHERE item_report_category_cd = 'damen' and  item_report_group_cd = 'straehnen');
INSERT INTO item_report_groups select tenant_no,company_no, department_no, 'damen','toenen','Dtoenen' FROM BUSINESSUNITS WHERE NOT EXISTS (SELECT * FROM item_report_groups      WHERE item_report_category_cd = 'damen' and  item_report_group_cd = 'toenen');
INSERT INTO item_report_groups select tenant_no,company_no, department_no, 'damen','faerben','Dfaerben' FROM BUSINESSUNITS WHERE NOT EXISTS (SELECT * FROM item_report_groups      WHERE item_report_category_cd = 'damen' and  item_report_group_cd = 'faerben');
INSERT INTO item_report_groups select tenant_no,company_no, department_no, 'damen','haarschnitt','Dhaarschnitt' FROM BUSINESSUNITS WHERE NOT EXISTS (SELECT * FROM item_report_groups      WHERE item_report_category_cd = 'damen' and  item_report_group_cd = 'haarschnitt');
INSERT INTO item_report_groups select tenant_no,company_no, department_no, 'damen','haarpflege','Dhaarpflege' FROM BUSINESSUNITS WHERE NOT EXISTS (SELECT * FROM item_report_groups      WHERE item_report_category_cd = 'damen' and  item_report_group_cd = 'haarpflege');
INSERT INTO item_report_groups select tenant_no,company_no, department_no, 'damen','kopfhaut','Dkopfhaut' FROM BUSINESSUNITS WHERE NOT EXISTS (SELECT * FROM item_report_groups      WHERE item_report_category_cd = 'damen' and  item_report_group_cd = 'kopfhaut');
INSERT INTO item_report_groups select tenant_no,company_no, department_no, 'kosmetik','augen','Kaugen' FROM BUSINESSUNITS WHERE NOT EXISTS (SELECT * FROM item_report_groups      WHERE item_report_category_cd = 'kosmetik' and  item_report_group_cd = 'augen');
INSERT INTO item_report_groups select tenant_no,company_no, department_no, 'kosmetik','hand','Khand' FROM BUSINESSUNITS WHERE NOT EXISTS (SELECT * FROM item_report_groups      WHERE item_report_category_cd = 'kosmetik' and  item_report_group_cd = 'hand');
INSERT INTO item_report_groups select tenant_no,company_no, department_no, 'kosmetik','makeup','Kmakeup' FROM BUSINESSUNITS WHERE NOT EXISTS (SELECT * FROM item_report_groups      WHERE item_report_category_cd = 'kosmetik' and  item_report_group_cd = 'makeup');
INSERT INTO item_report_groups select tenant_no,company_no, department_no, 'herren','waschenfoenen','Hwaschenfoenen' FROM BUSINESSUNITS WHERE NOT EXISTS (SELECT * FROM item_report_groups      WHERE item_report_category_cd = 'herren' and  item_report_group_cd = 'waschenfoenen');
INSERT INTO item_report_groups select tenant_no,company_no, department_no, 'herren','dauerwelle','Hdauerwelle' FROM BUSINESSUNITS WHERE NOT EXISTS (SELECT * FROM item_report_groups      WHERE item_report_category_cd = 'herren' and  item_report_group_cd = 'dauerwelle');
INSERT INTO item_report_groups select tenant_no,company_no, department_no, 'herren','faerben','Hfaerben' FROM BUSINESSUNITS WHERE NOT EXISTS (SELECT * FROM item_report_groups      WHERE item_report_category_cd = 'herren' and  item_report_group_cd = 'faerben');
INSERT INTO item_report_groups select tenant_no,company_no, department_no, 'herren','haarschnitt1','Hhaarschnitt1' FROM BUSINESSUNITS WHERE NOT EXISTS (SELECT * FROM item_report_groups      WHERE item_report_category_cd = 'herren' and  item_report_group_cd = 'haarschnitt1');
INSERT INTO item_report_groups select tenant_no,company_no, department_no, 'herren','haarpflege','Hhaarpflege' FROM BUSINESSUNITS WHERE NOT EXISTS (SELECT * FROM item_report_groups      WHERE item_report_category_cd = 'herren' and  item_report_group_cd = 'haarpflege');
INSERT INTO item_report_groups select tenant_no,company_no, department_no, 'herren','kopfhaut','Hkopfhaut' FROM BUSINESSUNITS WHERE NOT EXISTS (SELECT * FROM item_report_groups      WHERE item_report_category_cd = 'herren' and  item_report_group_cd = 'kopfhaut');
INSERT INTO item_report_groups select tenant_no,company_no, department_no, 'kinder','waschenfoenen','Kwaschenfoenen' FROM BUSINESSUNITS WHERE NOT EXISTS (SELECT * FROM item_report_groups      WHERE item_report_category_cd = 'kinder' and  item_report_group_cd = 'waschenfoenen');
INSERT INTO item_report_groups select tenant_no,company_no, department_no, 'kinder','dauerwelle','Kdauerwelle' FROM BUSINESSUNITS WHERE NOT EXISTS (SELECT * FROM item_report_groups      WHERE item_report_category_cd = 'kinder' and  item_report_group_cd = 'dauerwelle');
INSERT INTO item_report_groups select tenant_no,company_no, department_no, 'kinder','faerben','Kfaerben' FROM BUSINESSUNITS WHERE NOT EXISTS (SELECT * FROM item_report_groups      WHERE item_report_category_cd = 'kinder' and  item_report_group_cd = 'faerben');
INSERT INTO item_report_groups select tenant_no,company_no, department_no, 'kinder','haarschnitt1','Khaarschnitt1' FROM BUSINESSUNITS WHERE NOT EXISTS (SELECT * FROM item_report_groups      WHERE item_report_category_cd = 'kinder' and  item_report_group_cd = 'haarschnitt1');
INSERT INTO item_report_groups select tenant_no,company_no, department_no, 'kinder','haarpflege','Khaarpflege' FROM BUSINESSUNITS WHERE NOT EXISTS (SELECT * FROM item_report_groups      WHERE item_report_category_cd = 'kinder' and  item_report_group_cd = 'haarpflege');
INSERT INTO item_report_groups select tenant_no,company_no, department_no, 'kinder','kopfhaut','Kkopfhaut' FROM BUSINESSUNITS WHERE NOT EXISTS (SELECT * FROM item_report_groups      WHERE item_report_category_cd = 'kinder' and  item_report_group_cd = 'kopfhaut');
INSERT INTO item_report_groups select tenant_no,company_no, department_no, 'laser','laser','Laser' FROM BUSINESSUNITS WHERE NOT EXISTS (SELECT * FROM item_report_groups      WHERE item_report_category_cd = 'laser' and  item_report_group_cd = 'laser');


  