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

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

View File

@@ -507,7 +507,7 @@ Total : 575 files, 67395 codes, 18525 comments, 9686 blanks, all 95606 lines
| [static/js/components/common/temporary/overlay_error.js](/static/js/components/common/temporary/overlay_error.js) | JavaScript | 17 | 0 | 2 | 19 | | [static/js/components/common/temporary/overlay_error.js](/static/js/components/common/temporary/overlay_error.js) | JavaScript | 17 | 0 | 2 | 19 |
| [static/js/components/common/video.js](/static/js/components/common/video.js) | JavaScript | 10 | 0 | 4 | 14 | | [static/js/components/common/video.js](/static/js/components/common/video.js) | JavaScript | 10 | 0 | 4 | 14 |
| [static/js/dom.js](/static/js/dom.js) | JavaScript | 169 | 18 | 11 | 198 | | [static/js/dom.js](/static/js/dom.js) | JavaScript | 169 | 18 | 11 | 198 |
| [static/js/lib/business_objects.js](/static/js/lib/business_objects.js) | JavaScript | 15 | 7 | 2 | 24 | | [static/js/lib/business_objects/business_objects.js](/static/js/lib/business_objects/business_objects.js) | JavaScript | 15 | 7 | 2 | 24 |
| [static/js/lib/common.js](/static/js/lib/common.js) | JavaScript | 63 | 3 | 19 | 85 | | [static/js/lib/common.js](/static/js/lib/common.js) | JavaScript | 63 | 3 | 19 | 85 |
| [static/js/lib/constants.js](/static/js/lib/constants.js) | JavaScript | 4 | 1 | 2 | 7 | | [static/js/lib/constants.js](/static/js/lib/constants.js) | JavaScript | 4 | 1 | 2 | 7 |
| [static/js/lib/events.js](/static/js/lib/events.js) | JavaScript | 9 | 0 | 1 | 10 | | [static/js/lib/events.js](/static/js/lib/events.js) | JavaScript | 9 | 0 | 1 | 10 |

File diff suppressed because one or more lines are too long

View File

@@ -2124,7 +2124,7 @@ Total : 2192 files, 564177 codes, 49307 comments, 82958 blanks, all 696442 line
| [static/js/components/common/temporary/overlay_error.js](/static/js/components/common/temporary/overlay_error.js) | JavaScript | 17 | 0 | 2 | 19 | | [static/js/components/common/temporary/overlay_error.js](/static/js/components/common/temporary/overlay_error.js) | JavaScript | 17 | 0 | 2 | 19 |
| [static/js/components/common/video.js](/static/js/components/common/video.js) | JavaScript | 10 | 0 | 4 | 14 | | [static/js/components/common/video.js](/static/js/components/common/video.js) | JavaScript | 10 | 0 | 4 | 14 |
| [static/js/dom.js](/static/js/dom.js) | JavaScript | 169 | 18 | 11 | 198 | | [static/js/dom.js](/static/js/dom.js) | JavaScript | 169 | 18 | 11 | 198 |
| [static/js/lib/business_objects.js](/static/js/lib/business_objects.js) | JavaScript | 15 | 7 | 2 | 24 | | [static/js/lib/business_objects/business_objects.js](/static/js/lib/business_objects/business_objects.js) | JavaScript | 15 | 7 | 2 | 24 |
| [static/js/lib/common.js](/static/js/lib/common.js) | JavaScript | 63 | 3 | 19 | 85 | | [static/js/lib/common.js](/static/js/lib/common.js) | JavaScript | 63 | 3 | 19 | 85 |
| [static/js/lib/constants.js](/static/js/lib/constants.js) | JavaScript | 4 | 1 | 2 | 7 | | [static/js/lib/constants.js](/static/js/lib/constants.js) | JavaScript | 4 | 1 | 2 | 7 |
| [static/js/lib/events.js](/static/js/lib/events.js) | JavaScript | 9 | 0 | 1 | 10 | | [static/js/lib/events.js](/static/js/lib/events.js) | JavaScript | 9 | 0 | 1 | 10 |

File diff suppressed because one or more lines are too long

View File

@@ -2124,7 +2124,7 @@ Total : 2192 files, 564177 codes, 49307 comments, 82958 blanks, all 696442 line
| [static/js/components/common/temporary/overlay_error.js](/static/js/components/common/temporary/overlay_error.js) | JavaScript | 17 | 0 | 2 | 19 | | [static/js/components/common/temporary/overlay_error.js](/static/js/components/common/temporary/overlay_error.js) | JavaScript | 17 | 0 | 2 | 19 |
| [static/js/components/common/video.js](/static/js/components/common/video.js) | JavaScript | 10 | 0 | 4 | 14 | | [static/js/components/common/video.js](/static/js/components/common/video.js) | JavaScript | 10 | 0 | 4 | 14 |
| [static/js/dom.js](/static/js/dom.js) | JavaScript | 169 | 18 | 11 | 198 | | [static/js/dom.js](/static/js/dom.js) | JavaScript | 169 | 18 | 11 | 198 |
| [static/js/lib/business_objects.js](/static/js/lib/business_objects.js) | JavaScript | 15 | 7 | 2 | 24 | | [static/js/lib/business_objects/business_objects.js](/static/js/lib/business_objects/business_objects.js) | JavaScript | 15 | 7 | 2 | 24 |
| [static/js/lib/common.js](/static/js/lib/common.js) | JavaScript | 63 | 3 | 19 | 85 | | [static/js/lib/common.js](/static/js/lib/common.js) | JavaScript | 63 | 3 | 19 | 85 |
| [static/js/lib/constants.js](/static/js/lib/constants.js) | JavaScript | 4 | 1 | 2 | 7 | | [static/js/lib/constants.js](/static/js/lib/constants.js) | JavaScript | 4 | 1 | 2 | 7 |
| [static/js/lib/events.js](/static/js/lib/events.js) | JavaScript | 9 | 0 | 1 | 10 | | [static/js/lib/events.js](/static/js/lib/events.js) | JavaScript | 9 | 0 | 1 | 10 |

File diff suppressed because one or more lines are too long

View File

@@ -2124,7 +2124,7 @@ Total : 2192 files, 564177 codes, 49307 comments, 82958 blanks, all 696442 line
| [static/js/components/common/temporary/overlay_error.js](/static/js/components/common/temporary/overlay_error.js) | JavaScript | 17 | 0 | 2 | 19 | | [static/js/components/common/temporary/overlay_error.js](/static/js/components/common/temporary/overlay_error.js) | JavaScript | 17 | 0 | 2 | 19 |
| [static/js/components/common/video.js](/static/js/components/common/video.js) | JavaScript | 10 | 0 | 4 | 14 | | [static/js/components/common/video.js](/static/js/components/common/video.js) | JavaScript | 10 | 0 | 4 | 14 |
| [static/js/dom.js](/static/js/dom.js) | JavaScript | 169 | 18 | 11 | 198 | | [static/js/dom.js](/static/js/dom.js) | JavaScript | 169 | 18 | 11 | 198 |
| [static/js/lib/business_objects.js](/static/js/lib/business_objects.js) | JavaScript | 15 | 7 | 2 | 24 | | [static/js/lib/business_objects/business_objects.js](/static/js/lib/business_objects/business_objects.js) | JavaScript | 15 | 7 | 2 | 24 |
| [static/js/lib/common.js](/static/js/lib/common.js) | JavaScript | 63 | 3 | 19 | 85 | | [static/js/lib/common.js](/static/js/lib/common.js) | JavaScript | 63 | 3 | 19 | 85 |
| [static/js/lib/constants.js](/static/js/lib/constants.js) | JavaScript | 4 | 1 | 2 | 7 | | [static/js/lib/constants.js](/static/js/lib/constants.js) | JavaScript | 4 | 1 | 2 | 7 |
| [static/js/lib/events.js](/static/js/lib/events.js) | JavaScript | 9 | 0 | 1 | 10 | | [static/js/lib/events.js](/static/js/lib/events.js) | JavaScript | 9 | 0 | 1 | 10 |

File diff suppressed because one or more lines are too long

View File

@@ -516,7 +516,7 @@ Total : 584 files, 70074 codes, 18431 comments, 9994 blanks, all 98499 lines
| [static/js/components/common/temporary/overlay_error.js](/static/js/components/common/temporary/overlay_error.js) | JavaScript | 17 | 0 | 2 | 19 | | [static/js/components/common/temporary/overlay_error.js](/static/js/components/common/temporary/overlay_error.js) | JavaScript | 17 | 0 | 2 | 19 |
| [static/js/components/common/video.js](/static/js/components/common/video.js) | JavaScript | 10 | 0 | 4 | 14 | | [static/js/components/common/video.js](/static/js/components/common/video.js) | JavaScript | 10 | 0 | 4 | 14 |
| [static/js/dom.js](/static/js/dom.js) | JavaScript | 169 | 18 | 11 | 198 | | [static/js/dom.js](/static/js/dom.js) | JavaScript | 169 | 18 | 11 | 198 |
| [static/js/lib/business_objects.js](/static/js/lib/business_objects.js) | JavaScript | 15 | 7 | 2 | 24 | | [static/js/lib/business_objects/business_objects.js](/static/js/lib/business_objects/business_objects.js) | JavaScript | 15 | 7 | 2 | 24 |
| [static/js/lib/common.js](/static/js/lib/common.js) | JavaScript | 63 | 3 | 19 | 85 | | [static/js/lib/common.js](/static/js/lib/common.js) | JavaScript | 63 | 3 | 19 | 85 |
| [static/js/lib/constants.js](/static/js/lib/constants.js) | JavaScript | 4 | 1 | 2 | 7 | | [static/js/lib/constants.js](/static/js/lib/constants.js) | JavaScript | 4 | 1 | 2 | 7 |
| [static/js/lib/events.js](/static/js/lib/events.js) | JavaScript | 9 | 0 | 1 | 10 | | [static/js/lib/events.js](/static/js/lib/events.js) | JavaScript | 9 | 0 | 1 | 10 |

File diff suppressed because one or more lines are too long

View File

@@ -35,6 +35,7 @@ class Base():
FLAG_CITY: ClassVar[str] = 'city' FLAG_CITY: ClassVar[str] = 'city'
FLAG_CODE: ClassVar[str] = 'code' FLAG_CODE: ClassVar[str] = 'code'
FLAG_COUNTY: ClassVar[str] = 'county' FLAG_COUNTY: ClassVar[str] = 'county'
FLAG_CREATED_BY: ClassVar[str] = 'created_by'
FLAG_CREATED_ON: ClassVar[str] = 'created_on' FLAG_CREATED_ON: ClassVar[str] = 'created_on'
FLAG_CURRENCY: ClassVar[str] = 'currency' FLAG_CURRENCY: ClassVar[str] = 'currency'
FLAG_CURRENCY_COST: ClassVar[str] = 'currency_cost' FLAG_CURRENCY_COST: ClassVar[str] = 'currency_cost'

View File

@@ -68,8 +68,6 @@ class Currency(db.Model, Store_Base):
return currency return currency
@classmethod @classmethod
def from_DB_get_many_product_catalogue_product_permutation(cls, query_row): def from_DB_get_many_product_catalogue_product_permutation(cls, query_row):
_m = 'Currency.from_DB_get_many_product_catalogue_product_permutation'
v_arg_type = 'class attribute'
currency = cls() currency = cls()
currency.id_currency = query_row[5] currency.id_currency = query_row[5]
currency.code = query_row[6] currency.code = query_row[6]
@@ -77,14 +75,10 @@ class Currency(db.Model, Store_Base):
return currency return currency
@classmethod @classmethod
def from_DB_get_many_product_price_and_discount_and_delivery_region(cls, query_row): def from_DB_get_many_product_price_and_discount_and_delivery_region(cls, query_row):
_m = 'Currency.from_DB_get_many_product_price_and_discount_and_delivery_region'
v_arg_type = 'class attribute'
currency = cls() currency = cls()
return currency return currency
@classmethod @classmethod
def from_DB_stock_item(cls, query_row): def from_DB_stock_item(cls, query_row):
_m = 'Currency.from_DB_get_many_stock_item'
v_arg_type = 'class attribute'
currency = cls() currency = cls()
currency.id_currency = query_row[12] currency.id_currency = query_row[12]
currency.code = query_row[13] currency.code = query_row[13]
@@ -92,12 +86,24 @@ class Currency(db.Model, Store_Base):
return currency return currency
@classmethod @classmethod
def from_DB_supplier(cls, query_row): def from_DB_supplier(cls, query_row):
_m = 'Currency.from_DB_supplier'
v_arg_type = 'class attribute'
currency = cls() currency = cls()
currency.id_currency = query_row[1] currency.id_currency = query_row[1]
currency.symbol = query_row[2] currency.code = query_row[2]
currency.code = query_row[3] currency.symbol = query_row[3]
return currency
@classmethod
def from_DB_supplier_purchase_order(cls, query_row):
currency = cls()
currency.id_currency = query_row[3]
currency.code = query_row[4]
currency.symbol = query_row[5]
return currency
@classmethod
def from_DB_manufacturing_purchase_order(cls, query_row):
currency = cls()
currency.id_currency = query_row[1]
currency.code = query_row[2]
currency.symbol = query_row[3]
return currency return currency
def __repr__(self): def __repr__(self):
return f''' return f'''

View File

@@ -12,6 +12,7 @@ Business object for manufacturing_purchase_order
# internal # internal
import lib.argument_validation as av import lib.argument_validation as av
from business_objects.currency import Currency
from business_objects.db_base import Get_Many_Parameters_Base from business_objects.db_base import Get_Many_Parameters_Base
from business_objects.store.store_base import Store_Base from business_objects.store.store_base import Store_Base
from extensions import db from extensions import db
@@ -38,19 +39,21 @@ class Manufacturing_Purchase_Order(db.Model, Store_Base):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
Store_Base.__init__(self) Store_Base.__init__(self)
self.items = None self.items = []
self.currency = None
@classmethod @classmethod
def from_DB_manufacturing_purchase_order(cls, query_row): def from_DB_manufacturing_purchase_order(cls, query_row):
manufacturing_purchase_order = cls() manufacturing_purchase_order = cls()
manufacturing_purchase_order.id_order = query_row[0] manufacturing_purchase_order.id_order = query_row[0]
manufacturing_purchase_order.id_currency = query_row[1] manufacturing_purchase_order.id_currency = query_row[1]
manufacturing_purchase_order.cost_total_local_VAT_excl = query_row[2] manufacturing_purchase_order.currency = Currency.from_DB_manufacturing_purchase_order(query_row)
manufacturing_purchase_order.cost_total_local_VAT_incl = query_row[3] manufacturing_purchase_order.cost_total_local_VAT_excl = query_row[4]
manufacturing_purchase_order.price_total_local_VAT_excl = query_row[4] manufacturing_purchase_order.cost_total_local_VAT_incl = query_row[5]
manufacturing_purchase_order.price_total_local_VAT_incl = query_row[5] manufacturing_purchase_order.price_total_local_VAT_excl = query_row[6]
manufacturing_purchase_order.active = av.input_bool(query_row[6], 'active', f'{cls.__name__}.from_DB_manufacturing_purchase_order') manufacturing_purchase_order.price_total_local_VAT_incl = query_row[7]
manufacturing_purchase_order.created_on = query_row[7] manufacturing_purchase_order.active = av.input_bool(query_row[8], 'active', f'{cls.__name__}.from_DB_manufacturing_purchase_order')
manufacturing_purchase_order.name = query_row[8] manufacturing_purchase_order.created_on = query_row[9]
manufacturing_purchase_order.name = query_row[10]
return manufacturing_purchase_order return manufacturing_purchase_order
def __repr__(self): def __repr__(self):
@@ -74,6 +77,7 @@ class Manufacturing_Purchase_Order(db.Model, Store_Base):
self.FLAG_COST_TOTAL_LOCAL_VAT_INCL: self.cost_total_local_VAT_incl, self.FLAG_COST_TOTAL_LOCAL_VAT_INCL: self.cost_total_local_VAT_incl,
self.FLAG_PRICE_TOTAL_LOCAL_VAT_EXCL: self.price_total_local_VAT_excl, self.FLAG_PRICE_TOTAL_LOCAL_VAT_EXCL: self.price_total_local_VAT_excl,
self.FLAG_PRICE_TOTAL_LOCAL_VAT_INCL: self.price_total_local_VAT_incl, self.FLAG_PRICE_TOTAL_LOCAL_VAT_INCL: self.price_total_local_VAT_incl,
self.FLAG_ORDER_ITEMS: [item.to_json() for item in self.items],
self.FLAG_ACTIVE: av.input_bool(self.active, self.FLAG_ACTIVE, f'{self.__class__.__name__}.to_json'), self.FLAG_ACTIVE: av.input_bool(self.active, self.FLAG_ACTIVE, f'{self.__class__.__name__}.to_json'),
self.FLAG_CREATED_ON: self.created_on, self.FLAG_CREATED_ON: self.created_on,
self.FLAG_NAME: self.name, self.FLAG_NAME: self.name,
@@ -107,7 +111,6 @@ class Manufacturing_Purchase_Order(db.Model, Store_Base):
return preview return preview
class Manufacturing_Purchase_Order_Product_Link(db.Model, Store_Base): class Manufacturing_Purchase_Order_Product_Link(db.Model, Store_Base):
FLAG_LATENCY_MANUFACTURE_DAYS: ClassVar[str] = 'latency_manufacture_days'
FLAG_QUANTITY_PRODUCED: ClassVar[str] = 'quantity_produced' FLAG_QUANTITY_PRODUCED: ClassVar[str] = 'quantity_produced'
FLAG_QUANTITY_USED: ClassVar[str] = 'quantity_used' FLAG_QUANTITY_USED: ClassVar[str] = 'quantity_used'
NAME_ATTR_OPTION_VALUE: ClassVar[str] = Store_Base.ATTR_ID_MANUFACTURING_PURCHASE_ORDER_PRODUCT_LINK NAME_ATTR_OPTION_VALUE: ClassVar[str] = Store_Base.ATTR_ID_MANUFACTURING_PURCHASE_ORDER_PRODUCT_LINK
@@ -120,7 +123,8 @@ class Manufacturing_Purchase_Order_Product_Link(db.Model, Store_Base):
name_permutation = db.Column(db.String(255)) name_permutation = db.Column(db.String(255))
quantity_used = db.Column(db.Float) quantity_used = db.Column(db.Float)
quantity_produced = db.Column(db.Float) quantity_produced = db.Column(db.Float)
latency_manufacture_days = db.Column(db.Integer) id_unit_latency_manufacture = db.Column(db.Integer)
latency_manufacture = db.Column(db.Integer)
display_order = db.Column(db.Integer) display_order = db.Column(db.Integer)
cost_unit_local_VAT_excl = db.Column(db.Float) cost_unit_local_VAT_excl = db.Column(db.Float)
cost_unit_local_VAT_incl = db.Column(db.Float) cost_unit_local_VAT_incl = db.Column(db.Float)
@@ -142,13 +146,14 @@ class Manufacturing_Purchase_Order_Product_Link(db.Model, Store_Base):
link.id_unit_quantity = query_row[4] link.id_unit_quantity = query_row[4]
link.quantity_used = query_row[5] link.quantity_used = query_row[5]
link.quantity_produced = query_row[6] link.quantity_produced = query_row[6]
link.latency_manufacture_days = query_row[7] link.id_unit_latency_manufacture = query_row[7]
link.display_order = query_row[8] link.latency_manufacture = query_row[8]
link.cost_unit_local_VAT_excl = query_row[9] link.display_order = query_row[9]
link.cost_unit_local_VAT_incl = query_row[10] link.cost_unit_local_VAT_excl = query_row[10]
link.price_unit_local_VAT_excl = query_row[11] link.cost_unit_local_VAT_incl = query_row[11]
link.price_unit_local_VAT_incl = query_row[12] link.price_unit_local_VAT_excl = query_row[12]
link.active = query_row[13] link.price_unit_local_VAT_incl = query_row[13]
link.active = query_row[14]
return link return link
def __repr__(self): def __repr__(self):
return f''' return f'''
@@ -159,7 +164,8 @@ class Manufacturing_Purchase_Order_Product_Link(db.Model, Store_Base):
{self.ATTR_ID_UNIT_MEASUREMENT_QUANTITY}: {self.id_unit_quantity}, {self.ATTR_ID_UNIT_MEASUREMENT_QUANTITY}: {self.id_unit_quantity},
{self.FLAG_QUANTITY_USED}: {self.quantity_used}, {self.FLAG_QUANTITY_USED}: {self.quantity_used},
{self.FLAG_QUANTITY_PRODUCED}: {self.quantity_produced}, {self.FLAG_QUANTITY_PRODUCED}: {self.quantity_produced},
{self.FLAG_LATENCY_MANUFACTURE_DAYS}: {self.latency_manufacture_days}, {self.ATTR_ID_UNIT_MEASUREMENT_LATENCY_MANUFACTURE}: {self.id_unit_latency_manufacture},
{self.FLAG_LATENCY_MANUFACTURE}: {self.latency_manufacture},
{self.FLAG_DISPLAY_ORDER}: {self.display_order}, {self.FLAG_DISPLAY_ORDER}: {self.display_order},
{self.FLAG_COST_UNIT_LOCAL_VAT_EXCL}: {self.cost_unit_local_VAT_excl}, {self.FLAG_COST_UNIT_LOCAL_VAT_EXCL}: {self.cost_unit_local_VAT_excl},
{self.FLAG_COST_UNIT_LOCAL_VAT_INCL}: {self.cost_unit_local_VAT_incl}, {self.FLAG_COST_UNIT_LOCAL_VAT_INCL}: {self.cost_unit_local_VAT_incl},
@@ -177,7 +183,8 @@ class Manufacturing_Purchase_Order_Product_Link(db.Model, Store_Base):
self.ATTR_ID_UNIT_MEASUREMENT_QUANTITY: self.id_unit_quantity, self.ATTR_ID_UNIT_MEASUREMENT_QUANTITY: self.id_unit_quantity,
self.FLAG_QUANTITY_USED: self.quantity_used, self.FLAG_QUANTITY_USED: self.quantity_used,
self.FLAG_QUANTITY_PRODUCED: self.quantity_produced, self.FLAG_QUANTITY_PRODUCED: self.quantity_produced,
self.FLAG_LATENCY_MANUFACTURE_DAYS: self.latency_manufacture_days, self.ATTR_ID_UNIT_MEASUREMENT_LATENCY_MANUFACTURE: self.id_unit_latency_manufacture,
self.FLAG_LATENCY_MANUFACTURE: self.latency_manufacture,
self.FLAG_DISPLAY_ORDER: self.display_order, self.FLAG_DISPLAY_ORDER: self.display_order,
self.FLAG_COST_UNIT_LOCAL_VAT_EXCL: self.cost_unit_local_VAT_excl, self.FLAG_COST_UNIT_LOCAL_VAT_EXCL: self.cost_unit_local_VAT_excl,
self.FLAG_COST_UNIT_LOCAL_VAT_INCL: self.cost_unit_local_VAT_incl, self.FLAG_COST_UNIT_LOCAL_VAT_INCL: self.cost_unit_local_VAT_incl,
@@ -201,7 +208,8 @@ class Manufacturing_Purchase_Order_Product_Link(db.Model, Store_Base):
link.id_unit_quantity = json[cls.ATTR_ID_UNIT_MEASUREMENT_QUANTITY] link.id_unit_quantity = json[cls.ATTR_ID_UNIT_MEASUREMENT_QUANTITY]
link.quantity_used = json[cls.FLAG_QUANTITY_USED] link.quantity_used = json[cls.FLAG_QUANTITY_USED]
link.quantity_produced = json[cls.FLAG_QUANTITY_PRODUCED] link.quantity_produced = json[cls.FLAG_QUANTITY_PRODUCED]
link.latency_manufacture_days = json[cls.FLAG_LATENCY_MANUFACTURE_DAYS] link.id_unit_latency_manufacture = json[cls.ATTR_ID_UNIT_MEASUREMENT_LATENCY_MANUFACTURE]
link.latency_manufacture = json[cls.FLAG_LATENCY_MANUFACTURE]
link.display_order = json[cls.FLAG_DISPLAY_ORDER] link.display_order = json[cls.FLAG_DISPLAY_ORDER]
link.cost_unit_local_VAT_excl = json[cls.FLAG_COST_UNIT_LOCAL_VAT_EXCL] link.cost_unit_local_VAT_excl = json[cls.FLAG_COST_UNIT_LOCAL_VAT_EXCL]
link.cost_unit_local_VAT_incl = json[cls.FLAG_COST_UNIT_LOCAL_VAT_INCL] link.cost_unit_local_VAT_incl = json[cls.FLAG_COST_UNIT_LOCAL_VAT_INCL]
@@ -269,7 +277,8 @@ class Manufacturing_Purchase_Order_Product_Link_Temp(db.Model, Store_Base):
id_unit_quantity: int = db.Column(db.Integer) id_unit_quantity: int = db.Column(db.Integer)
quantity_used: float = db.Column(db.Float) quantity_used: float = db.Column(db.Float)
quantity_produced: float = db.Column(db.Float) quantity_produced: float = db.Column(db.Float)
latency_manufacture_days: int = db.Column(db.Integer) id_unit_latency_manufacture = db.Column(db.Integer)
latency_manufacture: int = db.Column(db.Integer)
display_order: int = db.Column(db.Integer) display_order: int = db.Column(db.Integer)
cost_unit_local_VAT_excl: float = db.Column(db.Float) cost_unit_local_VAT_excl: float = db.Column(db.Float)
cost_unit_local_VAT_incl: float = db.Column(db.Float) cost_unit_local_VAT_incl: float = db.Column(db.Float)
@@ -286,7 +295,8 @@ class Manufacturing_Purchase_Order_Product_Link_Temp(db.Model, Store_Base):
row.id_unit_quantity = manufacturing_purchase_order_product_link.id_unit_quantity row.id_unit_quantity = manufacturing_purchase_order_product_link.id_unit_quantity
row.quantity_used = manufacturing_purchase_order_product_link.quantity_used row.quantity_used = manufacturing_purchase_order_product_link.quantity_used
row.quantity_produced = manufacturing_purchase_order_product_link.quantity_produced row.quantity_produced = manufacturing_purchase_order_product_link.quantity_produced
row.latency_manufacture_days = manufacturing_purchase_order_product_link.latency_manufacture_days row.id_unit_latency_manufacture = manufacturing_purchase_order_product_link.id_unit_latency_manufacture
row.latency_manufacture = manufacturing_purchase_order_product_link.latency_manufacture
row.display_order = manufacturing_purchase_order_product_link.display_order row.display_order = manufacturing_purchase_order_product_link.display_order
row.cost_unit_local_VAT_excl = manufacturing_purchase_order_product_link.cost_unit_local_VAT_excl row.cost_unit_local_VAT_excl = manufacturing_purchase_order_product_link.cost_unit_local_VAT_excl
row.cost_unit_local_VAT_incl = manufacturing_purchase_order_product_link.cost_unit_local_VAT_incl row.cost_unit_local_VAT_incl = manufacturing_purchase_order_product_link.cost_unit_local_VAT_incl
@@ -302,7 +312,8 @@ id_permutation: {self.id_permutation}
id_unit_quantity: {self.id_unit_quantity} id_unit_quantity: {self.id_unit_quantity}
quantity_used: {self.quantity_used} quantity_used: {self.quantity_used}
quantity_produced: {self.quantity_produced} quantity_produced: {self.quantity_produced}
latency_manufacture_days: {self.latency_manufacture_days} {self.ATTR_ID_UNIT_MEASUREMENT_LATENCY_MANUFACTURE}: {self.id_unit_latency_manufacture}
latency_manufacture: {self.latency_manufacture}
display_order: {self.display_order} display_order: {self.display_order}
cost_unit_local_VAT_excl: {self.cost_unit_local_VAT_excl} cost_unit_local_VAT_excl: {self.cost_unit_local_VAT_excl}
cost_unit_local_VAT_incl: {self.cost_unit_local_VAT_incl} cost_unit_local_VAT_incl: {self.cost_unit_local_VAT_incl}

