Fix: Product Category save + filter debugging.

This commit is contained in:
2024-11-18 14:02:23 +00:00
parent 2d5783cb01
commit b80be23852
33 changed files with 47013 additions and 168 deletions

View File

@@ -21,6 +21,7 @@ class Base():
ATTR_ID_ACCESS_LEVEL: ClassVar[str] = 'id_access_level'
ATTR_ID_ADDRESS: ClassVar[str] = 'id_address'
ATTR_ID_CURRENCY: ClassVar[str] = 'id_currency'
ATTR_ID_MSG_ERROR_TYPE: ClassVar[str] = 'id_type'
ATTR_ID_REGION: ClassVar[str] = 'id_region'
ATTR_ID_USER: ClassVar[str] = 'id_user'
ATTR_ID_USER_MANAGER: ClassVar[str] = 'id_user_manager'
@@ -49,6 +50,7 @@ class Base():
FLAG_GUID: ClassVar[str] = 'guid'
FLAG_IS_NOT_EMPTY: ClassVar[str] = 'is_not_empty'
# FLAG_KEY_PRIMARY: ClassVar[str] = 'key_primary'
FLAG_MESSAGE: ClassVar[str] = 'message'
FLAG_NAME: ClassVar[str] = 'name'
FLAG_NAME_ATTR_OPTION_TEXT: ClassVar[str] = 'NAME_ATTR_OPTION_TEXT'
FLAG_NAME_ATTR_OPTION_VALUE: ClassVar[str] = 'NAME_ATTR_OPTION_VALUE'

View File

@@ -10,13 +10,8 @@ Description:
Business object for SQL errors
"""
# IMPORTS
# VARIABLE INSTANTIATION
# CLASSES
# METHODS
# IMPORTS
# internal
from business_objects.base import Base
import lib.argument_validation as av
from lib import data_types
from forms.forms import Form_Basket_Add, Form_Basket_Edit # Form_Product
@@ -65,3 +60,12 @@ class SQL_Error(db.Model):
error.name = record[4]
error.description = record[5]
return error
def to_json(self):
return {
Base.FLAG_DISPLAY_ORDER: self.display_order,
Base.ATTR_ID_MSG_ERROR_TYPE: self.id_type,
Base.FLAG_CODE: self.code,
Base.FLAG_MESSAGE: self.msg,
Base.FLAG_NAME: self.name,
Base.FLAG_DESCRIPTION: self.description,
}

View File

@@ -603,7 +603,7 @@ class Parameters_Product(Get_Many_Parameters_Base):
def from_filters_product_category(cls, filters_category):
return cls(
get_all_product_category = True,
get_inactive_product_category = filters_category.active.data,
get_inactive_product_category = not filters_category.active.data,
ids_product_category = '',
get_all_product = True,
get_inactive_product = False,

View File

@@ -524,3 +524,6 @@ class Product_Category_Temp(db.Model, Store_Base):
'created_on': self.created_on,
'created_by': self.created_by
"""
def __repr__(self):
return str(self.__dict__)

View File

@@ -125,3 +125,5 @@ class Store_Base(Base):
FLAG_UNIT_MEASUREMENT_QUANTITY: ClassVar[str] = 'unit_measurement_quantity'
FLAG_VALUE_TEXT: ClassVar[str] = 'value_text'
def __repr__(self):
return str(self.__dict__)

View File

