update `storetype` set name = 'Company' where id = 1;
INSERT INTO `storetype` (name, active, created, createdById, updated, updatedById) VALUES ('Store Warehouse', 1, '2022-07-11 03:45:34', 10, '2022-07-11 03:45:34', 10);

ALTER TABLE preferredlocationtype
  RENAME TO `warehouseunit`;

update `warehouseunit` set name = 'Warehouse 1', description = 'warehouse 1' where id = 1;
INSERT INTO `warehouseunit` (name, description, active, created, createdById, updated, updatedById) VALUES ('Warehouse 2', 'warehouse 2', 1, '2022-07-11 03:45:34', 10, '2022-07-11 03:45:34', 10);

ALTER TABLE `store`
ADD COLUMN `warehouseunitId` int(10) DEFAULT NULL AFTER `typeId`;

ALTER TABLE `store`
ADD COLUMN `isCanCreateOrder` tinyint(1) NOT NULL DEFAULT 1 AFTER `warehouseunitId`;

ALTER TABLE `store`
ADD COLUMN `isCanCreatePo` tinyint(1) NOT NULL DEFAULT 1 AFTER `isCanCreateOrder`;

update store set isCanCreateOrder = 0 where id = 1;

INSERT INTO `store` (name, rootStoreId, typeId, warehouseunitId, isCanCreateOrder, isCanCreatePo, active, created, createdById, updated, updatedById) VALUES ('Company 1', null, 1, null, 1, 1, 1, '2022-07-11 03:45:34', 10, '2022-07-11 03:45:34', 10);
INSERT INTO `store` (name, rootStoreId, typeId, warehouseunitId, isCanCreateOrder, isCanCreatePo, active, created, createdById, updated, updatedById) VALUES ('Company 2', null, 1, null, 1, 1, 1, '2022-07-11 03:45:34', 10, '2022-07-11 03:45:34', 10);

INSERT INTO `store` (name, rootStoreId, typeId, warehouseunitId, isCanCreateOrder, isCanCreatePo, active, created, createdById, updated, updatedById) VALUES ('Head Office Warehouse 1', 1,  5, 1, 0, 1, 1, '2022-07-11 03:45:34', 10, '2022-07-11 03:45:34', 10);
INSERT INTO `store` (name, rootStoreId, typeId, warehouseunitId, isCanCreateOrder, isCanCreatePo, active, created, createdById, updated, updatedById) VALUES ('Head Office Warehouse 2', 1,  5, 2, 0, 1, 1, '2022-07-11 03:45:34', 10, '2022-07-11 03:45:34', 10);

INSERT INTO `store` (name, rootStoreId, typeId, warehouseunitId, isCanCreateOrder, isCanCreatePo, active, created, createdById, updated, updatedById) VALUES ('Company 1 Warehouse 1', 2,  5, 1, 1, 0, 1, '2022-07-11 03:45:34', 10, '2022-07-11 03:45:34', 10);
INSERT INTO `store` (name, rootStoreId, typeId, warehouseunitId, isCanCreateOrder, isCanCreatePo, active, created, createdById, updated, updatedById) VALUES ('Company 1 Warehouse 2', 2,  5, 2, 1, 0, 1, '2022-07-11 03:45:34', 10, '2022-07-11 03:45:34', 10);

INSERT INTO `store` (name, rootStoreId, typeId, warehouseunitId, isCanCreateOrder, isCanCreatePo, active, created, createdById, updated, updatedById) VALUES ('Company 2 Warehouse 1', 3,  5, 1, 1, 0, 1, '2022-07-11 03:45:34', 10, '2022-07-11 03:45:34', 10);
INSERT INTO `store` (name, rootStoreId, typeId, warehouseunitId, isCanCreateOrder, isCanCreatePo, active, created, createdById, updated, updatedById) VALUES ('Company 2 Warehouse 2', 3,  5, 2, 1, 0, 1, '2022-07-11 03:45:34', 10, '2022-07-11 03:45:34', 10);