View File

@@ -40,7 +40,7 @@ class Product_Permutation(db.Model, Store_Base):
FLAG_COST_LOCAL = 'cost_local' FLAG_COST_LOCAL = 'cost_local'
FLAG_PROFIT_LOCAL_MIN = 'profit_local_min' FLAG_PROFIT_LOCAL_MIN = 'profit_local_min'
FLAG_HAS_VARIATIONS = 'has_variations' FLAG_HAS_VARIATIONS = 'has_variations'
FLAG_LATENCY_MANUFACTURE_DAYS = 'latency_manufacture_days' FLAG_LATENCY_MANUFACTURE = 'latency_manufacture'
FLAG_UNIT_MEASUREMENT_QUANTITY = f'{Unit_Measurement.ATTR_ID_UNIT_MEASUREMENT}_quantity' FLAG_UNIT_MEASUREMENT_QUANTITY = f'{Unit_Measurement.ATTR_ID_UNIT_MEASUREMENT}_quantity'
FLAG_SYMBOL_UNIT_MEASUREMENT_QUANTITY = f'{Unit_Measurement.FLAG_SYMBOL}_quantity' FLAG_SYMBOL_UNIT_MEASUREMENT_QUANTITY = f'{Unit_Measurement.FLAG_SYMBOL}_quantity'
FLAG_SYMBOL_IS_SUFFIX_NOT_PREFIX_UNIT_MEASUREMENT_QUANTITY = f'{Unit_Measurement.FLAG_SYMBOL_IS_SUFFIX_NOT_PREFIX}_quantity' FLAG_SYMBOL_IS_SUFFIX_NOT_PREFIX_UNIT_MEASUREMENT_QUANTITY = f'{Unit_Measurement.FLAG_SYMBOL_IS_SUFFIX_NOT_PREFIX}_quantity'
@@ -80,7 +80,7 @@ class Product_Permutation(db.Model, Store_Base):
cost_local = db.Column(db.Float) cost_local = db.Column(db.Float)
profit_local_min = db.Column(db.Float) profit_local_min = db.Column(db.Float)
has_variations = db.Column(db.Boolean) has_variations = db.Column(db.Boolean)
latency_manufacture_days = db.Column(db.Integer) latency_manufacture = db.Column(db.Integer)
id_unit_measurement_quantity = db.Column(db.Integer) id_unit_measurement_quantity = db.Column(db.Integer)
symbol_unit_measurement_quantity = db.Column(db.String(50)) symbol_unit_measurement_quantity = db.Column(db.String(50))
symbol_is_suffix_not_prefix_unit_measurement_quantity = db.Column(db.Boolean) symbol_is_suffix_not_prefix_unit_measurement_quantity = db.Column(db.Boolean)
@@ -151,7 +151,7 @@ class Product_Permutation(db.Model, Store_Base):
permutation.cost_local = query_row[4] permutation.cost_local = query_row[4]
permutation.currency_cost = Currency.from_DB_get_many_product_catalogue_product_permutation(query_row) permutation.currency_cost = Currency.from_DB_get_many_product_catalogue_product_permutation(query_row)
permutation.profit_local_min = query_row[8] permutation.profit_local_min = query_row[8]
permutation.latency_manufacture_days = query_row[9] permutation.latency_manufacture = query_row[9]
permutation.id_unit_measurement_quantity = query_row[10] permutation.id_unit_measurement_quantity = query_row[10]
permutation.symbol_unit_measurement_quantity = query_row[11] permutation.symbol_unit_measurement_quantity = query_row[11]
permutation.symbol_is_suffix_not_prefix_unit_measurement_quantity = av.input_bool(query_row[12], cls.FLAG_SYMBOL_IS_SUFFIX_NOT_PREFIX_UNIT_MEASUREMENT_QUANTITY, _m, v_arg_type=v_arg_type) permutation.symbol_is_suffix_not_prefix_unit_measurement_quantity = av.input_bool(query_row[12], cls.FLAG_SYMBOL_IS_SUFFIX_NOT_PREFIX_UNIT_MEASUREMENT_QUANTITY, _m, v_arg_type=v_arg_type)
@@ -224,7 +224,7 @@ class Product_Permutation(db.Model, Store_Base):
permutation.cost_local = json[cls.FLAG_COST_LOCAL] permutation.cost_local = json[cls.FLAG_COST_LOCAL]
permutation.currency_cost = Currency.from_json(json, '_cost') permutation.currency_cost = Currency.from_json(json, '_cost')
permutation.profit_local_min = json[cls.FLAG_PROFIT_LOCAL_MIN] permutation.profit_local_min = json[cls.FLAG_PROFIT_LOCAL_MIN]
permutation.latency_manufacture_days = json[cls.FLAG_LATENCY_MANUFACTURE_DAYS] permutation.latency_manufacture = json[cls.FLAG_LATENCY_MANUFACTURE]
permutation.id_unit_measurement_quantity = json[cls.FLAG_UNIT_MEASUREMENT_QUANTITY] permutation.id_unit_measurement_quantity = json[cls.FLAG_UNIT_MEASUREMENT_QUANTITY]
permutation.symbol_unit_measurement_quantity = json.get(cls.FLAG_SYMBOL_UNIT_MEASUREMENT_QUANTITY) permutation.symbol_unit_measurement_quantity = json.get(cls.FLAG_SYMBOL_UNIT_MEASUREMENT_QUANTITY)
permutation.symbol_is_suffix_not_prefix_unit_measurement_quantity = json.get(cls.FLAG_SYMBOL_IS_SUFFIX_NOT_PREFIX_UNIT_MEASUREMENT_QUANTITY) permutation.symbol_is_suffix_not_prefix_unit_measurement_quantity = json.get(cls.FLAG_SYMBOL_IS_SUFFIX_NOT_PREFIX_UNIT_MEASUREMENT_QUANTITY)
@@ -269,7 +269,7 @@ class Product_Permutation(db.Model, Store_Base):
self.FLAG_COST_LOCAL: self.cost_local, self.FLAG_COST_LOCAL: self.cost_local,
self.FLAG_CURRENCY_COST: self.currency_cost.to_json(), self.FLAG_CURRENCY_COST: self.currency_cost.to_json(),
self.FLAG_PROFIT_LOCAL_MIN: self.profit_local_min, self.FLAG_PROFIT_LOCAL_MIN: self.profit_local_min,
self.FLAG_LATENCY_MANUFACTURE_DAYS: self.latency_manufacture_days, self.FLAG_LATENCY_MANUFACTURE: self.latency_manufacture,
self.FLAG_UNIT_MEASUREMENT_QUANTITY: self.id_unit_measurement_quantity, self.FLAG_UNIT_MEASUREMENT_QUANTITY: self.id_unit_measurement_quantity,
self.FLAG_SYMBOL_UNIT_MEASUREMENT_QUANTITY: self.symbol_unit_measurement_quantity, self.FLAG_SYMBOL_UNIT_MEASUREMENT_QUANTITY: self.symbol_unit_measurement_quantity,
self.FLAG_SYMBOL_IS_SUFFIX_NOT_PREFIX_UNIT_MEASUREMENT_QUANTITY: self.symbol_is_suffix_not_prefix_unit_measurement_quantity, self.FLAG_SYMBOL_IS_SUFFIX_NOT_PREFIX_UNIT_MEASUREMENT_QUANTITY: self.symbol_is_suffix_not_prefix_unit_measurement_quantity,
@@ -320,11 +320,11 @@ class Product_Permutation(db.Model, Store_Base):
return self.prices[0] return self.prices[0]
def output_delivery_date(self): def output_delivery_date(self):
return (datetime.now() + timedelta(days=self.latency_manufacture_days)).strftime('%A, %d %B %Y') return (datetime.now() + timedelta(days=self.latency_manufacture)).strftime('%A, %d %B %Y')
""" """
def output_lead_time(self): def output_lead_time(self):
return '1 day' if self.latency_manufacture_days == 1 else f'{self.latency_manufacture_days} days' return '1 day' if self.latency_manufacture == 1 else f'{self.latency_manufacture} days'
def output_price(self, is_included_VAT): def output_price(self, is_included_VAT):
if self.is_unavailable_in_currency_or_region: if self.is_unavailable_in_currency_or_region:
@@ -353,7 +353,7 @@ class Product_Permutation(db.Model, Store_Base):
description: {self.description} description: {self.description}
cost_local: {self.cost_local} cost_local: {self.cost_local}
currency_cost: {self.currency_cost} currency_cost: {self.currency_cost}
latency_manufacture_days: {self.latency_manufacture_days} latency_manufacture: {self.latency_manufacture}
id_unit_measurement_quantity: {self.id_unit_measurement_quantity} id_unit_measurement_quantity: {self.id_unit_measurement_quantity}
symbol_unit_measurement_quantity: {self.symbol_unit_measurement_quantity} symbol_unit_measurement_quantity: {self.symbol_unit_measurement_quantity}
symbol_is_suffix_not_prefix_unit_measurement_quantity: {self.symbol_is_suffix_not_prefix_unit_measurement_quantity} symbol_is_suffix_not_prefix_unit_measurement_quantity: {self.symbol_is_suffix_not_prefix_unit_measurement_quantity}
@@ -500,7 +500,7 @@ class Product_Permutation_Temp(db.Model, Store_Base):
cost_local: float = db.Column(db.Float) cost_local: float = db.Column(db.Float)
id_currency_cost: int = db.Column(db.Integer) id_currency_cost: int = db.Column(db.Integer)
profit_local_min: float = db.Column(db.Float) profit_local_min: float = db.Column(db.Float)
latency_manufacture_days: int = db.Column(db.Integer) latency_manufacture: int = db.Column(db.Integer)
id_unit_measurement_quantity: int = db.Column(db.Integer) id_unit_measurement_quantity: int = db.Column(db.Integer)
count_unit_measurement_per_quantity_step: int = db.Column(db.Float) count_unit_measurement_per_quantity_step: int = db.Column(db.Float)
quantity_min: int = db.Column(db.Integer) quantity_min: int = db.Column(db.Integer)
@@ -525,7 +525,7 @@ class Product_Permutation_Temp(db.Model, Store_Base):
row.cost_local = product_permutation.cost_local row.cost_local = product_permutation.cost_local
row.id_currency_cost = product_permutation.currency_cost.id_currency row.id_currency_cost = product_permutation.currency_cost.id_currency
row.profit_local_min = product_permutation.profit_local_min row.profit_local_min = product_permutation.profit_local_min
row.latency_manufacture_days = product_permutation.latency_manufacture_days row.latency_manufacture = product_permutation.latency_manufacture
row.id_unit_measurement_quantity = product_permutation.id_unit_measurement_quantity row.id_unit_measurement_quantity = product_permutation.id_unit_measurement_quantity
row.count_unit_measurement_per_quantity_step = product_permutation.count_unit_measurement_per_quantity_step row.count_unit_measurement_per_quantity_step = product_permutation.count_unit_measurement_per_quantity_step
row.quantity_min = product_permutation.quantity_min row.quantity_min = product_permutation.quantity_min
@@ -548,7 +548,7 @@ class Product_Permutation_Temp(db.Model, Store_Base):
cost_local: {self.cost_local} cost_local: {self.cost_local}
id_currency_cost: {self.id_currency_cost} id_currency_cost: {self.id_currency_cost}
profit_local_min: {self.profit_local_min} profit_local_min: {self.profit_local_min}
latency_manufacture_days: {self.latency_manufacture_days} latency_manufacture: {self.latency_manufacture}
id_unit_measurement_quantity: {self.id_unit_measurement_quantity} id_unit_measurement_quantity: {self.id_unit_measurement_quantity}
{Product_Permutation.FLAG_COUNT_UNIT_MEASUREMENT_PER_QUANTITY_STEP}: {self.count_unit_measurement_per_quantity_step} {Product_Permutation.FLAG_COUNT_UNIT_MEASUREMENT_PER_QUANTITY_STEP}: {self.count_unit_measurement_per_quantity_step}
quantity_min: {self.quantity_min} quantity_min: {self.quantity_min}
@@ -573,7 +573,7 @@ class Product_Permutation_Temp(db.Model, Store_Base):
Product_Permutation.FLAG_COST_LOCAL: float(self.cost_local), Product_Permutation.FLAG_COST_LOCAL: float(self.cost_local),
Product_Permutation.FLAG_CURRENCY_COST: int(self.id_currency_cost), Product_Permutation.FLAG_CURRENCY_COST: int(self.id_currency_cost),
Product_Permutation.FLAG_PROFIT_LOCAL_MIN: float(self.profit_local_min), Product_Permutation.FLAG_PROFIT_LOCAL_MIN: float(self.profit_local_min),
Product_Permutation.FLAG_LATENCY_MANUFACTURE_DAYS: int(self.latency_manufacture_days), Product_Permutation.FLAG_LATENCY_MANUFACTURE: int(self.latency_manufacture),
Product_Permutation.FLAG_UNIT_MEASUREMENT_QUANTITY: int(self.id_unit_measurement_quantity), Product_Permutation.FLAG_UNIT_MEASUREMENT_QUANTITY: int(self.id_unit_measurement_quantity),
Product_Permutation.FLAG_COUNT_UNIT_MEASUREMENT_PER_QUANTITY_STEP: float(self.count_unit_measurement_per_quantity_step), Product_Permutation.FLAG_COUNT_UNIT_MEASUREMENT_PER_QUANTITY_STEP: float(self.count_unit_measurement_per_quantity_step),
self.FLAG_QUANTITY_MIN: float(self.quantity_min), self.FLAG_QUANTITY_MIN: float(self.quantity_min),

View File

@@ -80,6 +80,7 @@ class Store_Base(Base):
ATTR_ID_SUPPLIER_ADDRESS: ClassVar[str] = 'id_address' ATTR_ID_SUPPLIER_ADDRESS: ClassVar[str] = 'id_address'
ATTR_ID_SUPPLIER_PURCHASE_ORDER: ClassVar[str] = 'id_order' ATTR_ID_SUPPLIER_PURCHASE_ORDER: ClassVar[str] = 'id_order'
ATTR_ID_SUPPLIER_PURCHASE_ORDER_PRODUCT_LINK: ClassVar[str] = 'id_link' ATTR_ID_SUPPLIER_PURCHASE_ORDER_PRODUCT_LINK: ClassVar[str] = 'id_link'
ATTR_ID_UNIT_MEASUREMENT_LATENCY_MANUFACTURE: ClassVar[str] = 'id_unit_latency_manufacture'
ATTR_ID_UNIT_MEASUREMENT_QUANTITY: ClassVar[str] = 'id_unit_quantity' ATTR_ID_UNIT_MEASUREMENT_QUANTITY: ClassVar[str] = 'id_unit_quantity'
# FLAG_COST_LOCAL: ClassVar[str] = 'cost_local' # FLAG_COST_LOCAL: ClassVar[str] = 'cost_local'
FLAG_COST_TOTAL_LOCAL_VAT_EXCL: ClassVar[str] = 'cost_total_local_vat_excl' FLAG_COST_TOTAL_LOCAL_VAT_EXCL: ClassVar[str] = 'cost_total_local_vat_excl'
@@ -94,7 +95,9 @@ class Store_Base(Base):
FLAG_HAS_VARIATIONS: ClassVar[str] = 'has_variations' FLAG_HAS_VARIATIONS: ClassVar[str] = 'has_variations'
FLAG_IS_OUT_OF_STOCK: ClassVar[str] = 'is_out_of_stock' FLAG_IS_OUT_OF_STOCK: ClassVar[str] = 'is_out_of_stock'
FLAG_LATENCY_DELIVERY_DAYS: ClassVar[str] = 'latency_delivery_days' FLAG_LATENCY_DELIVERY_DAYS: ClassVar[str] = 'latency_delivery_days'
FLAG_LATENCY_MANUFACTURE: ClassVar[str] = 'latency_manufacture'
FLAG_MANUFACTURING_PURCHASE_ORDER: ClassVar[str] = 'manufacturing_purchase_order' FLAG_MANUFACTURING_PURCHASE_ORDER: ClassVar[str] = 'manufacturing_purchase_order'
FLAG_ORDER_ITEMS: ClassVar[str] = 'order_items'
FLAG_PLANT: ClassVar[str] = 'plant' FLAG_PLANT: ClassVar[str] = 'plant'
FLAG_PRICE_TOTAL_LOCAL_VAT_EXCL: ClassVar[str] = 'price_total_local_vat_excl' FLAG_PRICE_TOTAL_LOCAL_VAT_EXCL: ClassVar[str] = 'price_total_local_vat_excl'
FLAG_PRICE_TOTAL_LOCAL_VAT_INCL: ClassVar[str] = 'price_total_local_vat_incl' FLAG_PRICE_TOTAL_LOCAL_VAT_INCL: ClassVar[str] = 'price_total_local_vat_incl'
@@ -118,5 +121,7 @@ class Store_Base(Base):
FLAG_SUPPLIER_ADDRESS: ClassVar[str] = 'supplier_address' FLAG_SUPPLIER_ADDRESS: ClassVar[str] = 'supplier_address'
FLAG_SUPPLIER_PURCHASE_ORDER: ClassVar[str] = 'supplier_purchase_order' FLAG_SUPPLIER_PURCHASE_ORDER: ClassVar[str] = 'supplier_purchase_order'
FLAG_TEXT: ClassVar[str] = 'text' FLAG_TEXT: ClassVar[str] = 'text'
FLAG_UNIT_MEASUREMENT_LATENCY_MANUFACTURE: ClassVar[str] = 'unit_measurement_latency_manufacture'
FLAG_UNIT_MEASUREMENT_QUANTITY: ClassVar[str] = 'unit_measurement_quantity'
FLAG_VALUE_TEXT: ClassVar[str] = 'value_text' FLAG_VALUE_TEXT: ClassVar[str] = 'value_text'

View File

@@ -27,7 +27,7 @@ class Supplier(db.Model, Store_Base):
FLAG_NAME_COMPANY: ClassVar[str] = 'name_company' FLAG_NAME_COMPANY: ClassVar[str] = 'name_company'
FLAG_NAME_CONTACT: ClassVar[str] = 'name_contact' FLAG_NAME_CONTACT: ClassVar[str] = 'name_contact'
NAME_ATTR_OPTION_VALUE: ClassVar[str] = Store_Base.ATTR_ID_SUPPLIER NAME_ATTR_OPTION_VALUE: ClassVar[str] = Store_Base.ATTR_ID_SUPPLIER
NAME_ATTR_OPTION_TEXT: ClassVar[str] = Store_Base.FLAG_NAME NAME_ATTR_OPTION_TEXT: ClassVar[str] = FLAG_NAME_COMPANY
__tablename__ = 'Shop_Supplier_Temp' __tablename__ = 'Shop_Supplier_Temp'
id_supplier = db.Column(db.Integer, primary_key=True) id_supplier = db.Column(db.Integer, primary_key=True)
# id_address = db.Column(db.Integer) # id_address = db.Column(db.Integer)
@@ -64,7 +64,12 @@ class Supplier(db.Model, Store_Base):
supplier.website = query_row[10] supplier.website = query_row[10]
supplier.active = av.input_bool(query_row[11], 'active', f'{cls.__name__}.from_DB_supplier') supplier.active = av.input_bool(query_row[11], 'active', f'{cls.__name__}.from_DB_supplier')
return supplier return supplier
@classmethod
def from_DB_supplier_purchase_order(cls, query_row):
supplier = cls()
supplier.id_supplier = query_row[1]
supplier.name_company = query_row[2]
return supplier
def __repr__(self): def __repr__(self):
return f''' return f'''
id: {self.id_supplier}, id: {self.id_supplier},

View File