@@ -82,11 +82,16 @@ def save_category():
objsCategory.append(Product_Category.from_json(category))
# model_save = Model_View_Store_Product_Category() # filters_product=filters_form)
Helper_App.console_log(f'objsCategory={objsCategory}')
Model_View_Store_Product_Category.save_categories(data.get('comment', 'No comment'), objsCategory)
errors = Model_View_Store_Product_Category.save_categories(data.get('comment', 'No comment'), objsCategory)
model_return = Model_View_Store_Product_Category(form_filters_old=form_filters)
if not model_return.is_user_logged_in:
raise Exception('User not logged in')
if (len(errors) > 0):
return jsonify({
Model_View_Store_Product_Category.FLAG_STATUS: Model_View_Store_Product_Category.FLAG_FAILURE,
Model_View_Store_Product_Category.FLAG_MESSAGE: f'Error saving categories.\n{model_return.convert_list_objects_to_json(errors)}'
})
return jsonify({
Model_View_Store_Product_Category.FLAG_STATUS: Model_View_Store_Product_Category.FLAG_SUCCESS,
Model_View_Store_Product_Category.FLAG_DATA: model_return.category_list.to_json()

View File

@@ -45,6 +45,8 @@ from flask import Flask, session, current_app
from pydantic import BaseModel, ConfigDict
from typing import ClassVar
from datetime import datetime
import time
from sqlalchemy.exc import OperationalError
# db = SQLAlchemy()
@@ -206,6 +208,7 @@ class DataStore_Base(BaseModel):
cursor.close()
return users, errors
@staticmethod
def upload_bulk(permanent_table_name, records, batch_size):
_m = 'DataStore_Base.upload_bulk'
@@ -222,12 +225,15 @@ class DataStore_Base(BaseModel):
else:
expected_columns = set(column.name for column in db.inspect(table_object).columns)
Helper_App.console_log(f'expected_columns: {expected_columns}')
""" v1, v2
try:
for i in range(0, len(records), batch_size):
"" v1
batch = records[i:i+batch_size]
Helper_App.console_log(f'batch: {batch}')
db.session.bulk_save_objects(batch)
"""
""
""
data = [object.to_json() for object in batch]
Helper_App.console_log(f'data: {data}')
for row in data:
@@ -237,12 +243,38 @@ class DataStore_Base(BaseModel):
Helper_App.console_log(f'missing columns: {expected_columns - row_keys}')
Helper_App.console_log(f'extra columns: {row_keys - expected_columns}')
# db.session.bulk_insert_mappings(permanent_table_name, data)
"""
db.session.commit()
""
except Exception as e:
Helper_App.console_log(f'{_m}\n{e}')
db.session.rollback()
raise e
"""
max_retries = 3
initial_backoff = 1
for i in range(0, len(records), batch_size):
batch = records[i:i + batch_size]
try:
retries = 0
while retries < max_retries:
try:
db.session.bulk_save_objects(batch)
db.session.commit()
break
except OperationalError as e:
if "Lock wait timeout exceeded" not in str(e) or retries == max_retries - 1:
raise
wait_time = initial_backoff * (2 ** retries)
current_app.logger.warning(f"Lock timeout encountered. Retrying in {wait_time} seconds... (Attempt {retries + 1}/{max_retries})")
time.sleep(wait_time)
retries += 1
# Ensure the session is clean for the retry
db.session.rollback()
except Exception as e:
db.session.rollback()
raise e
@classmethod
def get_many_access_level(cls, filters=None):
_m = 'DataStore_Store_Base.get_many_access_level'

View File

@@ -85,6 +85,19 @@ class DataStore_Store_Product_Category(DataStore_Store_Base):
'a_debug': 0,
}
save_result = cls.db_procedure_execute('p_shop_save_product_category', argument_dict_list)
# Errors
cursor = save_result.cursor
result_set_e = cursor.fetchall()
Helper_App.console_log(f'raw errors: {result_set_e}')
errors = []
if len(result_set_e) > 0:
errors = [SQL_Error.from_DB_record(row) for row in result_set_e] # (row[0], row[1])
for error in errors:
Helper_App.console_log(f"Error [{error.code}]: {error.msg}")
DataStore_Store_Product_Category.db_cursor_clear(cursor)
save_result.close()
Helper_App.console_log('save procedure executed')
return errors

View File

@@ -55,4 +55,4 @@ class Model_View_Store_Product_Category(Model_View_Store):
@classmethod
def save_categories(cls, comment, list_categories):
_m = f'{cls.__name__}.save_categories'
DataStore_Store_Product_Category().save_categories(comment, list_categories)
return DataStore_Store_Product_Category().save_categories(comment, list_categories)

21301
static/MySQL/0000_combine.sql Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -100,7 +100,7 @@ BEGIN
, is_new
)
SELECT
IFNULL(PC_T.id_category, PC.id_category) AS id_category
PC_T.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
@@ -109,8 +109,8 @@ BEGIN
, 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
FROM partsltd_prod.Shop_Product_Category_Temp PC_T
LEFT JOIN partsltd_prod.Shop_Product_Category PC ON PC_T.id_category = PC.id_category
WHERE PC_T.guid = a_guid
;
@@ -163,18 +163,37 @@ BEGIN
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_Category t_C
ON P.id_category = t_C.id_category
AND t_C.is_new = 0
WHERE P.active = 1
);
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);
IF a_debug = 1 THEN
SELECT
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
;
END IF;
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_Category t_C
INNER JOIN Shop_Product P ON t_C.id_category = P.id_product
@@ -187,22 +206,24 @@ BEGIN
, t_C.can_admin = UE_T.can_admin
;
CALL p_shop_clear_calc_user(a_guid);
END IF;
END IF;
CALL p_shop_clear_calc_user(
a_guid
, 0 -- a_debug
);
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 )
INSERT INTO partsltd_prod.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
UPDATE partsltd_prod.Shop_Product_Category PC
INNER JOIN tmp_Category t_C
ON PC.id_category = t_C.id_category
AND t_C.is_new = 0
SET
PC.id_category = t_C.id_category
, PC.code = t_C.code
@@ -213,9 +234,8 @@ BEGIN
, PC.display_order = t_C.display_order
, PC.id_change_set = v_id_change_set
;
END IF;
INSERT INTO Shop_Product_Category (
INSERT INTO partsltd_prod.Shop_Product_Category (
code
, name
, description
@@ -236,16 +256,21 @@ BEGIN
, a_id_user AS created_by
, v_time_start AS created_on
FROM tmp_Category t_C
WHERE is_new = 1
AND active = 1
WHERE
t_C.is_new = 1
AND t_C.active = 1
;
DELETE FROM Shop_Product_Category_Temp
WHERE GUID = a_guid;
COMMIT;
END IF;
START TRANSACTION;
DELETE FROM partsltd_prod.Shop_Product_Category_Temp
WHERE GUID = a_guid;
COMMIT;
# Errors
SELECT *
FROM tmp_Msg_Error t_ME
@@ -253,10 +278,10 @@ BEGIN
;
IF a_debug = 1 THEN
SELECT * from tmp_Catgory;
SELECT * from tmp_Category;
END IF;
DROP TEMPORARY TABLE tmp_Catgory;
DROP TEMPORARY TABLE tmp_Category;
DROP TEMPORARY TABLE tmp_Msg_Error;
IF a_debug = 1 THEN
@@ -265,3 +290,27 @@ BEGIN
END //
DELIMITER ;;
/*
select
*
-- COUNT(*)
-- delete
from partsltd_prod.Shop_Product_Category_Temp
;
CALL partsltd_prod.p_shop_save_product_category (
'nipples'
, (SELECT GUID FROM partsltd_prod.Shop_Product_Category_Temp ORDER BY id_temp DESC LIMIT 1)
, 1
, 1
);
select
*
-- COUNT(*)
-- delete
from partsltd_prod.Shop_Product_Category_Temp
;
*/

View File

@@ -292,11 +292,16 @@ BEGIN
WHERE is_new = 1
;
DELETE FROM partsltd_prod.Shop_Product_Category_Temp
WHERE GUID = a_guid;
COMMIT;
END IF;
START TRANSACTION;
DELETE FROM partsltd_prod.Shop_Product_Category_Temp
WHERE GUID = a_guid;
COMMIT;
SELECT *
FROM tmp_Msg_Error t_ME
INNER JOIN partsltd_prod.Shop_Msg_Error_Type MET ON t_ME.id_type = MET.id_type

View File

@@ -604,8 +604,11 @@ BEGIN
, PPVL.active = t_PPVL.active
, PPVL.id_change_set = v_id_change_set
;
COMMIT;
END IF;
START TRANSACTION;
DELETE FROM Shop_Product_Permutation_Temp
WHERE GUID = a_guid

View File

@@ -511,6 +511,11 @@ BEGIN
, V.id_change_set = v_id_change_set
;
COMMIT;
END IF;
START TRANSACTION;
DELETE VT_T
FROM partsltd_prod.Shop_Variation_Type_Temp VT_T
WHERE VT_T.GUID = a_guid
@@ -521,7 +526,6 @@ BEGIN
;
COMMIT;
END IF;
# Errors
SELECT *

View File

@@ -590,11 +590,15 @@ BEGIN
AND active = 1
;
COMMIT;
END IF;
START TRANSACTION;
DELETE FROM partsltd_prod.Shop_Stock_Item_Temp
WHERE GUID = a_guid;
COMMIT;
END IF;
# Errors
SELECT *

View File

@@ -248,11 +248,15 @@ BEGIN
, U.id_change_set = v_id_change_set
;
COMMIT;
END IF;
START TRANSACTION;
DELETE FROM Shop_User_Temp
WHERE GUID = a_guid;
COMMIT;
END IF;
# Errors
SELECT *

View File

@@ -558,6 +558,13 @@ BEGIN
COMMIT;
END IF;
START TRANSACTION;
DELETE FROM partsltd_prod.Shop_Supplier_Temp
WHERE GUID = a_guid;
DELETE FROM partsltd_prod.Shop_Supplier_Address_Temp
WHERE GUID = a_guid;
COMMIT;
# Errors
SELECT *
FROM tmp_Msg_Error t_ME

View File

@@ -756,6 +756,11 @@ BEGIN
, SPOPL.id_change_set = v_id_change_set
;
COMMIT;
END IF;
START TRANSACTION;
DELETE SPO_T
FROM Shop_Supplier_Purchase_Order_Temp SPO_T
WHERE SPO_T.GUID = a_guid
@@ -766,7 +771,6 @@ BEGIN
;
COMMIT;
END IF;
# Errors
SELECT *

View File

@@ -921,6 +921,11 @@ BEGIN
, MPOPL.id_change_set = v_id_change_set
;
COMMIT;
END IF;
START TRANSACTION;
DELETE MPO_T
FROM partsltd_prod.Shop_Manufacturing_Purchase_Order_Temp MPO_T
WHERE MPO_T.GUID = a_guid
@@ -931,7 +936,6 @@ BEGIN
;
COMMIT;
END IF;
# Errors
SELECT *

221
static/MySQL/temp.txt Normal file
View File

@@ -0,0 +1,221 @@
0001_destroy.sql
1000_tbl_Shop_Product_Change_Set.sql
1000_tbl_Split_Temp.sql
1001_tbl_Shop_User_Change_Set.sql
1001_tbl_Split_Key_Value_Pair_Csv_Temp.sql
1002_tbl_Shop_Sales_And_Purchasing_Change_Set.sql
1003_tbl_Shop_Access_Level.sql
1004_tbl_Shop_Access_Level_Audit.sql
1005_tbl_Msg_Error_Type.sql
1010_tbl_File_Type.sql
1011_tbl_File_Type_Audit.sql
1012_tbl_Shop_General.sql
1013_tbl_Shop_General_Audit.sql
1014_tbl_Shop_Image_Type.sql
1015_tbl_Shop_Image_Type_Audit.sql
1100_tbl_Shop_Region.sql
1101_tbl_Shop_Region_Audit.sql
1102_tbl_Shop_Region_Temp.sql
1103_tbl_Shop_Region_Branch.sql
1104_tbl_Shop_Region_Branch_Audit.sql
1105_tbl_Shop_Region_Branch_Temp.sql
1106_tbl_Shop_Address.sql
1106_tbl_Shop_Plant.sql
1107_tbl_Shop_Address_Audit.sql
1107_tbl_Shop_Plant_Audit.sql
1108_tbl_Shop_Plant_Temp.sql
1109_tbl_Shop_Storage_Location.sql
1110_tbl_Shop_Storage_Location_Audit.sql
1111_tbl_Shop_Storage_Location_Temp.sql
1112_tbl_Shop_Storage_Location_Branch.sql
1113_tbl_Shop_Storage_Location_Branch_Audit.sql
1114_tbl_Shop_Storage_Location_Branch_Temp.sql
1115_tbl_Shop_Currency.sql
1116_tbl_Shop_Currency_Audit.sql
1117_tbl_Shop_Currency_Temp.sql
1118_tbl_Shop_Tax_Or_Surcharge.sql
1119_tbl_Shop_Tax_Or_Surcharge_Audit.sql
1120_tbl_Shop_Tax_Or_Surcharge_Temp.sql
1121_tbl_Shop_Unit_Measurement.sql
1122_tbl_Shop_Unit_Measurement_Audit.sql
1124_tbl_Shop_Unit_Measurement_Conversion.sql
1125_tbl_Shop_Unit_Measurement_Conversion_Audit.sql
1200_tbl_Shop_Product_Category.sql
1201_tbl_Shop_Product_Category_Audit.sql
1202_tbl_Shop_Product_Category_Temp.sql
1203_tbl_Shop_Product.sql
1204_tbl_Shop_Product_Audit.sql
1205_tbl_Shop_Product_Temp.sql
1206_tbl_Shop_Product_Permutation.sql
1207_tbl_Shop_Product_Permutation_Audit.sql
1208_tbl_Shop_Product_Permutation_Temp.sql
1209_tbl_Shop_Variation_Type.sql
1210_tbl_Shop_Variation_Type_Audit.sql
1211_tbl_Shop_Variation_Type_Temp.sql
1212_tbl_Shop_Variation.sql
1213_tbl_Shop_Variation_Audit.sql
1214_tbl_Shop_Variation_Temp.sql
1215_tbl_Shop_Product_Permutation_Variation_Link.sql
1216_tbl_Shop_Product_Permutation_Variation_Link_Audit.sql
1217_tbl_Shop_Product_Permutation_Variation_Link_Temp.sql
1218_tbl_Shop_Stock_Item.sql
1219_tbl_Shop_Stock_Item_Audit.sql
1220_tbl_Shop_Stock_Item_Temp.sql
1221_tbl_Shop_Product_Price.sql
1222_tbl_Shop_Product_Price_Audit.sql
1223_tbl_Shop_Product_Price_Temp.sql
1224_tbl_Shop_Product_Image.sql
1225_tbl_Shop_Product_Image_Audit.sql
1227_tbl_Shop_Delivery_Option.sql
1228_tbl_Shop_Delivery_Option_Audit.sql
1230_tbl_Shop_Product_Permutation_Delivery_Option_Link.sql
1231_tbl_Shop_Product_Permutation_Delivery_Option_Link_Audit.sql
1233_tbl_Shop_Discount.sql
1234_tbl_Shop_Discount_Audit.sql
1236_tbl_Shop_Discount_Region_Currency_Link.sql
1237_tbl_Shop_Discount_Region_Currency_Link_Audit.sql
1300_tbl_Shop_Permission_Group.sql
1301_tbl_Shop_Permission_Group_Audit.sql
1303_tbl_Shop_Permission.sql
1304_tbl_Shop_Permission_Audit.sql
1306_tbl_Shop_Role.sql
1307_tbl_Shop_Role_Audit.sql
1309_tbl_Shop_Role_Permission_Link.sql
1310_tbl_Shop_Role_Permission_Link_Audit.sql
1312_tbl_Shop_User.sql
1313_tbl_Shop_User_Audit.sql
1315_tbl_Shop_User_Role_Link.sql
1316_tbl_Shop_User_Role_Link_Audit.sql
1318_tbl_Shop_User_Address.sql
1319_tbl_Shop_User_Address_Audit.sql
1321_tbl_Shop_User_Basket.sql
1322_tbl_Shop_User_Basket_Audit.sql
1397_tbl_Shop_Order_Status.sql
1398_tbl_Shop_Order_Status_Audit.sql
1400_tbl_Shop_Supplier.sql
1401_tbl_Shop_Supplier_Audit.sql
1402_tbl_Shop_Supplier_Temp.sql
1403_tbl_Shop_Supplier_Address.sql
1404_tbl_Shop_Supplier_Address_Audit.sql
1405_tbl_Shop_Supplier_Address_Temp.sql
1409_tbl_Shop_Supplier_Purchase_Order.sql
1410_tbl_Shop_Supplier_Purchase_Order_Audit.sql
1411_tbl_Shop_Supplier_Purchase_Order_Temp.sql
1412_tbl_Shop_Supplier_Purchase_Order_Product_Link.sql
1413_tbl_Shop_Supplier_Purchase_Order_Product_Link_Audit.sql
1414_tbl_Shop_Supplier_Purchase_Order_Product_Link_Temp.sql
1415_tbl_Shop_Manufacturing_Purchase_Order.sql
1416_tbl_Shop_Manufacturing_Purchase_Order_Audit.sql
1417_tbl_Shop_Manufacturing_Purchase_Order_Temp.sql
1418_tbl_Shop_Manufacturing_Purchase_Order_Product_Link.sql
1419_tbl_Shop_Manufacturing_Purchase_Order_Product_Link_Audit.sql
1420_tbl_Shop_Manufacturing_Purchase_Order_Product_Link_Temp.sql
1421_tbl_Shop_Customer.sql
1422_tbl_Shop_Customer_Audit.sql
1424_tbl_Shop_Customer_Sales_Order.sql
1425_tbl_Shop_Customer_Sales_Order_Audit.sql
1427_tbl_Shop_Customer_Sales_Order_Product_Link.sql
1428_tbl_Shop_Customer_Sales_Order_Product_Link_Audit.sql
1429_tbl_Shop_Customer_Sales_Order_Product_Link_Temp.sql
1500_tbl_Shop_Calc_User_Temp.sql
3000_tri_Shop_Access_Level.sql
3000_tri_Shop_Product_Change_Set.sql
3001_tri_Shop_User_Change_Set.sql
3002_tri_Shop_Sales_And_Purchasing_Change_Set.sql
3010_tri_File_Type.sql
3011_tri_File_Type_Audit.sql
3012_tri_Shop_General.sql
3014_tri_Shop_Image_Type.sql
3100_tri_Shop_Region.sql
3103_tri_Shop_Region_Branch.sql
3106_tri_Shop_Address.sql
3109_tri_Shop_Storage_Location.sql
3115_tri_Shop_Currency.sql
3118_tri_Shop_Tax_Or_Surcharge.sql
3200_tri_Shop_Category.sql
3203_tri_Shop_Product.sql
3206_tri_Shop_Product_Permutation.sql
3209_tri_Shop_Variation_Type.sql
3212_tri_Shop_Variation.sql
3215_tri_Shop_Product_Permutation_Variation_Link.sql
3218_tri_Shop_Stock_Item.sql
3221_tri_Shop_Product_Price.sql
3224_tri_Shop_Product_Image.sql
3227_tri_Shop_Delivery_Option.sql
3230_tri_Shop_Product_Permutation_Delivery_Option_Link.sql
3233_tri_Shop_Discount.sql
3236_tri_Shop_Discount_Region_Currency_Link.sql
3300_tri_Shop_Permission_Group.sql
3303_tri_Shop_Permission.sql
3306_tri_Shop_Role.sql
3309_tri_Shop_Role_Permission_Link.sql
3312_tri_Shop_User.sql
3315_tri_Shop_User_Role_Link.sql
3318_tri_Shop_User_Address.sql
3321_tri_Shop_User_Basket.sql
3324_tri_Shop_User_Order_Status.sql
3400_tri_Shop_Supplier.sql
3403_tri_Shop_Supplier_Address.sql
3403_tri_Shop_Unit_Measurement.sql
3406_tri_Shop_Unit_Of_Measurement_Conversion.sql
3409_tri_Shop_Supplier_Purchase_Order.sql
3412_tri_Shop_Supplier_Purchase_Order_Product_Link.sql
3415_tri_Shop_Manufacturing_Purchase_Order.sql
3418_tri_Shop_Manufacturing_Purchase_Order_Product_Link.sql
3421_tri_Shop_Customer.sql
3424_tri_Shop_Customer_Sales_Order.sql
3427_tri_Shop_Customer_Sales_Order_Product_Link.sql
6000_p_debug_timing_reporting.sql
6000_p_split.sql
6001_p_clear_split_temp.sql
6001_p_validate_guid.sql
6003_p_split_key_value_pair_csv.sql
6004_p_clear_split_key_value_pair_csv_temp.sql
6206_fn_shop_get_product_permutation_name.sql
6210_fn_shop_get_id_product_permutation_from_variation_csv_list.sql
6211_fn_shop_get_product_variations_from_id_csv_list.sql
6500_p_shop_calc_user.sql
6501_p_shop_clear_calc_user.sql
7003_p_shop_get_many_access_level.sql
7101_p_shop_get_many_region.sql
7106_p_shop_get_many_plant.sql
7109_p_shop_get_many_storage_location.sql
7116_p_shop_get_many_currency.sql
7122_p_shop_get_many_unit_measurement.sql
7200_p_shop_save_product_category.sql
7200_p_shop_save_product_category_test.sql
7202_p_shop_clear_calc_product_permutation.sql
7203_p_shop_save_product.sql
7203_p_shop_save_product_test.sql
7204_p_shop_calc_product_permutation.sql
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
7212_p_shop_save_product_variation.sql
7212_p_shop_save_product_variation_test.sql
7219_p_shop_get_many_stock_item.sql
7220_p_shop_save_stock_item.sql
7220_p_shop_save_stock_item_test.sql
7221_p_get_many_shop_product_price_and_discount_and_delivery_option.sql
7223_p_shop_get_many_stripe_price_new.sql
7312_p_shop_save_user.sql
7313_p_get_many_user.sql
7321_p_shop_save_user_basket.sql
7400_p_shop_save_supplier.sql
7400_p_shop_save_supplier_temp.sql
7401_p_shop_get_many_supplier.sql
7403_p_shop_save_supplier_purchase_order.sql
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
7424_p_shop_save_customer_sales_order.sql
7425_p_shop_get_many_customer_sales_order.sql
9000_populate.sql
9001_view.sql
9010_anal.sql

25170
static/batch/0000_combined.sql Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,6 @@
-- File: combined.sql
GO

View File

@@ -2018,9 +2018,12 @@ var OverlayError = /*#__PURE__*/function () {
;// CONCATENATED MODULE: ./static/js/pages/base_table.js
function base_table_typeof(o) { "@babel/helpers - typeof"; return base_table_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, base_table_typeof(o); }
function base_table_defineProperty(e, r, t) { return (r = base_table_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function base_table_classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
function base_table_defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, base_table_toPropertyKey(o.key), o); } }
function base_table_createClass(e, r, t) { return r && base_table_defineProperties(e.prototype, r), t && base_table_defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
function base_table_toPropertyKey(t) { var i = base_table_toPrimitive(t, "string"); return "symbol" == base_table_typeof(i) ? i : i + ""; }
function base_table_toPrimitive(t, r) { if ("object" != base_table_typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != base_table_typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function base_table_callSuper(t, o, e) { return o = base_table_getPrototypeOf(o), base_table_possibleConstructorReturn(t, base_table_isNativeReflectConstruct() ? Reflect.construct(o, e || [], base_table_getPrototypeOf(t).constructor) : o.apply(t, e)); }
function base_table_possibleConstructorReturn(t, e) { if (e && ("object" == base_table_typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return base_table_assertThisInitialized(t); }
function base_table_assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
@@ -2031,9 +2034,6 @@ function base_table_superPropBase(t, o) { for (; !{}.hasOwnProperty.call(t, o) &
function base_table_getPrototypeOf(t) { return base_table_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, base_table_getPrototypeOf(t); }
function base_table_inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && base_table_setPrototypeOf(t, e); }
function base_table_setPrototypeOf(t, e) { return base_table_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, base_table_setPrototypeOf(t, e); }
function base_table_defineProperty(e, r, t) { return (r = base_table_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function base_table_toPropertyKey(t) { var i = base_table_toPrimitive(t, "string"); return "symbol" == base_table_typeof(i) ? i : i + ""; }
function base_table_toPrimitive(t, r) { if ("object" != base_table_typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != base_table_typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
@@ -2053,18 +2053,12 @@ var TableBasePage = /*#__PURE__*/function (_BasePage) {
var _this;
base_table_classCallCheck(this, TableBasePage);
_this = base_table_callSuper(this, TableBasePage, [router]);
base_table_defineProperty(_this, "getAndLoadFilteredTableContent", function () {
_this.callFilterTableContent()["catch"](function (error) {
return console.error('Error:', error);
});
});
_this.cursorYInitial = null;
_this.rowInitial = null;
_this.placeholder = null;
_this.dragSrcEl = null;
_this.dragSrcRow = null;
_this.hookupTableCellDdls = _this.hookupTableCellDdls.bind(_this);
_this.getAndLoadFilteredTableContent = _this.getAndLoadFilteredTableContent.bind(_this);
return _this;
}
base_table_inherits(TableBasePage, _BasePage);
@@ -2139,9 +2133,15 @@ var TableBasePage = /*#__PURE__*/function (_BasePage) {
var _this3 = this;
this.hookupEventHandler("click", idButtonApplyFilters, function (event, button) {
event.stopPropagation();
_this3.getAndLoadFilteredTableContent();
_this3.callFilterTableContent();
});
}
/*
getAndLoadFilteredTableContent = () => {
this.callFilterTableContent()
.catch(error => console.error('Error:', error));
}
*/
}, {
key: "getFormFilters",
value: function getFormFilters() {
@@ -2216,7 +2216,7 @@ var TableBasePage = /*#__PURE__*/function (_BasePage) {
console.log('Records saved!');
console.log('Data received:', data);
}
_this5.getAndLoadFilteredTableContent();
_this5.callFilterTableContent();
} else {
if (_verbose) {
console.log("error: ", data[flagMessage]);
@@ -2277,10 +2277,11 @@ var TableBasePage = /*#__PURE__*/function (_BasePage) {
}, {
key: "hookupButtonCancel",
value: function hookupButtonCancel() {
var _this8 = this;
Events.initialiseEventHandler(idFormFilters + ' button.' + flagCancel, flagInitialised, function (button) {
button.addEventListener("click", function (event) {
event.stopPropagation();
this.getAndLoadFilteredTableContent();
_this8.callFilterTableContent();
});
button.classList.add(flagCollapsed);
});
@@ -2313,14 +2314,14 @@ var TableBasePage = /*#__PURE__*/function (_BasePage) {
}, {
key: "hookupTableMain",
value: function hookupTableMain() {
var _this8 = this;
var _this9 = this;
if (this.constructor === TableBasePage) {
throw new Error("Must implement hookupTableMain() method.");
}
if (true) {
// _rowBlank == null) {
Events.initialiseEventHandler(idTableMain, flagInitialised, function (table) {
_this8.cacheRowBlank();
_this9.cacheRowBlank();
});
}
}
@@ -2378,9 +2379,9 @@ var TableBasePage = /*#__PURE__*/function (_BasePage) {
}, {
key: "hookupChangeHandlerTableCells",
value: function hookupChangeHandlerTableCells(inputSelector) {
var _this9 = this;
var _this10 = this;
var handler = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (event, element) {
_this9.handleChangeNestedElementCellTable(event, element);
_this10.handleChangeNestedElementCellTable(event, element);
};
Events.initialiseEventHandler(inputSelector, flagInitialised, function (input) {
input.addEventListener("change", function (event) {
@@ -2524,9 +2525,9 @@ var TableBasePage = /*#__PURE__*/function (_BasePage) {
}, {
key: "hookupChangeHandlerTableCellsWhenNotCollapsed",
value: function hookupChangeHandlerTableCellsWhenNotCollapsed(inputSelector) {
var _this10 = this;
var _this11 = this;
var handler = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (event, element) {
if (!element.classList.contains(flagCollapsed)) _this10.handleChangeNestedElementCellTable(event, element);
if (!element.classList.contains(flagCollapsed)) _this11.handleChangeNestedElementCellTable(event, element);
};
this.hookupEventHandler("change", inputSelector, handler);
}
@@ -2606,10 +2607,10 @@ var TableBasePage = /*#__PURE__*/function (_BasePage) {
}, {
key: "hookupFieldsActive",
value: function hookupFieldsActive() {
var _this11 = this;
var _this12 = this;
var flagTable = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
var handleClickRowNew = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (event, element) {
_this11.handleClickAddRowTable(event, element);
_this12.handleClickAddRowTable(event, element);
};
var selectorButton = 'table' + (validation_Validation.isEmpty(flagTable) ? '' : '.' + flagTable) + ' > tbody > tr > td.' + flagActive + ' button';
var selectorButtonDelete = selectorButton + '.' + flagDelete;
@@ -2624,9 +2625,9 @@ var TableBasePage = /*#__PURE__*/function (_BasePage) {
}, {
key: "hookupButtonsRowDelete",
value: function hookupButtonsRowDelete(selectorButtonDelete, selectorButtonUndelete) {
var _this12 = this;
var _this13 = this;
this.hookupEventHandler("click", selectorButtonDelete, function (event, element) {
_this12.handleClickButtonRowDelete(event, element, selectorButtonDelete, selectorButtonUndelete);
_this13.handleClickButtonRowDelete(event, element, selectorButtonDelete, selectorButtonUndelete);
});
}
}, {
@@ -2651,9 +2652,9 @@ var TableBasePage = /*#__PURE__*/function (_BasePage) {
}, {
key: "hookupButtonsRowUndelete",
value: function hookupButtonsRowUndelete(selectorButtonDelete, selectorButtonUndelete) {
var _this13 = this;
var _this14 = this;
this.hookupEventHandler("click", selectorButtonUndelete, function (event, element) {
_this13.handleClickButtonRowUndelete(event, element, selectorButtonDelete, selectorButtonUndelete);
_this14.handleClickButtonRowUndelete(event, element, selectorButtonDelete, selectorButtonUndelete);
});
}
}, {
@@ -2681,15 +2682,15 @@ var TableBasePage = /*#__PURE__*/function (_BasePage) {
}, {
key: "hookupTableCellDdlPreviews",
value: function hookupTableCellDdlPreviews(cellSelector, optionList) {
var _this14 = this;
var _this15 = this;
var ddlHookup = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function (cellSelector) {
_this14.hookupTableCellDdls(cellSelector);
_this15.hookupTableCellDdls(cellSelector);
};
var changeHandler = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : function (event, element) {
_this14.handleChangeNestedElementCellTable(event, element);
_this15.handleChangeNestedElementCellTable(event, element);
};
this.hookupEventHandler("click", cellSelector, function (event, td) {
_this14.handleClickTableCellDdlPreview(event, td, optionList, cellSelector, function (cellSelector) {
_this15.handleClickTableCellDdlPreview(event, td, optionList, cellSelector, function (cellSelector) {
ddlHookup(cellSelector, function (event, element) {
changeHandler(event, element);
});
@@ -2700,9 +2701,9 @@ var TableBasePage = /*#__PURE__*/function (_BasePage) {
}, {
key: "hookupTableCellDdls",
value: function hookupTableCellDdls(ddlSelector) {
var _this15 = this;
var _this16 = this;
var changeHandler = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (event, element) {
_this15.handleChangeNestedElementCellTable(event, element);
_this16.handleChangeNestedElementCellTable(event, element);
};
this.hookupEventHandler("change", ddlSelector, function (event, element) {
changeHandler(event, element);
@@ -2711,9 +2712,9 @@ var TableBasePage = /*#__PURE__*/function (_BasePage) {
}, {
key: "handleClickTableCellDdlPreview",
value: function handleClickTableCellDdlPreview(event, td, optionObjectList, cellSelector) {
var _this16 = this;
var _this17 = this;
var ddlHookup = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : function (cellSelector) {
_this16.hookupTableCellDdls(cellSelector);
_this17.hookupTableCellDdls(cellSelector);
};
if (td.querySelector('select')) return;
// td.removeEventListener("click", ddlHookup);
@@ -2773,14 +2774,14 @@ var TableBasePage = /*#__PURE__*/function (_BasePage) {
}, {
key: "hookupTableCellDDlPreviewsWhenNotCollapsed",
value: function hookupTableCellDDlPreviewsWhenNotCollapsed(cellSelector, optionList) {
var _this17 = this;
var _this18 = this;
var ddlHookup = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function (event, element) {
_this17.hookupTableCellDdls(event, element);
_this18.hookupTableCellDdls(event, element);
};
this.hookupEventHandler("click", cellSelector, function (event, td) {
var div = td.querySelector('div');
if (!div || div.classList.contains(flagCollapsed)) return;
_this17.handleClickTableCellDdlPreview(event, td, optionList, cellSelector, function (event, element) {
_this18.handleClickTableCellDdlPreview(event, td, optionList, cellSelector, function (event, element) {
ddlHookup(event, element);
});
});
@@ -2788,9 +2789,9 @@ var TableBasePage = /*#__PURE__*/function (_BasePage) {
}, {
key: "hookupProductCategoryDdls",
value: function hookupProductCategoryDdls(ddlSelector) {
var _this18 = this;
var _this19 = this;
this.hookupChangeHandlerTableCells(ddlSelector, function (event, element) {
_this18.handleChangeProductCategoryDdl(event, element);
_this19.handleChangeProductCategoryDdl(event, element);
});
}
}, {
@@ -2824,15 +2825,15 @@ var TableBasePage = /*#__PURE__*/function (_BasePage) {
}, {
key: "hookupPreviewsProductPermutationVariation",
value: function hookupPreviewsProductPermutationVariation() {
var _this19 = this;
var _this20 = this;
this.hookupEventHandler("click", idTableMain + ' td.' + flagProductVariations, function (event, element) {
return _this19.handleClickProductPermutationVariationsPreview(event, element);
return _this20.handleClickProductPermutationVariationsPreview(event, element);
});
}
}, {
key: "handleClickProductPermutationVariationsPreview",
value: function handleClickProductPermutationVariationsPreview(event, element) {
var _this20 = this;
var _this21 = this;
var tblVariations = element.querySelector('table.' + flagProductVariations);
if (!validation_Validation.isEmpty(tblVariations)) return;
this.toggleColumnCollapsed(flagProductVariations, false);
@@ -2861,7 +2862,7 @@ var TableBasePage = /*#__PURE__*/function (_BasePage) {
var tbody = document.createElement("tbody");
if (!validation_Validation.isEmpty(permutationVariations)) {
permutationVariations.forEach(function (permutationVariation, index) {
_this20.addProductPermutationVariationRow(tbody, permutationVariation);
_this21.addProductPermutationVariationRow(tbody, permutationVariation);
});
}
tblVariations.appendChild(tbody);
@@ -3007,9 +3008,9 @@ var TableBasePage = /*#__PURE__*/function (_BasePage) {
}, {
key: "hookupDdlsProductPermutationVariationType",
value: function hookupDdlsProductPermutationVariationType() {
var _this21 = this;
var _this22 = this;
this.hookupTableCellDdls(idTableMain + ' td.' + flagProductVariations + ' td.' + flagProductVariationType + ' select', function (event, ddlVariationType) {
_this21.handleChangeDdlProductVariationOrVariationType(event, ddlVariationType);
_this22.handleChangeDdlProductVariationOrVariationType(event, ddlVariationType);
var idVariationTypeSelected = DOM.getElementValueCurrent(ddlVariationType);
var row = DOM.getRowFromElement(ddlVariationType);
var tdVariation = row.querySelector('td.' + flagProductVariation);
@@ -3025,7 +3026,7 @@ var TableBasePage = /*#__PURE__*/function (_BasePage) {
option = DOM.createOption(optionJson);
ddlVariation.appendChild(option);
});
_this21.handleChangeDdlProductVariationOrVariationType(event, ddlVariation);
_this22.handleChangeDdlProductVariationOrVariationType(event, ddlVariation);
});
}
}, {
@@ -3037,21 +3038,21 @@ var TableBasePage = /*#__PURE__*/function (_BasePage) {
}, {
key: "hookupDdlsProductPermutationVariation",
value: function hookupDdlsProductPermutationVariation() {
var _this22 = this;
var _this23 = this;
this.hookupTableCellDdls(idTableMain + ' td.' + flagProductVariations + ' td.' + flagProductVariation + ' select', function (event, ddlVariation) {
_this22.handleChangeDdlProductVariationOrVariationType(event, ddlVariation);
_this23.handleChangeDdlProductVariationOrVariationType(event, ddlVariation);
});
}
}, {
key: "hookupButtonsProductPermutationVariationAddDelete",
value: function hookupButtonsProductPermutationVariationAddDelete() {
var _this23 = this;
var _this24 = this;
var selectorButton = idTableMain + ' td.' + flagProductVariations + ' tr.' + flagProductVariation + ' button';
var selectorButtonDelete = selectorButton + '.' + flagDelete;
var selectorButtonUndelete = selectorButton + '.' + flagAdd;
this.hookupButtonsRowDelete(selectorButtonDelete, selectorButtonUndelete, function (event, element) {
_this23.handleClickButtonRowDelete(event, element);
_this23.updateProductPermutationVariations(element);
_this24.handleClickButtonRowDelete(event, element);
_this24.updateProductPermutationVariations(element);
});
this.hookupButtonsRowUndelete(selectorButtonDelete, selectorButtonUndelete);
this.hookupButtonsProductPermutationVariationAdd();
@@ -3059,9 +3060,9 @@ var TableBasePage = /*#__PURE__*/function (_BasePage) {
}, {
key: "hookupButtonsProductPermutationVariationAdd",
value: function hookupButtonsProductPermutationVariationAdd() {
var _this24 = this;
var _this25 = this;
this.hookupEventHandler("click", idTableMain + ' td.' + flagProductVariations + ' button.' + flagAdd, function (event, element) {
_this24.handleClickButtonProductPermutationVariationAdd(event, element);
_this25.handleClickButtonProductPermutationVariationAdd(event, element);
});
}
}, {

View File

@@ -25,7 +25,6 @@ export default class TableBasePage extends BasePage {
this.dragSrcRow = null;
this.hookupTableCellDdls = this.hookupTableCellDdls.bind(this);
this.getAndLoadFilteredTableContent = this.getAndLoadFilteredTableContent.bind(this);
}
initialize(isPopState = false) {
@@ -85,13 +84,15 @@ export default class TableBasePage extends BasePage {
hookupButtonApplyFilters() {
this.hookupEventHandler("click", idButtonApplyFilters, (event, button) => {
event.stopPropagation();
this.getAndLoadFilteredTableContent();
this.callFilterTableContent();
});
}
/*
getAndLoadFilteredTableContent = () => {
this.callFilterTableContent()
.catch(error => console.error('Error:', error));
}
*/
getFormFilters() {
return document.querySelector(idFormFilters);
}
@@ -146,7 +147,7 @@ export default class TableBasePage extends BasePage {
console.log('Records saved!');
console.log('Data received:', data);
}
this.getAndLoadFilteredTableContent();
this.callFilterTableContent();
}
else {
if (_verbose) { console.log("error: ", data[flagMessage]); }
@@ -193,10 +194,10 @@ export default class TableBasePage extends BasePage {
.catch(error => console.error('Error:', error));
}
hookupButtonCancel() {
Events.initialiseEventHandler(idFormFilters + ' button.' + flagCancel, flagInitialised, function(button) {
button.addEventListener("click", function(event) {
Events.initialiseEventHandler(idFormFilters + ' button.' + flagCancel, flagInitialised, (button) => {
button.addEventListener("click", (event) => {
event.stopPropagation();
this.getAndLoadFilteredTableContent();
this.callFilterTableContent();
});
button.classList.add(flagCollapsed);
});