feat: Shop Supplier Purchase Order get, filter, and add new.

This commit is contained in:
2024-10-25 16:42:13 +01:00
parent 002551c0a9
commit ea5b8e8ca1
121 changed files with 3835 additions and 865 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -43,6 +43,7 @@ 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_Supplier_Address;
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;
@@ -305,6 +306,7 @@ DROP PROCEDURE IF EXISTS p_get_many_user;
DROP PROCEDURE IF EXISTS p_shop_get_many_user_basket;
DROP PROCEDURE IF EXISTS p_shop_edit_user_basket;
DROP PROCEDURE IF EXISTS p_shop_save_supplier;
DROP PROCEDURE IF EXISTS p_shop_save_supplier_test;
DROP PROCEDURE IF EXISTS p_shop_get_many_supplier;
DROP PROCEDURE IF EXISTS p_shop_save_supplier_purchase_order;
DROP PROCEDURE IF EXISTS p_shop_get_many_supplier_purchase_order;

View File

@@ -18,7 +18,7 @@ CREATE TABLE IF NOT EXISTS Shop_Product_Permutation (
id_currency_cost INT NOT NULL,
profit_local_min FLOAT NOT NULL,
-- id_currency_profit_min INT NOT NULL,
latency_manufacture_days INT NOT NULL,
latency_manufacture INT NOT NULL,
id_unit_measurement_quantity INT NOT NULL,
CONSTRAINT FK_Shop_Product_Permutation_id_unit_quantity
FOREIGN KEY (id_unit_measurement_quantity)

View File

@@ -12,7 +12,7 @@ CREATE TABLE IF NOT EXISTS Shop_Product_Permutation_Temp (
, cost_local FLOAT NOT NULL
, id_currency_cost INT NOT NULL
, profit_local_min FLOAT NOT NULL
, latency_manufacture_days INT NOT NULL
, latency_manufacture INT NOT NULL
, id_unit_measurement_quantity INT NOT NULL
, count_unit_measurement_per_quantity_step FLOAT NOT NULL
, quantity_min FLOAT NOT NULL

View File

@@ -4,29 +4,30 @@
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Supplier';
CREATE TABLE IF NOT EXISTS Shop_Supplier (
id_supplier INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
name_company VARCHAR(255) NOT NULL,
name_contact VARCHAR(255) NULL,
department_contact VARCHAR(255) NULL,
id_supplier INT NOT NULL AUTO_INCREMENT PRIMARY KEY
, 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,
website VARCHAR(255) NULL,
id_currency INT NOT NULL,
CONSTRAINT FK_Shop_Supplier_id_currency
, phone_number VARCHAR(50) NULL
, fax VARCHAR(50) NULL
, email VARCHAR(255) NOT NULL
, website VARCHAR(255) NULL
, id_currency INT NOT NULL
, CONSTRAINT FK_Shop_Supplier_id_currency
FOREIGN KEY (id_currency)
REFERENCES Shop_Currency(id_currency),
active BIT NOT NULL DEFAULT 1,
created_on DATETIME,
created_by INT,
id_change_set INT,
CONSTRAINT FK_Shop_Supplier_id_change_set
REFERENCES Shop_Currency(id_currency)
, active BIT NOT NULL DEFAULT 1
, created_on DATETIME
, created_by INT
, id_change_set INT
, CONSTRAINT FK_Shop_Supplier_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES Shop_User_Change_Set(id_change_set)
REFERENCES Shop_Sales_And_Purchasing_Change_Set(id_change_set)
, id_supplier_temp INT NOT NULL
);

View File

@@ -25,5 +25,5 @@ CREATE TABLE Shop_Supplier_Address (
, 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)
REFERENCES partsltd_prod.Shop_Sales_And_Purchasing_Change_Set(id_change_set)
);

View File

@@ -7,6 +7,7 @@ SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning
CREATE TABLE IF NOT EXISTS Shop_Supplier_Purchase_Order (
id_order INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
id_order_temp INT NULL,
id_supplier_ordered INT NOT NULL,
CONSTRAINT FK_Shop_Supplier_Purchase_Order_id_supplier_ordered
FOREIGN KEY (id_supplier_ordered)

View File

@@ -1,11 +1,14 @@
# Supplier Purchase Order Staging
DROP TABLE IF EXISTS Shop_Supplier_Purchase_Order_Temp;
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Supplier_Purchase_Order_Temp';
CREATE TABLE IF NOT EXISTS Shop_Supplier_Purchase_Order_Temp (
id_order INT NOT NULL,
id_supplier_ordered INT NOT NULL,
id_currency_cost INT NOT NULL,
active BIT NULL
id_order INT NOT NULL
, id_supplier_ordered INT NOT NULL
, id_currency_cost INT NOT NULL
, active BIT NULL
, GUID BINARY(36) NOT NULL
);

View File

@@ -10,8 +10,9 @@ SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning
CREATE TABLE IF NOT EXISTS Shop_Supplier_Purchase_Order_Product_Link_Temp (
id_link INT NOT NULL PRIMARY KEY
, id_order INT NOT NULL
, id_permutation INT NOT NULL
, id_currency_cost INT NOT NULL
, id_product INT NULL
, id_permutation INT NULL
, csv_list_variations VARCHAR(4000) NULL
, id_unit_quantity INT NOT NULL
, quantity_ordered FLOAT NOT NULL
, quantity_received FLOAT NULL

View File

@@ -5,6 +5,7 @@ SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning
CREATE TABLE IF NOT EXISTS Shop_Manufacturing_Purchase_Order (
id_order INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
id_order_temp INT NULL,
/*
cost_total_local FLOAT NOT NULL,
id_currency_cost INT NOT NULL,

View File

@@ -2,38 +2,41 @@
# Manufacturing Purchase Order Product Link
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Manufacturing_Purchase_Order_Product_Link';
CREATE TABLE IF NOT EXISTS Shop_Manufacturing_Purchase_Order_Product_Link (
id_link INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
id_order INT NOT NULL,
CONSTRAINT FK_Manufacturing_Purchase_Order_Product_Link_id_order
id_link INT NOT NULL AUTO_INCREMENT PRIMARY KEY
, id_order INT NOT NULL
, CONSTRAINT FK_Manufacturing_Purchase_Order_Product_Link_id_order
FOREIGN KEY (id_order)
REFERENCES Shop_Manufacturing_Purchase_Order(id_order),
id_permutation INT NOT NULL,
CONSTRAINT FK_Manufacturing_Purchase_Order_Product_Link_id_permutation
REFERENCES Shop_Manufacturing_Purchase_Order(id_order)
, id_permutation INT NOT NULL
, CONSTRAINT FK_Manufacturing_Purchase_Order_Product_Link_id_permutation
FOREIGN KEY (id_permutation)
REFERENCES Shop_Product_Permutation(id_permutation),
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
REFERENCES Shop_Product_Permutation(id_permutation)
, 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
, 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),
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,
created_by INT,
updated_last_on DATETIME NULL,
created_last_by VARCHAR(100) NULL,
id_change_set INT NULL,
CONSTRAINT FK_Manufacturing_Purchase_Order_id_change_set
REFERENCES Shop_Unit_Measurement(id_unit_measurement)
, quantity_used FLOAT NULL
, quantity_produced FLOAT NULL
, id_unit_latency_manufacture INT NULL
, CONSTRAINT FK_MPO_id_unit_latency_manufacture
FOREIGN KEY (id_unit_latency_manufacture)
REFERENCES Shop_Unit_Measurement(id_unit_measurement)
, latency_manufacture INT NULL
, display_order INT NOT NULL
, active BIT NOT NULL
, created_on DATETIME
, created_by INT
, updated_last_on DATETIME NULL
, created_last_by VARCHAR(100) NULL
, id_change_set INT NULL
, CONSTRAINT FK_Manufacturing_Purchase_Order_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES Shop_Sales_And_Purchasing_Change_Set(id_change_set)
);

View File

@@ -11,9 +11,10 @@ CREATE TABLE IF NOT EXISTS Shop_Manufacturing_Purchase_Order_Product_Link_Temp (
id_order INT NOT NULL,
id_permutation INT NOT NULL,
id_unit_quantity INT NOT NULL,
quantity_used FLOAT NOT NULL,
latency_manufacture_days INT NOT NULL,
quantity_produced FLOAT NOT NULL,
quantity_used FLOAT NULL,
quantity_produced FLOAT NULL,
id_unit_latency_manufacture INT NULL,
latency_manufacture INT NULL,
display_order INT NOT NULL,
active BIT NOT NULL,
cost_unit_local_VAT_excl FLOAT NULL,

View File

@@ -93,9 +93,9 @@ BEGIN
WHERE NOT (OLD.price_GBP_min <=> NEW.price_GBP_min)
UNION
*/
# Changed latency_manufacture_days
SELECT NEW.id_permutation, 'latency_manufacture_days', CONVERT(OLD.latency_manufacture_days, CHAR), CONVERT(NEW.latency_manufacture_days, CHAR), NEW.id_change_set
WHERE NOT OLD.latency_manufacture_days <=> NEW.latency_manufacture_days
# Changed latency_manufacture
SELECT NEW.id_permutation, 'latency_manufacture', CONVERT(OLD.latency_manufacture, CHAR), CONVERT(NEW.latency_manufacture, CHAR), NEW.id_change_set
WHERE NOT OLD.latency_manufacture <=> NEW.latency_manufacture
UNION
# Changed id_unit_measurement_quantity
SELECT NEW.id_permutation, 'id_unit_measurement_quantity', CONVERT(OLD.id_unit_measurement_quantity, CHAR), CONVERT(NEW.id_unit_measurement_quantity, CHAR), NEW.id_change_set

View File

@@ -72,6 +72,10 @@ BEGIN
# Changed id_currency
SELECT NEW.id_supplier, 'id_currency', OLD.id_currency, NEW.id_currency, NEW.id_change_set
WHERE NOT OLD.id_currency <=> NEW.id_currency
UNION
# Changed id_supplier_temp
SELECT NEW.id_supplier, 'id_supplier_temp', OLD.id_supplier_temp, NEW.id_supplier_temp, NEW.id_change_set
WHERE NOT OLD.id_supplier_temp <=> NEW.id_supplier_temp
;
END //
DELIMITER ;;

View File

@@ -35,6 +35,10 @@ BEGIN
value_new,
id_change_set
)
# Changed id_order_temp
SELECT NEW.id_order, 'id_order_temp', OLD.id_order_temp, NEW.id_order_temp, NEW.id_change_set
WHERE NOT OLD.id_order_temp <=> NEW.id_order_temp
UNION
# 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

View File

@@ -13,7 +13,11 @@ BEFORE INSERT ON Shop_Manufacturing_Purchase_Order
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));
-- SET NEW.created_by := IFNULL(NEW.created_by, IFNULL((SELECT id_user FROM Shop_User WHERE firstname = CURRENT_USER()), -1));
IF NOT EXISTS (SELECT * FROM partsltd_prod.Shop_User U WHERE U.id_user = NEW.created_on LIMIT 1) THEN
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'Valid created by User ID must be provided.';
END IF;
END //
DELIMITER ;;
@@ -27,6 +31,10 @@ BEGIN
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'New change Set ID must be provided.';
END IF;
IF NOT EXISTS (SELECT * FROM partsltd_prod.Shop_User U WHERE U.id_user = NEW.created_on LIMIT 1) THEN
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'Valid created by User ID must be provided.';
END IF;
INSERT INTO Shop_Manufacturing_Purchase_Order_Audit (
id_order,
@@ -35,6 +43,10 @@ BEGIN
value_new,
id_change_set
)
# Changed id_order_temp
SELECT NEW.id_order, 'id_order_temp', OLD.id_order_temp, NEW.id_order_temp, NEW.id_change_set
WHERE NOT OLD.id_order_temp <=> NEW.id_order_temp
UNION
# 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

View File

@@ -71,9 +71,13 @@ BEGIN
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
WHERE NOT OLD.latency_manufacture_days <=> NEW.latency_manufacture_days
# Changed id_unit_latency_manufacture
SELECT NEW.id_link, 'id_unit_latency_manufacture', OLD.id_unit_latency_manufacture, NEW.id_unit_latency_manufacture, NEW.id_change_set
WHERE NOT OLD.id_unit_latency_manufacture <=> NEW.id_unit_latency_manufacture
UNION
# Changed latency_manufacture
SELECT NEW.id_link, 'latency_manufacture', OLD.latency_manufacture, NEW.latency_manufacture, NEW.id_change_set
WHERE NOT OLD.latency_manufacture <=> NEW.latency_manufacture
UNION
# Changed display_order
SELECT NEW.id_link, 'display_order', OLD.display_order, NEW.display_order, NEW.id_change_set

View File

@@ -12,18 +12,21 @@ BEGIN
SET name := (
SELECT
CONCAT(
P.name
IFNULL(PC.name, '(No Category)')
, ' - '
, IFNULL(P.name, '(No Product)')
, CASE WHEN P.has_variations = 1 THEN
CONCAT(' - ', GROUP_CONCAT(CONCAT(VT.name, ': ', V.name) SEPARATOR ', '))
ELSE '' END
)
FROM Shop_Product_Permutation PP
INNER JOIN Shop_Product P ON PP.id_product = P.id_product
INNER JOIN Shop_Product_Permutation_Variation_Link PPVL ON PP.id_permutation = PPVL.id_permutation
INNER JOIN Shop_Variation V ON PPVL.id_variation = V.id_variation
INNER JOIN Shop_Variation_Type VT ON V.id_type = VT.id_type
INNER JOIN Shop_Product_Category PC ON P.id_category = PC.id_category
LEFT JOIN Shop_Product_Permutation_Variation_Link PPVL ON PP.id_permutation = PPVL.id_permutation
LEFT JOIN Shop_Variation V ON PPVL.id_variation = V.id_variation
LEFT JOIN Shop_Variation_Type VT ON V.id_type = VT.id_type
WHERE PP.id_permutation = id_product_permutation
GROUP BY P.id_product, P.name, P.has_variations, VT.display_order, VT.name, V.display_order, V.name
GROUP BY PC.id_category, PC.name, P.id_product, P.name, P.has_variations, VT.display_order, VT.name, V.display_order, V.name
LIMIT 1
);
@@ -31,3 +34,10 @@ BEGIN
END //
DELIMITER ;
SELECT
fn_shop_get_product_permutation_name(
3 -- id_product_permutation
)
;

View File

@@ -549,7 +549,7 @@ BEGIN
, cost_local
, id_currency_cost
, profit_local_min
, latency_manufacture_days
, latency_manufacture
, id_unit_measurement_quantity
, count_unit_measurement_per_quantity_step
, quantity_min
@@ -575,7 +575,7 @@ BEGIN
, PP.cost_local
, PP.id_currency_cost
, PP.profit_local_min
, PP.latency_manufacture_days
, PP.latency_manufacture
, PP.id_unit_measurement_quantity
, PP.count_unit_measurement_per_quantity_step
, PP.quantity_min

View File

@@ -342,7 +342,7 @@ BEGIN
C.code AS code_currency_cost,
C.symbol AS symbol_currency_cost,
PP.profit_local_min,
PP.latency_manufacture_days,
PP.latency_manufacture,
PP.id_unit_measurement_quantity,
UM_Q.symbol AS symbol_unit_measurement_quantity,
UM_Q.symbol_is_suffix_not_prefix AS symbol_is_suffix_not_prefix_unit_measurement_quantity,

View File

@@ -74,7 +74,7 @@ BEGIN
, cost_local FLOAT NOT NULL
, id_currency_cost INT NOT NULL
, profit_local_min FLOAT NOT NULL
, latency_manufacture_days INT NOT NULL
, latency_manufacture INT NOT NULL
, id_unit_measurement_quantity INT NOT NULL
, count_unit_measurement_per_quantity_step FLOAT NOT NULL
, quantity_min FLOAT NOT NULL
@@ -112,7 +112,7 @@ BEGIN
, cost_local
, id_currency_cost
, profit_local_min
, latency_manufacture_days
, latency_manufacture
, id_unit_measurement_quantity
, count_unit_measurement_per_quantity_step
, quantity_min
@@ -136,7 +136,7 @@ BEGIN
, IFNULL(PP_T.cost_local, PP.cost_local) AS cost_local
, IFNULL(PP_T.id_currency_cost, PP.id_currency_cost) AS a_id_currency_cost
, IFNULL(PP_T.profit_local_min, PP.profit_local_min) AS profit_local_min
, IFNULL(PP_T.latency_manufacture_days, PP.latency_manufacture_days) AS latency_manufacture_days
, IFNULL(PP_T.latency_manufacture, PP.latency_manufacture) AS latency_manufacture
, IFNULL(PP_T.id_unit_measurement_quantity, PP.id_unit_measurement_quantity) AS id_unit_measurement_quantity
, IFNULL(PP_T.count_unit_measurement_per_quantity_step, PP.count_unit_measurement_per_quantity_step) AS count_unit_measurement_per_quantity_step
, IFNULL(PP_T.quantity_min, PP.quantity_min) AS quantity_min
@@ -210,12 +210,12 @@ BEGIN
WHERE ISNULL(t_P.profit_local_min)
;
END IF;
-- latency_manufacture_days
IF EXISTS (SELECT * FROM tmp_Permutation t_P WHERE ISNULL(t_P.latency_manufacture_days) LIMIT 1) THEN
-- latency_manufacture
IF EXISTS (SELECT * FROM tmp_Permutation t_P WHERE ISNULL(t_P.latency_manufacture) LIMIT 1) THEN
INSERT INTO tmp_Msg_Error (
guid
, id_type
, latency_manufacture_days
, latency_manufacture
, msg
)
SELECT
@@ -224,7 +224,7 @@ BEGIN
, v_code_type_error_bad_data
, CONCAT('The following product permutation(s) do not have a manufacturing latency: ', GROUP_CONCAT(IFNULL(t_P.name_error, 'NULL') SEPARATOR ', ')) AS msg
FROM tmp_Permutation t_P
WHERE ISNULL(t_P.latency_manufacture_days)
WHERE ISNULL(t_P.latency_manufacture)
;
END IF;
-- id_unit_measurement_quantity
@@ -396,7 +396,7 @@ BEGIN
, PP.cost_local = t_P.cost_local
, PP.id_currency_cost = t_P.id_currency_cost
, PP.profit_local_min = t_P.profit_local_min
, PP.latency_manufacture_days = t_P.latency_manufacture_days
, PP.latency_manufacture = t_P.latency_manufacture
, PP.id_unit_measurement_quantity = t_P.id_unit_measurement_quantity
, PP.count_unit_measurement_per_quantity_step = t_P.count_unit_measurement_per_quantity_step
, PP.quantity_min = t_P.quantity_min
@@ -420,7 +420,7 @@ BEGIN
, cost_local
, id_currency_cost
, profit_local_min
, latency_manufacture_days
, latency_manufacture
, id_unit_measurement_quantity
, count_unit_measurement_per_quantity_step
, quantity_min
@@ -443,7 +443,7 @@ BEGIN
, t_P.cost_local AS cost_local
, t_P.id_currency_cost AS id_currency_cost
, t_P.profit_local_min AS profit_local_min
, t_P.latency_manufacture_days AS latency_manufacture_days
, t_P.latency_manufacture AS latency_manufacture
, t_P.id_unit_measurement_quantity AS id_unit_measurement_quantity
, t_P.count_unit_measurement_per_quantity_step AS count_unit_measurement_per_quantity_step
, t_P.quantity_min AS quantity_min
@@ -492,7 +492,7 @@ INSERT INTO Shop_Product_Permutation_Temp (
cost_local,
id_currency_cost,
profit_local_min,
latency_manufacture_days,
latency_manufacture,
id_unit_measurement_quantity,
count_unit_measurement_per_quantity_step,
quantity_min,
@@ -516,7 +516,7 @@ VALUES
, 5.0 -- cost_local,
, 1 -- id_currency_cost,
, 3.0 -- profit_local_min,
, 14 -- latency_manufacture_days,
, 14 -- latency_manufacture,
, 1 -- id_unit_measurement_quantity,
, 1.0 -- count_unit_measurement_quantity,
, 3.0 -- quantity_min,

View File

@@ -629,7 +629,7 @@ INSERT INTO Shop_Product_Permutation_Temp (
cost_local,
id_currency_cost,
profit_local_min,
latency_manufacture_days,
latency_manufacture,
id_unit_measurement_quantity,
count_unit_measurement_per_quantity_step,
quantity_min,
@@ -653,7 +653,7 @@ VALUES
, 5.0 -- cost_local,
, 1 -- id_currency_cost,
, 3.0 -- profit_local_min,
, 14 -- latency_manufacture_days,
, 14 -- latency_manufacture,
, 1 -- id_unit_measurement_quantity,
, 1.0 -- count_unit_measurement_quantity,
, 3.0 -- quantity_min,

View File

@@ -691,7 +691,7 @@ BEGIN
CURRENCY.code AS code_currency_cost,
CURRENCY.symbol AS symbol_currency_cost,
PP.profit_local_min,
t_P.latency_manufacture_days,
t_P.latency_manufacture,
t_P.quantity_min,
t_P.quantity_max,
t_P.quantity_step,

View File

@@ -68,11 +68,12 @@ BEGIN
SET a_comment := TRIM(IFNULL(a_comment, ''));
DROP TEMPORARY TABLE IF EXISTS tmp_Supplier;
DROP TEMPORARY TABLE IF EXISTS tmp_Supplier_Address;
DROP TEMPORARY TABLE IF EXISTS tmp_Msg_Error;
CREATE TEMPORARY TABLE tmp_Supplier (
id_supplier INT NOT NULL
, id_address INT NOT NULL
id_supplier_temp INT NOT NULL
, id_supplier INT NULL
, id_currency INT NOT NULL
, name_company VARCHAR(255) NOT NULL
, name_contact VARCHAR(255) NULL
@@ -96,6 +97,8 @@ BEGIN
, city VARCHAR(256) NOT NULL
, county VARCHAR(256) NOT NULL
, active BIT NOT NULL
, name_error VARCHAR(1000) NOT NULL
, is_new BIT NOT NULL
);
CREATE TEMPORARY TABLE IF NOT EXISTS tmp_Msg_Error (
@@ -107,8 +110,8 @@ BEGIN
INSERT INTO tmp_Supplier (
id_supplier
, id_address
id_supplier_temp
, id_supplier
, id_currency
, name_company
, name_contact
@@ -123,7 +126,7 @@ BEGIN
)
SELECT
S_T.id_supplier
, S_T.id_address
, S_T.id_supplier
, S_T.id_currency
, S_T.name_company
, S_T.name_contact
@@ -269,7 +272,7 @@ BEGIN
;
END IF;
# duplicate
IF EXISTS (SELECT COUNT(*) FROM tmp_Supplier t_S WHERE COUNT(*) > 1 GROUP BY t_S.id_supplier) THEN
IF EXISTS (SELECT COUNT(*) FROM tmp_Supplier t_S GROUP BY t_S.id_supplier HAVING COUNT(*) > 1) THEN
INSERT INTO tmp_Msg_Error (
id_type
, code
@@ -280,8 +283,8 @@ BEGIN
, 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
HAVING COUNT(*) > 1
;
END IF;
@@ -353,7 +356,7 @@ BEGIN
;
END IF;
# duplicate
IF EXISTS (SELECT COUNT(*) FROM tmp_Supplier_Address t_SA WHERE COUNT(*) > 1 GROUP BY t_SA.id_address) THEN
IF EXISTS (SELECT COUNT(*) FROM tmp_Supplier_Address t_SA GROUP BY t_SA.id_address HAVING COUNT(*) > 1) THEN
INSERT INTO tmp_Msg_Error (
id_type
, code
@@ -364,15 +367,15 @@ BEGIN
, 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
HAVING COUNT(*) > 1
;
END IF;
-- Permissions
IF a_debug = 1 THEN
SELECT
v_guid
a_guid
, a_id_user
, FALSE -- get inactive users
, v_id_permission_supplier
@@ -384,7 +387,7 @@ BEGIN
END IF;
CALL p_shop_calc_user(
v_guid
a_guid
, a_id_user
, FALSE -- get inactive users
, v_id_permission_supplier
@@ -397,7 +400,7 @@ BEGIN
SELECT * from partsltd_prod.Shop_Calc_User_Temp WHERE GUID = a_guid;
END IF;
IF NOT EXISTS (SELECT can_view FROM partsltd_prod.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 = a_guid) THEN
DELETE FROM tmp_Msg_Error;
INSERT INTO tmp_Msg_Error (
@@ -413,7 +416,10 @@ BEGIN
;
END IF;
CALL partsltd_prod.p_shop_clear_calc_user( a_guid );
CALL partsltd_prod.p_shop_clear_calc_user(
a_guid
, 0 -- a_debug
);
IF EXISTS ( SELECT * FROM tmp_Msg_Error LIMIT 1 ) THEN
DELETE FROM tmp_Supplier;
@@ -437,7 +443,7 @@ BEGIN
SET v_id_change_set := LAST_INSERT_ID();
INSERT INTO partsltd_prod.Shop_Supplier (
id_address
id_supplier_temp
, id_currency
, name_company
, name_contact
@@ -450,7 +456,7 @@ BEGIN
, id_change_set
)
SELECT
t_S.id_address
t_S.id_supplier
, t_S.id_currency
, t_S.name_company
, t_S.name_contact
@@ -460,18 +466,31 @@ BEGIN
, t_S.email
, t_S.website
, t_S.active
v_id_change_set
, v_id_change_set
FROM tmp_Supplier t_S
WHERE t_S.is_new = 1
;
UPDATE tmp_Supplier t_S
INNER JOIN partsltd_prod.Shop_Supplier S ON t_S.id_supplier_temp = S.id_supplier_temp
SET
t_S.id_supplier = S.id_supplier
WHERE t_S.is_new = 1
;
UPDATE tmp_Supplier_Address t_SA
INNER JOIN tmp_Supplier t_S ON t_SA.id_supplier = t_S.id_supplier_temp
SET
t_SA.id_supplier = t_S.id_supplier
WHERE t_S.is_new = 1
;
UPDATE partsltd_prod.Shop_Supplier S
INNER JOIN tmp_Supplier t_S
ON S.id_supplier = t_S.id_supplier
AND t_S.is_new = 0
SET
S.id_address = t_S.id_address
, S.id_currency = t_S.id_currency
S.id_currency = t_S.id_currency
, S.name_company = t_S.name_company
, S.name_contact = t_S.name_contact
, S.department_contact = t_S.department_contact
@@ -497,8 +516,7 @@ BEGIN
;
INSERT INTO partsltd_prod.Shop_Supplier_Address (
id_address
, id_supplier
id_supplier
, id_region
, postcode
, address_line_1
@@ -506,10 +524,10 @@ BEGIN
, city
, county
, active
, id_change_set
)
SELECT
t_SA.id_address
, t_SA.id_supplier
t_SA.id_supplier
, t_SA.id_region
, t_SA.postcode
, t_SA.address_line_1
@@ -517,6 +535,7 @@ BEGIN
, t_SA.city
, t_SA.county
, t_SA.active
, v_id_change_set
FROM tmp_Supplier_Address t_SA
WHERE t_SA.is_new = 1
;
@@ -526,8 +545,7 @@ BEGIN
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_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
@@ -535,6 +553,7 @@ BEGIN
, SA.city = t_SA.city
, SA.county = t_SA.county
, SA.active = t_SA.active
, SA.id_change_set = v_id_change_set
;
COMMIT;
END IF;
@@ -546,11 +565,14 @@ BEGIN
;
IF a_debug = 1 THEN
SELECT 'A_DEBUG';
SELECT * from tmp_Supplier;
SELECT * from tmp_Supplier_Address;
END IF;
DROP TEMPORARY TABLE tmp_Supplier;
DROP TEMPORARY TABLE tmp_Msg_Error;
DROP TEMPORARY TABLE IF EXISTS tmp_Supplier;
DROP TEMPORARY TABLE IF EXISTS tmp_Supplier_Address;
DROP TEMPORARY TABLE IF EXISTS tmp_Msg_Error;
IF a_debug = 1 THEN
CALL partsltd_prod.p_debug_timing_reporting ( v_time_start );
@@ -561,3 +583,7 @@ DELIMITER ;;
-- SELECT * FROM Shop_Supplier;
delete from shop_supplier_audit where id_supplier = 9;
delete from shop_supplier where id_supplier = 9;
delete from shop_supplier_address_audit where id_address = -4;
delete from shop_supplier_address where id_address = -4;

View File

@@ -0,0 +1,131 @@
-- Clear previous proc
DROP PROCEDURE IF EXISTS partsltd_prod.p_shop_save_supplier_test;
DELIMITER //
CREATE PROCEDURE p_shop_save_supplier_test ()
BEGIN
DECLARE v_guid BINARY(36);
DECLARE v_time_start TIMESTAMP(6);
SET v_time_start := CURRENT_TIMESTAMP(6);
SET v_guid := 'nips';
SELECT *
FROM partsltd_prod.Shop_Supplier
;
SELECT *
FROM partsltd_prod.Shop_Supplier_Temp
;
SELECT *
FROM partsltd_prod.Shop_Supplier_Address
;
SELECT *
FROM partsltd_prod.Shop_Supplier_Address_Temp
;
START TRANSACTION;
INSERT INTO partsltd_prod.Shop_Supplier_Temp (
id_supplier
, id_currency
, name_company
, name_contact
, department_contact
, phone_number
, fax
, email
, website
, active
, guid
)
VALUES (
-3
, 1
, 'Asda'
, ''
, NULL
, ''
, '123'
, 'test mail'
, 'test url'
, 1 -- active
, v_guid
);
INSERT INTO partsltd_prod.Shop_Supplier_Address_Temp (
id_address
, id_supplier
, id_region
, postcode
, address_line_1
, address_line_2
, city
, county
, active
, GUID
)
VALUES (
-4
, -3
, 1
, 'test postcode'
, 'test'
, 'test'
, 'test'
, 'cunty'
, 1
, v_guid
)
;
COMMIT;
SELECT *
FROM partsltd_prod.Shop_Supplier_Temp
WHERE GUID = v_guid
;
SELECT *
FROM partsltd_prod.Shop_Supplier_Address_Temp
WHERE GUID = v_guid
;
CALL partsltd_prod.p_shop_save_supplier (
'Test save Supplier' -- comment
, v_guid -- guid
, 1 -- id_user
, 1 -- debug
);
SELECT *
FROM partsltd_prod.Shop_Supplier_Temp
;
SELECT *
FROM partsltd_prod.Shop_Supplier_Address_Temp
;
SELECT *
FROM partsltd_prod.Shop_Supplier
;
SELECT *
FROM partsltd_prod.Shop_Supplier_Address
;
CALL partsltd_prod.p_debug_timing_reporting ( v_time_start );
END //
DELIMITER ;;
CALL partsltd_prod.p_shop_save_supplier_test ();
DELETE FROM partsltd_prod.Shop_Supplier_Temp;
DELETE FROM partsltd_prod.Shop_Supplier_Address_Temp;
DROP TABLE IF EXISTS tmp_Msg_Error;
/*
Cannot add or update a child row: a foreign key constraint fails (`partsltd_prod`.`shop_supplier_address`, CONSTRAINT `FK_Shop_Supplier_Address_id_supplier` FOREIGN KEY (`id_supplier`) REFERENCES `shop_supplier` (`id_supplier`) ON UPDATE RESTRICT)
*/

View File

@@ -196,8 +196,8 @@ BEGIN
SELECT
t_S.id_supplier,
S.id_currency,
C.symbol AS symbol_currency,
C.code AS code_currency,
C.symbol AS symbol_currency,
S.name_company,
S.name_contact,
S.department_contact,

View File

@@ -0,0 +1,843 @@
-- Clear previous proc
DROP PROCEDURE IF EXISTS p_shop_save_supplier_purchase_order;
DROP TABLE IF EXISTS tmp_Supplier_Purchase_Order_Product_Link;
DROP TABLE IF EXISTS tmp_Msg_Error;
DELIMITER //
CREATE PROCEDURE p_shop_save_supplier_purchase_order (
IN a_comment VARCHAR(500)
, IN a_guid BINARY(36)
, IN a_id_user INT
, IN a_debug BIT
)
BEGIN
DECLARE v_code_type_error_bad_data VARCHAR(50);
DECLARE v_code_type_error_no_permission VARCHAR(50);
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 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;
DECLARE v_ids_product_permission TEXT;
DECLARE v_time_start TIMESTAMP(6);
DECLARE exit handler for SQLEXCEPTION
BEGIN
GET DIAGNOSTICS CONDITION 1
@sqlstate = RETURNED_SQLSTATE
, @errno = MYSQL_ERRNO
, @text = MESSAGE_TEXT
;
ROLLBACK;
CREATE TEMPORARY TABLE IF NOT EXISTS tmp_Msg_Error (
display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT
, id_type INT NULL
, code VARCHAR(50) NOT NULL
, msg VARCHAR(4000) NOT NULL
);
INSERT INTO tmp_Msg_Error (
id_type
, code
, msg
)
SELECT
MET.id_type
, @errno
, @text
FROM partsltd_prod.Shop_Msg_Error_Type MET
WHERE code = 'MYSQL_ERROR'
;
SELECT *
FROM tmp_Msg_Error;
DROP TABLE IF EXISTS tmp_Msg_Error;
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' 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_code_type_error_warning := (SELECT code FROM partsltd_prod.Shop_Msg_Error_Type WHERE code = 'WARNING' LIMIT 1);
SET v_id_type_error_warning := (SELECT id_type FROM partsltd_prod.Shop_Msg_Error_Type WHERE code = v_code_type_error_warning LIMIT 1);
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'));
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, ''));
DROP TEMPORARY TABLE IF EXISTS tmp_Supplier_Purchase_Order;
DROP TEMPORARY TABLE IF EXISTS tmp_Supplier_Purchase_Order_Product_Link;
DROP TEMPORARY TABLE IF EXISTS tmp_Msg_Error;
-- Temporary tables
CREATE TEMPORARY TABLE tmp_Supplier_Purchase_Order (
id_order INT NOT NULL PRIMARY KEY
, id_order_temp INT NOT NULL
, id_supplier_ordered INT NOT NULL
, id_currency_cost INT NOT NULL
, cost_total_local_VAT_excl FLOAT NULL
, cost_total_local_VAT_incl FLOAT NULL
, active BIT NOT NULL
, is_new BIT NOT NULL
, name_error VARCHAR(1000) 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
, quantity_ordered FLOAT NOT NULL
, id_unit_quantity INT NOT NULL
, quantity_received FLOAT NULL
, latency_delivery_days INT NOT NULL
, display_order INT NOT NULL
, active BIT NOT NULL
, cost_total_local_VAT_excl FLOAT NOT NULL
, cost_total_local_VAT_incl FLOAT NOT NULL
, cost_unit_local_VAT_excl FLOAT NOT NULL
, cost_unit_local_VAT_incl FLOAT NOT NULL
, has_order BIT NULL
, is_new BIT NOT NULL
, name_error VARCHAR(1000) NULL
);
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
);
INSERT INTO tmp_Supplier_Purchase_Order (
id_order
, id_order_temp
, id_supplier_ordered
, id_currency_cost
, active
, is_new
, name_error
)
SELECT
SPO_T.id_order
, SPO_T.id_order
, IFNULL(IFNULL(SPO_T.id_supplier_ordered, SPO.id_supplier_ordered), 0) AS id_supplier_ordered
, IFNULL(IFNULL(SPO_T.id_currency_cost, SPO.id_currency_cost), 0) AS id_currency_cost
, IFNULL(IFNULL(SPO_T.active, SPO.active), 1) AS active
, ISNULL(SPO.id_order) AS is_new
, CONCAT(
IFNULL(S.name_company, '(No Supplier)')
, ' - '
, IFNULL(SPO.created_on, '(No creation date)')
, ' - '
, IFNULL(C.symbol, '(No Currency)')
, ' '
, IFNULL(IFNULL(SPO.cost_total_local_vat_excl, SPO.cost_total_local_vat_incl), '(No cost)')
) AS name_error
FROM partsltd_prod.Shop_Supplier_Purchase_Order_Temp SPO_T
LEFT JOIN partsltd_prod.Shop_Supplier_Purchase_Order SPO ON SPO_T.id_order = SPO.id_order
LEFT JOIN partsltd_prod.Shop_Supplier S ON SPO_T.id_supplier_ordered = S.id_supplier
LEFT JOIN partsltd_prod.Shop_Currency C ON SPO_T.id_currency_cost = C.id_currency
WHERE SPO_T.GUID = a_guid
;
INSERT INTO tmp_Supplier_Purchase_Order_Product_Link (
id_link
, id_order
, id_permutation
-- , id_currency_cost
, id_unit_quantity
, quantity_ordered
, quantity_received
, latency_delivery_days
, display_order
, cost_total_local_VAT_excl
, cost_total_local_VAT_incl
, cost_unit_local_VAT_excl
, cost_unit_local_VAT_incl
, active
, has_order
, is_new
)
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(
IFNULL(
SPOPL_T.id_permutation
, CASE WHEN NOT ISNULL(SPOPL_T.id_product) AND NOT ISNULL(SPOPL_T.csv_list_variations) THEN
partsltd_prod.fn_shop_get_id_product_permutation_from_variation_csv_list(SPOPL_T.id_product, SPOPL_T.csv_list_variations)
ELSE NULL END
)
, 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.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
, IFNULL(IFNULL(SPOPL_T.cost_total_local_VAT_excl, SPOPL.cost_total_local_VAT_excl), 0) AS cost_total_local_VAT_excl
, IFNULL(IFNULL(SPOPL_T.cost_total_local_VAT_incl, SPOPL.cost_total_local_VAT_incl), 0) AS cost_total_local_VAT_incl
, IFNULL(SPOPL_T.cost_total_local_VAT_excl / SPOPL_T.quantity_ordered, SPOPL.cost_unit_local_VAT_excl) AS cost_unit_local_VAT_excl
, IFNULL(SPOPL_T.cost_total_local_VAT_incl / SPOPL_T.quantity_ordered, SPOPL.cost_unit_local_VAT_incl) AS cost_unit_local_VAT_incl
, IFNULL(IFNULL(SPOPL_T.active, SPOPL.active), 1) AS active
, NOT ISNULL(t_SPO.id_order) AS has_order
, IFNULL(SPOPL_T.id_link, 0) < 1 AS is_new
FROM partsltd_prod.Shop_Supplier_Purchase_Order_Product_Link_Temp SPOPL_T
LEFT JOIN partsltd_prod.Shop_Supplier_Purchase_Order_Product_Link SPOPL ON SPOPL_T.id_link = SPOPL.id_link
LEFT JOIN tmp_Supplier_Purchase_Order t_SPO ON SPOPL_T.id_order = t_SPO.id_order
WHERE SPOPL_T.GUID = a_guid
;
UPDATE tmp_Supplier_Purchase_Order_Product_Link t_SPOPL
INNER JOIN partsltd_prod.Shop_Supplier_Purchase_Order_Product_Link_Temp SPOPL_T ON t_SPOPL.id_order = SPOPL_T.id_order
LEFT JOIN partsltd_prod.Shop_Product P ON SPOPL_T.id_product = P.id_product
LEFT JOIN partsltd_prod.Shop_Product_Category PC ON P.id_category = PC.id_category
SET
name_error = CONCAT(
CASE WHEN ISNULL(t_SPOPL.id_permutation) THEN
CASE WHEN ISNULL(SPOPL_T.id_product) THEN
'(No Product Permutation)'
ELSE
CONCAT(
PC.name
, ' - '
, P.name
)
END
ELSE
fn_shop_get_product_permutation_name(t_SPOPL.id_permutation)
END
, ' - x'
, IFNULL(t_SPOPL.quantity_ordered, '(No Quantity)')
)
;
INSERT INTO tmp_Supplier_Purchase_Order (
id_order
, id_order_temp
, id_supplier_ordered
, id_currency_cost
, active
, is_new
)
SELECT
SPO.id_order
, SPO.id_order
, IFNULL(SPO.id_supplier_ordered, 0) AS id_supplier_ordered
, IFNULL(SPO.id_currency_cost, 0) AS id_currency_cost
, SPO.active AS active
, 0 AS is_new
FROM partsltd_prod.Shop_Supplier_Purchase_Order SPO
INNER JOIN tmp_Supplier_Purchase_Order_Product_Link t_SPOPL
ON SPO.id_order = t_SPOPL.id_order
AND t_SPOPL.has_order = 0
;
UPDATE tmp_Supplier_Purchase_Order t_SPO
INNER JOIN (
SELECT
t_SPOPL.id_order
, SUM(t_SPOPL.cost_total_local_VAT_excl) AS cost_total_local_VAT_excl
, SUM(t_SPOPL.cost_total_local_VAT_incl) AS cost_total_local_VAT_incl
FROM tmp_Supplier_Purchase_Order_Product_Link t_SPOPL
GROUP BY t_SPOPL.id_order
) SUM_t_SPOPL ON t_SPO.id_order = SUM_t_SPOPL.id_order
SET
t_SPO.cost_total_local_VAT_excl = SUM_t_SPOPL.cost_total_local_VAT_excl
, t_SPO.cost_total_local_VAT_incl = SUM_t_SPOPL.cost_total_local_VAT_incl
;
-- Validation
-- Supplier Purchase Order
# id_order
IF EXISTS (
SELECT *
FROM tmp_Supplier_Purchase_Order t_SPO
LEFT JOIN partsltd_prod.Shop_Supplier_Purchase_Order SPO ON t_SPO.id_order = SPO.id_order
WHERE 1=1
AND t_SPO.id_order > 0
AND ISNULL(SPO.id_order)
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(
'A valid ID is required for the following Supplier Purchase Order(s): '
, GROUP_CONCAT(CONCAT(IFNULL(t_SPO.id_stock, '(No Supplier Purchase Order)')) SEPARATOR ', ')
) AS msg
FROM tmp_Stock_Item t_SPO
LEFT JOIN partsltd_prod.Shop_Supplier_Purchase_Order SPO ON t_SPO.id_order = SPO.id_order
WHERE 1=1
AND t_SPO.id_stock > 0
AND ISNULL(SPO.id_stock)
;
END IF;
# id_supplier_ordered
IF EXISTS (
SELECT *
FROM tmp_Supplier_Purchase_Order t_SPO
LEFT JOIN partsltd_prod.Shop_Supplier S ON t_SPO.id_supplier_ordered = S.id_supplier
WHERE 1=1
AND (
ISNULL(S.id_supplier)
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(
'A valid supplier is required for the following Supplier Purchase Order(s): '
, GROUP_CONCAT(CONCAT(IFNULL(t_SPO.id_stock, '(No Supplier Purchase Order)'), ' - ', t_SPO.id_supplier_ordered) SEPARATOR ', ')
) AS msg
FROM tmp_Stock_Item t_SPO
LEFT JOIN partsltd_prod.Shop_Supplier S ON t_SPO.id_supplier_ordered = S.id_supplier
WHERE 1=1
AND (
ISNULL(S.id_supplier)
OR S.active = 0
)
;
END IF;
# id_currency_cost
IF EXISTS (
SELECT *
FROM tmp_Supplier_Purchase_Order t_SPO
LEFT JOIN partsltd_prod.Shop_Currency C ON t_SPO.id_currency_cost = C.id_currency
WHERE 1=1
AND (
ISNULL(C.id_currency)
OR C.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(
'A valid currency 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_Currency C ON t_SPO.id_currency_cost = C.id_currency
WHERE 1=1
AND (
ISNULL(C.id_currency)
OR C.active = 0
)
;
END IF;
# id_unit_quantity
IF EXISTS (
SELECT *
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)
OR UM.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(
'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_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)
OR UM.active = 0
)
;
END IF;
# Invalid quantity ordered
IF EXISTS (
SELECT *
FROM tmp_Supplier_Purchase_Order_Product_Link t_SPOPL
WHERE
ISNULL(t_SPOPL.quantity_ordered)
OR t_SPOPL.quantity_ordered <= 0
) THEN
INSERT INTO tmp_Msg_Error (
id_type, code, msg
)
SELECT
v_id_error_type_bad_data,
v_code_error_type_bad_data,
CONCAT(
'A valid quantity ordered is required for the following Supplier Purchase Order Item(s): '
, GROUP_CONCAT(t_SPOPL.name_error SEPARATOR ', ')
)
FROM tmp_Supplier_Purchase_Order_Product_Link t_SPOPL
WHERE
ISNULL(t_SPOPL.quantity_ordered)
OR t_SPOPL.quantity_ordered <= 0
;
END IF;
# Invalid quantity received
IF EXISTS (
SELECT *
FROM tmp_Supplier_Purchase_Order_Product_Link t_SPOPL
WHERE t_SPOPL.quantity_received < 0
) THEN
INSERT INTO tmp_Msg_Error (
id_type, code, msg
)
SELECT
v_id_error_type_bad_data,
v_code_error_type_bad_data,
CONCAT(
'A valid quantity received is required for the following Supplier Purchase Order Item(s): '
, GROUP_CONCAT(t_SPOPL.name_error, ' - ', t_SPOPL.quantity_received SEPARATOR ', ')
)
FROM tmp_Supplier_Purchase_Order_Product_Link t_SPOPL
WHERE t_SPOPL.quantity_received < 0
;
END IF;
# Invalid delivery latency
IF EXISTS (
SELECT *
FROM tmp_Supplier_Purchase_Order_Product_Link t_SPOPL
WHERE t_SPOPL.latency_delivery_days < 0
) THEN
INSERT INTO tmp_Msg_Error (
id_type, code, msg
)
SELECT
v_id_error_type_bad_data,
v_code_error_type_bad_data,
CONCAT(
'A valid delivery latency is required for the following Supplier Purchase Order Item(s): '
, GROUP_CONCAT(t_SPOPL.name_error, ' - ', t_SPOPL.latency_delivery_days SEPARATOR ', ')
)
FROM tmp_Supplier_Purchase_Order_Product_Link t_SPOPL
WHERE t_SPOPL.latency_delivery_days < 0
;
END IF;
-- Duplicates
IF EXISTS (
SELECT
id_permutation
, name_error
, COUNT(*)
FROM tmp_Supplier_Purchase_Order_Product_Link t_SPOPL
GROUP BY id_permutation, name_error
HAVING COUNT(*) > 1
) THEN
INSERT INTO tmp_Msg_Error (
id_type, code, msg
)
SELECT
v_id_error_type_bad_data,
v_code_error_type_bad_data,
CONCAT('Duplicate records: ', GROUP_CONCAT(t_SPOPLC.name_error SEPARATOR ', '))
FROM (
SELECT
id_permutation
, name_error
, COUNT(*)
FROM tmp_Supplier_Purchase_Order_Product_Link t_SPOPL
GROUP BY id_permutation, name_error
HAVING COUNT(*) > 1
) t_SPOPLC
;
END IF;
-- Empty Supplier Purchase Order
IF EXISTS ( SELECT * FROM tmp_Supplier_Purchase_Order t_SPO LEFT JOIN tmp_Supplier_Purchase_Order_Product_Link t_SPOPL ON t_SPO.id_order = t_SPOPL.id_order WHERE ISNULL(t_SPOPL.id_order) ) THEN
INSERT INTO tmp_Msg_Error (
id_type, code, msg
)
SELECT
v_id_error_type_bad_data,
v_code_error_type_bad_data,
CONCAT(
'There are no items in the following Supplier Purchase Order(s): '
, GROUP_CONCAT(t_SPO.name_error SEPARATOR ', ')
) AS msg
FROM tmp_Supplier_Purchase_Order t_SPO
LEFT JOIN tmp_Supplier_Purchase_Order_Product_Link t_SPOPL ON t_SPO.id_order = t_SPOPL.id_order
WHERE ISNULL(t_SPOPL.id_order)
;
END IF;
-- Supplier Purchase Order Items without Order
IF EXISTS (
SELECT *
FROM tmp_Supplier_Purchase_Order_Product_Link t_SPOPL
LEFT JOIN tmp_Supplier_Purchase_Order t_SPO ON t_SPOPL.id_order = t_SPO.id_order
WHERE ISNULL(t_SPO.id_order)
) THEN
INSERT INTO tmp_Msg_Error (
id_type, code, msg
)
SELECT
v_id_error_type_bad_data,
v_code_error_type_bad_data,
CONCAT(
'There is no order for the following Supplier Purchase Order Item(s): '
, GROUP_CONCAT(t_SPOPL.name_error SEPARATOR ', ')
) AS msg
FROM tmp_Supplier_Purchase_Order_Product_Link t_SPOPL
LEFT JOIN tmp_Supplier_Purchase_Order t_SPO ON t_SPOPL.id_order = t_SPO.id_order
WHERE ISNULL(t_SPO.id_order)
;
END IF;
-- Permissions
SET v_ids_product_permission := (
SELECT
GROUP_CONCAT(DISTINCT PP.id_product SEPARATOR ',')
FROM tmp_Supplier_Purchase_Order_Product_Link t_SPOPL
INNER JOIN partsltd_prod.Shop_Product_Permutation PP ON t_SPOPL.id_permutation = PP.id_permutation
);
IF a_debug = 1 THEN
SELECT
a_guid
, a_id_user
, FALSE -- get inactive users
, v_id_permission_supplier_purchase_order
, v_id_access_level_edit
, v_ids_product_permission -- ids_product
, 0 -- a_debug
;
SELECT * from partsltd_prod.Shop_Calc_User_Temp;
END IF;
CALL p_shop_calc_user(
a_guid
, a_id_user
, FALSE -- get inactive users
, v_id_permission_supplier_purchase_order
, v_id_access_level_edit
, v_ids_product_permission -- ids_product
, 0 -- a_debug
);
IF a_debug = 1 THEN
SELECT * from partsltd_prod.Shop_Calc_User_Temp WHERE GUID = a_guid;
END IF;
IF NOT EXISTS (SELECT can_view FROM partsltd_prod.Shop_Calc_User_Temp UE_T WHERE UE_T.GUID = a_guid) THEN
DELETE FROM tmp_Msg_Error;
INSERT INTO tmp_Msg_Error (
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 partsltd_prod.Shop_Permission WHERE id_permission = v_id_permission_supplier LIMIT 1))
)
;
END IF;
CALL partsltd_prod.p_shop_clear_calc_user(
a_guid
, 0 -- a_debug
);
IF EXISTS (
SELECT *
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 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
) 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;
IF EXISTS ( SELECT * FROM tmp_Msg_Error LIMIT 1 ) THEN
DELETE FROM tmp_Supplier_Purchase_Order;
DELETE FROM tmp_Supplier_Purchase_Order_Product_Link;
END IF;
-- Transaction
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error) THEN
START TRANSACTION;
INSERT INTO Shop_Sales_And_Purchasing_Change_Set (
comment
, updated_last_by
, updated_last_on
)
VALUES (
a_comment
, a_id_user
, v_time_start
);
SET v_id_change_set := LAST_INSERT_ID();
INSERT INTO partsltd_prod.Shop_Supplier_Purchase_Order (
id_order_temp
, id_supplier_ordered
, id_currency_cost
, cost_total_local_VAT_excl
, cost_total_local_VAT_incl
, active
, created_by
, created_on
, id_change_set
)
SELECT
t_SPO.id_order_temp
, t_SPO.id_supplier_ordered
, t_SPO.id_currency_cost
, t_SPO.cost_total_local_VAT_excl
, t_SPO.cost_total_local_VAT_incl
, t_SPO.active
, a_id_user
, v_time_start
, v_id_change_set
FROM tmp_Supplier_Purchase_Order t_SPO
INNER JOIN tmp_Supplier_Purchase_Order_Product_Link t_SPOPL ON t_SPO.id_order = t_SPOPL.id_order
WHERE t_SPOPL.is_new = 1
GROUP BY t_SPO.id_order
;
UPDATE partsltd_prod.Shop_Supplier_Purchase_Order SPO
INNER JOIN tmp_Supplier_Purchase_Order t_SPO
ON SPO.id_order = t_SPO.id_order
AND t_SPO.is_new = 0
INNER JOIN tmp_Supplier_Purchase_Order_Product_Link t_SPOPL ON t_SPO.id_order = t_SPOPL.id_order
SET
SPO.id_supplier_ordered = t_SPO.id_supplier_ordered
, SPO.id_currency_cost = t_SPO.id_currency_cost
, SPO.cost_total_local_VAT_excl = t_SPO.cost_total_local_VAT_excl
, SPO.cost_total_local_VAT_incl = t_SPO.cost_total_local_VAT_incl
, SPO.active = t_SPO.active
, SPO.id_change_set = v_id_change_set
;
UPDATE tmp_Supplier_Purchase_Order t_SPO
INNER JOIN partsltd_prod.Shop_Supplier_Purchase_Order SPO ON t_SPO.id_order_temp = SPO.id_order_temp
SET
t_SPO.id_order = SPO.id_order
WHERE t_SPO.is_new = 1
;
UPDATE tmp_Supplier_Purchase_Order_Product_Link t_SPOPL
INNER JOIN tmp_Supplier_Purchase_Order t_SPO ON t_SPOPL.id_order = t_SPO.id_order_temp
SET
t_SPOPL.id_order = t_SPO.id_order
WHERE t_SPO.is_new = 1
;
INSERT INTO Shop_Supplier_Purchase_Order_Product_Link (
id_order
, id_permutation
, id_unit_quantity
, quantity_ordered
, quantity_received
, latency_delivery_days
, display_order
, active
, cost_total_local_VAT_excl
, cost_total_local_VAT_incl
, cost_unit_local_VAT_excl
, cost_unit_local_VAT_incl
, created_by
, created_on
, id_change_set
)
SELECT
t_SPOPL.id_order
, t_SPOPL.id_permutation
, t_SPOPL.id_unit_quantity
, t_SPOPL.quantity_ordered
, t_SPOPL.quantity_received
, t_SPOPL.latency_delivery_days
, t_SPOPL.display_order
, t_SPOPL.active
, t_SPOPL.cost_total_local_VAT_excl
, t_SPOPL.cost_total_local_VAT_incl
, t_SPOPL.cost_unit_local_VAT_excl
, t_SPOPL.cost_unit_local_VAT_incl
, a_id_user
, v_time_start
, v_id_change_set
FROM tmp_Supplier_Purchase_Order_Product_Link t_SPOPL
WHERE t_SPOPL.is_new = 1
;
UPDATE partsltd_prod.Shop_Supplier_Purchase_Order_Product_Link SPOPL
INNER JOIN tmp_Supplier_Purchase_Order_Product_Link t_SPOPL
ON SPOPL.id_link = t_SPOPL.id_link
AND t_SPOPL.is_new = 0
SET
SPOPL.id_order = t_SPOPL.id_order
, SPOPL.id_permutation = t_SPOPL.id_permutation
, SPOPL.id_unit_quantity = t_SPOPL.id_unit_quantity
, SPOPL.quantity_ordered = t_SPOPL.quantity_ordered
, SPOPL.quantity_received = t_SPOPL.quantity_received
, SPOPL.latency_delivery_days = t_SPOPL.latency_delivery_days
, SPOPL.display_order = t_SPOPL.display_order
, SPOPL.active = t_SPOPL.active
, SPOPL.cost_total_local_VAT_excl = t_SPOPL.cost_total_local_VAT_excl
, SPOPL.cost_total_local_VAT_incl = t_SPOPL.cost_total_local_VAT_incl
, SPOPL.cost_unit_local_VAT_excl = t_SPOPL.cost_unit_local_VAT_excl
, SPOPL.cost_unit_local_VAT_incl = t_SPOPL.cost_unit_local_VAT_incl
, SPOPL.id_change_set = v_id_change_set
;
DELETE SPO_T
FROM Shop_Supplier_Purchase_Order_Temp SPO_T
WHERE SPO_T.GUID = a_guid
;
DELETE SPOPL_T
FROM Shop_Supplier_Purchase_Order_Product_Link_Temp SPOPL_T
WHERE SPOPL_T.GUID = a_guid
;
COMMIT;
END IF;
# Errors
SELECT *
FROM tmp_Msg_Error t_ME
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_Supplier_Purchase_Order;
SELECT * from tmp_Supplier_Purchase_Order_Product_Link;
END IF;
DROP TEMPORARY TABLE tmp_Supplier_Purchase_Order;
DROP TEMPORARY TABLE tmp_Supplier_Purchase_Order_Product_Link;
DROP TEMPORARY TABLE tmp_Msg_Error;
IF a_debug = 1 THEN
CALL partsltd_prod.p_debug_timing_reporting ( v_time_start );
END IF;
END //
DELIMITER ;;
/*
DELETE FROM Shop_Supplier_Purchase_Order_Product_Link_Audit;
DELETE FROM Shop_Supplier_Purchase_Order_Product_Link;
DELETE FROM Shop_Supplier_Purchase_Order_Product_Link_Temp;
DELETE FROM Shop_Supplier_Purchase_Order_Audit;
DELETE FROM Shop_Supplier_Purchase_Order;
INSERT INTO Shop_Supplier_Purchase_Order_Product_Link_Temp (
guid,
id_link,
id_order,
id_permutation,
cost_total_local,
id_currency_cost,
quantity_ordered,
id_unit_quantity,
quantity_received,
latency_delivery_days,
display_order,
active
)
VALUES
(
'NIPS', # guid
-1, # id_link,
-1, # id_order,
1, # id_permutation,
100, # cost_total_local,
1, # id_currency_cost,
1, # quantity_ordered,
1, # id_unit_quantity,
1, # quantity_received,
14, # latency_delivery_days ,
1, # display_order
1 # active
)
;
SELECT * FROM Shop_Supplier_Purchase_Order_Product_Link_Temp;
CALL p_shop_save_supplier_purchase_order (
'NIPS', # a_guid
'auth0|6582b95c895d09a70ba10fef', # a_id_user
-1, # a_id_order
1, # a_id_supplier_ordered
1 # a_id_currency_cost
);
SELECT * FROM Shop_Supplier_Purchase_Order_Product_Link_Temp;
DELETE FROM Shop_Supplier_Purchase_Order_Product_Link_Audit;
DELETE FROM Shop_Supplier_Purchase_Order_Product_Link;
DELETE FROM Shop_Supplier_Purchase_Order_Product_Link_Temp;
DELETE FROM Shop_Supplier_Purchase_Order_Audit;
DELETE FROM Shop_Supplier_Purchase_Order;
*/

View File

@@ -0,0 +1,127 @@
-- Clear previous proc
DROP PROCEDURE IF EXISTS partsltd_prod.p_shop_save_supplier_purchase_order_test;
DELIMITER //
CREATE PROCEDURE p_shop_save_supplier_purchase_order_test ()
BEGIN
DECLARE v_guid BINARY(36);
DECLARE v_time_start TIMESTAMP(6);
SET v_time_start := CURRENT_TIMESTAMP(6);
SET v_guid := 'nips';
SELECT *
FROM partsltd_prod.Shop_Supplier_Purchase_Order
;
SELECT *
FROM partsltd_prod.Shop_Supplier_Purchase_Order_Temp
;
SELECT *
FROM partsltd_prod.Shop_Supplier_Purchase_Order_Product_Link
;
SELECT *
FROM partsltd_prod.Shop_Supplier_Purchase_Order_Product_Link_Temp
;
START TRANSACTION;
DELETE FROM partsltd_prod.Shop_Supplier_Purchase_Order_Temp;
DELETE FROM partsltd_prod.Shop_Supplier_Purchase_Order_Product_Link_Temp;
INSERT INTO partsltd_prod.Shop_Supplier_Purchase_Order_Temp (
id_order
, id_supplier_ordered
, id_currency_cost
, active
, GUID
)
VALUES (
-1
, 1
, 1
, 1
, v_guid
)
;
INSERT INTO partsltd_prod.Shop_Supplier_Purchase_Order_Product_Link_Temp (
id_link
, id_order
, id_permutation
, id_unit_quantity
, quantity_ordered
, quantity_received
, latency_delivery_days
, display_order
, active
, cost_total_local_VAT_excl
, cost_total_local_VAT_incl
, GUID
)
VALUES (
-1
, -1
, 3
, 3
, 3
, 1
, 7
, 1
, 1
, 5
, 6
, v_guid
)
;
COMMIT;
SELECT *
FROM partsltd_prod.Shop_Supplier_Purchase_Order_Temp
WHERE GUID = v_guid
;
SELECT *
FROM partsltd_prod.Shop_Supplier_Purchase_Order_Product_Link_Temp
WHERE GUID = v_guid
;
CALL partsltd_prod.p_shop_save_supplier_purchase_order (
'Test save Supplier Purchase Order' -- comment
, v_guid -- guid
, 1 -- id_user
, 1 -- debug
);
SELECT *
FROM partsltd_prod.Shop_Supplier_Purchase_Order_Temp
;
SELECT *
FROM partsltd_prod.Shop_Supplier_Purchase_Order_Product_Link_Temp
;
SELECT *
FROM partsltd_prod.Shop_Supplier_Purchase_Order
;
SELECT *
FROM partsltd_prod.Shop_Supplier_Purchase_Order_Product_Link
;
CALL partsltd_prod.p_debug_timing_reporting ( v_time_start );
END //
DELIMITER ;;
CALL partsltd_prod.p_shop_save_supplier_purchase_order_test ();
DELETE FROM partsltd_prod.Shop_Supplier_Purchase_Order_Temp;
DELETE FROM partsltd_prod.Shop_Supplier_Purchase_Order_Product_Link_Temp;
DROP TABLE IF EXISTS tmp_Msg_Error;
/*
Cannot add or update a child row: a foreign key constraint fails (`partsltd_prod`.`shop_supplier_address`, CONSTRAINT `FK_Shop_Supplier_Address_id_supplier` FOREIGN KEY (`id_supplier`) REFERENCES `shop_supplier` (`id_supplier`) ON UPDATE RESTRICT)
*/

View File

@@ -379,13 +379,13 @@ 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_ids_permission_supplier_purchase_order LIMIT 1))
)
;
END IF;
IF EXISTS ( SELECT * FROM tmp_Msg_Error LIMIT 1 ) THEN
DELETE FROM tmp_Supplier_Purchase_Order_Product_Link;
DELETE FROM tmp_Permutation;
DELETE FROM tmp_Supplier_Purchase_Order;
END IF;
@@ -414,7 +414,10 @@ BEGIN
SELECT
t_SPO.id_order
, SPO.id_supplier_ordered
, S.name_company
, SPO.id_currency_cost
, C.symbol
, C.code
, SPO.cost_total_local_VAT_excl
, SPO.cost_total_local_VAT_incl
, SPO.active
@@ -426,12 +429,16 @@ BEGIN
) 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
LEFT JOIN partsltd_prod.Shop_Supplier S ON SPO.id_supplier_ordered = S.id_supplier
LEFT JOIN partsltd_prod.Shop_Currency C ON SPO.id_currency_cost = C.id_currency
;
# Supplier Purchase Order Product Link
SELECT
SPOPL.id_link
, SPOPL.id_order
, P.id_category
, P.id_product
, SPOPL.id_permutation
, fn_shop_get_product_permutation_name(SPOPL.id_permutation) AS name_permutation
-- , SPOPL.id_currency_cost
@@ -447,6 +454,8 @@ BEGIN
, 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
LEFT JOIN partsltd_prod.Shop_Product_Permutation PP ON SPOPL.id_permutation = PP.id_permutation
LEFT JOIN partsltd_prod.Shop_Product P ON PP.id_product = P.id_product
;
# Errors

View File

@@ -48,9 +48,11 @@ BEGIN
, msg
)
SELECT
NULL
MET.id_type
, @errno
, @text
FROM partsltd_prod.Shop_Msg_Error_Type MET
WHERE code = 'MYSQL_ERROR'
;
SELECT *
FROM tmp_Msg_Error;
@@ -68,13 +70,16 @@ BEGIN
CALL p_validate_guid ( a_guid );
SET a_comment := TRIM(IFNULL(a_comment, ''));
DROP TEMPORARY TABLE IF EXISTS tmp_Manufacturing;
DROP TEMPORARY TABLE IF EXISTS tmp_Manufacturing_Purchase_Order;
DROP TEMPORARY TABLE IF EXISTS tmp_Manufacturing_Purchase_Order_Product_Link;
DROP TEMPORARY TABLE IF EXISTS tmp_Msg_Error;
-- Temporary tables
CREATE TEMPORARY TABLE tmp_Manufacturing_Purchase_Order (
id_order INT NOT NULL PRIMARY KEY
, id_currency_cost INT NOT NULL
, is_new BIT NOT NULL
, name_error VARCHAR(1000) NOT NULL
);
CREATE TEMPORARY TABLE tmp_Manufacturing_Purchase_Order_Product_Link (
@@ -82,10 +87,11 @@ BEGIN
, id_order INT NOT NULL
, id_permutation INT NOT NULL
, id_currency_cost INT NOT NULL
, quantity_ordered FLOAT NOT NULL
, quantity_used FLOAT NOT NULL
, id_unit_quantity INT NOT NULL
, quantity_received FLOAT NULL
, latency_delivery_days INT NOT NULL
, quantity_produced FLOAT NULL
, id_unit_latency_manufacture INT NULL
, latency_manufacture INT NULL
, display_order INT NOT NULL
, active BIT NOT NULL
, name_error VARCHAR(200) NOT NULL
@@ -94,6 +100,8 @@ BEGIN
, cost_unit_local_VAT_excl FLOAT NOT NULL
, cost_unit_local_VAT_incl FLOAT NOT NULL
, has_order BIT NULL
, is_new BIT NOT NULL
, name_error VARCHAR(1000) NOT NULL
);
CREATE TEMPORARY TABLE IF NOT EXISTS tmp_Msg_Error (
@@ -120,10 +128,11 @@ BEGIN
, id_order
, id_permutation
, id_currency_cost
, quantity_ordered
, id_unit_quantity
, quantity_received
, latency_delivery_days
, quantity_used
, quantity_produced
, id_unit_latency_manufacture
, latency_manufacture
, display_order
, active
, name_error
@@ -139,22 +148,23 @@ BEGIN
, 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.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
, SPOPL_T.quantity_used AS quantity_used
, SPOPL_T.quantity_produced AS quantity_produced
, SPOPL_T.id_unit_latency_manufacture AS id_unit_latency_manufacture
, SPOPL_T.latency_manufacture AS latency_manufacture
, IFNULL(SPOPL_T.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)
, ' - x'
, IFNULL(SPOPL_T.quantity_ordered, '(No Quantity)')
, IFNULL(SPOPL_T.quantity_used, '(No Quantity)')
) AS name_error
, IFNULL(SPOPL_T.id_link, 0) < 1 AS is_new
, IFNULL(IFNULL(SPOPL_T.cost_total_local_VAT_excl, MPOPL.cost_total_local_VAT_excl), 0) AS cost_total_local_VAT_excl
, IFNULL(IFNULL(SPOPL_T.cost_total_local_VAT_incl, MPOPL.cost_total_local_VAT_incl), 0) AS cost_total_local_VAT_incl
, IFNULL(SPOPL_T.cost_total_local_VAT_excl / SPOPL_T.quantity_ordered, MPOPL.cost_unit_local_VAT_excl) AS cost_unit_local_VAT_excl
, IFNULL(SPOPL_T.cost_total_local_VAT_incl / SPOPL_T.quantity_ordered, MPOPL.cost_unit_local_VAT_incl) AS cost_unit_local_VAT_incl
, SPOPL_T.cost_total_local_VAT_excl AS cost_total_local_VAT_excl
, SPOPL_T.cost_total_local_VAT_incl AS cost_total_local_VAT_incl
, SPOPL_T.cost_total_local_VAT_excl / SPOPL_T.quantity_used AS cost_unit_local_VAT_excl
, SPOPL_T.cost_total_local_VAT_incl / SPOPL_T.quantity_used AS cost_unit_local_VAT_incl
, NOT ISNULL(t_MPO.id_order) AS has_order
FROM partsltd_prod.Shop_Manufacturing_Purchase_Order_Product_Link_Temp SPOPL_T
LEFT JOIN partsltd_prod.Shop_Manufacturing_Purchase_Order_Product_Link MPOPL ON SPOPL_T.id_link = MPOPL.id_link
@@ -277,8 +287,8 @@ BEGIN
SELECT *
FROM tmp_Manufacturing_Purchase_Order_Product_Link
WHERE
ISNULL(t_MPOPL.quantity_ordered)
OR t_MPOPL.quantity_ordered <= 0
ISNULL(t_MPOPL.quantity_used)
OR t_MPOPL.quantity_used <= 0
) THEN
INSERT INTO tmp_Msg_Error (
id_type, code, msg
@@ -292,15 +302,15 @@ BEGIN
)
FROM tmp_Manufacturing_Purchase_Order_Product_Link t_MPOPL
WHERE
ISNULL(t_MPOPL.quantity_ordered)
OR t_MPOPL.quantity_ordered <= 0
ISNULL(t_MPOPL.quantity_used)
OR t_MPOPL.quantity_used <= 0
;
END IF;
# Invalid quantity received
IF EXISTS (
SELECT *
FROM tmp_Manufacturing_Purchase_Order_Product_Link
WHERE t_MPOPL.quantity_received < 0
WHERE t_MPOPL.quantity_produced < 0
) THEN
INSERT INTO tmp_Msg_Error (
id_type, code, msg
@@ -310,17 +320,52 @@ BEGIN
v_code_error_type_bad_data,
CONCAT(
'A valid quantity received is required for the following Manufacturing Purchase Order Item(s): '
, GROUP_CONCAT(t_MPOPL.name_error, ' - ', t_MPOPL.quantity_received SEPARATOR ', ')
, GROUP_CONCAT(t_MPOPL.name_error, ' - ', t_MPOPL.quantity_produced SEPARATOR ', ')
)
FROM tmp_Manufacturing_Purchase_Order_Product_Link t_MPOPL
WHERE t_MPOPL.quantity_received < 0
WHERE t_MPOPL.quantity_produced < 0
;
END IF;
# Invalid delivery latency
# id_unit_latency_manufacture
IF EXISTS (
SELECT *
FROM tmp_Manufacturing_Purchase_Order t_MPO
LEFT JOIN partsltd_prod.Shop_Unit_Measurement UM ON t_MPO.id_unit_latency_manufacture = UM.id_unit_measurement
WHERE 1=1
AND (
NOT ISNULL(t_MPO.id_unit_latency_manufacture)
OR ISNULL(UM.id_unit_measurement)
OR UM.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(
'A valid unit measurement of manufacture latency is required for the following Manufacturing Purchase Order(s): '
, GROUP_CONCAT(CONCAT(IFNULL(t_MPO.id_stock, '(No Manufacturing Purchase Order)'), ' - ', t_MPO.id_unit_latency_manufacture) SEPARATOR ', ')
) AS msg
FROM tmp_Stock_Item t_SPO
LEFT JOIN partsltd_prod.Shop_Unit_Measurement UM ON t_MPO.id_unit_latency_manufacture = UM.id_unit_measurement
WHERE 1=1
AND (
NOT ISNULL(t_MPO.id_unit_latency_manufacture)
OR ISNULL(UM.id_unit_measurement)
OR UM.active = 0
)
;
END IF;
# Invalid manufacture latency
IF EXISTS (
SELECT *
FROM tmp_Manufacturing_Purchase_Order_Product_Link
WHERE t_MPOPL.latency_delivery_days < 0
WHERE t_MPOPL.latency_manufacture < 0
) THEN
INSERT INTO tmp_Msg_Error (
id_type, code, msg
@@ -329,11 +374,11 @@ BEGIN
v_id_error_type_bad_data,
v_code_error_type_bad_data,
CONCAT(
'A valid delivery latency is required for the following Manufacturing Purchase Order Item(s): '
, GROUP_CONCAT(t_MPOPL.name_error, ' - ', t_MPOPL.latency_delivery_days SEPARATOR ', ')
'A valid manufacture latency is required for the following Manufacturing Purchase Order Item(s): '
, GROUP_CONCAT(t_MPOPL.name_error, ' - ', t_MPOPL.latency_manufacture SEPARATOR ', ')
)
FROM tmp_Manufacturing_Purchase_Order_Product_Link t_MPOPL
WHERE t_MPOPL.latency_delivery_days < 0
WHERE t_MPOPL.latency_manufacture < 0
;
END IF;
@@ -415,7 +460,7 @@ BEGIN
);
IF a_debug = 1 THEN
SELECT
v_guid
a_guid
, a_id_user
, FALSE -- get inactive users
, v_ids_permission_manufacturing_purchase_order
@@ -427,7 +472,7 @@ BEGIN
END IF;
CALL p_shop_calc_user(
v_guid
a_guid
, a_id_user
, FALSE -- get inactive users
, v_ids_permission_manufacturing_purchase_order
@@ -440,7 +485,7 @@ BEGIN
SELECT * from partsltd_prod.Shop_Calc_User_Temp WHERE GUID = a_guid;
END IF;
IF NOT EXISTS (SELECT can_view FROM partsltd_prod.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 = a_guid) THEN
DELETE FROM tmp_Msg_Error;
INSERT INTO tmp_Msg_Error (
@@ -505,9 +550,10 @@ BEGIN
, id_permutation
, id_currency_cost
, id_unit_quantity
, quantity_ordered
, quantity_received
, latency_delivery_days
, quantity_used
, quantity_produced
, id_unit_latency_manufacture
, latency_manufacture
, display_order
, active
, cost_total_local_VAT_excl
@@ -520,9 +566,10 @@ BEGIN
, t_MPOPL.id_permutation
, t_MPOPL.id_currency_cost
, t_MPOPL.id_unit_quantity
, t_MPOPL.quantity_ordered
, t_MPOPL.quantity_received
, t_MPOPL.latency_delivery_days
, t_MPOPL.quantity_used
, t_MPOPL.quantity_produced
, t_MPOPL.id_unit_latency_manufacture
, t_MPOPL.latency_manufacture
, t_MPOPL.display_order
, t_MPOPL.active
, t_MPOPL.cost_total_local_VAT_excl
@@ -551,18 +598,19 @@ BEGIN
ON MPOPL.id_link = t_MPOPL.id_link
AND t_MPOPL.is_new = 0
SET
MPOPL.id_order = t_MPOPL.id_order,
MPOPL.id_permutation = t_MPOPL.id_permutation,
MPOPL.id_currency_cost = t_MPOPL.id_currency_cost,
MPOPL.id_unit_quantity = t_MPOPL.id_unit_quantity,
MPOPL.quantity_ordered = t_MPOPL.quantity_ordered,
MPOPL.quantity_received = t_MPOPL.quantity_received,
MPOPL.latency_delivery_days = t_MPOPL.latency_delivery_days,
MPOPL.display_order = t_MPOPL.display_order,
MPOPL.active = t_MPOPL.active,
MPOPL.cost_total_local_VAT_excl = t_MPOPL.cost_total_local_VAT_excl,
MPOPL.cost_total_local_VAT_incl = t_MPOPL.cost_total_local_VAT_incl,
MPOPL.id_change_set = v_id_change_set
MPOPL.id_order = t_MPOPL.id_order
, MPOPL.id_permutation = t_MPOPL.id_permutation
, MPOPL.id_currency_cost = t_MPOPL.id_currency_cost
, MPOPL.id_unit_quantity = t_MPOPL.id_unit_quantity
, MPOPL.quantity_used = t_MPOPL.quantity_used
, MPOPL.quantity_produced = t_MPOPL.quantity_produced
, MPOPL.id_unit_latency_manufacture = t_MPOPL.id_unit_latency_manufacture
, MPOPL.latency_manufacture = t_MPOPL.latency_manufacture
, MPOPL.display_order = t_MPOPL.display_order
, MPOPL.active = t_MPOPL.active
, MPOPL.cost_total_local_VAT_excl = t_MPOPL.cost_total_local_VAT_excl
, MPOPL.cost_total_local_VAT_incl = t_MPOPL.cost_total_local_VAT_incl
, MPOPL.id_change_set = v_id_change_set
;
DELETE SPO_T
@@ -584,7 +632,8 @@ BEGIN
;
IF a_debug = 1 THEN
SELECT * from tmp_Manufacturing;
SELECT * from tmp_Manufacturing_Purchase_Order;
SELECT * from tmp_Manufacturing_Purchase_Order_Product_Link;
END IF;
DROP TEMPORARY TABLE tmp_Manufacturing_Purchase_Order;
@@ -613,10 +662,10 @@ INSERT INTO Shop_Manufacturing_Purchase_Order_Product_Link_Temp (
id_permutation,
cost_total_local,
id_currency_cost,
quantity_ordered,
quantity_used,
id_unit_quantity,
quantity_received,
latency_delivery_days,
quantity_produced,
latency_manufacture,
display_order,
active
)
@@ -628,10 +677,10 @@ VALUES
1, # id_permutation,
100, # cost_total_local,
1, # id_currency_cost,
1, # quantity_ordered,
1, # quantity_used,
1, # id_unit_quantity,
1, # quantity_received,
14, # latency_delivery_days ,
1, # quantity_produced,
14, # latency_manufacture ,
1, # display_order
1 # active
)

View File

@@ -317,6 +317,8 @@ BEGIN
SELECT
t_MPO.id_order
, MPO.id_currency
, C.code
, C.symbol
, MPO.cost_total_local_VAT_excl
, MPO.cost_total_local_VAT_incl
, MPO.price_total_local_VAT_excl
@@ -330,6 +332,7 @@ BEGIN
) 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
LEFT JOIN partsltd_prod.Shop_Currency C ON MPO.id_currency_cost = C.id_currency
;
# Manufacturing Purchase Order Product Link
@@ -341,7 +344,8 @@ BEGIN
, MPOPL.id_unit_quantity
, MPOPL.quantity_used
, MPOPL.quantity_produced
, MPOPL.latency_manufacture_days
, MPOPL.id_unit_latency_manufacture
, MPOPL.latency_manufacture
, MPOPL.display_order
, MPOPL.cost_unit_local_VAT_excl
, MPOPL.cost_unit_local_VAT_incl

View File

@@ -203,7 +203,7 @@ BEGIN
price_GBP_min FLOAT NOT NULL,
*/
/*
latency_manufacture_days INT NOT NULL,
latency_manufacture INT NOT NULL,
quantity_min FLOAT NOT NULL,
quantity_max FLOAT NOT NULL,
quantity_step FLOAT NOT NULL,
@@ -398,7 +398,7 @@ BEGIN
price_GBP_VAT_excl,
price_GBP_min,
*
latency_manufacture_days,
latency_manufacture,
quantity_min,
quantity_max,
quantity_step,
@@ -430,7 +430,7 @@ BEGIN
PP.price_GBP_VAT_excl,
PP.price_GBP_min,
*
PP.latency_manufacture_days,
PP.latency_manufacture,
PP.quantity_min,
PP.quantity_max,
PP.quantity_step,

View File

@@ -258,7 +258,7 @@ INSERT INTO Shop_Product_Permutation (
id_currency_cost,
profit_local_min,
# id_currency_profit_min,
latency_manufacture_days,
latency_manufacture,
id_unit_measurement_quantity,
count_unit_measurement_per_quantity_step,
quantity_min,
@@ -690,7 +690,8 @@ VALUES
# Supplier
INSERT INTO Shop_Supplier (
name_company
id_supplier_temp
, name_company
, name_contact
, department_contact
-- , id_address
@@ -702,7 +703,8 @@ INSERT INTO Shop_Supplier (
)
VALUES
(
'Precision And Research Technology Systems Limited'
-1
, 'Precision And Research Technology Systems Limited'
, 'Teddy Middleton-Smith'
, 'Executive Management'
-- , 1
@@ -716,7 +718,8 @@ VALUES
# Suppliers
INSERT INTO Shop_Supplier (
name_company
id_supplier_temp
, name_company
, name_contact
, department_contact
-- , id_address
@@ -728,7 +731,8 @@ INSERT INTO Shop_Supplier (
)
VALUES
(
'Malt Kiln Farm Shop'
-2
, 'Malt Kiln Farm Shop'
, NULL
, NULL
-- , 1

View File

@@ -2674,7 +2674,7 @@ CREATE TABLE `shop_product_permutation` (
`id_currency_cost_manufacturing` int NOT NULL,
`profit_local_min` float NOT NULL,
`id_currency_profit_min` int NOT NULL,
`latency_manufacture_days` int NOT NULL,
`latency_manufacture` int NOT NULL,
`quantity_min` float NOT NULL,
`quantity_max` float NOT NULL,
`quantity_step` float NOT NULL,
@@ -2794,9 +2794,9 @@ DELIMITER ;;;
WHERE NOT (OLD.price_GBP_min <=> NEW.price_GBP_min)
UNION
*/
# Changed latency_manufacture_days
SELECT NEW.id_product, 'latency_manufacture_days', CONVERT(OLD.latency_manufacture_days, CHAR), CONVERT(NEW.latency_manufacture_days, CHAR), NEW.id_change_set
WHERE NOT OLD.latency_manufacture_days <=> NEW.latency_manufacture_days
# Changed latency_manufacture
SELECT NEW.id_product, 'latency_manufacture', CONVERT(OLD.latency_manufacture, CHAR), CONVERT(NEW.latency_manufacture, CHAR), NEW.id_change_set
WHERE NOT OLD.latency_manufacture <=> NEW.latency_manufacture
UNION
# Changed quantity_min
SELECT NEW.id_product, 'quantity_min', CONVERT(OLD.quantity_min, CHAR), CONVERT(NEW.quantity_min, CHAR), NEW.id_change_set
@@ -6110,7 +6110,7 @@ BEGIN
price_GBP_full FLOAT NOT NULL,
price_GBP_min FLOAT NOT NULL,
*/
latency_manufacture_days INT NOT NULL,
latency_manufacture INT NOT NULL,
quantity_min FLOAT NOT NULL,
quantity_max FLOAT NOT NULL,
quantity_step FLOAT NOT NULL,
@@ -6224,7 +6224,7 @@ BEGIN
price_GBP_VAT_excl,
price_GBP_min,
*/
latency_manufacture_days,
latency_manufacture,
quantity_min,
quantity_max,
quantity_step,
@@ -6254,7 +6254,7 @@ BEGIN
PP.price_GBP_VAT_excl,
PP.price_GBP_min,
*/
PP.latency_manufacture_days,
PP.latency_manufacture,
PP.quantity_min,
PP.quantity_max,
PP.quantity_step,
@@ -6705,7 +6705,7 @@ BEGIN
t_P.description,
P.has_variations,
P.id_category,
t_P.latency_manufacture_days,
t_P.latency_manufacture,
t_P.quantity_min,
t_P.quantity_max,
t_P.quantity_step,

View File

@@ -2674,7 +2674,7 @@ CREATE TABLE `shop_product_permutation` (
`id_currency_cost_manufacturing` int NOT NULL,
`profit_local_min` float NOT NULL,
`id_currency_profit_min` int NOT NULL,
`latency_manufacture_days` int NOT NULL,
`latency_manufacture` int NOT NULL,
`quantity_min` float NOT NULL,
`quantity_max` float NOT NULL,
`quantity_step` float NOT NULL,
@@ -2794,9 +2794,9 @@ DELIMITER ;;;
WHERE NOT (OLD.price_GBP_min <=> NEW.price_GBP_min)
UNION
*/
# Changed latency_manufacture_days
SELECT NEW.id_product, 'latency_manufacture_days', CONVERT(OLD.latency_manufacture_days, CHAR), CONVERT(NEW.latency_manufacture_days, CHAR), NEW.id_change_set
WHERE NOT OLD.latency_manufacture_days <=> NEW.latency_manufacture_days
# Changed latency_manufacture
SELECT NEW.id_product, 'latency_manufacture', CONVERT(OLD.latency_manufacture, CHAR), CONVERT(NEW.latency_manufacture, CHAR), NEW.id_change_set
WHERE NOT OLD.latency_manufacture <=> NEW.latency_manufacture
UNION
# Changed quantity_min
SELECT NEW.id_product, 'quantity_min', CONVERT(OLD.quantity_min, CHAR), CONVERT(NEW.quantity_min, CHAR), NEW.id_change_set
@@ -6110,7 +6110,7 @@ BEGIN
price_GBP_full FLOAT NOT NULL,
price_GBP_min FLOAT NOT NULL,
*/
latency_manufacture_days INT NOT NULL,
latency_manufacture INT NOT NULL,
quantity_min FLOAT NOT NULL,
quantity_max FLOAT NOT NULL,
quantity_step FLOAT NOT NULL,
@@ -6224,7 +6224,7 @@ BEGIN
price_GBP_VAT_excl,
price_GBP_min,
*/
latency_manufacture_days,
latency_manufacture,
quantity_min,
quantity_max,
quantity_step,
@@ -6254,7 +6254,7 @@ BEGIN
PP.price_GBP_VAT_excl,
PP.price_GBP_min,
*/
PP.latency_manufacture_days,
PP.latency_manufacture,
PP.quantity_min,
PP.quantity_max,
PP.quantity_step,
@@ -6705,7 +6705,7 @@ BEGIN
t_P.description,
P.has_variations,
P.id_category,
t_P.latency_manufacture_days,
t_P.latency_manufacture,
t_P.quantity_min,
t_P.quantity_max,
t_P.quantity_step,

View File

@@ -93,8 +93,8 @@
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
1404_tbl_Shop_Supplier_Address_Audit.sql
1405_tbl_Shop_Supplier_Address_Temp.sql
1409_tbl_Shop_Supplier_Purchase_Order.sql
1410_tbl_Shop_Supplier_Purchase_Order_Audit.sql
1411_tbl_Shop_Supplier_Purchase_Order_Temp.sql
@@ -197,8 +197,9 @@
7313_p_get_many_user.sql
7321_p_shop_save_user_basket.sql
7400_p_shop_save_supplier.sql
7400_p_shop_save_supplier_temp.sql
7401_p_shop_get_many_supplier.sql
7403_p_save_supplier_purchase_order.sql
7403_p_shop_save_supplier_purchase_order.sql
7404_p_shop_get_many_supplier_purchase_order.sql
7415_p_shop_save_manufacturing_purchase_order.sql
7416_p_shop_get_many_manufacturing_purchase_order.sql