1. View, filter, and save Product Permutation. \n 2. Synchronised with Product Category page and all common functionality moved into base and base table css, js, and python files.

This commit is contained in:
2024-09-24 23:25:52 +01:00
parent d37f632c92
commit cf78e4b3bc
239 changed files with 6371 additions and 4336 deletions

View File

@@ -20,19 +20,21 @@ from dataclasses import dataclass
from typing import ClassVar
class Product_Price(db.Model, Store_Base):
ATTR_ID_PRODUCT_PRICE: ClassVar[str] = 'id-price'
NAME_ATTR_OPTION_VALUE: ClassVar[str] = Store_Base.ATTR_ID_PRODUCT_PRICE
NAME_ATTR_OPTION_TEXT = Store_Base.FLAG_TEXT
FLAG_VALUE_LOCAL_VAT_INCL: ClassVar[str] = 'value-local-vat-incl'
FLAG_VALUE_LOCAL_VAT_EXCL: ClassVar[str] = 'value-local-vat-excl'
FLAG_DISPLAY_ORDER: ClassVar[str] = 'display-order-price'
id_price = db.Column(db.Integer, primary_key=True)
id_permutation = db.Column(db.Integer)
id_product = db.Column(db.Integer)
id_category = db.Column(db.Integer)
"""
id_currency = db.Column(db.Integer)
code_currency = db.Column(db.String(50))
name_currency = db.Column(db.String(255))
symbol_currency = db.Column(db.String(50))
"""
id_region = db.Column(db.Integer)
value_local_VAT_incl = db.Column(db.Float)
value_local_VAT_excl = db.Column(db.Float)
@@ -41,18 +43,23 @@ class Product_Price(db.Model, Store_Base):
def __init__(self):
super().__init__()
Store_Base.__init__(self)
def from_DB_get_many_product_catalogue(query_row):
self.currency = None
self.delivery_region = None
@classmethod
def from_DB_get_many_product_catalogue(cls, query_row):
# _m = 'Product_Price.from_DB_get_many_product_catalogue'
price = Product_Price()
price = cls()
price.id_price = query_row[0]
price.id_permutation = query_row[1]
price.id_product = query_row[2]
price.id_category = query_row[3]
price.currency = Currency.from_DB_get_many_product_price_and_discount_and_delivery_region(query_row)
"""
price.id_currency = query_row[4]
price.code_currency = query_row[5]
price.name_currency = query_row[6]
price.symbol_currency = query_row[7]
"""
price.id_region = query_row[8]
price.value_local_VAT_incl = query_row[9]
price.value_local_VAT_excl = query_row[10]
@@ -65,35 +72,26 @@ class Product_Price(db.Model, Store_Base):
id_permutation: {self.id_permutation}
id_product: {self.id_product}
id_category: {self.id_category}
id_currency: {self.id_currency}
code_currency: {self.code_currency}
name_currency: {self.name_currency}
symbol_currency: {self.symbol_currency}
currency: {self.currency}
id_region: {self.id_region}
value_local (VAT incl): {self.value_local_VAT_incl}
value_local (VAT excl): {self.value_local_VAT_excl}
display_order (UID): {self.display_order}
{self.FLAG_TEXT}: {self.currency.symbol} {self.value_local_VAT_incl}
'''
def to_json(self):
return {
self.ATTR_ID_PRODUCT_PRICE: {self.id_price},
self.ATTR_ID_PRODUCT_PERMUTATION: {self.id_permutation},
self.ATTR_ID_PRODUCT: {self.id_product},
self.ATTR_ID_PRODUCT_CATEGORY: {self.id_category},
Currency.ATTR_ID_CURRENCY: {self.id_currency},
Currency.FLAG_CODE: {self.code_currency},
Currency.FLAG_NAME: {self.name_currency},
Currency.FLAG_SYMBOL: {self.symbol_currency},
Delivery_Region.ATTR_ID_REGION: {self.id_region},
self.FLAG_VALUE_LOCAL_VAT_INCL: {self.value_local_VAT_incl},
self.FLAG_VALUE_LOCAL_VAT_EXCL: {self.value_local_VAT_excl},
self.FLAG_DISPLAY_ORDER: {self.display_order}
}
def to_json_option(self):
return {
'value': self.id_price,
'text': f'{self.symbol_currency} {self.value_local_VAT_incl}'
**self.get_shared_json_attributes(self),
self.ATTR_ID_PRODUCT_PRICE: self.id_price,
self.ATTR_ID_PRODUCT_PERMUTATION: self.id_permutation,
self.ATTR_ID_PRODUCT: self.id_product,
self.ATTR_ID_PRODUCT_CATEGORY: self.id_category,
self.FLAG_CURRENCY: self.currency.to_json(),
Delivery_Region.ATTR_ID_DELIVERY_REGION: self.id_region,
self.FLAG_VALUE_LOCAL_VAT_INCL: self.value_local_VAT_incl,
self.FLAG_VALUE_LOCAL_VAT_EXCL: self.value_local_VAT_excl,
self.FLAG_DISPLAY_ORDER: self.display_order
}
@classmethod
@@ -103,11 +101,8 @@ class Product_Price(db.Model, Store_Base):
price.id_permutation = json[cls.ATTR_ID_PRODUCT_PERMUTATION]
price.id_product = json[cls.ATTR_ID_PRODUCT]
price.id_category = json[cls.ATTR_ID_PRODUCT_CATEGORY]
price.id_currency = json[Currency.ATTR_ID_CURRENCY]
price.code_currency = json[Currency.FLAG_CODE]
price.name_currency = json[Currency.FLAG_NAME]
price.symbol_currency = json[Currency.FLAG_SYMBOL]
price.id_region = json[Delivery_Region.ATTR_ID_REGION]
price.currency = Currency.from_json(json)
price.id_region = json[Delivery_Region.ATTR_ID_DELIVERY_REGION]
price.value_local_VAT_incl = json[cls.FLAG_VALUE_LOCAL_VAT_INCL]
price.value_local_VAT_excl = json[cls.FLAG_VALUE_LOCAL_VAT_EXCL]
price.display_order = json[cls.FLAG_DISPLAY_ORDER]