Fix: Product, Product Category, Product Permutation, Supplier, Supplier Purchase Order, and Manufacturing Purchase Order architecture update for getting and saving data.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -282,6 +282,7 @@ DROP PROCEDURE IF EXISTS p_shop_get_many_storage_location;
|
||||
DROP PROCEDURE IF EXISTS p_shop_get_many_currency;
|
||||
|
||||
DROP PROCEDURE IF EXISTS p_shop_save_category;
|
||||
DROP PROCEDURE IF EXISTS p_shop_save_category_test;
|
||||
DROP PROCEDURE IF EXISTS p_shop_save_product_category;
|
||||
DROP PROCEDURE IF EXISTS p_shop_save_product_category_test;
|
||||
DROP PROCEDURE IF EXISTS p_shop_save_product;
|
||||
@@ -292,6 +293,7 @@ DROP PROCEDURE IF EXISTS p_shop_get_many_product;
|
||||
DROP PROCEDURE IF EXISTS p_shop_get_many_stripe_product_new;
|
||||
DROP PROCEDURE IF EXISTS p_shop_save_permutation;
|
||||
DROP PROCEDURE IF EXISTS p_shop_save_product_permutation;
|
||||
DROP PROCEDURE IF EXISTS p_shop_save_product_permutation_test;
|
||||
DROP PROCEDURE IF EXISTS p_shop_get_many_product_variation;
|
||||
DROP FUNCTION IF EXISTS fn_shop_get_id_product_permutation_from_variation_csv_list;
|
||||
DROP PROCEDURE IF EXISTS p_shop_save_stock_item;
|
||||
@@ -313,6 +315,7 @@ DROP PROCEDURE IF EXISTS p_shop_save_supplier_purchase_order;
|
||||
DROP PROCEDURE IF EXISTS p_shop_save_supplier_purchase_order_test;
|
||||
DROP PROCEDURE IF EXISTS p_shop_get_many_supplier_purchase_order;
|
||||
DROP PROCEDURE IF EXISTS p_shop_save_manufacturing_purchase_order;
|
||||
DROP PROCEDURE IF EXISTS p_shop_save_manufacturing_purchase_order_test;
|
||||
DROP PROCEDURE IF EXISTS p_shop_get_many_manufacturing_purchase_order;
|
||||
DROP PROCEDURE IF EXISTS p_shop_save_customer;
|
||||
DROP PROCEDURE IF EXISTS p_shop_get_many_customer;
|
||||
|
||||
@@ -12,9 +12,9 @@ CREATE TABLE IF NOT EXISTS Shop_Product_Category_Temp (
|
||||
, description VARCHAR(4000) NULL
|
||||
, id_access_level_required INT NOT NULL DEFAULT 1
|
||||
, display_order INT NOT NULL
|
||||
, active BIT NOT NULL
|
||||
, can_view BIT NULL DEFAULT NULL
|
||||
, can_edit BIT NULL DEFAULT NULL
|
||||
, can_admin BIT NULL DEFAULT NULL
|
||||
, active BIT NULL
|
||||
, can_view BIT NULL
|
||||
, can_edit BIT NULL
|
||||
, can_admin BIT NULL
|
||||
, guid BINARY(36) NOT NULL
|
||||
);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
# Product Permutation
|
||||
|
||||
|
||||
-- DROP TABLE partsltd_prod.Shop_Product_Permutation;
|
||||
|
||||
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Product_Permutation';
|
||||
|
||||
@@ -14,9 +14,10 @@ CREATE TABLE IF NOT EXISTS Shop_Product_Permutation (
|
||||
ON UPDATE RESTRICT,
|
||||
-- name VARCHAR(255) NOT NULL,
|
||||
description VARCHAR(4000) NOT NULL,
|
||||
cost_local FLOAT NOT NULL,
|
||||
cost_local_VAT_excl FLOAT NULL,
|
||||
cost_local_VAT_incl FLOAT NULL,
|
||||
id_currency_cost INT NOT NULL,
|
||||
profit_local_min FLOAT NOT NULL,
|
||||
profit_local_min FLOAT NULL,
|
||||
-- id_currency_profit_min INT NOT NULL,
|
||||
latency_manufacture INT NOT NULL,
|
||||
id_unit_measurement_quantity INT NOT NULL,
|
||||
@@ -24,8 +25,8 @@ CREATE TABLE IF NOT EXISTS Shop_Product_Permutation (
|
||||
FOREIGN KEY (id_unit_measurement_quantity)
|
||||
REFERENCES Shop_Unit_Measurement(id_unit_measurement),
|
||||
count_unit_measurement_per_quantity_step FLOAT NOT NULL,
|
||||
quantity_min FLOAT NOT NULL,
|
||||
quantity_max FLOAT NOT NULL,
|
||||
quantity_min FLOAT NULL,
|
||||
quantity_max FLOAT NULL,
|
||||
quantity_stock FLOAT NOT NULL,
|
||||
is_subscription BIT NOT NULL,
|
||||
id_unit_measurement_interval_recurrence INT,
|
||||
@@ -49,7 +50,7 @@ CREATE TABLE IF NOT EXISTS Shop_Product_Permutation (
|
||||
*/
|
||||
count_interval_expiration_unsealed INT,
|
||||
active BIT NOT NULL DEFAULT 1,
|
||||
display_order INT NOT NULL,
|
||||
-- display_order INT NOT NULL,
|
||||
created_on DATETIME,
|
||||
created_by INT,
|
||||
id_change_set INT,
|
||||
|
||||
@@ -9,9 +9,10 @@ CREATE TABLE IF NOT EXISTS Shop_Product_Permutation_Temp (
|
||||
id_permutation INT NOT NULL
|
||||
, id_product INT NOT NULL
|
||||
, description VARCHAR(4000) NOT NULL
|
||||
, cost_local FLOAT NOT NULL
|
||||
, cost_local_VAT_excl FLOAT NULL
|
||||
, cost_local_VAT_incl FLOAT NULL
|
||||
, id_currency_cost INT NOT NULL
|
||||
, profit_local_min FLOAT NOT NULL
|
||||
, profit_local_min FLOAT NULL
|
||||
, latency_manufacture INT NOT NULL
|
||||
, id_unit_measurement_quantity INT NOT NULL
|
||||
, count_unit_measurement_per_quantity_step FLOAT NOT NULL
|
||||
|
||||
@@ -28,6 +28,6 @@ CREATE TABLE IF NOT EXISTS Shop_Supplier (
|
||||
, id_change_set INT
|
||||
, CONSTRAINT FK_Shop_Supplier_id_change_set
|
||||
FOREIGN KEY (id_change_set)
|
||||
REFERENCES Shop_Sales_And_Purchasing_Change_Set(id_change_set)
|
||||
REFERENCES Shop_User_Change_Set(id_change_set)
|
||||
, id_supplier_temp INT NOT NULL
|
||||
);
|
||||
|
||||
@@ -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_Sales_And_Purchasing_Change_Set(id_change_set)
|
||||
REFERENCES partsltd_prod.Shop_User_Change_Set(id_change_set)
|
||||
);
|
||||
@@ -14,10 +14,10 @@ CREATE TABLE IF NOT EXISTS Shop_Manufacturing_Purchase_Order (
|
||||
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,
|
||||
cost_total_local_VAT_excl FLOAT NULL,
|
||||
cost_total_local_VAT_incl FLOAT NULL,
|
||||
price_total_local_VAT_excl FLOAT NULL,
|
||||
price_total_local_VAT_incl FLOAT NULL,
|
||||
/*
|
||||
latency_delivery INT NOT NULL,
|
||||
quantity_ordered FLOAT NOT NULL,
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
|
||||
# Manufacturing Purchase Order Temp
|
||||
|
||||
-- DROP TABLE Shop_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 (
|
||||
@@ -8,11 +10,11 @@ CREATE TABLE IF NOT EXISTS Shop_Manufacturing_Purchase_Order_Temp (
|
||||
/*
|
||||
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,
|
||||
id_currency INT NOT NULL,
|
||||
cost_total_local_VAT_excl FLOAT NULL,
|
||||
cost_total_local_VAT_incl FLOAT NULL,
|
||||
price_total_local_VAT_excl FLOAT NULL,
|
||||
price_total_local_VAT_incl FLOAT NULL,
|
||||
/*
|
||||
latency_delivery INT NOT NULL,
|
||||
quantity_ordered FLOAT NOT NULL,
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
|
||||
# Manufacturing Purchase Order Product Link
|
||||
|
||||
-- DROP TABLE partsltd_prod.Shop_Manufacturing_Purchase_Order_Product_Link_Audit
|
||||
-- DROP TABLE partsltd_prod.Shop_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';
|
||||
|
||||
@@ -9,11 +11,11 @@ CREATE TABLE IF NOT EXISTS Shop_Manufacturing_Purchase_Order_Product_Link (
|
||||
, 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)
|
||||
REFERENCES partsltd_prod.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)
|
||||
REFERENCES partsltd_prod.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
|
||||
@@ -21,13 +23,13 @@ CREATE TABLE IF NOT EXISTS Shop_Manufacturing_Purchase_Order_Product_Link (
|
||||
, 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)
|
||||
REFERENCES partsltd_prod.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)
|
||||
REFERENCES partsltd_prod.Shop_Unit_Measurement(id_unit_measurement)
|
||||
, latency_manufacture INT NULL
|
||||
, display_order INT NOT NULL
|
||||
, active BIT NOT NULL
|
||||
@@ -38,5 +40,5 @@ CREATE TABLE IF NOT EXISTS Shop_Manufacturing_Purchase_Order_Product_Link (
|
||||
, 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)
|
||||
REFERENCES partsltd_prod.Shop_Sales_And_Purchasing_Change_Set(id_change_set)
|
||||
);
|
||||
|
||||
@@ -9,7 +9,9 @@ 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,
|
||||
id_order INT NOT NULL,
|
||||
id_permutation INT NOT NULL,
|
||||
id_product INT NULL,
|
||||
id_permutation INT NULL,
|
||||
csv_list_variations VARCHAR(4000) NULL,
|
||||
id_unit_quantity INT NOT NULL,
|
||||
quantity_used FLOAT NULL,
|
||||
quantity_produced FLOAT NULL,
|
||||
|
||||
@@ -69,9 +69,13 @@ BEGIN
|
||||
SELECT NEW.id_permutation, 'description', OLD.description, NEW.description, NEW.id_change_set
|
||||
WHERE NOT (OLD.description <=> NEW.description)
|
||||
UNION
|
||||
# Changed cost_local
|
||||
SELECT NEW.id_permutation, 'cost_local', CONVERT(OLD.cost_local, CHAR), CONVERT(NEW.cost_local, CHAR), NEW.id_change_set
|
||||
WHERE NOT (OLD.cost_local <=> NEW.cost_local)
|
||||
# Changed cost_local_VAT_excl
|
||||
SELECT NEW.id_permutation, 'cost_local_VAT_excl', CONVERT(OLD.cost_local_VAT_excl, CHAR), CONVERT(NEW.cost_local_VAT_excl, CHAR), NEW.id_change_set
|
||||
WHERE NOT (OLD.cost_local_VAT_excl <=> NEW.cost_local_VAT_excl)
|
||||
UNION
|
||||
# Changed cost_local_VAT_incl
|
||||
SELECT NEW.id_permutation, 'cost_local_VAT_incl', CONVERT(OLD.cost_local_VAT_incl, CHAR), CONVERT(NEW.cost_local_VAT_incl, CHAR), NEW.id_change_set
|
||||
WHERE NOT (OLD.cost_local_VAT_incl <=> NEW.cost_local_VAT_incl)
|
||||
UNION
|
||||
# Changed id_currency_cost
|
||||
SELECT NEW.id_permutation, 'id_currency_cost', CONVERT(OLD.id_currency_cost, CHAR), CONVERT(NEW.id_currency_cost, CHAR), NEW.id_change_set
|
||||
|
||||
@@ -14,7 +14,7 @@ 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));
|
||||
IF NOT EXISTS (SELECT * FROM partsltd_prod.Shop_User U WHERE U.id_user = NEW.created_on LIMIT 1) THEN
|
||||
IF NOT EXISTS (SELECT * FROM partsltd_prod.Shop_User U WHERE U.id_user = NEW.created_by LIMIT 1) THEN
|
||||
SIGNAL SQLSTATE '45000'
|
||||
SET MESSAGE_TEXT = 'Valid created by User ID must be provided.';
|
||||
END IF;
|
||||
@@ -31,10 +31,6 @@ 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,
|
||||
|
||||
@@ -10,7 +10,8 @@ DELIMITER //
|
||||
CREATE PROCEDURE p_shop_save_product_category (
|
||||
IN a_comment VARCHAR(500),
|
||||
IN a_guid BINARY(36),
|
||||
IN a_id_user INT
|
||||
IN a_id_user INT,
|
||||
IN a_debug BIT
|
||||
)
|
||||
BEGIN
|
||||
DECLARE v_code_type_error_bad_data VARCHAR(100);
|
||||
@@ -19,7 +20,7 @@ BEGIN
|
||||
DECLARE v_ids_product_permission LONGTEXT;
|
||||
DECLARE v_id_change_set INT;
|
||||
DECLARE v_id_access_level_edit INT;
|
||||
DECLARE v_now DATETIME;
|
||||
DECLARE v_time_start TIMESTAMP(6);
|
||||
|
||||
DECLARE exit handler for SQLEXCEPTION
|
||||
BEGIN
|
||||
@@ -38,33 +39,33 @@ BEGIN
|
||||
|
||||
CREATE TEMPORARY TABLE IF NOT EXISTS tmp_Msg_Error (
|
||||
display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT
|
||||
, guid BINARY(36) NOT NULL
|
||||
, id_type INT NULL
|
||||
, code VARCHAR(50) NOT NULL
|
||||
, msg VARCHAR(4000) NOT NULL
|
||||
);
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid
|
||||
, id_type
|
||||
id_type
|
||||
, code
|
||||
, msg
|
||||
)
|
||||
SELECT
|
||||
a_guid
|
||||
, NULL
|
||||
MET.id_type
|
||||
, @errno
|
||||
, @text
|
||||
FROM partsltd_prod.Shop_Msg_Error_Type MET
|
||||
WHERE MET.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 := 'BAD_DATA';
|
||||
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_id_access_level_edit := (SELECT id_access_level FROM Shop_Access_Level WHERE code = 'EDIT' LIMIT 1);
|
||||
|
||||
SET a_guid := IFNULL(a_guid, UUID());
|
||||
CALL p_validate_guid ( a_guid );
|
||||
|
||||
DROP TABLE IF EXISTS tmp_Category;
|
||||
|
||||
@@ -85,7 +86,6 @@ BEGIN
|
||||
|
||||
CREATE TEMPORARY TABLE IF NOT EXISTS tmp_Msg_Error (
|
||||
display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT
|
||||
, guid BINARY(36) NOT NULL
|
||||
, id_type INT NULL
|
||||
, code VARCHAR(50) NOT NULL
|
||||
, msg VARCHAR(4000) NOT NULL
|
||||
@@ -110,7 +110,7 @@ BEGIN
|
||||
, IFNULL(PC_T.name, PC.code) AS name
|
||||
, IFNULL(PC_T.description, PC.description) AS description
|
||||
, IFNULL(PC_T.id_access_level_required, PC.id_access_level_required) AS id_access_level_required
|
||||
, IFNULL(PC_T.active, PC.active) AS active
|
||||
, IFNULL(IFNULL(PC_T.active, PC.active), 1) AS active
|
||||
, IFNULL(PC_T.display_order, PC.display_order) AS display_order
|
||||
, IFNULL(PC_T.name, IFNULL(PC.name, IFNULL(PC_T.code, IFNULL(PC.code, IFNULL(PC_T.id_category, '(No Product Category)'))))) AS name_error
|
||||
, CASE WHEN IFNULL(PC_T.id_category, 0) < 1 THEN 1 ELSE 0 END AS is_new
|
||||
@@ -124,14 +124,12 @@ BEGIN
|
||||
-- code
|
||||
IF EXISTS (SELECT * FROM tmp_Category t_C WHERE ISNULL(t_C.code) LIMIT 1) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid
|
||||
, id_type
|
||||
id_type
|
||||
, code
|
||||
, msg
|
||||
)
|
||||
SELECT
|
||||
a_guid AS GUID
|
||||
, v_id_type_error_bad_data
|
||||
v_id_type_error_bad_data
|
||||
, v_code_type_error_bad_data
|
||||
, CONCAT('The following category(s) do not have a code: ', GROUP_CONCAT(IFNULL(t_C.name_error, 'NULL') SEPARATOR ', ')) AS msg
|
||||
FROM tmp_Category t_C
|
||||
@@ -141,14 +139,12 @@ BEGIN
|
||||
-- name
|
||||
IF EXISTS (SELECT * FROM tmp_Category t_C WHERE ISNULL(t_C.name) LIMIT 1) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid
|
||||
, id_type
|
||||
id_type
|
||||
, code
|
||||
, msg
|
||||
)
|
||||
SELECT
|
||||
a_guid AS GUID
|
||||
, v_id_type_error_bad_data
|
||||
v_id_type_error_bad_data
|
||||
, v_code_type_error_bad_data
|
||||
, CONCAT('The following category(s) do not have a name: ', GROUP_CONCAT(IFNULL(t_C.name_error, 'NULL') SEPARATOR ', ')) AS msg
|
||||
FROM tmp_Category t_C
|
||||
@@ -158,14 +154,12 @@ BEGIN
|
||||
-- display_order
|
||||
IF EXISTS (SELECT * FROM tmp_Category t_C WHERE ISNULL(t_C.display_order) LIMIT 1) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid
|
||||
, id_type
|
||||
id_type
|
||||
, code
|
||||
, msg
|
||||
)
|
||||
SELECT
|
||||
a_guid AS GUID
|
||||
, v_id_type_error_bad_data
|
||||
v_id_type_error_bad_data
|
||||
, v_code_type_error_bad_data
|
||||
, CONCAT('The following category(s) do not have a display order: ', GROUP_CONCAT(IFNULL(t_C.name_error, 'NULL') SEPARATOR ', ')) AS msg
|
||||
FROM tmp_Category t_C
|
||||
@@ -202,8 +196,6 @@ BEGIN
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
SET v_now := CURRENT_DATETIME();
|
||||
|
||||
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error LIMIT 1) THEN
|
||||
START TRANSACTION;
|
||||
|
||||
@@ -247,7 +239,7 @@ BEGIN
|
||||
, t_C.active AS active
|
||||
, t_C.display_order AS display_order
|
||||
, a_id_user AS created_by
|
||||
, v_now AS created_on
|
||||
, v_time_start AS created_on
|
||||
FROM tmp_Category t_C
|
||||
WHERE is_new = 1
|
||||
AND active = 1
|
||||
@@ -259,10 +251,22 @@ BEGIN
|
||||
COMMIT;
|
||||
END IF;
|
||||
|
||||
SELECT * FROM tmp_Msg_Error;
|
||||
# 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
|
||||
;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Catgory;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Msg_Error;
|
||||
IF a_debug = 1 THEN
|
||||
SELECT * from tmp_Catgory;
|
||||
END IF;
|
||||
|
||||
DROP TEMPORARY TABLE tmp_Catgory;
|
||||
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 ;;
|
||||
|
||||
|
||||
@@ -1,274 +1,75 @@
|
||||
|
||||
|
||||
|
||||
|
||||
-- Clear previous proc
|
||||
DROP PROCEDURE IF EXISTS p_shop_save_product_category_test;
|
||||
DROP PROCEDURE IF EXISTS partsltd_prod.p_shop_save_product_category_test;
|
||||
|
||||
|
||||
DELIMITER //
|
||||
CREATE PROCEDURE p_shop_save_product_category_test (
|
||||
IN a_id_user INT,
|
||||
IN a_guid BINARY(36),
|
||||
IN a_comment VARCHAR(500)
|
||||
)
|
||||
CREATE PROCEDURE p_shop_save_product_category_test ()
|
||||
BEGIN
|
||||
DECLARE v_code_type_error_bad_data VARCHAR(100);
|
||||
DECLARE v_id_type_error_bad_data INT;
|
||||
DECLARE v_id_permission_product INT;
|
||||
DECLARE v_ids_product_permission LONGTEXT;
|
||||
DECLARE v_id_change_set INT;
|
||||
|
||||
DECLARE v_guid BINARY(36);
|
||||
DECLARE v_time_start TIMESTAMP(6);
|
||||
|
||||
DECLARE exit handler for SQLEXCEPTION
|
||||
BEGIN
|
||||
-- Get diagnostic information
|
||||
GET DIAGNOSTICS CONDITION 1
|
||||
@sqlstate = RETURNED_SQLSTATE
|
||||
, @errno = MYSQL_ERRNO
|
||||
, @text = MESSAGE_TEXT
|
||||
;
|
||||
|
||||
-- Rollback the transaction
|
||||
ROLLBACK;
|
||||
|
||||
-- Select the error information
|
||||
-- SELECT 'Error' AS status, @errno AS error_code, @sqlstate AS sql_state, @text AS message;
|
||||
|
||||
CREATE TEMPORARY TABLE IF NOT EXISTS tmp_Msg_Error (
|
||||
display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT
|
||||
, guid BINARY(36) NOT NULL
|
||||
, id_type INT NULL
|
||||
, code VARCHAR(50) NOT NULL
|
||||
, msg VARCHAR(4000) NOT NULL
|
||||
);
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid
|
||||
, id_type
|
||||
SET v_time_start := CURRENT_TIMESTAMP(6);
|
||||
SET v_guid := 'nips';
|
||||
|
||||
SELECT *
|
||||
FROM partsltd_prod.Shop_Product_Category
|
||||
;
|
||||
SELECT *
|
||||
FROM partsltd_prod.Shop_Product_Category_Temp
|
||||
;
|
||||
|
||||
START TRANSACTION;
|
||||
|
||||
INSERT INTO partsltd_prod.Shop_Product_Category_Temp (
|
||||
id_category
|
||||
, name
|
||||
, code
|
||||
, msg
|
||||
, description
|
||||
, id_access_level_required
|
||||
, display_order
|
||||
, guid
|
||||
)
|
||||
SELECT
|
||||
a_guid
|
||||
, NULL
|
||||
, @errno
|
||||
, @text
|
||||
;
|
||||
|
||||
SELECT * FROM tmp_Msg_Error;
|
||||
DROP TABLE IF EXISTS tmp_Msg_Error;
|
||||
END;
|
||||
VALUES (
|
||||
-5 -- id_category
|
||||
, 'Nips' -- name
|
||||
, 'Lips' -- code
|
||||
, 'Chips' -- description
|
||||
, 2 -- id_access_level_required
|
||||
, 25 -- display_order
|
||||
, v_guid
|
||||
);
|
||||
|
||||
COMMIT;
|
||||
|
||||
select 'p_shop_save_product_category_test';
|
||||
SELECT *
|
||||
FROM partsltd_prod.Shop_Product_Category_Temp
|
||||
WHERE GUID = v_guid
|
||||
;
|
||||
|
||||
SET v_code_type_error_bad_data := 'BAD_DATA';
|
||||
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 a_guid := IFNULL(a_guid, UUID());
|
||||
|
||||
DROP TABLE IF EXISTS tmp_Category;
|
||||
|
||||
CREATE TEMPORARY TABLE tmp_Category (
|
||||
id_category INT NOT NULL
|
||||
, code VARCHAR(50) NOT NULL
|
||||
, name VARCHAR(255) NOT NULL
|
||||
, description VARCHAR(4000) NULL
|
||||
, active BIT NOT NULL
|
||||
, display_order INT NOT NULL
|
||||
, can_view BIT NULL
|
||||
, can_edit BIT NULL
|
||||
, can_admin BIT NULL
|
||||
, name_error VARCHAR(255) NOT NULL
|
||||
, is_new BIT NOT NULL
|
||||
CALL partsltd_prod.p_shop_save_product_category (
|
||||
'Test save product category' -- comment
|
||||
, v_guid -- guid
|
||||
, 1 -- id_user
|
||||
, 1 -- debug
|
||||
);
|
||||
|
||||
CREATE TEMPORARY TABLE IF NOT EXISTS tmp_Msg_Error (
|
||||
display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT
|
||||
, guid BINARY(36) NOT NULL
|
||||
, id_type INT NULL
|
||||
/*
|
||||
CONSTRAINT FK_tmp_Msg_Error_id_type
|
||||
FOREIGN KEY (id_type)
|
||||
REFERENCES Shop_Msg_Error_Type (id_type),
|
||||
*/
|
||||
, code VARCHAR(50) NOT NULL
|
||||
, msg VARCHAR(4000) NOT NULL
|
||||
);
|
||||
|
||||
SELECT *
|
||||
FROM partsltd_prod.Shop_Product_Category
|
||||
;
|
||||
SELECT *
|
||||
FROM partsltd_prod.Shop_Product_Category_Temp
|
||||
;
|
||||
|
||||
-- Get data from Temp table
|
||||
INSERT INTO tmp_Category (
|
||||
id_category
|
||||
, code
|
||||
, name
|
||||
, description
|
||||
, active
|
||||
, display_order
|
||||
, name_error
|
||||
, is_new
|
||||
)
|
||||
SELECT
|
||||
IFNULL(PC_T.id_category, PC.id_category) AS id_category
|
||||
, IFNULL(PC_T.code, PC.code) AS code
|
||||
, IFNULL(PC_T.name, PC.code) AS name
|
||||
, IFNULL(PC_T.description, PC.description) AS description
|
||||
, IFNULL(PC_T.active, PC.active) AS active
|
||||
, IFNULL(PC_T.display_order, PC.display_order) AS display_order
|
||||
, IFNULL(PC_T.name, IFNULL(PC.name, IFNULL(PC_T.code, IFNULL(PC.code, IFNULL(PC_T.id_category, '(No Product Category)'))))) AS name_error
|
||||
, CASE WHEN IFNULL(PC_T.id_category, 0) < 1 THEN 1 ELSE 0 END AS is_new
|
||||
FROM Shop_Product_Category_Temp PC_T
|
||||
LEFT JOIN Shop_Product_Category PC ON PC_T.id_category = PC.id_category
|
||||
WHERE PC_T.guid = a_guid
|
||||
;
|
||||
|
||||
-- Validation
|
||||
-- Missing mandatory fields
|
||||
-- code
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid
|
||||
, id_type
|
||||
, code
|
||||
, msg
|
||||
)
|
||||
SELECT
|
||||
a_guid AS GUID
|
||||
, v_id_type_error_bad_data
|
||||
, v_code_type_error_bad_data
|
||||
, CONCAT('The following category(s) do not have a code: ', GROUP_CONCAT(t_C.name_error SEPARATOR ', ')) AS msg
|
||||
FROM tmp_Category t_C
|
||||
;
|
||||
-- name
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid
|
||||
, id_type
|
||||
, code
|
||||
, msg
|
||||
)
|
||||
SELECT
|
||||
a_guid AS GUID
|
||||
, v_id_type_error_bad_data
|
||||
, v_code_type_error_bad_data
|
||||
, CONCAT('The following category(s) do not have a name: ', GROUP_CONCAT(t_C.name_error SEPARATOR ', ')) AS msg
|
||||
FROM tmp_Category t_C
|
||||
;
|
||||
-- display_order
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid
|
||||
, id_type
|
||||
, code
|
||||
, msg
|
||||
)
|
||||
SELECT
|
||||
a_guid AS GUID
|
||||
, v_id_type_error_bad_data
|
||||
, v_code_type_error_bad_data
|
||||
, CONCAT('The following category(s) do not have a display order: ', GROUP_CONCAT(t_C.name_error SEPARATOR ', ')) AS msg
|
||||
FROM tmp_Category t_C
|
||||
;
|
||||
|
||||
SELECT * FROM tmp_Category;
|
||||
|
||||
-- Permissions
|
||||
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error LIMIT 1) THEN -- (SELECT * FROM tmp_Product WHERE is_new = 0 LIMIT 1) THEN
|
||||
SET v_ids_product_permission := (
|
||||
SELECT GROUP_CONCAT(P.id_product SEPARATOR ',')
|
||||
FROM Shop_Product P
|
||||
INNER JOIN Shop_Product_Category PC
|
||||
ON P.id_category = PC.id_category
|
||||
AND PC.is_new = 0
|
||||
);
|
||||
IF NOT ISNULL(v_ids_product_permission) THEN
|
||||
SET v_id_permission_product = (SELECT id_permission FROM Shop_Permission WHERE code = 'STORE_PRODUCT' LIMIT 1);
|
||||
|
||||
CALL p_shop_calc_user(a_guid, a_id_user, v_id_permission_product, v_ids_product_permission);
|
||||
|
||||
UPDATE tmp_Category t_C
|
||||
INNER JOIN Shop_Product P ON t_C.id_category = P.id_product
|
||||
INNER JOIN Shop_Calc_User_Temp UE_T
|
||||
ON P.id_product = UE_T.id_product
|
||||
AND UE_T.GUID = a_guid
|
||||
SET
|
||||
t_C.can_view = UE_T.can_view
|
||||
, t_C.can_edit = UE_T.can_edit
|
||||
, t_C.can_admin = UE_T.can_admin
|
||||
;
|
||||
|
||||
CALL p_shop_clear_calc_user(a_guid);
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
SELECT * FROM tmp_Category;
|
||||
|
||||
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error LIMIT 1) THEN
|
||||
START TRANSACTION;
|
||||
|
||||
IF NOT ISNULL(v_ids_product_permission) THEN
|
||||
INSERT INTO Shop_Product_Change_Set ( comment )
|
||||
VALUES ( a_comment )
|
||||
;
|
||||
|
||||
SET v_id_change_set := LAST_INSERT_ID();
|
||||
|
||||
UPDATE Shop_Product_Category PC
|
||||
INNER JOIN tmp_Category t_C ON PC.id_category = t_C.id_category
|
||||
SET
|
||||
PC.id_category = t_C.id_category
|
||||
, PC.code = t_C.code
|
||||
, PC.name = t_P.name
|
||||
, PC.description = t_C.description
|
||||
, PC.display_order = t_C.display_order
|
||||
, PC.active = t_C.active
|
||||
, P.id_change_set = v_id_change_set
|
||||
;
|
||||
END IF;
|
||||
|
||||
INSERT INTO Shop_Product_Category (
|
||||
id_category
|
||||
, code
|
||||
, name
|
||||
, description
|
||||
, display_order
|
||||
, active
|
||||
, created_by
|
||||
, created_on
|
||||
)
|
||||
SELECT
|
||||
t_C.id_category AS id_category
|
||||
, t_C.code AS code
|
||||
, t_C.name AS name
|
||||
, t_C.description AS description
|
||||
, t_C.active AS active
|
||||
, t_P.display_order AS display_order
|
||||
, a_id_user AS created_by
|
||||
, v_now AS created_on
|
||||
FROM tmp_Category t_C
|
||||
WHERE is_new = 1
|
||||
AND active = 1
|
||||
;
|
||||
|
||||
ROLLBACK;
|
||||
END IF;
|
||||
|
||||
SELECT * FROM tmp_Msg_Error;
|
||||
SELECT * FROM tmp_Category;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Catgory;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Msg_Error;
|
||||
CALL partsltd_prod.p_debug_timing_reporting ( v_time_start );
|
||||
END //
|
||||
DELIMITER ;;
|
||||
|
||||
/*
|
||||
CALL partsltd_prod.p_shop_save_product_category_test ();
|
||||
|
||||
select *
|
||||
from shop_product_category;
|
||||
select *
|
||||
from shop_product_category_temp;
|
||||
|
||||
SELECT 'nips' as guid;
|
||||
|
||||
CALL p_shop_save_product_category_TEST (1, 'nips', 'y');
|
||||
|
||||
select *
|
||||
from shop_product_category;
|
||||
select *
|
||||
from shop_product_category_temp;
|
||||
|
||||
DELETE FROM partsltd_prod.Shop_Product_Category_Temp;
|
||||
|
||||
DROP TABLE IF EXISTS tmp_Msg_Error;
|
||||
*/
|
||||
|
||||
@@ -64,7 +64,7 @@ BEGIN
|
||||
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_id_access_level_edit := (SELECT id_access_level FROM Shop_Access_Level WHERE code = 'EDIT' LIMIT 1);
|
||||
|
||||
SET a_guid := IFNULL(a_guid, UUID());
|
||||
CALL p_validate_guid ( a_guid );
|
||||
SET a_debug := IFNULL(a_debug, 0);
|
||||
|
||||
IF a_debug = 1 THEN
|
||||
|
||||
@@ -33,7 +33,9 @@ BEGIN
|
||||
, active
|
||||
, guid
|
||||
)
|
||||
VALUES (
|
||||
VALUES
|
||||
/* Test 1 - Update
|
||||
(
|
||||
4 -- id_product
|
||||
, 1 -- id_category
|
||||
, 'Laptops' -- name
|
||||
@@ -42,7 +44,20 @@ BEGIN
|
||||
, 2 -- display_order
|
||||
, 1 -- active
|
||||
, v_guid
|
||||
);
|
||||
)
|
||||
*/
|
||||
/* Test 2 - Insert */
|
||||
(
|
||||
-14 -- id_product
|
||||
, 5 -- id_category
|
||||
, 'Clip' -- name
|
||||
, 0 -- has_variations
|
||||
, 1 -- id_access_level_required
|
||||
, 1 -- display_order
|
||||
, 1 -- active
|
||||
, v_guid
|
||||
)
|
||||
;
|
||||
|
||||
COMMIT;
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ BEGIN
|
||||
WHERE MET.code = 'BAD_DATA'
|
||||
;
|
||||
|
||||
SET a_id_user := TRIM(IFNULL(a_id_user, 0));
|
||||
SET a_id_user := IFNULL(a_id_user, 0);
|
||||
SET a_get_all_product_category := IFNULL(a_get_all_product_category, 0);
|
||||
SET a_get_inactive_product_category := IFNULL(a_get_inactive_product_category, 0);
|
||||
SET a_ids_product_category := TRIM(IFNULL(a_ids_product_category, ''));
|
||||
@@ -473,6 +473,9 @@ BEGIN
|
||||
DELETE FROM tmp_Product_calc;
|
||||
DELETE FROM tmp_Permutation_calc;
|
||||
ELSE
|
||||
SELECT * FROM Shop_Product_Category_Temp;
|
||||
SELECT * FROM Shop_Product_Temp;
|
||||
SELECT * FROM Shop_Product_Permutation_Temp;
|
||||
*/
|
||||
START TRANSACTION;
|
||||
|
||||
@@ -546,7 +549,8 @@ BEGIN
|
||||
id_permutation
|
||||
, id_product
|
||||
, description
|
||||
, cost_local
|
||||
, cost_local_VAT_excl
|
||||
, cost_local_VAT_incl
|
||||
, id_currency_cost
|
||||
, profit_local_min
|
||||
, latency_manufacture
|
||||
@@ -572,7 +576,8 @@ BEGIN
|
||||
t_PP.id_permutation
|
||||
, PP.id_product
|
||||
, PP.description
|
||||
, PP.cost_local
|
||||
, PP.cost_local_VAT_excl
|
||||
, PP.cost_local_VAT_incl
|
||||
, PP.id_currency_cost
|
||||
, PP.profit_local_min
|
||||
, PP.latency_manufacture
|
||||
|
||||
@@ -8,7 +8,8 @@ DELIMITER //
|
||||
CREATE PROCEDURE p_shop_save_product_permutation (
|
||||
IN a_comment VARCHAR(500),
|
||||
IN a_guid BINARY(36),
|
||||
IN a_id_user INT
|
||||
IN a_id_user INT,
|
||||
IN a_debug BIT
|
||||
)
|
||||
BEGIN
|
||||
|
||||
@@ -18,7 +19,7 @@ BEGIN
|
||||
DECLARE v_ids_product_permission LONGTEXT;
|
||||
DECLARE v_id_change_set INT;
|
||||
DECLARE v_id_access_level_edit INT;
|
||||
DECLARE v_now DATETIME;
|
||||
DECLARE v_time_start TIMESTAMP(6);
|
||||
|
||||
DECLARE exit handler for SQLEXCEPTION
|
||||
BEGIN
|
||||
@@ -37,33 +38,34 @@ BEGIN
|
||||
|
||||
CREATE TEMPORARY TABLE IF NOT EXISTS tmp_Msg_Error (
|
||||
display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT
|
||||
, guid BINARY(36) NOT NULL
|
||||
, id_type INT NULL
|
||||
, code VARCHAR(50) NOT NULL
|
||||
, msg VARCHAR(4000) NOT NULL
|
||||
);
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid
|
||||
, id_type
|
||||
id_type
|
||||
, code
|
||||
, msg
|
||||
)
|
||||
SELECT
|
||||
a_guid
|
||||
, NULL
|
||||
MET.id_type
|
||||
, @errno
|
||||
, @text
|
||||
FROM partsltd_prod.Shop_Msg_Error_Type MET
|
||||
WHERE MET.code = 'MYSQL_ERROR'
|
||||
LIMIT 1
|
||||
;
|
||||
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 := 'BAD_DATA';
|
||||
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_id_access_level_edit := (SELECT id_access_level FROM Shop_Access_Level WHERE code = 'EDIT' LIMIT 1);
|
||||
|
||||
SET a_guid := IFNULL(a_guid, UUID());
|
||||
CALL p_validate_guid ( a_guid );
|
||||
|
||||
DROP TABLE IF EXISTS tmp_Permutation;
|
||||
|
||||
@@ -71,14 +73,15 @@ BEGIN
|
||||
id_permutation INT NOT NULL
|
||||
, id_product INT NOT NULL
|
||||
, description VARCHAR(4000) NOT NULL
|
||||
, cost_local FLOAT NOT NULL
|
||||
, cost_local_VAT_excl FLOAT NULL
|
||||
, cost_local_VAT_incl FLOAT NULL
|
||||
, id_currency_cost INT NOT NULL
|
||||
, profit_local_min FLOAT NOT NULL
|
||||
, profit_local_min FLOAT 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
|
||||
, quantity_max FLOAT NOT NULL
|
||||
, quantity_min FLOAT NULL
|
||||
, quantity_max FLOAT NULL
|
||||
, quantity_stock FLOAT NOT NULL
|
||||
, is_subscription BIT NOT NULL
|
||||
, id_unit_measurement_interval_recurrence INT
|
||||
@@ -97,7 +100,6 @@ BEGIN
|
||||
|
||||
CREATE TEMPORARY TABLE IF NOT EXISTS tmp_Msg_Error (
|
||||
display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT
|
||||
, guid BINARY(36) NOT NULL
|
||||
, id_type INT NULL
|
||||
, code VARCHAR(50) NOT NULL
|
||||
, msg VARCHAR(4000) NOT NULL
|
||||
@@ -109,7 +111,8 @@ BEGIN
|
||||
id_permutation
|
||||
, id_product
|
||||
, description
|
||||
, cost_local
|
||||
, cost_local_VAT_excl
|
||||
, cost_local_VAT_incl
|
||||
, id_currency_cost
|
||||
, profit_local_min
|
||||
, latency_manufacture
|
||||
@@ -133,7 +136,8 @@ BEGIN
|
||||
PP_T.id_permutation
|
||||
, IFNULL(PP_T.id_product, PP.id_product) AS id_product
|
||||
, IFNULL(PP_T.description, PP.description) AS description
|
||||
, IFNULL(PP_T.cost_local, PP.cost_local) AS cost_local
|
||||
, IFNULL(PP_T.cost_local_VAT_excl, PP.cost_local_VAT_excl) AS cost_local_VAT_excl
|
||||
, IFNULL(PP_T.cost_local_VAT_incl, PP.cost_local_VAT_incl) AS cost_local_VAT_incl
|
||||
, 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, PP.latency_manufacture) AS latency_manufacture
|
||||
@@ -150,7 +154,7 @@ BEGIN
|
||||
, IFNULL(PP_T.id_unit_measurement_interval_expiration_unsealed, PP.id_unit_measurement_interval_expiration_unsealed) AS id_unit_measurement_interval_expiration_unsealed
|
||||
, IFNULL(PP_T.count_interval_expiration_unsealed, PP.count_interval_expiration_unsealed) AS count_interval_expiration_unsealed
|
||||
, IFNULL(PP_T.active, PP.active) AS active
|
||||
, fn_shop_get_product_permutation_name(PP_T.id_permutation)
|
||||
, IFNULL(fn_shop_get_product_permutation_name(PP_T.id_permutation), '(No Permutation)') AS name_error
|
||||
, CASE WHEN IFNULL(PP_T.id_permutation, 0) < 1 THEN 1 ELSE 0 END AS is_new
|
||||
FROM Shop_Product_Permutation_Temp PP_T
|
||||
LEFT JOIN Shop_Product_Permutation PP ON PP_T.id_permutation = PP.id_permutation
|
||||
@@ -162,67 +166,77 @@ BEGIN
|
||||
-- id_product
|
||||
IF EXISTS (SELECT * FROM tmp_Permutation t_P WHERE ISNULL(t_P.id_product) LIMIT 1) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid
|
||||
, id_type
|
||||
, id_product
|
||||
id_type
|
||||
, code
|
||||
, msg
|
||||
)
|
||||
SELECT
|
||||
a_guid AS GUID
|
||||
, v_id_type_error_bad_data
|
||||
v_id_type_error_bad_data
|
||||
, v_code_type_error_bad_data
|
||||
, CONCAT('The following product permutation(s) do not have a product: ', GROUP_CONCAT(IFNULL(t_P.name_error, 'NULL') SEPARATOR ', ')) AS msg
|
||||
, CONCAT('The following product permutation(s) do not have a product: ', GROUP_CONCAT(t_P.name_error SEPARATOR ', ')) AS msg
|
||||
FROM tmp_Permutation t_P
|
||||
WHERE ISNULL(t_P.id_product)
|
||||
;
|
||||
END IF;
|
||||
-- cost_local
|
||||
IF EXISTS (SELECT * FROM tmp_Permutation t_P WHERE ISNULL(t_P.cost_local) LIMIT 1) THEN
|
||||
-- cost_local_VAT_excl
|
||||
IF EXISTS (SELECT * FROM tmp_Permutation t_P WHERE NOT ISNULL(t_P.cost_local_VAT_excl) AND t_P.cost_local_VAT_excl < 0 LIMIT 1) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid
|
||||
, id_type
|
||||
, cost_local
|
||||
id_type
|
||||
, code
|
||||
, msg
|
||||
)
|
||||
SELECT
|
||||
a_guid AS GUID
|
||||
, v_id_type_error_bad_data
|
||||
v_id_type_error_bad_data
|
||||
, v_code_type_error_bad_data
|
||||
, CONCAT('The following product permutation(s) do not have a local cost: ', GROUP_CONCAT(IFNULL(t_P.name_error, 'NULL') SEPARATOR ', ')) AS msg
|
||||
, CONCAT('The following product permutation(s) do not have a valid local cost excluding VAT: ', GROUP_CONCAT(t_P.name_error SEPARATOR ', ')) AS msg
|
||||
FROM tmp_Permutation t_P
|
||||
WHERE ISNULL(t_P.cost_local)
|
||||
WHERE NOT ISNULL(t_P.cost_local_VAT_excl) AND t_P.cost_local_VAT_excl < 0
|
||||
;
|
||||
END IF;
|
||||
-- cost_local_VAT_incl
|
||||
IF EXISTS (SELECT * FROM tmp_Permutation t_P WHERE NOT ISNULL(t_P.cost_local_VAT_incl) AND t_P.cost_local_VAT_incl < 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 product permutation(s) do not have a valid local cost including VAT: ', GROUP_CONCAT(t_P.name_error SEPARATOR ', ')) AS msg
|
||||
FROM tmp_Permutation t_P
|
||||
WHERE NOT ISNULL(t_P.cost_local_VAT_incl) AND t_P.cost_local_VAT_incl < 0
|
||||
;
|
||||
END IF;
|
||||
-- profit_local_min
|
||||
IF EXISTS (SELECT * FROM tmp_Permutation t_P WHERE ISNULL(t_P.profit_local_min) LIMIT 1) THEN
|
||||
IF EXISTS (SELECT * FROM tmp_Permutation t_P WHERE NOT ISNULL(t_P.profit_local_min) AND t_P.profit_local_min < 0 LIMIT 1) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid
|
||||
, id_type
|
||||
, profit_local_min
|
||||
id_type
|
||||
, code
|
||||
, msg
|
||||
)
|
||||
SELECT
|
||||
a_guid AS GUID
|
||||
, v_id_type_error_bad_data
|
||||
v_id_type_error_bad_data
|
||||
, v_code_type_error_bad_data
|
||||
, CONCAT('The following product permutation(s) do not have a local minimum profit: ', GROUP_CONCAT(IFNULL(t_P.name_error, 'NULL') SEPARATOR ', ')) AS msg
|
||||
, CONCAT('The following product permutation(s) do not have a local minimum profit: ', GROUP_CONCAT(t_P.name_error SEPARATOR ', ')) AS msg
|
||||
FROM tmp_Permutation t_P
|
||||
WHERE ISNULL(t_P.profit_local_min)
|
||||
WHERE NOT ISNULL(t_P.profit_local_min) AND t_P.profit_local_min < 0
|
||||
;
|
||||
END IF;
|
||||
|
||||
SELECT 'NIPS';
|
||||
|
||||
-- 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
|
||||
id_type
|
||||
, code
|
||||
, msg
|
||||
)
|
||||
SELECT
|
||||
a_guid AS GUID
|
||||
, v_id_type_error_bad_data
|
||||
v_id_type_error_bad_data
|
||||
, 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
|
||||
, CONCAT('The following product permutation(s) do not have a manufacturing latency: ', GROUP_CONCAT(t_P.name_error SEPARATOR ', ')) AS msg
|
||||
FROM tmp_Permutation t_P
|
||||
WHERE ISNULL(t_P.latency_manufacture)
|
||||
;
|
||||
@@ -230,16 +244,14 @@ BEGIN
|
||||
-- id_unit_measurement_quantity
|
||||
IF EXISTS (SELECT * FROM tmp_Permutation t_P WHERE ISNULL(t_P.id_unit_measurement_quantity) LIMIT 1) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid
|
||||
, id_type
|
||||
, id_unit_measurement_quantity
|
||||
id_type
|
||||
, code
|
||||
, msg
|
||||
)
|
||||
SELECT
|
||||
a_guid AS GUID
|
||||
, v_id_type_error_bad_data
|
||||
v_id_type_error_bad_data
|
||||
, v_code_type_error_bad_data
|
||||
, CONCAT('The following product permutation(s) do not have a unit measurement for stock quantities: ', GROUP_CONCAT(IFNULL(t_P.name_error, 'NULL') SEPARATOR ', ')) AS msg
|
||||
, CONCAT('The following product permutation(s) do not have a unit measurement for stock quantities: ', GROUP_CONCAT(t_P.name_error SEPARATOR ', ')) AS msg
|
||||
FROM tmp_Permutation t_P
|
||||
WHERE ISNULL(t_P.id_unit_measurement_quantity)
|
||||
;
|
||||
@@ -247,16 +259,14 @@ BEGIN
|
||||
-- count_unit_measurement_per_quantity_step
|
||||
IF EXISTS (SELECT * FROM tmp_Permutation t_P WHERE ISNULL(t_P.count_unit_measurement_per_quantity_step) LIMIT 1) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid
|
||||
, id_type
|
||||
, count_unit_measurement_per_quantity_step
|
||||
id_type
|
||||
, code
|
||||
, msg
|
||||
)
|
||||
SELECT
|
||||
a_guid AS GUID
|
||||
, v_id_type_error_bad_data
|
||||
v_id_type_error_bad_data
|
||||
, v_code_type_error_bad_data
|
||||
, CONCAT('The following product permutation(s) do not have a count unit measurement per quantity step: ', GROUP_CONCAT(IFNULL(t_P.name_error, 'NULL') SEPARATOR ', ')) AS msg
|
||||
, CONCAT('The following product permutation(s) do not have a count unit measurement per quantity step: ', GROUP_CONCAT(t_P.name_error SEPARATOR ', ')) AS msg
|
||||
FROM tmp_Permutation t_P
|
||||
WHERE ISNULL(t_P.count_unit_measurement_per_quantity_step)
|
||||
;
|
||||
@@ -264,16 +274,14 @@ BEGIN
|
||||
-- quantity_min
|
||||
IF EXISTS (SELECT * FROM tmp_Permutation t_P WHERE ISNULL(t_P.quantity_min) LIMIT 1) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid
|
||||
, id_type
|
||||
, quantity_min
|
||||
id_type
|
||||
, code
|
||||
, msg
|
||||
)
|
||||
SELECT
|
||||
a_guid AS GUID
|
||||
, v_id_type_error_bad_data
|
||||
v_id_type_error_bad_data
|
||||
, v_code_type_error_bad_data
|
||||
, CONCAT('The following product permutation(s) do not have a minimum quantity: ', GROUP_CONCAT(IFNULL(t_P.name_error, 'NULL') SEPARATOR ', ')) AS msg
|
||||
, CONCAT('The following product permutation(s) do not have a minimum quantity: ', GROUP_CONCAT(t_P.name_error SEPARATOR ', ')) AS msg
|
||||
FROM tmp_Permutation t_P
|
||||
WHERE ISNULL(t_P.quantity_min)
|
||||
;
|
||||
@@ -281,16 +289,14 @@ BEGIN
|
||||
-- quantity_max
|
||||
IF EXISTS (SELECT * FROM tmp_Permutation t_P WHERE ISNULL(t_P.quantity_max) LIMIT 1) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid
|
||||
, id_type
|
||||
, quantity_max
|
||||
id_type
|
||||
, code
|
||||
, msg
|
||||
)
|
||||
SELECT
|
||||
a_guid AS GUID
|
||||
, v_id_type_error_bad_data
|
||||
v_id_type_error_bad_data
|
||||
, v_code_type_error_bad_data
|
||||
, CONCAT('The following product permutation(s) do not have a maximum quantity: ', GROUP_CONCAT(IFNULL(t_P.name_error, 'NULL') SEPARATOR ', ')) AS msg
|
||||
, CONCAT('The following product permutation(s) do not have a maximum quantity: ', GROUP_CONCAT(t_P.name_error SEPARATOR ', ')) AS msg
|
||||
FROM tmp_Permutation t_P
|
||||
WHERE ISNULL(t_P.quantity_max)
|
||||
;
|
||||
@@ -298,16 +304,14 @@ BEGIN
|
||||
-- is_subscription
|
||||
IF EXISTS (SELECT * FROM tmp_Permutation t_P WHERE ISNULL(t_P.is_subscription) LIMIT 1) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid
|
||||
, id_type
|
||||
, is_subscription
|
||||
id_type
|
||||
, code
|
||||
, msg
|
||||
)
|
||||
SELECT
|
||||
a_guid AS GUID
|
||||
, v_id_type_error_bad_data
|
||||
v_id_type_error_bad_data
|
||||
, v_code_type_error_bad_data
|
||||
, CONCAT('The following product permutation(s) do not have an is subscription?: ', GROUP_CONCAT(IFNULL(t_P.name_error, 'NULL') SEPARATOR ', ')) AS msg
|
||||
, CONCAT('The following product permutation(s) do not have an is subscription?: ', GROUP_CONCAT(t_P.name_error SEPARATOR ', ')) AS msg
|
||||
FROM tmp_Permutation t_P
|
||||
WHERE ISNULL(t_P.is_subscription)
|
||||
;
|
||||
@@ -315,68 +319,82 @@ BEGIN
|
||||
-- does_expire_faster_once_unsealed
|
||||
IF EXISTS (SELECT * FROM tmp_Permutation t_P WHERE ISNULL(t_P.does_expire_faster_once_unsealed) LIMIT 1) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid
|
||||
, id_type
|
||||
, does_expire_faster_once_unsealed
|
||||
id_type
|
||||
, code
|
||||
, msg
|
||||
)
|
||||
SELECT
|
||||
a_guid AS GUID
|
||||
, v_id_type_error_bad_data
|
||||
v_id_type_error_bad_data
|
||||
, v_code_type_error_bad_data
|
||||
, CONCAT('The following product permutation(s) do not have a does expire faster once unsealed: ', GROUP_CONCAT(IFNULL(t_P.name_error, 'NULL') SEPARATOR ', ')) AS msg
|
||||
, CONCAT('The following product permutation(s) do not have a does expire faster once unsealed: ', GROUP_CONCAT(t_P.name_error SEPARATOR ', ')) AS msg
|
||||
FROM tmp_Permutation t_P
|
||||
WHERE ISNULL(t_P.does_expire_faster_once_unsealed)
|
||||
;
|
||||
END IF;
|
||||
|
||||
-- Permissions
|
||||
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error LIMIT 1) THEN -- (SELECT * FROM tmp_Product WHERE is_new = 0 LIMIT 1) THEN
|
||||
SET v_ids_product_permission := (
|
||||
SELECT GROUP_CONCAT(P.id_product SEPARATOR ',')
|
||||
FROM Shop_Product P
|
||||
INNER JOIN tmp_Permutation t_P
|
||||
ON P.id_product = t_P.id_product
|
||||
-- AND t_P.is_new = 0
|
||||
);
|
||||
IF NOT ISNULL(v_ids_product_permission) THEN
|
||||
SET v_id_permission_product = (SELECT id_permission FROM Shop_Permission WHERE code = 'STORE_PRODUCT' LIMIT 1);
|
||||
|
||||
CALL p_shop_calc_user(a_guid, a_id_user, FALSE, v_id_permission_product, v_id_access_level_edit, v_ids_product_permission);
|
||||
|
||||
UPDATE tmp_Permutation t_P
|
||||
INNER JOIN Shop_Product P ON t_P.id_product = P.id_product
|
||||
INNER JOIN Shop_Calc_User_Temp UE_T
|
||||
ON P.id_product = UE_T.id_product
|
||||
AND UE_T.GUID = a_guid
|
||||
SET
|
||||
t_P.can_view = UE_T.can_view
|
||||
, t_P.can_edit = UE_T.can_edit
|
||||
, t_P.can_admin = UE_T.can_admin
|
||||
;
|
||||
|
||||
CALL p_shop_clear_calc_user(a_guid);
|
||||
|
||||
IF EXISTS (SELECT * FROM tmp_Permutation t_P WHERE ISNULL(t_P.can_edit) LIMIT 1) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid
|
||||
, id_type
|
||||
, code
|
||||
, msg
|
||||
)
|
||||
SELECT
|
||||
a_guid AS GUID
|
||||
, v_id_type_error_bad_data
|
||||
, v_code_type_error_bad_data
|
||||
, CONCAT('The following product permutation(s) do not have product edit permission: ', GROUP_CONCAT(IFNULL(t_P.name_error, 'NULL') SEPARATOR ', ')) AS msg
|
||||
FROM tmp_Permutation t_P
|
||||
WHERE ISNULL(t_P.can_edit)
|
||||
;
|
||||
END IF;
|
||||
END IF;
|
||||
SET v_ids_product_permission := (
|
||||
SELECT GROUP_CONCAT(P.id_product SEPARATOR ',')
|
||||
FROM Shop_Product P
|
||||
INNER JOIN tmp_Permutation t_P
|
||||
ON P.id_product = t_P.id_product
|
||||
-- AND t_P.is_new = 0
|
||||
);
|
||||
|
||||
SET v_id_permission_product = (SELECT id_permission FROM Shop_Permission WHERE code = 'STORE_PRODUCT' LIMIT 1);
|
||||
|
||||
IF a_debug = 1 THEN
|
||||
SELECT
|
||||
a_guid
|
||||
, a_id_user
|
||||
, FALSE AS a_get_inactive_user
|
||||
, v_id_permission_product
|
||||
, v_id_access_level_edit
|
||||
, v_ids_product_permission
|
||||
, 0 AS a_debug
|
||||
;
|
||||
END IF;
|
||||
|
||||
SET v_now := CURRENT_DATETIME();
|
||||
CALL p_shop_calc_user(
|
||||
a_guid
|
||||
, a_id_user
|
||||
, FALSE -- a_get_inactive_user
|
||||
, v_id_permission_product
|
||||
, v_id_access_level_edit
|
||||
, v_ids_product_permission
|
||||
, 0 -- a_debug
|
||||
);
|
||||
|
||||
UPDATE tmp_Permutation t_P
|
||||
INNER JOIN Shop_Product P ON t_P.id_product = P.id_product
|
||||
INNER JOIN Shop_Calc_User_Temp UE_T
|
||||
ON P.id_product = UE_T.id_product
|
||||
AND UE_T.GUID = a_guid
|
||||
SET
|
||||
t_P.can_view = UE_T.can_view
|
||||
, t_P.can_edit = UE_T.can_edit
|
||||
, t_P.can_admin = UE_T.can_admin
|
||||
;
|
||||
|
||||
CALL p_shop_clear_calc_user(
|
||||
a_guid
|
||||
, 0 -- a_debug
|
||||
);
|
||||
|
||||
IF EXISTS (SELECT * FROM tmp_Permutation t_P WHERE ISNULL(t_P.can_edit) 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 product permutation(s) do not have product edit permission: ', GROUP_CONCAT(t_P.name_error SEPARATOR ', ')) AS msg
|
||||
FROM tmp_Permutation t_P
|
||||
WHERE ISNULL(t_P.can_edit)
|
||||
;
|
||||
END IF;
|
||||
|
||||
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error LIMIT 1) THEN
|
||||
START TRANSACTION;
|
||||
@@ -393,7 +411,8 @@ BEGIN
|
||||
SET
|
||||
PP.id_product = t_P.id_product
|
||||
, PP.description = t_P.description
|
||||
, PP.cost_local = t_P.cost_local
|
||||
, PP.cost_local_VAT_excl = t_P.cost_local_VAT_excl
|
||||
, PP.cost_local_VAT_incl = t_P.cost_local_VAT_incl
|
||||
, PP.id_currency_cost = t_P.id_currency_cost
|
||||
, PP.profit_local_min = t_P.profit_local_min
|
||||
, PP.latency_manufacture = t_P.latency_manufacture
|
||||
@@ -417,7 +436,8 @@ BEGIN
|
||||
INSERT INTO Shop_Product_Permutation (
|
||||
id_product
|
||||
, description
|
||||
, cost_local
|
||||
, cost_local_VAT_excl
|
||||
, cost_local_VAT_incl
|
||||
, id_currency_cost
|
||||
, profit_local_min
|
||||
, latency_manufacture
|
||||
@@ -440,7 +460,8 @@ BEGIN
|
||||
SELECT
|
||||
t_P.id_product AS id_product
|
||||
, t_P.description AS description
|
||||
, t_P.cost_local AS cost_local
|
||||
, t_P.cost_local_VAT_excl AS cost_local_VAT_excl
|
||||
, t_P.cost_local_VAT_incl AS cost_local_VAT_incl
|
||||
, t_P.id_currency_cost AS id_currency_cost
|
||||
, t_P.profit_local_min AS profit_local_min
|
||||
, t_P.latency_manufacture AS latency_manufacture
|
||||
@@ -458,7 +479,7 @@ BEGIN
|
||||
, t_P.count_interval_expiration_unsealed AS count_interval_expiration_unsealed
|
||||
, t_P.active AS active
|
||||
, a_id_user AS created_by
|
||||
, v_now AS created_on
|
||||
, v_time_start AS created_on
|
||||
FROM tmp_Permutation t_P
|
||||
WHERE
|
||||
is_new = 1
|
||||
@@ -471,10 +492,22 @@ BEGIN
|
||||
COMMIT;
|
||||
END IF;
|
||||
|
||||
SELECT * FROM tmp_Msg_Error;
|
||||
# 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
|
||||
;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Permutation;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Msg_Error;
|
||||
IF a_debug = 1 THEN
|
||||
SELECT * from tmp_Permutation;
|
||||
END IF;
|
||||
|
||||
DROP TEMPORARY TABLE tmp_Permutation;
|
||||
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 ;;
|
||||
|
||||
|
||||
124
static/MySQL/7206_p_shop_save_product_permutation_test.sql
Normal file
124
static/MySQL/7206_p_shop_save_product_permutation_test.sql
Normal file
@@ -0,0 +1,124 @@
|
||||
|
||||
|
||||
-- Clear previous proc
|
||||
DROP PROCEDURE IF EXISTS partsltd_prod.p_shop_save_product_permutation_test;
|
||||
|
||||
|
||||
DELIMITER //
|
||||
CREATE PROCEDURE p_shop_save_product_permutation_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_Product_Permutation
|
||||
;
|
||||
SELECT *
|
||||
FROM partsltd_prod.Shop_Product_Permutation_Temp
|
||||
;
|
||||
|
||||
START TRANSACTION;
|
||||
|
||||
INSERT INTO partsltd_prod.Shop_Product_Permutation_Temp (
|
||||
id_permutation
|
||||
, id_product
|
||||
, description
|
||||
, cost_local_VAT_excl
|
||||
, cost_local_VAT_incl
|
||||
, id_currency_cost
|
||||
, profit_local_min
|
||||
, latency_manufacture
|
||||
, id_unit_measurement_quantity
|
||||
, count_unit_measurement_per_quantity_step
|
||||
, quantity_min
|
||||
, quantity_max
|
||||
, quantity_stock
|
||||
, is_subscription
|
||||
, id_unit_measurement_interval_recurrence
|
||||
, count_interval_recurrence
|
||||
, id_stripe_product
|
||||
, does_expire_faster_once_unsealed
|
||||
, id_unit_measurement_interval_expiration_unsealed
|
||||
, count_interval_expiration_unsealed
|
||||
, active
|
||||
, guid
|
||||
)
|
||||
VALUES
|
||||
/* Test 1 - Insert */
|
||||
(
|
||||
-1 -- id_permutation
|
||||
, 8 -- id_product
|
||||
, 'Hair clip' -- description
|
||||
, NULL -- cost_local_VAT_excl
|
||||
, NULL -- cost_local_VAT_incl
|
||||
, 1 -- id_currency_cost
|
||||
, NULL -- profit_local_min
|
||||
, 1 -- latency_manufacture
|
||||
, 3 -- id_unit_measurement_quantity
|
||||
, 1 -- count_unit_measurement_per_quantity_step
|
||||
, 0 -- quantity_min
|
||||
, 0 -- quantity_max
|
||||
, 2 -- quantity_stock
|
||||
, FALSE -- is_subscription
|
||||
, NULL -- id_unit_measurement_interval_recurrence
|
||||
, NULL -- count_interval_recurrence
|
||||
, NULL -- id_stripe_product
|
||||
, FALSE -- does_expire_faster_once_unsealed
|
||||
, NULL -- id_unit_measurement_interval_expiration_unsealed
|
||||
, NULL -- count_interval_expiration_unsealed
|
||||
, 1 -- active
|
||||
, v_guid
|
||||
)
|
||||
/* Test 2 - Update
|
||||
(
|
||||
4 -- id_product
|
||||
, 1 -- id_category
|
||||
, 'Laptops' -- name
|
||||
, 0 -- has_variations
|
||||
, 2 -- id_access_level_required
|
||||
, 2 -- display_order
|
||||
, 1 -- active
|
||||
, v_guid
|
||||
)
|
||||
*/
|
||||
;
|
||||
|
||||
COMMIT;
|
||||
|
||||
SELECT *
|
||||
FROM partsltd_prod.Shop_Product_Permutation_Temp
|
||||
WHERE GUID = v_guid
|
||||
;
|
||||
|
||||
CALL partsltd_prod.p_shop_save_product_permutation (
|
||||
'Test save product' -- comment
|
||||
, v_guid -- guid
|
||||
, 1 -- id_user
|
||||
, 1 -- debug
|
||||
);
|
||||
|
||||
SELECT *
|
||||
FROM partsltd_prod.Shop_Product_Permutation
|
||||
;
|
||||
SELECT *
|
||||
FROM partsltd_prod.Shop_Product_Permutation_Temp
|
||||
;
|
||||
|
||||
CALL partsltd_prod.p_debug_timing_reporting ( v_time_start );
|
||||
END //
|
||||
DELIMITER ;;
|
||||
|
||||
/*
|
||||
CALL partsltd_prod.p_shop_save_product_permutation_test ();
|
||||
|
||||
DELETE FROM partsltd_prod.Shop_Product_Permutation_Temp;
|
||||
|
||||
DROP TABLE IF EXISTS tmp_Msg_Error;
|
||||
|
||||
|
||||
SELECT * FROM partsltd_prod.Shop_Product
|
||||
*/
|
||||
@@ -429,7 +429,7 @@ BEGIN
|
||||
-- Transaction
|
||||
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error) THEN
|
||||
START TRANSACTION;
|
||||
INSERT INTO partsltd_prod.Shop_Sales_And_Purchasing_Change_Set (
|
||||
INSERT INTO partsltd_prod.Shop_User_Change_Set (
|
||||
comment
|
||||
, updated_last_by
|
||||
, updated_last_on
|
||||
|
||||
@@ -42,6 +42,7 @@ BEGIN
|
||||
, active
|
||||
, guid
|
||||
)
|
||||
/* Test 1 - Insert
|
||||
VALUES (
|
||||
-3
|
||||
, 1
|
||||
@@ -54,8 +55,26 @@ BEGIN
|
||||
, 'test url'
|
||||
, 1 -- active
|
||||
, v_guid
|
||||
);
|
||||
)
|
||||
*/
|
||||
/* Test 2 - Update */
|
||||
SELECT
|
||||
id_supplier
|
||||
, id_currency
|
||||
, name_company
|
||||
, 'Nat' AS name_contact
|
||||
, 'Butchery' AS department_contact
|
||||
, phone_number
|
||||
, fax
|
||||
, email
|
||||
, website
|
||||
, active
|
||||
, v_guid
|
||||
FROM partsltd_prod.Shop_Supplier S
|
||||
WHERE S.id_supplier = 2
|
||||
;
|
||||
|
||||
/*
|
||||
INSERT INTO partsltd_prod.Shop_Supplier_Address_Temp (
|
||||
id_address
|
||||
, id_supplier
|
||||
@@ -68,6 +87,7 @@ BEGIN
|
||||
, active
|
||||
, GUID
|
||||
)
|
||||
/ Test 1 - Insert
|
||||
VALUES (
|
||||
-4
|
||||
, -3
|
||||
@@ -80,7 +100,23 @@ BEGIN
|
||||
, 1
|
||||
, v_guid
|
||||
)
|
||||
/
|
||||
/ Test 2 - Update /
|
||||
SELECT
|
||||
id_address
|
||||
, id_supplier
|
||||
, id_region
|
||||
, postcode
|
||||
, address_line_1
|
||||
, address_line_2
|
||||
, city
|
||||
, county
|
||||
, active
|
||||
, v_guid
|
||||
FROM partsltd_prod.Shop_Supplier_Address SA
|
||||
WHERE SA.id_supplier = 2
|
||||
;
|
||||
*/
|
||||
|
||||
COMMIT;
|
||||
|
||||
@@ -118,14 +154,14 @@ BEGIN
|
||||
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)
|
||||
Cannot add or update a child row: a foreign key constraint fails (`partsltd_prod`.`shop_supplier`, CONSTRAINT `FK_Shop_Supplier_id_change_set` FOREIGN KEY (`id_change_set`) REFERENCES `shop_sales_and_purchasing_change_set` (`id_change_set`))
|
||||
|
||||
*/
|
||||
@@ -285,7 +285,7 @@ BEGIN
|
||||
'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
|
||||
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_stock > 0
|
||||
@@ -316,7 +316,7 @@ BEGIN
|
||||
'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
|
||||
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 (
|
||||
@@ -349,7 +349,7 @@ BEGIN
|
||||
'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
|
||||
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 (
|
||||
@@ -559,7 +559,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 = a_guid) THEN
|
||||
IF EXISTS (SELECT * FROM partsltd_prod.Shop_Calc_User_Temp UE_T WHERE UE_T.GUID = a_guid AND IFNULL(UE_T.can_view, 0) = 0) THEN
|
||||
DELETE FROM tmp_Msg_Error;
|
||||
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
@@ -567,11 +567,18 @@ BEGIN
|
||||
, code
|
||||
, msg
|
||||
)
|
||||
VALUES (
|
||||
SELECT
|
||||
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 '
|
||||
, GROUP_CONCAT(name SEPARATOR ', ')
|
||||
) AS msg
|
||||
FROM partsltd_prod.Shop_Permission PERM
|
||||
INNER JOIN partsltd_prod.Shop_Calc_User_Temp UE_T
|
||||
ON PERM.id_permission = UE_T.id_permission
|
||||
AND UE_T.GUID = a_guid
|
||||
AND IFNULL(UE_T.can_view, 0) = 0
|
||||
;
|
||||
END IF;
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ BEGIN
|
||||
, active
|
||||
, GUID
|
||||
)
|
||||
/* Test 1 - Insert
|
||||
/* Test 1 - Insert */
|
||||
VALUES (
|
||||
-1
|
||||
, 1
|
||||
@@ -47,7 +47,7 @@ BEGIN
|
||||
, 1
|
||||
, v_guid
|
||||
)
|
||||
*/
|
||||
/* Test 2 - Update
|
||||
SELECT
|
||||
id_order
|
||||
, id_supplier_ordered
|
||||
@@ -56,6 +56,7 @@ BEGIN
|
||||
, v_guid
|
||||
FROM partsltd_prod.Shop_Supplier_Purchase_Order
|
||||
WHERE id_order = 6
|
||||
*/
|
||||
;
|
||||
|
||||
INSERT INTO partsltd_prod.Shop_Supplier_Purchase_Order_Product_Link_Temp (
|
||||
@@ -72,7 +73,7 @@ BEGIN
|
||||
, cost_total_local_VAT_incl
|
||||
, GUID
|
||||
)
|
||||
/* Test 1 - Insert
|
||||
/* Test 1 - Insert */
|
||||
VALUES (
|
||||
-1
|
||||
, -1
|
||||
@@ -87,7 +88,7 @@ BEGIN
|
||||
, 6
|
||||
, v_guid
|
||||
)
|
||||
*/
|
||||
/* Test 2 - Update
|
||||
SELECT
|
||||
id_link
|
||||
, id_order
|
||||
@@ -103,6 +104,7 @@ BEGIN
|
||||
, v_guid
|
||||
FROM partsltd_prod.Shop_Supplier_Purchase_Order_Product_Link
|
||||
WHERE id_order = 6
|
||||
*/
|
||||
;
|
||||
|
||||
COMMIT;
|
||||
@@ -149,6 +151,7 @@ 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)
|
||||
|
||||
*/
|
||||
@@ -0,0 +1,149 @@
|
||||
|
||||
|
||||
-- Clear previous proc
|
||||
DROP PROCEDURE IF EXISTS partsltd_prod.p_shop_save_Manufacturing_purchase_order_test;
|
||||
|
||||
|
||||
DELIMITER //
|
||||
CREATE PROCEDURE p_shop_save_Manufacturing_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_Manufacturing_Purchase_Order
|
||||
;
|
||||
SELECT *
|
||||
FROM partsltd_prod.Shop_Manufacturing_Purchase_Order_Temp
|
||||
;
|
||||
SELECT *
|
||||
FROM partsltd_prod.Shop_Manufacturing_Purchase_Order_Product_Link
|
||||
;
|
||||
SELECT *
|
||||
FROM partsltd_prod.Shop_Manufacturing_Purchase_Order_Product_Link_Temp
|
||||
;
|
||||
|
||||
START TRANSACTION;
|
||||
|
||||
DELETE FROM partsltd_prod.Shop_Manufacturing_Purchase_Order_Temp;
|
||||
DELETE FROM partsltd_prod.Shop_Manufacturing_Purchase_Order_Product_Link_Temp;
|
||||
|
||||
INSERT INTO partsltd_prod.Shop_Manufacturing_Purchase_Order_Temp (
|
||||
id_order
|
||||
, id_currency
|
||||
, active
|
||||
, GUID
|
||||
)
|
||||
/* Test 1 - Insert */
|
||||
VALUES (
|
||||
-1
|
||||
, 1
|
||||
, 1
|
||||
, v_guid
|
||||
)
|
||||
/* Test 2: Alter
|
||||
SELECT
|
||||
id_order
|
||||
, id_currency
|
||||
, active
|
||||
, v_guid
|
||||
FROM partsltd_prod.Shop_Manufacturing_Purchase_Order
|
||||
WHERE id_order = 6
|
||||
*/
|
||||
;-- SELECT * FROM partsltd_prod.Shop_Unit_Measurement;
|
||||
|
||||
INSERT INTO partsltd_prod.Shop_Manufacturing_Purchase_Order_Product_Link_Temp (
|
||||
id_link
|
||||
, id_order
|
||||
, id_permutation
|
||||
, id_unit_quantity
|
||||
, quantity_used
|
||||
, quantity_produced
|
||||
, id_unit_latency_manufacture
|
||||
, latency_manufacture
|
||||
, display_order
|
||||
, active
|
||||
, GUID
|
||||
)
|
||||
/* Test 1 - Insert */
|
||||
VALUES (
|
||||
-1 -- id_link
|
||||
, -1 -- id_order
|
||||
, 3 -- id_permutation
|
||||
, 3 -- id_unit_quantity
|
||||
, 3 -- quantity_used
|
||||
, 0 -- quantity_produced
|
||||
, 4 -- id_unit_latency_manufacture
|
||||
, 4 -- latency_manufacture
|
||||
, 1 -- display_order
|
||||
, 1 -- active
|
||||
, v_guid --
|
||||
)
|
||||
/* Test 2: Alter
|
||||
SELECT
|
||||
id_link
|
||||
, id_order
|
||||
, id_permutation
|
||||
, id_unit_quantity
|
||||
, quantity_used
|
||||
, quantity_produced
|
||||
, id_unit_latency_manufacture
|
||||
, latency_manufacture
|
||||
, display_order
|
||||
, active
|
||||
, v_guid
|
||||
FROM partsltd_prod.Shop_Manufacturing_Purchase_Order_Product_Link
|
||||
WHERE id_order = 6
|
||||
*/
|
||||
;
|
||||
|
||||
COMMIT;
|
||||
|
||||
SELECT *
|
||||
FROM partsltd_prod.Shop_Manufacturing_Purchase_Order_Temp
|
||||
WHERE GUID = v_guid
|
||||
;
|
||||
|
||||
SELECT *
|
||||
FROM partsltd_prod.Shop_Manufacturing_Purchase_Order_Product_Link_Temp
|
||||
WHERE GUID = v_guid
|
||||
;
|
||||
|
||||
CALL partsltd_prod.p_shop_save_Manufacturing_purchase_order (
|
||||
'Test save Manufacturing Purchase Order' -- comment
|
||||
, v_guid -- guid
|
||||
, 1 -- id_user
|
||||
, 1 -- debug
|
||||
);
|
||||
|
||||
SELECT *
|
||||
FROM partsltd_prod.Shop_Manufacturing_Purchase_Order_Temp
|
||||
;
|
||||
SELECT *
|
||||
FROM partsltd_prod.Shop_Manufacturing_Purchase_Order_Product_Link_Temp
|
||||
;
|
||||
SELECT *
|
||||
FROM partsltd_prod.Shop_Manufacturing_Purchase_Order
|
||||
;
|
||||
SELECT *
|
||||
FROM partsltd_prod.Shop_Manufacturing_Purchase_Order_Product_Link
|
||||
;
|
||||
|
||||
CALL partsltd_prod.p_debug_timing_reporting ( v_time_start );
|
||||
END //
|
||||
DELIMITER ;;
|
||||
|
||||
/*
|
||||
CALL partsltd_prod.p_shop_save_Manufacturing_purchase_order_test ();
|
||||
|
||||
DELETE FROM partsltd_prod.Shop_Manufacturing_Purchase_Order_Temp;
|
||||
DELETE FROM partsltd_prod.Shop_Manufacturing_Purchase_Order_Product_Link_Temp;
|
||||
|
||||
DROP TABLE IF EXISTS tmp_Msg_Error;
|
||||
|
||||
select * from partsltd_prod.Shop_User;
|
||||
*/
|
||||
@@ -18,11 +18,13 @@ CREATE PROCEDURE p_shop_save_manufacturing_purchase_order (
|
||||
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_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_id_type_error_warning INT;
|
||||
DECLARE v_ids_product_permission TEXT;
|
||||
DECLARE v_time_start TIMESTAMP(6);
|
||||
|
||||
@@ -64,6 +66,8 @@ BEGIN
|
||||
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_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);
|
||||
|
||||
@@ -77,28 +81,38 @@ BEGIN
|
||||
-- Temporary tables
|
||||
CREATE TEMPORARY TABLE tmp_Manufacturing_Purchase_Order (
|
||||
id_order INT NOT NULL PRIMARY KEY
|
||||
, id_currency_cost INT NOT NULL
|
||||
, id_order_temp INT NOT NULL
|
||||
, id_currency INT NOT NULL
|
||||
, active BIT NOT NULL
|
||||
, is_new BIT NOT NULL
|
||||
, name_error VARCHAR(1000) NOT NULL
|
||||
, cost_total_local_VAT_excl FLOAT NULL
|
||||
, cost_total_local_VAT_incl FLOAT NULL
|
||||
, price_total_local_VAT_excl FLOAT NULL
|
||||
, price_total_local_VAT_incl FLOAT NULL
|
||||
);
|
||||
|
||||
CREATE TEMPORARY TABLE tmp_Manufacturing_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_used FLOAT NOT NULL
|
||||
, id_product INT NULL
|
||||
, id_permutation INT NULL
|
||||
, id_currency INT NOT NULL
|
||||
, id_unit_quantity INT NOT NULL
|
||||
, quantity_used FLOAT 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
|
||||
, 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
|
||||
, cost_unit_local_VAT_excl FLOAT NULL
|
||||
, cost_unit_local_VAT_incl FLOAT NULL
|
||||
, cost_total_local_VAT_excl FLOAT NULL
|
||||
, cost_total_local_VAT_incl FLOAT NULL
|
||||
, price_unit_local_VAT_excl FLOAT NULL
|
||||
, price_unit_local_VAT_incl FLOAT NULL
|
||||
, price_total_local_VAT_excl FLOAT NULL
|
||||
, price_total_local_VAT_incl FLOAT NULL
|
||||
, has_order BIT NULL
|
||||
, is_new BIT NOT NULL
|
||||
, name_error VARCHAR(1000) NOT NULL
|
||||
@@ -113,21 +127,37 @@ BEGIN
|
||||
|
||||
INSERT INTO tmp_Manufacturing_Purchase_Order (
|
||||
id_order
|
||||
, id_currency_cost
|
||||
, id_order_temp
|
||||
, id_currency
|
||||
, active
|
||||
, is_new
|
||||
, name_error
|
||||
)
|
||||
SELECT
|
||||
SPO_T.id_order
|
||||
, IFNULL(IFNULL(SPO_T.id_currency_cost, MPO.id_currency_cost), 0) AS id_currency_cost
|
||||
FROM partsltd_prod.Shop_Manufacturing_Purchase_Order_Temp SPO_T
|
||||
LEFT JOIN partsltd_prod.Shop_Manufacturing_Purchase_Order MPO ON SPO_T.id_order = MPO.id_order
|
||||
WHERE SPO_T.GUID = a_guid
|
||||
MPO_T.id_order
|
||||
, MPO_T.id_order
|
||||
, IFNULL(IFNULL(MPO_T.id_currency, MPO.id_currency), 0) AS id_currency
|
||||
, IFNULL(IFNULL(MPO_T.active, MPO.active), 1) AS active
|
||||
, IFNULL(MPO_T.id_order, 0) < 1 AS is_new
|
||||
, CASE WHEN IFNULL(MPO_T.id_order, -1) < 0 THEN
|
||||
CONCAT('New Manufacturing Purchase Order ', MPO_T.id_order)
|
||||
ELSE
|
||||
CONCAT(
|
||||
IFNULL(IFNULL(MPO_T.id_order, MPO.id_order), '(No Manufacturing Purchase Order)')
|
||||
, ' - '
|
||||
, IFNULL(IFNULL(MPO_T.id_currency, MPO.id_currency), '(No Currency)')
|
||||
)
|
||||
END AS name_error
|
||||
FROM partsltd_prod.Shop_Manufacturing_Purchase_Order_Temp MPO_T
|
||||
LEFT JOIN partsltd_prod.Shop_Manufacturing_Purchase_Order MPO ON MPO_T.id_order = MPO.id_order
|
||||
WHERE MPO_T.GUID = a_guid
|
||||
;
|
||||
|
||||
INSERT INTO tmp_Manufacturing_Purchase_Order_Product_Link (
|
||||
id_link
|
||||
, id_order
|
||||
, id_product
|
||||
, id_permutation
|
||||
, id_currency_cost
|
||||
, id_unit_quantity
|
||||
, quantity_used
|
||||
, quantity_produced
|
||||
@@ -135,55 +165,126 @@ BEGIN
|
||||
, latency_manufacture
|
||||
, display_order
|
||||
, active
|
||||
, name_error
|
||||
, is_new
|
||||
, cost_total_local_VAT_excl
|
||||
, cost_total_local_VAT_incl
|
||||
, cost_unit_local_VAT_excl
|
||||
, cost_unit_local_VAT_incl
|
||||
, price_unit_local_VAT_excl
|
||||
, price_unit_local_VAT_incl
|
||||
, has_order
|
||||
, is_new
|
||||
)
|
||||
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_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_unit_quantity, MPOPL.id_unit_quantity), 0) AS id_unit_quantity
|
||||
, 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_used, '(No Quantity)')
|
||||
) AS name_error
|
||||
, IFNULL(SPOPL_T.id_link, 0) < 1 AS is_new
|
||||
, 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
|
||||
IFNULL(MPOPL_T.id_link, 0) AS id_link
|
||||
, IFNULL(IFNULL(MPOPL_T.id_order, MPOPL.id_order), 0) AS id_order
|
||||
, IFNULL(MPOPL_T.id_product, PP.id_product) AS id_product
|
||||
, IFNULL(
|
||||
IFNULL(
|
||||
IFNULL(
|
||||
MPOPL_T.id_permutation
|
||||
, CASE WHEN NOT ISNULL(MPOPL_T.id_product) AND NOT ISNULL(MPOPL_T.csv_list_variations) THEN
|
||||
partsltd_prod.fn_shop_get_id_product_permutation_from_variation_csv_list(MPOPL_T.id_product, MPOPL_T.csv_list_variations)
|
||||
ELSE NULL END
|
||||
)
|
||||
, MPOPL.id_permutation
|
||||
)
|
||||
, 0
|
||||
) AS id_permutation
|
||||
, IFNULL(IFNULL(MPOPL_T.id_unit_quantity, MPOPL.id_unit_quantity), 0) AS id_unit_quantity
|
||||
, MPOPL_T.quantity_used AS quantity_used
|
||||
, MPOPL_T.quantity_produced AS quantity_produced
|
||||
, MPOPL_T.id_unit_latency_manufacture AS id_unit_latency_manufacture
|
||||
, MPOPL_T.latency_manufacture AS latency_manufacture
|
||||
, IFNULL(MPOPL_T.display_order, RANK() OVER (PARTITION BY IFNULL(IFNULL(MPOPL_T.id_order, MPOPL.id_order), 0) ORDER BY IFNULL(IFNULL(MPOPL_T.display_order, MPOPL.display_order), 0))) AS display_order
|
||||
, IFNULL(IFNULL(MPOPL_T.active, MPOPL.active), 1) AS active
|
||||
-- , MPOPL_T.cost_total_local_VAT_excl / MPOPL_T.quantity_used AS cost_unit_local_VAT_excl
|
||||
-- , MPOPL_T.cost_total_local_VAT_incl / MPOPL_T.quantity_used AS cost_unit_local_VAT_incl
|
||||
, IFNULL(MPOPL_T.cost_unit_local_VAT_excl, MPOPL.cost_unit_local_VAT_excl) AS cost_unit_local_VAT_excl
|
||||
, IFNULL(MPOPL_T.cost_unit_local_VAT_incl, MPOPL.cost_unit_local_VAT_incl) AS cost_unit_local_VAT_incl
|
||||
, IFNULL(MPOPL_T.price_unit_local_VAT_excl, MPOPL.price_unit_local_VAT_excl) AS price_unit_local_VAT_excl
|
||||
, IFNULL(MPOPL_T.price_unit_local_VAT_incl, MPOPL.price_unit_local_VAT_incl) AS price_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
|
||||
LEFT JOIN tmp_Manufacturing_Purchase_Order t_MPO ON SPOPL_T.id_order = t_MPO.id_order
|
||||
WHERE SPOPL_T.GUID = a_guid
|
||||
, IFNULL(MPOPL_T.id_link, 0) < 1 AS is_new
|
||||
FROM partsltd_prod.Shop_Manufacturing_Purchase_Order_Product_Link_Temp MPOPL_T
|
||||
LEFT JOIN partsltd_prod.Shop_Manufacturing_Purchase_Order_Product_Link MPOPL ON MPOPL_T.id_link = MPOPL.id_link
|
||||
LEFT JOIN tmp_Manufacturing_Purchase_Order t_MPO ON MPOPL_T.id_order = t_MPO.id_order
|
||||
LEFT JOIN partsltd_prod.Shop_Product_Permutation PP ON MPOPL.id_permutation = PP.id_permutation
|
||||
WHERE MPOPL_T.GUID = a_guid
|
||||
;
|
||||
|
||||
UPDATE tmp_Manufacturing_Purchase_Order_Product_Link t_MPOPL
|
||||
-- INNER JOIN partsltd_prod.Shop_Manufacturing_Purchase_Order_Product_Link_Temp MPOPL_T ON t_MPOPL.id_order = MPOPL_T.id_order
|
||||
LEFT JOIN partsltd_prod.Shop_Product_Permutation PP ON t_MPOPL.id_permutation = PP.id_permutation
|
||||
LEFT JOIN partsltd_prod.Shop_Product P ON PP.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_MPOPL.id_permutation) THEN
|
||||
CASE WHEN ISNULL(PP.id_product) THEN
|
||||
'(No Product Permutation)'
|
||||
ELSE
|
||||
CONCAT(
|
||||
PC.name
|
||||
, ' - '
|
||||
, P.name
|
||||
)
|
||||
END
|
||||
ELSE
|
||||
fn_shop_get_product_permutation_name(PP.id_permutation)
|
||||
END
|
||||
, ' - x'
|
||||
, IFNULL(t_MPOPL.quantity_used, '(No Quantity)')
|
||||
, ' Used - x'
|
||||
, IFNULL(t_MPOPL.quantity_produced, '(No Quantity)')
|
||||
, ' Produced'
|
||||
)
|
||||
, cost_total_local_VAT_excl = t_MPOPL.quantity_used * t_MPOPL.cost_unit_local_VAT_excl
|
||||
, cost_total_local_VAT_incl = t_MPOPL.quantity_used * t_MPOPL.cost_unit_local_VAT_incl
|
||||
, price_total_local_VAT_excl = t_MPOPL.quantity_produced * t_MPOPL.price_unit_local_VAT_excl
|
||||
, price_total_local_VAT_incl = t_MPOPL.quantity_produced * t_MPOPL.price_unit_local_VAT_incl
|
||||
;
|
||||
|
||||
-- Insert missing order records
|
||||
INSERT INTO tmp_Manufacturing_Purchase_Order (
|
||||
id_order
|
||||
, id_currency_cost
|
||||
, id_order_temp
|
||||
, id_currency
|
||||
, active
|
||||
, is_new
|
||||
, name_error
|
||||
)
|
||||
SELECT
|
||||
SPO_T.id_order
|
||||
, IFNULL(IFNULL(SPO_T.id_currency_cost, MPO.id_currency_cost), 0) AS id_currency_cost
|
||||
MPO.id_order
|
||||
, MPO.id_order_temp
|
||||
, MPO.id_currency
|
||||
, MPO.active
|
||||
, FALSE AS is_new
|
||||
, CONCAT(
|
||||
IFNULL(MPO.id_order, '(No Manufacturing Purchase Order)')
|
||||
, ' - '
|
||||
, IFNULL(MPO.id_currency, '(No Currency)')
|
||||
) AS name_error
|
||||
FROM partsltd_prod.Shop_Manufacturing_Purchase_Order MPO
|
||||
INNER JOIN tmp_Manufacturing_Purchase_Order_Product_Link t_MPOPL
|
||||
ON MPO.id_order = t_MPOPL.id_order
|
||||
AND t_MPOPL.has_order = 0
|
||||
;
|
||||
|
||||
UPDATE tmp_Manufacturing_Purchase_Order t_MPO
|
||||
INNER JOIN (
|
||||
SELECT
|
||||
t_MPOPL.id_order
|
||||
, SUM(t_MPOPL.cost_total_local_VAT_excl) AS cost_total_local_VAT_excl
|
||||
, SUM(t_MPOPL.cost_total_local_VAT_incl) AS cost_total_local_VAT_incl
|
||||
, SUM(t_MPOPL.price_total_local_VAT_excl) AS price_total_local_VAT_excl
|
||||
, SUM(t_MPOPL.price_total_local_VAT_incl) AS price_total_local_VAT_incl
|
||||
FROM tmp_Manufacturing_Purchase_Order_Product_Link t_MPOPL
|
||||
GROUP BY t_MPOPL.id_order
|
||||
) SUM_t_MPOPL ON t_MPO.id_order = SUM_t_MPOPL.id_order
|
||||
SET
|
||||
t_MPO.cost_total_local_VAT_excl = SUM_t_MPOPL.cost_total_local_VAT_excl
|
||||
, t_MPO.cost_total_local_VAT_incl = SUM_t_MPOPL.cost_total_local_VAT_incl
|
||||
, t_MPO.price_total_local_VAT_excl = SUM_t_MPOPL.price_total_local_VAT_excl
|
||||
, t_MPO.price_total_local_VAT_incl = SUM_t_MPOPL.price_total_local_VAT_incl
|
||||
;
|
||||
|
||||
-- Validation
|
||||
-- Manufacturing Purchase Order
|
||||
@@ -207,20 +308,20 @@ BEGIN
|
||||
, v_code_type_error_bad_data
|
||||
, CONCAT(
|
||||
'A valid ID is required for the following Manufacturing Purchase Order(s): '
|
||||
, GROUP_CONCAT(CONCAT(IFNULL(t_MPO.id_stock, '(No Manufacturing Purchase Order)')) SEPARATOR ', ')
|
||||
, GROUP_CONCAT(t_MPO.name_error SEPARATOR ', ')
|
||||
) AS msg
|
||||
FROM tmp_Stock_Item t_SPO
|
||||
FROM tmp_Manufacturing_Purchase_Order t_MPO
|
||||
LEFT JOIN partsltd_prod.Shop_Manufacturing_Purchase_Order MPO ON t_MPO.id_order = MPO.id_order
|
||||
WHERE 1=1
|
||||
AND t_MPO.id_stock > 0
|
||||
AND ISNULL(MPO.id_stock)
|
||||
AND t_MPO.id_order > 0
|
||||
AND ISNULL(MPO.id_order)
|
||||
;
|
||||
END IF;
|
||||
# id_currency_cost
|
||||
# id_currency
|
||||
IF EXISTS (
|
||||
SELECT *
|
||||
FROM tmp_Manufacturing_Purchase_Order t_MPO
|
||||
LEFT JOIN partsltd_prod.Shop_Currency C ON t_MPO.id_currency_cost = C.id_currency
|
||||
LEFT JOIN partsltd_prod.Shop_Currency C ON t_MPO.id_currency = C.id_currency
|
||||
WHERE 1=1
|
||||
AND (
|
||||
ISNULL(C.id_currency)
|
||||
@@ -238,10 +339,10 @@ BEGIN
|
||||
, v_code_type_error_bad_data
|
||||
, CONCAT(
|
||||
'A valid currency is required for the following Manufacturing Purchase Order(s): '
|
||||
, GROUP_CONCAT(CONCAT(IFNULL(t_MPO.id_stock, '(No Manufacturing Purchase Order)'), ' - ', t_MPO.id_currency_cost) SEPARATOR ', ')
|
||||
, GROUP_CONCAT(CONCAT(t_MPO.name_error, ' - ', t_MPO.id_currency) SEPARATOR ', ')
|
||||
) AS msg
|
||||
FROM tmp_Stock_Item t_SPO
|
||||
LEFT JOIN partsltd_prod.Shop_Currency C ON t_MPO.id_currency_cost = C.id_currency
|
||||
FROM tmp_Manufacturing_Purchase_Order t_MPO
|
||||
LEFT JOIN partsltd_prod.Shop_Currency C ON t_MPO.id_currency = C.id_currency
|
||||
WHERE 1=1
|
||||
AND (
|
||||
ISNULL(C.id_currency)
|
||||
@@ -252,8 +353,8 @@ BEGIN
|
||||
# id_unit_quantity
|
||||
IF EXISTS (
|
||||
SELECT *
|
||||
FROM tmp_Manufacturing_Purchase_Order t_MPO
|
||||
LEFT JOIN partsltd_prod.Shop_Unit_Measurement UM ON t_MPO.id_unit_quantity = UM.id_unit_measurement
|
||||
FROM tmp_Manufacturing_Purchase_Order_Product_Link t_MPOPL
|
||||
LEFT JOIN partsltd_prod.Shop_Unit_Measurement UM ON t_MPOPL.id_unit_quantity = UM.id_unit_measurement
|
||||
WHERE 1=1
|
||||
AND (
|
||||
ISNULL(UM.id_unit_measurement)
|
||||
@@ -271,10 +372,10 @@ BEGIN
|
||||
, v_code_type_error_bad_data
|
||||
, CONCAT(
|
||||
'A valid unit measurement of quantity is required for the following Manufacturing Purchase Order(s): '
|
||||
, GROUP_CONCAT(CONCAT(IFNULL(t_MPO.id_stock, '(No Manufacturing Purchase Order)'), ' - ', t_MPO.id_currency_cost) SEPARATOR ', ')
|
||||
, GROUP_CONCAT(CONCAT(t_MPOPL.name_error, ' - ', t_MPO.id_unit_quantity) SEPARATOR ', ')
|
||||
) AS msg
|
||||
FROM tmp_Stock_Item t_SPO
|
||||
LEFT JOIN partsltd_prod.Shop_Unit_Measurement UM ON t_MPO.id_unit_quantity = UM.id_unit_measurement
|
||||
FROM tmp_Manufacturing_Purchase_Order_Product_Link t_MPOPL
|
||||
LEFT JOIN partsltd_prod.Shop_Unit_Measurement UM ON t_MPOPL.id_unit_quantity = UM.id_unit_measurement
|
||||
WHERE 1=1
|
||||
AND (
|
||||
ISNULL(UM.id_unit_measurement)
|
||||
@@ -282,10 +383,10 @@ BEGIN
|
||||
)
|
||||
;
|
||||
END IF;
|
||||
# Invalid quantity ordered
|
||||
# Invalid quantity used
|
||||
IF EXISTS (
|
||||
SELECT *
|
||||
FROM tmp_Manufacturing_Purchase_Order_Product_Link
|
||||
FROM tmp_Manufacturing_Purchase_Order_Product_Link t_MPOPL
|
||||
WHERE
|
||||
ISNULL(t_MPOPL.quantity_used)
|
||||
OR t_MPOPL.quantity_used <= 0
|
||||
@@ -297,20 +398,22 @@ BEGIN
|
||||
v_id_error_type_bad_data,
|
||||
v_code_error_type_bad_data,
|
||||
CONCAT(
|
||||
'A valid quantity ordered is required for the following Manufacturing Purchase Order Item(s): '
|
||||
, GROUP_CONCAT(t_MPOPL.name_error SEPARATOR ', ')
|
||||
'A valid quantity used is required for the following Manufacturing Purchase Order Item(s): '
|
||||
, GROUP_CONCAT(CONCAT(t_MPOPL.name_error, ' - ', t_MPOPL.quantity_used) SEPARATOR ', ')
|
||||
)
|
||||
FROM tmp_Manufacturing_Purchase_Order_Product_Link t_MPOPL
|
||||
WHERE
|
||||
ISNULL(t_MPOPL.quantity_used)
|
||||
OR t_MPOPL.quantity_used <= 0
|
||||
NOT ISNULL(t_MPOPL.quantity_used)
|
||||
AND t_MPOPL.quantity_used <= 0
|
||||
;
|
||||
END IF;
|
||||
# Invalid quantity received
|
||||
# Invalid quantity produced
|
||||
IF EXISTS (
|
||||
SELECT *
|
||||
FROM tmp_Manufacturing_Purchase_Order_Product_Link
|
||||
WHERE t_MPOPL.quantity_produced < 0
|
||||
FROM tmp_Manufacturing_Purchase_Order_Product_Link t_MPOPL
|
||||
WHERE
|
||||
NOT ISNULL(t_MPOPL.quantity_produced)
|
||||
AND t_MPOPL.quantity_produced < 0
|
||||
) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
id_type, code, msg
|
||||
@@ -319,24 +422,24 @@ BEGIN
|
||||
v_id_error_type_bad_data,
|
||||
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_produced SEPARATOR ', ')
|
||||
'A valid quantity produced is required for the following Manufacturing Purchase Order Item(s): '
|
||||
, GROUP_CONCAT(CONCAT(t_MPOPL.name_error, ' - ', t_MPOPL.quantity_produced) SEPARATOR ', ')
|
||||
)
|
||||
FROM tmp_Manufacturing_Purchase_Order_Product_Link t_MPOPL
|
||||
WHERE t_MPOPL.quantity_produced < 0
|
||||
WHERE
|
||||
NOT ISNULL(t_MPOPL.quantity_produced)
|
||||
AND t_MPOPL.quantity_produced < 0
|
||||
;
|
||||
END IF;
|
||||
# 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
|
||||
)
|
||||
FROM tmp_Manufacturing_Purchase_Order_Product_Link t_MPOPL
|
||||
LEFT JOIN partsltd_prod.Shop_Unit_Measurement UM ON t_MPOPL.id_unit_latency_manufacture = UM.id_unit_measurement
|
||||
WHERE
|
||||
ISNULL(t_MPOPL.id_unit_latency_manufacture)
|
||||
OR ISNULL(UM.id_unit_measurement)
|
||||
OR UM.active = 0
|
||||
LIMIT 1
|
||||
) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
@@ -349,22 +452,20 @@ BEGIN
|
||||
, 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 ', ')
|
||||
, GROUP_CONCAT(CONCAT(t_MPOPL.name_error, ' - ', t_MPOPL.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
|
||||
)
|
||||
FROM tmp_Manufacturing_Purchase_Order_Product_Link t_MPOPL
|
||||
LEFT JOIN partsltd_prod.Shop_Unit_Measurement UM ON t_MPOPL.id_unit_latency_manufacture = UM.id_unit_measurement
|
||||
WHERE
|
||||
ISNULL(t_MPOPL.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
|
||||
FROM tmp_Manufacturing_Purchase_Order_Product_Link t_MPOPL
|
||||
WHERE t_MPOPL.latency_manufacture < 0
|
||||
) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
@@ -375,13 +476,111 @@ BEGIN
|
||||
v_code_error_type_bad_data,
|
||||
CONCAT(
|
||||
'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 ', ')
|
||||
, GROUP_CONCAT(CONCAT(t_MPOPL.name_error, ' - ', t_MPOPL.latency_manufacture) SEPARATOR ', ')
|
||||
)
|
||||
FROM tmp_Manufacturing_Purchase_Order_Product_Link t_MPOPL
|
||||
WHERE t_MPOPL.latency_manufacture < 0
|
||||
;
|
||||
END IF;
|
||||
|
||||
# Invalid costs excl VAT
|
||||
IF EXISTS (
|
||||
SELECT *
|
||||
FROM tmp_Manufacturing_Purchase_Order_Product_Link t_MPOPL
|
||||
WHERE
|
||||
NOT ISNULL(t_MPOPL.cost_unit_local_VAT_excl)
|
||||
AND t_MPOPL.cost_unit_local_VAT_excl < 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 cost excluding VAT is required for the following Manufacturing Purchase Order Item(s): '
|
||||
, GROUP_CONCAT(CONCAT(t_MPOPL.name_error, ' - ', t_MPOPL.cost_unit_local_VAT_excl) SEPARATOR ', ')
|
||||
)
|
||||
FROM tmp_Manufacturing_Purchase_Order_Product_Link t_MPOPL
|
||||
WHERE
|
||||
NOT ISNULL(t_MPOPL.cost_unit_local_VAT_excl)
|
||||
AND t_MPOPL.cost_unit_local_VAT_excl < 0
|
||||
;
|
||||
END IF;
|
||||
# Invalid costs incl VAT
|
||||
IF EXISTS (
|
||||
SELECT *
|
||||
FROM tmp_Manufacturing_Purchase_Order_Product_Link t_MPOPL
|
||||
WHERE
|
||||
NOT ISNULL(t_MPOPL.cost_unit_local_VAT_incl)
|
||||
AND t_MPOPL.cost_unit_local_VAT_incl < 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 cost including VAT is required for the following Manufacturing Purchase Order Item(s): '
|
||||
, GROUP_CONCAT(CONCAT(t_MPOPL.name_error, ' - ', t_MPOPL.cost_unit_local_VAT_incl) SEPARATOR ', ')
|
||||
)
|
||||
FROM tmp_Manufacturing_Purchase_Order_Product_Link t_MPOPL
|
||||
WHERE
|
||||
NOT ISNULL(t_MPOPL.cost_unit_local_VAT_incl)
|
||||
AND t_MPOPL.cost_unit_local_VAT_incl < 0
|
||||
;
|
||||
END IF;
|
||||
|
||||
# Invalid prices excl VAT
|
||||
IF EXISTS (
|
||||
SELECT *
|
||||
FROM tmp_Manufacturing_Purchase_Order_Product_Link t_MPOPL
|
||||
WHERE
|
||||
NOT ISNULL(t_MPOPL.price_unit_local_VAT_excl)
|
||||
AND t_MPOPL.price_unit_local_VAT_excl < 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 price excluding VAT is required for the following Manufacturing Purchase Order Item(s): '
|
||||
, GROUP_CONCAT(CONCAT(t_MPOPL.name_error, ' - ', t_MPOPL.price_unit_local_VAT_excl) SEPARATOR ', ')
|
||||
)
|
||||
FROM tmp_Manufacturing_Purchase_Order_Product_Link t_MPOPL
|
||||
WHERE
|
||||
NOT ISNULL(t_MPOPL.price_unit_local_VAT_excl)
|
||||
AND t_MPOPL.price_unit_local_VAT_excl < 0
|
||||
;
|
||||
END IF;
|
||||
# Invalid prices incl VAT
|
||||
IF EXISTS (
|
||||
SELECT *
|
||||
FROM tmp_Manufacturing_Purchase_Order_Product_Link t_MPOPL
|
||||
WHERE
|
||||
NOT ISNULL(t_MPOPL.price_unit_local_VAT_incl)
|
||||
AND t_MPOPL.price_unit_local_VAT_incl < 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 price including VAT is required for the following Manufacturing Purchase Order Item(s): '
|
||||
, GROUP_CONCAT(CONCAT(t_MPOPL.name_error, ' - ', t_MPOPL.price_unit_local_VAT_incl) SEPARATOR ', ')
|
||||
)
|
||||
FROM tmp_Manufacturing_Purchase_Order_Product_Link t_MPOPL
|
||||
WHERE
|
||||
NOT ISNULL(t_MPOPL.price_unit_local_VAT_incl)
|
||||
AND t_MPOPL.price_unit_local_VAT_incl < 0
|
||||
;
|
||||
END IF;
|
||||
|
||||
-- Duplicates
|
||||
IF EXISTS (
|
||||
SELECT
|
||||
@@ -398,7 +597,7 @@ BEGIN
|
||||
SELECT
|
||||
v_id_error_type_bad_data,
|
||||
v_code_error_type_bad_data,
|
||||
CONCAT('Duplicate records: ', GROUP_CONCAT(t_SPOPLC.name_error SEPARATOR ', '))
|
||||
CONCAT('Duplicate records: ', GROUP_CONCAT(t_MPOPLC.name_error SEPARATOR ', '))
|
||||
FROM (
|
||||
SELECT
|
||||
id_permutation
|
||||
@@ -407,7 +606,7 @@ BEGIN
|
||||
FROM tmp_Manufacturing_Purchase_Order_Product_Link t_MPOPL
|
||||
GROUP BY id_permutation
|
||||
HAVING COUNT(*) > 1
|
||||
) t_SPOPLC
|
||||
) t_MPOPLC
|
||||
;
|
||||
END IF;
|
||||
-- Empty Manufacturing Purchase Order
|
||||
@@ -468,7 +667,10 @@ BEGIN
|
||||
, v_ids_product_permission -- ids_product
|
||||
, 0 -- a_debug
|
||||
;
|
||||
SELECT * from partsltd_prod.Shop_Calc_User_Temp;
|
||||
SELECT *
|
||||
FROM partsltd_prod.Shop_Calc_User_Temp
|
||||
WHERE GUID = a_guid
|
||||
;
|
||||
END IF;
|
||||
|
||||
CALL p_shop_calc_user(
|
||||
@@ -485,7 +687,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 = a_guid) THEN
|
||||
IF EXISTS (SELECT * FROM partsltd_prod.Shop_Calc_User_Temp UE_T WHERE UE_T.GUID = a_guid AND IFNULL(UE_T.can_view, 0) = 0) THEN
|
||||
DELETE FROM tmp_Msg_Error;
|
||||
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
@@ -493,18 +695,94 @@ BEGIN
|
||||
, code
|
||||
, msg
|
||||
)
|
||||
VALUES (
|
||||
SELECT
|
||||
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 '
|
||||
, GROUP_CONCAT(name SEPARATOR ', ')
|
||||
)
|
||||
FROM partsltd_prod.Shop_Permission PERM
|
||||
INNER JOIN partsltd_prod.Shop_Calc_User_Temp UE_T
|
||||
ON PERM.id_permission = UE_T.id_permission
|
||||
AND UE_T.GUID = a_guid
|
||||
AND IFNULL(UE_T.can_view, 0) = 0
|
||||
;
|
||||
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
|
||||
);
|
||||
|
||||
-- Changed quantity used
|
||||
IF EXISTS (
|
||||
SELECT *
|
||||
FROM tmp_Manufacturing_Purchase_Order_Product_Link t_MPOPL
|
||||
INNER JOIN partsltd_prod.Shop_Manufacturing_Purchase_Order_Product_Link MPOPL ON t_MPOPL.id_link = MPOPL.id_link
|
||||
INNER JOIN partsltd_prod.Shop_Stock_Item SI ON MPOPL.id_permutation = SI.id_permutation
|
||||
WHERE
|
||||
t_MPOPL.is_new = 0
|
||||
AND t_MPOPL.quantity_used <> MPOPL.quantity_used
|
||||
) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
id_type
|
||||
, code
|
||||
, msg
|
||||
)
|
||||
SELECT
|
||||
v_id_type_error_warning
|
||||
, v_code_type_error_warning
|
||||
, CONCAT(
|
||||
'The quantity used has changed on the following orders. Please update the stock items appropriately.'
|
||||
, GROUP_CONCAT(
|
||||
CONCAT(
|
||||
t_MPOPL.name_error
|
||||
, ' - from '
|
||||
, MPOPL.quantity_used
|
||||
, ' to '
|
||||
, t_MPOPL.quantity_used
|
||||
) SEPARATOR ', '
|
||||
)
|
||||
) AS msg
|
||||
;
|
||||
END IF;
|
||||
-- Changed quantity produced
|
||||
IF EXISTS (
|
||||
SELECT *
|
||||
FROM tmp_Manufacturing_Purchase_Order_Product_Link t_MPOPL
|
||||
INNER JOIN partsltd_prod.Shop_Manufacturing_Purchase_Order_Product_Link MPOPL ON t_MPOPL.id_link = MPOPL.id_link
|
||||
INNER JOIN partsltd_prod.Shop_Stock_Item SI ON MPOPL.id_permutation = SI.id_permutation
|
||||
WHERE
|
||||
t_MPOPL.is_new = 0
|
||||
AND t_MPOPL.quantity_produced <> MPOPL.quantity_produced
|
||||
) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
id_type
|
||||
, code
|
||||
, msg
|
||||
)
|
||||
SELECT
|
||||
v_id_type_error_warning
|
||||
, v_code_type_error_warning
|
||||
, CONCAT(
|
||||
'The quantity produced has changed on the following orders. Please update the stock items appropriately.'
|
||||
, GROUP_CONCAT(
|
||||
CONCAT(
|
||||
t_MPOPL.name_error
|
||||
, ' - from '
|
||||
, MPOPL.quantity_produced
|
||||
, ' to '
|
||||
, t_MPOPL.quantity_produced
|
||||
) SEPARATOR ', '
|
||||
)
|
||||
) AS msg
|
||||
;
|
||||
END IF;
|
||||
|
||||
IF EXISTS ( SELECT * FROM tmp_Msg_Error LIMIT 1 ) THEN
|
||||
DELETE FROM tmp_Manufacturing;
|
||||
IF EXISTS ( SELECT * FROM tmp_Msg_Error WHERE id_type <> v_id_type_error_warning LIMIT 1 ) THEN
|
||||
DELETE FROM tmp_Manufacturing_Purchase_Order_Product_Link;
|
||||
DELETE FROM tmp_Manufacturing_Purchase_Order;
|
||||
END IF;
|
||||
|
||||
-- Transaction
|
||||
@@ -524,31 +802,50 @@ BEGIN
|
||||
SET v_id_change_set := LAST_INSERT_ID();
|
||||
|
||||
INSERT INTO partsltd_prod.Shop_Manufacturing_Purchase_Order (
|
||||
id_currency_cost
|
||||
id_order_temp
|
||||
, id_currency
|
||||
, cost_total_local_VAT_excl
|
||||
, cost_total_local_VAT_incl
|
||||
, price_total_local_VAT_excl
|
||||
, price_total_local_VAT_incl
|
||||
, active
|
||||
, created_by
|
||||
, created_on
|
||||
, id_change_set
|
||||
, active
|
||||
)
|
||||
SELECT
|
||||
t_MPO.id_currency_cost
|
||||
, SUM(t_MPOPL.cost_total_local_VAT_excl)
|
||||
, SUM(t_MPOPL.cost_total_local_VAT_incl)
|
||||
t_MPO.id_order_temp
|
||||
, t_MPO.id_currency
|
||||
, t_MPO.cost_total_local_VAT_excl
|
||||
, t_MPO.cost_total_local_VAT_incl
|
||||
, t_MPO.price_total_local_VAT_excl
|
||||
, t_MPO.price_total_local_VAT_incl
|
||||
, t_MPO.active
|
||||
, a_id_user
|
||||
, v_time_start
|
||||
, v_id_change_set
|
||||
FROM tmp_Manufacturing_Purchase_Order t_MPO
|
||||
INNER JOIN tmp_Manufacturing_Purchase_Order_Product_Link t_MPOPL ON t_MPO.id_order = t_MPOPL.id_order
|
||||
WHERE t_MPOPL.is_new = 1
|
||||
WHERE t_MPO.is_new = 1
|
||||
;
|
||||
|
||||
UPDATE tmp_Manufacturing_Purchase_Order t_MPO
|
||||
INNER JOIN partsltd_prod.Shop_Manufacturing_Purchase_Order MPO ON t_MPO.id_order_temp = MPO.id_order_temp
|
||||
SET
|
||||
t_MPO.id_order = MPO.id_order
|
||||
WHERE t_MPO.is_new = 1
|
||||
;
|
||||
|
||||
UPDATE tmp_Manufacturing_Purchase_Order_Product_Link t_MPOPL
|
||||
INNER JOIN tmp_Manufacturing_Purchase_Order t_MPO ON t_MPOPL.id_order = t_MPO.id_order_temp
|
||||
SET
|
||||
t_MPOPL.id_order = t_MPO.id_order
|
||||
WHERE t_MPO.is_new = 1
|
||||
;
|
||||
|
||||
INSERT INTO Shop_Manufacturing_Purchase_Order_Product_Link (
|
||||
id_order
|
||||
, id_permutation
|
||||
, id_currency_cost
|
||||
, id_unit_quantity
|
||||
, quantity_used
|
||||
, quantity_produced
|
||||
@@ -556,15 +853,17 @@ BEGIN
|
||||
, latency_manufacture
|
||||
, display_order
|
||||
, active
|
||||
, cost_total_local_VAT_excl
|
||||
, cost_total_local_VAT_incl
|
||||
, cost_unit_local_VAT_excl
|
||||
, cost_unit_local_VAT_incl
|
||||
, price_unit_local_VAT_excl
|
||||
, price_unit_local_VAT_incl
|
||||
, created_by
|
||||
, created_on
|
||||
, id_change_set
|
||||
)
|
||||
SELECT
|
||||
t_MPOPL.id_order
|
||||
, t_MPOPL.id_permutation
|
||||
, t_MPOPL.id_currency_cost
|
||||
, t_MPOPL.id_unit_quantity
|
||||
, t_MPOPL.quantity_used
|
||||
, t_MPOPL.quantity_produced
|
||||
@@ -572,9 +871,12 @@ BEGIN
|
||||
, t_MPOPL.latency_manufacture
|
||||
, t_MPOPL.display_order
|
||||
, t_MPOPL.active
|
||||
, t_MPOPL.cost_total_local_VAT_excl
|
||||
, t_MPOPL.cost_total_local_VAT_incl
|
||||
, t_MPOPL.cost_unit_local_VAT_excl
|
||||
, t_MPOPL.cost_unit_local_VAT_incl
|
||||
, t_MPOPL.price_unit_local_VAT_excl
|
||||
, t_MPOPL.price_unit_local_VAT_incl
|
||||
, a_id_user
|
||||
, v_time_start
|
||||
, v_id_change_set
|
||||
FROM tmp_Manufacturing_Purchase_Order_Product_Link t_MPOPL
|
||||
WHERE t_MPOPL.is_new = 1
|
||||
@@ -586,10 +888,12 @@ BEGIN
|
||||
AND t_MPO.is_new = 0
|
||||
INNER JOIN tmp_Manufacturing_Purchase_Order_Product_Link t_MPOPL ON t_MPO.id_order = t_MPOPL.id_order
|
||||
SET
|
||||
MPO.id_currency_cost = id_currency_cost
|
||||
, MPO.cost_total_local_VAT_excl = SUM(t_MPOPL.cost_total_local_VAT_excl)
|
||||
, MPO.cost_total_local_VAT_incl = SUM(t_MPOPL.cost_total_local_VAT_incl)
|
||||
, MPO.active = a_active
|
||||
MPO.id_currency = t_MPO.id_currency
|
||||
, MPO.cost_total_local_VAT_excl = t_MPO.cost_total_local_VAT_excl
|
||||
, MPO.cost_total_local_VAT_incl = t_MPO.cost_total_local_VAT_incl
|
||||
, MPO.price_total_local_VAT_excl = t_MPO.price_total_local_VAT_excl
|
||||
, MPO.price_total_local_VAT_incl = t_MPO.price_total_local_VAT_incl
|
||||
, MPO.active = t_MPO.active
|
||||
, MPO.id_change_set = v_id_change_set
|
||||
;
|
||||
|
||||
@@ -600,7 +904,6 @@ BEGIN
|
||||
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
|
||||
@@ -608,18 +911,20 @@ BEGIN
|
||||
, 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.cost_unit_local_VAT_excl = t_MPOPL.cost_unit_local_VAT_excl
|
||||
, MPOPL.cost_unit_local_VAT_incl = t_MPOPL.cost_unit_local_VAT_incl
|
||||
, MPOPL.price_unit_local_VAT_excl = t_MPOPL.price_unit_local_VAT_excl
|
||||
, MPOPL.price_unit_local_VAT_incl = t_MPOPL.price_unit_local_VAT_incl
|
||||
, MPOPL.id_change_set = v_id_change_set
|
||||
;
|
||||
|
||||
DELETE SPO_T
|
||||
FROM Shop_Manufacturing_Purchase_Order_Temp SPO_T
|
||||
WHERE SPO_T.GUID = a_guid
|
||||
DELETE MPO_T
|
||||
FROM partsltd_prod.Shop_Manufacturing_Purchase_Order_Temp MPO_T
|
||||
WHERE MPO_T.GUID = a_guid
|
||||
;
|
||||
DELETE SPOPL_T
|
||||
FROM Shop_Manufacturing_Purchase_Order_Product_Link_Temp SPOPL_T
|
||||
WHERE SPOPL_T.GUID = a_guid
|
||||
DELETE MPOPL_T
|
||||
FROM partsltd_prod.Shop_Manufacturing_Purchase_Order_Product_Link_Temp MPOPL_T
|
||||
WHERE MPOPL_T.GUID = a_guid
|
||||
;
|
||||
|
||||
COMMIT;
|
||||
@@ -661,7 +966,7 @@ INSERT INTO Shop_Manufacturing_Purchase_Order_Product_Link_Temp (
|
||||
id_order,
|
||||
id_permutation,
|
||||
cost_total_local,
|
||||
id_currency_cost,
|
||||
id_currency,
|
||||
quantity_used,
|
||||
id_unit_quantity,
|
||||
quantity_produced,
|
||||
@@ -676,7 +981,7 @@ VALUES
|
||||
-1, # id_order,
|
||||
1, # id_permutation,
|
||||
100, # cost_total_local,
|
||||
1, # id_currency_cost,
|
||||
1, # id_currency,
|
||||
1, # quantity_used,
|
||||
1, # id_unit_quantity,
|
||||
1, # quantity_produced,
|
||||
|
||||
@@ -332,7 +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
|
||||
LEFT JOIN partsltd_prod.Shop_Currency C ON MPO.id_currency = C.id_currency
|
||||
;
|
||||
|
||||
# Manufacturing Purchase Order Product Link
|
||||
@@ -380,7 +380,6 @@ END //
|
||||
DELIMITER ;;
|
||||
|
||||
|
||||
/*
|
||||
|
||||
CALL p_shop_get_many_manufacturing_purchase_order (
|
||||
1 # a_id_user
|
||||
@@ -393,4 +392,5 @@ CALL p_shop_get_many_manufacturing_purchase_order (
|
||||
, 0 # a_debug
|
||||
);
|
||||
|
||||
/*
|
||||
*/
|
||||
|
||||
@@ -251,10 +251,11 @@ VALUES
|
||||
|
||||
# Product Permutations
|
||||
INSERT INTO Shop_Product_Permutation (
|
||||
display_order,
|
||||
-- display_order,
|
||||
id_product,
|
||||
description,
|
||||
cost_local,
|
||||
cost_local_VAT_excl,
|
||||
cost_local_VAT_incl,
|
||||
id_currency_cost,
|
||||
profit_local_min,
|
||||
# id_currency_profit_min,
|
||||
@@ -275,10 +276,11 @@ INSERT INTO Shop_Product_Permutation (
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
1,
|
||||
-- 1,
|
||||
1,
|
||||
'Good Red',
|
||||
5,
|
||||
6,
|
||||
1,
|
||||
3,
|
||||
# 1,
|
||||
@@ -298,10 +300,11 @@ VALUES
|
||||
, NULL
|
||||
),
|
||||
(
|
||||
2,
|
||||
-- 2,
|
||||
1,
|
||||
'Good Blue',
|
||||
6,
|
||||
7.2,
|
||||
1,
|
||||
4,
|
||||
# 1,
|
||||
@@ -321,10 +324,11 @@ VALUES
|
||||
, NULL
|
||||
),
|
||||
(
|
||||
3,
|
||||
-- 3,
|
||||
2,
|
||||
'Test product describes good',
|
||||
10,
|
||||
12,
|
||||
1,
|
||||
5,
|
||||
# 1,
|
||||
@@ -344,10 +348,11 @@ VALUES
|
||||
, NULL
|
||||
),
|
||||
(
|
||||
4,
|
||||
-- 4,
|
||||
3,
|
||||
'Phone describes good',
|
||||
10,
|
||||
12,
|
||||
1,
|
||||
5,
|
||||
# 1,
|
||||
@@ -367,10 +372,11 @@ VALUES
|
||||
, NULL
|
||||
),
|
||||
(
|
||||
5,
|
||||
-- 5,
|
||||
4,
|
||||
'Laptop describes good',
|
||||
10,
|
||||
12,
|
||||
1,
|
||||
5,
|
||||
# 1,
|
||||
@@ -390,10 +396,11 @@ VALUES
|
||||
, NULL
|
||||
),
|
||||
(
|
||||
6,
|
||||
-- 6,
|
||||
5,
|
||||
'Smart watch describes good',
|
||||
10,
|
||||
12,
|
||||
1,
|
||||
5,
|
||||
# 1,
|
||||
@@ -742,6 +749,18 @@ VALUES
|
||||
, 'https://www.maltkilnfarmshop.co.uk/'
|
||||
, 1
|
||||
)
|
||||
, (
|
||||
-3
|
||||
, 'Asda'
|
||||
, NULL
|
||||
, NULL
|
||||
-- , 1
|
||||
, ''
|
||||
, NULL
|
||||
, ''
|
||||
, ''
|
||||
, 1
|
||||
)
|
||||
;
|
||||
|
||||
# Supplier Addresses
|
||||
|
||||
@@ -187,6 +187,7 @@
|
||||
7204_p_shop_get_many_product.sql
|
||||
7205_p_shop_get_many_stripe_product_new.sql
|
||||
7206_p_shop_save_product_permutation.sql
|
||||
7206_p_shop_save_product_permutation_test.sql
|
||||
7210_p_shop_get_many_product_variation.sql
|
||||
7219_p_shop_get_many_stock_item.sql
|
||||
7220_p_shop_save_stock_item.sql
|
||||
@@ -203,6 +204,7 @@
|
||||
7403_p_shop_save_supplier_purchase_order_test.sql
|
||||
7404_p_shop_get_many_supplier_purchase_order.sql
|
||||
7415_p_shop_save_manufacturing_purchase_order.sql
|
||||
7415_p_shop_save_Manufacturing_purchase_order_test.sql
|
||||
7416_p_shop_get_many_manufacturing_purchase_order.sql
|
||||
7421_p_shop_save_customer.sql
|
||||
7422_p_shop_get_many_customer.sql
|
||||
|
||||
@@ -39,7 +39,6 @@ tr {
|
||||
min-height: 1px;
|
||||
border-bottom: 1px solid var(--c_purple_dark);
|
||||
border-top: 1px solid var(--c_purple_dark);
|
||||
padding-bottom: 1vh;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,4 +12,8 @@ form.filter button.save, form.filter button.button-cancel {
|
||||
form.filter button.save, form.filter button.button-cancel {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
#formFilters .container-input.filter.active {
|
||||
width: 8vh;
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
|
||||
#tableMain {
|
||||
overflow-x: auto;
|
||||
padding: 1vh 2vh;
|
||||
max-width: min(calc(1vh * 80), calc(1vw * 90));
|
||||
max-width: 95vw; /* min(calc(1vh * 80), calc(1vw * 90)); */
|
||||
width: fit-content;
|
||||
margin: 1vh 2vh;
|
||||
align-items: normal;
|
||||
@@ -12,4 +13,12 @@
|
||||
width: 20vh;
|
||||
min-width: 20vh;
|
||||
padding: 0 0.5vh;
|
||||
}
|
||||
#tableMain thead tr th.active, #tableMain tbody tr td.active {
|
||||
width: 6vh;
|
||||
min-width: 6vh;
|
||||
}
|
||||
#tableMain tbody tr td.display_order, #tableMain thead tr th.display_order {
|
||||
width: 5vh;
|
||||
min-width: 5vh;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
#formFilters {
|
||||
width: 50vh;
|
||||
width: 100vh;
|
||||
}
|
||||
|
||||
#formFilters .container-input.filter.active {
|
||||
@@ -11,6 +11,71 @@
|
||||
width: 8vh;
|
||||
}
|
||||
|
||||
|
||||
#tableMain tbody tr td.cost_total_local_vat_excl, #tableMain thead tr th.cost_total_local_vat_excl,
|
||||
#tableMain tbody tr td.cost_total_local_vat_incl, #tableMain thead tr th.cost_total_local_vat_incl {
|
||||
width: 10vh;
|
||||
min-width: 10vh;
|
||||
}
|
||||
|
||||
#tableMain thead tr th.order_items.collapsed,
|
||||
#tableMain tbody tr td.order_items.collapsed {
|
||||
width: 15vh;
|
||||
min-width: 15vh;
|
||||
}
|
||||
#tableMain:has(tbody tr td.order_items table thead tr th.product_variations.collapsed) thead tr th.order_items,
|
||||
#tableMain:has(tbody tr td.order_items table thead tr th.product_variations.collapsed) tbody tr td.order_items {
|
||||
width: 100vh; /* 95vh */
|
||||
min-width: 100vh;
|
||||
}
|
||||
#tableMain thead tr th.order_items,
|
||||
#tableMain tbody tr td.order_items {
|
||||
width: 110vh;
|
||||
min-width: 110vh;
|
||||
}
|
||||
#tableMain tbody tr td.order_items table thead tr th, #tableMain tbody tr td.order_items table tbody tr td {
|
||||
width: 12vh;
|
||||
min-width: 12vh;
|
||||
}
|
||||
#tableMain tbody tr td.order_items table thead tr th.display_order, #tableMain tbody tr td.order_items table tbody tr td.display_order {
|
||||
width: 5vh;
|
||||
min-width: 5vh;
|
||||
}
|
||||
#tableMain tbody tr td.order_items table thead tr th.id_unit_measurement_quantity, #tableMain tbody tr td.order_items table tbody tr td.id_unit_measurement_quantity,
|
||||
#tableMain tbody tr td.order_items table thead tr th.unit_measurement_latency_manufacture, #tableMain tbody tr td.order_items table tbody tr td.unit_measurement_latency_manufacture {
|
||||
width: 6vh;
|
||||
min-width: 6vh;
|
||||
}
|
||||
|
||||
#tableMain tbody tr td.order_items table thead tr th.product_variations.collapsed, #tableMain tbody tr td.order_items table tbody tr td.product_variations.collapsed {
|
||||
width: 10vh;
|
||||
min-width: 10vh;
|
||||
}
|
||||
#tableMain tbody tr td.order_items table thead tr th.product_variations, #tableMain tbody tr td.order_items table tbody tr td.product_variations {
|
||||
width: 20vh;
|
||||
min-width: 20vh;
|
||||
}
|
||||
#tableMain tbody tr td.order_items table tbody tr td.product_variations table thead tr th, #tableMain tbody tr td.order_items table tbody tr td.product_variations table tbody tr td {
|
||||
width: 8vh;
|
||||
min-width: 8vh;
|
||||
}
|
||||
#tableMain tbody tr td.order_items table tbody tr td.product_variations table thead tr th:last-of-type, #tableMain tbody tr td.order_items table tbody tr td.product_variations table tbody tr td:last-of-type {
|
||||
width: 4vh;
|
||||
min-width: 4vh;
|
||||
}
|
||||
|
||||
#tableMain tbody tr td.order_items table thead tr th.quantity_used, #tableMain tbody tr td.order_items table tbody tr td.quantity_used,
|
||||
#tableMain tbody tr td.order_items table thead tr th.quantity_produced, #tableMain tbody tr td.order_items table tbody tr td.quantity_produced,
|
||||
#tableMain tbody tr td.order_items table thead tr th.latency_manufacture, #tableMain tbody tr td.order_items table tbody tr td.latency_manufacture {
|
||||
width: 8vh;
|
||||
min-width: 8vh;
|
||||
}
|
||||
#tableMain tbody tr td.order_items table thead tr th.active, #tableMain tbody tr td.order_items table tbody tr td.active,
|
||||
#tableMain tbody tr td.order_items table thead tr th.add, #tableMain tbody tr td.order_items table tbody tr td.delete {
|
||||
width: 4vh;
|
||||
min-width: 4vh;
|
||||
}
|
||||
|
||||
#tableMain thead tr th.currency.collapsed, #tableMain tbody tr td.currency.collapsed {
|
||||
width: 9vh;
|
||||
min-width: 9vh;
|
||||
@@ -26,13 +91,4 @@
|
||||
#tableMain tbody tr td.price_total_local_vat_incl, #tableMain thead tr th.price_total_local_vat_incl {
|
||||
width: 5vh;
|
||||
min-width: 5vh;
|
||||
}
|
||||
#tableMain tbody tr td.items, #tableMain thead tr th.items {
|
||||
width: 40vh;
|
||||
min-width: 40vh;
|
||||
}
|
||||
|
||||
#tableMain tbody tr td.active, #tableMain thead tr th.active {
|
||||
width: 5vh;
|
||||
min-width: 5vh;
|
||||
}
|
||||
}
|
||||
@@ -41,22 +41,22 @@
|
||||
}
|
||||
#tableMain:has(tbody tr td.order_items table thead tr th.product_variations.collapsed) thead tr th.order_items,
|
||||
#tableMain:has(tbody tr td.order_items table thead tr th.product_variations.collapsed) tbody tr td.order_items {
|
||||
width: 91vh;
|
||||
min-width: 91vh;
|
||||
width: 126vh;
|
||||
min-width: 126vh;
|
||||
}
|
||||
#tableMain thead tr th.order_items,
|
||||
#tableMain tbody tr td.order_items {
|
||||
width: 101vh;
|
||||
min-width: 101vh;
|
||||
width: 136vh;
|
||||
min-width: 136vh;
|
||||
}
|
||||
#tableMain tbody tr td.order_items table thead tr th, #tableMain tbody tr td.order_items table tbody tr td {
|
||||
width: 12vh;
|
||||
min-width: 12vh;
|
||||
}
|
||||
#tableMain tbody tr td.order_items table thead tr th.display_order, #tableMain tbody tr td.order_items table tbody tr td.display_order,
|
||||
#tableMain tbody tr td.order_items table thead tr th.id_unit_measurement_quantity, #tableMain tbody tr td.order_items table tbody tr td.id_unit_measurement_quantity {
|
||||
width: 6vh;
|
||||
min-width: 6vh;
|
||||
#tableMain tbody tr td.order_items table thead tr th.add, #tableMain tbody tr td.order_items table tbody tr td.delete {
|
||||
width: 5vh;
|
||||
min-width: 5vh;
|
||||
}
|
||||
|
||||
#tableMain tbody tr td.order_items table thead tr th.product_variations.collapsed, #tableMain tbody tr td.order_items table tbody tr td.product_variations.collapsed {
|
||||
@@ -76,8 +76,16 @@
|
||||
min-width: 4vh;
|
||||
}
|
||||
|
||||
#tableMain tbody tr td.order_items table thead tr th.id_unit_measurement_quantity, #tableMain tbody tr td.order_items table tbody tr td.id_unit_measurement_quantity {
|
||||
width: 6vh;
|
||||
min-width: 6vh;
|
||||
}
|
||||
#tableMain tbody tr td.order_items table thead tr th.quantity_ordered, #tableMain tbody tr td.order_items table tbody tr td.quantity_ordered,
|
||||
#tableMain tbody tr td.order_items table thead tr th.quantity_received, #tableMain tbody tr td.order_items table tbody tr td.quantity_received,
|
||||
#tableMain tbody tr td.order_items table thead tr th.cost_total_local_vat_excl, #tableMain tbody tr td.order_items table tbody tr td.cost_total_local_vat_excl,
|
||||
#tableMain tbody tr td.order_items table thead tr th.cost_total_local_vat_incl, #tableMain tbody tr td.order_items table tbody tr td.cost_total_local_vat_incl,
|
||||
#tableMain tbody tr td.order_items table thead tr th.cost_unit_local_vat_excl, #tableMain tbody tr td.order_items table tbody tr td.cost_unit_local_vat_excl,
|
||||
#tableMain tbody tr td.order_items table thead tr th.cost_unit_local_vat_incl, #tableMain tbody tr td.order_items table tbody tr td.cost_unit_local_vat_incl,
|
||||
#tableMain tbody tr td.order_items table thead tr th.latency_delivery_days, #tableMain tbody tr td.order_items table tbody tr td.latency_delivery_days {
|
||||
width: 8vh;
|
||||
min-width: 8vh;
|
||||
|
||||
@@ -50,4 +50,7 @@
|
||||
/* Right column */
|
||||
.rightcolumn {
|
||||
min-width: fit-content;
|
||||
}
|
||||
}
|
||||
|
||||
/* Main Table */
|
||||
|
||||
|
||||
16
static/dist/css/main.bundle.css
vendored
16
static/dist/css/main.bundle.css
vendored
@@ -645,7 +645,6 @@ tr {
|
||||
min-height: 1px;
|
||||
border-bottom: 1px solid var(--c_purple_dark);
|
||||
border-top: 1px solid var(--c_purple_dark);
|
||||
padding-bottom: 1vh;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
@@ -691,10 +690,15 @@ form.filter button.save, form.filter button.button-cancel {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
#formFilters .container-input.filter.active {
|
||||
width: 8vh;
|
||||
}
|
||||
|
||||
|
||||
#tableMain {
|
||||
overflow-x: auto;
|
||||
padding: 1vh 2vh;
|
||||
max-width: min(calc(1vh * 80), calc(1vw * 90));
|
||||
max-width: 95vw; /* min(calc(1vh * 80), calc(1vw * 90)); */
|
||||
width: fit-content;
|
||||
margin: 1vh 2vh;
|
||||
align-items: normal;
|
||||
@@ -706,6 +710,14 @@ form.filter button.save, form.filter button.button-cancel {
|
||||
min-width: 20vh;
|
||||
padding: 0 0.5vh;
|
||||
}
|
||||
#tableMain thead tr th.active, #tableMain tbody tr td.active {
|
||||
width: 6vh;
|
||||
min-width: 6vh;
|
||||
}
|
||||
#tableMain tbody tr td.display_order, #tableMain thead tr th.display_order {
|
||||
width: 5vh;
|
||||
min-width: 5vh;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
4
static/dist/css/store_home.bundle.css
vendored
4
static/dist/css/store_home.bundle.css
vendored
@@ -52,3 +52,7 @@
|
||||
min-width: fit-content;
|
||||
}
|
||||
|
||||
/* Main Table */
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -52,6 +52,10 @@
|
||||
min-width: fit-content;
|
||||
}
|
||||
|
||||
/* Main Table */
|
||||
|
||||
|
||||
|
||||
#formFilters {
|
||||
width: 50vh;
|
||||
}
|
||||
|
||||
@@ -52,6 +52,10 @@
|
||||
min-width: fit-content;
|
||||
}
|
||||
|
||||
/* Main Table */
|
||||
|
||||
|
||||
|
||||
#formFilters {
|
||||
width: 50vh;
|
||||
}
|
||||
|
||||
4
static/dist/css/store_stock_items.bundle.css
vendored
4
static/dist/css/store_stock_items.bundle.css
vendored
@@ -52,6 +52,10 @@
|
||||
min-width: fit-content;
|
||||
}
|
||||
|
||||
/* Main Table */
|
||||
|
||||
|
||||
|
||||
th, td {
|
||||
min-width: fit-content;
|
||||
}
|
||||
|
||||
2
static/dist/js/main.bundle.js
vendored
2
static/dist/js/main.bundle.js
vendored
File diff suppressed because one or more lines are too long
@@ -22,8 +22,6 @@ export default class API {
|
||||
options.body = JSON.stringify(data);
|
||||
}
|
||||
|
||||
console.log('API request:', method, url, data);
|
||||
|
||||
try {
|
||||
const response = await fetch(url, options);
|
||||
if (!response.ok) {
|
||||
@@ -38,10 +36,7 @@ export default class API {
|
||||
|
||||
static getUrlFromHash(hash, params = null) {
|
||||
if (hash == null) hash = hashPageHome;
|
||||
console.log("getUrlFromHash:");
|
||||
console.log("base url: " + _pathHost + "\nhash: " + hash + '\nparams: ' + params);
|
||||
let url = API.parameteriseUrl(_pathHost + hash, params);
|
||||
console.log("url: " + url);
|
||||
return url;
|
||||
}
|
||||
static parameteriseUrl(url, params) {
|
||||
|
||||
@@ -48,7 +48,6 @@ class App {
|
||||
|
||||
handleGlobalClick(event) {
|
||||
// Handle global click events
|
||||
console.log('Global click:', event.target);
|
||||
}
|
||||
|
||||
start() {
|
||||
|
||||
@@ -3,14 +3,12 @@
|
||||
function handleSelectCollapse(elementSelect) {
|
||||
let optionSelected = document.querySelectorAll(elementSelect).querySelector('option:selected');
|
||||
optionSelected.text(optionSelected.getAttribute(attrTextCollapsed));
|
||||
console.log('collapsed: ', optionSelected.text());
|
||||
optionSelected.classList.remove(flagExpanded);
|
||||
optionSelected.classList.add(flagCollapsed);
|
||||
}
|
||||
function handleSelectExpand(elementSelect) {
|
||||
let optionSelected = document.querySelectorAll(elementSelect).querySelector('option:selected');
|
||||
optionSelected.text(optionSelected.getAttribute(attrTextExpanded));
|
||||
console.log('expanded: ', optionSelected.text());
|
||||
optionSelected.classList.remove(flagCollapsed);
|
||||
optionSelected.classList.add(flagExpanded);
|
||||
}
|
||||
@@ -54,11 +54,9 @@ export default class DOM {
|
||||
static convertForm2JSON(elementForm) {
|
||||
let dataForm = {};
|
||||
if (Validation.isEmpty(elementForm)) {
|
||||
console.log("empty form element");
|
||||
return dataForm;
|
||||
}
|
||||
let containersFilter = elementForm.querySelectorAll('.' + flagContainerInput + '.' + flagFilter);
|
||||
console.log("containersFilter: " + containersFilter);
|
||||
let containerFilter, labelFilter, keyFilter, filter;
|
||||
for (let indexFilter = 0; indexFilter < containersFilter.length; indexFilter++) {
|
||||
containerFilter = containersFilter[indexFilter];
|
||||
|
||||
@@ -11,7 +11,7 @@ export default class BusinessObjects {
|
||||
static getOptionJsonFromObjectJson(objectJson, valueSelected = null) {
|
||||
let keyText = objectJson[flagNameAttrOptionText];
|
||||
let keyValue = objectJson[flagNameAttrOptionValue];
|
||||
console.log({objectJson, keyText, keyValue});
|
||||
if (_verbose) { console.log({objectJson, keyText, keyValue}); };
|
||||
return BusinessObjects.getOptionJsonFromObjectJsonAndKeys(objectJson, keyText, keyValue, valueSelected);
|
||||
}
|
||||
/*
|
||||
|
||||
@@ -3,4 +3,3 @@ const _dataLoadingFlag = 'data-loading'
|
||||
var _domParser = null;
|
||||
// var hashPageCurrent; // moved to layout
|
||||
const keyPublicStripe = 'pk_test_51OGrxlL7BuLKjoMpfpfw7bSmZZK1MhqMoQ5VhW2jUj7YtoEejO4vqnxKPiqTHHuh9U4qqkywbPCSI9TpFKtr4SYH007KHMWs68';
|
||||
var _verbose = true;
|
||||
|
||||
@@ -14,7 +14,7 @@ export default class BasePage {
|
||||
throw new Error("Router is required");
|
||||
}
|
||||
else {
|
||||
console.log("initialising with router: ", router);
|
||||
if (_verbose) { console.log("initialising with router: ", router); }
|
||||
}
|
||||
this.router = router;
|
||||
this.title = titlePageCurrent;
|
||||
@@ -38,7 +38,7 @@ export default class BasePage {
|
||||
}
|
||||
|
||||
logInitialisation() {
|
||||
console.log('Initializing ' + this.title + ' page');
|
||||
if (_verbose) { console.log('Initializing ' + this.title + ' page'); }
|
||||
}
|
||||
|
||||
hookupCommonElements() {
|
||||
@@ -189,7 +189,7 @@ export default class BasePage {
|
||||
Events.initialiseEventHandler('form.' + flagFilter + ' button.' + flagSave, flagInitialised, (button) => {
|
||||
button.addEventListener("click", (event) => {
|
||||
event.stopPropagation();
|
||||
console.log('saving page: ', this.title);
|
||||
if (_verbose) { console.log('saving page: ', this.title); }
|
||||
OverlayConfirm.show();
|
||||
});
|
||||
// button.classList.add(flagCollapsed);
|
||||
@@ -204,7 +204,7 @@ export default class BasePage {
|
||||
}
|
||||
|
||||
leave() {
|
||||
console.log('Leaving ' + this.title + ' page');
|
||||
if (_verbose) { console.log('Leaving ' + this.title + ' page'); }
|
||||
if (this.constructor === BasePage) {
|
||||
throw new Error("Must implement leave() method.");
|
||||
}
|
||||
@@ -222,11 +222,11 @@ export default class BasePage {
|
||||
if (show) {
|
||||
buttonCancel.classList.remove(flagCollapsed);
|
||||
buttonSave.classList.remove(flagCollapsed);
|
||||
console.log('showing buttons');
|
||||
if (_verbose) { console.log('showing buttons'); }
|
||||
} else {
|
||||
buttonCancel.classList.add(flagCollapsed);
|
||||
buttonSave.classList.add(flagCollapsed);
|
||||
console.log('hiding buttons');
|
||||
if (_verbose) { console.log('hiding buttons'); }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -134,7 +134,7 @@ export default class TableBasePage extends BasePage {
|
||||
let filtersJson = DOM.convertForm2JSON(formFilters);
|
||||
this.callFilterTableContent(filtersJson)
|
||||
.then(data => {
|
||||
console.log('Table data received:', data);
|
||||
if (_verbose) { console.log('Table data received:', data); }
|
||||
this.callbackLoadTableContent(data);
|
||||
})
|
||||
.catch(error => console.error('Error:', error));
|
||||
@@ -156,12 +156,14 @@ export default class TableBasePage extends BasePage {
|
||||
this.callSaveTableContent(records, formElement, comment)
|
||||
.then(data => {
|
||||
if (data[flagStatus] == flagSuccess) {
|
||||
console.log('Records saved!');
|
||||
console.log('Data received:', data);
|
||||
if (_verbose) {
|
||||
console.log('Records saved!');
|
||||
console.log('Data received:', data);
|
||||
}
|
||||
this.getAndLoadFilteredTableContent();
|
||||
}
|
||||
else {
|
||||
console.log("error: ", data[flagMessage]);
|
||||
if (_verbose) { console.log("error: ", data[flagMessage]); }
|
||||
OverlayError.show(data[flagMessage]);
|
||||
}
|
||||
})
|
||||
@@ -192,12 +194,14 @@ export default class TableBasePage extends BasePage {
|
||||
this.callSaveTableContent(records, formElement, comment)
|
||||
.then(data => {
|
||||
if (data[flagStatus] == flagSuccess) {
|
||||
console.log('Records saved!');
|
||||
console.log('Data received:', data);
|
||||
if (_verbose) {
|
||||
console.log('Records saved!');
|
||||
console.log('Data received:', data);
|
||||
}
|
||||
this.callbackLoadTableContent(data);
|
||||
}
|
||||
else {
|
||||
console.log("error: ", data[flagMessage]);
|
||||
if (_verbose) { console.log("error: ", data[flagMessage]); }
|
||||
OverlayError.show(data[flagMessage]);
|
||||
}
|
||||
})
|
||||
@@ -207,7 +211,7 @@ export default class TableBasePage extends BasePage {
|
||||
Events.initialiseEventHandler(idFormFilters + ' button.' + flagCancel, flagInitialised, function(button) {
|
||||
button.addEventListener("click", function(event) {
|
||||
event.stopPropagation();
|
||||
getAndLoadFilteredTableContent();
|
||||
this.getAndLoadFilteredTableContent();
|
||||
});
|
||||
button.classList.add(flagCollapsed);
|
||||
});
|
||||
@@ -255,7 +259,7 @@ export default class TableBasePage extends BasePage {
|
||||
cacheRowBlank() {
|
||||
let selectorRowNew = idTableMain + ' tbody tr.' + flagRowNew;
|
||||
let rowBlankTemp = document.querySelector(selectorRowNew);
|
||||
console.log("row blank temp: ", rowBlankTemp);
|
||||
if (_verbose) { console.log("row blank temp: ", rowBlankTemp); }
|
||||
_rowBlank = rowBlankTemp.cloneNode(true);
|
||||
document.querySelectorAll(selectorRowNew).forEach(function(row) {
|
||||
row.remove();
|
||||
@@ -368,10 +372,10 @@ export default class TableBasePage extends BasePage {
|
||||
let wasDirtyParentRows = this.getAllIsDirtyRowsInParentTree(element);
|
||||
let wasDirtyElement = element.classList.contains(flagDirty);
|
||||
let isDirtyElement = DOM.updateAndCheckIsElementDirty(element);
|
||||
console.log({isDirtyElement, wasDirtyElement, wasDirtyParentRows});
|
||||
if (_verbose) { console.log({isDirtyElement, wasDirtyElement, wasDirtyParentRows}); }
|
||||
if (isDirtyElement != wasDirtyElement) {
|
||||
let td = DOM.getCellFromElement(element);
|
||||
DOM.setElementAttributeValueCurrent(td, DOM.getElementValueCurrent(element));
|
||||
DOM.setElementAttributeValueCurrent(td, DOM.getElementAttributeValueCurrent(element));
|
||||
this.toggleShowButtonsSaveCancel(isDirtyElement);
|
||||
this.cascadeChangedIsDirtyNestedElementCellTable(element, isDirtyElement, wasDirtyParentRows);
|
||||
}
|
||||
@@ -397,7 +401,7 @@ export default class TableBasePage extends BasePage {
|
||||
let tr = DOM.getRowFromElement(td);
|
||||
let isDirtyRow = isDirtyTd || DOM.hasDirtyChildrenNotDeletedContainer(tr);
|
||||
let wasDirtyRow = wasDirtyParentRows.pop();
|
||||
console.log({isDirtyRow, wasDirtyRow});
|
||||
if (_verbose) { console.log({isDirtyRow, wasDirtyRow}); }
|
||||
if (isDirtyRow != wasDirtyRow) {
|
||||
DOM.handleDirtyElement(tr, isDirtyRow);
|
||||
this.toggleShowButtonsSaveCancel(isDirtyRow);
|
||||
@@ -517,10 +521,9 @@ export default class TableBasePage extends BasePage {
|
||||
cellSelector
|
||||
, optionList
|
||||
, ddlHookup = (cellSelector) => { this.hookupTableCellDdls(cellSelector); }
|
||||
, changeHandler = (event, element) => { this.handleChangeTableCellDdl(event, element); }
|
||||
, changeHandler = (event, element) => { this.handleChangeNestedElementCellTable(event, element); }
|
||||
) {
|
||||
this.hookupEventHandler("click", cellSelector, (event, td) => {
|
||||
// if (td.querySelector('select')) return;
|
||||
this.handleClickTableCellDdlPreview(
|
||||
event
|
||||
, td
|
||||
@@ -532,14 +535,14 @@ export default class TableBasePage extends BasePage {
|
||||
); }
|
||||
);
|
||||
});
|
||||
ddlHookup(cellSelector + ' select');
|
||||
}
|
||||
hookupTableCellDdls(ddlSelector, changeHandler = (event, element) => { this.handleChangeTableCellDdl(event, element); }) {
|
||||
hookupTableCellDdls(ddlSelector, changeHandler = (event, element) => { this.handleChangeNestedElementCellTable(event, element); }) {
|
||||
this.hookupEventHandler("change", ddlSelector, (event, element) => { changeHandler(event, element); });
|
||||
}
|
||||
handleClickTableCellDdlPreview(event, td, optionObjectList, cellSelector, ddlHookup = (cellSelector) => { this.hookupTableCellDdls(cellSelector); }) {
|
||||
if (td.querySelector('select')) return;
|
||||
// td.removeEventListener("click", ddlHookup);
|
||||
console.log("click table cell ddl preview");
|
||||
let tdNew = td.cloneNode(true);
|
||||
td.parentNode.replaceChild(tdNew, td);
|
||||
let idSelected = DOM.getElementAttributeValueCurrent(tdNew);
|
||||
@@ -547,7 +550,10 @@ export default class TableBasePage extends BasePage {
|
||||
let ddl = document.createElement('select');
|
||||
DOM.setElementValuesCurrentAndPrevious(ddl, idSelected);
|
||||
let optionJson, option;
|
||||
console.log({optionObjectList, cellSelector});
|
||||
if (_verbose) {
|
||||
console.log("click table cell ddl preview");
|
||||
console.log({optionObjectList, cellSelector});
|
||||
}
|
||||
option = DOM.createOption(null);
|
||||
ddl.appendChild(option);
|
||||
optionObjectList.forEach((optionObjectJson) => {
|
||||
@@ -557,8 +563,10 @@ export default class TableBasePage extends BasePage {
|
||||
});
|
||||
tdNew.appendChild(ddl);
|
||||
let ddlSelector = cellSelector + ' select';
|
||||
debugger;
|
||||
ddlHookup(ddlSelector);
|
||||
}
|
||||
/*
|
||||
handleChangeTableCellDdl(event, ddl) {
|
||||
let row = DOM.getRowFromElement(ddl);
|
||||
let td = DOM.getCellFromElement(ddl);
|
||||
@@ -585,6 +593,7 @@ export default class TableBasePage extends BasePage {
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
hookupTableCellDDlPreviewsWhenNotCollapsed(cellSelector, optionList, ddlHookup = (event, element) => { this.hookupTableCellDdls(event, element); }) {
|
||||
this.hookupEventHandler("click", cellSelector, (event, td) => {
|
||||
let div = td.querySelector('div');
|
||||
@@ -596,7 +605,7 @@ export default class TableBasePage extends BasePage {
|
||||
this.hookupChangeHandlerTableCells(ddlSelector, (event, element) => { this.handleChangeProductCategoryDdl(event, element); });
|
||||
}
|
||||
handleChangeProductCategoryDdl(event, ddlCategory) {
|
||||
this.handleChangeTableCellDdl(event, ddlCategory);
|
||||
this.handleChangeNestedElementCellTable(event, ddlCategory);
|
||||
let idProductCategorySelected = DOM.getElementValueCurrent(ddlCategory);
|
||||
let row = DOM.getRowFromElement(ddlCategory);
|
||||
let tdProduct = row.querySelector('td.' + flagProduct);
|
||||
@@ -611,7 +620,7 @@ export default class TableBasePage extends BasePage {
|
||||
option = DOM.createOption(optionJson);
|
||||
ddlProduct.appendChild(option);
|
||||
});
|
||||
this.handleChangeTableCellDdl(event, ddlProduct);
|
||||
this.handleChangeNestedElementCellTable(event, ddlProduct);
|
||||
}
|
||||
hookupFieldsProductPermutationVariation() {
|
||||
this.hookupPreviewsProductPermutationVariation();
|
||||
@@ -625,7 +634,6 @@ export default class TableBasePage extends BasePage {
|
||||
handleClickProductPermutationVariationsPreview(event, element) {
|
||||
let tblVariations = element.querySelector('table.' + flagProductVariations);
|
||||
if (!Validation.isEmpty(tblVariations)) return;
|
||||
console.log("click product permutation variations preview");
|
||||
this.toggleColumnCollapsed(flagProductVariations, false);
|
||||
let permutationVariations = this.getElementProductVariations(element);
|
||||
tblVariations = document.createElement("table");
|
||||
@@ -650,18 +658,21 @@ export default class TableBasePage extends BasePage {
|
||||
thead.appendChild(tr);
|
||||
tblVariations.appendChild(thead);
|
||||
let tbody = document.createElement("tbody");
|
||||
console.log('variations:', permutationVariations);
|
||||
if (!Validation.isEmpty(permutationVariations)) {
|
||||
permutationVariations.forEach((permutationVariation, index) => {
|
||||
this.addProductPermutationVariationRow(tbody, permutationVariation);
|
||||
});
|
||||
}
|
||||
tblVariations.appendChild(tbody);
|
||||
if (_verbose) {
|
||||
console.log("click product permutation variations preview");
|
||||
console.log('variations:', permutationVariations);
|
||||
console.log("tblVariations: ", tblVariations);
|
||||
}
|
||||
|
||||
let cellParent = element.closest(idTableMain + ' tbody tr td.' + flagProductVariations);
|
||||
cellParent.innerHTML = '';
|
||||
cellParent.appendChild(tblVariations);
|
||||
console.log("tblVariations: ", tblVariations);
|
||||
|
||||
this.hookupFieldsProductPermutationVariation();
|
||||
}
|
||||
@@ -680,7 +691,7 @@ export default class TableBasePage extends BasePage {
|
||||
permutationVariations.forEach((variation) => {
|
||||
parts = variation.split(':');
|
||||
if (parts.length == 2) {
|
||||
console.log("parts: ", parts);
|
||||
if (_verbose) { console.log("parts: ", parts); }
|
||||
new_variation_type = productVariationTypes[parts[0].trim()];
|
||||
new_variation = productVariations[parts[1].trim()];
|
||||
objVariations.push({
|
||||
@@ -689,7 +700,7 @@ export default class TableBasePage extends BasePage {
|
||||
});
|
||||
}
|
||||
else {
|
||||
console.log("error: invalid variation: ", variation);
|
||||
if (_verbose) { console.log("error: invalid variation: ", variation); }
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -712,6 +723,7 @@ export default class TableBasePage extends BasePage {
|
||||
};
|
||||
}
|
||||
addProductPermutationVariationRow(tbody, permutationVariation) {
|
||||
if (_verbose) { console.log("permutationVariation: ", permutationVariation); }
|
||||
let productVariationType, optionProductVariationTypeJson, optionProductVariationType, productVariation, optionProductVariationJson, optionProductVariation;
|
||||
/*
|
||||
if (Validation.isEmpty(variations)) {
|
||||
@@ -734,7 +746,7 @@ export default class TableBasePage extends BasePage {
|
||||
if (doFilterProductVariationKeys) {
|
||||
productVariationKeys = productVariationKeys.filter(variationKey => !productVariationTypeKeysSelected.has(productVariations[variationKey][attrIdProductVariationType]));
|
||||
}
|
||||
console.log("permutationVariation: ", permutationVariation);
|
||||
|
||||
let permutationVariationJson = permutationVariation[flagProductVariation];
|
||||
let permutationVariationTypeJson = permutationVariation[flagProductVariationType];
|
||||
|
||||
@@ -747,7 +759,7 @@ export default class TableBasePage extends BasePage {
|
||||
DOM.setElementAttributesValuesCurrentAndPrevious(ddlVariationType, permutationVariationTypeJson[attrIdProductVariationType]);
|
||||
|
||||
optionProductVariationType = DOM.createOption(null);
|
||||
console.log("optionProductVariationType: ", optionProductVariationType);
|
||||
if (_verbose) { console.log("optionProductVariationType: ", optionProductVariationType); }
|
||||
ddlVariationType.appendChild(optionProductVariationType);
|
||||
|
||||
productVariationTypeKeys.forEach((productVariationTypeKey) => {
|
||||
@@ -759,7 +771,7 @@ export default class TableBasePage extends BasePage {
|
||||
productVariationType = productVariationTypes[productVariationTypeKey];
|
||||
optionProductVariationTypeJson = BusinessObjects.getOptionJsonFromObjectJson(productVariationType, permutationVariationTypeJson[attrIdProductVariationType]);
|
||||
optionProductVariationType = DOM.createOption(optionProductVariationTypeJson);
|
||||
console.log("optionProductVariationType: ", optionProductVariationType);
|
||||
if (_verbose) { console.log("optionProductVariationType: ", optionProductVariationType); }
|
||||
ddlVariationType.appendChild(optionProductVariationType);
|
||||
});
|
||||
|
||||
@@ -772,14 +784,14 @@ export default class TableBasePage extends BasePage {
|
||||
DOM.setElementAttributesValuesCurrentAndPrevious(ddlVariation, permutationVariationJson[attrIdProductVariation]);
|
||||
|
||||
optionProductVariation = DOM.createOption(null);
|
||||
console.log("optionProductVariation: ", optionProductVariation);
|
||||
if (_verbose) { console.log("optionProductVariation: ", optionProductVariation); }
|
||||
ddlVariation.appendChild(optionProductVariation);
|
||||
|
||||
productVariationKeys.forEach((productVariationKey) => {
|
||||
productVariation = productVariations[productVariationKey];
|
||||
optionProductVariationJson = BusinessObjects.getOptionJsonFromObjectJson(productVariation, permutationVariationJson[attrIdProductVariation]);
|
||||
optionProductVariation = DOM.createOption(optionProductVariationJson);
|
||||
console.log("optionProductVariation: ", optionProductVariation);
|
||||
if (_verbose) { console.log("optionProductVariation: ", optionProductVariation); }
|
||||
ddlVariation.appendChild(optionProductVariation);
|
||||
});
|
||||
|
||||
|
||||
@@ -21,12 +21,12 @@ export default class PageStoreBasket extends BasePage {
|
||||
hookupStoreCardsInfo() {
|
||||
|
||||
document.querySelectorAll(idContainerInfoDelivery).addEventListener("click", function(event) {
|
||||
console.log("delivery modal display method");
|
||||
if (_verbose) { console.log("delivery modal display method"); }
|
||||
document.querySelectorAll(idOverlayInfoDelivery).css('display', 'block');
|
||||
});
|
||||
|
||||
document.querySelectorAll(idContainerInfoBilling).addEventListener("click", function(event) {
|
||||
console.log("billing modal display method");
|
||||
if (_verbose) { console.log("billing modal display method"); }
|
||||
document.querySelectorAll(idOverlayInfoBilling).css('display', 'block');
|
||||
});
|
||||
}
|
||||
@@ -44,7 +44,7 @@ export default class PageStoreBasket extends BasePage {
|
||||
elForm.submit(function(event) {
|
||||
elForm = document.querySelectorAll(elForm);
|
||||
event.preventDefault();
|
||||
console.log("delivery submit method");
|
||||
if (_verbose) { console.log("delivery submit method"); }
|
||||
|
||||
ajaxData = {};
|
||||
ajaxData[keyInfoType] = keyInfoDelivery;
|
||||
@@ -63,7 +63,7 @@ export default class PageStoreBasket extends BasePage {
|
||||
Events.initialiseEventHandler(elForm, flagInitialised, function() {
|
||||
elForm.submit(function(event) {
|
||||
event.preventDefault();
|
||||
console.log("billing submit method");
|
||||
if (_verbose) { console.log("billing submit method"); }
|
||||
|
||||
ajaxData = {};
|
||||
ajaxData[keyInfoType] = keyInfoBilling;
|
||||
@@ -81,7 +81,7 @@ export default class PageStoreBasket extends BasePage {
|
||||
|
||||
loadInfoAddress(response) {
|
||||
|
||||
console.log('ajax:'); console.log(response.data);
|
||||
if (_verbose) { console.log('response:'); console.log(response.data); }
|
||||
let infoType = response.data[keyInfoType];
|
||||
let infoAddress = response.data[infoType];
|
||||
LocalStorage.setLocalStorage(infoType, infoAddress);
|
||||
@@ -119,11 +119,13 @@ export default class PageStoreBasket extends BasePage {
|
||||
elOverlay = document.querySelectorAll(idOverlayInfoDelivery);
|
||||
elForm = elOverlay.querySelector('form');
|
||||
|
||||
console.log('converting billing form to json\nform ID: ' + elForm.id);
|
||||
ajaxData[flagForm] = convertForm2JSON(elForm); // formData; // form.serialize();
|
||||
let keys = [keyNameFull, keyPhoneNumber, keyPostcode, keyAddress1, keyAddress2, keyCity, keyCounty];
|
||||
console.log('ajaxData:');
|
||||
console.log(ajaxData);
|
||||
if (_verbose) {
|
||||
console.log('converting billing form to json\nform ID: ' + elForm.id);
|
||||
console.log('ajaxData:');
|
||||
console.log(ajaxData);
|
||||
}
|
||||
ajaxData[flagForm][keyInfoIdentical] = getElementValueCurrent(elForm.querySelector('#' + keyInfoIdentical));
|
||||
for (var k in keys) {
|
||||
if (idOverlayInfo == idOverlayInfoBilling && ajaxData[flagForm][keyInfoIdentical]) {
|
||||
@@ -132,8 +134,10 @@ export default class PageStoreBasket extends BasePage {
|
||||
ajaxData[flagForm][keys[k]] = getElementValueCurrent(elForm.querySelector('#' + keys[k]));
|
||||
}
|
||||
}
|
||||
console.log('ajaxData:');
|
||||
console.log(ajaxData);
|
||||
if (_verbose) {
|
||||
console.log('ajaxData:');
|
||||
console.log(ajaxData);
|
||||
}
|
||||
return ajaxData;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ export default class PageStoreManufacturingPurchaseOrders extends TableBasePage
|
||||
let inputCostTotalLocalVatIncl = row.querySelector('td.' + flagCostTotalLocalVatIncl + ' input');
|
||||
let inputPriceTotalLocalVatExcl = row.querySelector('td.' + flagPriceTotalLocalVatExcl + ' input');
|
||||
let inputPriceTotalLocalVatIncl = row.querySelector('td.' + flagPriceTotalLocalVatIncl + ' input');
|
||||
let tdItems = row.querySelector('td.' + flagOrderItems);
|
||||
let trsPurchaseOrderItem = row.querySelectorAll('tr.' + flagOrderItems);
|
||||
let checkboxActive = row.querySelector('td.' + flagActive + ' textarea');
|
||||
|
||||
let jsonRow = {};
|
||||
@@ -47,11 +47,12 @@ export default class PageStoreManufacturingPurchaseOrders extends TableBasePage
|
||||
jsonRow[flagCostTotalLocalVatIncl] = DOM.getElementAttributeValueCurrent(inputCostTotalLocalVatIncl);
|
||||
jsonRow[flagPriceTotalLocalVatExcl] = DOM.getElementAttributeValueCurrent(inputPriceTotalLocalVatExcl);
|
||||
jsonRow[flagPriceTotalLocalVatIncl] = DOM.getElementAttributeValueCurrent(inputPriceTotalLocalVatIncl);
|
||||
// jsonRow[flagOrderItems] = DOM.getElementAttributeValueCurrent(tdItems);
|
||||
let orderItems = [];
|
||||
trsPurchaseOrderItem.forEach((tr) => {
|
||||
orderItems.push(this.getJsonRowOrderItem(tr));
|
||||
});
|
||||
if (trsPurchaseOrderItem != null) {
|
||||
trsPurchaseOrderItem.forEach((tr) => {
|
||||
orderItems.push(this.getJsonRowOrderItem(tr));
|
||||
});
|
||||
}
|
||||
jsonRow[flagOrderItems] = orderItems;
|
||||
jsonRow[flagActive] = DOM.getElementAttributeValueCurrent(checkboxActive);
|
||||
return jsonRow;
|
||||
@@ -77,8 +78,6 @@ export default class PageStoreManufacturingPurchaseOrders extends TableBasePage
|
||||
jsonRow[attrIdUnitMeasurementQuantity] = DOM.getElementAttributeValueCurrent(tdUnitQuantity);
|
||||
jsonRow[flagQuantityUsed] = DOM.getElementAttributeValueCurrent(inputQuantityUsed);
|
||||
jsonRow[flagQuantityProduced] = DOM.getElementAttributeValueCurrent(inputQuantityProduced);
|
||||
jsonRow[flagCostTotalLocalVatExcl] = DOM.getElementAttributeValueCurrent(inputCostTotalLocalVatExcl);
|
||||
jsonRow[flagCostTotalLocalVatIncl] = DOM.getElementAttributeValueCurrent(inputCostTotalLocalVatIncl);
|
||||
jsonRow[flagLatencyManufacture] = DOM.getElementAttributeValueCurrent(inputLatencyManufacture);
|
||||
jsonRow[flagActive] = DOM.getElementAttributeValueCurrent(checkboxActive);
|
||||
|
||||
@@ -91,11 +90,11 @@ export default class PageStoreManufacturingPurchaseOrders extends TableBasePage
|
||||
hookupTableMain() {
|
||||
super.hookupTableMain();
|
||||
this.hookupCurrencyFields();
|
||||
this.hookupCostInputs();
|
||||
this.hookupCostAndPriceInputs();
|
||||
this.hookupOrderItemsFields();
|
||||
this.hookupInputsActiveTable();
|
||||
}
|
||||
hookupCostInputs() {
|
||||
hookupCostAndPriceInputs() {
|
||||
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagCostTotalLocalVatExcl + ' input');
|
||||
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagCostTotalLocalVatIncl + ' input');
|
||||
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagPriceTotalLocalVatExcl + ' input');
|
||||
@@ -110,8 +109,7 @@ export default class PageStoreManufacturingPurchaseOrders extends TableBasePage
|
||||
this.hookupFieldsOrderItemUnitQuantity();
|
||||
this.hookupFieldsOrderItemQuantityUsed();
|
||||
this.hookupFieldsOrderItemQuantityProduced();
|
||||
this.hookupFieldsOrderItemCostTotalLocalVatExcl();
|
||||
this.hookupFieldsOrderItemCostTotalLocalVatIncl();
|
||||
this.hookupFieldsOrderItemUnitMeasurementLatencyManufacture();
|
||||
this.hookupFieldsOrderItemLatencyManufacture();
|
||||
this.hookupFieldsOrderItemActive();
|
||||
this.hookupFieldsOrderItemAddDelete();
|
||||
@@ -124,7 +122,7 @@ export default class PageStoreManufacturingPurchaseOrders extends TableBasePage
|
||||
});
|
||||
}
|
||||
handleClickOrderItemsPreview(event, element) {
|
||||
console.log("click order items preview");
|
||||
if (_verbose) { console.log("click order items preview"); }
|
||||
this.toggleColumnHeaderCollapsed(flagOrderItems, false);
|
||||
element.classList.remove(flagCollapsed);
|
||||
|
||||
@@ -154,10 +152,11 @@ export default class PageStoreManufacturingPurchaseOrders extends TableBasePage
|
||||
thUnitQuantity.textContent = 'Unit Quantity';
|
||||
let thQuantityUsed = document.createElement("th");
|
||||
thQuantityUsed.classList.add(flagQuantityUsed);
|
||||
thQuantityUsed.textContent = 'Quantity Ordered';
|
||||
thQuantityUsed.textContent = 'Quantity Used';
|
||||
let thQuantityProduced = document.createElement("th");
|
||||
thQuantityProduced.classList.add(flagQuantityProduced);
|
||||
thQuantityProduced.textContent = 'Quantity Received';
|
||||
thQuantityProduced.textContent = 'Quantity Produced';
|
||||
/*
|
||||
let thCostTotalLocalVatExcl = document.createElement("th");
|
||||
thCostTotalLocalVatExcl.classList.add(flagCostTotalLocalVatExcl);
|
||||
thCostTotalLocalVatExcl.textContent = 'Cost Total Local VAT Excl';
|
||||
@@ -170,9 +169,13 @@ export default class PageStoreManufacturingPurchaseOrders extends TableBasePage
|
||||
let thCostUnitLocalVatIncl = document.createElement("th");
|
||||
thCostUnitLocalVatIncl.classList.add(flagCostUnitLocalVatIncl);
|
||||
thCostUnitLocalVatIncl.textContent = 'Cost Unit Local VAT Incl';
|
||||
*/
|
||||
let thUnitMeasurementLatencyManufacture = document.createElement("th");
|
||||
thUnitMeasurementLatencyManufacture.classList.add(flagUnitMeasurementLatencyManufacture);
|
||||
thUnitMeasurementLatencyManufacture.textContent = 'Unit Measurement Latency Manufacture';
|
||||
let thLatencyManufacture = document.createElement("th");
|
||||
thLatencyManufacture.classList.add(flagLatencyManufacture);
|
||||
thLatencyManufacture.textContent = 'Latency Delivery (Days)';
|
||||
thLatencyManufacture.textContent = 'Latency Manufacture';
|
||||
let thActive = document.createElement("th");
|
||||
thActive.classList.add(flagActive);
|
||||
thActive.textContent = 'Active';
|
||||
@@ -190,10 +193,13 @@ export default class PageStoreManufacturingPurchaseOrders extends TableBasePage
|
||||
tr.appendChild(thUnitQuantity);
|
||||
tr.appendChild(thQuantityUsed);
|
||||
tr.appendChild(thQuantityProduced);
|
||||
/*
|
||||
tr.appendChild(thCostTotalLocalVatExcl);
|
||||
tr.appendChild(thCostTotalLocalVatIncl);
|
||||
tr.appendChild(thCostUnitLocalVatExcl);
|
||||
tr.appendChild(thCostUnitLocalVatIncl);
|
||||
*/
|
||||
tr.appendChild(thUnitMeasurementLatencyManufacture);
|
||||
tr.appendChild(thLatencyManufacture);
|
||||
tr.appendChild(thActive);
|
||||
tr.appendChild(thAddDelete);
|
||||
@@ -210,11 +216,11 @@ export default class PageStoreManufacturingPurchaseOrders extends TableBasePage
|
||||
let cellNew = cell.cloneNode(false);
|
||||
cellNew.appendChild(tblOrderItems);
|
||||
row.replaceChild(cellNew, cell);
|
||||
console.log("tblOrderItems: ", tblOrderItems);
|
||||
if (_verbose) { console.log("tblOrderItems: ", tblOrderItems); }
|
||||
this.hookupOrderItemsFields();
|
||||
}
|
||||
addRowManufacturingPurchaseOrderItem(tbody, orderItem) { // productVariationTypeOptions, productVariationOptions, productCategoryOptions, productOptions, unitMeasurementOptions,
|
||||
console.log("addRowManufacturingPurchaseOrderItem: ", orderItem);
|
||||
if (_verbose) { console.log("addRowManufacturingPurchaseOrderItem: ", orderItem); }
|
||||
|
||||
let tdDisplayOrder = document.createElement("td");
|
||||
tdDisplayOrder.classList.add(flagDisplayOrder);
|
||||
@@ -245,6 +251,7 @@ export default class PageStoreManufacturingPurchaseOrders extends TableBasePage
|
||||
|
||||
let tdVariations = document.createElement("td");
|
||||
tdVariations.classList.add(flagProductVariations);
|
||||
tdVariations.classList.add(flagCollapsed);
|
||||
DOM.setElementAttributesValuesCurrentAndPrevious(tdVariations, orderItem[attrIdProductCategory]);
|
||||
let divVariations = document.createElement("div");
|
||||
divVariations.classList.add(flagProductVariations);
|
||||
@@ -276,6 +283,7 @@ export default class PageStoreManufacturingPurchaseOrders extends TableBasePage
|
||||
DOM.setElementAttributesValuesCurrentAndPrevious(inputQuantityProduced, orderItem[flagQuantityProduced]);
|
||||
tdQuantityProduced.appendChild(inputQuantityProduced);
|
||||
|
||||
/*
|
||||
let tdCostTotalLocalVatExcl = document.createElement("td");
|
||||
tdCostTotalLocalVatExcl.classList.add(flagCostTotalLocalVatExcl);
|
||||
let inputCostTotalLocalVatExcl = document.createElement("input");
|
||||
@@ -307,7 +315,16 @@ export default class PageStoreManufacturingPurchaseOrders extends TableBasePage
|
||||
divCostUnitLocalVatIncl.classList.add(flagCostUnitLocalVatIncl);
|
||||
DOM.setElementValuesCurrentAndPrevious(divCostUnitLocalVatIncl, orderItem[flagCostUnitLocalVatIncl]);
|
||||
tdCostUnitLocalVatIncl.appendChild(divCostUnitLocalVatIncl);
|
||||
*/
|
||||
|
||||
let tdUnitMeasurementLatencyManufacture = document.createElement("td");
|
||||
tdUnitMeasurementLatencyManufacture.classList.add(flagUnitMeasurementLatencyManufacture);
|
||||
DOM.setElementAttributesValuesCurrentAndPrevious(tdUnitMeasurementLatencyManufacture, orderItem[attrIdUnitMeasurementLatencyManufacture]);
|
||||
let divUnitMeasurementLatencyManufacture = document.createElement("div");
|
||||
divUnitMeasurementLatencyManufacture.classList.add(flagUnitMeasurementLatencyManufacture);
|
||||
// DOM.setElementValuesCurrentAndPrevious(divUnitMeasurementLatencyManufacture, orderItem[flagUnitMeasurementLatencyManufacture]);
|
||||
tdUnitMeasurementLatencyManufacture.appendChild(divUnitMeasurementLatencyManufacture);
|
||||
|
||||
let tdLatencyManufacture = document.createElement("td");
|
||||
tdLatencyManufacture.classList.add(flagLatencyManufacture);
|
||||
let inputLatencyManufacture = document.createElement("input");
|
||||
@@ -343,10 +360,13 @@ export default class PageStoreManufacturingPurchaseOrders extends TableBasePage
|
||||
tr.appendChild(tdUnitQuantity);
|
||||
tr.appendChild(tdQuantityUsed);
|
||||
tr.appendChild(tdQuantityProduced);
|
||||
/*
|
||||
tr.appendChild(tdCostTotalLocalVatExcl);
|
||||
tr.appendChild(tdCostTotalLocalVatIncl);
|
||||
tr.appendChild(tdCostUnitLocalVatExcl);
|
||||
tr.appendChild(tdCostUnitLocalVatIncl);
|
||||
*/
|
||||
tr.appendChild(tdUnitMeasurementLatencyManufacture);
|
||||
tr.appendChild(tdLatencyManufacture);
|
||||
tr.appendChild(tdActive);
|
||||
tr.appendChild(tdDelete);
|
||||
@@ -368,9 +388,6 @@ export default class PageStoreManufacturingPurchaseOrders extends TableBasePage
|
||||
hookupFieldsOrderItemProductVariations() {
|
||||
this.hookupEventHandler("click", idTableMain + ' td.' + flagOrderItems + ' td.' + flagProductVariations, (event, element) => this.handleClickProductPermutationVariationsPreview(event, element));
|
||||
}
|
||||
handleChangeElementProductVariationsSubtableCell(event, element) {
|
||||
this.handleChangeNestedElementCellTable(event, element); // , flagProductVariations);
|
||||
}
|
||||
hookupFieldsOrderItemUnitQuantity() {
|
||||
this.hookupTableCellDdlPreviews(idTableMain + ' td.' + flagOrderItems + ' td.' + flagUnitMeasurementQuantity, Utils.getListFromDict(unitMeasurements));
|
||||
}
|
||||
@@ -380,6 +397,7 @@ export default class PageStoreManufacturingPurchaseOrders extends TableBasePage
|
||||
hookupFieldsOrderItemQuantityProduced() {
|
||||
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagOrderItems + ' td.' + flagQuantityProduced + ' input');
|
||||
}
|
||||
/*
|
||||
hookupFieldsOrderItemPriceTotalLocalVatExcl() {
|
||||
this.hookupChangeHandlerTableCells(
|
||||
idTableMain + ' td.' + flagOrderItems + ' td.' + flagPriceTotalLocalVatExcl + ' input'
|
||||
@@ -438,6 +456,7 @@ export default class PageStoreManufacturingPurchaseOrders extends TableBasePage
|
||||
hookupFieldsOrderItemPriceUnitLocalVatIncl() {
|
||||
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagOrderItems + ' td.' + flagPriceUnitLocalVatIncl + ' input');
|
||||
}
|
||||
*/
|
||||
hookupFieldsOrderItemUnitMeasurementLatencyManufacture() {
|
||||
this.hookupTableCellDdlPreviews(idTableMain + ' td.' + flagOrderItems + ' td.' + flagUnitMeasurementLatencyManufacture, Utils.getListFromDict(unitMeasurementsTime));
|
||||
}
|
||||
@@ -459,11 +478,11 @@ export default class PageStoreManufacturingPurchaseOrders extends TableBasePage
|
||||
this.hookupEventHandler("click", idTableMain + ' td.' + flagOrderItems + ' th button.' + flagAdd, (event, element) => {
|
||||
let row = element.closest(idTableMain + ' > tbody > tr');
|
||||
let idManufacturingPurchaseOrder = row.getAttribute(attrIdManufacturingPurchaseOrder);
|
||||
let hasActiveOrderItem = row.querySelectorAll('td.' + flagOrderItems + ' input.' + flagActive + ':checked').length > 0;
|
||||
let countManufacturingOrderItemes = row.querySelectorAll('td.' + flagOrderItems + ' td.' + flagManufacturingPurchaseOrder).length;
|
||||
// let hasActiveOrderItem = row.querySelectorAll('td.' + flagOrderItems + ' input.' + flagActive + ':checked').length > 0;
|
||||
let countManufacturingOrderItems = row.querySelectorAll('td.' + flagOrderItems + ' td.' + flagManufacturingPurchaseOrder).length;
|
||||
let manufacturingPurchaseOrderItem = {
|
||||
[attrIdManufacturingPurchaseOrder]: idManufacturingPurchaseOrder,
|
||||
[attrIdManufacturingPurchaseOrderProductLink]: -1 - countManufacturingOrderItemes,
|
||||
[attrIdManufacturingPurchaseOrderProductLink]: -1 - countManufacturingOrderItems,
|
||||
[attrIdProductCategory]: 0,
|
||||
[attrIdProduct]: 0,
|
||||
[flagProductVariations]: '',
|
||||
@@ -473,10 +492,10 @@ export default class PageStoreManufacturingPurchaseOrders extends TableBasePage
|
||||
[attrIdUnitMeasurementLatencyManufacture]: 0,
|
||||
[flagLatencyManufacture]: '',
|
||||
[flagDisplayOrder]: countManufacturingOrderItems + 1,
|
||||
[flagActive]: !hasActiveOrderItem,
|
||||
[flagActive]: true, // !hasActiveOrderItem,
|
||||
};
|
||||
let tbody = row.querySelector('td.' + flagOrderItems + ' table tbody');
|
||||
this.addRowManufacturingOrderItem(tbody, manufacturingPurchaseOrderItem);
|
||||
this.addRowManufacturingPurchaseOrderItem(tbody, manufacturingPurchaseOrderItem);
|
||||
/*
|
||||
if (!hasActiveOrderItem) {
|
||||
let tdOrderItem = row.querySelector('td.' + flagOrderItems);
|
||||
|
||||
@@ -65,7 +65,7 @@ export default class StoreMixinPage {
|
||||
});
|
||||
dropdownCurrency.addEventListener("change", function() {
|
||||
let selectedCurrency = dropdownCurrency.val();
|
||||
console.log("selected currency: ", selectedCurrency);
|
||||
if (_verbose) { console.log("selected currency: ", selectedCurrency); }
|
||||
let basket = LocalStorage.getLocalStorage(keyBasket);
|
||||
basket[keyIdCurrency] = selectedCurrency;
|
||||
// LocalStorage.setLocalStorage(keyIdCurrency, selectedCurrency);
|
||||
@@ -109,17 +109,17 @@ export default class StoreMixinPage {
|
||||
Events.initialiseEventHandler(dropdownRegion, flagInitialised, function() {
|
||||
dropdownRegion = document.querySelectorAll(dropdownRegion);
|
||||
dropdownRegion.addEventListener("focus", function() {
|
||||
console.log("dropdown region focused");
|
||||
if (_verbose) { console.log("dropdown region focused"); }
|
||||
handleSelectExpand(dropdownRegion);
|
||||
});
|
||||
dropdownRegion.addEventListener("blur", function() {
|
||||
console.log("dropdown region blurred");
|
||||
if (_verbose) { console.log("dropdown region blurred"); }
|
||||
handleSelectCollapse(dropdownRegion);
|
||||
});
|
||||
dropdownRegion.addEventListener("change", function() {
|
||||
handleSelectCollapse(dropdownRegion);
|
||||
let selectedRegion = dropdownRegion.val();
|
||||
console.log("selected region: ", selectedRegion);
|
||||
if (_verbose) { console.log("selected region: ", selectedRegion); }
|
||||
let basket = LocalStorage.getLocalStorage(keyBasket);
|
||||
basket[keyIdRegionDelivery] = selectedRegion;
|
||||
// LocalStorage.setLocalStorage(keyIdRegionDelivery, selectedRegion);
|
||||
@@ -138,10 +138,13 @@ export default class StoreMixinPage {
|
||||
elSelector.addEventListener("change", function(event) {
|
||||
ajaxData = {};
|
||||
ajaxData[flagForm] = convertForm2JSON(elForm);
|
||||
console.log('sending data to include VAT controller: '); console.log(ajaxData);
|
||||
if (_verbose) {
|
||||
console.log('sending data to include VAT controller: ');
|
||||
console.log(ajaxData);
|
||||
}
|
||||
ajaxJSONData('set include VAT', mapHashToController(hashStoreSetIsIncludedVAT), ajaxData, function() { window.location.reload() }, false);
|
||||
});
|
||||
console.log("form is included VAT initialised")
|
||||
if (_verbose) { console.log("form is included VAT initialised"); }
|
||||
});
|
||||
}
|
||||
hookupLocalStorage() {
|
||||
@@ -153,7 +156,7 @@ export default class StoreMixinPage {
|
||||
// console.log('d:'); console.log(d);
|
||||
let basketLocalStorage = LocalStorage.getLocalStorage(keyBasket);
|
||||
if (!StoreMixinPage.validateBasket(basketLocalStorage)) {
|
||||
console.log('locally-stored basket not valid');
|
||||
if (_verbose) { console.log('locally-stored basket not valid'); }
|
||||
basketLocalStorage = StoreMixinPage.makeNewBasket();
|
||||
}
|
||||
let basketServer = StoreMixinPage.validateBasket(userBasket) ? userBasket : basketLocalStorage;
|
||||
@@ -216,7 +219,7 @@ export default class StoreMixinPage {
|
||||
this.hookupDeleteBasketItemButtons();
|
||||
}
|
||||
toggleShowButtonCheckout() {
|
||||
console.log("toggling checkout button");
|
||||
if (_verbose) { console.log("toggling checkout button"); }
|
||||
const buttonCheckout = document.querySelectorAll(idButtonCheckout);
|
||||
const labelBasketEmpty = document.querySelectorAll(idLabelBasketEmpty);
|
||||
if (userBasket['items'].length == 0) {
|
||||
@@ -228,7 +231,7 @@ export default class StoreMixinPage {
|
||||
}
|
||||
}
|
||||
hookupButtonCheckout() {
|
||||
console.log("hooking up checkout button");
|
||||
if (_verbose) { console.log("hooking up checkout button"); }
|
||||
const buttonCheckout = document.querySelectorAll(idButtonCheckout);
|
||||
// let lsPage = getPageLocalStorage(hashPageCurrent);
|
||||
Events.initialiseEventHandler(buttonCheckout, flagInitialised, function() {
|
||||
@@ -383,7 +386,7 @@ export default class StoreMixinPage {
|
||||
getCurrencySelected() {
|
||||
let elementSelectorCurrency = document.querySelectorAll(idSelectorCurrency);
|
||||
let selectedCurrency = elementSelectorCurrency.val();
|
||||
console.log("selected currency: ", selectedCurrency);
|
||||
if (_verbose) { console.log("selected currency: ", selectedCurrency); }
|
||||
return selectedCurrency;
|
||||
}
|
||||
|
||||
@@ -392,13 +395,15 @@ export default class StoreMixinPage {
|
||||
let d; // , lsShared;
|
||||
let selectorCardProduct = '.card.subcard';
|
||||
Events.initialiseEventHandler(selectorCardProduct, flagInitialised, function(cardProduct) {
|
||||
console.log("initialising product card: ", cardProduct);
|
||||
if (_verbose) { console.log("initialising product card: ", cardProduct); }
|
||||
cardProduct.addEventListener("click", function(event) {
|
||||
// d = { keyIdProduct: product.getAttribute(attrIdProduct) }
|
||||
var elemClicked = event.target;
|
||||
if (elemClicked.id != 'submit') { // disable for submit buttons
|
||||
console.log("product click: " + cardProduct.getAttribute(attrIdProduct));
|
||||
console.log("permutation click: " + cardProduct.getAttribute(attrIdPermutation));
|
||||
if (_verbose) {
|
||||
console.log("product click: " + cardProduct.getAttribute(attrIdProduct));
|
||||
console.log("permutation click: " + cardProduct.getAttribute(attrIdPermutation));
|
||||
}
|
||||
var d = {}
|
||||
d[keyIdProduct] = cardProduct.getAttribute(attrIdProduct)
|
||||
d[keyIdPermutation] = cardProduct.getAttribute(attrIdPermutation)
|
||||
@@ -406,7 +411,7 @@ export default class StoreMixinPage {
|
||||
goToPage(hashPageStoreProduct, d);
|
||||
}
|
||||
});
|
||||
console.log("click method added for product ID: " + cardProduct.getAttribute(attrIdProduct) + ', permutation ID: ', cardProduct.getAttribute(attrIdPermutation));
|
||||
if (_verbose) { console.log("click method added for product ID: " + cardProduct.getAttribute(attrIdProduct) + ', permutation ID: ', cardProduct.getAttribute(attrIdPermutation)); }
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -33,13 +33,13 @@ export default class PageStoreProductCategories extends TableBasePage {
|
||||
|
||||
loadRowTable(rowJson) {
|
||||
if (rowJson == null) return;
|
||||
if (_verbose) { console.log("applying data row: ", rowJson); }
|
||||
let row = _rowBlank.cloneNode(true);
|
||||
row.classList.remove(flagRowNew);
|
||||
row.classList.remove(flagInitialised);
|
||||
row.querySelectorAll('.' + flagInitialised).forEach(function(element) {
|
||||
element.classList.remove(flagInitialised);
|
||||
});
|
||||
console.log("applying data row: ", rowJson);
|
||||
let sliderDisplayOrder = row.querySelector('td.' + flagDisplayOrder + ' .' + flagSlider);
|
||||
let textareaCode = row.querySelector('td.' + flagCode + ' textarea');
|
||||
let textareaName = row.querySelector('td.' + flagName + ' textarea');
|
||||
@@ -75,13 +75,13 @@ export default class PageStoreProductCategories extends TableBasePage {
|
||||
|
||||
let jsonCategory = {};
|
||||
jsonCategory[attrIdProductCategory] = row.getAttribute(attrIdProductCategory);
|
||||
jsonCategory[flagCode] = DOM.getElementValueCurrent(textareaCode);
|
||||
jsonCategory[flagName] = DOM.getElementValueCurrent(textareaName);
|
||||
jsonCategory[flagDescription] = DOM.getElementValueCurrent(textareaDescription);
|
||||
jsonCategory[flagCode] = DOM.getElementAttributeValueCurrent(textareaCode);
|
||||
jsonCategory[flagName] = DOM.getElementAttributeValueCurrent(textareaName);
|
||||
jsonCategory[flagDescription] = DOM.getElementAttributeValueCurrent(textareaDescription);
|
||||
// jsonCategory[flagAccessLevelRequired] = tdAccessLevel.getAttribute(flagAccessLevelRequired);
|
||||
jsonCategory[attrIdAccessLevel] = DOM.getElementValueCurrent(tdAccessLevel);
|
||||
jsonCategory[flagActive] = DOM.getElementValueCurrent(inputActive);
|
||||
jsonCategory[flagDisplayOrder] = sliderDisplayOrder.getAttribute(attrValueCurrent);
|
||||
jsonCategory[attrIdAccessLevel] = DOM.getElementAttributeValueCurrent(tdAccessLevel);
|
||||
jsonCategory[flagActive] = DOM.getElementAttributeValueCurrent(inputActive);
|
||||
jsonCategory[flagDisplayOrder] = DOM.getElementAttributeValueCurrent(sliderDisplayOrder);
|
||||
return jsonCategory;
|
||||
}
|
||||
initialiseRowNew(row) {
|
||||
|
||||
@@ -67,12 +67,12 @@ export default class PageStoreProductPermutations extends TableBasePage {
|
||||
}
|
||||
|
||||
loadRowTable(rowJson) {
|
||||
/*
|
||||
if (rowJson == null) return;
|
||||
if (_verbose) { console.log("applying data row: ", rowJson); }
|
||||
/*
|
||||
let tableMain = TableBasePage.getTableMain();
|
||||
let row = _rowBlank.cloneNode(true);
|
||||
row.classList.remove(flagRowNew);
|
||||
console.log("applying data row: ", rowJson);
|
||||
let dllCategory = row.querySelector('td.' + flagProductCategory + ' select');
|
||||
dllCategory.value = rowJson[attrIdProductCategory];
|
||||
let ddlProduct = row.querySelector('td.' + flagProduct + ' select');
|
||||
@@ -130,7 +130,8 @@ export default class PageStoreProductPermutations extends TableBasePage {
|
||||
let tdProduct = row.querySelector('td.' + flagProduct);
|
||||
let tdProductVariations = row.querySelector('td.' + flagProductVariations);
|
||||
let inputDescription = row.querySelector('td.' + flagDescription + ' textarea');
|
||||
let inputCostLocal = row.querySelector('td.' + flagCostLocal + ' input');
|
||||
let inputCostLocalVatExcl = row.querySelector('td.' + flagCostUnitLocalVatExcl + ' input');
|
||||
let inputCostLocalVatIncl = row.querySelector('td.' + flagCostUnitLocalVatIncl + ' input');
|
||||
let tdCurrencyCost = row.querySelector('td.' + flagCurrencyCost);
|
||||
let inputProfitLocalMin = row.querySelector('td.' + flagProfitLocalMin + ' input');
|
||||
let inputLatencyManufactureDays = row.querySelector('td.' + flagLatencyManufacture + ' input');
|
||||
@@ -155,7 +156,8 @@ export default class PageStoreProductPermutations extends TableBasePage {
|
||||
jsonRow[flagProductVariations] = tdProductVariations.getAttribute(attrValueCurrent);
|
||||
jsonRow[flagHasVariations] = jsonRow[flagProductVariations] != '';
|
||||
jsonRow[flagDescription] = inputDescription.getAttribute(attrValueCurrent);
|
||||
jsonRow[flagCostLocal] = inputCostLocal.getAttribute(attrValueCurrent);
|
||||
jsonRow[flagCostUnitLocalVatExcl] = inputCostLocalVatExcl.getAttribute(attrValueCurrent);
|
||||
jsonRow[flagCostUnitLocalVatIncl] = inputCostLocalVatIncl.getAttribute(attrValueCurrent);
|
||||
jsonRow[flagCurrencyCost] = tdCurrencyCost.getAttribute(attrValueCurrent);
|
||||
jsonRow[flagProfitLocalMin] = inputProfitLocalMin.getAttribute(attrValueCurrent);
|
||||
jsonRow[flagLatencyManufacture] = inputLatencyManufactureDays.getAttribute(attrValueCurrent);
|
||||
@@ -181,8 +183,10 @@ export default class PageStoreProductPermutations extends TableBasePage {
|
||||
let ddlProductFilter = document.querySelector(idFormFilters + ' #' + attrIdProduct);
|
||||
let idProductFilter = DOM.getElementValueCurrent(ddlProductFilter);
|
||||
let hasProductFilter = !(Validation.isEmpty(idProductFilter) || idProductFilter == '0');
|
||||
console.log("initialiseRowNew: ", row);
|
||||
console.log({ddlCategoryFilter, idProductCategoryFilter, hasCategoryFilter, ddlProductFilter, idProductFilter, hasProductFilter});
|
||||
if (_verbose) {
|
||||
console.log("initialiseRowNew: ", row);
|
||||
console.log({ddlCategoryFilter, idProductCategoryFilter, hasCategoryFilter, ddlProductFilter, idProductFilter, hasProductFilter});
|
||||
}
|
||||
if (!hasCategoryFilter && !hasProductFilter) return;
|
||||
if (hasCategoryFilter) {
|
||||
let ddlCategory = row.querySelector('td.' + flagProductCategory + ' select');
|
||||
@@ -231,7 +235,10 @@ export default class PageStoreProductPermutations extends TableBasePage {
|
||||
this.hookupTableCellDdlPreviews(idTableMain + ' td.' + flagCurrencyCost, Utils.getListFromDict(currencies));
|
||||
}
|
||||
hookupCostInputs(){
|
||||
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagCostLocal + ' input');
|
||||
/*
|
||||
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagCostUnitLocalVatExcl + ' input');
|
||||
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagCostUnitLocalVatIncl + ' input');
|
||||
*/
|
||||
}
|
||||
hookupProfitFields(){
|
||||
// this.hookupCurrencyProfitFields();
|
||||
@@ -268,7 +275,6 @@ export default class PageStoreProductPermutations extends TableBasePage {
|
||||
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagCountUnitMeasurementPerQuantityStep + ' input');
|
||||
}
|
||||
hookupUnitMeasurementQuantityFields() {
|
||||
console.log("hooking up unit measurement quantity fields");
|
||||
this.hookupTableCellDdlPreviews(idTableMain + ' td.' + flagUnitMeasurementQuantity, Utils.getListFromDict(unitMeasurements));
|
||||
}
|
||||
hookupSubscriptionFields() {
|
||||
|
||||
@@ -40,7 +40,6 @@ export default class PageStoreProducts extends TableBasePage {
|
||||
row.querySelectorAll('.' + flagInitialised).forEach(function(element) {
|
||||
element.classList.remove(flagInitialised);
|
||||
});
|
||||
console.log("applying data row: ", rowJson);
|
||||
let sliderDisplayOrder = row.querySelector('td.' + flagDisplayOrder + ' .' + flagSlider);
|
||||
let tdProductCategory = row.querySelector('td.' + flagProductCategory);
|
||||
let divProductCategory = tdProductCategory.querySelector('div.' + flagProductCategory);
|
||||
|
||||
@@ -115,8 +115,10 @@ export default class PageStoreStockItems extends TableBasePage {
|
||||
let ddlProductFilter = document.querySelector(idFormFilters + ' #' + attrIdProduct);
|
||||
let idProductFilter = DOM.getElementValueCurrent(ddlProductFilter);
|
||||
let hasProductFilter = !(Validation.isEmpty(idProductFilter) || idProductFilter == '0');
|
||||
console.log("initialiseRowNew: ", row);
|
||||
console.log({ddlCategoryFilter, idProductCategoryFilter, hasCategoryFilter, ddlProductFilter, idProductFilter, hasProductFilter});
|
||||
if (_verbose) {
|
||||
console.log("initialiseRowNew: ", row);
|
||||
console.log({ddlCategoryFilter, idProductCategoryFilter, hasCategoryFilter, ddlProductFilter, idProductFilter, hasProductFilter});
|
||||
}
|
||||
if (!hasCategoryFilter && !hasProductFilter) return;
|
||||
if (hasCategoryFilter) {
|
||||
let ddlCategory = row.querySelector('td.' + flagProductCategory + ' select');
|
||||
@@ -222,7 +224,7 @@ export default class PageStoreStockItems extends TableBasePage {
|
||||
DOM.setElementAttributesValuesCurrentAndPrevious(ddlPlant, plantJson[attrIdPlant]);
|
||||
|
||||
optionPlant = DOM.createOption(null);
|
||||
console.log("optionPlant: ", optionPlant);
|
||||
if (_verbose) { console.log("optionPlant: ", optionPlant); }
|
||||
ddlPlant.appendChild(optionPlant);
|
||||
|
||||
plantKeys.forEach((plantKey) => {
|
||||
@@ -232,7 +234,7 @@ export default class PageStoreStockItems extends TableBasePage {
|
||||
valueSelected = plantJson[attrIdPlant]
|
||||
);
|
||||
optionPlant = DOM.createOption(optionPlantJson);
|
||||
console.log("optionPlant: ", optionPlant);
|
||||
if (_verbose) { console.log("optionPlant: ", optionPlant); }
|
||||
ddlPlant.appendChild(optionPlant);
|
||||
});
|
||||
|
||||
@@ -245,7 +247,7 @@ export default class PageStoreStockItems extends TableBasePage {
|
||||
DOM.setElementAttributesValuesCurrentAndPrevious(ddlStorageLocation, storageLocationJson[attrIdStorageLocation]);
|
||||
|
||||
optionStorageLocation = DOM.createOption(null);
|
||||
console.log("optionStorageLocation: ", optionStorageLocation);
|
||||
if (_verbose) { console.log("optionStorageLocation: ", optionStorageLocation); }
|
||||
ddlStorageLocation.appendChild(optionStorageLocation);
|
||||
|
||||
StorageLocationKeys.forEach((StorageLocationKey) => {
|
||||
@@ -255,7 +257,7 @@ export default class PageStoreStockItems extends TableBasePage {
|
||||
valueSelected = storageLocationJson[attrIdStorageLocation]
|
||||
);
|
||||
optionStorageLocation = DOM.createOption(optionStorageLocationJson);
|
||||
console.log("optionStorageLocation: ", optionStorageLocation);
|
||||
if (_verbose) { console.log("optionStorageLocation: ", optionStorageLocation); }
|
||||
ddlStorageLocation.appendChild(optionStorageLocation);
|
||||
});
|
||||
|
||||
@@ -270,12 +272,12 @@ export default class PageStoreStockItems extends TableBasePage {
|
||||
let parent = element.parentElement;
|
||||
parent.innerHTML = '';
|
||||
parent.appendChild(tblStorageLocation);
|
||||
console.log("tblStorageLocation: ", tblStorageLocation);
|
||||
if (_verbose) { console.log("tblStorageLocation: ", tblStorageLocation); }
|
||||
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagPlant + ' select', (event, element) => { this.handleChangeStoragePlantDdl(event, element); });
|
||||
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagStorageLocation + ' select', (event, element) => { this.handleChangeStorageLocationDdl(event, element); });
|
||||
}
|
||||
handleChangeStoragePlantDdl(event, ddlPlant) {
|
||||
this.handleChangeTableCellDdl(event, ddlPlant);
|
||||
this.handleChangeNestedElementCellTable(event, ddlPlant);
|
||||
let row = DOM.getRowFromElement(ddlPlant);
|
||||
let ddlStorageLocation = row.querySelector('td.' + flagStorageLocation + ' select');
|
||||
ddlStorageLocation.innerHTML = '';
|
||||
@@ -288,10 +290,10 @@ export default class PageStoreStockItems extends TableBasePage {
|
||||
option = DOM.createOption(optionJson);
|
||||
ddlStorageLocation.appendChild(option);
|
||||
});
|
||||
this.handleChangeTableCellDdl(event, ddlStorageLocation);
|
||||
this.handleChangeNestedElementCellTable(event, ddlStorageLocation);
|
||||
}
|
||||
handleChangeStorageLocationDdl(event, ddlStorageLocation) {
|
||||
this.handleChangeTableCellDdl(event, ddlStorageLocation);
|
||||
this.handleChangeNestedElementCellTable(event, ddlStorageLocation);
|
||||
}
|
||||
|
||||
hookupSealingInputs() {
|
||||
|
||||
@@ -129,7 +129,7 @@ export default class PageStoreSupplierPurchaseOrders extends TableBasePage {
|
||||
});
|
||||
}
|
||||
handleClickOrderItemsPreview(event, element) {
|
||||
console.log("click order items preview");
|
||||
if (_verbose) { console.log("click order items preview"); }
|
||||
this.toggleColumnHeaderCollapsed(flagOrderItems, false);
|
||||
element.classList.remove(flagCollapsed);
|
||||
|
||||
@@ -216,11 +216,11 @@ export default class PageStoreSupplierPurchaseOrders extends TableBasePage {
|
||||
let cellNew = cell.cloneNode(false);
|
||||
cellNew.appendChild(tblOrderItems);
|
||||
row.replaceChild(cellNew, cell);
|
||||
console.log("tblOrderItems: ", tblOrderItems);
|
||||
if (_verbose) { console.log("tblOrderItems: ", tblOrderItems); }
|
||||
this.hookupOrderItemsFields();
|
||||
}
|
||||
addRowSupplierPurchaseOrderItem(tbody, orderItem) { // productVariationTypeOptions, productVariationOptions, productCategoryOptions, productOptions, unitMeasurementOptions,
|
||||
console.log("addRowSupplierPurchaseOrderItem: ", orderItem);
|
||||
if (_verbose) { console.log("addRowSupplierPurchaseOrderItem: ", orderItem); }
|
||||
|
||||
let tdDisplayOrder = document.createElement("td");
|
||||
tdDisplayOrder.classList.add(flagDisplayOrder);
|
||||
@@ -255,6 +255,7 @@ export default class PageStoreSupplierPurchaseOrders extends TableBasePage {
|
||||
|
||||
let tdVariations = document.createElement("td");
|
||||
tdVariations.classList.add(flagProductVariations);
|
||||
tdVariations.classList.add(flagCollapsed);
|
||||
DOM.setElementAttributesValuesCurrentAndPrevious(tdVariations, orderItem[attrIdProductVariation]);
|
||||
let divVariations = document.createElement("div");
|
||||
divVariations.classList.add(flagProductVariations);
|
||||
@@ -312,14 +313,14 @@ export default class PageStoreSupplierPurchaseOrders extends TableBasePage {
|
||||
tdCostUnitLocalVatExcl.classList.add(flagCostUnitLocalVatExcl);
|
||||
let divCostUnitLocalVatExcl = document.createElement("div");
|
||||
divCostUnitLocalVatExcl.classList.add(flagCostUnitLocalVatExcl);
|
||||
DOM.setElementValuesCurrentAndPrevious(divCostUnitLocalVatExcl, orderItem[flagCostUnitLocalVatExcl]);
|
||||
DOM.setElementValuesCurrentAndPrevious(divCostUnitLocalVatExcl, orderItem[flagCostUnitLocalVatExcl].toFixed(3));
|
||||
tdCostUnitLocalVatExcl.appendChild(divCostUnitLocalVatExcl);
|
||||
|
||||
let tdCostUnitLocalVatIncl = document.createElement("td");
|
||||
tdCostUnitLocalVatIncl.classList.add(flagCostUnitLocalVatIncl);
|
||||
let divCostUnitLocalVatIncl = document.createElement("div");
|
||||
divCostUnitLocalVatIncl.classList.add(flagCostUnitLocalVatIncl);
|
||||
DOM.setElementValuesCurrentAndPrevious(divCostUnitLocalVatIncl, orderItem[flagCostUnitLocalVatIncl]);
|
||||
DOM.setElementValuesCurrentAndPrevious(divCostUnitLocalVatIncl, orderItem[flagCostUnitLocalVatIncl].toFixed(3));
|
||||
tdCostUnitLocalVatIncl.appendChild(divCostUnitLocalVatIncl);
|
||||
|
||||
let tdLatencyDeliveryDays = document.createElement("td");
|
||||
@@ -384,20 +385,11 @@ export default class PageStoreSupplierPurchaseOrders extends TableBasePage {
|
||||
this.hookupEventHandler("click", idTableMain + ' td.' + flagOrderItems + ' td.' + flagProductVariations, (event, element) => this.handleClickProductPermutationVariationsPreview(event, element));
|
||||
}
|
||||
*/
|
||||
handleChangeElementProductVariationsSubtableCell(event, element) {
|
||||
this.handleChangeNestedElementCellTable(event, element); // flagProductVariations);
|
||||
}
|
||||
hookupDdlsProductPermutationVariation() {
|
||||
this.hookupTableCellDdls(
|
||||
idTableMain + ' td.' + flagProductVariations + ' td.' + flagProductVariation
|
||||
, (event, element) => { this.handleChangeElementProductVariationsSubtableCell(event, element); }
|
||||
);
|
||||
this.hookupTableCellDdls(idTableMain + ' td.' + flagProductVariations + ' td.' + flagProductVariation);
|
||||
}
|
||||
hookupDdlsProductPermutationVariationType() {
|
||||
this.hookupTableCellDdls(
|
||||
idTableMain + ' td.' + flagProductVariations + ' td.' + flagProductVariationType
|
||||
, (event, element) => { this.handleChangeElementProductVariationsSubtableCell(event, element); }
|
||||
);
|
||||
this.hookupTableCellDdls(idTableMain + ' td.' + flagProductVariations + ' td.' + flagProductVariationType);
|
||||
}
|
||||
hookupFieldsOrderItemUnitQuantity() {
|
||||
this.hookupTableCellDdlPreviews(
|
||||
@@ -442,7 +434,7 @@ export default class PageStoreSupplierPurchaseOrders extends TableBasePage {
|
||||
|
||||
let divCostUnitLocalVatExcl = row.querySelector('td.' + flagCostUnitLocalVatExcl + ' div');
|
||||
let costUnitLocalVatExcl = quantityOrdered == 0 ? 0 : costTotalLocalVatExcl / quantityOrdered;
|
||||
DOM.setElementValuesCurrentAndPrevious(divCostUnitLocalVatExcl, costUnitLocalVatExcl);
|
||||
DOM.setElementValuesCurrentAndPrevious(divCostUnitLocalVatExcl, costUnitLocalVatExcl.toFixed(3));
|
||||
|
||||
let rowSupplierPurchaseOrder = row.closest(idTableMain + ' > tbody > tr');
|
||||
let divCostGrandTotalLocalVatExcl = rowSupplierPurchaseOrder.querySelector('td.' + flagCostTotalLocalVatExcl + ' div');
|
||||
@@ -459,7 +451,7 @@ export default class PageStoreSupplierPurchaseOrders extends TableBasePage {
|
||||
|
||||
let divCostUnitLocalVatIncl = row.querySelector('td.' + flagCostUnitLocalVatIncl + ' div');
|
||||
let costUnitLocalVatIncl = quantityOrdered == 0 ? 0 : costTotalLocalVatIncl / quantityOrdered;
|
||||
DOM.setElementValuesCurrentAndPrevious(divCostUnitLocalVatIncl, costUnitLocalVatIncl);
|
||||
DOM.setElementValuesCurrentAndPrevious(divCostUnitLocalVatIncl, costUnitLocalVatIncl.toFixed(3));
|
||||
|
||||
let rowSupplierPurchaseOrder = row.closest(idTableMain + ' > tbody > tr');
|
||||
let divCostGrandTotalLocalVatIncl = rowSupplierPurchaseOrder.querySelector('td.' + flagCostTotalLocalVatIncl + ' div');
|
||||
@@ -485,7 +477,7 @@ export default class PageStoreSupplierPurchaseOrders extends TableBasePage {
|
||||
this.hookupEventHandler("click", idTableMain + ' td.' + flagOrderItems + ' th button.' + flagAdd, (event, element) => {
|
||||
let row = element.closest(idTableMain + ' > tbody > tr');
|
||||
let idSupplierPurchaseOrder = row.getAttribute(attrIdSupplierPurchaseOrder);
|
||||
let hasActiveOrderItem = row.querySelectorAll('td.' + flagOrderItems + ' input.' + flagActive + ':checked').length > 0;
|
||||
// let hasActiveOrderItem = row.querySelectorAll('td.' + flagOrderItems + ' input.' + flagActive + ':checked').length > 0;
|
||||
let countSupplierOrderItems = row.querySelectorAll('td.' + flagOrderItems + ' td.' + flagSupplierPurchaseOrder).length;
|
||||
let supplierOrderItem = {
|
||||
[attrIdSupplierPurchaseOrder]: idSupplierPurchaseOrder,
|
||||
@@ -502,7 +494,7 @@ export default class PageStoreSupplierPurchaseOrders extends TableBasePage {
|
||||
[flagCostUnitLocalVatIncl]: '',
|
||||
[flagLatencyDeliveryDays]: '',
|
||||
[flagDisplayOrder]: countSupplierOrderItems + 1,
|
||||
[flagActive]: !hasActiveOrderItem,
|
||||
[flagActive]: true, // !hasActiveOrderItem,
|
||||
};
|
||||
let tbody = row.querySelector('td.' + flagOrderItems + ' table tbody');
|
||||
this.addRowSupplierPurchaseOrderItem(tbody, supplierOrderItem);
|
||||
|
||||
@@ -132,7 +132,7 @@ export default class PageStoreSuppliers extends TableBasePage {
|
||||
});
|
||||
}
|
||||
handleClickAddressPreview(event, element) {
|
||||
console.log("click address preview");
|
||||
if (_verbose) { console.log("click address preview"); }
|
||||
this.toggleColumnHeaderCollapsed(flagAddress, false);
|
||||
element.classList.remove(flagCollapsed);
|
||||
let row = DOM.getRowFromElement(element);
|
||||
@@ -192,11 +192,11 @@ export default class PageStoreSuppliers extends TableBasePage {
|
||||
let cellNew = cell.cloneNode(false);
|
||||
cellNew.appendChild(tblAddresses);
|
||||
row.replaceChild(cellNew, cell);
|
||||
console.log("tblAddresses: ", tblAddresses);
|
||||
if (_verbose) { console.log("tblAddresses: ", tblAddresses); }
|
||||
this.hookupAddressFields();
|
||||
}
|
||||
addRowSupplierAddress(tbody, supplierAddress, regionOptions) {
|
||||
console.log("addRowSupplierAddress: ", supplierAddress);
|
||||
if (_verbose) { console.log("addRowSupplierAddress: ", supplierAddress); }
|
||||
let tdPostcode = document.createElement("td");
|
||||
tdPostcode.classList.add(flagPostcode);
|
||||
let textareaPostcode = document.createElement("textarea");
|
||||
@@ -279,28 +279,25 @@ export default class PageStoreSuppliers extends TableBasePage {
|
||||
tbody.appendChild(tr);
|
||||
}
|
||||
hookupAddressPostcodeInputs() {
|
||||
this.handleChangeElementAddressSubtableCells(idTableMain + ' td.' + flagAddress + ' textarea.' + flagPostcode);
|
||||
}
|
||||
handleChangeElementAddressSubtableCells(event, element) {
|
||||
this.handleChangeNestedElementCellTable(event, element); // flagAddress);
|
||||
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagAddress + ' textarea.' + flagPostcode);
|
||||
}
|
||||
hookupAddressLine1Inputs() {
|
||||
this.handleChangeElementAddressSubtableCells(idTableMain + ' td.' + flagAddress + ' textarea.' + flagAddressLine1);
|
||||
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagAddress + ' textarea.' + flagAddressLine1);
|
||||
}
|
||||
hookupAddressLine2Inputs() {
|
||||
this.handleChangeElementAddressSubtableCells(idTableMain + ' td.' + flagAddress + ' textarea.' + flagAddressLine2);
|
||||
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagAddress + ' textarea.' + flagAddressLine2);
|
||||
}
|
||||
hookupAddressCityInputs() {
|
||||
this.handleChangeElementAddressSubtableCells(idTableMain + ' td.' + flagAddress + ' textarea.' + flagCity);
|
||||
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagAddress + ' textarea.' + flagCity);
|
||||
}
|
||||
hookupAddressCountyInputs() {
|
||||
this.handleChangeElementAddressSubtableCells(idTableMain + ' td.' + flagAddress + ' textarea.' + flagCounty);
|
||||
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagAddress + ' textarea.' + flagCounty);
|
||||
}
|
||||
hookupAddressRegionDdls() {
|
||||
this.handleChangeElementAddressSubtableCells(idTableMain + ' td.' + flagAddress + ' select.' + flagRegion);
|
||||
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagAddress + ' select.' + flagRegion);
|
||||
}
|
||||
hookupAddressActiveCheckboxes() {
|
||||
this.handleChangeElementAddressSubtableCells(idTableMain + ' td.' + flagAddress + ' input.' + flagActive, (event, element) => {
|
||||
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagAddress + ' input.' + flagActive, (event, element) => {
|
||||
let rowSupplierAddress = element.closest('tr');
|
||||
let idAddress = rowSupplierAddress.getAttribute(attrIdSupplierAddress);
|
||||
DOM.setElementAttributeValueCurrent(rowSupplierAddress, idAddress);
|
||||
|
||||
@@ -143,7 +143,7 @@ export default class Router {
|
||||
return module; // [pageJson.name];
|
||||
}
|
||||
catch (error) {
|
||||
console.log("this.pages: ", this.pages);
|
||||
if (_verbose) { console.log("this.pages: ", this.pages); };
|
||||
console.error('Page not found:', hashPage);
|
||||
throw error;
|
||||
}
|
||||
@@ -169,7 +169,6 @@ export default class Router {
|
||||
// this.beforeLeave();
|
||||
/*
|
||||
if (this.routes[hash]) {
|
||||
console.log("navigating to hash: " + hash);
|
||||
this.routes[hash](isPopState);
|
||||
} else {
|
||||
console.error(`Hash ${hash} not found`);
|
||||
@@ -323,7 +322,6 @@ export default class Router {
|
||||
*/
|
||||
|
||||
static loadPageBodyFromResponse(response) {
|
||||
console.log(response.data);
|
||||
DOM.loadPageBody(response.data);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user