feat(JavaScript): Updated architecture for TableBasePage object with static row ID attribute attached for adding ID against each row added to DOM

This commit is contained in:
2024-10-18 22:25:07 +01:00
parent 8fcfcf0ef4
commit 002551c0a9
112 changed files with 7280 additions and 3608 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -16,29 +16,42 @@ DROP TABLE IF EXISTS tmp_Price;
DROP TABLE IF EXISTS tmp_Shop_User;
DROP TABLE IF EXISTS tmp_Shop_Order;
DROP TABLE IF EXISTS tmp_Shop_Product;
DROP TABLE IF EXISTS tmp_Product;
DROP TABLE IF EXISTS tmp_Product_Permutation;
DROP TABLE IF EXISTS tmp_Permutation;
DROP TABLE IF EXISTS tmp_Shop_Product_p_shop_calc_user;
DROP TABLE IF EXISTS tmp_Shop_Product_p_Shop_Calc_User;
DROP TABLE IF EXISTS tmp_Shop_Image;
DROP TABLE IF EXISTS tmp_Image;
DROP TABLE IF EXISTS tmp_Product_Image;
DROP TABLE IF EXISTS tmp_Shop_Variation;
DROP TABLE IF EXISTS tmp_Variation;
DROP TABLE IF EXISTS tmp_Variation_Type;
DROP TABLE IF EXISTS tmp_Shop_Discount;
DROP TABLE IF EXISTS tmp_Discount;
DROP TABLE IF EXISTS tmp_Shop_Category;
DROP TABLE IF EXISTS tmp_Category;
DROP TABLE IF EXISTS tmp_Shop_Product_Category;
DROP TABLE IF EXISTS tmp_Product_Category;
DROP TABLE IF EXISTS tmp_Shop_Product_Currency_Region_Link;
DROP TABLE IF EXISTS tmp_Shop_Product_Currency_Link;
DROP TABLE IF EXISTS tmp_User_Role_Link;
DROP TABLE IF EXISTS tmp_Shop_Basket;
DROP TABLE IF EXISTS tmp_Shop_Supplier_Purchase_Order_Product_Link;
DROP TABLE IF EXISTS tmp_Supplier_Purchase_Order_Product_Link;
DROP TABLE IF EXISTS tmp_Shop_Supplier_Purchase_Order;
DROP TABLE IF EXISTS tmp_Supplier_Purchase_Order;
DROP TABLE IF EXISTS tmp_Shop_Supplier;
DROP TABLE IF EXISTS tmp_Supplier;
DROP TABLE IF EXISTS tmp_Shop_Manufacturing_Purchase_Order_Product_Link;
DROP TABLE IF EXISTS tmp_Manufacturing_Purchase_Order_Product_Link;
DROP TABLE IF EXISTS tmp_Shop_Manufacturing_Purchase_Order;
DROP TABLE IF EXISTS tmp_Manufacturing_Purchase_Order;
DROP TABLE IF EXISTS tmp_Shop_Customer;
DROP TABLE IF EXISTS tmp_Shop_Customer_Sale_Order_Product_Link;
DROP TABLE IF EXISTS tmp_Shop_Customer_Sale_Order;
# Delete old tables
DROP TABLE IF EXISTS Split_Temp;
DROP TABLE IF EXISTS Split_Key_Value_Pair_Csv_Temp;
@@ -62,6 +75,7 @@ DROP TABLE IF EXISTS Shop_Manufacturing_Purchase_Order_Product_Link_Temp;
DROP TABLE IF EXISTS Shop_Manufacturing_Purchase_Order_Product_Link_Audit;
DROP TABLE IF EXISTS Shop_Manufacturing_Purchase_Order_Product_Link;
DROP TABLE IF EXISTS Shop_Manufacturing_Purchase_Order_Temp;
DROP TABLE IF EXISTS Shop_Manufacturing_Purchase_Order_Audit;
DROP TABLE IF EXISTS Shop_Manufacturing_Purchase_Order;
@@ -69,9 +83,14 @@ DROP TABLE IF EXISTS Shop_Supplier_Purchase_Order_Product_Link_Temp;
DROP TABLE IF EXISTS Shop_Supplier_Purchase_Order_Product_Link_Audit;
DROP TABLE IF EXISTS Shop_Supplier_Purchase_Order_Product_Link;
DROP TABLE IF EXISTS Shop_Supplier_Purchase_Order_Temp;
DROP TABLE IF EXISTS Shop_Supplier_Purchase_Order_Audit;
DROP TABLE IF EXISTS Shop_Supplier_Purchase_Order;
DROP TABLE IF EXISTS Shop_Supplier_Address_Temp;
DROP TABLE IF EXISTS Shop_Supplier_Address_Audit;
DROP TABLE IF EXISTS Shop_Supplier_Address;
DROP TABLE IF EXISTS Shop_Supplier_Temp;
DROP TABLE IF EXISTS Shop_Supplier_Audit;
DROP TABLE IF EXISTS Shop_Supplier;

View File

@@ -5,18 +5,27 @@
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Address';
CREATE TABLE Shop_Address (
id_address INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
id_region INT NOT NULL,
postcode VARCHAR(20) NOT NULL,
address_line_1 VARCHAR(256) NOT NULL,
address_line_2 VARCHAR(256) NOT NULL,
city VARCHAR(256) NOT NULL,
county VARCHAR(256) NOT NULL,
active BIT NOT NULL DEFAULT 1,
created_on DATETIME,
created_by INT,
id_change_set INT,
CONSTRAINT FK_Shop_Address_id_change_set
id_address INT NOT NULL AUTO_INCREMENT PRIMARY KEY
, id_region INT NOT NULL
, CONSTRAINT FK_Shop_Address_id_region
FOREIGN KEY (id_region)
REFERENCES partsltd_prod.Shop_Region(id_region)
/*
, id_supplier INT NULL
, CONSTRAINT FK_Shop_Address_id_supplier
FOREIGN KEY (id_supplier)
REFERENCES partsltd_prod.Shop_Supplier(id_supplier)
*/
, postcode VARCHAR(20) NOT NULL
, address_line_1 VARCHAR(256) NOT NULL
, address_line_2 VARCHAR(256) NOT NULL
, city VARCHAR(256) NOT NULL
, county VARCHAR(256) NOT NULL
, active BIT NOT NULL DEFAULT 1
, created_on DATETIME
, created_by INT
, id_change_set INT
, CONSTRAINT FK_Shop_Address_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES Shop_User_Change_Set(id_change_set)
REFERENCES partsltd_prod.Shop_User_Change_Set(id_change_set)
);

View File