@@ -12,8 +12,10 @@ Business object for supplier_purchase_order
# internal # internal
import lib.argument_validation as av import lib.argument_validation as av
from business_objects.currency import Currency
from business_objects.db_base import Get_Many_Parameters_Base from business_objects.db_base import Get_Many_Parameters_Base
from business_objects.store.store_base import Store_Base from business_objects.store.store_base import Store_Base
from business_objects.store.supplier import Supplier
from extensions import db from extensions import db
# external # external
from pydantic import BaseModel from pydantic import BaseModel
@@ -23,7 +25,7 @@ from datetime import datetime
class Supplier_Purchase_Order(db.Model, Store_Base): class Supplier_Purchase_Order(db.Model, Store_Base):
NAME_ATTR_OPTION_VALUE: ClassVar[str] = Store_Base.ATTR_ID_SUPPLIER_PURCHASE_ORDER NAME_ATTR_OPTION_VALUE: ClassVar[str] = Store_Base.ATTR_ID_SUPPLIER_PURCHASE_ORDER
NAME_ATTR_OPTION_TEXT: ClassVar[str] = Store_Base.FLAG_NAME NAME_ATTR_OPTION_TEXT: ClassVar[str] = Store_Base.FLAG_NAME
# __tablename__ = 'Shop_Supplier_Purchase_Order_Temp' __tablename__ = 'Shop_Supplier_Purchase_Order'
id_order = db.Column(db.Integer, primary_key=True) id_order = db.Column(db.Integer, primary_key=True)
id_supplier = db.Column(db.Integer) id_supplier = db.Column(db.Integer)
id_currency = db.Column(db.Integer) id_currency = db.Column(db.Integer)
@@ -37,25 +39,31 @@ class Supplier_Purchase_Order(db.Model, Store_Base):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
Store_Base.__init__(self) Store_Base.__init__(self)
self.items = None self.currency = None
self.items = []
self.supplier = None
@classmethod @classmethod
def from_DB_supplier_purchase_order(cls, query_row): def from_DB_supplier_purchase_order(cls, query_row):
supplier_purchase_order = cls() supplier_purchase_order = cls()
supplier_purchase_order.id_order = query_row[0] supplier_purchase_order.id_order = query_row[0]
supplier_purchase_order.id_supplier = query_row[1] supplier_purchase_order.id_supplier = query_row[1]
supplier_purchase_order.id_currency = query_row[2] supplier_purchase_order.supplier = Supplier.from_DB_supplier_purchase_order(query_row)
supplier_purchase_order.cost_total_local_VAT_excl = query_row[3] supplier_purchase_order.id_currency = query_row[3]
supplier_purchase_order.cost_total_local_VAT_incl = query_row[4] supplier_purchase_order.currency = Currency.from_DB_supplier_purchase_order(query_row)
supplier_purchase_order.active = av.input_bool(query_row[5], 'active', f'{cls.__name__}.from_DB_supplier_purchase_order') supplier_purchase_order.cost_total_local_VAT_excl = query_row[6]
supplier_purchase_order.created_on = query_row[6] supplier_purchase_order.cost_total_local_VAT_incl = query_row[7]
supplier_purchase_order.name = query_row[7] supplier_purchase_order.active = av.input_bool(query_row[8], 'active', f'{cls.__name__}.from_DB_supplier_purchase_order')
supplier_purchase_order.created_on = query_row[9]
supplier_purchase_order.name = query_row[10]
return supplier_purchase_order return supplier_purchase_order
def __repr__(self): def __repr__(self):
return f''' return f'''
{self.ATTR_ID_SUPPLIER_PURCHASE_ORDER}: {self.id_order}, {self.ATTR_ID_SUPPLIER_PURCHASE_ORDER}: {self.id_order},
{self.ATTR_ID_SUPPLIER}: {self.id_supplier}, {self.ATTR_ID_SUPPLIER}: {self.id_supplier},
{self.FLAG_SUPPLIER}: {self.supplier},
{self.ATTR_ID_CURRENCY}: {self.id_currency}, {self.ATTR_ID_CURRENCY}: {self.id_currency},
{self.FLAG_CURRENCY}: {self.currency},
{self.FLAG_COST_TOTAL_LOCAL_VAT_EXCL}: {self.cost_total_local_VAT_excl}, {self.FLAG_COST_TOTAL_LOCAL_VAT_EXCL}: {self.cost_total_local_VAT_excl},
{self.FLAG_COST_TOTAL_LOCAL_VAT_INCL}: {self.cost_total_local_VAT_incl}, {self.FLAG_COST_TOTAL_LOCAL_VAT_INCL}: {self.cost_total_local_VAT_incl},
{self.FLAG_ACTIVE}: {self.active}, {self.FLAG_ACTIVE}: {self.active},
@@ -67,9 +75,12 @@ class Supplier_Purchase_Order(db.Model, Store_Base):
**self.get_shared_json_attributes(self), **self.get_shared_json_attributes(self),
self.ATTR_ID_SUPPLIER_PURCHASE_ORDER: self.id_order, self.ATTR_ID_SUPPLIER_PURCHASE_ORDER: self.id_order,
self.ATTR_ID_SUPPLIER: self.id_supplier, self.ATTR_ID_SUPPLIER: self.id_supplier,
self.FLAG_SUPPLIER: self.supplier.to_json(),
self.ATTR_ID_CURRENCY: self.id_currency, self.ATTR_ID_CURRENCY: self.id_currency,
self.FLAG_CURRENCY: self.currency.to_json(),
self.FLAG_COST_TOTAL_LOCAL_VAT_EXCL: self.cost_total_local_VAT_excl, self.FLAG_COST_TOTAL_LOCAL_VAT_EXCL: self.cost_total_local_VAT_excl,
self.FLAG_COST_TOTAL_LOCAL_VAT_INCL: self.cost_total_local_VAT_incl, self.FLAG_COST_TOTAL_LOCAL_VAT_INCL: self.cost_total_local_VAT_incl,
self.FLAG_ORDER_ITEMS: [item.to_json() for item in self.items],
self.FLAG_ACTIVE: av.input_bool(self.active, self.FLAG_ACTIVE, f'{self.__class__.__name__}.to_json'), self.FLAG_ACTIVE: av.input_bool(self.active, self.FLAG_ACTIVE, f'{self.__class__.__name__}.to_json'),
self.FLAG_CREATED_ON: self.created_on, self.FLAG_CREATED_ON: self.created_on,
self.FLAG_NAME: self.name, self.FLAG_NAME: self.name,
@@ -89,16 +100,19 @@ class Supplier_Purchase_Order(db.Model, Store_Base):
supplier_purchase_order.cost_total_local_VAT_excl = json[cls.FLAG_COST_TOTAL_LOCAL_VAT_EXCL] supplier_purchase_order.cost_total_local_VAT_excl = json[cls.FLAG_COST_TOTAL_LOCAL_VAT_EXCL]
supplier_purchase_order.cost_total_local_VAT_incl = json[cls.FLAG_COST_TOTAL_LOCAL_VAT_INCL] supplier_purchase_order.cost_total_local_VAT_incl = json[cls.FLAG_COST_TOTAL_LOCAL_VAT_INCL]
supplier_purchase_order.active = json[cls.FLAG_ACTIVE] supplier_purchase_order.active = json[cls.FLAG_ACTIVE]
supplier_purchase_order.created_on = json[cls.FLAG_CREATED_ON] supplier_purchase_order.created_on = json.get(cls.FLAG_CREATED_ON, None)
supplier_purchase_order.name = json[cls.FLAG_NAME] supplier_purchase_order.created_by = json.get(cls.FLAG_CREATED_BY, None)
supplier_purchase_order.name = json.get(cls.FLAG_NAME, None)
return supplier_purchase_order return supplier_purchase_order
class Supplier_Purchase_Order_Product_Link(db.Model, Store_Base): class Supplier_Purchase_Order_Product_Link(db.Model, Store_Base):
NAME_ATTR_OPTION_VALUE: ClassVar[str] = Store_Base.ATTR_ID_SUPPLIER_PURCHASE_ORDER_PRODUCT_LINK NAME_ATTR_OPTION_VALUE: ClassVar[str] = Store_Base.ATTR_ID_SUPPLIER_PURCHASE_ORDER_PRODUCT_LINK
NAME_ATTR_OPTION_TEXT: ClassVar[str] = Store_Base.FLAG_NAME NAME_ATTR_OPTION_TEXT: ClassVar[str] = Store_Base.FLAG_NAME
__tablename__ = 'Shop_Supplier_Purchase_Order_Temp' __tablename__ = 'Shop_Supplier_Purchase_Order_Product_Link'
id_link = db.Column(db.Integer, primary_key=True) id_link = db.Column(db.Integer, primary_key=True)
id_order = db.Column(db.Integer) id_order = db.Column(db.Integer)
id_category = db.Column(db.Integer)
id_product = db.Column(db.Integer)
id_permutation = db.Column(db.Integer) id_permutation = db.Column(db.Integer)
id_unit_quantity = db.Column(db.Integer) id_unit_quantity = db.Column(db.Integer)
name_permutation = db.Column(db.String(255)) name_permutation = db.Column(db.String(255))
@@ -108,32 +122,41 @@ class Supplier_Purchase_Order_Product_Link(db.Model, Store_Base):
display_order = db.Column(db.Integer) display_order = db.Column(db.Integer)
cost_total_local_VAT_excl = db.Column(db.Float) cost_total_local_VAT_excl = db.Column(db.Float)
cost_total_local_VAT_incl = db.Column(db.Float) cost_total_local_VAT_incl = db.Column(db.Float)
cost_unit_local_VAT_excl = db.Column(db.Float)
cost_unit_local_VAT_incl = db.Column(db.Float)
active = db.Column(db.Boolean) active = db.Column(db.Boolean)
created_on = db.Column(db.DateTime) created_on = db.Column(db.DateTime)
created_by = db.Column(db.Integer) created_by = db.Column(db.Integer)
def __init__(self): def __init__(self):
super().__init__() super().__init__()
Store_Base.__init__(self) Store_Base.__init__(self)
# self.unit_quantity = None
@classmethod @classmethod
def from_DB_supplier_purchase_order(cls, query_row): def from_DB_supplier_purchase_order(cls, query_row):
link = cls() link = cls()
link.id_link = query_row[0] link.id_link = query_row[0]
link.id_order = query_row[1] link.id_order = query_row[1]
link.id_permutation = query_row[2] link.id_category = query_row[2]
link.name_permutation = query_row[3] link.id_product = query_row[3]
link.id_unit_quantity = query_row[4] link.id_permutation = query_row[4]
link.quantity_ordered = query_row[5] link.name_permutation = query_row[5]
link.quantity_received = query_row[6] link.id_unit_quantity = query_row[6]
link.latency_delivery_days = query_row[7] link.quantity_ordered = query_row[7]
link.display_order = query_row[8] link.quantity_received = query_row[8]
link.cost_total_local_VAT_excl = query_row[9] link.latency_delivery_days = query_row[9]
link.cost_total_local_VAT_incl = query_row[10] link.display_order = query_row[10]
link.active = query_row[11] link.cost_total_local_VAT_excl = query_row[11]
link.cost_total_local_VAT_incl = query_row[12]
link.cost_unit_local_VAT_excl = query_row[13]
link.cost_unit_local_VAT_incl = query_row[14]
link.active = query_row[15]
return link return link
def __repr__(self): def __repr__(self):
return f''' return f'''
{self.ATTR_ID_SUPPLIER_PURCHASE_ORDER_PRODUCT_LINK}: {self.id_link}, {self.ATTR_ID_SUPPLIER_PURCHASE_ORDER_PRODUCT_LINK}: {self.id_link},
{self.ATTR_ID_SUPPLIER_PURCHASE_ORDER}: {self.id_order}, {self.ATTR_ID_SUPPLIER_PURCHASE_ORDER}: {self.id_order},
{self.ATTR_ID_PRODUCT_CATEGORY}: {self.id_category},
{self.ATTR_ID_PRODUCT}: {self.id_product},
{self.ATTR_ID_PRODUCT_PERMUTATION}: {self.id_permutation}, {self.ATTR_ID_PRODUCT_PERMUTATION}: {self.id_permutation},
{self.FLAG_NAME}: {self.name_permutation}, {self.FLAG_NAME}: {self.name_permutation},
{self.ATTR_ID_UNIT_MEASUREMENT_QUANTITY}: {self.id_unit_quantity}, {self.ATTR_ID_UNIT_MEASUREMENT_QUANTITY}: {self.id_unit_quantity},
@@ -143,6 +166,8 @@ class Supplier_Purchase_Order_Product_Link(db.Model, Store_Base):
{self.FLAG_DISPLAY_ORDER}: {self.display_order}, {self.FLAG_DISPLAY_ORDER}: {self.display_order},
{self.FLAG_COST_TOTAL_LOCAL_VAT_EXCL}: {self.cost_total_local_VAT_excl}, {self.FLAG_COST_TOTAL_LOCAL_VAT_EXCL}: {self.cost_total_local_VAT_excl},
{self.FLAG_COST_TOTAL_LOCAL_VAT_INCL}: {self.cost_total_local_VAT_incl}, {self.FLAG_COST_TOTAL_LOCAL_VAT_INCL}: {self.cost_total_local_VAT_incl},
{self.FLAG_COST_UNIT_LOCAL_VAT_EXCL}: {self.cost_unit_local_VAT_excl},
{self.FLAG_COST_UNIT_LOCAL_VAT_INCL}: {self.cost_unit_local_VAT_incl},
{self.FLAG_ACTIVE}: {self.active} {self.FLAG_ACTIVE}: {self.active}
''' '''
def to_json(self): def to_json(self):
@@ -150,6 +175,8 @@ class Supplier_Purchase_Order_Product_Link(db.Model, Store_Base):
**self.get_shared_json_attributes(self), **self.get_shared_json_attributes(self),
self.ATTR_ID_SUPPLIER_PURCHASE_ORDER_PRODUCT_LINK: self.id_link, self.ATTR_ID_SUPPLIER_PURCHASE_ORDER_PRODUCT_LINK: self.id_link,
self.ATTR_ID_SUPPLIER_PURCHASE_ORDER: self.id_order, self.ATTR_ID_SUPPLIER_PURCHASE_ORDER: self.id_order,
self.ATTR_ID_PRODUCT_CATEGORY: self.id_category,
self.ATTR_ID_PRODUCT: self.id_product,
self.ATTR_ID_PRODUCT_PERMUTATION: self.id_permutation, self.ATTR_ID_PRODUCT_PERMUTATION: self.id_permutation,
self.FLAG_NAME: self.name_permutation, self.FLAG_NAME: self.name_permutation,
self.ATTR_ID_UNIT_MEASUREMENT_QUANTITY: self.id_unit_quantity, self.ATTR_ID_UNIT_MEASUREMENT_QUANTITY: self.id_unit_quantity,
@@ -159,6 +186,8 @@ class Supplier_Purchase_Order_Product_Link(db.Model, Store_Base):
self.FLAG_DISPLAY_ORDER: self.display_order, self.FLAG_DISPLAY_ORDER: self.display_order,
self.FLAG_COST_TOTAL_LOCAL_VAT_EXCL: self.cost_total_local_VAT_excl, self.FLAG_COST_TOTAL_LOCAL_VAT_EXCL: self.cost_total_local_VAT_excl,
self.FLAG_COST_TOTAL_LOCAL_VAT_INCL: self.cost_total_local_VAT_incl, self.FLAG_COST_TOTAL_LOCAL_VAT_INCL: self.cost_total_local_VAT_incl,
self.FLAG_COST_UNIT_LOCAL_VAT_EXCL: self.cost_unit_local_VAT_excl,
self.FLAG_COST_UNIT_LOCAL_VAT_INCL: self.cost_unit_local_VAT_incl,
self.FLAG_ACTIVE: av.input_bool(self.active, self.FLAG_ACTIVE, f'{self.__class__.__name__}.to_json'), self.FLAG_ACTIVE: av.input_bool(self.active, self.FLAG_ACTIVE, f'{self.__class__.__name__}.to_json'),
} }
def to_json_option(self): def to_json_option(self):
@@ -172,8 +201,10 @@ class Supplier_Purchase_Order_Product_Link(db.Model, Store_Base):
link = cls() link = cls()
link.id_link = json[cls.ATTR_ID_SUPPLIER_PURCHASE_ORDER_PRODUCT_LINK] link.id_link = json[cls.ATTR_ID_SUPPLIER_PURCHASE_ORDER_PRODUCT_LINK]
link.id_order = json[cls.ATTR_ID_SUPPLIER_PURCHASE_ORDER] link.id_order = json[cls.ATTR_ID_SUPPLIER_PURCHASE_ORDER]
link.id_category = json.get(cls.ATTR_ID_PRODUCT_CATEGORY, None)
link.id_product = json.get(cls.ATTR_ID_PRODUCT, None)
link.id_permutation = json[cls.ATTR_ID_PRODUCT_PERMUTATION] link.id_permutation = json[cls.ATTR_ID_PRODUCT_PERMUTATION]
link.name_permutation = json[cls.FLAG_NAME] link.name_permutation = json.get(cls.FLAG_NAME, None)
link.id_unit_quantity = json[cls.ATTR_ID_UNIT_MEASUREMENT_QUANTITY] link.id_unit_quantity = json[cls.ATTR_ID_UNIT_MEASUREMENT_QUANTITY]
link.quantity_ordered = json[cls.FLAG_QUANTITY_ORDERED] link.quantity_ordered = json[cls.FLAG_QUANTITY_ORDERED]
link.quantity_received = json[cls.FLAG_QUANTITY_RECEIVED] link.quantity_received = json[cls.FLAG_QUANTITY_RECEIVED]
@@ -181,6 +212,8 @@ class Supplier_Purchase_Order_Product_Link(db.Model, Store_Base):
link.display_order = json[cls.FLAG_DISPLAY_ORDER] link.display_order = json[cls.FLAG_DISPLAY_ORDER]
link.cost_total_local_VAT_excl = json[cls.FLAG_COST_TOTAL_LOCAL_VAT_EXCL] link.cost_total_local_VAT_excl = json[cls.FLAG_COST_TOTAL_LOCAL_VAT_EXCL]
link.cost_total_local_VAT_incl = json[cls.FLAG_COST_TOTAL_LOCAL_VAT_INCL] link.cost_total_local_VAT_incl = json[cls.FLAG_COST_TOTAL_LOCAL_VAT_INCL]
link.cost_unit_local_VAT_excl = json.get(cls.FLAG_COST_UNIT_LOCAL_VAT_EXCL, None)
link.cost_unit_local_VAT_incl = json(cls.FLAG_COST_UNIT_LOCAL_VAT_INCL, None)
link.active = json[cls.FLAG_ACTIVE] link.active = json[cls.FLAG_ACTIVE]
return link return link
@@ -213,31 +246,31 @@ class Parameters_Supplier_Purchase_Order(Get_Many_Parameters_Base):
def from_filters_supplier_purchase_order(cls, form): def from_filters_supplier_purchase_order(cls, form):
parameters = cls.get_default() parameters = cls.get_default()
parameters.a_get_inactive_order = form.active.data parameters.a_get_inactive_order = form.active.data
parameters.a_date_from = form.date_from.data parameters.a_date_from = None if form.date_from.data == '' else form.date_from.data
parameters.a_date_to = form.date_to.data parameters.a_date_to = None if form.date_to.data == '' else form.date_to.data
return parameters return parameters
class Supplier_Purchase_Order_Temp(db.Model, Store_Base): class Supplier_Purchase_Order_Temp(db.Model, Store_Base):
__tablename__: ClassVar[str] = 'Shop_Supplier_Purchase_Order_Temp' __tablename__: ClassVar[str] = 'Shop_Supplier_Purchase_Order_Temp'
__table_args__ = { 'extend_existing': True } __table_args__ = { 'extend_existing': True }
id_order: int = db.Column(db.Integer, primary_key=True) id_order: int = db.Column(db.Integer, primary_key=True)
id_supplier: int = db.Column(db.Integer) id_supplier_ordered: int = db.Column(db.Integer)
id_currency: int = db.Column(db.Integer) id_currency_cost: int = db.Column(db.Integer)
active: bool = db.Column(db.Boolean) active: bool = db.Column(db.Boolean)
guid: str = db.Column(db.String(36)) guid: str = db.Column(db.String(36))
@classmethod @classmethod
def from_supplier_purchase_order(cls, supplier_purchase_order): def from_supplier_purchase_order(cls, supplier_purchase_order):
row = cls() row = cls()
row.id_order = supplier_purchase_order.id_order row.id_order = supplier_purchase_order.id_order
row.id_supplier = supplier_purchase_order.id_supplier row.id_supplier_ordered = supplier_purchase_order.id_supplier
row.id_currency = supplier_purchase_order.id_currency row.id_currency_cost = supplier_purchase_order.id_currency
row.active = 1 if supplier_purchase_order.active else 0 row.active = 1 if supplier_purchase_order.active else 0
return row return row
def __repr__(self): def __repr__(self):
return f''' return f'''
id_order: {self.id_order} id_order: {self.id_order}
id_supplier: {self.id_supplier} id_supplier_ordered: {self.id_supplier_ordered}
id_currency: {self.id_currency} id_currency_cost: {self.id_currency_cost}
active: {self.active} active: {self.active}
guid: {self.guid} guid: {self.guid}
''' '''
@@ -245,23 +278,25 @@ guid: {self.guid}
class Supplier_Purchase_Order_Product_Link_Temp(db.Model, Store_Base): class Supplier_Purchase_Order_Product_Link_Temp(db.Model, Store_Base):
__tablename__: ClassVar[str] = 'Shop_Supplier_Purchase_Order_Product_Link_Temp' __tablename__: ClassVar[str] = 'Shop_Supplier_Purchase_Order_Product_Link_Temp'
__table_args__ = { 'extend_existing': True } __table_args__ = { 'extend_existing': True }
id_link: int = db.Column(db.Integer, primary_key=True) id_link = db.Column(db.Integer, primary_key=True)
id_order: int = db.Column(db.Integer) id_order = db.Column(db.Integer)
id_permutation: int = db.Column(db.Integer) id_product = db.Column(db.Integer)
id_unit_quantity: int = db.Column(db.Integer) id_permutation = db.Column(db.Integer)
quantity_ordered: float = db.Column(db.Float) id_unit_quantity = db.Column(db.Integer)
quantity_received: float = db.Column(db.Float) quantity_ordered = db.Column(db.Float)
latency_delivery_days: int = db.Column(db.Integer) quantity_received = db.Column(db.Float)
display_order: int = db.Column(db.Integer) latency_delivery_days = db.Column(db.Integer)
cost_total_local_VAT_excl: float = db.Column(db.Float) display_order = db.Column(db.Integer)
cost_total_local_VAT_incl: float = db.Column(db.Float) cost_total_local_VAT_excl = db.Column(db.Float)
active: bool = db.Column(db.Boolean) cost_total_local_VAT_incl = db.Column(db.Float)
guid: str = db.Column(db.String(36)) active = db.Column(db.Boolean)
guid = db.Column(db.String(36))
@classmethod @classmethod
def from_supplier_purchase_order_product_link(cls, supplier_purchase_order_product_link): def from_supplier_purchase_order_product_link(cls, supplier_purchase_order_product_link):
row = cls() row = cls()
row.id_link = supplier_purchase_order_product_link.id_link row.id_link = supplier_purchase_order_product_link.id_link
row.id_order = supplier_purchase_order_product_link.id_order row.id_order = supplier_purchase_order_product_link.id_order
row.id_product = supplier_purchase_order_product_link.id_product
row.id_permutation = supplier_purchase_order_product_link.id_permutation row.id_permutation = supplier_purchase_order_product_link.id_permutation
row.id_unit_quantity = supplier_purchase_order_product_link.id_unit_quantity row.id_unit_quantity = supplier_purchase_order_product_link.id_unit_quantity
row.quantity_ordered = supplier_purchase_order_product_link.quantity_ordered row.quantity_ordered = supplier_purchase_order_product_link.quantity_ordered
@@ -276,6 +311,7 @@ class Supplier_Purchase_Order_Product_Link_Temp(db.Model, Store_Base):
return f''' return f'''
id_link: {self.id_link} id_link: {self.id_link}
id_order: {self.id_order} id_order: {self.id_order}
id_product: {self.id_product}
id_permutation: {self.id_permutation} id_permutation: {self.id_permutation}
id_unit_quantity: {self.id_unit_quantity} id_unit_quantity: {self.id_unit_quantity}
quantity_ordered: {self.quantity_ordered} quantity_ordered: {self.quantity_ordered}

View File

