feat(MySQL): Get Many stored procedures created for product variations with variation types and product prices with discounts and delivery options.
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -18,7 +18,7 @@ Parent data model for store views
|
||||
# internal
|
||||
# from context import models
|
||||
from business_objects.store.store_base import Store_Base
|
||||
from business_objects.store.product import Product, Filters_Product, Product_Permutation # Product_Image_Filters,
|
||||
from business_objects.store.product import Product, Parameters_Product, Product_Permutation # Product_Image_Filters,
|
||||
# from business_objects.store.product_category import Filters_Product_Category
|
||||
from business_objects.store.image import Resolution_Level_Enum
|
||||
from business_objects.store.basket import Basket_Item, Basket
|
||||
@@ -106,8 +106,10 @@ class Model_View_Store(Model_View_Base):
|
||||
HASH_GET_STORE_PRODUCT_CATEGORY: ClassVar[str] = '/store/category_get'
|
||||
HASH_SAVE_STORE_PRODUCT: ClassVar[str] = '/store/save_product'
|
||||
HASH_GET_STORE_PRODUCT_PERMUTATION: ClassVar[str] = '/store/permutation_get'
|
||||
HASH_GET_STORE_STOCK_ITEM: ClassVar[str] = '/store/stock_item_get'
|
||||
HASH_SAVE_STORE_PRODUCT_CATEGORY: ClassVar[str] = '/store/save_category'
|
||||
HASH_SAVE_STORE_PRODUCT_PERMUTATION: ClassVar[str] = '/store/save_permutation'
|
||||
HASH_SAVE_STORE_STOCK_ITEM: ClassVar[str] = '/store/save_stock_item'
|
||||
HASH_STORE_SET_CURRENCY : ClassVar[str] = '/store/set_currency'
|
||||
HASH_STORE_SET_DELIVERY_REGION : ClassVar[str] = '/store/set_delivery_region'
|
||||
HASH_STORE_SET_IS_INCLUDED_VAT : ClassVar[str] = '/store/set_is_included_VAT'
|
||||
@@ -197,7 +199,7 @@ class Model_View_Store(Model_View_Base):
|
||||
|
||||
def get_many_product(self, product_filters): # category_ids = '', product_ids = '', get_all_category = True, get_all_product = True, max_products_per_category = -1):
|
||||
_m = 'Model_View_Store.get_many_product'
|
||||
av.val_instance(product_filters, 'product_filters', _m, Filters_Product)
|
||||
av.val_instance(product_filters, 'product_filters', _m, Parameters_Product)
|
||||
"""
|
||||
av.val_str(category_ids, 'category_ids', _m)
|
||||
av.val_str(product_ids, 'product_ids', _m)
|
||||
@@ -327,7 +329,7 @@ class Model_View_Store(Model_View_Base):
|
||||
is_included_VAT = basket[self.KEY_IS_INCLUDED_VAT]
|
||||
print(f'json basket items: {items}')
|
||||
product_ids, permutation_ids, item_index_dict = self._get_json_basket_id_CSVs_product_permutation(items)
|
||||
category_list, errors = DataStore_Store_Base().get_many_product(Filters_Product(
|
||||
category_list, errors = DataStore_Store_Base().get_many_product(Parameters_Product(
|
||||
self.id_user, # :a_id_user
|
||||
True, '', False, # :a_get_all_category, :a_ids_category, :a_get_inactive_category
|
||||
False, product_ids, False, False, # :a_get_all_product, :a_ids_product, :a_get_inactive_product, :a_get_first_product_only
|
||||
@@ -374,7 +376,7 @@ class Model_View_Store(Model_View_Base):
|
||||
"""
|
||||
ids_permutation_unavailable = self.basket.get_ids_permutation_unavailable()
|
||||
if len(ids_permutation_unavailable) > 0:
|
||||
category_list_unavailable, errors_unavailable = DataStore_Store().get_many_product(Filters_Product(
|
||||
category_list_unavailable, errors_unavailable = DataStore_Store().get_many_product(Parameters_Product(
|
||||
self.id_user, # :a_id_user
|
||||
True, '', False, # :a_get_all_category, :a_ids_category, :a_get_inactive_category
|
||||
False, '', False, False, # :a_get_all_product, :a_ids_product, :a_get_inactive_product, :a_get_first_product_only
|
||||
|
||||
@@ -16,18 +16,17 @@ Data model for store product view
|
||||
|
||||
# IMPORTS
|
||||
# internal
|
||||
from business_objects.store.product import Product, Parameters_Product
|
||||
from business_objects.store.product_category import Product_Category_Container
|
||||
from datastores.datastore_store_product import DataStore_Store_Product
|
||||
from forms.store.product import Filters_Product
|
||||
from models.model_view_store import Model_View_Store
|
||||
from datastores.datastore_store_base import DataStore_Store_Base
|
||||
# from routes import bp_home
|
||||
from business_objects.store.product import Product, Filters_Product
|
||||
import lib.argument_validation as av
|
||||
# external
|
||||
from typing import ClassVar
|
||||
|
||||
|
||||
# VARIABLE INSTANTIATION
|
||||
|
||||
|
||||
# CLASSES
|
||||
"""
|
||||
class Model_View_Store_Product(Model_View_Store):
|
||||
# categories: list # (str)
|
||||
# category_products: dict { category_enum_id: List[Product] }
|
||||
@@ -44,7 +43,7 @@ class Model_View_Store_Product(Model_View_Store):
|
||||
super().__init__(hash_page_current=hash_page_current, id_currency=id_currency, id_region_delivery=id_region_delivery, is_included_VAT=is_included_VAT)
|
||||
print('supered')
|
||||
|
||||
category_list = DataStore_Store_Base().get_many_product(Filters_Product(
|
||||
category_list = DataStore_Store_Base().get_many_product(Parameters_Product(
|
||||
self.info_user['sub'],
|
||||
True, '', False,
|
||||
True, '', False, False,
|
||||
@@ -57,10 +56,69 @@ class Model_View_Store_Product(Model_View_Store):
|
||||
print('connection to db successful')
|
||||
# self.categories = categories
|
||||
# self.category_index = category_index
|
||||
"""
|
||||
""
|
||||
if (category_list.get_category_count() > 0):
|
||||
self.product = category_list.get_permutation_first()
|
||||
else:
|
||||
self.product = None
|
||||
print('selected permutation selected')
|
||||
"""
|
||||
""
|
||||
"""
|
||||
|
||||
|
||||
class Model_View_Store_Product(Model_View_Store):
|
||||
category_list: Product_Category_Container = None
|
||||
category_list_filters: Product_Category_Container = None
|
||||
currencies: list = None
|
||||
currency_options: list = None
|
||||
filters_product: Parameters_Product = None
|
||||
form_filters: Filters_Product
|
||||
list_options_product: list = None
|
||||
product_blank: Product = None
|
||||
units_measurement: list = None
|
||||
units_measurement_time: list = None
|
||||
# variation_container: Product_Variation_Container = None
|
||||
variations: list = None
|
||||
variation_types: list = None
|
||||
|
||||
@property
|
||||
def title(self):
|
||||
return 'Products'
|
||||
|
||||
def __init__(self, form_filters, hash_page_current=Model_View_Store.HASH_PAGE_STORE_PRODUCTS):
|
||||
_m = 'Model_View_Store_Permutation.__init__'
|
||||
print(f'{_m}\nstarting...')
|
||||
super().__init__(hash_page_current=hash_page_current, form_filters=form_filters)
|
||||
parameters_product = Parameters_Product.from_form_filters_product(self.form_filters)
|
||||
datastore_store = DataStore_Store_Product()
|
||||
self.category_list, errors = datastore_store.get_many_product(parameters_product)
|
||||
self.category_list_filters, errors_filters = datastore_store.get_many_product(
|
||||
Parameters_Product(
|
||||
get_all_product_category = True,
|
||||
get_inactive_product_category = False,
|
||||
ids_product_category = '',
|
||||
get_all_product = True,
|
||||
get_inactive_product = False,
|
||||
ids_product = '',
|
||||
get_all_permutation = True,
|
||||
get_inactive_permutation = False,
|
||||
ids_permutation = '',
|
||||
get_all_image = False,
|
||||
get_inactive_image = False,
|
||||
ids_image = '',
|
||||
get_products_quantity_stock_below_min = parameters_product.get_products_quantity_stock_below_min
|
||||
)
|
||||
)
|
||||
print(f'category filters: {self.category_list_filters.categories}')
|
||||
self.form_filters.id_category.choices = [('0', 'All')] + [(str(category.id_category), category.name) for category in self.category_list_filters.categories]
|
||||
print(f'category options: {self.form_filters.id_category.choices}')
|
||||
self.variation_types, self.variations, errors = self.get_many_product_variation()
|
||||
self.units_measurement = self.get_many_unit_measurement()
|
||||
self.units_measurement_time = [unit_measurement for unit_measurement in self.units_measurement if unit_measurement.is_unit_of_time]
|
||||
self.currencies = self.get_many_currency()
|
||||
self.currency_options = [currency.to_json_option() for currency in self.currencies]
|
||||
|
||||
@staticmethod
|
||||
def save_products(comment, list_products):
|
||||
_m = 'Model_View_Store_Product.save_products'
|
||||
DataStore_Store_Product.save_products(comment, list_products)
|
||||
@@ -19,7 +19,7 @@ from forms.access_level import Filters_Access_Level
|
||||
# from forms.store.product_permutation import Filters_Product_Permutation
|
||||
from forms.store.product_category import Filters_Product_Category
|
||||
# from routes import bp_home
|
||||
from business_objects.store.product import Product, Filters_Product, Product_Permutation
|
||||
from business_objects.store.product import Product, Parameters_Product, Product_Permutation
|
||||
from business_objects.store.product_variation import Product_Variation_Container
|
||||
import lib.argument_validation as av
|
||||
|
||||
@@ -46,7 +46,7 @@ class Model_View_Store_Product_Category(Model_View_Store):
|
||||
self.access_levels = self.get_many_access_level(Filters_Access_Level())
|
||||
datastore_store = DataStore_Store_Product_Category()
|
||||
# self.form_filters = Filters_Product_Category.from_filters(filters_category)
|
||||
filters_product = Filters_Product.from_filters_product_category(self.form_filters)
|
||||
filters_product = Parameters_Product.from_filters_product_category(self.form_filters)
|
||||
self.category_list, errors = datastore_store.get_many_product(filters_product)
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -16,7 +16,7 @@ from datastores.datastore_store_product_permutation import DataStore_Store_Produ
|
||||
from business_objects.store.product_category import Product_Category_Container
|
||||
from forms.store.product_permutation import Filters_Product_Permutation
|
||||
# from routes import bp_home
|
||||
from business_objects.store.product import Product, Filters_Product, Product_Permutation
|
||||
from business_objects.store.product import Product, Parameters_Product, Product_Permutation
|
||||
from business_objects.store.product_variation import Product_Variation_Container
|
||||
import lib.argument_validation as av
|
||||
|
||||
@@ -25,19 +25,21 @@ from pydantic import BaseModel
|
||||
from typing import ClassVar
|
||||
|
||||
class Model_View_Store_Product_Permutation(Model_View_Store):
|
||||
"""
|
||||
ID_FILTER_CATEGORY: ClassVar[str] = 'id_category'
|
||||
ID_FILTER_PRODUCT: ClassVar[str] = 'id_product'
|
||||
ID_FILTER_IS_OUT_OF_STOCK: ClassVar[str] = 'is_out_of_stock'
|
||||
ID_FILTER_QUANTITY_MIN: ClassVar[str] = 'quantity_min'
|
||||
ID_FILTER_QUANTITY_MAX: ClassVar[str] = 'quantity_max'
|
||||
"""
|
||||
# ID_Filters_Product_Permutation: ClassVar[str] = 'Filters_Product_Permutation'
|
||||
KEY_PERMUTATIONS: ClassVar[str] = 'permutations'
|
||||
# KEY_PERMUTATIONS: ClassVar[str] = 'permutations'
|
||||
|
||||
category_list: Product_Category_Container = None
|
||||
category_list_filters: Product_Category_Container = None
|
||||
currencies: list = None
|
||||
currency_options: list = None
|
||||
filters_product: Filters_Product = None
|
||||
filters_product: Parameters_Product = None
|
||||
form_filters: Filters_Product_Permutation
|
||||
list_options_product: list = None
|
||||
permutation_blank: Product_Permutation = None
|
||||
@@ -56,11 +58,11 @@ class Model_View_Store_Product_Permutation(Model_View_Store):
|
||||
print(f'{_m}\nstarting...')
|
||||
super().__init__(hash_page_current=hash_page_current, form_filters=form_filters)
|
||||
# self.form_filters = Filters_Product_Permutation()
|
||||
filters_product = Filters_Product.from_form_filters_product_permutation(self.form_filters)
|
||||
filters_product = Parameters_Product.from_form_filters_product_permutation(self.form_filters)
|
||||
datastore_store = DataStore_Store_Product_Permutation()
|
||||
self.category_list, errors = datastore_store.get_many_product(filters_product)
|
||||
self.category_list_filters, errors_filters = datastore_store.get_many_product(
|
||||
Filters_Product(
|
||||
Parameters_Product(
|
||||
get_all_product_category = True,
|
||||
get_inactive_product_category = False,
|
||||
ids_product_category = '',
|
||||
@@ -83,7 +85,6 @@ class Model_View_Store_Product_Permutation(Model_View_Store):
|
||||
print(f'product options: {self.list_options_product}')
|
||||
self.form_filters.id_product.choices = [('0', 'All')] + [(str(product['value']), product['text']) for product in self.list_options_product]
|
||||
self.permutation_blank = Product_Permutation()
|
||||
print(f'category options: {self.form_filters.id_category.choices}')
|
||||
self.variation_types, self.variations, errors = self.get_many_product_variation()
|
||||
self.units_measurement = self.get_many_unit_measurement()
|
||||
self.units_measurement_time = [unit_measurement for unit_measurement in self.units_measurement if unit_measurement.is_unit_of_time]
|
||||
|
||||
@@ -14,9 +14,8 @@ Data model for store stock items view
|
||||
from models.model_view_store import Model_View_Store
|
||||
from datastores.datastore_store_stock_item import DataStore_Store_Stock_Item
|
||||
from business_objects.store.product_category import Product_Category_Container
|
||||
from forms.store.stock_item import Filters_Stock_Item
|
||||
# from routes import bp_home
|
||||
from business_objects.store.product import Product, Filters_Product, Product_Permutation
|
||||
from business_objects.store.product import Product, Parameters_Product, Product_Permutation
|
||||
from business_objects.store.stock_item import Stock_Item
|
||||
from forms.store.stock_item import Filters_Stock_Item
|
||||
import lib.argument_validation as av
|
||||
@@ -25,7 +24,7 @@ import lib.argument_validation as av
|
||||
from pydantic import BaseModel
|
||||
from typing import ClassVar
|
||||
|
||||
class Model_View_Store_Stock_Items(Model_View_Store):
|
||||
class Model_View_Store_Stock_Item(Model_View_Store):
|
||||
"""
|
||||
ID_FILTER_CATEGORY: ClassVar[str] = 'id_category'
|
||||
ID_FILTER_PRODUCT: ClassVar[str] = 'id_product'
|
||||
@@ -37,7 +36,7 @@ class Model_View_Store_Stock_Items(Model_View_Store):
|
||||
KEY_PERMUTATIONS: ClassVar[str] = 'permutations'
|
||||
|
||||
category_list: Product_Category_Container = None # (str)
|
||||
filters_stock_item: Parameters_Stock_Item
|
||||
filters_stock_item: Filters_Stock_Item
|
||||
form_filters: Filters_Stock_Item = None
|
||||
permutation_blank: Product_Permutation = None
|
||||
|
||||
@@ -52,27 +51,27 @@ class Model_View_Store_Stock_Items(Model_View_Store):
|
||||
# BaseModel.__init__(self, app=app, filters_stock_item=filters_stock_item, **kwargs)
|
||||
self.form_filters = Filters_Stock_Item()
|
||||
datastore_store = DataStore_Store_Stock_Item()
|
||||
tmp_category_list_stock_item, errors = datastore_store.get_many_product(Filters_Product.from_filters_stock_item(filters_stock_item))
|
||||
tmp_category_list_stock_item, errors = datastore_store.get_many_product(Parameters_Product.from_filters_stock_item(filters_stock_item))
|
||||
self.category_list, errors = datastore_store.get_many_stock_item(filters_stock_item, tmp_category_list_stock_item)
|
||||
category_list_filters, errors_filters = datastore_store.get_many_stock_item(
|
||||
"""
|
||||
Parameters_Stock_Item(
|
||||
# self.info_user['sub'],
|
||||
True, False, False, '', # get_all_category, get_inactive_category, get_first_category_only, ids_category
|
||||
True, False, False, '', # get_all_product, get_inactive_product, get_first_product_only, ids_product
|
||||
True, False, False, '', # get_all_permutation, get_inactive_permutation, get_first_permutation_only, ids_permutation
|
||||
False, False, False, '', # get_all_stock_item, get_inactive_stock_item, get_first_stock_item_only, ids_stock_item
|
||||
False, False, False, '', # get_all_region_storage, get_inactive_region_storage, get_first_region_storage_only, ids_region_storage
|
||||
False, False, False, '', # get_all_plant_storage, get_inactive_plant_storage, get_first_plant_storage_only, ids_plant_storage
|
||||
False, False, False, '', # get_all_location_storage, get_inactive_location_storage, get_first_location_storage_only, ids_location_storage
|
||||
None, # date_received_to
|
||||
False, False, # get_sealed_stock_item_only, get_unsealed_stock_item_only
|
||||
False, False, # get_expired_stock_item_only, get_nonexpired_stock_item_only
|
||||
False, False # get_consumed_stock_item_only, get_nonconsumed_stock_item_only
|
||||
)
|
||||
"""
|
||||
Filters_Stock_Item()
|
||||
)
|
||||
"""
|
||||
Parameters_Stock_Item(
|
||||
# self.info_user['sub'],
|
||||
True, False, False, '', # get_all_category, get_inactive_category, get_first_category_only, ids_category
|
||||
True, False, False, '', # get_all_product, get_inactive_product, get_first_product_only, ids_product
|
||||
True, False, False, '', # get_all_permutation, get_inactive_permutation, get_first_permutation_only, ids_permutation
|
||||
False, False, False, '', # get_all_stock_item, get_inactive_stock_item, get_first_stock_item_only, ids_stock_item
|
||||
False, False, False, '', # get_all_region_storage, get_inactive_region_storage, get_first_region_storage_only, ids_region_storage
|
||||
False, False, False, '', # get_all_plant_storage, get_inactive_plant_storage, get_first_plant_storage_only, ids_plant_storage
|
||||
False, False, False, '', # get_all_location_storage, get_inactive_location_storage, get_first_location_storage_only, ids_location_storage
|
||||
None, # date_received_to
|
||||
False, False, # get_sealed_stock_item_only, get_unsealed_stock_item_only
|
||||
False, False, # get_expired_stock_item_only, get_nonexpired_stock_item_only
|
||||
False, False # get_consumed_stock_item_only, get_nonconsumed_stock_item_only
|
||||
)
|
||||
"""
|
||||
|
||||
print(f'category_list_filters: {category_list_filters.categories}')
|
||||
self.form_filters.id_category.choices = [('0', 'All')] + [(str(category.id_category), category.name) for category in category_list_filters.categories]
|
||||
Reference in New Issue
Block a user