@@ -1,8 +1,6 @@
# Address Audits
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Address_Audit';
CREATE TABLE IF NOT EXISTS Shop_Address_Audit (

View File

@@ -8,10 +8,12 @@ CREATE TABLE IF NOT EXISTS Shop_Supplier (
name_company VARCHAR(255) NOT NULL,
name_contact VARCHAR(255) NULL,
department_contact VARCHAR(255) NULL,
/*
id_address INT NOT NULL,
CONSTRAINT FK_Shop_Supplier_id_address
FOREIGN KEY (id_address)
REFERENCES Shop_Address(id_address),
*/
phone_number VARCHAR(50) NULL,
fax VARCHAR(50) NULL,
email VARCHAR(255) NOT NULL,

View File

@@ -8,11 +8,12 @@ CREATE TABLE IF NOT EXISTS Shop_Supplier_Temp (
name_company VARCHAR(255) NOT NULL,
name_contact VARCHAR(255) NULL,
department_contact VARCHAR(255) NULL,
id_address INT NOT NULL,
-- id_address INT NOT NULL,
phone_number VARCHAR(50) NULL,
fax VARCHAR(50) NULL,
email VARCHAR(255) NOT NULL,
website VARCHAR(255) NULL,
id_currency INT NOT NULL,
active BIT NULL
active BIT NULL,
GUID BINARY(36) NOT NULL
);

View File

@@ -0,0 +1,29 @@
# Supplier Addresses
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Supplier_Address';
CREATE TABLE Shop_Supplier_Address (
id_address INT NOT NULL AUTO_INCREMENT PRIMARY KEY
, id_supplier INT NOT NULL
, CONSTRAINT FK_Shop_Supplier_Address_id_supplier
FOREIGN KEY (id_supplier)
REFERENCES partsltd_prod.Shop_Supplier(id_supplier)
ON UPDATE RESTRICT
, id_region INT NOT NULL
, CONSTRAINT FK_Shop_Supplier_Address_id_region
FOREIGN KEY (id_region)
REFERENCES partsltd_prod.Shop_Region(id_region)
, postcode VARCHAR(20) NOT NULL
, address_line_1 VARCHAR(256) NOT NULL
, address_line_2 VARCHAR(256) NOT NULL
, city VARCHAR(256) NOT NULL
, county VARCHAR(256) NOT NULL
, active BIT NOT NULL DEFAULT 1
, created_on DATETIME
, created_by INT
, id_change_set INT
, CONSTRAINT FK_Shop_Supplier_Address_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES partsltd_prod.Shop_User_Change_Set(id_change_set)
);

View File

@@ -0,0 +1,21 @@
# Supplier Address Audits
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Supplier_Address_Audit';
CREATE TABLE IF NOT EXISTS Shop_Supplier_Address_Audit (
id_audit INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
id_address INT NOT NULL,
CONSTRAINT FK_Shop_Supplier_Address_Audit_id_address
FOREIGN KEY (id_address)
REFERENCES Shop_Supplier_Address(id_address)
ON UPDATE RESTRICT,
name_field VARCHAR(50),
value_prev VARCHAR(500),
value_new VARCHAR(500),
id_change_set INT NOT NULL,
CONSTRAINT FK_Shop_Supplier_Address_Audit_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES Shop_User_Change_Set(id_change_set)
ON UPDATE RESTRICT
);

View File

@@ -0,0 +1,17 @@
# Supplier Addresses Staging
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Supplier_Address_Temp';
CREATE TABLE Shop_Supplier_Address_Temp (
id_address INT NOT NULL AUTO_INCREMENT PRIMARY KEY
, id_supplier INT NOT NULL
, id_region INT NOT NULL
, postcode VARCHAR(20) NOT NULL
, address_line_1 VARCHAR(256) NOT NULL
, address_line_2 VARCHAR(256) NOT NULL
, city VARCHAR(256) NOT NULL
, county VARCHAR(256) NOT NULL
, active BIT NOT NULL DEFAULT 1
, GUID BINARY(36) NOT NULL
);

View File

@@ -15,7 +15,7 @@ CREATE TABLE IF NOT EXISTS Shop_Supplier_Purchase_Order_Product_Link (
CONSTRAINT FK_Shop_Supplier_Purchase_Order_Product_Link_id_permutation
FOREIGN KEY (id_permutation)
REFERENCES Shop_Product_Permutation(id_permutation),
id_currency_cost INT NOT NULL,
-- id_currency_cost INT NOT NULL,
id_unit_quantity INT NOT NULL,
CONSTRAINT FK_Shop_Supplier_Purchase_Order_Product_Link_id_unit_quantity
FOREIGN KEY (id_unit_quantity)

View File

@@ -1,16 +1,22 @@
# Manufacturing Purchase Order
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Manufacturing_Purchase_Order';
CREATE TABLE IF NOT EXISTS Shop_Manufacturing_Purchase_Order (
id_order INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
/*
cost_total_local FLOAT NOT NULL,
id_currency_cost INT NOT NULL,
value_produced_total_local FLOAT NOT NULL,
*/
id_currency INT NOT NULL,
CONSTRAINT FK_Manufacturing_Purchase_Order_id_currency
FOREIGN KEY (id_currency)
REFERENCES Shop_Currency(id_currency),
cost_total_local_VAT_excl FLOAT NOT NULL,
cost_total_local_VAT_incl FLOAT NOT NULL,
price_total_local_VAT_excl FLOAT NOT NULL,
price_total_local_VAT_incl FLOAT NOT NULL,
/*
latency_delivery INT NOT NULL,
quantity_ordered FLOAT NOT NULL,

View File

@@ -0,0 +1,28 @@
# Manufacturing Purchase Order Temp
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Manufacturing_Purchase_Order_Temp';
CREATE TABLE IF NOT EXISTS Shop_Manufacturing_Purchase_Order_Temp (
id_order INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
/*
cost_total_local FLOAT NOT NULL,
*/
id_currency_cost INT NOT NULL,
cost_total_local_VAT_excl FLOAT NOT NULL,
cost_total_local_VAT_incl FLOAT NOT NULL,
price_total_local_VAT_excl FLOAT NOT NULL,
price_total_local_VAT_incl FLOAT NOT NULL,
/*
latency_delivery INT NOT NULL,
quantity_ordered FLOAT NOT NULL,
id_unit_quantity INT NOT NULL,
CONSTRAINT FK_Shop_Manufacturing_Purchase_Order_id_unit_quantity
FOREIGN KEY (id_unit_quantity)
REFERENCES Shop_Unit_Measurement(id_unit),
quantity_received INT NULL,
display_order INT NOT NULL,
*/
active BIT NOT NULL DEFAULT 1,
GUID BINARY(36) NOT NULL
);

View File

@@ -15,16 +15,17 @@ CREATE TABLE IF NOT EXISTS Shop_Manufacturing_Purchase_Order_Product_Link (
CONSTRAINT FK_Manufacturing_Purchase_Order_Product_Link_id_permutation
FOREIGN KEY (id_permutation)
REFERENCES Shop_Product_Permutation(id_permutation),
cost_total_local FLOAT NOT NULL,
id_currency_cost INT NOT NULL,
value_produced_total_local FLOAT NOT NULL,
quantity_used FLOAT NOT NULL,
cost_unit_local_VAT_excl FLOAT NOT NULL,
cost_unit_local_VAT_incl FLOAT NOT NULL,
price_unit_local_VAT_excl FLOAT NOT NULL,
price_unit_local_VAT_incl FLOAT NOT NULL,
id_unit_quantity INT NOT NULL,
CONSTRAINT FK_Manufacturing_Purchase_Order_id_unit_quantity
FOREIGN KEY (id_unit_quantity)
REFERENCES Shop_Unit_Measurement(id_unit_measurement),
latency_manufacture_days INT NOT NULL,
quantity_used FLOAT NOT NULL,
quantity_produced FLOAT NOT NULL,
latency_manufacture_days INT NOT NULL,
display_order INT NOT NULL,
active BIT NOT NULL,
created_on DATETIME,

View File

@@ -1,8 +1,6 @@
# Manufacturing Purchase Order Product Link Temp
-- DROP TABLE Shop_Manufacturing_Purchase_Order_Product_Link_Temp;
-- SELECT * FROM Shop_Manufacturing_Purchase_Order_Product_Link_Temp;
@@ -10,26 +8,17 @@ SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning
CREATE TABLE IF NOT EXISTS Shop_Manufacturing_Purchase_Order_Product_Link_Temp (
id_link INT NOT NULL PRIMARY KEY,
GUID BINARY(36) NOT NULL,
id_order INT NOT NULL,
/*
CONSTRAINT FK_Manuf_Purch_Order_Product_Link_Temp_id_order
FOREIGN KEY (id_order)
REFERENCES Shop_Manufacturing_Purchase_Order(id_order),
*/
id_permutation INT NOT NULL,
CONSTRAINT FK_Manuf_Purch_Order_Product_Link_Temp_id_permutation
FOREIGN KEY (id_permutation)
REFERENCES Shop_Product_Permutation(id_permutation),
cost_total_local FLOAT NOT NULL,
id_currency_cost INT NOT NULL,
quantity_used FLOAT NOT NULL,
id_unit_quantity INT NOT NULL,
CONSTRAINT FK_Manuf_Purch_Order_Product_Link_Temp_id_unit_quantity
FOREIGN KEY (id_unit_quantity)
REFERENCES Shop_Unit_Measurement(id_unit_measurement),
quantity_produced FLOAT NULL,
quantity_used FLOAT NOT NULL,
latency_manufacture_days INT NOT NULL,
quantity_produced FLOAT NOT NULL,
display_order INT NOT NULL,
active BIT NOT NULL
active BIT NOT NULL,
cost_unit_local_VAT_excl FLOAT NULL,
cost_unit_local_VAT_incl FLOAT NULL,
price_unit_local_VAT_excl FLOAT NULL,
price_unit_local_VAT_incl FLOAT NULL,
GUID BINARY(36) NOT NULL
);

View File

@@ -47,10 +47,12 @@ BEGIN
SELECT NEW.id_supplier, 'department_contact', OLD.department_contact, NEW.department_contact, NEW.id_change_set
WHERE NOT OLD.department_contact <=> NEW.department_contact
UNION
/*
# Changed id_address
SELECT NEW.id_supplier, 'id_address', OLD.id_address, NEW.id_address, NEW.id_change_set
WHERE NOT OLD.id_address <=> NEW.id_address
UNION
*/
# Changed phone_number
SELECT NEW.id_supplier, 'phone_number', OLD.phone_number, NEW.phone_number, NEW.id_change_set
WHERE NOT OLD.phone_number <=> NEW.phone_number

View File

@@ -0,0 +1,65 @@
# Shop Supplier Address
DROP TRIGGER IF EXISTS before_insert_Shop_Supplier_Address;
DROP TRIGGER IF EXISTS before_update_Shop_Supplier_Address;
DELIMITER //
CREATE TRIGGER before_insert_Shop_Supplier_Address
BEFORE INSERT ON Shop_Supplier_Address
FOR EACH ROW
BEGIN
SET NEW.created_on := IFNULL(NEW.created_on, NOW());
SET NEW.created_by := IFNULL(NEW.created_by, IFNULL((SELECT id_user FROM Shop_User WHERE firstname = CURRENT_USER()), -1));
END //
DELIMITER ;;
DELIMITER //
CREATE TRIGGER before_update_Shop_Supplier_Address
BEFORE UPDATE ON Shop_Supplier_Address
FOR EACH ROW
BEGIN
IF OLD.id_change_set <=> NEW.id_change_set THEN
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'New change Set ID must be provided.';
END IF;
INSERT INTO Shop_Supplier_Address_Audit (
id_address,
name_field,
value_prev,
value_new,
id_change_set
)
# Changed region
SELECT NEW.id_address, 'id_region', OLD.id_region, NEW.id_region, NEW.id_change_set
WHERE NOT OLD.id_region <=> NEW.id_region
UNION
# Changed postcode
SELECT NEW.id_address, 'postcode', OLD.postcode, NEW.postcode, NEW.id_change_set
WHERE NOT OLD.postcode <=> NEW.postcode
UNION
# Changed address_line_1
SELECT NEW.id_address, 'address_line_1', OLD.address_line_1, NEW.address_line_1, NEW.id_change_set
WHERE NOT OLD.address_line_1 <=> NEW.address_line_1
UNION
# Changed address_line_2
SELECT NEW.id_address, 'address_line_2', OLD.address_line_2, NEW.address_line_2, NEW.id_change_set
WHERE NOT OLD.address_line_2 <=> NEW.address_line_2
UNION
# Changed city
SELECT NEW.id_address, 'city', OLD.city, NEW.city, NEW.id_change_set
WHERE NOT OLD.city <=> NEW.city
UNION
# Changed county
SELECT NEW.id_address, 'county', OLD.county, NEW.county, NEW.id_change_set
WHERE NOT OLD.county <=> NEW.county
UNION
# Changed active
SELECT NEW.id_address, 'active', CONVERT(CONVERT(OLD.active, SIGNED), CHAR), CONVERT(CONVERT(NEW.active, SIGNED), CHAR), NEW.id_change_set
WHERE NOT (OLD.active <=> NEW.active)
;
END //
DELIMITER ;;

View File

@@ -38,14 +38,18 @@ BEGIN
# Changed id_supplier_ordered
SELECT NEW.id_order, 'id_supplier_ordered', OLD.id_supplier_ordered, NEW.id_supplier_ordered, NEW.id_change_set
WHERE NOT OLD.id_supplier_ordered <=> NEW.id_supplier_ordered
UNION
# Changed cost_total_local
SELECT NEW.id_order, 'cost_total_local', OLD.cost_total_local, NEW.cost_total_local, NEW.id_change_set
WHERE NOT OLD.cost_total_local <=> NEW.cost_total_local
UNION
# Changed id_currency_cost
SELECT NEW.id_order, 'id_currency_cost', OLD.id_currency_cost, NEW.id_currency_cost, NEW.id_change_set
WHERE NOT OLD.id_currency_cost <=> NEW.id_currency_cost
UNION
# Changed cost_total_local_VAT_excl
SELECT NEW.id_order, 'cost_total_local_VAT_excl', OLD.cost_total_local_VAT_excl, NEW.cost_total_local_VAT_excl, NEW.id_change_set
WHERE NOT OLD.cost_total_local_VAT_excl <=> NEW.cost_total_local_VAT_excl
UNION
# Changed cost_total_local_VAT_incl
SELECT NEW.id_order, 'cost_total_local_VAT_incl', OLD.cost_total_local_VAT_incl, NEW.cost_total_local_VAT_incl, NEW.id_change_set
WHERE NOT OLD.cost_total_local_VAT_incl <=> NEW.cost_total_local_VAT_incl
/*
UNION
# Changed latency_delivery

View File

@@ -43,15 +43,13 @@ BEGIN
SELECT NEW.id_link, 'id_permutation', OLD.id_permutation, NEW.id_permutation, NEW.id_change_set
WHERE NOT OLD.id_permutation <=> NEW.id_permutation
UNION
# Changed cost_total_local
SELECT NEW.id_link, 'cost_total_local', OLD.cost_total_local, NEW.cost_total_local, NEW.id_change_set
WHERE NOT OLD.cost_total_local <=> NEW.cost_total_local
UNION
/*
# Changed id_currency_cost
SELECT NEW.id_link, 'id_currency_cost', OLD.id_currency_cost, NEW.id_currency_cost, NEW.id_change_set
WHERE NOT OLD.id_currency_cost <=> NEW.id_currency_cost
UNION
# Changed quantity_ordered
*/
# Changed quantity_ordered
SELECT NEW.id_link, 'quantity_ordered', OLD.quantity_ordered, NEW.quantity_ordered, NEW.id_change_set
WHERE NOT OLD.quantity_ordered <=> NEW.quantity_ordered
UNION
@@ -74,6 +72,22 @@ BEGIN
# Changed active
SELECT NEW.id_link, 'active', OLD.active, NEW.active, NEW.id_change_set
WHERE NOT OLD.active <=> NEW.active
UNION
# Changed cost_total_local_VAT_excl
SELECT NEW.id_link, 'cost_total_local_VAT_excl', OLD.cost_total_local_VAT_excl, NEW.cost_total_local_VAT_excl, NEW.id_change_set
WHERE NOT OLD.cost_total_local_VAT_excl <=> NEW.cost_total_local_VAT_excl
UNION
# Changed cost_total_local_VAT_incl
SELECT NEW.id_link, 'cost_total_local_VAT_incl', OLD.cost_total_local_VAT_incl, NEW.cost_total_local_VAT_incl, NEW.id_change_set
WHERE NOT OLD.cost_total_local_VAT_incl <=> NEW.cost_total_local_VAT_incl
UNION
# Changed cost_unit_local_VAT_excl
SELECT NEW.id_link, 'cost_unit_local_VAT_excl', OLD.cost_unit_local_VAT_excl, NEW.cost_unit_local_VAT_excl, NEW.id_change_set
WHERE NOT OLD.cost_unit_local_VAT_excl <=> NEW.cost_unit_local_VAT_excl
UNION
# Changed cost_unit_local_VAT_incl
SELECT NEW.id_link, 'cost_unit_local_VAT_incl', OLD.cost_unit_local_VAT_incl, NEW.cost_unit_local_VAT_incl, NEW.id_change_set
WHERE NOT OLD.cost_unit_local_VAT_incl <=> NEW.cost_unit_local_VAT_incl
;
END //
DELIMITER ;;

View File

@@ -35,17 +35,25 @@ BEGIN
value_new,
id_change_set
)
# Changed cost_total_local
SELECT NEW.id_order, 'cost_total_local', OLD.cost_total_local, NEW.cost_total_local, NEW.id_change_set
WHERE NOT OLD.cost_total_local <=> NEW.cost_total_local
# Changed id_currency
SELECT NEW.id_order, 'id_currency', OLD.id_currency, NEW.id_currency, NEW.id_change_set
WHERE NOT OLD.id_currency <=> NEW.id_currency
UNION
# Changed value_produced_total_local
SELECT NEW.id_order, 'value_produced_total_local', OLD.value_produced_total_local, NEW.value_produced_total_local, NEW.id_change_set
WHERE NOT OLD.value_produced_total_local <=> NEW.value_produced_total_local
# Changed cost_total_local_VAT_excl
SELECT NEW.id_order, 'cost_total_local_VAT_excl', OLD.cost_total_local_VAT_excl, NEW.cost_total_local_VAT_excl, NEW.id_change_set
WHERE NOT OLD.cost_total_local_VAT_excl <=> NEW.cost_total_local_VAT_excl
UNION
# Changed id_currency_cost
SELECT NEW.id_order, 'id_currency_cost', OLD.id_currency_cost, NEW.id_currency_cost, NEW.id_change_set
WHERE NOT OLD.id_currency_cost <=> NEW.id_currency_cost
# Changed cost_total_local_VAT_incl
SELECT NEW.id_order, 'cost_total_local_VAT_incl', OLD.cost_total_local_VAT_incl, NEW.cost_total_local_VAT_incl, NEW.id_change_set
WHERE NOT OLD.cost_total_local_VAT_incl <=> NEW.cost_total_local_VAT_incl
UNION
# Changed price_total_local_VAT_excl
SELECT NEW.id_order, 'price_total_local_VAT_excl', OLD.price_total_local_VAT_excl, NEW.price_total_local_VAT_excl, NEW.id_change_set
WHERE NOT OLD.price_total_local_VAT_excl <=> NEW.price_total_local_VAT_excl
UNION
# Changed price_total_local_VAT_incl
SELECT NEW.id_order, 'price_total_local_VAT_incl', OLD.price_total_local_VAT_incl, NEW.price_total_local_VAT_incl, NEW.id_change_set
WHERE NOT OLD.price_total_local_VAT_incl <=> NEW.price_total_local_VAT_incl
UNION
# Changed active
SELECT NEW.id_order, 'active', OLD.active, NEW.active, NEW.id_change_set

View File

@@ -43,25 +43,33 @@ BEGIN
SELECT NEW.id_link, 'id_permutation', OLD.id_permutation, NEW.id_permutation, NEW.id_change_set
WHERE NOT OLD.id_permutation <=> NEW.id_permutation
UNION
# Changed cost_total_local
SELECT NEW.id_link, 'cost_total_local', OLD.cost_total_local, NEW.cost_total_local, NEW.id_change_set
WHERE NOT OLD.cost_total_local <=> NEW.cost_total_local
UNION
# Changed id_currency_cost
SELECT NEW.id_link, 'id_currency_cost', OLD.id_currency_cost, NEW.id_currency_cost, NEW.id_change_set
WHERE NOT OLD.id_currency_cost <=> NEW.id_currency_cost
# Changed id_unit_quantity
SELECT NEW.id_link, 'id_unit_quantity', OLD.id_unit_quantity, NEW.id_unit_quantity, NEW.id_change_set
WHERE NOT OLD.id_unit_quantity <=> NEW.id_unit_quantity
UNION
# Changed quantity_used
SELECT NEW.id_link, 'quantity_used', OLD.quantity_used, NEW.quantity_used, NEW.id_change_set
WHERE NOT OLD.quantity_used <=> NEW.quantity_used
UNION
# Changed id_unit_quantity
SELECT NEW.id_link, 'id_unit_quantity', OLD.id_unit_quantity, NEW.id_unit_quantity, NEW.id_change_set
WHERE NOT OLD.id_unit_quantity <=> NEW.id_unit_quantity
UNION
# Changed quantity_produced
SELECT NEW.id_link, 'quantity_produced', OLD.quantity_produced, NEW.quantity_produced, NEW.id_change_set
WHERE NOT OLD.quantity_produced <=> NEW.quantity_produced
UNION
# Changed cost_unit_local_VAT_excl
SELECT NEW.id_order, 'cost_unit_local_VAT_excl', OLD.cost_unit_local_VAT_excl, NEW.cost_unit_local_VAT_excl, NEW.id_change_set
WHERE NOT OLD.cost_unit_local_VAT_excl <=> NEW.cost_unit_local_VAT_excl
UNION
# Changed cost_unit_local_VAT_incl
SELECT NEW.id_order, 'cost_unit_local_VAT_incl', OLD.cost_unit_local_VAT_incl, NEW.cost_unit_local_VAT_incl, NEW.id_change_set
WHERE NOT OLD.cost_unit_local_VAT_incl <=> NEW.cost_unit_local_VAT_incl
UNION
# Changed price_unit_local_VAT_excl
SELECT NEW.id_order, 'price_unit_local_VAT_excl', OLD.price_unit_local_VAT_excl, NEW.price_unit_local_VAT_excl, NEW.id_change_set
WHERE NOT OLD.price_unit_local_VAT_excl <=> NEW.price_unit_local_VAT_excl
UNION
# Changed price_unit_local_VAT_incl
SELECT NEW.id_order, 'price_unit_local_VAT_incl', OLD.price_unit_local_VAT_incl, NEW.price_unit_local_VAT_incl, NEW.id_change_set
WHERE NOT OLD.price_unit_local_VAT_incl <=> NEW.price_unit_local_VAT_incl
UNION
# Changed latency_manufacture_days
SELECT NEW.id_link, 'latency_manufacture_days', OLD.latency_manufacture_days, NEW.latency_manufacture_days, NEW.id_change_set

View File

@@ -17,27 +17,25 @@ BEGIN
SET v_time_end := CURRENT_TIMESTAMP(6);
SELECT
a_time_start
, UNIX_DATETIME(a_time_start)
, UNIX_TIMESTAMP(a_time_start)
, MICROSECOND(a_time_start) / 1000
, v_time_end
, UNIX_DATETIME(v_time_end)
, UNIX_TIMESTAMP(v_time_end)
, MICROSECOND(v_time_end) / 1000
, v_time_end - a_time_start AS timestamp_delta
, UNIX_DATETIME(v_time_end - a_time_start) AS UNIX_DATETIME_timestamp_delta
, UNIX_TIMESTAMP(v_time_end - a_time_start) AS UNIX_TIMESTAMP_timestamp_delta
, MICROSECOND(v_time_end - a_time_start) AS MICROSECOND_timestamp_delta
-- , TIME_FORMAT(TIMEDIFF(v_time_end, a_time_start), '%H:%i:%s') AS time_difference
, CONCAT(
TIME_FORMAT(TIMEDIFF(v_time_end, a_time_start), '%H hours, %i minutes, %s seconds'),
', ',
DATETIMEDIFF(MICROSECOND, a_time_start, v_time_end) % 1000000 / 1000, ' milliseconds'
TIMESTAMPDIFF(MICROSECOND, a_time_start, v_time_end) % 1000000 / 1000, ' milliseconds'
) AS time_difference
;
END //
DELIMITER ;;
/*
CALL partsltd_prod.p_debug_timing_reporting (
CURRENT_TIMESTAMP(6)

View File

@@ -373,8 +373,8 @@ BEGIN
)
)
AND (
a_get_products_quantity_stock_below_min = 1
AND PP.quantity_stock < PP.quantity_min
a_get_products_quantity_stock_below_min = 0
OR PP.quantity_stock < PP.quantity_min
)
AND (
a_get_inactive_permutation = 1

View File

@@ -447,8 +447,13 @@ BEGIN
-- WHERE guid = v_guid
;
IF a_debug = 1 THEN
SELECT * FROM tmp_Category;
SELECT * FROM tmp_Product;
SELECT * FROM tmp_Permutation;
SELECT * FROM tmp_Image;
END IF;
-- Clean up
DROP TEMPORARY TABLE IF EXISTS tmp_Split;
DROP TEMPORARY TABLE IF EXISTS tmp_Image;
DROP TEMPORARY TABLE IF EXISTS tmp_Category;
@@ -481,7 +486,7 @@ CALL partsltd_prod.p_shop_get_many_product (
, 0 # a_get_inactive_image
, '' # a_ids_image
, 0 # a_get_products_quantity_stock_below_minimum
, 0 # a_debug
, 1 # a_debug
);
select * FROM partsltd_prod.Shop_Calc_User_Temp;

View File

@@ -45,9 +45,11 @@ BEGIN
, msg
)
SELECT
NULL
id_type
, @errno
, @text
FROM partsltd_prod.Shop_Msg_Error_Type MET
WHERE code = 'MYSQL_ERROR'
;
SELECT *
FROM tmp_Msg_Error;
@@ -55,12 +57,12 @@ BEGIN
END;
SET v_time_start := CURRENT_TIMESTAMP(6);
SET v_code_type_error_bad_data := (SELECT code FROM partsltd_prod.Shop_Msg_Error_Type WHERE code = 'BAD_DATA');
SET v_id_type_error_bad_data := (SELECT id_type FROM partsltd_prod.Shop_Msg_Error_Type WHERE code = v_code_type_error_bad_data);
SET v_code_type_error_no_permission := (SELECT code FROM partsltd_prod.Shop_Msg_Error_Type WHERE code = 'NO_PERMISSION');
SET v_id_type_error_no_permission := (SELECT id_type FROM partsltd_prod.Shop_Msg_Error_Type WHERE code = v_code_type_error_no_permission);
SET v_id_permission_supplier = (SELECT id_permission FROM partsltd_prod.Shop_Permission WHERE code = 'STORE_SUPPLIER' LIMIT 1);
SET v_id_access_level_EDIT = (SELECT id_access_level FROM partsltd_prod.Shop_Access_Level WHERE code = 'EDIT');
SET v_code_type_error_bad_data := (SELECT code FROM partsltd_prod.Shop_Msg_Error_Type WHERE code = 'BAD_DATA' LIMIT 1);
SET v_id_type_error_bad_data := (SELECT id_type FROM partsltd_prod.Shop_Msg_Error_Type WHERE code = v_code_type_error_bad_data LIMIT 1);
SET v_code_type_error_no_permission := (SELECT code FROM partsltd_prod.Shop_Msg_Error_Type WHERE code = 'NO_PERMISSION' LIMIT 1);
SET v_id_type_error_no_permission := (SELECT id_type FROM partsltd_prod.Shop_Msg_Error_Type WHERE code = v_code_type_error_no_permission LIMIT 1);
SET v_id_permission_supplier := (SELECT id_permission FROM partsltd_prod.Shop_Permission WHERE code = 'STORE_SUPPLIER' LIMIT 1);
SET v_id_access_level_EDIT := (SELECT id_access_level FROM partsltd_prod.Shop_Access_Level WHERE code = 'EDIT' LIMIT 1);
CALL p_validate_guid ( a_guid );
SET a_comment := TRIM(IFNULL(a_comment, ''));
@@ -84,6 +86,18 @@ BEGIN
, is_new BIT NOT NULL
);
CREATE TEMPORARY TABLE tmp_Supplier_Address (
id_address INT NOT NULL
, id_supplier INT NOT NULL
, id_region INT NOT NULL
, postcode VARCHAR(20) NOT NULL
, address_line_1 VARCHAR(256) NOT NULL
, address_line_2 VARCHAR(256) NOT NULL
, city VARCHAR(256) NOT NULL
, county VARCHAR(256) NOT NULL
, active BIT NOT NULL
);
CREATE TEMPORARY TABLE IF NOT EXISTS tmp_Msg_Error (
display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT
, id_type INT NOT NULL
@@ -125,7 +139,38 @@ BEGIN
WHERE GUID = a_guid
;
INSERT INTO tmp_Supplier_Address (
id_address
, id_supplier
, id_region
, postcode
, address_line_1
, address_line_2
, city
, county
, active
, name_error
, is_new
)
SELECT
SA_T.id_address
, SA_T.id_supplier
, SA_T.id_region
, SA_T.postcode
, SA_T.address_line_1
, SA_T.address_line_2
, SA_T.city
, SA_T.county
, SA_T.active
, IFNULL(SA_T.postcode, IFNULL(SA_T.city, IFNULL(SA_T.county, IFNULL(SA_T.address_line_1, IFNULL(SA_T.address_line_2, '(No Supplier)'))))) AS name_error
, IFNULL(SA_T.id_address, 0) < 1 AS is_new
FROM partsltd_prod.Shop_Supplier_Address_Temp SA_T
WHERE GUID = a_guid
;
-- Validation
-- Suppliers
/*
# id_address
IF EXISTS (
SELECT *
@@ -159,6 +204,7 @@ BEGIN
)
;
END IF;
*/
# id_currency
IF EXISTS (
SELECT *
@@ -222,6 +268,106 @@ BEGIN
WHERE ISNULL(t_S.email)
;
END IF;
# duplicate
IF EXISTS (SELECT COUNT(*) FROM tmp_Supplier t_S WHERE COUNT(*) > 1 GROUP BY t_S.id_supplier) THEN
INSERT INTO tmp_Msg_Error (
id_type
, code
, msg
)
SELECT
v_id_type_error_bad_data
, v_code_type_error_bad_data
, CONCAT('The following supplier(s) are duplicates: ', GROUP_CONCAT(IFNULL(t_S.name_error, 'NULL') SEPARATOR ', ')) AS msg
FROM tmp_Supplier t_S
WHERE COUNT(*) > 1
GROUP BY t_S.id_supplier
;
END IF;
-- Addresses
# id_supplier
IF EXISTS (
SELECT *
FROM tmp_Supplier_Address t_SA
LEFT JOIN partsltd_prod.Shop_Supplier S ON t_SA.id_supplier = S.id_supplier
WHERE 1=1
AND (
t_SA.id_supplier = 0
OR S.active = 0
)
LIMIT 1
) THEN
INSERT INTO tmp_Msg_Error (
id_type
, code
, msg
)
SELECT
v_id_type_error_bad_data
, v_code_type_error_bad_data
, CONCAT(
'The following supplier address(es) have an invalid or inactive Supplier: '
, GROUP_CONCAT(t_S.name_error SEPARATOR ', ')
) AS msg
FROM tmp_Supplier t_S
LEFT JOIN partsltd_prod.Shop_Supplier S ON t_SA.id_supplier = S.id_supplier
WHERE 1=1
AND (
t_SA.id_supplier = 0
OR S.active = 0
)
;
END IF;
# id_region
IF EXISTS (
SELECT *
FROM tmp_Supplier_Address t_SA
LEFT JOIN partsltd_prod.Shop_Region R ON t_SA.id_region = R.id_region
WHERE 1=1
AND (
t_SA.id_region = 0
OR R.active = 0
)
LIMIT 1
) THEN
INSERT INTO tmp_Msg_Error (
id_type
, code
, msg
)
SELECT
v_id_type_error_bad_data
, v_code_type_error_bad_data
, CONCAT(
'The following supplier address(es) have an invalid or inactive Supplier: '
, GROUP_CONCAT(t_S.name_error SEPARATOR ', ')
) AS msg
FROM tmp_Supplier t_S
LEFT JOIN partsltd_prod.Shop_Region R ON t_SA.id_region = R.id_region
WHERE 1=1
AND (
t_SA.id_region = 0
OR R.active = 0
)
;
END IF;
# duplicate
IF EXISTS (SELECT COUNT(*) FROM tmp_Supplier_Address t_SA WHERE COUNT(*) > 1 GROUP BY t_SA.id_address) THEN
INSERT INTO tmp_Msg_Error (
id_type
, code
, msg
)
SELECT
v_id_type_error_bad_data
, v_code_type_error_bad_data
, CONCAT('The following supplier address(es) are duplicates: ', GROUP_CONCAT(IFNULL(t_S.name_error, 'NULL') SEPARATOR ', ')) AS msg
FROM tmp_Supplier_Address t_SA
WHERE COUNT(*) > 1
GROUP BY t_SA.id_address
;
END IF;
-- Permissions
IF a_debug = 1 THEN
@@ -262,7 +408,7 @@ BEGIN
VALUES (
v_id_type_error_no_permission
, v_code_type_error_no_permission
CONCAT('You do not have view permissions for ', (SELECT name FROM partsltd_prod.Shop_Permission WHERE id_permission = v_id_permission_supplier LIMIT 1))
, CONCAT('You do not have view permissions for ', (SELECT name FROM partsltd_prod.Shop_Permission WHERE id_permission = v_id_permission_supplier LIMIT 1))
)
;
END IF;
@@ -291,7 +437,6 @@ BEGIN
SET v_id_change_set := LAST_INSERT_ID();
INSERT INTO partsltd_prod.Shop_Supplier (
-- id_supplier,
id_address
, id_currency
, name_company
@@ -350,6 +495,47 @@ BEGIN
S.id_change_set = v_id_change_set
*/
;
INSERT INTO partsltd_prod.Shop_Supplier_Address (
id_address
, id_supplier
, id_region
, postcode
, address_line_1
, address_line_2
, city
, county
, active
)
SELECT
t_SA.id_address
, t_SA.id_supplier
, t_SA.id_region
, t_SA.postcode
, t_SA.address_line_1
, t_SA.address_line_2
, t_SA.city
, t_SA.county
, t_SA.active
FROM tmp_Supplier_Address t_SA
WHERE t_SA.is_new = 1
;
UPDATE partsltd_prod.Shop_Supplier_Address SA
INNER JOIN tmp_Supplier_Address t_SA
ON SA.id_address = t_SA.id_address
AND t_SA.is_new = 0
SET
SA.id_address = t_SA.id_address
, SA.id_supplier = t_SA.id_supplier
, SA.id_region = t_SA.id_region
, SA.postcode = t_SA.postcode
, SA.address_line_1 = t_SA.address_line_1
, SA.address_line_2 = t_SA.address_line_2
, SA.city = t_SA.city
, SA.county = t_SA.county
, SA.active = t_SA.active
;
COMMIT;
END IF;

View File

@@ -23,24 +23,26 @@ BEGIN
SET v_time_start := CURRENT_TIMESTAMP(6);
SET v_guid := UUID();
SET v_id_access_level_view := (SELECT id_access_level FROM Shop_Access_Level WHERE code = 'VIEW' LIMIT 1);
SET v_code_type_error_bad_data := (SELECT code FROM Shop_Msg_Error_Type WHERE code = 'BAD_DATA' LIMIT 1);
SET v_id_type_error_bad_data := (SELECT id_type FROM Shop_Msg_Error_Type WHERE code = v_code_type_error_bad_data LIMIT 1);
SET v_code_type_error_no_permission := (SELECT code FROM Shop_Msg_Error_Type WHERE code = 'NO_PERMISSION');
SET v_id_type_error_no_permission := (SELECT id_type FROM Shop_Msg_Error_Type WHERE code = v_code_type_error_no_permission);
SET v_id_permission_supplier := (SELECT id_permission FROM Shop_Permission WHERE code = 'STORE_SUPPLIER' LIMIT 1);
SET v_id_access_level_view := (SELECT id_access_level FROM partsltd_prod.Shop_Access_Level WHERE code = 'VIEW' LIMIT 1);
SET v_code_type_error_bad_data := (SELECT code FROM partsltd_prod.Shop_Msg_Error_Type WHERE code = 'BAD_DATA' LIMIT 1);
SET v_id_type_error_bad_data := (SELECT id_type FROM partsltd_prod.Shop_Msg_Error_Type WHERE code = v_code_type_error_bad_data LIMIT 1);
SET v_code_type_error_no_permission := (SELECT code FROM partsltd_prod.Shop_Msg_Error_Type WHERE code = 'NO_PERMISSION');
SET v_id_type_error_no_permission := (SELECT id_type FROM partsltd_prod.Shop_Msg_Error_Type WHERE code = v_code_type_error_no_permission);
SET v_id_permission_supplier := (SELECT id_permission FROM partsltd_prod.Shop_Permission WHERE code = 'STORE_SUPPLIER' LIMIT 1);
SET a_get_all_supplier := IFNULL(a_get_all_supplier, 0);
SET a_get_inactive_supplier := IFNULL(a_get_inactive_supplier, 0);
SET a_ids_supplier := TRIM(IFNULL(a_ids_supplier, ''));
DROP TEMPORARY TABLE IF EXISTS tmp_Supplier;
DROP TEMPORARY TABLE IF EXISTS tmp_Msg_Error;
DROP TEMPORARY TABLE IF EXISTS tmp_Split;
CREATE TEMPORARY TABLE tmp_Supplier (
id_supplier INT NOT NULL
);
CREATE TABLE IF NOT EXISTS tmp_Msg_Error (
CREATE TEMPORARY TABLE IF NOT EXISTS tmp_Msg_Error (
display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
id_type INT NOT NULL,
code VARCHAR(50) NOT NULL,
@@ -94,7 +96,7 @@ BEGIN
OR ISNULL(S.id_supplier)
OR (
S.active = 0
AND v_get_inactive_supplier = 0
AND a_get_inactive_supplier = 0
)
) THEN
INSERT INTO tmp_Msg_Error (
@@ -113,7 +115,7 @@ BEGIN
OR ISNULL(S.id_supplier)
OR (
S.active = 0
AND v_get_inactive_supplier = 0
AND a_get_inactive_supplier = 0
)
;
ELSE
@@ -173,14 +175,14 @@ BEGIN
DELETE FROM tmp_Msg_Error;
INSERT INTO tmp_Msg_Error (
, id_type
id_type
, code
, msg
)
VALUES (
v_id_type_error_no_permission
, v_code_type_error_no_permission
CONCAT('You do not have view permissions for ', (SELECT name FROM Shop_Permission WHERE id_permission = v_id_permission_supplier LIMIT 1))
, CONCAT('You do not have view permissions for ', (SELECT name FROM Shop_Permission WHERE id_permission = v_id_permission_supplier LIMIT 1))
)
;
END IF;
@@ -193,8 +195,9 @@ BEGIN
# Suppliers
SELECT
t_S.id_supplier,
S.id_address,
S.id_currency,
C.symbol AS symbol_currency,
C.code AS code_currency,
S.name_company,
S.name_contact,
S.department_contact,
@@ -204,14 +207,32 @@ BEGIN
S.website,
S.active
FROM tmp_Supplier t_S
INNER JOIN Shop_Supplier S
ON t_S.id_supplier = S.id_supplier
INNER JOIN partsltd_prod.Shop_Supplier S ON t_S.id_supplier = S.id_supplier
LEFT JOIN partsltd_prod.Shop_Currency C ON S.id_currency = C.id_currency
;
# Supplier Addresses
SELECT
t_S.id_supplier
, SA.id_address
, SA.id_region
, R.name AS name_region
, SA.postcode
, SA.address_line_1
, SA.address_line_2
, SA.city
, SA.county
, SA.active
FROM tmp_Supplier t_S
INNER JOIN partsltd_prod.Shop_Supplier S ON t_S.id_supplier = S.id_supplier
INNER JOIN partsltd_prod.Shop_Supplier_Address SA ON S.id_supplier = SA.id_supplier
LEFT JOIN partsltd_prod.Shop_Region R ON SA.id_region = R.id_region
;
# Errors
SELECT *
FROM tmp_Msg_Error t_ME
INNER JOIN Shop_Msg_Error_Type MET ON t_ME.id_type = MET.id_type
INNER JOIN partsltd_prod.Shop_Msg_Error_Type MET ON t_ME.id_type = MET.id_type
;
IF a_debug = 1 THEN
@@ -220,6 +241,7 @@ BEGIN
DROP TEMPORARY TABLE IF EXISTS tmp_Supplier;
DROP TEMPORARY TABLE IF EXISTS tmp_Msg_Error;
DROP TEMPORARY TABLE IF EXISTS tmp_Split;
IF a_debug = 1 THEN
CALL p_debug_timing_reporting( v_time_start );
@@ -228,6 +250,7 @@ END //
DELIMITER ;;
/*
CALL p_shop_get_many_supplier (
1 -- 'auth0|6582b95c895d09a70ba10fef' # a_id_user
@@ -237,5 +260,4 @@ CALL p_shop_get_many_supplier (
, 0 # a_debug
);
/*
*/

View File

@@ -21,7 +21,7 @@ BEGIN
DECLARE v_code_type_error_warning VARCHAR(50);
DECLARE v_id_access_level_edit INT;
DECLARE v_id_change_set INT;
DECLARE v_id_permission_supplier_purchase_order INT;
DECLARE v_id_permission_supplier_purchase_order VARCHAR(100);
DECLARE v_id_type_error_bad_data INT;
DECLARE v_id_type_error_no_permission INT;
DECLARE v_id_type_error_warning INT;
@@ -66,8 +66,8 @@ BEGIN
SET v_id_type_error_no_permission := (SELECT id_type FROM partsltd_prod.Shop_Msg_Error_Type WHERE code = v_code_type_error_no_permission);
SET v_code_type_error_warning := (SELECT code FROM partsltd_prod.Shop_Msg_Error_Type WHERE code = 'WARNING');
SET v_id_type_error_warning := (SELECT id_type FROM partsltd_prod.Shop_Msg_Error_Type WHERE code = v_code_type_error_warning);
SET v_id_permission_supplier_purchase_order = (SELECT id_permission FROM partsltd_prod.Shop_Permission WHERE code = 'STORE_SUPPLIER_PURCHASE_ORDER' LIMIT 1);
SET v_id_access_level_edit = (SELECT id_access_level FROM partsltd_prod.Shop_Access_Level WHERE code = 'EDIT');
SET v_id_permission_supplier_purchase_order := (SELECT GROUP_CONCAT(id_permission SEPARATOR ',') FROM partsltd_prod.Shop_Permission WHERE code IN ('STORE_SUPPLIER', 'STORE_SUPPLIER_PURCHASE_ORDER', 'STORE_PRODUCT') LIMIT 1);
SET v_id_access_level_edit := (SELECT id_access_level FROM partsltd_prod.Shop_Access_Level WHERE code = 'EDIT' LIMIT 1);
CALL p_validate_guid ( a_guid );
SET a_comment := TRIM(IFNULL(a_comment, ''));
@@ -81,13 +81,14 @@ BEGIN
, id_supplier_ordered INT NOT NULL
, id_currency_cost INT NOT NULL
-- , cost_total_local FLOAT NOT NULL
, active BIT NOT NULL
);
CREATE TEMPORARY TABLE tmp_Supplier_Purchase_Order_Product_Link (
id_link INT NOT NULL PRIMARY KEY
, id_order INT NOT NULL
, id_permutation INT NOT NULL
, id_currency_cost INT NOT NULL
-- , id_currency_cost INT NOT NULL
, quantity_ordered FLOAT NOT NULL
, id_unit_quantity INT NOT NULL
, quantity_received FLOAT NULL
@@ -127,9 +128,9 @@ BEGIN
id_link
, id_order
, id_permutation
, id_currency_cost
, quantity_ordered
-- , id_currency_cost
, id_unit_quantity
, quantity_ordered
, quantity_received
, latency_delivery_days
, display_order
@@ -144,14 +145,14 @@ BEGIN
)
SELECT
IFNULL(SPOPL_T.id_link, 0) AS id_link
, IFNULL(IFNULL(SPOPL_T.id_order, SPOPL.id_order) 0) AS id_order
, IFNULL(IFNULL(SPOPL_T.id_order, SPOPL.id_order), 0) AS id_order
, IFNULL(IFNULL(SPOPL_T.id_permutation, SPOPL.id_permutation), 0) AS id_permutation
, IFNULL(IFNULL(SPOPL_T.id_currency_cost, SPOPL.id_currency_cost) 0) AS id_currency_cost
, IFNULL(IFNULL(SPOPL_T.quantity_ordered, SPOPL.quantity_ordered), 0) AS quantity_ordered
-- , IFNULL(IFNULL(SPOPL_T.id_currency_cost, SPOPL.id_currency_cost), 0) AS id_currency_cost
, IFNULL(IFNULL(SPOPL_T.id_unit_quantity, SPOPL.id_unit_quantity), 0) AS id_unit_quantity
, IFNULL(IFNULL(SPOPL_T.quantity_ordered, SPOPL.quantity_ordered), 0) AS quantity_ordered
, IFNULL(SPOPL_T.quantity_received, SPOPL.quantity_received) AS quantity_received
, IFNULL(SPOPL_T.latency_delivery_days, SPOPL.latency_delivery_days) AS latency_delivery_days
, RANK() OVER (PARTITION BY IFNULL(IFNULL(SPOPL_T.id_order, SPOPL.id_order) 0) ORDER BY IFNULL(IFNULL(SPOPL_T.display_order, SPOPL.display_order), 0)) AS display_order
, RANK() OVER (PARTITION BY IFNULL(IFNULL(SPOPL_T.id_order, SPOPL.id_order), 0) ORDER BY IFNULL(IFNULL(SPOPL_T.display_order, SPOPL.display_order), 0)) AS display_order
, IFNULL(IFNULL(SPOPL_T.active, SPOPL.active), 1) AS active
, CONCAT(
fn_shop_get_product_permutation_name(SPOPL_T.id_permutation)
@@ -285,8 +286,8 @@ BEGIN
# id_unit_quantity
IF EXISTS (
SELECT *
FROM tmp_Supplier_Purchase_Order t_SPO
LEFT JOIN partsltd_prod.Shop_Unit_Measurement UM ON t_SPO.id_unit_quantity = UM.id_unit_measurement
FROM tmp_Supplier_Purchase_Order_Product_Link t_SPOPL
LEFT JOIN partsltd_prod.Shop_Unit_Measurement UM ON t_SPOPL.id_unit_quantity = UM.id_unit_measurement
WHERE 1=1
AND (
ISNULL(UM.id_unit_measurement)
@@ -306,8 +307,8 @@ BEGIN
'A valid unit measurement of quantity is required for the following Supplier Purchase Order(s): '
, GROUP_CONCAT(CONCAT(IFNULL(t_SPO.id_stock, '(No Supplier Purchase Order)'), ' - ', t_SPO.id_currency_cost) SEPARATOR ', ')
) AS msg
FROM tmp_Stock_Item t_SPO
LEFT JOIN partsltd_prod.Shop_Unit_Measurement UM ON t_SPO.id_unit_quantity = UM.id_unit_measurement
FROM tmp_Supplier_Purchase_Order_Product_Link t_SPOPL
LEFT JOIN partsltd_prod.Shop_Unit_Measurement UM ON t_SPOPL.id_unit_quantity = UM.id_unit_measurement
WHERE 1=1
AND (
ISNULL(UM.id_unit_measurement)
@@ -318,7 +319,7 @@ BEGIN
# Invalid quantity ordered
IF EXISTS (
SELECT *
FROM tmp_Supplier_Purchase_Order_Product_Link
FROM tmp_Supplier_Purchase_Order_Product_Link t_SPOPL
WHERE
ISNULL(t_SPOPL.quantity_ordered)
OR t_SPOPL.quantity_ordered <= 0
@@ -342,7 +343,7 @@ BEGIN
# Invalid quantity received
IF EXISTS (
SELECT *
FROM tmp_Supplier_Purchase_Order_Product_Link
FROM tmp_Supplier_Purchase_Order_Product_Link t_SPOPL
WHERE t_SPOPL.quantity_received < 0
) THEN
INSERT INTO tmp_Msg_Error (
@@ -362,7 +363,7 @@ BEGIN
# Invalid delivery latency
IF EXISTS (
SELECT *
FROM tmp_Supplier_Purchase_Order_Product_Link
FROM tmp_Supplier_Purchase_Order_Product_Link t_SPOPL
WHERE t_SPOPL.latency_delivery_days < 0
) THEN
INSERT INTO tmp_Msg_Error (
@@ -494,7 +495,7 @@ BEGIN
VALUES (
v_id_type_error_no_permission
, v_code_type_error_no_permission
CONCAT('You do not have view permissions for ', (SELECT name FROM partsltd_prod.Shop_Permission WHERE id_permission = v_id_permission_supplier LIMIT 1))
, CONCAT('You do not have view permissions for ', (SELECT name FROM partsltd_prod.Shop_Permission WHERE id_permission = v_id_permission_supplier LIMIT 1))
)
;
END IF;
@@ -513,8 +514,30 @@ BEGIN
INNER JOIN partsltd_prod.Shop_Stock_Item SI ON SPOPL.id_permutation = SI.id_permutation
WHERE
t_SPOPL.is_new = 0
AND t_SPOPL.quantity_received < SPOPL.quantity_received
)
AND t_SPOPL.quantity_received <> SPOPL.quantity_received
) THEN
INSERT INTO tmp_Msg_Error (
id_type
, code
, msg
)
SELECT
v_id_type_error_warning
, v_code_type_error_warning
, CONCAT(
'The quantity received has changed on the following orders. Please update the stock items appropriately.'
, GROUP_CONCAT(
CONCAT(
t_SPOPL.name_error
, ' - from '
, SPOPL.quantity_received
, ' to '
, t_SPOPL.quantity_received
) SEPARATOR ', '
)
) AS msg
;
END IF;
-- Transaction
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error) THEN
@@ -559,7 +582,7 @@ BEGIN
INSERT INTO Shop_Supplier_Purchase_Order_Product_Link (
id_order
, id_permutation
, id_currency_cost
-- , id_currency_cost
, id_unit_quantity
, quantity_ordered
, quantity_received
@@ -574,7 +597,7 @@ BEGIN
SELECT
t_SPOPL.id_order
, t_SPOPL.id_permutation
, t_SPOPL.id_currency_cost
-- , t_SPOPL.id_currency_cost
, t_SPOPL.id_unit_quantity
, t_SPOPL.quantity_ordered
, t_SPOPL.quantity_received
@@ -583,8 +606,8 @@ BEGIN
, t_SPOPL.active
, t_SPOPL.cost_total_local_VAT_excl
, t_SPOPL.cost_total_local_VAT_incl
a_id_user
v_id_change_set
, a_id_user
, v_id_change_set
FROM tmp_Supplier_Purchase_Order_Product_Link t_SPOPL
WHERE t_SPOPL.is_new = 1
;
@@ -610,7 +633,7 @@ BEGIN
SET
SPOPL.id_order = t_SPOPL.id_order,
SPOPL.id_permutation = t_SPOPL.id_permutation,
SPOPL.id_currency_cost = t_SPOPL.id_currency_cost,
-- SPOPL.id_currency_cost = t_SPOPL.id_currency_cost,
SPOPL.id_unit_quantity = t_SPOPL.id_unit_quantity,
SPOPL.quantity_ordered = t_SPOPL.quantity_ordered,
SPOPL.quantity_received = t_SPOPL.quantity_received,
@@ -632,6 +655,7 @@ BEGIN
;
COMMIT;
END IF;
# Errors
SELECT *

View File

@@ -26,19 +26,19 @@ BEGIN
DECLARE v_has_filter_date_from BIT;
DECLARE v_has_filter_date_to BIT;
DECLARE v_id_access_level_view INT;
DECLARE v_ids_permission_supplier_purchase_order INT;
DECLARE v_ids_permission_supplier_purchase_order VARCHAR(100);
DECLARE v_id_type_error_bad_data INT;
DECLARE v_id_type_error_no_permission INT;
DECLARE v_time_start TIMESTAMP(6);
SET v_time_start := CURRENT_TIMESTAMP(6);
SET v_guid := UUID();
SET v_id_access_level_view := (SELECT id_access_level FROM Shop_Access_Level WHERE code = 'VIEW' LIMIT 1);
SET v_code_type_error_bad_data := (SELECT code FROM Shop_Msg_Error_Type WHERE code = 'BAD_DATA' LIMIT 1);
SET v_id_type_error_bad_data := (SELECT id_type FROM Shop_Msg_Error_Type WHERE code = v_code_type_error_bad_data LIMIT 1);
SET v_code_type_error_no_permission := (SELECT code FROM Shop_Msg_Error_Type WHERE code = 'NO_PERMISSION');
SET v_id_type_error_no_permission := (SELECT id_type FROM Shop_Msg_Error_Type WHERE code = v_code_type_error_no_permission);
SET v_ids_permission_supplier_purchase_order := (SELECT id_permission FROM Shop_Permission WHERE code = 'STORE_SUPPLIER_PURCHASE_ORDER' LIMIT 1);
SET v_id_access_level_view := (SELECT id_access_level FROM partsltd_prod.Shop_Access_Level WHERE code = 'VIEW' LIMIT 1);
SET v_code_type_error_bad_data := (SELECT code FROM partsltd_prod.Shop_Msg_Error_Type WHERE code = 'BAD_DATA' LIMIT 1);
SET v_id_type_error_bad_data := (SELECT id_type FROM partsltd_prod.Shop_Msg_Error_Type WHERE code = v_code_type_error_bad_data LIMIT 1);
SET v_code_type_error_no_permission := (SELECT code FROM partsltd_prod.Shop_Msg_Error_Type WHERE code = 'NO_PERMISSION' LIMIT 1);
SET v_id_type_error_no_permission := (SELECT id_type FROM partsltd_prod.Shop_Msg_Error_Type WHERE code = v_code_type_error_no_permission LIMIT 1);
SET v_ids_permission_supplier_purchase_order := (SELECT GROUP_CONCAT(id_permission SEPARATOR ',') FROM partsltd_prod.Shop_Permission WHERE code IN ('STORE_SUPPLIER', 'STORE_SUPPLIER_PURCHASE_ORDER', 'STORE_PRODUCT'));
SET a_get_all_supplier := IFNULL(a_get_all_supplier, 1);
SET a_get_inactive_supplier := IFNULL(a_get_inactive_supplier, 0);
@@ -51,32 +51,38 @@ BEGIN
SET a_date_to := IFNULL(a_date_to, NULL);
SET a_debug := IFNULL(a_debug, 0);
DROP TABLE IF EXISTS tmp_Supplier_Purchase_Order_Product_Link;
DROP TABLE IF EXISTS tmp_Supplier_Purchase_Order;
DROP TABLE IF EXISTS tmp_Supplier;
DROP TABLE IF EXISTS tmp_Product;
DROP TEMPORARY TABLE IF EXISTS tmp_Supplier_Purchase_Order_Product_Link;
DROP TEMPORARY TABLE IF EXISTS tmp_Supplier_Purchase_Order;
DROP TEMPORARY TABLE IF EXISTS tmp_Supplier;
DROP TEMPORARY TABLE IF EXISTS tmp_Permutation;
DROP TEMPORARY TABLE IF EXISTS tmp_Msg_Error;
DROP TEMPORARY TABLE IF EXISTS tmp_Split;
CREATE TABLE tmp_Supplier (
CREATE TEMPORARY TABLE tmp_Supplier (
id_supplier INT NOT NULL PRIMARY KEY
);
CREATE TABLE tmp_Supplier_Purchase_Order (
CREATE TEMPORARY TABLE tmp_Supplier_Purchase_Order (
id_order INT NOT NULL PRIMARY KEY
);
CREATE TABLE tmp_Supplier_Purchase_Order_Product_Link (
id_link INT NOT NULL PRIMARY KEY,
id_order INT NOT NULL,
id_permutation INT NOT NULL
CREATE TEMPORARY TABLE tmp_Permutation (
id_permutation INT NOT NULL PRIMARY KEY
);
CREATE TABLE IF NOT EXISTS tmp_Msg_Error (
CREATE TEMPORARY TABLE IF NOT EXISTS tmp_Msg_Error (
display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
id_type INT NOT NULL,
code VARCHAR(50) NOT NULL,
msg VARCHAR(4000) NOT NULL
);
CREATE TEMPORARY TABLE IF NOT EXISTS tmp_Split (
substring VARCHAR(4000) NOT NULL
, as_int INT NULL
);
DELETE FROM tmp_Split;
SET v_has_filter_supplier = CASE WHEN a_ids_supplier = '' THEN 0 ELSE 1 END;
SET v_has_filter_order = CASE WHEN a_ids_order = '' THEN 0 ELSE 1 END;
SET v_has_filter_permutation = CASE WHEN a_ids_permutation = '' THEN 0 ELSE 1 END;
@@ -189,7 +195,7 @@ BEGIN
OR ISNULL(S.id_supplier)
OR (
S.active = 0
AND v_get_inactive_supplier = 0
AND a_get_inactive_supplier = 0
)
) THEN
INSERT INTO tmp_Msg_Error (
@@ -208,7 +214,7 @@ BEGIN
OR ISNULL(S.id_supplier)
OR (
S.active = 0
AND v_get_inactive_supplier = 0
AND a_get_inactive_supplier = 0
)
;
ELSE
@@ -267,7 +273,7 @@ BEGIN
OR ISNULL(SPO.id_order)
OR (
SPO.active = 0
AND v_get_inactive_order = 0
AND a_get_inactive_order = 0
)
) THEN
INSERT INTO tmp_Msg_Error (
@@ -286,7 +292,7 @@ BEGIN
OR ISNULL(SPO.id_order)
OR (
SPO.active = 0
AND v_get_inactive_order = 0
AND a_get_inactive_order = 0
)
;
ELSE
@@ -340,40 +346,40 @@ BEGIN
v_guid
, a_id_user
, FALSE -- get inactive users
, v_id_permission_supplier_purchase_order
, v_ids_permission_supplier_purchase_order
, v_id_access_level_view
, '' -- ids_product
, 0 -- a_debug
;
SELECT * from Shop_Calc_User_Temp;
SELECT * from partsltd_prod.Shop_Calc_User_Temp;
END IF;
CALL p_shop_calc_user(
v_guid
, a_id_user
, FALSE -- get inactive users
, v_id_permission_supplier_purchase_order
, v_ids_permission_supplier_purchase_order
, v_id_access_level_view
, '' -- ids_product
, 0 -- a_debug
);
IF a_debug = 1 THEN
SELECT * from Shop_Calc_User_Temp;
SELECT * from partsltd_prod.Shop_Calc_User_Temp;
END IF;
IF NOT EXISTS (SELECT can_view FROM Shop_Calc_User_Temp UE_T WHERE UE_T.GUID = v_guid) THEN
IF NOT EXISTS (SELECT can_view FROM partsltd_prod.Shop_Calc_User_Temp UE_T WHERE UE_T.GUID = v_guid) THEN
DELETE FROM tmp_Msg_Error;
INSERT INTO tmp_Msg_Error (
, id_type
id_type
, code
, msg
)
VALUES (
v_id_type_error_no_permission
, v_code_type_error_no_permission
CONCAT('You do not have view permissions for ', (SELECT name FROM Shop_Permission WHERE id_permission = v_id_permission_supplier LIMIT 1))
, CONCAT('You do not have view permissions for ', (SELECT name FROM partsltd_prod.Shop_Permission WHERE id_permission = v_id_permission_supplier LIMIT 1))
)
;
END IF;
@@ -399,7 +405,7 @@ BEGIN
S.id_currency,
t_S.active
FROM tmp_Supplier t_S
INNER JOIN Shop_Supplier S
INNER JOIN partsltd_prod.Shop_Supplier S
ON t_S.id_supplier = S.id_supplier
;
*/
@@ -412,6 +418,12 @@ BEGIN
, SPO.cost_total_local_VAT_excl
, SPO.cost_total_local_VAT_incl
, SPO.active
, SPO.created_on
, CONCAT(
SPO.cost_total_local_VAT_excl
, ' on '
, SPO.created_on
) AS name
FROM tmp_Supplier_Purchase_Order t_SPO
INNER JOIN partsltd_prod.Shop_Supplier_Purchase_Order SPO ON SPO.id_order = t_SPO.id_order
;
@@ -422,23 +434,25 @@ BEGIN
, SPOPL.id_order
, SPOPL.id_permutation
, fn_shop_get_product_permutation_name(SPOPL.id_permutation) AS name_permutation
, SPOPL.id_currency_cost
-- , SPOPL.id_currency_cost
, SPOPL.id_unit_quantity
, SPOPL.quantity_ordered
, SPOPL.quantity_received
, SPOPL.latency_delivery_days
, SPOPL.display_order
, SPO.cost_total_local_VAT_excl
, SPO.cost_total_local_VAT_incl
FROM tmp_Supplier_Purchase_Order_Product_Link t_SPOPL
INNER JOIN partsltd_prod.Shop_Supplier_Purchase_Order_Product_Link SPOPL ON t_SPOPL.id_link = SPOPL.id_link
INNER JOIN tmp_Supplier_Purchase_Order t_SPO ON SPOPL.id_order = t_SPO.id_order
, SPOPL.cost_total_local_VAT_excl
, SPOPL.cost_total_local_VAT_incl
, SPOPL.cost_unit_local_VAT_excl
, SPOPL.cost_unit_local_VAT_incl
, SPOPL.active
FROM tmp_Supplier_Purchase_Order t_SPO
INNER JOIN partsltd_prod.Shop_Supplier_Purchase_Order_Product_Link SPOPL ON t_SPO.id_order = SPOPL.id_order
;
# Errors
SELECT *
FROM tmp_Msg_Error t_ME
INNER JOIN Shop_Msg_Error_Type MET ON t_ME.id_type = MET.id_type
INNER JOIN partsltd_prod.Shop_Msg_Error_Type MET ON t_ME.id_type = MET.id_type
;
IF a_debug = 1 THEN
@@ -450,7 +464,9 @@ BEGIN
DROP TEMPORARY TABLE IF EXISTS tmp_Supplier_Purchase_Order_Product_Link;
DROP TEMPORARY TABLE IF EXISTS tmp_Supplier_Purchase_Order;
DROP TEMPORARY TABLE IF EXISTS tmp_Supplier;
DROP TEMPORARY TABLE IF EXISTS tmp_Permutation;
DROP TEMPORARY TABLE IF EXISTS tmp_Msg_Error;
DROP TEMPORARY TABLE IF EXISTS tmp_Split;
IF a_debug = 1 THEN
CALL p_debug_timing_reporting( v_time_start );
@@ -459,15 +475,14 @@ END //
DELIMITER ;;
/*
CALL p_shop_get_many_supplier_purchase_order (
'', # a_id_user
1, # a_id_user
1, # a_get_all_supplier
0, # a_get_inactive_supplier
'', # a_ids_supplier
1, # a_get_all_order
-- 0, # a_get_inactive_order
0, # a_get_inactive_order
'', # a_ids_order
'', # a_ids_permutation
NULL, # a_date_from
@@ -475,4 +490,5 @@ CALL p_shop_get_many_supplier_purchase_order (
, 0 # a_debug
);
/*
*/

View File

@@ -20,7 +20,7 @@ BEGIN
DECLARE v_code_type_error_no_permission VARCHAR(50);
DECLARE v_id_access_level_edit INT;
DECLARE v_id_change_set INT;
DECLARE v_id_permission_manufacturing_purchase_order INT;
DECLARE v_ids_permission_manufacturing_purchase_order VARCHAR(100);
DECLARE v_id_type_error_bad_data INT;
DECLARE v_id_type_error_no_permission INT;
DECLARE v_ids_product_permission TEXT;
@@ -58,12 +58,12 @@ BEGIN
END;
SET v_time_start := CURRENT_TIMESTAMP(6);
SET v_code_type_error_bad_data := (SELECT code FROM partsltd_prod.Shop_Msg_Error_Type WHERE code = 'BAD_DATA');
SET v_id_type_error_bad_data := (SELECT id_type FROM partsltd_prod.Shop_Msg_Error_Type WHERE code = v_code_type_error_bad_data);
SET v_code_type_error_no_permission := (SELECT code FROM partsltd_prod.Shop_Msg_Error_Type WHERE code = 'NO_PERMISSION');
SET v_id_type_error_no_permission := (SELECT id_type FROM partsltd_prod.Shop_Msg_Error_Type WHERE code = v_code_type_error_no_permission);
SET v_id_permission_manufacturing_purchase_order = (SELECT id_permission FROM partsltd_prod.Shop_Permission WHERE code = 'STORE_SUPPLIER_PURCHASE_ORDER' LIMIT 1);
SET v_id_access_level_edit = (SELECT id_access_level FROM partsltd_prod.Shop_Access_Level WHERE code = 'EDIT');
SET v_code_type_error_bad_data := (SELECT code FROM partsltd_prod.Shop_Msg_Error_Type WHERE code = 'BAD_DATA' LIMIT 1);
SET v_id_type_error_bad_data := (SELECT id_type FROM partsltd_prod.Shop_Msg_Error_Type WHERE code = v_code_type_error_bad_data LIMIT 1);
SET v_code_type_error_no_permission := (SELECT code FROM partsltd_prod.Shop_Msg_Error_Type WHERE code = 'NO_PERMISSION' LIMIT 1);
SET v_id_type_error_no_permission := (SELECT id_type FROM partsltd_prod.Shop_Msg_Error_Type WHERE code = v_code_type_error_no_permission LIMIT 1);
SET v_ids_permission_manufacturing_purchase_order := (SELECT GROUP_CONCAT(id_permission SEPARATOR ',') FROM partsltd_prod.Shop_Permission WHERE code IN ('STORE_MANUFACTURING_PURCHASE_ORDER', 'STORE_PRODUCT'));
SET v_id_access_level_edit := (SELECT id_access_level FROM partsltd_prod.Shop_Access_Level WHERE code = 'EDIT' LIMIT 1);
CALL p_validate_guid ( a_guid );
SET a_comment := TRIM(IFNULL(a_comment, ''));
@@ -136,14 +136,14 @@ BEGIN
)
SELECT
IFNULL(SPOPL_T.id_link, 0) AS id_link
, IFNULL(IFNULL(SPOPL_T.id_order, MPOPL.id_order) 0) AS id_order
, IFNULL(IFNULL(SPOPL_T.id_order, MPOPL.id_order), 0) AS id_order
, IFNULL(IFNULL(SPOPL_T.id_permutation, MPOPL.id_permutation), 0) AS id_permutation
, IFNULL(IFNULL(SPOPL_T.id_currency_cost, MPOPL.id_currency_cost) 0) AS id_currency_cost
, IFNULL(IFNULL(SPOPL_T.id_currency_cost, MPOPL.id_currency_cost), 0) AS id_currency_cost
, IFNULL(IFNULL(SPOPL_T.quantity_ordered, MPOPL.quantity_ordered), 0) AS quantity_ordered
, IFNULL(IFNULL(SPOPL_T.id_unit_quantity, MPOPL.id_unit_quantity), 0) AS id_unit_quantity
, IFNULL(SPOPL_T.quantity_received, MPOPL.quantity_received) AS quantity_received
, IFNULL(SPOPL_T.latency_delivery_days, MPOPL.latency_delivery_days) AS latency_delivery_days
, RANK() OVER (PARTITION BY IFNULL(IFNULL(SPOPL_T.id_order, MPOPL.id_order) 0) ORDER BY IFNULL(IFNULL(SPOPL_T.display_order, MPOPL.display_order), 0)) AS display_order
, RANK() OVER (PARTITION BY IFNULL(IFNULL(SPOPL_T.id_order, MPOPL.id_order), 0) ORDER BY IFNULL(IFNULL(SPOPL_T.display_order, MPOPL.display_order), 0)) AS display_order
, IFNULL(IFNULL(SPOPL_T.active, MPOPL.active), 1) AS active
, CONCAT(
fn_shop_get_product_permutation_name(SPOPL_T.id_permutation)
@@ -418,7 +418,7 @@ BEGIN
v_guid
, a_id_user
, FALSE -- get inactive users
, v_id_permission_manufacturing_purchase_order
, v_ids_permission_manufacturing_purchase_order
, v_id_access_level_edit
, v_ids_product_permission -- ids_product
, 0 -- a_debug
@@ -430,7 +430,7 @@ BEGIN
v_guid
, a_id_user
, FALSE -- get inactive users
, v_id_permission_manufacturing_purchase_order
, v_ids_permission_manufacturing_purchase_order
, v_id_access_level_edit
, v_ids_product_permission -- ids_product
, 0 -- a_debug
@@ -451,7 +451,7 @@ BEGIN
VALUES (
v_id_type_error_no_permission
, v_code_type_error_no_permission
CONCAT('You do not have view permissions for ', (SELECT name FROM partsltd_prod.Shop_Permission WHERE id_permission = v_id_permission_manufacturing LIMIT 1))
, CONCAT('You do not have view permissions for ', (SELECT name FROM partsltd_prod.Shop_Permission WHERE id_permission = v_id_permission_manufacturing LIMIT 1))
)
;
END IF;
@@ -527,8 +527,8 @@ BEGIN
, t_MPOPL.active
, t_MPOPL.cost_total_local_VAT_excl
, t_MPOPL.cost_total_local_VAT_incl
a_id_user
v_id_change_set
, a_id_user
, v_id_change_set
FROM tmp_Manufacturing_Purchase_Order_Product_Link t_MPOPL
WHERE t_MPOPL.is_new = 1
;
@@ -575,6 +575,7 @@ BEGIN
;
COMMIT;
END IF;
# Errors
SELECT *

View File

@@ -5,9 +5,6 @@ DROP PROCEDURE IF EXISTS p_shop_get_many_manufacturing_purchase_order;
DELIMITER //
CREATE PROCEDURE p_shop_get_many_manufacturing_purchase_order (
IN a_id_user INT,
IN a_get_all_manufacturing BIT,
IN a_get_inactive_manufacturing BIT,
IN a_ids_manufacturing TEXT,
IN a_get_all_order BIT,
IN a_get_inactive_order BIT,
IN a_ids_order TEXT,
@@ -25,19 +22,19 @@ BEGIN
DECLARE v_has_filter_date_from BIT;
DECLARE v_has_filter_date_to BIT;
DECLARE v_id_access_level_view INT;
DECLARE v_ids_permission_manufacturing_purchase_order INT;
DECLARE v_ids_permission_manufacturing_purchase_order VARCHAR(100);
DECLARE v_id_type_error_bad_data INT;
DECLARE v_id_type_error_no_permission INT;
DECLARE v_time_start TIMESTAMP(6);
SET v_time_start := CURRENT_TIMESTAMP(6);
SET v_guid := UUID();
SET v_id_access_level_view := (SELECT id_access_level FROM Shop_Access_Level WHERE code = 'VIEW' LIMIT 1);
SET v_code_type_error_bad_data := (SELECT code FROM Shop_Msg_Error_Type WHERE code = 'BAD_DATA' LIMIT 1);
SET v_id_type_error_bad_data := (SELECT id_type FROM Shop_Msg_Error_Type WHERE code = v_code_type_error_bad_data LIMIT 1);
SET v_code_type_error_no_permission := (SELECT code FROM Shop_Msg_Error_Type WHERE code = 'NO_PERMISSION');
SET v_id_type_error_no_permission := (SELECT id_type FROM Shop_Msg_Error_Type WHERE code = v_code_type_error_no_permission);
SET v_ids_permission_manufacturing_purchase_order := (SELECT id_permission FROM Shop_Permission WHERE code = 'STORE_SUPPLIER_PURCHASE_ORDER' LIMIT 1);
SET v_id_access_level_view := (SELECT id_access_level FROM partsltd_prod.Shop_Access_Level WHERE code = 'VIEW' LIMIT 1);
SET v_code_type_error_bad_data := (SELECT code FROM partsltd_prod.Shop_Msg_Error_Type WHERE code = 'BAD_DATA' LIMIT 1);
SET v_id_type_error_bad_data := (SELECT id_type FROM partsltd_prod.Shop_Msg_Error_Type WHERE code = v_code_type_error_bad_data LIMIT 1);
SET v_code_type_error_no_permission := (SELECT code FROM partsltd_prod.Shop_Msg_Error_Type WHERE code = 'NO_PERMISSION');
SET v_id_type_error_no_permission := (SELECT id_type FROM partsltd_prod.Shop_Msg_Error_Type WHERE code = v_code_type_error_no_permission);
SET v_ids_permission_manufacturing_purchase_order := (SELECT GROUP_CONCAT(id_permission SEPARATOR ',') FROM partsltd_prod.Shop_Permission WHERE code IN ('STORE_MANUFACTURING_PURCHASE_ORDER', 'STORE_PRODUCT'));
SET a_get_all_order := IFNULL(a_get_all_order, 1);
SET a_get_inactive_order := IFNULL(a_get_inactive_order, 0);
@@ -47,27 +44,33 @@ BEGIN
SET a_date_to := IFNULL(a_date_to, NULL);
SET a_debug := IFNULL(a_debug, 0);
DROP TABLE IF EXISTS tmp_Manufacturing_Purchase_Order_Product_Link;
DROP TABLE IF EXISTS tmp_Manufacturing_Purchase_Order;
DROP TABLE IF EXISTS tmp_Product;
DROP TEMPORARY TABLE IF EXISTS tmp_Manufacturing_Purchase_Order_Product_Link;
DROP TEMPORARY TABLE IF EXISTS tmp_Manufacturing_Purchase_Order;
DROP TEMPORARY TABLE IF EXISTS tmp_Permutation;
DROP TEMPORARY TABLE IF EXISTS tmp_Msg_Error;
DROP TEMPORARY TABLE IF EXISTS tmp_Split;
CREATE TABLE tmp_Manufacturing_Purchase_Order (
CREATE TEMPORARY TABLE tmp_Manufacturing_Purchase_Order (
id_order INT NOT NULL PRIMARY KEY
);
CREATE TABLE tmp_Manufacturing_Purchase_Order_Product_Link (
id_link INT NOT NULL PRIMARY KEY,
id_order INT NOT NULL,
id_permutation INT NOT NULL
CREATE TEMPORARY TABLE tmp_Permutation (
id_permutation INT NOT NULL PRIMARY KEY
);
CREATE TABLE IF NOT EXISTS tmp_Msg_Error (
CREATE TEMPORARY TABLE IF NOT EXISTS tmp_Msg_Error (
display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
id_type INT NOT NULL,
code VARCHAR(50) NOT NULL,
msg VARCHAR(4000) NOT NULL
);
CREATE TEMPORARY TABLE IF NOT EXISTS tmp_Split (
substring VARCHAR(4000) NOT NULL
, as_int INT NULL
);
DELETE FROM tmp_Split;
SET v_has_filter_order = CASE WHEN a_ids_order = '' THEN 0 ELSE 1 END;
SET v_has_filter_permutation = CASE WHEN a_ids_permutation = '' THEN 0 ELSE 1 END;
SET v_has_filter_date_from = CASE WHEN ISNULL(a_date_from) THEN 0 ELSE 1 END;
@@ -172,13 +175,13 @@ BEGIN
IF EXISTS (
SELECT *
FROM tmp_Split t_S
LEFT JOIN partsltd_prod.Shop_Manufacturing_Purchase_Order SPO ON t_S.as_int = SPO.id_order
LEFT JOIN partsltd_prod.Shop_Manufacturing_Purchase_Order MPO ON t_S.as_int = MPO.id_order
WHERE
ISNULL(t_S.as_int)
OR ISNULL(SPO.id_order)
OR ISNULL(MPO.id_order)
OR (
SPO.active = 0
AND v_get_inactive_order = 0
MPO.active = 0
AND a_get_inactive_order = 0
)
) THEN
INSERT INTO tmp_Msg_Error (
@@ -191,13 +194,13 @@ BEGIN
v_code_type_error_bad_data,
CONCAT('Invalid or inactive Manufacturing Purchase Order IDs: ', IFNULL(GROUP_CONCAT(t_S.substring SEPARATOR ', '), 'NULL'))
FROM tmp_Split t_S
LEFT JOIN partsltd_prod.Shop_Manufacturing_Purchase_Order SPO ON t_S.as_int = SPO.id_order
LEFT JOIN partsltd_prod.Shop_Manufacturing_Purchase_Order MPO ON t_S.as_int = MPO.id_order
WHERE
ISNULL(t_S.as_int)
OR ISNULL(SPO.id_order)
OR ISNULL(MPO.id_order)
OR (
SPO.active = 0
AND v_get_inactive_order = 0
MPO.active = 0
AND a_get_inactive_order = 0
)
;
ELSE
@@ -205,11 +208,11 @@ BEGIN
id_order
)
SELECT
SPO.id_order
MPO.id_order
FROM tmp_Split t_S
RIGHT JOIN partsltd_prod.Shop_Manufacturing_Purchase_Order SPO ON t_S.as_int = SPO.id_order
INNER JOIN partsltd_prod.Shop_Manufacturing_Purchase_Order_Product_Link SPOPL ON SPO.id_order = SPOPL.id_order
INNER JOIN tmp_Permutation t_PP ON SPOPL.id_permutation = t_PP.id_permutation
RIGHT JOIN partsltd_prod.Shop_Manufacturing_Purchase_Order MPO ON t_S.as_int = MPO.id_order
INNER JOIN partsltd_prod.Shop_Manufacturing_Purchase_Order_Product_Link MPOPL ON MPO.id_order = MPOPL.id_order
INNER JOIN tmp_Permutation t_PP ON MPOPL.id_permutation = t_PP.id_permutation
WHERE (
a_get_all_order = 1
OR (
@@ -223,15 +226,15 @@ BEGIN
)
AND (
a_get_inactive_order = 1
OR SPO.active = 1
OR MPO.active = 1
)
AND (
v_has_filter_date_from = 0
OR SPO.created_on > a_date_from
OR MPO.created_on > a_date_from
)
AND (
v_has_filter_date_to = 0
OR SPO.created_on < a_date_to
OR MPO.created_on < a_date_to
)
;
@@ -246,40 +249,40 @@ BEGIN
v_guid
, a_id_user
, FALSE -- get inactive users
, v_id_permission_manufacturing_purchase_order
, v_ids_permission_manufacturing_purchase_order
, v_id_access_level_view
, '' -- ids_product
, 0 -- a_debug
;
SELECT * from Shop_Calc_User_Temp;
SELECT * FROM partsltd_prod.Shop_Calc_User_Temp;
END IF;
CALL p_shop_calc_user(
v_guid
, a_id_user
, FALSE -- get inactive users
, v_id_permission_manufacturing_purchase_order
, v_ids_permission_manufacturing_purchase_order
, v_id_access_level_view
, '' -- ids_product
, 0 -- a_debug
);
IF a_debug = 1 THEN
SELECT * from Shop_Calc_User_Temp;
SELECT * FROM partsltd_prod.Shop_Calc_User_Temp;
END IF;
IF NOT EXISTS (SELECT can_view FROM Shop_Calc_User_Temp UE_T WHERE UE_T.GUID = v_guid) THEN
IF NOT EXISTS (SELECT can_view FROM partsltd_prod.Shop_Calc_User_Temp UE_T WHERE UE_T.GUID = v_guid) THEN
DELETE FROM tmp_Msg_Error;
INSERT INTO tmp_Msg_Error (
, id_type
id_type
, code
, msg
)
VALUES (
v_id_type_error_no_permission
, v_code_type_error_no_permission
CONCAT('You do not have view permissions for ', (SELECT name FROM Shop_Permission WHERE id_permission = v_id_permission_manufacturing LIMIT 1))
, CONCAT('You do not have view permissions for ', (SELECT name FROM partsltd_prod.Shop_Permission WHERE id_permission = v_id_permission_manufacturing LIMIT 1))
)
;
END IF;
@@ -305,60 +308,66 @@ BEGIN
S.id_currency,
t_S.active
FROM tmp_Manufacturing t_S
INNER JOIN Shop_Manufacturing S
INNER JOIN partsltd_prod.Shop_Manufacturing S
ON t_S.id_manufacturing = S.id_manufacturing
;
*/
# Manufacturing Purchase Order
SELECT
t_SPO.id_order
, SPO.id_manufacturing_ordered
, SPO.id_currency_cost
, SPO.cost_total_local_VAT_excl
, SPO.cost_total_local_VAT_incl
, SPO.active
FROM tmp_Manufacturing_Purchase_Order t_SPO
INNER JOIN partsltd_prod.Shop_Manufacturing_Purchase_Order SPO ON SPO.id_order = t_SPO.id_order
t_MPO.id_order
, MPO.id_currency
, MPO.cost_total_local_VAT_excl
, MPO.cost_total_local_VAT_incl
, MPO.price_total_local_VAT_excl
, MPO.price_total_local_VAT_incl
, MPO.active
, MPO.created_on
, CONCAT(
MPO.cost_total_local_VAT_excl
, ' on '
, MPO.created_on
) AS name
FROM tmp_Manufacturing_Purchase_Order t_MPO
INNER JOIN partsltd_prod.Shop_Manufacturing_Purchase_Order MPO ON MPO.id_order = t_MPO.id_order
;
# Manufacturing Purchase Order Product Link
SELECT
SPOPL.id_link
, SPOPL.id_order
, SPOPL.id_permutation
, fn_shop_get_product_permutation_name(SPOPL.id_permutation) AS name_permutation
, SPOPL.id_currency_cost
, SPOPL.id_unit_quantity
, SPOPL.quantity_ordered
, SPOPL.quantity_received
, SPOPL.latency_delivery_days
, SPOPL.display_order
, SPO.cost_total_local_VAT_excl
, SPO.cost_total_local_VAT_incl
, SPO.cost_unit_local_VAT_excl
, SPO.cost_unit_local_VAT_incl
FROM tmp_Manufacturing_Purchase_Order_Product_Link t_SPOPL
INNER JOIN partsltd_prod.Shop_Manufacturing_Purchase_Order_Product_Link SPOPL ON t_SPOPL.id_link = SPOPL.id_link
INNER JOIN tmp_Manufacturing_Purchase_Order t_SPO ON SPOPL.id_order = t_SPO.id_order
MPOPL.id_link
, MPOPL.id_order
, MPOPL.id_permutation
, fn_shop_get_product_permutation_name(MPOPL.id_permutation) AS name_permutation
, MPOPL.id_unit_quantity
, MPOPL.quantity_used
, MPOPL.quantity_produced
, MPOPL.latency_manufacture_days
, MPOPL.display_order
, MPOPL.cost_unit_local_VAT_excl
, MPOPL.cost_unit_local_VAT_incl
, MPOPL.price_unit_local_VAT_excl
, MPOPL.price_unit_local_VAT_incl
, MPOPL.active
FROM tmp_Manufacturing_Purchase_Order t_MPO
INNER JOIN partsltd_prod.Shop_Manufacturing_Purchase_Order_Product_Link MPOPL ON t_MPO.id_order = MPOPL.id_order
;
# Errors
SELECT *
FROM tmp_Msg_Error t_ME
INNER JOIN Shop_Msg_Error_Type MET ON t_ME.id_type = MET.id_type
INNER JOIN partsltd_prod.Shop_Msg_Error_Type MET ON t_ME.id_type = MET.id_type
;
IF a_debug = 1 THEN
SELECT * from tmp_Manufacturing_Purchase_Order_Product_Link;
SELECT * from tmp_Manufacturing_Purchase_Order;
SELECT * from tmp_Manufacturing;
SELECT * from tmp_Permutation;
END IF;
DROP TEMPORARY TABLE IF EXISTS tmp_Manufacturing_Purchase_Order_Product_Link;
DROP TEMPORARY TABLE IF EXISTS tmp_Manufacturing_Purchase_Order;
DROP TEMPORARY TABLE IF EXISTS tmp_Manufacturing;
DROP TEMPORARY TABLE IF EXISTS tmp_Permutation;
DROP TEMPORARY TABLE IF EXISTS tmp_Msg_Error;
DROP TEMPORARY TABLE IF EXISTS tmp_Split;
IF a_debug = 1 THEN
CALL p_debug_timing_reporting( v_time_start );
@@ -367,20 +376,17 @@ END //
DELIMITER ;;
/*
CALL p_shop_get_many_manufacturing_purchase_order (
'', # a_id_user
1, # a_get_all_manufacturing
0, # a_get_inactive_manufacturing
'', # a_ids_manufacturing
1, # a_get_all_order
-- 0, # a_get_inactive_order
'', # a_ids_order
'', # a_ids_permutation
NULL, # a_date_from
NULL # a_date_to
1 # a_id_user
, 1 # a_get_all_order
, 0 # a_get_inactive_order
, '' # a_ids_order
, '' # a_ids_permutation
, NULL # a_date_from
, NULL # a_date_to
, 0 # a_debug
);
/*
*/

View File

@@ -690,10 +690,28 @@ VALUES
# Supplier
INSERT INTO Shop_Supplier (
name_company, name_contact, department_contact, id_address, phone_number, fax, email, website, id_currency
name_company
, name_contact
, department_contact
-- , id_address
, phone_number
, fax
, email
, website
, id_currency
)
VALUES
('Precision And Research Technology Systems Limited', 'Teddy Middleton-Smith', 'Executive Management', 1, '07375571430', '', 'teddy@partsltd.co.uk', 'www.partsltd.co.uk', 1)
(
'Precision And Research Technology Systems Limited'
, 'Teddy Middleton-Smith'
, 'Executive Management'
-- , 1
, '07375571430'
, ''
, 'teddy@partsltd.co.uk'
, 'www.partsltd.co.uk'
, 1
)
;
# Suppliers
@@ -701,7 +719,7 @@ INSERT INTO Shop_Supplier (
name_company
, name_contact
, department_contact
, id_address
-- , id_address
, phone_number
, fax
, email
@@ -709,7 +727,51 @@ INSERT INTO Shop_Supplier (
, id_currency
)
VALUES
('Malt Kiln Farm Shop', NULL, NULL, 1, '01788 832640', NULL, 'farmshop@maltkilnfarmshop.co.uk', 'https://www.maltkilnfarmshop.co.uk/', 1)
(
'Malt Kiln Farm Shop'
, NULL
, NULL
-- , 1
, '01788 832640'
, NULL
, 'farmshop@maltkilnfarmshop.co.uk'
, 'https://www.maltkilnfarmshop.co.uk/'
, 1
)
;
# Supplier Addresses
INSERT INTO Shop_Supplier_Address (
id_supplier
, id_region
, postcode
, address_line_1
, address_line_2
, city
, county
, active
)
VALUES
(
1
, 1
, 'CV22 6DN'
, '53 Alfred Green Close'
, ''
, 'Rugby'
, 'Warwickshire'
, 1
),
(
2
, 1
, 'CV22 6DN'
, '53 Alfred Green Close'
, ''
, 'Rugby'
, 'Warwickshire'
, 1
)
;
/*

View File

@@ -91,13 +91,19 @@
1398_tbl_Shop_Order_Status_Audit.sql
1400_tbl_Shop_Supplier.sql
1401_tbl_Shop_Supplier_Audit.sql
1402_tbl_Shop_Supplier_Temp.sql
1403_tbl_Shop_Supplier_Address.sql
1403_tbl_Shop_Supplier_Address_Temp.sql
1404_tbl_Shop_Supplier_Address.sql
1409_tbl_Shop_Supplier_Purchase_Order.sql
1410_tbl_Shop_Supplier_Purchase_Order_Audit.sql
1411_tbl_Shop_Supplier_Purchase_Order_Temp.sql
1412_tbl_Shop_Supplier_Purchase_Order_Product_Link.sql
1413_tbl_Shop_Supplier_Purchase_Order_Product_Link_Audit.sql
1414_tbl_Shop_Supplier_Purchase_Order_Product_Link_Temp.sql
1415_tbl_Shop_Manufacturing_Purchase_Order.sql
1416_tbl_Shop_Manufacturing_Purchase_Order_Audit.sql
1417_tbl_Shop_Manufacturing_Purchase_Order_Temp.sql
1418_tbl_Shop_Manufacturing_Purchase_Order_Product_Link.sql
1419_tbl_Shop_Manufacturing_Purchase_Order_Product_Link_Audit.sql
1420_tbl_Shop_Manufacturing_Purchase_Order_Product_Link_Temp.sql
@@ -146,6 +152,7 @@
3321_tri_Shop_User_Basket.sql
3324_tri_Shop_User_Order_Status.sql
3400_tri_Shop_Supplier.sql
3403_tri_Shop_Supplier_Address.sql
3403_tri_Shop_Unit_Measurement.sql
3406_tri_Shop_Unit_Of_Measurement_Conversion.sql
3409_tri_Shop_Supplier_Purchase_Order.sql
@@ -162,6 +169,7 @@
6003_p_split_key_value_pair_csv.sql
6004_p_clear_split_key_value_pair_csv_temp.sql
6206_fn_shop_get_product_permutation_name.sql
6210_fn_shop_get_id_product_permutation_from_variation_csv_list.sql
6500_p_shop_calc_user.sql
6501_p_shop_clear_calc_user.sql
7003_p_shop_get_many_access_level.sql
@@ -179,7 +187,6 @@
7204_p_shop_get_many_product.sql
7205_p_shop_get_many_stripe_product_new.sql
7206_p_shop_save_product_permutation.sql
7210_fn_shop_get_id_product_permutation_from_variation_csv_list.sql
7210_p_shop_get_many_product_variation.sql
7219_p_shop_get_many_stock_item.sql
7220_p_shop_save_stock_item.sql