@@ -93,18 +93,18 @@ def save_supplier_purchase_order():
for supplier_purchase_order in supplier_purchase_orders: for supplier_purchase_order in supplier_purchase_orders:
objs_supplier_purchase_order.append(Supplier_Purchase_Order.from_json(supplier_purchase_order)) objs_supplier_purchase_order.append(Supplier_Purchase_Order.from_json(supplier_purchase_order))
print(f'objs_supplier_purchase_order={objs_supplier_purchase_order}') print(f'objs_supplier_purchase_order={objs_supplier_purchase_order}')
save_errors = Model_View_Store_Supplier_Purchase_Order.save_supplier_purchase_orders(data.get('comment', 'No comment'), objs_supplier_purchase_order) save_errors, save_warnings = Model_View_Store_Supplier_Purchase_Order.save_supplier_purchase_orders(data.get('comment', 'No comment'), objs_supplier_purchase_order)
if len(save_errors) > 0: if len(save_errors) > 0:
return jsonify({ return jsonify({
Model_View_Store_Supplier_Purchase_Order.FLAG_STATUS: Model_View_Store_Supplier_Purchase_Order.FLAG_FAILURE, Model_View_Store_Supplier_Purchase_Order.FLAG_STATUS: Model_View_Store_Supplier_Purchase_Order.FLAG_FAILURE,
Model_View_Store_Supplier_Purchase_Order.FLAG_MESSAGE: f'Save errors: {save_errors}' Model_View_Store_Supplier_Purchase_Order.FLAG_MESSAGE: f'Save errors: {save_errors}'
}) })
model_return = Model_View_Store_Supplier_Purchase_Order(filters_supplier_purchase_order_old = form_filters) model_return = Model_View_Store_Supplier_Purchase_Order(form_filters_old = form_filters)
if not model_return.is_user_logged_in: if not model_return.is_user_logged_in:
raise Exception('User not logged in.') raise Exception('User not logged in.')
return jsonify({ return jsonify({
Model_View_Store_Supplier_Purchase_Order.FLAG_STATUS: Model_View_Store_Supplier_Purchase_Order.FLAG_SUCCESS, Model_View_Store_Supplier_Purchase_Order.FLAG_STATUS: Model_View_Store_Supplier_Purchase_Order.FLAG_SUCCESS,
Model_View_Store_Supplier_Purchase_Order.FLAG_DATA: model_return.category_list.to_json() Model_View_Store_Supplier_Purchase_Order.FLAG_DATA: model_return.convert_list_objects_to_json(model_return.supplier_purchase_orders)
}) })
except Exception as e: except Exception as e:
return jsonify({ return jsonify({

View File

@@ -55,17 +55,21 @@ class DataStore_Store_Manufacturing_Purchase_Order(DataStore_Store_Base):
result_set_1 = cursor.fetchall() result_set_1 = cursor.fetchall()
print(f'raw manufacturing_purchase_orders: {result_set_1}') print(f'raw manufacturing_purchase_orders: {result_set_1}')
manufacturing_purchase_orders = [] manufacturing_purchase_orders = []
indices_manufacturing_purchase_order = {}
for row in result_set_1: for row in result_set_1:
new_manufacturing_purchase_order = Manufacturing_Purchase_Order.from_DB_manufacturing_purchase_order(row) new_manufacturing_purchase_order = Manufacturing_Purchase_Order.from_DB_manufacturing_purchase_order(row)
indices_manufacturing_purchase_order[new_manufacturing_purchase_order.id_order] = len(manufacturing_purchase_orders)
manufacturing_purchase_orders.append(new_manufacturing_purchase_order) manufacturing_purchase_orders.append(new_manufacturing_purchase_order)
# Manufacturing_Purchase_Orders Items # Manufacturing_Purchase_Orders Items
cursor.nextset()
result_set_1 = cursor.fetchall() result_set_1 = cursor.fetchall()
print(f'raw manufacturing_purchase_order_product_links: {result_set_1}') print(f'raw manufacturing_purchase_order_product_links: {result_set_1}')
order_product_links = [] order_product_links = []
for row in result_set_1: for row in result_set_1:
new_link = Manufacturing_Purchase_Order_Product_Link.from_DB_manufacturing_purchase_order(row) new_link = Manufacturing_Purchase_Order_Product_Link.from_DB_manufacturing_purchase_order(row)
manufacturing_purchase_orders.append(new_manufacturing_purchase_order) order_product_links.append(new_link)
manufacturing_purchase_orders[indices_manufacturing_purchase_order[new_link.id_order]].items.append(new_link)
# Errors # Errors
cursor.nextset() cursor.nextset()

View File

@@ -66,7 +66,7 @@ class DataStore_Store_Product_Permutation(DataStore_Store_Base):
cost_local, cost_local,
id_currency_cost, id_currency_cost,
profit_local_min, profit_local_min,
latency_manufacture_days, latency_manufacture,
id_unit_measurement_quantity, id_unit_measurement_quantity,
count_unit_measurement_quantity, count_unit_measurement_quantity,
quantity_min, quantity_min,

View File

@@ -36,11 +36,12 @@ class DataStore_Store_Supplier(DataStore_Store_Base):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
def get_many_supplier(self, parameters_supplier): @classmethod
def get_many_supplier(cls, parameters_supplier):
_m = 'DataStore_Store_Supplier.get_many_supplier' _m = 'DataStore_Store_Supplier.get_many_supplier'
av.val_instance(parameters_supplier, 'parameters_supplier', _m, Parameters_Supplier) av.val_instance(parameters_supplier, 'parameters_supplier', _m, Parameters_Supplier)
argument_dict = parameters_supplier.to_json() argument_dict = parameters_supplier.to_json()
user = self.get_user_session() user = cls.get_user_session()
argument_dict = { argument_dict = {
'a_id_user': user.id_user 'a_id_user': user.id_user
, **argument_dict , **argument_dict
@@ -48,7 +49,7 @@ class DataStore_Store_Supplier(DataStore_Store_Base):
} }
print(f'argument_dict: {argument_dict}') print(f'argument_dict: {argument_dict}')
print('executing p_shop_get_many_supplier') print('executing p_shop_get_many_supplier')
result = self.db_procedure_execute('p_shop_get_many_supplier', argument_dict) result = cls.db_procedure_execute('p_shop_get_many_supplier', argument_dict)
cursor = result.cursor cursor = result.cursor
print('data received') print('data received')

View File

@@ -55,9 +55,22 @@ class DataStore_Store_Supplier_Purchase_Order(DataStore_Store_Base):
result_set_1 = cursor.fetchall() result_set_1 = cursor.fetchall()
print(f'raw supplier_purchase_orders: {result_set_1}') print(f'raw supplier_purchase_orders: {result_set_1}')
supplier_purchase_orders = [] supplier_purchase_orders = []
indices_supplier_purchase_order = {}
for row in result_set_1: for row in result_set_1:
new_supplier_purchase_order = Supplier_Purchase_Order.from_DB_supplier_purchase_order(row) new_supplier_purchase_order = Supplier_Purchase_Order.from_DB_supplier_purchase_order(row)
supplier_purchase_orders.append(new_supplier_purchase_order) # , row) indices_supplier_purchase_order[new_supplier_purchase_order.id_order] = len(supplier_purchase_orders)
supplier_purchase_orders.append(new_supplier_purchase_order)
# Supplier_Purchase_Orders Items
cursor.nextset()
result_set_2 = cursor.fetchall()
print(f'raw supplier_purchase_order_product_links: {result_set_2}')
order_product_links = []
for row in result_set_2:
new_link = Supplier_Purchase_Order_Product_Link.from_DB_supplier_purchase_order(row)
order_product_links.append(new_link)
supplier_purchase_orders[indices_supplier_purchase_order[new_link.id_order]].items.append(new_link)
# Errors # Errors
cursor.nextset() cursor.nextset()

View File

@@ -29,7 +29,7 @@ from business_objects.user import User, User_Filters
# external # external
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from flask_sqlalchemy import SQLAlchemy from flask_sqlalchemy import SQLAlchemy
from flask import Flask, session, current_app from flask import Flask, session, current_app, jsonify
from pydantic import BaseModel, ConfigDict from pydantic import BaseModel, ConfigDict
from typing import ClassVar from typing import ClassVar
@@ -357,6 +357,16 @@ class Model_View_Base(BaseModel, ABC):
def convert_dict_values_to_json(dict): def convert_dict_values_to_json(dict):
return {key: dict[key].to_json() for key in dict.keys()} return {key: dict[key].to_json() for key in dict.keys()}
@staticmethod @staticmethod
def convert_list_objects_to_preview_str(list_objects):
preview_str = ''
for obj in list_objects:
if preview_str != '':
preview_str += '\n'
obj_json = obj.to_json()
print(f'obj_json: {obj_json}')
preview_str += obj_json[obj_json[Base.FLAG_NAME_ATTR_OPTION_TEXT]]
return preview_str
@staticmethod
def join_with_linebreaks(strs): def join_with_linebreaks(strs):
str_multiline = '' str_multiline = ''
for str in strs: for str in strs:
@@ -374,3 +384,6 @@ class Model_View_Base(BaseModel, ABC):
if date_time is None: if date_time is None:
return '' return ''
return date_time.strftime('%Y-%m-%dT%H:%M') return date_time.strftime('%Y-%m-%dT%H:%M')
@staticmethod
def jsonify(data):
return jsonify(data)

View File

@@ -48,6 +48,7 @@ class Model_View_Store(Model_View_Base):
ATTR_ID_DELIVERY_OPTION: ClassVar[str] = Store_Base.ATTR_ID_DELIVERY_OPTION ATTR_ID_DELIVERY_OPTION: ClassVar[str] = Store_Base.ATTR_ID_DELIVERY_OPTION
ATTR_ID_DISCOUNT: ClassVar[str] = Store_Base.ATTR_ID_DISCOUNT ATTR_ID_DISCOUNT: ClassVar[str] = Store_Base.ATTR_ID_DISCOUNT
ATTR_ID_MANUFACTURING_PURCHASE_ORDER: ClassVar[str] = Store_Base.ATTR_ID_MANUFACTURING_PURCHASE_ORDER ATTR_ID_MANUFACTURING_PURCHASE_ORDER: ClassVar[str] = Store_Base.ATTR_ID_MANUFACTURING_PURCHASE_ORDER
ATTR_ID_MANUFACTURING_PURCHASE_ORDER_PRODUCT_LINK: ClassVar[str] = Store_Base.ATTR_ID_MANUFACTURING_PURCHASE_ORDER_PRODUCT_LINK
ATTR_ID_PLANT: ClassVar[str] = 'id-plant' ATTR_ID_PLANT: ClassVar[str] = 'id-plant'
ATTR_ID_PRODUCT : ClassVar[str] = Product.ATTR_ID_PRODUCT # 'id-product' ATTR_ID_PRODUCT : ClassVar[str] = Product.ATTR_ID_PRODUCT # 'id-product'
ATTR_ID_PRODUCT_CATEGORY: ClassVar[str] = Product.ATTR_ID_PRODUCT_CATEGORY ATTR_ID_PRODUCT_CATEGORY: ClassVar[str] = Product.ATTR_ID_PRODUCT_CATEGORY
@@ -60,6 +61,9 @@ class Model_View_Store(Model_View_Base):
ATTR_ID_SUPPLIER: ClassVar[str] = Store_Base.ATTR_ID_SUPPLIER ATTR_ID_SUPPLIER: ClassVar[str] = Store_Base.ATTR_ID_SUPPLIER
ATTR_ID_SUPPLIER_ADDRESS: ClassVar[str] = Store_Base.ATTR_ID_SUPPLIER_ADDRESS ATTR_ID_SUPPLIER_ADDRESS: ClassVar[str] = Store_Base.ATTR_ID_SUPPLIER_ADDRESS
ATTR_ID_SUPPLIER_PURCHASE_ORDER: ClassVar[str] = Store_Base.ATTR_ID_SUPPLIER_PURCHASE_ORDER ATTR_ID_SUPPLIER_PURCHASE_ORDER: ClassVar[str] = Store_Base.ATTR_ID_SUPPLIER_PURCHASE_ORDER
ATTR_ID_SUPPLIER_PURCHASE_ORDER_PRODUCT_LINK: ClassVar[str] = Store_Base.ATTR_ID_SUPPLIER_PURCHASE_ORDER_PRODUCT_LINK
ATTR_ID_UNIT_MEASUREMENT_LATENCY_MANUFACTURE: ClassVar[str] = Product_Permutation.ATTR_ID_UNIT_MEASUREMENT_LATENCY_MANUFACTURE
ATTR_ID_UNIT_MEASUREMENT_QUANTITY: ClassVar[str] = Product_Permutation.ATTR_ID_UNIT_MEASUREMENT_QUANTITY
FLAG_BUTTON_BASKET_ADD : ClassVar[str] = Model_View_Base.FLAG_SUBMIT + '.buttonAddToBasket' FLAG_BUTTON_BASKET_ADD : ClassVar[str] = Model_View_Base.FLAG_SUBMIT + '.buttonAddToBasket'
FLAG_BUTTON_BUY_NOW : ClassVar[str] = 'buttonBuyNow' FLAG_BUTTON_BUY_NOW : ClassVar[str] = 'buttonBuyNow'
""" """
@@ -92,7 +96,8 @@ class Model_View_Store(Model_View_Base):
FLAG_IS_OUT_OF_STOCK: ClassVar[str] = Store_Base.FLAG_IS_OUT_OF_STOCK FLAG_IS_OUT_OF_STOCK: ClassVar[str] = Store_Base.FLAG_IS_OUT_OF_STOCK
FLAG_IS_SEALED: ClassVar[str] = Stock_Item.FLAG_IS_SEALED FLAG_IS_SEALED: ClassVar[str] = Stock_Item.FLAG_IS_SEALED
FLAG_IS_SUBSCRIPTION: ClassVar[str] = Product_Permutation.FLAG_IS_SUBSCRIPTION FLAG_IS_SUBSCRIPTION: ClassVar[str] = Product_Permutation.FLAG_IS_SUBSCRIPTION
FLAG_LATENCY_MANUFACTURE_DAYS: ClassVar[str] = Product_Permutation.FLAG_LATENCY_MANUFACTURE_DAYS FLAG_LATENCY_DELIVERY_DAYS: ClassVar[str] = Store_Base.FLAG_LATENCY_DELIVERY_DAYS
FLAG_LATENCY_MANUFACTURE: ClassVar[str] = Product_Permutation.FLAG_LATENCY_MANUFACTURE
FLAG_MANUFACTURING_PURCHASE_ORDER: ClassVar[str] = Store_Base.FLAG_MANUFACTURING_PURCHASE_ORDER FLAG_MANUFACTURING_PURCHASE_ORDER: ClassVar[str] = Store_Base.FLAG_MANUFACTURING_PURCHASE_ORDER
FLAG_NAME_PLURAL_UNIT_MEASUREMENT_INTERVAL_EXPIRATION_UNSEALED: ClassVar[str] = Product_Permutation.FLAG_NAME_PLURAL_UNIT_MEASUREMENT_INTERVAL_EXPIRATION_UNSEALED FLAG_NAME_PLURAL_UNIT_MEASUREMENT_INTERVAL_EXPIRATION_UNSEALED: ClassVar[str] = Product_Permutation.FLAG_NAME_PLURAL_UNIT_MEASUREMENT_INTERVAL_EXPIRATION_UNSEALED
FLAG_NAME_PLURAL_UNIT_MEASUREMENT_INTERVAL_RECURRENCE: ClassVar[str] = Product_Permutation.FLAG_NAME_PLURAL_UNIT_MEASUREMENT_INTERVAL_RECURRENCE FLAG_NAME_PLURAL_UNIT_MEASUREMENT_INTERVAL_RECURRENCE: ClassVar[str] = Product_Permutation.FLAG_NAME_PLURAL_UNIT_MEASUREMENT_INTERVAL_RECURRENCE
@@ -100,6 +105,7 @@ class Model_View_Store(Model_View_Base):
FLAG_NAME_SINGULAR_UNIT_MEASUREMENT_INTERVAL_EXPIRATION_UNSEALED: ClassVar[str] = Product_Permutation.FLAG_NAME_SINGULAR_UNIT_MEASUREMENT_INTERVAL_EXPIRATION_UNSEALED FLAG_NAME_SINGULAR_UNIT_MEASUREMENT_INTERVAL_EXPIRATION_UNSEALED: ClassVar[str] = Product_Permutation.FLAG_NAME_SINGULAR_UNIT_MEASUREMENT_INTERVAL_EXPIRATION_UNSEALED
FLAG_NAME_SINGULAR_UNIT_MEASUREMENT_INTERVAL_RECURRENCE: ClassVar[str] = Product_Permutation.FLAG_NAME_SINGULAR_UNIT_MEASUREMENT_INTERVAL_RECURRENCE FLAG_NAME_SINGULAR_UNIT_MEASUREMENT_INTERVAL_RECURRENCE: ClassVar[str] = Product_Permutation.FLAG_NAME_SINGULAR_UNIT_MEASUREMENT_INTERVAL_RECURRENCE
FLAG_NAME_SINGULAR_UNIT_MEASUREMENT_QUANTITY: ClassVar[str] = Product_Permutation.FLAG_NAME_SINGULAR_UNIT_MEASUREMENT_QUANTITY FLAG_NAME_SINGULAR_UNIT_MEASUREMENT_QUANTITY: ClassVar[str] = Product_Permutation.FLAG_NAME_SINGULAR_UNIT_MEASUREMENT_QUANTITY
FLAG_ORDER_ITEMS: ClassVar[str] = Store_Base.FLAG_ORDER_ITEMS
FLAG_PLANT: ClassVar[str] = Store_Base.FLAG_PLANT FLAG_PLANT: ClassVar[str] = Store_Base.FLAG_PLANT
FLAG_PRICE_TOTAL_LOCAL_VAT_EXCL: ClassVar[str] = Store_Base.FLAG_PRICE_TOTAL_LOCAL_VAT_EXCL FLAG_PRICE_TOTAL_LOCAL_VAT_EXCL: ClassVar[str] = Store_Base.FLAG_PRICE_TOTAL_LOCAL_VAT_EXCL
FLAG_PRICE_TOTAL_LOCAL_VAT_INCL: ClassVar[str] = Store_Base.FLAG_PRICE_TOTAL_LOCAL_VAT_INCL FLAG_PRICE_TOTAL_LOCAL_VAT_INCL: ClassVar[str] = Store_Base.FLAG_PRICE_TOTAL_LOCAL_VAT_INCL
@@ -116,6 +122,8 @@ class Model_View_Store(Model_View_Base):
FLAG_QUANTITY: ClassVar[str] = 'quantity' FLAG_QUANTITY: ClassVar[str] = 'quantity'
FLAG_QUANTITY_MAX: ClassVar[str] = Product_Permutation.FLAG_QUANTITY_MAX # 'quantity-max' FLAG_QUANTITY_MAX: ClassVar[str] = Product_Permutation.FLAG_QUANTITY_MAX # 'quantity-max'
FLAG_QUANTITY_MIN: ClassVar[str] = Product_Permutation.FLAG_QUANTITY_MIN # 'quantity-min' FLAG_QUANTITY_MIN: ClassVar[str] = Product_Permutation.FLAG_QUANTITY_MIN # 'quantity-min'
FLAG_QUANTITY_ORDERED: ClassVar[str] = Store_Base.FLAG_QUANTITY_ORDERED
FLAG_QUANTITY_RECEIVED: ClassVar[str] = Store_Base.FLAG_QUANTITY_RECEIVED
FLAG_QUANTITY_STOCK: ClassVar[str] = Product_Permutation.FLAG_QUANTITY_STOCK # 'quantity-stock' FLAG_QUANTITY_STOCK: ClassVar[str] = Product_Permutation.FLAG_QUANTITY_STOCK # 'quantity-stock'
FLAG_REGION: ClassVar[str] = Store_Base.FLAG_REGION FLAG_REGION: ClassVar[str] = Store_Base.FLAG_REGION
FLAG_STOCK_ITEM: ClassVar[str] = Store_Base.FLAG_STOCK_ITEM FLAG_STOCK_ITEM: ClassVar[str] = Store_Base.FLAG_STOCK_ITEM
@@ -132,6 +140,7 @@ class Model_View_Store(Model_View_Base):
FLAG_SYMBOL_UNIT_MEASUREMENT_QUANTITY: ClassVar[str] = Product_Permutation.FLAG_SYMBOL_UNIT_MEASUREMENT_QUANTITY FLAG_SYMBOL_UNIT_MEASUREMENT_QUANTITY: ClassVar[str] = Product_Permutation.FLAG_SYMBOL_UNIT_MEASUREMENT_QUANTITY
FLAG_UNIT_MEASUREMENT_INTERVAL_EXPIRATION_UNSEALED: ClassVar[str] = Product_Permutation.FLAG_UNIT_MEASUREMENT_INTERVAL_EXPIRATION_UNSEALED FLAG_UNIT_MEASUREMENT_INTERVAL_EXPIRATION_UNSEALED: ClassVar[str] = Product_Permutation.FLAG_UNIT_MEASUREMENT_INTERVAL_EXPIRATION_UNSEALED
FLAG_UNIT_MEASUREMENT_INTERVAL_RECURRENCE: ClassVar[str] = Product_Permutation.FLAG_UNIT_MEASUREMENT_INTERVAL_RECURRENCE FLAG_UNIT_MEASUREMENT_INTERVAL_RECURRENCE: ClassVar[str] = Product_Permutation.FLAG_UNIT_MEASUREMENT_INTERVAL_RECURRENCE
FLAG_UNIT_MEASUREMENT_LATENCY_MANUFACTURE: ClassVar[str] = Store_Base.FLAG_UNIT_MEASUREMENT_LATENCY_MANUFACTURE
FLAG_UNIT_MEASUREMENT_QUANTITY: ClassVar[str] = Product_Permutation.FLAG_UNIT_MEASUREMENT_QUANTITY FLAG_UNIT_MEASUREMENT_QUANTITY: ClassVar[str] = Product_Permutation.FLAG_UNIT_MEASUREMENT_QUANTITY
HASH_GET_STORE_CUSTOMER_SALES_ORDER: ClassVar[str] = '/store/customer_sales_order_get' HASH_GET_STORE_CUSTOMER_SALES_ORDER: ClassVar[str] = '/store/customer_sales_order_get'
HASH_GET_STORE_MANUFACTURING_PURCHASE_ORDER: ClassVar[str] = '/store/manufacturing_purchase_order_get' HASH_GET_STORE_MANUFACTURING_PURCHASE_ORDER: ClassVar[str] = '/store/manufacturing_purchase_order_get'

View File

@@ -13,11 +13,18 @@ Data model for manufacturing purchase order view page
# internal # internal
from models.model_view_store import Model_View_Store from models.model_view_store import Model_View_Store
from datastores.datastore_store_manufacturing_purchase_order import DataStore_Store_Manufacturing_Purchase_Order from datastores.datastore_store_manufacturing_purchase_order import DataStore_Store_Manufacturing_Purchase_Order
from business_objects.store.manufacturing_purchase_order import Manufacturing_Purchase_Order, Parameters_Manufacturing_Purchase_Order from business_objects.store.product import Product, Parameters_Product
from business_objects.store.product_category import Product_Category_Container
from business_objects.store.manufacturing_purchase_order import Manufacturing_Purchase_Order, Parameters_Manufacturing_Purchase_Order, Manufacturing_Purchase_Order_Product_Link
from forms.store.manufacturing_purchase_order import Filters_Manufacturing_Purchase_Order from forms.store.manufacturing_purchase_order import Filters_Manufacturing_Purchase_Order
import lib.argument_validation as av import lib.argument_validation as av
# external
from typing import ClassVar
class Model_View_Store_Manufacturing_Purchase_Order(Model_View_Store): class Model_View_Store_Manufacturing_Purchase_Order(Model_View_Store):
FLAG_QUANTITY_PRODUCED: ClassVar[str] = Manufacturing_Purchase_Order_Product_Link.FLAG_QUANTITY_PRODUCED
FLAG_QUANTITY_USED: ClassVar[str] = Manufacturing_Purchase_Order_Product_Link.FLAG_QUANTITY_USED
category_list_filters: Product_Category_Container = None
currencies: list = None currencies: list = None
currency_options: list = None currency_options: list = None
form_filters: Filters_Manufacturing_Purchase_Order = None form_filters: Filters_Manufacturing_Purchase_Order = None
@@ -25,6 +32,8 @@ class Model_View_Store_Manufacturing_Purchase_Order(Model_View_Store):
manufacturing_purchase_orders: list = None manufacturing_purchase_orders: list = None
units_measurement: list = None units_measurement: list = None
units_measurement_time: list = None units_measurement_time: list = None
variation_types: list = None
variations: list = None
@property @property
def title(self): def title(self):
@@ -38,6 +47,8 @@ class Model_View_Store_Manufacturing_Purchase_Order(Model_View_Store):
parameters_manufacturing_purchase_order = Parameters_Manufacturing_Purchase_Order.from_filters_manufacturing_purchase_order(form_filters_old) parameters_manufacturing_purchase_order = Parameters_Manufacturing_Purchase_Order.from_filters_manufacturing_purchase_order(form_filters_old)
datastore_manufacturing_purchase_order = DataStore_Store_Manufacturing_Purchase_Order() datastore_manufacturing_purchase_order = DataStore_Store_Manufacturing_Purchase_Order()
self.manufacturing_purchase_orders, errors = datastore_manufacturing_purchase_order.get_many_manufacturing_purchase_order(parameters_manufacturing_purchase_order) self.manufacturing_purchase_orders, errors = datastore_manufacturing_purchase_order.get_many_manufacturing_purchase_order(parameters_manufacturing_purchase_order)
self.category_list_filters, errors = DataStore_Store_Manufacturing_Purchase_Order.get_many_product(Parameters_Product.get_default())
self.variation_types, self.variations, errors = self.get_many_product_variation()
self.units_measurement = self.get_many_unit_measurement() 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.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.currencies = self.get_many_currency()

View File

@@ -12,19 +12,27 @@ Data model for supplier purchase order view page
# internal # internal
from models.model_view_store import Model_View_Store from models.model_view_store import Model_View_Store
from datastores.datastore_store_supplier import DataStore_Store_Supplier
from datastores.datastore_store_supplier_purchase_order import DataStore_Store_Supplier_Purchase_Order from datastores.datastore_store_supplier_purchase_order import DataStore_Store_Supplier_Purchase_Order
from business_objects.store.product import Product, Parameters_Product
from business_objects.store.product_category import Product_Category_Container
from business_objects.store.supplier import Supplier, Parameters_Supplier
from business_objects.store.supplier_purchase_order import Supplier_Purchase_Order, Parameters_Supplier_Purchase_Order from business_objects.store.supplier_purchase_order import Supplier_Purchase_Order, Parameters_Supplier_Purchase_Order
from forms.store.supplier_purchase_order import Filters_Supplier_Purchase_Order from forms.store.supplier_purchase_order import Filters_Supplier_Purchase_Order
import lib.argument_validation as av import lib.argument_validation as av
class Model_View_Store_Supplier_Purchase_Order(Model_View_Store): class Model_View_Store_Supplier_Purchase_Order(Model_View_Store):
category_list_filters: Product_Category_Container = None
currencies: list = None currencies: list = None
currency_options: list = None currency_options: list = None
form_filters: Filters_Supplier_Purchase_Order = None form_filters: Filters_Supplier_Purchase_Order = None
form_filters_old: Filters_Supplier_Purchase_Order form_filters_old: Filters_Supplier_Purchase_Order
supplier_purchase_orders: list = None supplier_purchase_orders: list = None
suppliers: list = None
units_measurement: list = None units_measurement: list = None
units_measurement_time: list = None units_measurement_time: list = None
variation_types: list = None
variations: list = None
@property @property
def title(self): def title(self):
@@ -39,6 +47,9 @@ class Model_View_Store_Supplier_Purchase_Order(Model_View_Store):
datastore_supplier_purchase_order = DataStore_Store_Supplier_Purchase_Order() datastore_supplier_purchase_order = DataStore_Store_Supplier_Purchase_Order()
self.supplier_purchase_orders, errors = datastore_supplier_purchase_order.get_many_supplier_purchase_order(parameters_supplier_purchase_order) self.supplier_purchase_orders, errors = datastore_supplier_purchase_order.get_many_supplier_purchase_order(parameters_supplier_purchase_order)
self.suppliers, errors = DataStore_Store_Supplier.get_many_supplier(Parameters_Supplier.get_default())
self.category_list_filters, errors = DataStore_Store_Supplier_Purchase_Order.get_many_product(Parameters_Product.get_default())
self.variation_types, self.variations, errors = self.get_many_product_variation()
self.units_measurement = self.get_many_unit_measurement() 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.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.currencies = self.get_many_currency()

File diff suppressed because it is too large Load Diff

View File

@@ -43,6 +43,7 @@ DROP TABLE IF EXISTS tmp_Shop_Supplier_Purchase_Order;
DROP TABLE IF EXISTS tmp_Supplier_Purchase_Order; DROP TABLE IF EXISTS tmp_Supplier_Purchase_Order;
DROP TABLE IF EXISTS tmp_Shop_Supplier; DROP TABLE IF EXISTS tmp_Shop_Supplier;
DROP TABLE IF EXISTS tmp_Supplier; DROP TABLE IF EXISTS tmp_Supplier;
DROP TABLE IF EXISTS tmp_Supplier_Address;
DROP TABLE IF EXISTS tmp_Shop_Manufacturing_Purchase_Order_Product_Link; DROP TABLE IF EXISTS tmp_Shop_Manufacturing_Purchase_Order_Product_Link;
DROP TABLE IF EXISTS tmp_Manufacturing_Purchase_Order_Product_Link; DROP TABLE IF EXISTS tmp_Manufacturing_Purchase_Order_Product_Link;
DROP TABLE IF EXISTS tmp_Shop_Manufacturing_Purchase_Order; DROP TABLE IF EXISTS tmp_Shop_Manufacturing_Purchase_Order;
@@ -305,6 +306,7 @@ DROP PROCEDURE IF EXISTS p_get_many_user;
DROP PROCEDURE IF EXISTS p_shop_get_many_user_basket; DROP PROCEDURE IF EXISTS p_shop_get_many_user_basket;
DROP PROCEDURE IF EXISTS p_shop_edit_user_basket; DROP PROCEDURE IF EXISTS p_shop_edit_user_basket;
DROP PROCEDURE IF EXISTS p_shop_save_supplier; DROP PROCEDURE IF EXISTS p_shop_save_supplier;
DROP PROCEDURE IF EXISTS p_shop_save_supplier_test;
DROP PROCEDURE IF EXISTS p_shop_get_many_supplier; DROP PROCEDURE IF EXISTS p_shop_get_many_supplier;
DROP PROCEDURE IF EXISTS p_shop_save_supplier_purchase_order; DROP PROCEDURE IF EXISTS p_shop_save_supplier_purchase_order;
DROP PROCEDURE IF EXISTS p_shop_get_many_supplier_purchase_order; DROP PROCEDURE IF EXISTS p_shop_get_many_supplier_purchase_order;

View File

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

View File

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

View File

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

View File

@@ -25,5 +25,5 @@ CREATE TABLE Shop_Supplier_Address (
, id_change_set INT , id_change_set INT
, CONSTRAINT FK_Shop_Supplier_Address_id_change_set , CONSTRAINT FK_Shop_Supplier_Address_id_change_set
FOREIGN KEY (id_change_set) FOREIGN KEY (id_change_set)
REFERENCES partsltd_prod.Shop_User_Change_Set(id_change_set) REFERENCES partsltd_prod.Shop_Sales_And_Purchasing_Change_Set(id_change_set)
); );

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -71,9 +71,13 @@ BEGIN
SELECT NEW.id_order, 'price_unit_local_VAT_incl', OLD.price_unit_local_VAT_incl, NEW.price_unit_local_VAT_incl, NEW.id_change_set SELECT NEW.id_order, 'price_unit_local_VAT_incl', OLD.price_unit_local_VAT_incl, NEW.price_unit_local_VAT_incl, NEW.id_change_set
WHERE NOT OLD.price_unit_local_VAT_incl <=> NEW.price_unit_local_VAT_incl WHERE NOT OLD.price_unit_local_VAT_incl <=> NEW.price_unit_local_VAT_incl
UNION UNION
# Changed latency_manufacture_days # Changed id_unit_latency_manufacture
SELECT NEW.id_link, 'latency_manufacture_days', OLD.latency_manufacture_days, NEW.latency_manufacture_days, NEW.id_change_set SELECT NEW.id_link, 'id_unit_latency_manufacture', OLD.id_unit_latency_manufacture, NEW.id_unit_latency_manufacture, NEW.id_change_set
WHERE NOT OLD.latency_manufacture_days <=> NEW.latency_manufacture_days WHERE NOT OLD.id_unit_latency_manufacture <=> NEW.id_unit_latency_manufacture
UNION
# Changed latency_manufacture
SELECT NEW.id_link, 'latency_manufacture', OLD.latency_manufacture, NEW.latency_manufacture, NEW.id_change_set
WHERE NOT OLD.latency_manufacture <=> NEW.latency_manufacture
UNION UNION
# Changed display_order # Changed display_order
SELECT NEW.id_link, 'display_order', OLD.display_order, NEW.display_order, NEW.id_change_set SELECT NEW.id_link, 'display_order', OLD.display_order, NEW.display_order, NEW.id_change_set

View File

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

View File

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

View File

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

View File

@@ -74,7 +74,7 @@ BEGIN
, cost_local FLOAT NOT NULL , cost_local FLOAT NOT NULL
, id_currency_cost INT NOT NULL , id_currency_cost INT NOT NULL
, profit_local_min FLOAT NOT NULL , profit_local_min FLOAT NOT NULL
, latency_manufacture_days INT NOT NULL , latency_manufacture INT NOT NULL
, id_unit_measurement_quantity INT NOT NULL , id_unit_measurement_quantity INT NOT NULL
, count_unit_measurement_per_quantity_step FLOAT NOT NULL , count_unit_measurement_per_quantity_step FLOAT NOT NULL
, quantity_min FLOAT NOT NULL , quantity_min FLOAT NOT NULL
@@ -112,7 +112,7 @@ BEGIN
, cost_local , cost_local
, id_currency_cost , id_currency_cost
, profit_local_min , profit_local_min
, latency_manufacture_days , latency_manufacture
, id_unit_measurement_quantity , id_unit_measurement_quantity
, count_unit_measurement_per_quantity_step , count_unit_measurement_per_quantity_step
, quantity_min , quantity_min
@@ -136,7 +136,7 @@ BEGIN
, IFNULL(PP_T.cost_local, PP.cost_local) AS cost_local , IFNULL(PP_T.cost_local, PP.cost_local) AS cost_local
, IFNULL(PP_T.id_currency_cost, PP.id_currency_cost) AS a_id_currency_cost , IFNULL(PP_T.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.profit_local_min, PP.profit_local_min) AS profit_local_min
, IFNULL(PP_T.latency_manufacture_days, PP.latency_manufacture_days) AS latency_manufacture_days , IFNULL(PP_T.latency_manufacture, PP.latency_manufacture) AS latency_manufacture
, IFNULL(PP_T.id_unit_measurement_quantity, PP.id_unit_measurement_quantity) AS id_unit_measurement_quantity , IFNULL(PP_T.id_unit_measurement_quantity, PP.id_unit_measurement_quantity) AS id_unit_measurement_quantity
, IFNULL(PP_T.count_unit_measurement_per_quantity_step, PP.count_unit_measurement_per_quantity_step) AS count_unit_measurement_per_quantity_step , IFNULL(PP_T.count_unit_measurement_per_quantity_step, PP.count_unit_measurement_per_quantity_step) AS count_unit_measurement_per_quantity_step
, IFNULL(PP_T.quantity_min, PP.quantity_min) AS quantity_min , IFNULL(PP_T.quantity_min, PP.quantity_min) AS quantity_min
@@ -210,12 +210,12 @@ BEGIN
WHERE ISNULL(t_P.profit_local_min) WHERE ISNULL(t_P.profit_local_min)
; ;
END IF; END IF;
-- latency_manufacture_days -- latency_manufacture
IF EXISTS (SELECT * FROM tmp_Permutation t_P WHERE ISNULL(t_P.latency_manufacture_days) LIMIT 1) THEN IF EXISTS (SELECT * FROM tmp_Permutation t_P WHERE ISNULL(t_P.latency_manufacture) LIMIT 1) THEN
INSERT INTO tmp_Msg_Error ( INSERT INTO tmp_Msg_Error (
guid guid
, id_type , id_type
, latency_manufacture_days , latency_manufacture
, msg , msg
) )
SELECT SELECT
@@ -224,7 +224,7 @@ BEGIN
, v_code_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(IFNULL(t_P.name_error, 'NULL') SEPARATOR ', ')) AS msg
FROM tmp_Permutation t_P FROM tmp_Permutation t_P
WHERE ISNULL(t_P.latency_manufacture_days) WHERE ISNULL(t_P.latency_manufacture)
; ;
END IF; END IF;
-- id_unit_measurement_quantity -- id_unit_measurement_quantity
@@ -396,7 +396,7 @@ BEGIN
, PP.cost_local = t_P.cost_local , PP.cost_local = t_P.cost_local
, PP.id_currency_cost = t_P.id_currency_cost , PP.id_currency_cost = t_P.id_currency_cost
, PP.profit_local_min = t_P.profit_local_min , PP.profit_local_min = t_P.profit_local_min
, PP.latency_manufacture_days = t_P.latency_manufacture_days , PP.latency_manufacture = t_P.latency_manufacture
, PP.id_unit_measurement_quantity = t_P.id_unit_measurement_quantity , PP.id_unit_measurement_quantity = t_P.id_unit_measurement_quantity
, PP.count_unit_measurement_per_quantity_step = t_P.count_unit_measurement_per_quantity_step , PP.count_unit_measurement_per_quantity_step = t_P.count_unit_measurement_per_quantity_step
, PP.quantity_min = t_P.quantity_min , PP.quantity_min = t_P.quantity_min
@@ -420,7 +420,7 @@ BEGIN
, cost_local , cost_local
, id_currency_cost , id_currency_cost
, profit_local_min , profit_local_min
, latency_manufacture_days , latency_manufacture
, id_unit_measurement_quantity , id_unit_measurement_quantity
, count_unit_measurement_per_quantity_step , count_unit_measurement_per_quantity_step
, quantity_min , quantity_min
@@ -443,7 +443,7 @@ BEGIN
, t_P.cost_local AS cost_local , t_P.cost_local AS cost_local
, t_P.id_currency_cost AS id_currency_cost , t_P.id_currency_cost AS id_currency_cost
, t_P.profit_local_min AS profit_local_min , t_P.profit_local_min AS profit_local_min
, t_P.latency_manufacture_days AS latency_manufacture_days , t_P.latency_manufacture AS latency_manufacture
, t_P.id_unit_measurement_quantity AS id_unit_measurement_quantity , t_P.id_unit_measurement_quantity AS id_unit_measurement_quantity
, t_P.count_unit_measurement_per_quantity_step AS count_unit_measurement_per_quantity_step , t_P.count_unit_measurement_per_quantity_step AS count_unit_measurement_per_quantity_step
, t_P.quantity_min AS quantity_min , t_P.quantity_min AS quantity_min
@@ -492,7 +492,7 @@ INSERT INTO Shop_Product_Permutation_Temp (
cost_local, cost_local,
id_currency_cost, id_currency_cost,
profit_local_min, profit_local_min,
latency_manufacture_days, latency_manufacture,
id_unit_measurement_quantity, id_unit_measurement_quantity,
count_unit_measurement_per_quantity_step, count_unit_measurement_per_quantity_step,
quantity_min, quantity_min,
@@ -516,7 +516,7 @@ VALUES
, 5.0 -- cost_local, , 5.0 -- cost_local,
, 1 -- id_currency_cost, , 1 -- id_currency_cost,
, 3.0 -- profit_local_min, , 3.0 -- profit_local_min,
, 14 -- latency_manufacture_days, , 14 -- latency_manufacture,
, 1 -- id_unit_measurement_quantity, , 1 -- id_unit_measurement_quantity,
, 1.0 -- count_unit_measurement_quantity, , 1.0 -- count_unit_measurement_quantity,
, 3.0 -- quantity_min, , 3.0 -- quantity_min,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -379,13 +379,13 @@ BEGIN
VALUES ( VALUES (
v_id_type_error_no_permission v_id_type_error_no_permission
, v_code_type_error_no_permission , v_code_type_error_no_permission
, CONCAT('You do not have view permissions for ', (SELECT name FROM partsltd_prod.Shop_Permission WHERE id_permission = v_id_permission_supplier LIMIT 1)) , CONCAT('You do not have view permissions for ', (SELECT name FROM partsltd_prod.Shop_Permission WHERE id_permission = v_ids_permission_supplier_purchase_order LIMIT 1))
) )
; ;
END IF; END IF;
IF EXISTS ( SELECT * FROM tmp_Msg_Error LIMIT 1 ) THEN IF EXISTS ( SELECT * FROM tmp_Msg_Error LIMIT 1 ) THEN
DELETE FROM tmp_Supplier_Purchase_Order_Product_Link; DELETE FROM tmp_Permutation;
DELETE FROM tmp_Supplier_Purchase_Order; DELETE FROM tmp_Supplier_Purchase_Order;
END IF; END IF;
@@ -414,7 +414,10 @@ BEGIN
SELECT SELECT
t_SPO.id_order t_SPO.id_order
, SPO.id_supplier_ordered , SPO.id_supplier_ordered
, S.name_company
, SPO.id_currency_cost , SPO.id_currency_cost
, C.symbol
, C.code
, SPO.cost_total_local_VAT_excl , SPO.cost_total_local_VAT_excl
, SPO.cost_total_local_VAT_incl , SPO.cost_total_local_VAT_incl
, SPO.active , SPO.active
@@ -426,12 +429,16 @@ BEGIN
) AS name ) AS name
FROM tmp_Supplier_Purchase_Order t_SPO FROM tmp_Supplier_Purchase_Order t_SPO
INNER JOIN partsltd_prod.Shop_Supplier_Purchase_Order SPO ON SPO.id_order = t_SPO.id_order INNER JOIN partsltd_prod.Shop_Supplier_Purchase_Order SPO ON SPO.id_order = t_SPO.id_order
LEFT JOIN partsltd_prod.Shop_Supplier S ON SPO.id_supplier_ordered = S.id_supplier
LEFT JOIN partsltd_prod.Shop_Currency C ON SPO.id_currency_cost = C.id_currency
; ;
# Supplier Purchase Order Product Link # Supplier Purchase Order Product Link
SELECT SELECT
SPOPL.id_link SPOPL.id_link
, SPOPL.id_order , SPOPL.id_order
, P.id_category
, P.id_product
, SPOPL.id_permutation , SPOPL.id_permutation
, fn_shop_get_product_permutation_name(SPOPL.id_permutation) AS name_permutation , fn_shop_get_product_permutation_name(SPOPL.id_permutation) AS name_permutation
-- , SPOPL.id_currency_cost -- , SPOPL.id_currency_cost
@@ -447,6 +454,8 @@ BEGIN
, SPOPL.active , SPOPL.active
FROM tmp_Supplier_Purchase_Order t_SPO FROM tmp_Supplier_Purchase_Order t_SPO
INNER JOIN partsltd_prod.Shop_Supplier_Purchase_Order_Product_Link SPOPL ON t_SPO.id_order = SPOPL.id_order INNER JOIN partsltd_prod.Shop_Supplier_Purchase_Order_Product_Link SPOPL ON t_SPO.id_order = SPOPL.id_order
LEFT JOIN partsltd_prod.Shop_Product_Permutation PP ON SPOPL.id_permutation = PP.id_permutation
LEFT JOIN partsltd_prod.Shop_Product P ON PP.id_product = P.id_product
; ;
# Errors # Errors

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -93,8 +93,8 @@
1401_tbl_Shop_Supplier_Audit.sql 1401_tbl_Shop_Supplier_Audit.sql
1402_tbl_Shop_Supplier_Temp.sql 1402_tbl_Shop_Supplier_Temp.sql
1403_tbl_Shop_Supplier_Address.sql 1403_tbl_Shop_Supplier_Address.sql
1403_tbl_Shop_Supplier_Address_Temp.sql 1404_tbl_Shop_Supplier_Address_Audit.sql
1404_tbl_Shop_Supplier_Address.sql 1405_tbl_Shop_Supplier_Address_Temp.sql
1409_tbl_Shop_Supplier_Purchase_Order.sql 1409_tbl_Shop_Supplier_Purchase_Order.sql
1410_tbl_Shop_Supplier_Purchase_Order_Audit.sql 1410_tbl_Shop_Supplier_Purchase_Order_Audit.sql
1411_tbl_Shop_Supplier_Purchase_Order_Temp.sql 1411_tbl_Shop_Supplier_Purchase_Order_Temp.sql
@@ -197,8 +197,9 @@
7313_p_get_many_user.sql 7313_p_get_many_user.sql
7321_p_shop_save_user_basket.sql 7321_p_shop_save_user_basket.sql
7400_p_shop_save_supplier.sql 7400_p_shop_save_supplier.sql
7400_p_shop_save_supplier_temp.sql
7401_p_shop_get_many_supplier.sql 7401_p_shop_get_many_supplier.sql
7403_p_save_supplier_purchase_order.sql 7403_p_shop_save_supplier_purchase_order.sql
7404_p_shop_get_many_supplier_purchase_order.sql 7404_p_shop_get_many_supplier_purchase_order.sql
7415_p_shop_save_manufacturing_purchase_order.sql 7415_p_shop_save_manufacturing_purchase_order.sql
7416_p_shop_get_many_manufacturing_purchase_order.sql 7416_p_shop_get_many_manufacturing_purchase_order.sql

View File

@@ -911,7 +911,7 @@ CREATE TABLE IF NOT EXISTS Shop_Product_Permutation (
id_currency_cost INTEGER NOT NULL, id_currency_cost INTEGER NOT NULL,
profit_local_min REAL NOT NULL, profit_local_min REAL NOT NULL,
-- id_currency_profit_min INTEGER NOT NULL, -- id_currency_profit_min INTEGER NOT NULL,
latency_manufacture_days INTEGER NOT NULL, latency_manufacture INTEGER NOT NULL,
quantity_min REAL NOT NULL, quantity_min REAL NOT NULL,
quantity_max REAL NOT NULL, quantity_max REAL NOT NULL,
quantity_step REAL NOT NULL, quantity_step REAL NOT NULL,
@@ -2216,7 +2216,7 @@ CREATE TABLE IF NOT EXISTS Shop_Manufacturing_Purchase_Order_Product_Link (
CONSTRAINT FK_Manufacturing_Purchase_Order_id_unit_quantity CONSTRAINT FK_Manufacturing_Purchase_Order_id_unit_quantity
FOREIGN KEY (id_unit_quantity) FOREIGN KEY (id_unit_quantity)
REFERENCES Shop_Unit_Measurement(id_unit_measurement), REFERENCES Shop_Unit_Measurement(id_unit_measurement),
latency_manufacture_days INTEGER NOT NULL, latency_manufacture INTEGER NOT NULL,
quantity_produced REAL NOT NULL, quantity_produced REAL NOT NULL,
display_order INTEGER NOT NULL, display_order INTEGER NOT NULL,
active BOOLEAN NOT NULL, active BOOLEAN NOT NULL,
@@ -2260,7 +2260,7 @@ CREATE TABLE IF NOT EXISTS Shop_Manufacturing_Purchase_Order_Product_Link_Temp (
FOREIGN KEY (id_unit_quantity) FOREIGN KEY (id_unit_quantity)
REFERENCES Shop_Unit_Measurement(id_unit_measurement), REFERENCES Shop_Unit_Measurement(id_unit_measurement),
quantity_produced REAL NULL, quantity_produced REAL NULL,
latency_manufacture_days INTEGER NOT NULL, latency_manufacture INTEGER NOT NULL,
display_order INTEGER NOT NULL, display_order INTEGER NOT NULL,
active BOOLEAN NOT NULL active BOOLEAN NOT NULL
); );
@@ -3512,9 +3512,9 @@ BEGIN
WHERE NOT (OLD.price_GBP_min <=> NEW.price_GBP_min) WHERE NOT (OLD.price_GBP_min <=> NEW.price_GBP_min)
UNION UNION
*/ */
-- Changed latency_manufacture_days -- Changed latency_manufacture
SELECT NEW.id_product, 'latency_manufacture_days', CONVERT(OLD.latency_manufacture_days, CHAR), CONVERT(NEW.latency_manufacture_days, CHAR), NEW.id_change_set SELECT NEW.id_product, 'latency_manufacture', CONVERT(OLD.latency_manufacture, CHAR), CONVERT(NEW.latency_manufacture, CHAR), NEW.id_change_set
WHERE NOT OLD.latency_manufacture_days <=> NEW.latency_manufacture_days WHERE NOT OLD.latency_manufacture <=> NEW.latency_manufacture
UNION UNION
-- Changed quantity_min -- Changed quantity_min
SELECT NEW.id_product, 'quantity_min', CONVERT(OLD.quantity_min, CHAR), CONVERT(NEW.quantity_min, CHAR), NEW.id_change_set SELECT NEW.id_product, 'quantity_min', CONVERT(OLD.quantity_min, CHAR), CONVERT(NEW.quantity_min, CHAR), NEW.id_change_set
@@ -5271,9 +5271,9 @@ BEGIN
SELECT NEW.id_link, 'quantity_produced', OLD.quantity_produced, NEW.quantity_produced, NEW.id_change_set SELECT NEW.id_link, 'quantity_produced', OLD.quantity_produced, NEW.quantity_produced, NEW.id_change_set
WHERE NOT OLD.quantity_produced <=> NEW.quantity_produced WHERE NOT OLD.quantity_produced <=> NEW.quantity_produced
UNION UNION
-- Changed latency_manufacture_days -- Changed latency_manufacture
SELECT NEW.id_link, 'latency_manufacture_days', OLD.latency_manufacture_days, NEW.latency_manufacture_days, NEW.id_change_set SELECT NEW.id_link, 'latency_manufacture', OLD.latency_manufacture, NEW.latency_manufacture, NEW.id_change_set
WHERE NOT OLD.latency_manufacture_days <=> NEW.latency_manufacture_days WHERE NOT OLD.latency_manufacture <=> NEW.latency_manufacture
UNION UNION
-- Changed display_order -- Changed display_order
SELECT NEW.id_link, 'display_order', OLD.display_order, NEW.display_order, NEW.id_change_set SELECT NEW.id_link, 'display_order', OLD.display_order, NEW.display_order, NEW.id_change_set
@@ -7163,7 +7163,7 @@ BEGIN
FOREIGN KEY (id_unit_quantity) FOREIGN KEY (id_unit_quantity)
REFERENCES Shop_Unit_Measurement(id_unit_measurement), REFERENCES Shop_Unit_Measurement(id_unit_measurement),
quantity_produced REAL NULL, quantity_produced REAL NULL,
latency_manufacture_days INTEGER NOT NULL, latency_manufacture INTEGER NOT NULL,
display_order INTEGER NOT NULL, display_order INTEGER NOT NULL,
active BOOLEAN NOT NULL, active BOOLEAN NOT NULL,
name_error VARCHAR(200) NOT NULL name_error VARCHAR(200) NOT NULL
@@ -7246,7 +7246,7 @@ BEGIN
id_unit_quantity, id_unit_quantity,
quantity_produced, quantity_produced,
value_produced_total_local, value_produced_total_local,
latency_manufacture_days, latency_manufacture,
display_order, display_order,
active, active,
name_error name_error
@@ -7261,7 +7261,7 @@ BEGIN
MPOPL_T.id_unit_quantity, MPOPL_T.id_unit_quantity,
MPOPL_T.quantity_produced, MPOPL_T.quantity_produced,
(PP.cost_local + PP.profit_local_min) * MPOPL_T.quantity_produced AS value_produced_total_local, (PP.cost_local + PP.profit_local_min) * MPOPL_T.quantity_produced AS value_produced_total_local,
MPOPL_T.latency_manufacture_days, MPOPL_T.latency_manufacture,
MPOPL_T.display_order, MPOPL_T.display_order,
MPOPL_T.active, MPOPL_T.active,
PP.id_permutation, ' - ' || COALESCE(P.name ,'') AS name_error PP.id_permutation, ' - ' || COALESCE(P.name ,'') AS name_error
@@ -7281,7 +7281,7 @@ BEGIN
MPOPL_T.id_unit_quantity, MPOPL_T.id_unit_quantity,
MPOPL_T.quantity_produced, MPOPL_T.quantity_produced,
value_produced_total_local, value_produced_total_local,
MPOPL_T.latency_manufacture_days, MPOPL_T.latency_manufacture,
MPOPL_T.display_order, MPOPL_T.display_order,
MPOPL_T.active, MPOPL_T.active,
name_error name_error
@@ -7488,7 +7488,7 @@ BEGIN
quantity_used, quantity_used,
id_unit_quantity, id_unit_quantity,
quantity_produced, quantity_produced,
latency_manufacture_days, latency_manufacture,
display_order, display_order,
active, active,
created_by, created_by,
@@ -7503,7 +7503,7 @@ BEGIN
quantity_used, quantity_used,
id_unit_quantity, id_unit_quantity,
quantity_produced, quantity_produced,
latency_manufacture_days, latency_manufacture,
display_order, display_order,
active, active,
v_id_user, v_id_user,
@@ -7534,7 +7534,7 @@ BEGIN
MPOPL.quantity_used = t_MPOPL.quantity_used, MPOPL.quantity_used = t_MPOPL.quantity_used,
MPOPL.id_unit_quantity = t_MPOPL.id_unit_quantity, MPOPL.id_unit_quantity = t_MPOPL.id_unit_quantity,
MPOPL.quantity_produced = t_MPOPL.quantity_produced, MPOPL.quantity_produced = t_MPOPL.quantity_produced,
MPOPL.latency_manufacture_days = t_MPOPL.latency_manufacture_days, MPOPL.latency_manufacture = t_MPOPL.latency_manufacture,
MPOPL.display_order = t_MPOPL.display_order, MPOPL.display_order = t_MPOPL.display_order,
MPOPL.active = t_MPOPL.active, MPOPL.active = t_MPOPL.active,
MPOPL.id_change_set = v_id_change_set MPOPL.id_change_set = v_id_change_set
@@ -7552,7 +7552,7 @@ BEGIN
quantity_used, quantity_used,
id_unit_quantity, id_unit_quantity,
quantity_produced, quantity_produced,
latency_manufacture_days, latency_manufacture,
display_order, display_order,
active, active,
created_by, created_by,
@@ -7567,7 +7567,7 @@ BEGIN
quantity_used, quantity_used,
id_unit_quantity, id_unit_quantity,
quantity_produced, quantity_produced,
latency_manufacture_days, latency_manufacture,
display_order, display_order,
active, active,
v_id_user, v_id_user,
@@ -7634,7 +7634,7 @@ INSERT INTO Shop_Manufacturing_Purchase_Order_Product_Link_Temp (
quantity_used, quantity_used,
id_unit_quantity, id_unit_quantity,
quantity_produced, quantity_produced,
latency_manufacture_days, latency_manufacture,
display_order, display_order,
active active
) )
@@ -7649,7 +7649,7 @@ VALUES
1, -- quantity_used, 1, -- quantity_used,
1, -- id_unit_quantity, 1, -- id_unit_quantity,
1, -- quantity_produced, 1, -- quantity_produced,
14, -- latency_manufacture_days , 14, -- latency_manufacture ,
1, -- display_order 1, -- display_order
1 -- active 1 -- active
) )
@@ -9749,7 +9749,7 @@ BEGIN
price_GBP_full REAL NOT NULL, price_GBP_full REAL NOT NULL,
price_GBP_min REAL NOT NULL, price_GBP_min REAL NOT NULL,
*/ */
latency_manufacture_days INTEGER NOT NULL, latency_manufacture INTEGER NOT NULL,
quantity_min REAL NOT NULL, quantity_min REAL NOT NULL,
quantity_max REAL NOT NULL, quantity_max REAL NOT NULL,
quantity_step REAL NOT NULL, quantity_step REAL NOT NULL,
@@ -9872,7 +9872,7 @@ BEGIN
price_GBP_VAT_excl, price_GBP_VAT_excl,
price_GBP_min, price_GBP_min,
*/ */
latency_manufacture_days, latency_manufacture,
quantity_min, quantity_min,
quantity_max, quantity_max,
quantity_step, quantity_step,
@@ -9905,7 +9905,7 @@ BEGIN
PP.price_GBP_VAT_excl, PP.price_GBP_VAT_excl,
PP.price_GBP_min, PP.price_GBP_min,
*/ */
PP.latency_manufacture_days, PP.latency_manufacture,
PP.quantity_min, PP.quantity_min,
PP.quantity_max, PP.quantity_max,
PP.quantity_step, PP.quantity_step,
@@ -10412,7 +10412,7 @@ BEGIN
PP.cost_local, PP.cost_local,
PP.id_currency_cost, PP.id_currency_cost,
PP.profit_local_min, PP.profit_local_min,
t_P.latency_manufacture_days, t_P.latency_manufacture,
t_P.quantity_min, t_P.quantity_min,
t_P.quantity_max, t_P.quantity_max,
t_P.quantity_step, t_P.quantity_step,
@@ -12162,7 +12162,7 @@ BEGIN
price_GBP_full REAL NOT NULL, price_GBP_full REAL NOT NULL,
price_GBP_min REAL NOT NULL, price_GBP_min REAL NOT NULL,
*/ */
latency_manufacture_days INTEGER NOT NULL, latency_manufacture INTEGER NOT NULL,
quantity_min REAL NOT NULL, quantity_min REAL NOT NULL,
quantity_max REAL NOT NULL, quantity_max REAL NOT NULL,
quantity_step REAL NOT NULL, quantity_step REAL NOT NULL,
@@ -12318,7 +12318,7 @@ BEGIN
price_GBP_VAT_excl, price_GBP_VAT_excl,
price_GBP_min, price_GBP_min,
*/ */
latency_manufacture_days, latency_manufacture,
quantity_min, quantity_min,
quantity_max, quantity_max,
quantity_step, quantity_step,
@@ -12350,7 +12350,7 @@ BEGIN
PP.price_GBP_VAT_excl, PP.price_GBP_VAT_excl,
PP.price_GBP_min, PP.price_GBP_min,
*/ */
PP.latency_manufacture_days, PP.latency_manufacture,
PP.quantity_min, PP.quantity_min,
PP.quantity_max, PP.quantity_max,
PP.quantity_step, PP.quantity_step,
@@ -12849,7 +12849,7 @@ BEGIN
price_GBP_min REAL NOT NULL, price_GBP_min REAL NOT NULL,
*/ */
/* /*
latency_manufacture_days INTEGER NOT NULL, latency_manufacture INTEGER NOT NULL,
quantity_min REAL NOT NULL, quantity_min REAL NOT NULL,
quantity_max REAL NOT NULL, quantity_max REAL NOT NULL,
quantity_step REAL NOT NULL, quantity_step REAL NOT NULL,
@@ -12953,7 +12953,7 @@ BEGIN
price_GBP_VAT_excl, price_GBP_VAT_excl,
price_GBP_min, price_GBP_min,
*/ */
latency_manufacture_days, latency_manufacture,
quantity_min, quantity_min,
quantity_max, quantity_max,
quantity_step, quantity_step,
@@ -12985,7 +12985,7 @@ BEGIN
PP.price_GBP_VAT_excl, PP.price_GBP_VAT_excl,
PP.price_GBP_min, PP.price_GBP_min,
*/ */
PP.latency_manufacture_days, PP.latency_manufacture,
PP.quantity_min, PP.quantity_min,
PP.quantity_max, PP.quantity_max,
PP.quantity_step, PP.quantity_step,
@@ -13193,7 +13193,7 @@ BEGIN
MPOPL.quantity_used, MPOPL.quantity_used,
MPOPL.id_unit_quantity, MPOPL.id_unit_quantity,
MPOPL.quantity_produced, MPOPL.quantity_produced,
MPOPL.latency_manufacture_days, MPOPL.latency_manufacture,
MPOPL.display_order MPOPL.display_order
FROM Shop_manufacturing_Purchase_Order_Product_Link MPOPL FROM Shop_manufacturing_Purchase_Order_Product_Link MPOPL
-- INNER JOIN tmp_Shop_Manufacturing_Purchase_Order_Product_Link t_MPOPL ON MPOPL.id_link = t_MPOPL.id_link -- INNER JOIN tmp_Shop_Manufacturing_Purchase_Order_Product_Link t_MPOPL ON MPOPL.id_link = t_MPOPL.id_link
@@ -13731,7 +13731,7 @@ BEGIN
price_GBP_min REAL NOT NULL, price_GBP_min REAL NOT NULL,
*/ */
/* /*
latency_manufacture_days INTEGER NOT NULL, latency_manufacture INTEGER NOT NULL,
quantity_min REAL NOT NULL, quantity_min REAL NOT NULL,
quantity_max REAL NOT NULL, quantity_max REAL NOT NULL,
quantity_step REAL NOT NULL, quantity_step REAL NOT NULL,
@@ -13887,7 +13887,7 @@ BEGIN
price_GBP_VAT_excl, price_GBP_VAT_excl,
price_GBP_min, price_GBP_min,
*/ */
latency_manufacture_days, latency_manufacture,
quantity_min, quantity_min,
quantity_max, quantity_max,
quantity_step, quantity_step,
@@ -13919,7 +13919,7 @@ BEGIN
PP.price_GBP_VAT_excl, PP.price_GBP_VAT_excl,
PP.price_GBP_min, PP.price_GBP_min,
*/ */
PP.latency_manufacture_days, PP.latency_manufacture,
PP.quantity_min, PP.quantity_min,
PP.quantity_max, PP.quantity_max,
PP.quantity_step, PP.quantity_step,
@@ -14468,7 +14468,7 @@ INSERT INTO Shop_Product_Permutation (
id_currency_cost, id_currency_cost,
profit_local_min, profit_local_min,
-- id_currency_profit_min, -- id_currency_profit_min,
latency_manufacture_days, latency_manufacture,
quantity_min, quantity_min,
quantity_max, quantity_max,
quantity_step, quantity_step,

View File

@@ -18,7 +18,7 @@ CREATE TABLE IF NOT EXISTS Shop_Product_Permutation (
id_currency_cost INTEGER NOT NULL, id_currency_cost INTEGER NOT NULL,
profit_local_min REAL NOT NULL, profit_local_min REAL NOT NULL,
-- id_currency_profit_min INTEGER NOT NULL, -- id_currency_profit_min INTEGER NOT NULL,
latency_manufacture_days INTEGER NOT NULL, latency_manufacture INTEGER NOT NULL,
quantity_min REAL NOT NULL, quantity_min REAL NOT NULL,
quantity_max REAL NOT NULL, quantity_max REAL NOT NULL,
quantity_step REAL NOT NULL, quantity_step REAL NOT NULL,

View File

@@ -23,7 +23,7 @@ CREATE TABLE IF NOT EXISTS Shop_Manufacturing_Purchase_Order_Product_Link (
CONSTRAINT FK_Manufacturing_Purchase_Order_id_unit_quantity CONSTRAINT FK_Manufacturing_Purchase_Order_id_unit_quantity
FOREIGN KEY (id_unit_quantity) FOREIGN KEY (id_unit_quantity)
REFERENCES Shop_Unit_Measurement(id_unit_measurement), REFERENCES Shop_Unit_Measurement(id_unit_measurement),
latency_manufacture_days INTEGER NOT NULL, latency_manufacture INTEGER NOT NULL,
quantity_produced REAL NOT NULL, quantity_produced REAL NOT NULL,
display_order INTEGER NOT NULL, display_order INTEGER NOT NULL,
active BOOLEAN NOT NULL, active BOOLEAN NOT NULL,

View File

@@ -29,7 +29,7 @@ CREATE TABLE IF NOT EXISTS Shop_Manufacturing_Purchase_Order_Product_Link_Temp (
FOREIGN KEY (id_unit_quantity) FOREIGN KEY (id_unit_quantity)
REFERENCES Shop_Unit_Measurement(id_unit_measurement), REFERENCES Shop_Unit_Measurement(id_unit_measurement),
quantity_produced REAL NULL, quantity_produced REAL NULL,
latency_manufacture_days INTEGER NOT NULL, latency_manufacture INTEGER NOT NULL,
display_order INTEGER NOT NULL, display_order INTEGER NOT NULL,
active BOOLEAN NOT NULL active BOOLEAN NOT NULL
); );

View File

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

View File

@@ -63,9 +63,9 @@ BEGIN
SELECT NEW.id_link, 'quantity_produced', OLD.quantity_produced, NEW.quantity_produced, NEW.id_change_set SELECT NEW.id_link, 'quantity_produced', OLD.quantity_produced, NEW.quantity_produced, NEW.id_change_set
WHERE NOT OLD.quantity_produced <=> NEW.quantity_produced WHERE NOT OLD.quantity_produced <=> NEW.quantity_produced
UNION UNION
-- Changed latency_manufacture_days -- Changed latency_manufacture
SELECT NEW.id_link, 'latency_manufacture_days', OLD.latency_manufacture_days, NEW.latency_manufacture_days, NEW.id_change_set SELECT NEW.id_link, 'latency_manufacture', OLD.latency_manufacture, NEW.latency_manufacture, NEW.id_change_set
WHERE NOT OLD.latency_manufacture_days <=> NEW.latency_manufacture_days WHERE NOT OLD.latency_manufacture <=> NEW.latency_manufacture
UNION UNION
-- Changed display_order -- Changed display_order
SELECT NEW.id_link, 'display_order', OLD.display_order, NEW.display_order, NEW.id_change_set SELECT NEW.id_link, 'display_order', OLD.display_order, NEW.display_order, NEW.id_change_set

View File

@@ -90,7 +90,7 @@ BEGIN
FOREIGN KEY (id_unit_quantity) FOREIGN KEY (id_unit_quantity)
REFERENCES Shop_Unit_Measurement(id_unit_measurement), REFERENCES Shop_Unit_Measurement(id_unit_measurement),
quantity_produced REAL NULL, quantity_produced REAL NULL,
latency_manufacture_days INTEGER NOT NULL, latency_manufacture INTEGER NOT NULL,
display_order INTEGER NOT NULL, display_order INTEGER NOT NULL,
active BOOLEAN NOT NULL, active BOOLEAN NOT NULL,
name_error VARCHAR(200) NOT NULL name_error VARCHAR(200) NOT NULL
@@ -173,7 +173,7 @@ BEGIN
id_unit_quantity, id_unit_quantity,
quantity_produced, quantity_produced,
value_produced_total_local, value_produced_total_local,
latency_manufacture_days, latency_manufacture,
display_order, display_order,
active, active,
name_error name_error
@@ -188,7 +188,7 @@ BEGIN
MPOPL_T.id_unit_quantity, MPOPL_T.id_unit_quantity,
MPOPL_T.quantity_produced, MPOPL_T.quantity_produced,
(PP.cost_local + PP.profit_local_min) * MPOPL_T.quantity_produced AS value_produced_total_local, (PP.cost_local + PP.profit_local_min) * MPOPL_T.quantity_produced AS value_produced_total_local,
MPOPL_T.latency_manufacture_days, MPOPL_T.latency_manufacture,
MPOPL_T.display_order, MPOPL_T.display_order,
MPOPL_T.active, MPOPL_T.active,
PP.id_permutation, ' - ' || COALESCE(P.name ,'') AS name_error PP.id_permutation, ' - ' || COALESCE(P.name ,'') AS name_error
@@ -208,7 +208,7 @@ BEGIN
MPOPL_T.id_unit_quantity, MPOPL_T.id_unit_quantity,
MPOPL_T.quantity_produced, MPOPL_T.quantity_produced,
value_produced_total_local, value_produced_total_local,
MPOPL_T.latency_manufacture_days, MPOPL_T.latency_manufacture,
MPOPL_T.display_order, MPOPL_T.display_order,
MPOPL_T.active, MPOPL_T.active,
name_error name_error
@@ -415,7 +415,7 @@ BEGIN
quantity_used, quantity_used,
id_unit_quantity, id_unit_quantity,
quantity_produced, quantity_produced,
latency_manufacture_days, latency_manufacture,
display_order, display_order,
active, active,
created_by, created_by,
@@ -430,7 +430,7 @@ BEGIN
quantity_used, quantity_used,
id_unit_quantity, id_unit_quantity,
quantity_produced, quantity_produced,
latency_manufacture_days, latency_manufacture,
display_order, display_order,
active, active,
v_id_user, v_id_user,
@@ -461,7 +461,7 @@ BEGIN
MPOPL.quantity_used = t_MPOPL.quantity_used, MPOPL.quantity_used = t_MPOPL.quantity_used,
MPOPL.id_unit_quantity = t_MPOPL.id_unit_quantity, MPOPL.id_unit_quantity = t_MPOPL.id_unit_quantity,
MPOPL.quantity_produced = t_MPOPL.quantity_produced, MPOPL.quantity_produced = t_MPOPL.quantity_produced,
MPOPL.latency_manufacture_days = t_MPOPL.latency_manufacture_days, MPOPL.latency_manufacture = t_MPOPL.latency_manufacture,
MPOPL.display_order = t_MPOPL.display_order, MPOPL.display_order = t_MPOPL.display_order,
MPOPL.active = t_MPOPL.active, MPOPL.active = t_MPOPL.active,
MPOPL.id_change_set = v_id_change_set MPOPL.id_change_set = v_id_change_set
@@ -479,7 +479,7 @@ BEGIN
quantity_used, quantity_used,
id_unit_quantity, id_unit_quantity,
quantity_produced, quantity_produced,
latency_manufacture_days, latency_manufacture,
display_order, display_order,
active, active,
created_by, created_by,
@@ -494,7 +494,7 @@ BEGIN
quantity_used, quantity_used,
id_unit_quantity, id_unit_quantity,
quantity_produced, quantity_produced,
latency_manufacture_days, latency_manufacture,
display_order, display_order,
active, active,
v_id_user, v_id_user,
@@ -561,7 +561,7 @@ INSERT INTO Shop_Manufacturing_Purchase_Order_Product_Link_Temp (
quantity_used, quantity_used,
id_unit_quantity, id_unit_quantity,
quantity_produced, quantity_produced,
latency_manufacture_days, latency_manufacture,
display_order, display_order,
active active
) )
@@ -576,7 +576,7 @@ VALUES
1, -- quantity_used, 1, -- quantity_used,
1, -- id_unit_quantity, 1, -- id_unit_quantity,
1, -- quantity_produced, 1, -- quantity_produced,
14, -- latency_manufacture_days , 14, -- latency_manufacture ,
1, -- display_order 1, -- display_order
1 -- active 1 -- active
) )