INSERT INTO `store` (name, rootStoreId, typeId, warehouseunitId, isCanCreateOrder, isCanCreatePo, active, created, createdById, updated, updatedById) VALUES ('Hiring Stock', 1, 2, null, 0, 0, 1, '2022-07-11 03:45:34', 10, '2022-07-11 03:45:34', 10);


create table `storeprofile`(
    `id`  int(10) NOT NULL AUTO_INCREMENT ,
    `storeId` int(10) NOT NULL UNIQUE,
    `customerId` int(10) DEFAULT NULL ,
    `supplierId` int(10) DEFAULT NULL ,
    `orderPrefix` varchar(10) NOT NULL DEFAULT '',
    `invPrefix` varchar(10) NOT NULL DEFAULT '',
    `poPrefix` varchar(10) NOT NULL DEFAULT '',
    `logoURL` varchar(255) NOT NULL DEFAULT '',
    `ABN` varchar(20) NOT NULL DEFAULT '',
    `bankAccountName` varchar(50) NOT NULL DEFAULT '',
    `bankAccountNumber` varchar(10) NOT NULL DEFAULT '',
    `bankBSB` varchar(10) NOT NULL DEFAULT '',
    `active`  tinyint(1) NOT NULL DEFAULT 1 ,
    `created`  datetime NOT NULL DEFAULT '0001-01-01 00:00:00' ,
    `createdById`  int(10) NOT NULL DEFAULT 0 ,
    `updated`  timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
    `updatedById`  int(10) NOT NULL DEFAULT 0 ,
    PRIMARY KEY (`id`),
    INDEX `customerId` (`customerId`) USING BTREE ,
    INDEX `supplierId` (`supplierId`) USING BTREE ,
    INDEX `orderPrefix` (`orderPrefix`) USING BTREE ,
    INDEX `invPrefix` (`invPrefix`) USING BTREE ,
    INDEX `logoURL` (`logoURL`) USING BTREE ,
    INDEX `ABN` (`ABN`) USING BTREE ,
    INDEX `bankAccountName` (`bankAccountName`) USING BTREE ,
    INDEX `bankAccountNumber` (`bankAccountNumber`) USING BTREE ,
    INDEX `bankBSB` (`bankBSB`) USING BTREE ,
    INDEX `active` (`active`) USING BTREE ,
    INDEX `created` (`created`) USING BTREE ,
    INDEX `createdById` (`createdById`) USING BTREE ,
    INDEX `updated` (`updated`) USING BTREE ,
    INDEX `updatedById` (`updatedById`) USING BTREE
)
ENGINE=InnoDB
DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci
ROW_FORMAT=Compact;

INSERT INTO `storeprofile` (storeId, customerId, supplierId, orderPrefix, invPrefix, poPrefix, logoURL, ABN, bankAccountName, bankAccountNumber, bankBSB, active, created, createdById, updated, updatedById) VALUES (1, 3, 2, 'BPC', 'INVB', 'BPCP', '/themes/default/images/Head_Office.png', '111111' ,'Company one', '12341234', '123123', 1, '2022-08-02 03:45:34', 10, '2022-08-02 03:45:34', 10);

INSERT INTO `storeprofile` (storeId, customerId, supplierId, orderPrefix, invPrefix, poPrefix, logoURL, ABN, bankAccountName, bankAccountNumber, bankBSB, active, created, createdById, updated, updatedById) VALUES (2, 4, 3, 'UNF', 'INVU', 'UNFP', '/themes/default/images/BPC.png', '222222' ,'Company two', '45675678', '567567', 1, '2022-08-02 03:45:34', 10, '2022-08-02 03:45:34', 10);

INSERT INTO `storeprofile` (storeId, customerId, supplierId, orderPrefix, invPrefix, poPrefix, logoURL, ABN, bankAccountName, bankAccountNumber, bankBSB, active, created, createdById, updated, updatedById) VALUES (3, 5, 4, 'MERP', 'INVM', 'MERPP', '/themes/default/images/Scafeast.png', '333333' ,'Company three', '90129012', '901901', 1, '2022-08-02 03:45:34', 10, '2022-08-02 03:45:34', 10);