View File

@@ -203,7 +203,7 @@ BEGIN
price_GBP_full REAL NOT NULL, price_GBP_full REAL NOT NULL,
price_GBP_min REAL NOT NULL, price_GBP_min REAL NOT NULL,
*/ */
latency_manufacture_days INTEGER NOT NULL, latency_manufacture INTEGER NOT NULL,
quantity_min REAL NOT NULL, quantity_min REAL NOT NULL,
quantity_max REAL NOT NULL, quantity_max REAL NOT NULL,
quantity_step REAL NOT NULL, quantity_step REAL NOT NULL,
@@ -326,7 +326,7 @@ BEGIN
price_GBP_VAT_excl, price_GBP_VAT_excl,
price_GBP_min, price_GBP_min,
*/ */
latency_manufacture_days, latency_manufacture,
quantity_min, quantity_min,
quantity_max, quantity_max,
quantity_step, quantity_step,
@@ -359,7 +359,7 @@ BEGIN
PP.price_GBP_VAT_excl, PP.price_GBP_VAT_excl,
PP.price_GBP_min, PP.price_GBP_min,
*/ */
PP.latency_manufacture_days, PP.latency_manufacture,
PP.quantity_min, PP.quantity_min,
PP.quantity_max, PP.quantity_max,
PP.quantity_step, PP.quantity_step,
@@ -866,7 +866,7 @@ BEGIN
PP.cost_local, PP.cost_local,
PP.id_currency_cost, PP.id_currency_cost,
PP.profit_local_min, PP.profit_local_min,
t_P.latency_manufacture_days, t_P.latency_manufacture,
t_P.quantity_min, t_P.quantity_min,
t_P.quantity_max, t_P.quantity_max,
t_P.quantity_step, t_P.quantity_step,

View File

@@ -169,7 +169,7 @@ BEGIN
price_GBP_full REAL NOT NULL, price_GBP_full REAL NOT NULL,
price_GBP_min REAL NOT NULL, price_GBP_min REAL NOT NULL,
*/ */
latency_manufacture_days INTEGER NOT NULL, latency_manufacture INTEGER NOT NULL,
quantity_min REAL NOT NULL, quantity_min REAL NOT NULL,
quantity_max REAL NOT NULL, quantity_max REAL NOT NULL,
quantity_step REAL NOT NULL, quantity_step REAL NOT NULL,
@@ -325,7 +325,7 @@ BEGIN
price_GBP_VAT_excl, price_GBP_VAT_excl,
price_GBP_min, price_GBP_min,
*/ */
latency_manufacture_days, latency_manufacture,
quantity_min, quantity_min,
quantity_max, quantity_max,
quantity_step, quantity_step,
@@ -357,7 +357,7 @@ BEGIN
PP.price_GBP_VAT_excl, PP.price_GBP_VAT_excl,
PP.price_GBP_min, PP.price_GBP_min,
*/ */
PP.latency_manufacture_days, PP.latency_manufacture,
PP.quantity_min, PP.quantity_min,
PP.quantity_max, PP.quantity_max,
PP.quantity_step, PP.quantity_step,

View File

@@ -147,7 +147,7 @@ BEGIN
price_GBP_min REAL NOT NULL, price_GBP_min REAL NOT NULL,
*/ */
/* /*
latency_manufacture_days INTEGER NOT NULL, latency_manufacture INTEGER NOT NULL,
quantity_min REAL NOT NULL, quantity_min REAL NOT NULL,
quantity_max REAL NOT NULL, quantity_max REAL NOT NULL,
quantity_step REAL NOT NULL, quantity_step REAL NOT NULL,
@@ -251,7 +251,7 @@ BEGIN
price_GBP_VAT_excl, price_GBP_VAT_excl,
price_GBP_min, price_GBP_min,
*/ */
latency_manufacture_days, latency_manufacture,
quantity_min, quantity_min,
quantity_max, quantity_max,
quantity_step, quantity_step,
@@ -283,7 +283,7 @@ BEGIN
PP.price_GBP_VAT_excl, PP.price_GBP_VAT_excl,
PP.price_GBP_min, PP.price_GBP_min,
*/ */
PP.latency_manufacture_days, PP.latency_manufacture,
PP.quantity_min, PP.quantity_min,
PP.quantity_max, PP.quantity_max,
PP.quantity_step, PP.quantity_step,
@@ -491,7 +491,7 @@ BEGIN
MPOPL.quantity_used, MPOPL.quantity_used,
MPOPL.id_unit_quantity, MPOPL.id_unit_quantity,
MPOPL.quantity_produced, MPOPL.quantity_produced,
MPOPL.latency_manufacture_days, MPOPL.latency_manufacture,
MPOPL.display_order MPOPL.display_order
FROM Shop_manufacturing_Purchase_Order_Product_Link MPOPL FROM Shop_manufacturing_Purchase_Order_Product_Link MPOPL
-- INNER JOIN tmp_Shop_Manufacturing_Purchase_Order_Product_Link t_MPOPL ON MPOPL.id_link = t_MPOPL.id_link -- INNER JOIN tmp_Shop_Manufacturing_Purchase_Order_Product_Link t_MPOPL ON MPOPL.id_link = t_MPOPL.id_link

View File

@@ -179,7 +179,7 @@ BEGIN
price_GBP_min REAL NOT NULL, price_GBP_min REAL NOT NULL,
*/ */
/* /*
latency_manufacture_days INTEGER NOT NULL, latency_manufacture INTEGER NOT NULL,
quantity_min REAL NOT NULL, quantity_min REAL NOT NULL,
quantity_max REAL NOT NULL, quantity_max REAL NOT NULL,
quantity_step REAL NOT NULL, quantity_step REAL NOT NULL,
@@ -335,7 +335,7 @@ BEGIN
price_GBP_VAT_excl, price_GBP_VAT_excl,
price_GBP_min, price_GBP_min,
*/ */
latency_manufacture_days, latency_manufacture,
quantity_min, quantity_min,
quantity_max, quantity_max,
quantity_step, quantity_step,
@@ -367,7 +367,7 @@ BEGIN
PP.price_GBP_VAT_excl, PP.price_GBP_VAT_excl,
PP.price_GBP_min, PP.price_GBP_min,
*/ */
PP.latency_manufacture_days, PP.latency_manufacture,
PP.quantity_min, PP.quantity_min,
PP.quantity_max, PP.quantity_max,
PP.quantity_step, PP.quantity_step,

View File

@@ -198,7 +198,7 @@ INSERT INTO Shop_Product_Permutation (
id_currency_cost, id_currency_cost,
profit_local_min, profit_local_min,
-- id_currency_profit_min, -- id_currency_profit_min,
latency_manufacture_days, latency_manufacture,
quantity_min, quantity_min,
quantity_max, quantity_max,
quantity_step, quantity_step,

View File

@@ -9,7 +9,7 @@ thead, tbody {
} }
th { th {
background-color: var(--c_purple_pastel);
} }
td { td {
font-size: min(12px, calc(1vh * 3)); font-size: min(12px, calc(1vh * 3));
@@ -24,6 +24,17 @@ tr:not(:last-child) > td {
td > table > tbody > tr > td { td > table > tbody > tr > td {
border: none !important; border: none !important;
} }
th.collapsed, td.collapsed {
display: table-cell !important;
}
td.dirty {
background-color: var(--c_purple_dark);
}
td:not(.dirty) {
/* color: var(--c_purple_dark); */
background-color: var(--c_purple_pastel);
}
tr { tr {
min-height: 1px; min-height: 1px;
border-bottom: 1px solid var(--c_purple_dark); border-bottom: 1px solid var(--c_purple_dark);

View File

@@ -579,13 +579,12 @@ li {
} }
.dirty { :not(input,textarea,select).dirty {
/* color: var(--c_purple_dark); */
border-color: var(--c_purple_dark);
}
td.dirty {
background-color: var(--c_purple_dark); background-color: var(--c_purple_dark);
} }
input.dirty, textarea.dirty, select.dirty {
border-color: var(--c_purple_dark);
}
/* Tables */ /* Tables */

View File

@@ -99,7 +99,7 @@
width: 9vh; width: 9vh;
min-width: 9vh; min-width: 9vh;
} }
#tableMain thead tr th.latency_manufacture_days, #tableMain tbody tr td.latency_manufacture_days { #tableMain thead tr th.latency_manufacture, #tableMain tbody tr td.latency_manufacture {
width: 9vh; width: 9vh;
min-width: 9vh; min-width: 9vh;
} }

View File

@@ -20,7 +20,6 @@ th, td {
#tableMain thead tr th.product_variations.collapsed, #tableMain tbody tr td.product_variations.collapsed { #tableMain thead tr th.product_variations.collapsed, #tableMain tbody tr td.product_variations.collapsed {
width: 10vh; width: 10vh;
min-width: 10vh; min-width: 10vh;
display: table-cell !important;
} }
#tableMain thead tr th.product_variations, #tableMain tbody tr td.product_variations { #tableMain thead tr th.product_variations, #tableMain tbody tr td.product_variations {
width: 20vh; width: 20vh;
@@ -53,7 +52,6 @@ th, td {
#tableMain thead tr th.storage-location.collapsed, #tableMain tbody tr td.storage-location.collapsed { #tableMain thead tr th.storage-location.collapsed, #tableMain tbody tr td.storage-location.collapsed {
width: 10vh; width: 10vh;
min-width: 10vh; min-width: 10vh;
display: table-cell !important;
} }
#tableMain thead tr th.storage-location, #tableMain tbody tr td.storage-location { #tableMain thead tr th.storage-location, #tableMain tbody tr td.storage-location {
width: 20vh; width: 20vh;

View File

@@ -30,10 +30,63 @@
width: 10vh; width: 10vh;
min-width: 10vh; min-width: 10vh;
} }
#tableMain tbody tr td.items, #tableMain thead tr th.items {
#tableMain tbody tr td.order_items, #tableMain thead tr th.items {
width: 40vh; width: 40vh;
min-width: 40vh; min-width: 40vh;
} }
#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: 91vh;
min-width: 91vh;
}
#tableMain thead tr th.order_items,
#tableMain tbody tr td.order_items {
width: 101vh;
min-width: 101vh;
}
#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.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_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.latency_delivery_days, #tableMain tbody tr td.order_items table tbody tr td.latency_delivery_days {
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 {
width: 4vh;
min-width: 4vh;
}
#tableMain tbody tr td.active, #tableMain thead tr th.active { #tableMain tbody tr td.active, #tableMain thead tr th.active {
width: 5vh; width: 5vh;
min-width: 5vh; min-width: 5vh;

View File

@@ -579,13 +579,12 @@ li {
} }
.dirty { :not(input,textarea,select).dirty {
/* color: var(--c_purple_dark); */
border-color: var(--c_purple_dark);
}
td.dirty {
background-color: var(--c_purple_dark); background-color: var(--c_purple_dark);
} }
input.dirty, textarea.dirty, select.dirty {
border-color: var(--c_purple_dark);
}
/* Tables */ /* Tables */
@@ -615,7 +614,7 @@ thead, tbody {
} }
th { th {
background-color: var(--c_purple_pastel);
} }
td { td {
font-size: min(12px, calc(1vh * 3)); font-size: min(12px, calc(1vh * 3));
@@ -630,6 +629,17 @@ tr:not(:last-child) > td {
td > table > tbody > tr > td { td > table > tbody > tr > td {
border: none !important; border: none !important;
} }
th.collapsed, td.collapsed {
display: table-cell !important;
}
td.dirty {
background-color: var(--c_purple_dark);
}
td:not(.dirty) {
/* color: var(--c_purple_dark); */
background-color: var(--c_purple_pastel);
}
tr { tr {
min-height: 1px; min-height: 1px;
border-bottom: 1px solid var(--c_purple_dark); border-bottom: 1px solid var(--c_purple_dark);

View File

@@ -152,7 +152,7 @@
width: 9vh; width: 9vh;
min-width: 9vh; min-width: 9vh;
} }
#tableMain thead tr th.latency_manufacture_days, #tableMain tbody tr td.latency_manufacture_days { #tableMain thead tr th.latency_manufacture, #tableMain tbody tr td.latency_manufacture {
width: 9vh; width: 9vh;
min-width: 9vh; min-width: 9vh;
} }

View File

@@ -73,7 +73,6 @@ th, td {
#tableMain thead tr th.product_variations.collapsed, #tableMain tbody tr td.product_variations.collapsed { #tableMain thead tr th.product_variations.collapsed, #tableMain tbody tr td.product_variations.collapsed {
width: 10vh; width: 10vh;
min-width: 10vh; min-width: 10vh;
display: table-cell !important;
} }
#tableMain thead tr th.product_variations, #tableMain tbody tr td.product_variations { #tableMain thead tr th.product_variations, #tableMain tbody tr td.product_variations {
width: 20vh; width: 20vh;
@@ -106,7 +105,6 @@ th, td {
#tableMain thead tr th.storage-location.collapsed, #tableMain tbody tr td.storage-location.collapsed { #tableMain thead tr th.storage-location.collapsed, #tableMain tbody tr td.storage-location.collapsed {
width: 10vh; width: 10vh;
min-width: 10vh; min-width: 10vh;
display: table-cell !important;
} }
#tableMain thead tr th.storage-location, #tableMain tbody tr td.storage-location { #tableMain thead tr th.storage-location, #tableMain tbody tr td.storage-location {
width: 20vh; width: 20vh;

File diff suppressed because one or more lines are too long

BIN
static/docs/PARTS ERP.xlsx Normal file

Binary file not shown.

View File

@@ -1,4 +1,5 @@
import Common from "../../../lib/common.js";
import Validation from "../../../lib/validation.js"; import Validation from "../../../lib/validation.js";
export default class TextArea { export default class TextArea {
@@ -27,15 +28,15 @@ export default class TextArea {
elTextarea.style.removeProperty('height'); elTextarea.style.removeProperty('height');
textarea.getAttribute('rows', 1); textarea.getAttribute('rows', 1);
const paddingTop = parseCSSPropertyToFloat(textarea, 'padding-top'); const paddingTop = Common.parseFloatWithDefault(textarea.style.paddingTop);
const paddingBottom= parseCSSPropertyToFloat(textarea, 'padding-bottom'); const paddingBottom = Common.parseFloatWithDefault(textarea.style.paddingBottom);
const borderTop = parseCSSPropertyToFloat(textarea, 'border-top'); const borderTop = Common.parseFloatWithDefault(textarea.style.borderTop);
const borderBottom = parseCSSPropertyToFloat(textarea, 'border-bottom'); const borderBottom = Common.parseFloatWithDefault(textarea.style.borderBottom);
let heightDelta = paddingTop + paddingBottom + borderTop + borderBottom; let heightDelta = paddingTop + paddingBottom + borderTop + borderBottom;
let heightNew = elTextarea.scrollHeight + heightDelta; let heightNew = elTextarea.scrollHeight + heightDelta;
// If new height is less than 1 linem default to single line height // If new height is less than 1 linem default to single line height
const heightSingleLine = parseCSSPropertyToFloat(textarea, 'line-height') + heightDelta; const heightSingleLine = Common.parseFloatWithDefault(textarea.style.heightSingleLine) + heightDelta;
if (heightNew < heightSingleLine) heightNew = heightSingleLine; if (heightNew < heightSingleLine) heightNew = heightSingleLine;
elTextarea.style.height = heightNew + 'px'; elTextarea.style.height = heightNew + 'px';

View File

@@ -37,8 +37,19 @@ export default class DOM {
static getCellFromElement(element) { static getCellFromElement(element) {
return element.closest('td'); return element.closest('td');
} }
static getRowFromElement(element) { static getRowFromElement(element, flagRow) {
return element.closest('tr'); let selector = Validation.isEmpty(flagRow) ? 'tr' : 'tr.' + flagRow;
return element.closest(selector);
}
static getClosestParent(element, selector) {
let parent = element.parentElement;
while (parent) {
if (parent.matches(selector)) {
return parent;
}
parent = parent.parentElement;
}
return null;
} }
static convertForm2JSON(elementForm) { static convertForm2JSON(elementForm) {
let dataForm = {}; let dataForm = {};

View File

@@ -21,4 +21,7 @@ export default class BusinessObjects {
}; };
} }
*/ */
static getObjectText(objectJson) {
return objectJson[objectJson[flagNameAttrOptionText]];
}
} }

View File

@@ -0,0 +1,34 @@
export default class ProductPermutation {
static getProductVariationsFromIdCsv(csvVariations) {
let productVariations = [];
if (!csvVariations) return productVariations;
let variationPairs = csvVariations.split(',');
if (variationPairs.length == 0) return productVariations;
let parts;
variationPairs.forEach((variationPair) => {
parts = variationPair.split(':');
if (parts.length == 2) {
let productVariationType = productVariationTypes[parts[0]];
let productVariation = productVariations[parts[1]];
if (productVariationType && productVariation) {
productVariations.push([productVariationType, productVariation]);
}
}
});
return productVariations;
}
static getProductVariationsPreviewFromIdCsv(csvVariations) {
let variations = ProductPermutation.getProductVariationsFromIdCsv(csvVariations);
let preview = '';
if (variations.length == 0) return preview;
variations.forEach((variation) => {
if (preview.length > 0) {
preview += '\n';
}
preview += variation[0] + ': ' + variation[1] + ', ';
});
return preview;
}
}

View File

@@ -2,50 +2,11 @@
import Validation from "./validation.js"; import Validation from "./validation.js";
export default class Common { export default class Common {
static parseCSSPropertyToFloat(element, propertyName) { static parseFloatWithDefault(value, defaultValue = 0.00) {
var propertyText = element.css(propertyName); if (!Validation.isEmpty(value) && Validation.isValidNumber(value, true)) {
return parseFloat(value);
if (!Validation.isEmpty(propertyText)) {
propertyText = propertyText.replace('px', '');
if (!Validation.isValidNumber(propertyText, true)) return parseFloat(propertyText);
}
return 0.00;
}
static setPageToLoading(isLoading) {
if (isLoading) {
document.querySelectorAll(document.body).classList.add(_dataLoadingFlag);
}
else {
document.querySelectorAll(document.body).classList.remove(_dataLoadingFlag);
}
}
static setBackgroundToLoading(elId, isLoading) {
if (Validation.isEmpty(el)) {
var elObj = document.querySelectorAll(elId);
if (isLoading) {
setTimeout(function() {
elObj.innerHTML = "";
elObj.css({
"background-image": "url(" + urlImgLoading + ")",
"background-position": "center",
"background-repeat": "no-repeat"
});
}, 0);
}
else {
elObj.css("background-image", "");
}
} }
return defaultValue;
} }
static allowClick() { static allowClick() {

View File

@@ -151,13 +151,4 @@ export default class Validation {
img.onerror = function() { callback(false); }; img.onerror = function() { callback(false); };
img.src = url; img.src = url;
} }
static validateImageUrl(id, img) {
Validation.imageExists(img, function(exists) {
if (exists) {
document.querySelectorAll("#" + id).css({ "background-image": "url(" + url + ")", "background-size": "35px 35px"})
}
})
}
} }

View File

@@ -1,5 +1,5 @@
import BusinessObjects from "../lib/business_objects.js"; import BusinessObjects from "../lib/business_objects/business_objects.js";
import Events from "../lib/events.js"; import Events from "../lib/events.js";
import LocalStorage from "../lib/local_storage.js"; import LocalStorage from "../lib/local_storage.js";
import API from "../api.js"; import API from "../api.js";
@@ -179,7 +179,7 @@ export default class BasePage {
Events.initialiseEventHandler(idOverlay, flagInitialised, (overlay) => { Events.initialiseEventHandler(idOverlay, flagInitialised, (overlay) => {
overlay.querySelector('button.' + flagCancel).addEventListener("click", (event) => { overlay.querySelector('button.' + flagCancel).addEventListener("click", (event) => {
event.stopPropagation(); event.stopPropagation();
overlay.css('display', 'none'); overlay.style.display = 'none';
}); });
}); });
} }
@@ -222,9 +222,11 @@ export default class BasePage {
if (show) { if (show) {
buttonCancel.classList.remove(flagCollapsed); buttonCancel.classList.remove(flagCollapsed);
buttonSave.classList.remove(flagCollapsed); buttonSave.classList.remove(flagCollapsed);
console.log('showing buttons');
} else { } else {
buttonCancel.classList.add(flagCollapsed); buttonCancel.classList.add(flagCollapsed);
buttonSave.classList.add(flagCollapsed); buttonSave.classList.add(flagCollapsed);
console.log('hiding buttons');
} }
} }

View File

@@ -1,5 +1,5 @@
import BusinessObjects from "../lib/business_objects.js"; import BusinessObjects from "../lib/business_objects/business_objects.js";
import Events from "../lib/events.js"; import Events from "../lib/events.js";
import LocalStorage from "../lib/local_storage.js"; import LocalStorage from "../lib/local_storage.js";
import Validation from "../lib/validation.js"; import Validation from "../lib/validation.js";
@@ -113,7 +113,7 @@ export default class TableBasePage extends BasePage {
return document.querySelector(idFormFilters); return document.querySelector(idFormFilters);
} }
callbackLoadTableContent(response) { callbackLoadTableContent(response) {
let table = this.getTableMain(); let table = TableBasePage.getTableMain();
let bodyTable = table.querySelector('tbody'); let bodyTable = table.querySelector('tbody');
bodyTable.querySelectorAll('tr').forEach(function(row) { row.remove(); }); bodyTable.querySelectorAll('tr').forEach(function(row) { row.remove(); });
let rowsJson = response.data[flagRows]; let rowsJson = response.data[flagRows];
@@ -123,7 +123,7 @@ export default class TableBasePage extends BasePage {
rowsJson.forEach(this.loadRowTable.bind(this)); rowsJson.forEach(this.loadRowTable.bind(this));
this.hookupTableMain(); this.hookupTableMain();
} }
getTableMain() { static getTableMain() {
return document.querySelector(idTableMain); return document.querySelector(idTableMain);
} }
loadRowTable(rowJson) { loadRowTable(rowJson) {
@@ -168,7 +168,7 @@ export default class TableBasePage extends BasePage {
.catch(error => console.error('Error:', error)); .catch(error => console.error('Error:', error));
} }
getTableRecords(dirtyOnly = false) { getTableRecords(dirtyOnly = false) {
// let table = this.getTableMain(); // let table = TableBasePage.getTableMain();
let records = []; let records = [];
let record; let record;
document.querySelectorAll(idTableMain + ' > tbody > tr').forEach((row) => { document.querySelectorAll(idTableMain + ' > tbody > tr').forEach((row) => {
@@ -276,13 +276,13 @@ export default class TableBasePage extends BasePage {
* *
sliderDisplayOrder.addEventListener('change', (event) => { sliderDisplayOrder.addEventListener('change', (event) => {
console.log("slider change event"); console.log("slider change event");
this.handleChangeElementCellTable(sliderDisplayOrder); this.handleChangeNestedElementCellTable(sliderDisplayOrder);
}); });
}); });
*/ */
this.hookupChangeHandlerTableCells(selectorDisplayOrder); this.hookupChangeHandlerTableCells(selectorDisplayOrder);
} }
hookupChangeHandlerTableCells(inputSelector, handler = (event, element) => { this.handleChangeElementCellTable(event, element); }) { hookupChangeHandlerTableCells(inputSelector, handler = (event, element) => { this.handleChangeNestedElementCellTable(event, element); }) {
Events.initialiseEventHandler(inputSelector, flagInitialised, (input) => { Events.initialiseEventHandler(inputSelector, flagInitialised, (input) => {
input.addEventListener("change", (event) => { input.addEventListener("change", (event) => {
handler(event, input); handler(event, input);
@@ -291,6 +291,7 @@ export default class TableBasePage extends BasePage {
}); });
// this.hookupEventHandler("change", inputSelector, handler); // this.hookupEventHandler("change", inputSelector, handler);
} }
/*
handleChangeElementCellTable(event, element) { handleChangeElementCellTable(event, element) {
let row = DOM.getRowFromElement(element); let row = DOM.getRowFromElement(element);
let td = DOM.getCellFromElement(element); let td = DOM.getCellFromElement(element);
@@ -308,8 +309,103 @@ export default class TableBasePage extends BasePage {
} }
} }
} }
handleChangeElementNestedCellTable(event, element, flagColumnList = [], orderNesting = 1) {
let orderNestingTemp = orderNesting;
let row, td, nestedRowSelector;
while (orderNestingTemp > 0) {
nestedRowSelector = idTableMain;
for (let indexOrderNesting = 0; indexOrderNesting < orderNestingTemp; indexOrderNesting++) {
nestedRowSelector += ' tbody tr';
}
row = DOM.getClosestParent(element, nestedRowSelector);
td = row.querySelector('td.' + flag);
}
let row = DOM.getRowFromElement(element);
let td = DOM.getCellFromElement(element);
let wasDirtyRow = DOM.hasDirtyChildrenNotDeletedContainer(row);
let wasDirtyElement = element.classList.contains(flagDirty);
let isDirtyElement = DOM.updateAndCheckIsElementDirty(element);
if (isDirtyElement != wasDirtyElement) {
DOM.handleDirtyElement(td, isDirtyElement);
let isNowDirtyRow = DOM.hasDirtyChildrenNotDeletedContainer(row);
if (isNowDirtyRow != wasDirtyRow) {
DOM.handleDirtyElement(row, isNowDirtyRow);
let rows = this.getTableRecords(true);
let existsDirtyRecord = rows.length > 0;
this.toggleShowButtonsSaveCancel(existsDirtyRecord);
}
}
}
handleChangeElementSubtableCell(event, element, flagFieldSubtable) {
let rowSubtable = element.closest(idTableMain + ' td.' + flagFieldSubtable + ' tbody tr');
let rowTable = rowSubtable.closest(idTableMain + ' > tbody > tr');
let td = DOM.getCellFromElement(element);
// let tdSubtable = td.closest('td.' + flagFieldSubtable);
let wasDirtyRowSubtable = DOM.hasDirtyChildrenNotDeletedContainer(rowSubtable);
let wasDirtyRowTable = DOM.hasDirtyChildrenNotDeletedContainer(rowTable);
let wasDirtyElement = element.classList.contains(flagDirty);
let isDirtyElement = DOM.updateAndCheckIsElementDirty(element);
console.log({isDirtyElement, wasDirtyElement});
if (isDirtyElement != wasDirtyElement) {
DOM.handleDirtyElement(td, isDirtyElement);
let isNowDirtyRowSubtable = DOM.hasDirtyChildrenNotDeletedContainer(rowSubtable);
console.log({isNowDirtyRowSubtable, wasDirtyRowSubtable});
if (isNowDirtyRowSubtable != wasDirtyRowSubtable) {
DOM.handleDirtyElement(rowSubtable, isNowDirtyRowSubtable);
let isNowDirtyRowTable = DOM.hasDirtyChildrenNotDeletedContainer(rowTable);
console.log({isNowDirtyRowTable, wasDirtyRowTable});
if (isNowDirtyRowTable != wasDirtyRowTable) {
DOM.handleDirtyElement(rowTable, isNowDirtyRowTable);
let rows = this.getTableRecords(true);
let existsDirtyRecord = rows.length > 0;
this.toggleShowButtonsSaveCancel(existsDirtyRecord);
}
}
}
}
*/
handleChangeNestedElementCellTable(event, element) {
let wasDirtyParentRows = this.getAllIsDirtyRowsInParentTree(element);
let wasDirtyElement = element.classList.contains(flagDirty);
let isDirtyElement = DOM.updateAndCheckIsElementDirty(element);
console.log({isDirtyElement, wasDirtyElement, wasDirtyParentRows});
if (isDirtyElement != wasDirtyElement) {
let td = DOM.getCellFromElement(element);
DOM.setElementAttributeValueCurrent(td, DOM.getElementValueCurrent(element));
this.toggleShowButtonsSaveCancel(isDirtyElement);
this.cascadeChangedIsDirtyNestedElementCellTable(element, isDirtyElement, wasDirtyParentRows);
}
}
getAllIsDirtyRowsInParentTree(element) {
let rows = [];
let parent = element;
let isDirty;
while (parent) {
if (parent.matches('tr')) {
isDirty = parent.classList.contains(flagDirty)
rows.push(isDirty);
}
parent = parent.parentElement;
}
return rows;
}
cascadeChangedIsDirtyNestedElementCellTable(element, isDirtyElement, wasDirtyParentRows) {
if (Validation.isEmpty(wasDirtyParentRows)) return;
let td = DOM.getCellFromElement(element);
let isDirtyTd = isDirtyElement || DOM.hasDirtyChildrenNotDeletedContainer(tr);
DOM.handleDirtyElement(td, isDirtyTd);
let tr = DOM.getRowFromElement(td);
let isDirtyRow = isDirtyTd || DOM.hasDirtyChildrenNotDeletedContainer(tr);
let wasDirtyRow = wasDirtyParentRows.pop();
console.log({isDirtyRow, wasDirtyRow});
if (isDirtyRow != wasDirtyRow) {
DOM.handleDirtyElement(tr, isDirtyRow);
this.toggleShowButtonsSaveCancel(isDirtyRow);
this.cascadeChangedIsDirtyNestedElementCellTable(tr.parentElement, isDirtyRow, wasDirtyParentRows);
}
}
hookupChangeHandlerTableCellsWhenNotCollapsed(inputSelector, handler = (event, element) => { hookupChangeHandlerTableCellsWhenNotCollapsed(inputSelector, handler = (event, element) => {
if (!element.classList.contains(flagCollapsed)) this.handleChangeElementCellTable(event, element); if (!element.classList.contains(flagCollapsed)) this.handleChangeNestedElementCellTable(event, element);
}) { }) {
this.hookupEventHandler("change", inputSelector, handler); this.hookupEventHandler("change", inputSelector, handler);
} }
@@ -355,7 +451,7 @@ export default class TableBasePage extends BasePage {
return false; return false;
} }
handleDragSliderEnd(event) { handleDragSliderEnd(event) {
let table = this.getTableMain(); let table = TableBasePage.getTableMain();
let rows = table.querySelectorAll('tr'); let rows = table.querySelectorAll('tr');
rows.forEach(row => { rows.forEach(row => {
row.classList.remove(flagDragOver); row.classList.remove(flagDragOver);
@@ -381,33 +477,79 @@ export default class TableBasePage extends BasePage {
this.hookupChangeHandlerTableCells(idTableMain + ' tbody tr td.' + flagDescription + ' textarea'); this.hookupChangeHandlerTableCells(idTableMain + ' tbody tr td.' + flagDescription + ' textarea');
} }
hookupInputsActiveTable() { hookupInputsActiveTable() {
this.hookupChangeHandlerTableCells(idTableMain + ' tbody tr td.' + flagActive + ' input[type="checkbox"]'); this.hookupChangeHandlerTableCells(idTableMain + ' > tbody > tr > td.' + flagActive + ' input[type="checkbox"]');
}
hookupButtonsRowDelete(selectorButtonDelete, selectorButtonUndelete) {
this.hookupEventHandler("click", selectorButtonDelete, (event, element) => {
this.handleClickButtonRowDelete(event, element, selectorButtonDelete, selectorButtonUndelete);
});
}
handleClickButtonRowDelete(event, element, selectorButtonDelete, selectorButtonUndelete) {
let row = DOM.getRowFromElement(element);
row.classList.add(flagDelete);
let buttonAdd = document.createElement("button");
buttonAdd.classList.add(flagAdd);
buttonAdd.textContent = '+';
element.replaceWith(buttonAdd);
this.hookupButtonsRowUndelete(selectorButtonDelete, selectorButtonUndelete);
}
hookupButtonsRowUndelete(selectorButtonDelete, selectorButtonUndelete) {
this.hookupEventHandler("click", selectorButtonUndelete, (event, element) => {
this.handleClickButtonRowUndelete(event, element, selectorButtonDelete, selectorButtonUndelete);
});
}
handleClickButtonRowUndelete(event, element, selectorButtonDelete, selectorButtonUndelete) {
let row = DOM.getRowFromElement(element);
row.classList.add(flagDelete);
let buttonAdd = document.createElement("button");
buttonAdd.classList.add(flagAdd);
buttonAdd.textContent = '+';
element.replaceWith(buttonAdd);
this.hookupButtonsRowDelete(selectorButtonDelete, selectorButtonUndelete);
} }
hookupTdsAccessLevel() { hookupTdsAccessLevel() {
let cellSelector = idTableMain + ' tbody td.' + flagAccessLevel; let cellSelector = idTableMain + ' tbody td.' + flagAccessLevel;
this.hookupTableCellDdlPreviews(cellSelector, Utils.getListFromDict(accessLevels)); this.hookupTableCellDdlPreviews(cellSelector, Utils.getListFromDict(accessLevels));
} }
hookupTableCellDdlPreviews(cellSelector, optionList, ddlHookup = (event, element) => { this.hookupTableCellDdls(event, element); }) { hookupTableCellDdlPreviews(
cellSelector
, optionList
, ddlHookup = (cellSelector) => { this.hookupTableCellDdls(cellSelector); }
, changeHandler = (event, element) => { this.handleChangeTableCellDdl(event, element); }
) {
this.hookupEventHandler("click", cellSelector, (event, td) => { this.hookupEventHandler("click", cellSelector, (event, td) => {
// if (td.querySelector('select')) return; // if (td.querySelector('select')) return;
this.handleClickTableCellDdlPreview(event, td, optionList, cellSelector, (event, element) => { ddlHookup(event, element); }); this.handleClickTableCellDdlPreview(
event
, td
, optionList
, cellSelector
, (cellSelector) => { ddlHookup(
cellSelector
, (event, element) => { changeHandler(event, element); }
); }
);
}); });
} }
hookupTableCellDdls(ddlSelector) { hookupTableCellDdls(ddlSelector, changeHandler = (event, element) => { this.handleChangeTableCellDdl(event, element); }) {
this.hookupEventHandler("change", ddlSelector, (event, element) => { this.handleChangeTableCellDdl(event, element); }); this.hookupEventHandler("change", ddlSelector, (event, element) => { changeHandler(event, element); });
} }
handleClickTableCellDdlPreview(event, td, optionObjectList, cellSelector, ddlHookup = (event, element) => { this.hookupTableCellDdls(event, element); }) { handleClickTableCellDdlPreview(event, td, optionObjectList, cellSelector, ddlHookup = (cellSelector) => { this.hookupTableCellDdls(cellSelector); }) {
if (td.querySelector('select')) return; if (td.querySelector('select')) return;
// td.removeEventListener("click", ddlHookup); // td.removeEventListener("click", ddlHookup);
console.log("click table cell ddl preview"); console.log("click table cell ddl preview");
let tdNew = td.cloneNode(true); let tdNew = td.cloneNode(true);
td.parentNode.replaceChild(tdNew, td); td.parentNode.replaceChild(tdNew, td);
let idSelected = tdNew.getAttribute(attrValueCurrent); let idSelected = DOM.getElementAttributeValueCurrent(tdNew);
tdNew.innerHTML = ''; tdNew.innerHTML = '';
let ddl = document.createElement('select'); let ddl = document.createElement('select');
DOM.setElementValuesCurrentAndPrevious(ddl, DOM.getElementAttributeValueCurrent(tdNew)); DOM.setElementValuesCurrentAndPrevious(ddl, idSelected);
let optionJson, option; let optionJson, option;
console.log({optionObjectList, cellSelector}); console.log({optionObjectList, cellSelector});
option = DOM.createOption(null);
ddl.appendChild(option);
optionObjectList.forEach((optionObjectJson) => { optionObjectList.forEach((optionObjectJson) => {
optionJson = BusinessObjects.getOptionJsonFromObjectJson(optionObjectJson, idSelected); optionJson = BusinessObjects.getOptionJsonFromObjectJson(optionObjectJson, idSelected);
option = DOM.createOption(optionJson); option = DOM.createOption(optionJson);
@@ -450,14 +592,43 @@ export default class TableBasePage extends BasePage {
this.handleClickTableCellDdlPreview(event, td, optionList, cellSelector, (event, element) => { ddlHookup(event, element); }); this.handleClickTableCellDdlPreview(event, td, optionList, cellSelector, (event, element) => { ddlHookup(event, element); });
}); });
} }
hookupProductPermutationVariationFields() { hookupProductCategoryDdls(ddlSelector) {
this.hookupChangeHandlerTableCells(ddlSelector, (event, element) => { this.handleChangeProductCategoryDdl(event, element); });
}
handleChangeProductCategoryDdl(event, ddlCategory) {
this.handleChangeTableCellDdl(event, ddlCategory);
let idProductCategorySelected = DOM.getElementValueCurrent(ddlCategory);
let row = DOM.getRowFromElement(ddlCategory);
let tdProduct = row.querySelector('td.' + flagProduct);
tdProduct.dispatchEvent(new Event('click'));
let ddlProduct = row.querySelector('td.' + flagProduct + ' select');
ddlProduct.innerHTML = '';
ddlProduct.appendChild(DOM.createOption(null));
let optionJson, option;
Utils.getListFromDict(products).forEach((product) => {
if (idProductCategorySelected != '0' && product[attrIdProductCategory] != idProductCategorySelected) return;
optionJson = BusinessObjects.getOptionJsonFromObjectJson(product);
option = DOM.createOption(optionJson);
ddlProduct.appendChild(option);
});
this.handleChangeTableCellDdl(event, ddlProduct);
}
hookupFieldsProductPermutationVariation() {
this.hookupPreviewsProductPermutationVariation();
this.hookupDdlsProductPermutationVariation();
this.hookupDdlsProductPermutationVariationType();
this.hookupButtonsProductPermutationVariationAddDelete();
}
hookupPreviewsProductPermutationVariation() {
this.hookupEventHandler("click", idTableMain + ' td.' + flagProductVariations, (event, element) => this.handleClickProductPermutationVariationsPreview(event, element)); this.hookupEventHandler("click", idTableMain + ' td.' + flagProductVariations, (event, element) => this.handleClickProductPermutationVariationsPreview(event, element));
} }
handleClickProductPermutationVariationsPreview(event, element) { handleClickProductPermutationVariationsPreview(event, element) {
let tblVariations = element.querySelector('table.' + flagProductVariations);
if (!Validation.isEmpty(tblVariations)) return;
console.log("click product permutation variations preview"); console.log("click product permutation variations preview");
this.toggleColumnCollapsed(flagProductVariations, false); this.toggleColumnCollapsed(flagProductVariations, false);
let permutationVariations = this.getElementProductVariations(element); let permutationVariations = this.getElementProductVariations(element);
let tblVariations = document.createElement("table"); tblVariations = document.createElement("table");
tblVariations.classList.add(flagProductVariations); tblVariations.classList.add(flagProductVariations);
let thead = document.createElement("thead"); let thead = document.createElement("thead");
let tr = document.createElement("tr"); let tr = document.createElement("tr");
@@ -480,10 +651,7 @@ export default class TableBasePage extends BasePage {
tblVariations.appendChild(thead); tblVariations.appendChild(thead);
let tbody = document.createElement("tbody"); let tbody = document.createElement("tbody");
console.log('variations:', permutationVariations); console.log('variations:', permutationVariations);
if (Validation.isEmpty(permutationVariations)) { if (!Validation.isEmpty(permutationVariations)) {
permutationVariations = [PageStoreProductPermutations.createOptionUnselectedProductVariation()];
}
else {
permutationVariations.forEach((permutationVariation, index) => { permutationVariations.forEach((permutationVariation, index) => {
this.addProductPermutationVariationRow(tbody, permutationVariation); this.addProductPermutationVariationRow(tbody, permutationVariation);
}); });
@@ -494,10 +662,8 @@ export default class TableBasePage extends BasePage {
cellParent.innerHTML = ''; cellParent.innerHTML = '';
cellParent.appendChild(tblVariations); cellParent.appendChild(tblVariations);
console.log("tblVariations: ", tblVariations); console.log("tblVariations: ", tblVariations);
let selectorButtonAdd = idTableMain + ' td.' + flagProductVariations + ' button.' + flagAdd;
this.hookupEventHandler("click", selectorButtonAdd, this.handleClickButtonProductPermutationVariationsAdd); this.hookupFieldsProductPermutationVariation();
let selectorButtonDelete = idTableMain + ' td.' + flagProductVariations + ' button.' + flagDelete;
this.hookupEventHandler("click", selectorButtonDelete, this.handleClickButtonProductPermutationVariationsDelete);
} }
toggleColumnCollapsed(flagColumn, isCollapsed) { toggleColumnCollapsed(flagColumn, isCollapsed) {
this.toggleColumnHasClassnameFlag(flagColumn, isCollapsed, flagCollapsed); this.toggleColumnHasClassnameFlag(flagColumn, isCollapsed, flagCollapsed);
@@ -555,6 +721,19 @@ export default class TableBasePage extends BasePage {
let productVariationKeys = Object.keys(productVariations); let productVariationKeys = Object.keys(productVariations);
let productVariationTypeKeys = Object.keys(productVariationTypes); let productVariationTypeKeys = Object.keys(productVariationTypes);
let ddlsProductVariationType = tbody.querySelectorAll('select.' + flagProductVariationType);
let productVariationTypeKeysSelected = new Set();
let valueSelected;
let doFilterProductVariationKeys = permutationVariation[attrIdProductVariationType] != 0;
ddlsProductVariationType.forEach((ddlProductVariationType) => {
valueSelected = DOM.getElementValueCurrent(ddlProductVariationType);
productVariationTypeKeysSelected.add(valueSelected);
});
productVariationTypeKeys = productVariationTypeKeys.filter(typeKey => !productVariationTypeKeysSelected.has(typeKey));
if (productVariationTypeKeys.length == 0) return;
if (doFilterProductVariationKeys) {
productVariationKeys = productVariationKeys.filter(variationKey => !productVariationTypeKeysSelected.has(productVariations[variationKey][attrIdProductVariationType]));
}
console.log("permutationVariation: ", permutationVariation); console.log("permutationVariation: ", permutationVariation);
let permutationVariationJson = permutationVariation[flagProductVariation]; let permutationVariationJson = permutationVariation[flagProductVariation];
let permutationVariationTypeJson = permutationVariation[flagProductVariationType]; let permutationVariationTypeJson = permutationVariation[flagProductVariationType];
@@ -612,6 +791,7 @@ export default class TableBasePage extends BasePage {
buttonDelete.textContent = 'x'; buttonDelete.textContent = 'x';
let tr = document.createElement("tr"); let tr = document.createElement("tr");
tr.classList.add(flagProductVariation);
tdVariationType.appendChild(ddlVariationType); tdVariationType.appendChild(ddlVariationType);
tr.appendChild(tdVariationType); tr.appendChild(tdVariationType);
tdVariation.appendChild(ddlVariation); tdVariation.appendChild(ddlVariation);
@@ -620,13 +800,39 @@ export default class TableBasePage extends BasePage {
tr.appendChild(tdDelete); tr.appendChild(tdDelete);
tbody.appendChild(tr); tbody.appendChild(tr);
} }
handleClickButtonProductPermutationVariationsDelete(event, element) { hookupDdlsProductPermutationVariation() {
let row = getRowFromElement(element); this.hookupTableCellDdls(idTableMain + ' td.' + flagProductVariations + ' td.' + flagProductVariation);
let variationsCell = row.closest('td.' + flagProductVariations);
row.remove();
this.updateProductPermutationVariations(variationsCell);
} }
updateProductPermutationVariations(variationsCell) { hookupDdlsProductPermutationVariationType() {
this.hookupTableCellDdls(idTableMain + ' td.' + flagProductVariations + ' td.' + flagProductVariationType);
}
hookupButtonsProductPermutationVariationAddDelete() {
let selectorButton = idTableMain + ' td.' + flagProductVariations + ' tr.' + flagProductVariation + ' button';
let selectorButtonDelete = selectorButton + '.' + flagDelete;
let selectorButtonUndelete = selectorButton + '.' + flagAdd;
this.hookupButtonsRowDelete(selectorButtonDelete, selectorButtonUndelete, (event, element) => {
this.handleClickButtonRowDelete(event, element);
this.updateProductPermutationVariations(element);
});
this.hookupButtonsRowUndelete(selectorButtonDelete, selectorButtonUndelete);
this.hookupButtonsProductPermutationVariationAdd();
}
hookupButtonsProductPermutationVariationAdd() {
this.hookupEventHandler(
"click"
, idTableMain + ' td.' + flagProductVariations + ' button.' + flagAdd
, (event, element) => { this.handleClickButtonProductPermutationVariationAdd(event, element); }
);
}
handleClickButtonProductPermutationVariationAdd(event, element) {
let variationsCell = element.closest('td.' + flagProductVariations);
let tbody = variationsCell.querySelector('tbody');
let permutationVariation = TableBasePage.createOptionUnselectedProductVariation();
this.addProductPermutationVariationRow(tbody, permutationVariation);
this.hookupFieldsProductPermutationVariation();
}
updateProductPermutationVariations(element) {
let variationsCell = element.closest('td.' + flagProductVariations);
let variationPairsString = this.getProductPermutationVariationsText(variationsCell); let variationPairsString = this.getProductPermutationVariationsText(variationsCell);
variationsCell.setAttribute(attrValueCurrent, variationPairsString); variationsCell.setAttribute(attrValueCurrent, variationPairsString);
DOM.isElementDirty(variationsCell); DOM.isElementDirty(variationsCell);
@@ -662,7 +868,7 @@ export default class TableBasePage extends BasePage {
} }
toggleColumnHasClassnameFlag(columnFlag, isRequiredFlag, classnameFlag) { toggleColumnHasClassnameFlag(columnFlag, isRequiredFlag, classnameFlag) {
let table = this.getTableMain(); let table = TableBasePage.getTableMain();
let columnTh = table.querySelector('th.' + columnFlag); let columnTh = table.querySelector('th.' + columnFlag);
let columnThHasFlag = columnTh.classList.contains(classnameFlag); let columnThHasFlag = columnTh.classList.contains(classnameFlag);
if (isRequiredFlag == columnThHasFlag) return; if (isRequiredFlag == columnThHasFlag) return;
@@ -673,7 +879,7 @@ export default class TableBasePage extends BasePage {
}); });
} }
toggleColumnHeaderHasClassnameFlag(columnFlag, isRequiredFlag, classnameFlag) { toggleColumnHeaderHasClassnameFlag(columnFlag, isRequiredFlag, classnameFlag) {
let table = this.getTableMain(); let table = TableBasePage.getTableMain();
let columnTh = table.querySelector('th.' + columnFlag); let columnTh = table.querySelector('th.' + columnFlag);
DOM.toggleElementHasClassnameFlag(columnTh, isRequiredFlag, classnameFlag); DOM.toggleElementHasClassnameFlag(columnTh, isRequiredFlag, classnameFlag);
} }

View File

@@ -1,6 +1,6 @@
import API from "../../api.js"; import API from "../../api.js";
import BusinessObjects from "../../lib/business_objects.js"; import BusinessObjects from "../../lib/business_objects/business_objects.js";
import DOM from "../../dom.js"; import DOM from "../../dom.js";
import Events from "../../lib/events.js"; import Events from "../../lib/events.js";
import TableBasePage from "../base_table.js"; import TableBasePage from "../base_table.js";
@@ -8,11 +8,11 @@ import Utils from "../../lib/utils.js";
import Validation from "../../lib/validation.js"; import Validation from "../../lib/validation.js";
import StoreTableMixinPage from "./mixin_table.js"; import StoreTableMixinPage from "./mixin_table.js";
export default class PageStoreSupplierPurchaseOrders extends TableBasePage { export default class PageStoreManufacturingPurchaseOrders extends TableBasePage {
static hash = hashPageStoreSupplierPurchaseOrders; static hash = hashPageStoreManufacturingPurchaseOrders;
static attrIdRowObject = attrIdSupplierPurchaseOrder; static attrIdRowObject = attrIdManufacturingPurchaseOrder;
callFilterTableContent = API.getSupplierPurchaseOrdersByFilters; callFilterTableContent = API.getManufacturingPurchaseOrdersByFilters;
callSaveTableContent = API.saveSupplierPurchaseOrders; callSaveTableContent = API.saveManufacturingPurchaseOrders;
constructor(router) { constructor(router) {
super(router); super(router);
@@ -37,20 +37,53 @@ export default class PageStoreSupplierPurchaseOrders extends TableBasePage {
let inputCostTotalLocalVatIncl = row.querySelector('td.' + flagCostTotalLocalVatIncl + ' input'); let inputCostTotalLocalVatIncl = row.querySelector('td.' + flagCostTotalLocalVatIncl + ' input');
let inputPriceTotalLocalVatExcl = row.querySelector('td.' + flagPriceTotalLocalVatExcl + ' input'); let inputPriceTotalLocalVatExcl = row.querySelector('td.' + flagPriceTotalLocalVatExcl + ' input');
let inputPriceTotalLocalVatIncl = row.querySelector('td.' + flagPriceTotalLocalVatIncl + ' input'); let inputPriceTotalLocalVatIncl = row.querySelector('td.' + flagPriceTotalLocalVatIncl + ' input');
let tdItems = row.querySelector('td.' + flagItems); let tdItems = row.querySelector('td.' + flagOrderItems);
let checkboxActive = row.querySelector('td.' + flagActive + ' textarea'); let checkboxActive = row.querySelector('td.' + flagActive + ' textarea');
let jsonRow = {}; let jsonRow = {};
jsonRow[attrIdSupplierPurchaseOrder] = row.getAttribute(attrIdSupplierPurchaseOrder); jsonRow[attrIdManufacturingPurchaseOrder] = row.getAttribute(attrIdManufacturingPurchaseOrder);
jsonRow[attrIdCurrency] = DOM.getElementAttributeValueCurrent(tdCurrency); jsonRow[attrIdCurrency] = DOM.getElementAttributeValueCurrent(tdCurrency);
jsonRow[flagCostTotalLocalVatExcl] = DOM.getElementAttributeValueCurrent(inputCostTotalLocalVatExcl); jsonRow[flagCostTotalLocalVatExcl] = DOM.getElementAttributeValueCurrent(inputCostTotalLocalVatExcl);
jsonRow[flagCostTotalLocalVatIncl] = DOM.getElementAttributeValueCurrent(inputCostTotalLocalVatIncl); jsonRow[flagCostTotalLocalVatIncl] = DOM.getElementAttributeValueCurrent(inputCostTotalLocalVatIncl);
jsonRow[flagPriceTotalLocalVatExcl] = DOM.getElementAttributeValueCurrent(inputPriceTotalLocalVatExcl); jsonRow[flagPriceTotalLocalVatExcl] = DOM.getElementAttributeValueCurrent(inputPriceTotalLocalVatExcl);
jsonRow[flagPriceTotalLocalVatIncl] = DOM.getElementAttributeValueCurrent(inputPriceTotalLocalVatIncl); jsonRow[flagPriceTotalLocalVatIncl] = DOM.getElementAttributeValueCurrent(inputPriceTotalLocalVatIncl);
jsonRow[flagItems] = DOM.getElementAttributeValueCurrent(tdItems); // jsonRow[flagOrderItems] = DOM.getElementAttributeValueCurrent(tdItems);
let orderItems = [];
trsPurchaseOrderItem.forEach((tr) => {
orderItems.push(this.getJsonRowOrderItem(tr));
});
jsonRow[flagOrderItems] = orderItems;
jsonRow[flagActive] = DOM.getElementAttributeValueCurrent(checkboxActive); jsonRow[flagActive] = DOM.getElementAttributeValueCurrent(checkboxActive);
return jsonRow; return jsonRow;
} }
getJsonRowOrderItem(tr) {
let inputDisplayOrder = tr.querySelector('td.' + flagDisplayOrder + ' input');
let tdCategory = tr.querySelector('td.' + flagProductCategory);
let tdProduct = tr.querySelector('td.' + flagProduct);
let tdVariations = tr.querySelector('td.' + flagProductVariations);
let tdUnitQuantity = tr.querySelector('td.' + flagUnitMeasurementQuantity);
let inputQuantityUsed = tr.querySelector('td.' + flagQuantityUsed + ' input');
let inputQuantityProduced = tr.querySelector('td.' + flagQuantityProduced + ' input');
let inputLatencyManufacture = tr.querySelector('td.' + flagLatencyManufacture + ' input');
let checkboxActive = tr.querySelector('td.' + flagActive + ' input');
let jsonRow = {};
jsonRow[attrIdManufacturingPurchaseOrder] = tr.getAttribute(attrIdManufacturingPurchaseOrder);
jsonRow[attrIdManufacturingPurchaseOrderProductLink] = tr.getAttribute(attrIdManufacturingPurchaseOrderProductLink);
jsonRow[flagDisplayOrder] = DOM.getElementAttributeValueCurrent(inputDisplayOrder);
jsonRow[attrIdProductCategory] = DOM.getElementAttributeValueCurrent(tdCategory);
jsonRow[attrIdProduct] = DOM.getElementAttributeValueCurrent(tdProduct);
jsonRow[flagProductVariations] = DOM.getElementAttributeValueCurrent(tdVariations);
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);
return jsonRow;
}
initialiseRowNew(row) { initialiseRowNew(row) {
super.initialiseRowNew(row); super.initialiseRowNew(row);
} }
@@ -60,7 +93,7 @@ export default class PageStoreSupplierPurchaseOrders extends TableBasePage {
this.hookupCurrencyFields(); this.hookupCurrencyFields();
this.hookupCostInputs(); this.hookupCostInputs();
this.hookupOrderItemsFields(); this.hookupOrderItemsFields();
this.hookupActiveCheckboxes(); this.hookupInputsActiveTable();
} }
hookupCostInputs() { hookupCostInputs() {
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagCostTotalLocalVatExcl + ' input'); this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagCostTotalLocalVatExcl + ' input');
@@ -69,10 +102,390 @@ export default class PageStoreSupplierPurchaseOrders extends TableBasePage {
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagPriceTotalLocalVatIncl + ' input'); this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagPriceTotalLocalVatIncl + ' input');
} }
hookupOrderItemsFields() { hookupOrderItemsFields() {
this.hookupOrderItemsPreviews();
this.hookupFieldsOrderItemDisplayOrder();
this.hookupFieldsOrderItemProductCategory();
this.hookupFieldsOrderItemProduct();
this.hookupFieldsOrderItemProductVariations();
this.hookupFieldsOrderItemUnitQuantity();
this.hookupFieldsOrderItemQuantityUsed();
this.hookupFieldsOrderItemQuantityProduced();
this.hookupFieldsOrderItemCostTotalLocalVatExcl();
this.hookupFieldsOrderItemCostTotalLocalVatIncl();
this.hookupFieldsOrderItemLatencyManufacture();
this.hookupFieldsOrderItemActive();
this.hookupFieldsOrderItemAddDelete();
this.hookupButtonsOrderItemAdd();
} }
hookupActiveCheckboxes(){ hookupOrderItemsPreviews() {
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagActive + ' input'); this.hookupEventHandler("click", idTableMain + ' td.' + flagOrderItems, (event, td) => {
if (!td.classList.contains(flagCollapsed)) return;
this.handleClickOrderItemsPreview(event, td);
});
}
handleClickOrderItemsPreview(event, element) {
console.log("click order items preview");
this.toggleColumnHeaderCollapsed(flagOrderItems, false);
element.classList.remove(flagCollapsed);
let row = DOM.getRowFromElement(element);
let idManufacturingPurchaseOrder = row.getAttribute(attrIdManufacturingPurchaseOrder);
let manufacturingPurchaseOrderProductLinksList = idManufacturingPurchaseOrder > 0 ? manufacturingPurchaseOrderProductLinks[idManufacturingPurchaseOrder] : [];
let tblOrderItems = document.createElement("table");
tblOrderItems.classList.add(flagOrderItems);
let thead = document.createElement("thead");
let tr = document.createElement("tr");
let thDisplayOrder = document.createElement("th");
thDisplayOrder.classList.add(flagDisplayOrder);
thDisplayOrder.textContent = 'Display Order';
let thCategory = document.createElement("th");
thCategory.classList.add(flagProductCategory);
thCategory.textContent = 'Category';
let thProduct = document.createElement("th");
thProduct.classList.add(flagProduct);
thProduct.textContent = 'Product';
let thVariations = document.createElement("th");
thVariations.classList.add(flagProductVariations);
thVariations.classList.add(flagCollapsed);
thVariations.textContent = 'Variations';
let thUnitQuantity = document.createElement("th");
thUnitQuantity.classList.add(flagUnitMeasurementQuantity);
thUnitQuantity.textContent = 'Unit Quantity';
let thQuantityUsed = document.createElement("th");
thQuantityUsed.classList.add(flagQuantityUsed);
thQuantityUsed.textContent = 'Quantity Ordered';
let thQuantityProduced = document.createElement("th");
thQuantityProduced.classList.add(flagQuantityProduced);
thQuantityProduced.textContent = 'Quantity Received';
let thCostTotalLocalVatExcl = document.createElement("th");
thCostTotalLocalVatExcl.classList.add(flagCostTotalLocalVatExcl);
thCostTotalLocalVatExcl.textContent = 'Cost Total Local VAT Excl';
let thCostTotalLocalVatIncl = document.createElement("th");
thCostTotalLocalVatIncl.classList.add(flagCostTotalLocalVatIncl);
thCostTotalLocalVatIncl.textContent = 'Cost Total Local VAT Incl';
let thCostUnitLocalVatExcl = document.createElement("th");
thCostUnitLocalVatExcl.classList.add(flagCostUnitLocalVatExcl);
thCostUnitLocalVatExcl.textContent = 'Cost Unit Local VAT Excl';
let thCostUnitLocalVatIncl = document.createElement("th");
thCostUnitLocalVatIncl.classList.add(flagCostUnitLocalVatIncl);
thCostUnitLocalVatIncl.textContent = 'Cost Unit Local VAT Incl';
let thLatencyManufacture = document.createElement("th");
thLatencyManufacture.classList.add(flagLatencyManufacture);
thLatencyManufacture.textContent = 'Latency Delivery (Days)';
let thActive = document.createElement("th");
thActive.classList.add(flagActive);
thActive.textContent = 'Active';
let thAddDelete = document.createElement("th");
thAddDelete.classList.add(flagAdd);
let buttonAdd = document.createElement("button");
buttonAdd.classList.add(flagAdd);
buttonAdd.textContent = '+';
thAddDelete.appendChild(buttonAdd);
tr.appendChild(thDisplayOrder);
tr.appendChild(thCategory);
tr.appendChild(thProduct);
tr.appendChild(thVariations);
tr.appendChild(thUnitQuantity);
tr.appendChild(thQuantityUsed);
tr.appendChild(thQuantityProduced);
tr.appendChild(thCostTotalLocalVatExcl);
tr.appendChild(thCostTotalLocalVatIncl);
tr.appendChild(thCostUnitLocalVatExcl);
tr.appendChild(thCostUnitLocalVatIncl);
tr.appendChild(thLatencyManufacture);
tr.appendChild(thActive);
tr.appendChild(thAddDelete);
thead.appendChild(tr);
tblOrderItems.appendChild(thead);
let tbody = document.createElement("tbody");
manufacturingPurchaseOrderProductLinksList.forEach((orderItem, index) => {
this.addRowManufacturingPurchaseOrderItem(tbody, orderItem);
});
tblOrderItems.appendChild(tbody);
let cell = DOM.getCellFromElement(element);
let cellNew = cell.cloneNode(false);
cellNew.appendChild(tblOrderItems);
row.replaceChild(cellNew, cell);
console.log("tblOrderItems: ", tblOrderItems);
this.hookupOrderItemsFields();
}
addRowManufacturingPurchaseOrderItem(tbody, orderItem) { // productVariationTypeOptions, productVariationOptions, productCategoryOptions, productOptions, unitMeasurementOptions,
console.log("addRowManufacturingPurchaseOrderItem: ", orderItem);
let tdDisplayOrder = document.createElement("td");
tdDisplayOrder.classList.add(flagDisplayOrder);
let inputDisplayOrder = document.createElement("input");
inputDisplayOrder.classList.add(flagDisplayOrder);
inputDisplayOrder.type = 'number';
inputDisplayOrder.step = 1;
DOM.setElementValuesCurrentAndPrevious(inputDisplayOrder, orderItem[flagDisplayOrder]);
tdDisplayOrder.appendChild(inputDisplayOrder);
let tdCategory = document.createElement("td");
tdCategory.classList.add(flagProductCategory);
DOM.setElementAttributesValuesCurrentAndPrevious(tdCategory, orderItem[attrIdProductCategory]);
let divCategory = document.createElement("div");
divCategory.classList.add(flagProductCategory);
// DOM.setElementAttributesValuesCurrentAndPrevious(divCategory, orderItem[attrIdProductCategory]);
divCategory.textContent = orderItem[flagProductCategory];
tdCategory.appendChild(divCategory);
let tdProduct = document.createElement("td");
tdProduct.classList.add(flagProduct);
DOM.setElementAttributesValuesCurrentAndPrevious(tdProduct, orderItem[attrIdProductCategory]);
let divProduct = document.createElement("div");
divProduct.classList.add(flagProduct);
// DOM.setElementAttributesValuesCurrentAndPrevious(divProduct, orderItem[attrIdProduct]);
divProduct.textContent = orderItem[flagProduct];
tdProduct.appendChild(divProduct);
let tdVariations = document.createElement("td");
tdVariations.classList.add(flagProductVariations);
DOM.setElementAttributesValuesCurrentAndPrevious(tdVariations, orderItem[attrIdProductCategory]);
let divVariations = document.createElement("div");
divVariations.classList.add(flagProductVariations);
// DOM.setElementAttributesValuesCurrentAndPrevious(divVariations, orderItem[attrIdProductVariation]);
divVariations.textContent = orderItem[flagProductVariations];
tdVariations.appendChild(divVariations);
let tdUnitQuantity = document.createElement("td");
tdUnitQuantity.classList.add(flagUnitMeasurementQuantity);
DOM.setElementAttributesValuesCurrentAndPrevious(tdUnitQuantity, orderItem[attrIdProductCategory]);
let divUnitQuantity = document.createElement("div");
divUnitQuantity.classList.add(flagUnitMeasurementQuantity);
// DOM.setElementValuesCurrentAndPrevious(divUnitQuantity, orderItem[flagUnitMeasurementQuantity]);
tdUnitQuantity.appendChild(divUnitQuantity);
let tdQuantityUsed = document.createElement("td");
tdQuantityUsed.classList.add(flagQuantityUsed);
let inputQuantityUsed = document.createElement("input");
inputQuantityUsed.classList.add(flagQuantityUsed);
inputQuantityUsed.type = 'number';
DOM.setElementAttributesValuesCurrentAndPrevious(inputQuantityUsed, orderItem[flagQuantityUsed]);
tdQuantityUsed.appendChild(inputQuantityUsed);
let tdQuantityProduced = document.createElement("td");
tdQuantityProduced.classList.add(flagQuantityProduced);
let inputQuantityProduced = document.createElement("input");
inputQuantityProduced.classList.add(flagQuantityProduced);
inputQuantityProduced.type = 'number';
DOM.setElementAttributesValuesCurrentAndPrevious(inputQuantityProduced, orderItem[flagQuantityProduced]);
tdQuantityProduced.appendChild(inputQuantityProduced);
let tdCostTotalLocalVatExcl = document.createElement("td");
tdCostTotalLocalVatExcl.classList.add(flagCostTotalLocalVatExcl);
let inputCostTotalLocalVatExcl = document.createElement("input");
inputCostTotalLocalVatExcl.classList.add(flagCostTotalLocalVatExcl);
inputCostTotalLocalVatExcl.type = 'number';
inputCostTotalLocalVatExcl.step = 0.01;
DOM.setElementAttributesValuesCurrentAndPrevious(inputCostTotalLocalVatExcl, orderItem[flagCostTotalLocalVatExcl]);
tdCostTotalLocalVatExcl.appendChild(inputCostTotalLocalVatExcl);
let tdCostTotalLocalVatIncl = document.createElement("td");
tdCostTotalLocalVatIncl.classList.add(flagCostTotalLocalVatIncl);
let inputCostTotalLocalVatIncl = document.createElement("input");
inputCostTotalLocalVatIncl.classList.add(flagCostTotalLocalVatIncl);
inputCostTotalLocalVatIncl.type = 'number';
inputCostTotalLocalVatIncl.step = 0.01;
DOM.setElementAttributesValuesCurrentAndPrevious(inputCostTotalLocalVatIncl, orderItem[flagCostTotalLocalVatIncl]);
tdCostTotalLocalVatIncl.appendChild(inputCostTotalLocalVatIncl);
let tdCostUnitLocalVatExcl = document.createElement("td");
tdCostUnitLocalVatExcl.classList.add(flagCostUnitLocalVatExcl);
let divCostUnitLocalVatExcl = document.createElement("div");
divCostUnitLocalVatExcl.classList.add(flagCostUnitLocalVatExcl);
DOM.setElementValuesCurrentAndPrevious(divCostUnitLocalVatExcl, orderItem[flagCostUnitLocalVatExcl]);
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]);
tdCostUnitLocalVatIncl.appendChild(divCostUnitLocalVatIncl);
let tdLatencyManufacture = document.createElement("td");
tdLatencyManufacture.classList.add(flagLatencyManufacture);
let inputLatencyManufacture = document.createElement("input");
inputLatencyManufacture.classList.add(flagLatencyManufacture);
inputLatencyManufacture.type = 'number';
inputLatencyManufacture.step = 1;
DOM.setElementAttributesValuesCurrentAndPrevious(inputLatencyManufacture, orderItem[flagLatencyManufacture]);
tdLatencyManufacture.appendChild(inputLatencyManufacture);
let tdActive = document.createElement("td");
tdActive.classList.add(flagActive);
let checkboxActive = document.createElement("input");
checkboxActive.classList.add(flagActive);
checkboxActive.type = 'checkbox';
DOM.setElementValuesCurrentAndPrevious(checkboxActive, orderItem[flagActive]);
tdActive.appendChild(checkboxActive);
let tdDelete = document.createElement("td");
tdDelete.classList.add(flagDelete);
let buttonDelete = document.createElement("button");
buttonDelete.classList.add(flagDelete);
buttonDelete.textContent = 'x';
tdDelete.appendChild(buttonDelete);
let tr = document.createElement("tr");
tr.classList.add(flagOrderItems);
tr.setAttribute(attrIdManufacturingPurchaseOrder, orderItem[attrIdManufacturingPurchaseOrder]);
tr.setAttribute(attrIdManufacturingPurchaseOrderProductLink, orderItem[attrIdManufacturingPurchaseOrderProductLink]);
tr.appendChild(tdDisplayOrder);
tr.appendChild(tdCategory);
tr.appendChild(tdProduct);
tr.appendChild(tdVariations);
tr.appendChild(tdUnitQuantity);
tr.appendChild(tdQuantityUsed);
tr.appendChild(tdQuantityProduced);
tr.appendChild(tdCostTotalLocalVatExcl);
tr.appendChild(tdCostTotalLocalVatIncl);
tr.appendChild(tdCostUnitLocalVatExcl);
tr.appendChild(tdCostUnitLocalVatIncl);
tr.appendChild(tdLatencyManufacture);
tr.appendChild(tdActive);
tr.appendChild(tdDelete);
tbody.appendChild(tr);
}
hookupFieldsOrderItemDisplayOrder() {
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagOrderItems + ' td.' + flagDisplayOrder + ' input');
}
hookupFieldsOrderItemProductCategory() {
this.hookupTableCellDdlPreviews(
idTableMain + ' td.' + flagOrderItems + ' td.' + flagProductCategory
, Utils.getListFromDict(productCategories)
, (cellSelector) => { this.hookupProductCategoryDdls(cellSelector); }
);
}
hookupFieldsOrderItemProduct() {
this.hookupTableCellDdlPreviews(idTableMain + ' td.' + flagOrderItems + ' td.' + flagProduct, Utils.getListFromDict(products));
}
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));
}
hookupFieldsOrderItemQuantityUsed() {
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagOrderItems + ' td.' + flagQuantityUsed + ' input');
}
hookupFieldsOrderItemQuantityProduced() {
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagOrderItems + ' td.' + flagQuantityProduced + ' input');
}
hookupFieldsOrderItemPriceTotalLocalVatExcl() {
this.hookupChangeHandlerTableCells(
idTableMain + ' td.' + flagOrderItems + ' td.' + flagPriceTotalLocalVatExcl + ' input'
, (event, element) => {
this.handleChangeNestedElementCellTable(event, element);
this.updateFieldsPriceUnitLocalVatExcl(element);
}
);
}
hookupFieldsOrderItemPriceTotalLocalVatIncl() {
this.hookupChangeHandlerTableCells(
idTableMain + ' td.' + flagOrderItems + ' td.' + flagPriceTotalLocalVatIncl + ' input'
, (event, element) => {
this.handleChangeNestedElementCellTable(event, element);
this.updateFieldsPriceUnitLocalVatIncl(element);
}
);
}
updateFieldsPriceUnitLocalVatExcl(elementChanged) {
let row = elementChanged.closest('tr.' + flagOrderItems);
let inputPriceTotalLocalVatExcl = row.querySelector('td.' + flagPriceTotalLocalVatExcl + ' input');
let priceTotalLocalVatExcl = DOM.getElementValueCurrent(inputPriceTotalLocalVatExcl);
let inputQuantityUsed = row.querySelector('td.' + flagQuantityUsed + ' input');
let quantityUsed = DOM.getElementValueCurrent(inputQuantityUsed);
let divPriceUnitLocalVatExcl = row.querySelector('td.' + flagPriceUnitLocalVatExcl + ' div');
let priceUnitLocalVatExcl = quantityUsed == 0 ? 0 : priceTotalLocalVatExcl / quantityUsed;
DOM.setElementValuesCurrentAndPrevious(divPriceUnitLocalVatExcl, priceUnitLocalVatExcl);
let rowManufacturingPurchaseOrder = row.closest(idTableMain + ' > tbody > tr');
let divPriceGrandTotalLocalVatExcl = rowManufacturingPurchaseOrder.querySelector('td.' + flagPriceTotalLocalVatExcl + ' div');
let inputsPriceTotalLocalVatExcl = rowManufacturingPurchaseOrder.querySelectorAll('td.' + flagOrderItems + ' td.' + flagPriceTotalLocalVatExcl + ' input');
let priceGrandTotalLocalVatExcl = Array.from(inputsPriceTotalLocalVatExcl).reduce((acc, input) => acc + Number(DOM.getElementValueCurrent(input)), 0);
DOM.setElementValueCurrent(divPriceGrandTotalLocalVatExcl, priceGrandTotalLocalVatExcl);
}
updateFieldsPriceUnitLocalVatIncl(elementChanged) {
let row = elementChanged.closest('tr.' + flagOrderItems);
let inputPriceTotalLocalVatIncl = row.querySelector('td.' + flagPriceTotalLocalVatIncl + ' input');
let priceTotalLocalVatIncl = DOM.getElementValueCurrent(inputPriceTotalLocalVatIncl);
let inputQuantityUsed = row.querySelector('td.' + flagQuantityUsed + ' input');
let quantityUsed = DOM.getElementValueCurrent(inputQuantityUsed);
let divPriceUnitLocalVatIncl = row.querySelector('td.' + flagPriceUnitLocalVatIncl + ' div');
let priceUnitLocalVatIncl = quantityUsed == 0 ? 0 : priceTotalLocalVatIncl / quantityUsed;
DOM.setElementValuesCurrentAndPrevious(divPriceUnitLocalVatIncl, priceUnitLocalVatIncl);
let rowManufacturingPurchaseOrder = row.closest(idTableMain + ' > tbody > tr');
let divPriceGrandTotalLocalVatIncl = rowManufacturingPurchaseOrder.querySelector('td.' + flagPriceTotalLocalVatIncl + ' div');
let inputsPriceTotalLocalVatIncl = rowManufacturingPurchaseOrder.querySelectorAll('td.' + flagOrderItems + ' td.' + flagPriceTotalLocalVatIncl + ' input');
let priceGrandTotalLocalVatIncl = Array.from(inputsPriceTotalLocalVatIncl).reduce((acc, input) => acc + Number(DOM.getElementValueCurrent(input)), 0);
DOM.setElementValueCurrent(divPriceGrandTotalLocalVatIncl, priceGrandTotalLocalVatIncl);
}
hookupFieldsOrderItemPriceUnitLocalVatExcl() {
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagOrderItems + ' td.' + flagPriceUnitLocalVatExcl + ' input');
}
hookupFieldsOrderItemPriceUnitLocalVatIncl() {
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagOrderItems + ' td.' + flagPriceUnitLocalVatIncl + ' input');
}
hookupFieldsOrderItemUnitMeasurementLatencyManufacture() {
this.hookupTableCellDdlPreviews(idTableMain + ' td.' + flagOrderItems + ' td.' + flagUnitMeasurementLatencyManufacture, Utils.getListFromDict(unitMeasurementsTime));
}
hookupFieldsOrderItemLatencyManufacture() {
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagOrderItems + ' td.' + flagLatencyManufacture + ' input');
}
hookupFieldsOrderItemActive() {
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagOrderItems + ' input.' + flagActive);
}
hookupFieldsOrderItemAddDelete() {
let selectorButton = idTableMain + ' td.' + flagOrderItems + ' td.' + flagOrderItems + ' button';
let selectorButtonDelete = selectorButton + '.' + flagDelete;
let selectorButtonUndelete = selectorButton + '.' + flagAdd;
this.hookupButtonsRowDelete(selectorButtonDelete, selectorButtonUndelete);
this.hookupButtonsRowUndelete(selectorButtonDelete, selectorButtonUndelete);
this.hookupButtonsOrderItemAdd();
}
hookupButtonsOrderItemAdd() {
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 manufacturingPurchaseOrderItem = {
[attrIdManufacturingPurchaseOrder]: idManufacturingPurchaseOrder,
[attrIdManufacturingPurchaseOrderProductLink]: -1 - countManufacturingOrderItemes,
[attrIdProductCategory]: 0,
[attrIdProduct]: 0,
[flagProductVariations]: '',
[attrIdUnitMeasurementQuantity]: 0,
[flagQuantityUsed]: '',
[flagQuantityProduced]: '',
[attrIdUnitMeasurementLatencyManufacture]: 0,
[flagLatencyManufacture]: '',
[flagDisplayOrder]: countManufacturingOrderItems + 1,
[flagActive]: !hasActiveOrderItem,
};
let tbody = row.querySelector('td.' + flagOrderItems + ' table tbody');
this.addRowManufacturingOrderItem(tbody, manufacturingPurchaseOrderItem);
/*
if (!hasActiveOrderItem) {
let tdOrderItem = row.querySelector('td.' + flagOrderItems);
// tdOrderItem.setAttribute(attrIdManufacturingOrderItem, manufacturingPurchaseOrderItem[attrIdManufacturingOrderItem]);
DOM.setElementAttributeValueCurrent(tdOrderItem, manufacturingPurchaseOrderItem[attrIdManufacturingOrderItem]);
}
*/
this.hookupOrderItemsFields();
});
} }
leave() { leave() {

Some files were not shown because too many files have changed in this diff Show More