feat(JavaScript): Updated architecture for TableBasePage object with static row ID attribute attached for adding ID against each row added to DOM

This commit is contained in:
2024-10-18 22:25:07 +01:00
parent 8fcfcf0ef4
commit 002551c0a9
112 changed files with 7280 additions and 3608 deletions

View File

@@ -26,6 +26,7 @@ JavaScript
page
api
router
base - navigation buttons
MySQL
get
save

Binary file not shown.

4
app.py
View File

@@ -40,11 +40,13 @@ import lib.argument_validation as av
from controllers.core import routes_core
from controllers.legal import routes_legal
from controllers.store.store import routes_store
from controllers.store.manufacturing_purchase_order import routes_store_manufacturing_purchase_order
from controllers.store.product import routes_store_product
from controllers.store.product_category import routes_store_product_category
from controllers.store.product_permutation import routes_store_product_permutation
from controllers.store.stock_item import routes_store_stock_item
from controllers.store.supplier import routes_store_supplier
from controllers.store.supplier_purchase_order import routes_store_supplier_purchase_order
from controllers.user import routes_user
# external
from flask import Flask, render_template, jsonify, request, render_template_string, send_from_directory, redirect, url_for, session
@@ -125,11 +127,13 @@ with app.app_context():
app.register_blueprint(routes_core)
app.register_blueprint(routes_legal)
app.register_blueprint(routes_store)
app.register_blueprint(routes_store_manufacturing_purchase_order)
app.register_blueprint(routes_store_product)
app.register_blueprint(routes_store_product_category)
app.register_blueprint(routes_store_product_permutation)
app.register_blueprint(routes_store_stock_item)
app.register_blueprint(routes_store_supplier)
app.register_blueprint(routes_store_supplier_purchase_order)
app.register_blueprint(routes_user)

View File

@@ -17,7 +17,7 @@ from business_objects.region import Region
from extensions import db
# external
from typing import ClassVar
from flask import jsonify
class Address(db.Model, Base):
FLAG_ADDRESS_LINE_1: ClassVar[str] = 'address_line_1'
@@ -59,6 +59,12 @@ class Address(db.Model, Base):
address.id_address = query_row[6]
address.id_region = query_row[7]
return address
@classmethod
def from_DB_supplier(cls, query_row):
address = cls()
address.id_address = query_row[1]
address.postcode = query_row[2]
return address
def __repr__(self):
return f'''
{self.ATTR_ID_ADDRESS}: {self.id_address}
@@ -82,6 +88,8 @@ class Address(db.Model, Base):
self.FLAG_COUNTY: self.county,
self.FLAG_ACTIVE: 1 if av.input_bool(self.active, self.FLAG_ACTIVE, f'{self.__class__.__name__}.to_json') else 0
}
def to_json_str(self):
return jsonify(self.to_json())
@classmethod
def from_json(cls, json):
print(f'{cls.__name__}.from_json: {json}')

View File

@@ -27,14 +27,22 @@ class Base():
FLAG_ACCESS_LEVEL_REQUIRED: ClassVar[str] = 'access_level_required'
FLAG_ACTIVE: ClassVar[str] = 'active'
FLAG_ADDRESS: ClassVar[str] = 'address'
FLAG_ADDRESS_LINE_1: ClassVar[str] = 'address_line_1'
FLAG_ADDRESS_LINE_2: ClassVar[str] = 'address_line_2'
FLAG_CAN_ADMIN: ClassVar[str] = 'can_admin'
FLAG_CAN_EDIT: ClassVar[str] = 'can_edit'
FLAG_CAN_VIEW: ClassVar[str] = 'can_view'
FLAG_CITY: ClassVar[str] = 'city'
FLAG_CODE: ClassVar[str] = 'code'
FLAG_COUNTY: ClassVar[str] = 'county'
FLAG_CREATED_ON: ClassVar[str] = 'created_on'
FLAG_CURRENCY: ClassVar[str] = 'currency'
FLAG_CURRENCY_COST: ClassVar[str] = 'currency_cost'
FLAG_DATE_FROM: ClassVar[str] = 'date_from'
FLAG_DATE_TO: ClassVar[str] = 'date_to'
FLAG_DESCRIPTION: ClassVar[str] = 'description'
FLAG_DISPLAY_ORDER: ClassVar[str] = 'display_order'
FLAG_EDIT: ClassVar[str] = 'edit'
FLAG_EMAIL: ClassVar[str] = 'email'
FLAG_FAX: ClassVar[str] = 'fax'
FLAG_GUID: ClassVar[str] = 'guid'

View File

@@ -90,6 +90,15 @@ class Currency(db.Model, Store_Base):
currency.code = query_row[13]
currency.symbol = query_row[14]
return currency
@classmethod
def from_DB_supplier(cls, query_row):
_m = 'Currency.from_DB_supplier'
v_arg_type = 'class attribute'
currency = cls()
currency.id_currency = query_row[1]
currency.symbol = query_row[2]
currency.code = query_row[3]
return currency
def __repr__(self):
return f'''
id: {self.id_currency}

View File

@@ -32,13 +32,18 @@ class Region(db.Model, Base):
def __init__(self):
super().__init__()
Base.__init__(self)
self.region = None
@classmethod
def from_DB_stock_item(cls, query_row):
plant = cls()
plant.id_region = query_row[7]
return plant
region = cls()
region.id_region = query_row[7]
return region
@classmethod
def from_DB_supplier(cls, query_row):
region = cls()
region.id_region = query_row[2]
region.name = query_row[3]
return region
def __repr__(self):
return f'''
{self.ATTR_ID_REGION}: {self.id_region}
@@ -78,5 +83,4 @@ class Region(db.Model, Base):
region.code = query_row[1]
region.name = query_row[2]
region.active = av.input_bool(query_row[3], cls.FLAG_ACTIVE, f'{cls.__name__}.from_DB_region')
region.display_order = query_row[4]
return region

View File

@@ -0,0 +1,313 @@
"""
Project: PARTS Website
Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: Business Objects
Feature: Manufacturing_Purchase_Order Business Object
Description:
Business object for manufacturing_purchase_order
"""
# internal
import lib.argument_validation as av
from business_objects.db_base import Get_Many_Parameters_Base
from business_objects.store.store_base import Store_Base
from extensions import db
# external
from pydantic import BaseModel
from typing import ClassVar, Optional
from datetime import datetime
class Manufacturing_Purchase_Order(db.Model, Store_Base):
NAME_ATTR_OPTION_VALUE: ClassVar[str] = Store_Base.ATTR_ID_MANUFACTURING_PURCHASE_ORDER
NAME_ATTR_OPTION_TEXT: ClassVar[str] = Store_Base.FLAG_NAME
# __tablename__ = 'Shop_Manufacturing_Purchase_Order_Temp'
id_order = db.Column(db.Integer, primary_key=True)
id_currency = db.Column(db.Integer)
cost_total_local_VAT_excl = db.Column(db.Float)
cost_total_local_VAT_incl = db.Column(db.Float)
price_total_local_VAT_excl = db.Column(db.Float)
price_total_local_VAT_incl = db.Column(db.Float)
active = db.Column(db.Boolean)
created_on = db.Column(db.DateTime)
created_by = db.Column(db.Integer)
name = db.Column(db.String(255))
# items: list = None
def __init__(self):
super().__init__()
Store_Base.__init__(self)
self.items = None
@classmethod
def from_DB_manufacturing_purchase_order(cls, query_row):
manufacturing_purchase_order = cls()
manufacturing_purchase_order.id_order = query_row[0]
manufacturing_purchase_order.id_currency = query_row[1]
manufacturing_purchase_order.cost_total_local_VAT_excl = query_row[2]
manufacturing_purchase_order.cost_total_local_VAT_incl = query_row[3]
manufacturing_purchase_order.price_total_local_VAT_excl = query_row[4]
manufacturing_purchase_order.price_total_local_VAT_incl = query_row[5]
manufacturing_purchase_order.active = av.input_bool(query_row[6], 'active', f'{cls.__name__}.from_DB_manufacturing_purchase_order')
manufacturing_purchase_order.created_on = query_row[7]
manufacturing_purchase_order.name = query_row[8]
return manufacturing_purchase_order
def __repr__(self):
return f'''
{self.ATTR_ID_MANUFACTURING_PURCHASE_ORDER}: {self.id_order},
{self.ATTR_ID_CURRENCY}: {self.id_currency},
{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_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_ACTIVE}: {self.active},
{self.FLAG_CREATED_ON}: {self.created_on},
{self.FLAG_NAME}: {self.name}
'''
def to_json(self):
return {
**self.get_shared_json_attributes(self),
self.ATTR_ID_MANUFACTURING_PURCHASE_ORDER: self.id_order,
self.ATTR_ID_CURRENCY: self.id_currency,
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_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_ACTIVE: av.input_bool(self.active, self.FLAG_ACTIVE, f'{self.__class__.__name__}.to_json'),
self.FLAG_CREATED_ON: self.created_on,
self.FLAG_NAME: self.name,
}
def to_json_option(self):
return {
'value': self.id_order,
'text': self.name,
}
@classmethod
def from_json(cls, json):
print(f'{cls.__name__}.from_json: {json}')
manufacturing_purchase_order = cls()
manufacturing_purchase_order.id_order = json[cls.ATTR_ID_MANUFACTURING_PURCHASE_ORDER]
manufacturing_purchase_order.id_currency = json[cls.ATTR_ID_CURRENCY]
manufacturing_purchase_order.cost_total_local_VAT_excl = json[cls.FLAG_COST_TOTAL_LOCAL_VAT_EXCL]
manufacturing_purchase_order.cost_total_local_VAT_incl = json[cls.FLAG_COST_TOTAL_LOCAL_VAT_INCL]
manufacturing_purchase_order.price_total_local_VAT_excl = json[cls.FLAG_PRICE_TOTAL_LOCAL_VAT_EXCL]
manufacturing_purchase_order.price_total_local_VAT_incl = json[cls.FLAG_PRICE_TOTAL_LOCAL_VAT_INCL]
manufacturing_purchase_order.active = json[cls.FLAG_ACTIVE]
manufacturing_purchase_order.created_on = json[cls.FLAG_CREATED_ON]
manufacturing_purchase_order.name = json[cls.FLAG_NAME]
return manufacturing_purchase_order
def get_items_preview_str(self):
preview = ''
if self.items is not None:
for item in self.items:
if preview != '':
preview += '\n'
preview += f'{item.name_permutation}{f" -(x{item.quantity_used})" if item.quantity_used > 0 else ""}{f" +(x{item.quantity_produced})" if item.quantity_produced > 0 else ""}'
return preview
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_USED: ClassVar[str] = 'quantity_used'
NAME_ATTR_OPTION_VALUE: ClassVar[str] = Store_Base.ATTR_ID_MANUFACTURING_PURCHASE_ORDER_PRODUCT_LINK
NAME_ATTR_OPTION_TEXT: ClassVar[str] = Store_Base.FLAG_NAME
# __tablename__ = 'Shop_Manufacturing_Purchase_Order_Temp'
id_link = db.Column(db.Integer, primary_key=True)
id_order = db.Column(db.Integer)
id_permutation = db.Column(db.Integer)
id_unit_quantity = db.Column(db.Integer)
name_permutation = db.Column(db.String(255))
quantity_used = db.Column(db.Float)
quantity_produced = db.Column(db.Float)
latency_manufacture_days = db.Column(db.Integer)
display_order = db.Column(db.Integer)
cost_unit_local_VAT_excl = db.Column(db.Float)
cost_unit_local_VAT_incl = db.Column(db.Float)
price_unit_local_VAT_excl = db.Column(db.Float)
price_unit_local_VAT_incl = db.Column(db.Float)
active = db.Column(db.Boolean)
created_on = db.Column(db.DateTime)
created_by = db.Column(db.Integer)
def __init__(self):
super().__init__()
Store_Base.__init__(self)
@classmethod
def from_DB_manufacturing_purchase_order(cls, query_row):
link = cls()
link.id_link = query_row[0]
link.id_order = query_row[1]
link.id_permutation = query_row[2]
link.name_permutation = query_row[3]
link.id_unit_quantity = query_row[4]
link.quantity_used = query_row[5]
link.quantity_produced = query_row[6]
link.latency_manufacture_days = query_row[7]
link.display_order = query_row[8]
link.cost_unit_local_VAT_excl = query_row[9]
link.cost_unit_local_VAT_incl = query_row[10]
link.price_unit_local_VAT_excl = query_row[11]
link.price_unit_local_VAT_incl = query_row[12]
link.active = query_row[13]
return link
def __repr__(self):
return f'''
{self.ATTR_ID_MANUFACTURING_PURCHASE_ORDER_PRODUCT_LINK}: {self.id_link},
{self.ATTR_ID_MANUFACTURING_PURCHASE_ORDER}: {self.id_order},
{self.ATTR_ID_PRODUCT_PERMUTATION}: {self.id_permutation},
{self.FLAG_NAME}: {self.name_permutation},
{self.ATTR_ID_UNIT_MEASUREMENT_QUANTITY}: {self.id_unit_quantity},
{self.FLAG_QUANTITY_USED}: {self.quantity_used},
{self.FLAG_QUANTITY_PRODUCED}: {self.quantity_produced},
{self.FLAG_LATENCY_MANUFACTURE_DAYS}: {self.latency_manufacture_days},
{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_INCL}: {self.cost_unit_local_VAT_incl},
{self.FLAG_PRICE_UNIT_LOCAL_VAT_EXCL}: {self.price_unit_local_VAT_excl},
{self.FLAG_PRICE_UNIT_LOCAL_VAT_INCL}: {self.price_unit_local_VAT_incl},
{self.FLAG_ACTIVE}: {self.active}
'''
def to_json(self):
return {
**self.get_shared_json_attributes(self),
self.ATTR_ID_MANUFACTURING_PURCHASE_ORDER_PRODUCT_LINK: self.id_link,
self.ATTR_ID_MANUFACTURING_PURCHASE_ORDER: self.id_order,
self.ATTR_ID_PRODUCT_PERMUTATION: self.id_permutation,
self.FLAG_NAME: self.name_permutation,
self.ATTR_ID_UNIT_MEASUREMENT_QUANTITY: self.id_unit_quantity,
self.FLAG_QUANTITY_USED: self.quantity_used,
self.FLAG_QUANTITY_PRODUCED: self.quantity_produced,
self.FLAG_LATENCY_MANUFACTURE_DAYS: self.latency_manufacture_days,
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_INCL: self.cost_unit_local_VAT_incl,
self.FLAG_PRICE_UNIT_LOCAL_VAT_EXCL: self.price_unit_local_VAT_excl,
self.FLAG_PRICE_UNIT_LOCAL_VAT_INCL: self.price_unit_local_VAT_incl,
self.FLAG_ACTIVE: av.input_bool(self.active, self.FLAG_ACTIVE, f'{self.__class__.__name__}.to_json'),
}
def to_json_option(self):
return {
'value': self.id_order,
'text': self.name_permutation,
}
@classmethod
def from_json(cls, json):
print(f'{cls.__name__}.from_json: {json}')
link = cls()
link.id_link = json[cls.ATTR_ID_MANUFACTURING_PURCHASE_ORDER_PRODUCT_LINK]
link.id_order = json[cls.ATTR_ID_MANUFACTURING_PURCHASE_ORDER]
link.id_permutation = json[cls.ATTR_ID_PRODUCT_PERMUTATION]
link.name_permutation = json[cls.FLAG_NAME]
link.id_unit_quantity = json[cls.ATTR_ID_UNIT_MEASUREMENT_QUANTITY]
link.quantity_used = json[cls.FLAG_QUANTITY_USED]
link.quantity_produced = json[cls.FLAG_QUANTITY_PRODUCED]
link.latency_manufacture_days = json[cls.FLAG_LATENCY_MANUFACTURE_DAYS]
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_incl = json[cls.FLAG_COST_UNIT_LOCAL_VAT_INCL]
link.active = json[cls.FLAG_ACTIVE]
return link
class Parameters_Manufacturing_Purchase_Order(Get_Many_Parameters_Base):
a_get_all_order: bool
a_get_inactive_order: bool
a_ids_order: str
a_ids_permutation: str
a_date_from: Optional[datetime]
a_date_to: Optional[datetime]
def __init__(self, **kwargs):
super().__init__(**kwargs)
@classmethod
def get_default(cls):
return cls(
a_get_all_order = True,
a_get_inactive_order = False,
a_ids_order = '',
a_ids_permutation = '',
a_date_from = None,
a_date_to = None
)
@classmethod
def from_filters_manufacturing_purchase_order(cls, form):
parameters = cls.get_default()
parameters.a_get_inactive_order = form.active.data
parameters.a_date_from = form.date_from.data
parameters.a_date_to = form.date_to.data
return parameters
class Manufacturing_Purchase_Order_Temp(db.Model, Store_Base):
__tablename__: ClassVar[str] = 'Shop_Manufacturing_Purchase_Order_Temp'
__table_args__ = { 'extend_existing': True }
id_order: int = db.Column(db.Integer, primary_key=True)
id_manufacturing: int = db.Column(db.Integer)
id_currency: int = db.Column(db.Integer)
active: bool = db.Column(db.Boolean)
guid: str = db.Column(db.String(36))
@classmethod
def from_manufacturing_purchase_order(cls, manufacturing_purchase_order):
row = cls()
row.id_order = manufacturing_purchase_order.id_order
row.id_manufacturing = manufacturing_purchase_order.id_manufacturing
row.id_currency = manufacturing_purchase_order.id_currency
row.active = 1 if manufacturing_purchase_order.active else 0
return row
def __repr__(self):
return f'''
id_order: {self.id_order}
id_manufacturing: {self.id_manufacturing}
id_currency: {self.id_currency}
active: {self.active}
guid: {self.guid}
'''
class Manufacturing_Purchase_Order_Product_Link_Temp(db.Model, Store_Base):
__tablename__: ClassVar[str] = 'Shop_Manufacturing_Purchase_Order_Product_Link_Temp'
__table_args__ = { 'extend_existing': True }
id_link: int = db.Column(db.Integer, primary_key=True)
id_order: int = db.Column(db.Integer)
id_permutation: int = db.Column(db.Integer)
id_unit_quantity: int = db.Column(db.Integer)
quantity_used: float = db.Column(db.Float)
quantity_produced: float = db.Column(db.Float)
latency_manufacture_days: 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_incl: float = db.Column(db.Float)
price_unit_local_VAT_excl: float = db.Column(db.Float)
price_unit_local_VAT_incl: float = db.Column(db.Float)
active: bool = db.Column(db.Boolean)
guid: str = db.Column(db.String(36))
@classmethod
def from_manufacturing_purchase_order_product_link(cls, manufacturing_purchase_order_product_link):
row = cls()
row.id_link = manufacturing_purchase_order_product_link.id_link
row.id_order = manufacturing_purchase_order_product_link.id_order
row.id_permutation = manufacturing_purchase_order_product_link.id_permutation
row.id_unit_quantity = manufacturing_purchase_order_product_link.id_unit_quantity
row.quantity_used = manufacturing_purchase_order_product_link.quantity_used
row.quantity_produced = manufacturing_purchase_order_product_link.quantity_produced
row.latency_manufacture_days = manufacturing_purchase_order_product_link.latency_manufacture_days
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_incl = manufacturing_purchase_order_product_link.cost_unit_local_VAT_incl
row.price_unit_local_VAT_excl = manufacturing_purchase_order_product_link.price_unit_local_VAT_excl
row.price_unit_local_VAT_incl = manufacturing_purchase_order_product_link.price_unit_local_VAT_incl
row.active = 1 if manufacturing_purchase_order_product_link.active else 0
return row
def __repr__(self):
return f'''
id_link: {self.id_link}
id_order: {self.id_order}
id_permutation: {self.id_permutation}
id_unit_quantity: {self.id_unit_quantity}
quantity_used: {self.quantity_used}
quantity_produced: {self.quantity_produced}
latency_manufacture_days: {self.latency_manufacture_days}
display_order: {self.display_order}
cost_unit_local_VAT_excl: {self.cost_unit_local_VAT_excl}
cost_unit_local_VAT_incl: {self.cost_unit_local_VAT_incl}
price_unit_local_VAT_excl: {self.price_unit_local_VAT_excl}
price_unit_local_VAT_incl: {self.price_unit_local_VAT_incl}
active: {self.active}
guid: {self.guid}
'''

View File

@@ -112,8 +112,8 @@ class Stock_Item(db.Model, Store_Base):
stock_item.date_received = json[cls.FLAG_DATE_RECEIVED]
stock_item.id_location_storage = json[cls.ATTR_ID_STORAGE_LOCATION]
stock_item.id_currency_cost = json[cls.ATTR_ID_CURRENCY_COST]
stock_item.cost_local_VAT_excl = json[cls.FLAG_COST_LOCAL_VAT_EXCL]
stock_item.cost_local_VAT_incl = json[cls.FLAG_COST_LOCAL_VAT_INCL]
stock_item.cost_local_VAT_excl = json[cls.FLAG_COST_UNIT_LOCAL_VAT_EXCL]
stock_item.cost_local_VAT_incl = json[cls.FLAG_COST_UNIT_LOCAL_VAT_INCL]
stock_item.is_sealed = json[cls.FLAG_IS_SEALED]
stock_item.date_unsealed = json[cls.FLAG_DATE_UNSEALED]
stock_item.date_expiration = json[cls.FLAG_DATE_EXPIRATION]
@@ -150,8 +150,8 @@ class Stock_Item(db.Model, Store_Base):
self.ATTR_ID_PRODUCT_CATEGORY: self.id_category,
self.FLAG_STORAGE_LOCATION: self.storage_location.to_json(),
self.FLAG_CURRENCY_COST: self.currency_cost.to_json(),
self.FLAG_COST_LOCAL_VAT_EXCL: self.cost_local_VAT_excl,
self.FLAG_COST_LOCAL_VAT_INCL: self.cost_local_VAT_incl,
self.FLAG_COST_UNIT_LOCAL_VAT_EXCL: self.cost_local_VAT_excl,
self.FLAG_COST_UNIT_LOCAL_VAT_INCL: self.cost_local_VAT_incl,
}
def has_permutations(self):
return len(self.permutations) > 0

View File

@@ -59,11 +59,13 @@ class I_Store_Base():
class Store_Base(Base):
# ATTR_ID_CURRENCY_COST: ClassVar[str] = 'id_currency_cost'
ATTR_ID_CUSTOMER: ClassVar[str] = 'id_customer'
ATTR_ID_CUSTOMER_ADDRESS: ClassVar[str] = 'id_address'
ATTR_ID_CUSTOMER_SALES_ORDER: ClassVar[str] = 'id_customer_sales_order'
ATTR_ID_DELIVERY_OPTION: ClassVar[str] = 'id_delivery_option'
ATTR_ID_DISCOUNT: ClassVar[str] = 'id_discount'
ATTR_ID_IMAGE: ClassVar[str] = 'id_image'
ATTR_ID_MANUFACTURING_PURCHASE_ORDER: ClassVar[str] = 'id_manufacturing_purchase_order'
ATTR_ID_MANUFACTURING_PURCHASE_ORDER: ClassVar[str] = 'id_order'
ATTR_ID_MANUFACTURING_PURCHASE_ORDER_PRODUCT_LINK: ClassVar[str] = 'id_link'
ATTR_ID_PLANT: ClassVar[str] = 'id_plant'
ATTR_ID_PRODUCT: ClassVar[str] = 'id_product'
ATTR_ID_PRODUCT_CATEGORY: ClassVar[str] = 'id_category'
@@ -75,18 +77,29 @@ class Store_Base(Base):
ATTR_ID_STOCK_ITEM: ClassVar[str] = 'id_stock_item'
ATTR_ID_STORAGE_LOCATION: ClassVar[str] = 'id_location'
ATTR_ID_SUPPLIER: ClassVar[str] = 'id_supplier'
ATTR_ID_SUPPLIER_PURCHASE_ORDER: ClassVar[str] = 'id_supplier_purchase_order'
FLAG_COST_LOCAL: ClassVar[str] = 'cost_local'
FLAG_COST_LOCAL_VAT_EXCL: ClassVar[str] = FLAG_COST_LOCAL + '_vat_excl'
FLAG_COST_LOCAL_VAT_INCL: ClassVar[str] = FLAG_COST_LOCAL + '_vat_incl'
ATTR_ID_SUPPLIER_ADDRESS: ClassVar[str] = 'id_address'
ATTR_ID_SUPPLIER_PURCHASE_ORDER: ClassVar[str] = 'id_order'
ATTR_ID_SUPPLIER_PURCHASE_ORDER_PRODUCT_LINK: ClassVar[str] = 'id_link'
ATTR_ID_UNIT_MEASUREMENT_QUANTITY: ClassVar[str] = 'id_unit_quantity'
# 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_INCL: ClassVar[str] = 'cost_total_local_vat_incl'
FLAG_COST_UNIT_LOCAL_VAT_EXCL: ClassVar[str] = 'cost_unit_local_vat_excl'
FLAG_COST_UNIT_LOCAL_VAT_INCL: ClassVar[str] = 'cost_unit_local_vat_incl'
FLAG_CUSTOMER: ClassVar[str] = 'customer'
FLAG_CUSTOMER_ADDRESS: ClassVar[str] = 'customer_address'
FLAG_CUSTOMER_SALES_ORDER: ClassVar[str] = 'customer_sales_order'
FLAG_DELIVERY_OPTION: ClassVar[str] = 'delivery_option'
FLAG_DISCOUNT: ClassVar[str] = 'discount'
FLAG_HAS_VARIATIONS: ClassVar[str] = 'has_variations'
FLAG_IS_OUT_OF_STOCK: ClassVar[str] = 'is_out_of_stock'
FLAG_DISCOUNT: ClassVar[str] = 'discount'
FLAG_LATENCY_DELIVERY_DAYS: ClassVar[str] = 'latency_delivery_days'
FLAG_MANUFACTURING_PURCHASE_ORDER: ClassVar[str] = 'manufacturing_purchase_order'
FLAG_PLANT: ClassVar[str] = 'plant'
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_UNIT_LOCAL_VAT_EXCL: ClassVar[str] = 'price_unit_local_vat_excl'
FLAG_PRICE_UNIT_LOCAL_VAT_INCL: ClassVar[str] = 'price_unit_local_vat_incl'
FLAG_PRODUCT: ClassVar[str] = 'product'
FLAG_PRODUCT_CATEGORY: ClassVar[str] = 'product_category'
FLAG_PRODUCT_IMAGE: ClassVar[str] = 'product_image'
@@ -97,9 +110,12 @@ class Store_Base(Base):
FLAG_PRODUCT_VARIATION_TYPE: ClassVar[str] = 'product_variation_type'
FLAG_QUANTITY_MIN: ClassVar[str] = 'quantity_min'
FLAG_QUANTITY_MAX: ClassVar[str] = 'quantity_max'
FLAG_QUANTITY_ORDERED: ClassVar[str] = 'quantity_ordered'
FLAG_QUANTITY_RECEIVED: ClassVar[str] = 'quantity_received'
FLAG_STOCK_ITEM: ClassVar[str] = 'stock_item'
FLAG_STORAGE_LOCATION: ClassVar[str] = 'storage_location'
FLAG_SUPPLIER: ClassVar[str] = 'supplier'
FLAG_SUPPLIER_ADDRESS: ClassVar[str] = 'supplier_address'
FLAG_SUPPLIER_PURCHASE_ORDER: ClassVar[str] = 'supplier_purchase_order'
FLAG_TEXT: ClassVar[str] = 'text'
FLAG_VALUE_TEXT: ClassVar[str] = 'value_text'

View File

@@ -12,6 +12,9 @@ Business object for supplier
# internal
import lib.argument_validation as av
from business_objects.store.supplier_address import Supplier_Address
from business_objects.currency import Currency
from business_objects.db_base import Get_Many_Parameters_Base
from business_objects.store.store_base import Store_Base
from extensions import db
# external
@@ -27,12 +30,11 @@ class Supplier(db.Model, Store_Base):
NAME_ATTR_OPTION_TEXT: ClassVar[str] = Store_Base.FLAG_NAME
__tablename__ = 'Shop_Supplier_Temp'
id_supplier = db.Column(db.Integer, primary_key=True)
id_address = db.Column(db.Integer)
# id_address = db.Column(db.Integer)
id_currency = db.Column(db.Integer)
name_company = db.Column(db.String(255))
name_contact = db.Column(db.String(255))
department_contact = db.Column(db.String(255))
# address
phone_number = db.Column(db.String(50))
fax = db.Column(db.String(50))
email = db.Column(db.String(255))
@@ -43,26 +45,29 @@ class Supplier(db.Model, Store_Base):
def __init__(self):
super().__init__()
Store_Base.__init__(self)
self.addresses = []
self.currency = None
@classmethod
def from_DB_supplier(cls, query_row):
supplier = cls()
supplier.id_supplier = query_row[0]
supplier.id_address = query_row[1]
supplier.id_currency = query_row[2]
supplier.name_company = query_row[3]
supplier.name_contact = query_row[4]
supplier.department_contact = query_row[5]
supplier.phone_number = query_row[6]
supplier.fax = query_row[7]
supplier.email = query_row[8]
supplier.website = query_row[9]
supplier.active = query_row[10]
# supplier.id_address = query_row[1]
# supplier.address = Supplier_Address.from_DB_supplier(query_row)
supplier.id_currency = query_row[1]
supplier.currency = Currency.from_DB_supplier(query_row)
supplier.name_company = query_row[4]
supplier.name_contact = query_row[5]
supplier.department_contact = query_row[6]
supplier.phone_number = query_row[7]
supplier.fax = query_row[8]
supplier.email = query_row[9]
supplier.website = query_row[10]
supplier.active = av.input_bool(query_row[11], 'active', f'{cls.__name__}.from_DB_supplier')
return supplier
def __repr__(self):
return f'''
id: {self.id_supplier},
id_address: {self.id_address},
id_currency: {self.id_currency},
name_company: {self.name_company},
name_contact: {self.name_contact},
@@ -72,12 +77,13 @@ fax: {self.fax},
email: {self.email},
website: {self.website},
active: {self.active},
addresses: {self.addresses}
'''
def to_json(self):
return {
**self.get_shared_json_attributes(self),
self.ATTR_ID_SUPPLIER: self.id_supplier,
self.ATTR_ID_ADDRESS: self.id_address,
# self.ATTR_ID_ADDRESS: self.id_address,
self.ATTR_ID_CURRENCY: self.id_currency,
self.FLAG_NAME_COMPANY: self.name_company,
self.FLAG_NAME_CONTACT: self.name_contact,
@@ -98,7 +104,6 @@ active: {self.active},
print(f'{cls.__name__}.from_json: {json}')
supplier = cls()
supplier.id_supplier = json[cls.ATTR_ID_SUPPLIER]
supplier.id_address = json[cls.ATTR_ID_ADDRESS]
supplier.id_currency = json[cls.ATTR_ID_CURRENCY]
supplier.name_company = json[cls.FLAG_NAME_COMPANY]
supplier.name_contact = json[cls.FLAG_NAME_CONTACT]
@@ -108,4 +113,78 @@ active: {self.active},
supplier.email = json[cls.FLAG_EMAIL]
supplier.website = json[cls.FLAG_WEBSITE]
supplier.active = json[cls.FLAG_ACTIVE]
addresses = json.get(cls.FLAG_SUPPLIER_ADDRESS, [])
supplier.addresses = [Supplier_Address.from_json(address) for address in addresses]
return supplier
def get_address_active(self):
for address in self.addresses:
if address.active:
return address
return Supplier_Address()
address = Supplier_Address()
address.postcode = ''
return address
class Parameters_Supplier(Get_Many_Parameters_Base):
a_get_all_supplier: bool
a_get_inactive_supplier: bool
a_ids_supplier: str
def __init__(self, **kwargs):
super().__init__(**kwargs)
@classmethod
def get_default(cls):
return cls(
a_get_all_supplier = True,
a_get_inactive_supplier = False,
a_ids_supplier = '',
)
@classmethod
def from_filters_supplier(cls, form):
parameters = cls.get_default()
parameters.a_get_inactive_supplier = form.active.data
return parameters
class Supplier_Temp(db.Model, Store_Base):
__tablename__: ClassVar[str] = 'Shop_Supplier_Temp'
__table_args__ = { 'extend_existing': True }
id_supplier: int = db.Column(db.Integer, primary_key=True)
id_currency: int = db.Column(db.Integer)
# id_address: int = db.Column(db.Integer)
name_company: str = db.Column(db.String(255))
name_contact: str = db.Column(db.String(255))
department_contact: str = db.Column(db.String(255))
phone_number: str = db.Column(db.String(50))
fax: str = db.Column(db.String(50))
email: str = db.Column(db.String(255))
website: str = db.Column(db.String(255))
active: bool = db.Column(db.Boolean)
guid: str = db.Column(db.String(36))
@classmethod
def from_supplier(cls, supplier):
row = cls()
row.id_supplier = supplier.id_supplier
row.id_currency = supplier.id_currency
# row.id_address = supplier.id_address
row.name_company = supplier.name_company
row.name_contact = supplier.name_contact
row.department_contact = supplier.department_contact
row.phone_number = supplier.phone_number
row.fax = supplier.fax
row.email = supplier.email
row.website = supplier.website
row.active = 1 if supplier.active else 0
return row
def __repr__(self):
return f'''
id_supplier: {self.id_supplier}
id_currency: {self.id_currency}
name_company: {self.name_company}
name_contact: {self.name_contact}
department_contact: {self.department_contact}
phone_number: {self.phone_number}
fax: {self.fax}
email: {self.email}
website: {self.website}
active: {self.active}
guid: {self.guid}
'''

View File

@@ -0,0 +1,145 @@
"""
Project: PARTS Website
Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: Business Objects
Feature: Supplier Address Business Object
Description:
Business object for supplier address
"""
# internal
import lib.argument_validation as av
from business_objects.store.store_base import Store_Base
from business_objects.region import Region
from extensions import db
# external
from typing import ClassVar
from flask import jsonify
class Supplier_Address(db.Model, Store_Base):
FLAG_ADDRESS_LINE_1: ClassVar[str] = 'address_line_1'
FLAG_ADDRESS_LINE_2: ClassVar[str] = 'address_line_2'
FLAG_CITY: ClassVar[str] = 'city'
FLAG_COUNTY: ClassVar[str] = 'county'
NAME_ATTR_OPTION_VALUE: ClassVar[str] = Store_Base.ATTR_ID_ADDRESS
NAME_ATTR_OPTION_TEXT: ClassVar[str] = Store_Base.FLAG_POSTCODE
__tablename__ = 'Shop_Supplier_Address'
id_address = db.Column(db.Integer, primary_key=True)
id_supplier = db.Column(db.Integer)
id_region = db.Column(db.Integer)
postcode = db.Column(db.String(20))
address_line_1 = db.Column(db.String(256))
address_line_2 = db.Column(db.String(256))
city = db.Column(db.String(256))
county = db.Column(db.String(256))
active = db.Column(db.Boolean)
# region = None
def __init__(self):
super().__init__()
Store_Base.__init__(self)
self.region = Region()
@classmethod
def from_DB_supplier(cls, query_row):
address = cls()
address.id_supplier = query_row[0]
address.id_address = query_row[1]
address.id_region = query_row[2]
address.region = Region.from_DB_supplier(query_row)
address.postcode = query_row[4]
address.address_line_1 = query_row[5]
address.address_line_2 = query_row[6]
address.city = query_row[7]
address.county = query_row[8]
address.active = av.input_bool(query_row[9], 'active', f'{cls.__name__}.from_DB_supplier')
return address
def __repr__(self):
return f'''
{self.ATTR_ID_ADDRESS}: {self.id_address}
{self.ATTR_ID_SUPPLIER}: {self.id_supplier}
{self.FLAG_REGION}: {self.region}
{self.FLAG_POSTCODE}: {self.postcode}
{self.FLAG_ADDRESS_LINE_1}: {self.address_line_1}
{self.FLAG_ADDRESS_LINE_2}: {self.address_line_2}
{self.FLAG_CITY}: {self.city}
{self.FLAG_COUNTY}: {self.county}
{self.FLAG_ACTIVE}: {self.active}
'''
def to_json(self):
print(f'{self.__class__.__name__}.to_json\n{self.__dict__}\n{self}')
return {
**self.get_shared_json_attributes(self),
self.ATTR_ID_ADDRESS: self.id_address,
self.ATTR_ID_SUPPLIER: self.id_supplier,
self.FLAG_REGION: self.region.to_json(),
self.FLAG_POSTCODE: self.postcode,
self.FLAG_ADDRESS_LINE_1: self.address_line_1,
self.FLAG_ADDRESS_LINE_2: self.address_line_2,
self.FLAG_CITY: self.city,
self.FLAG_COUNTY: self.county,
self.FLAG_ACTIVE: 1 if av.input_bool(self.active, self.FLAG_ACTIVE, f'{self.__class__.__name__}.to_json') else 0
}
def to_json_str(self):
return jsonify(self.to_json())
@classmethod
def from_json(cls, json):
print(f'{cls.__name__}.from_json: {json}')
address = cls()
address.id_address = json[cls.ATTR_ID_ADDRESS]
address.id_supplier = json[cls.ATTR_ID_SUPPLIER]
address.id_region = json[cls.ATTR_ID_REGION]
address.region = Region()
address.region.id_region = json[cls.ATTR_ID_REGION]
address.postcode = json[cls.FLAG_POSTCODE]
address.address_line_1 = json[cls.FLAG_ADDRESS_LINE_1]
address.address_line_2 = json.get(cls.FLAG_ADDRESS_LINE_2, '')
address.city = json[cls.FLAG_CITY]
address.county = json[cls.FLAG_COUNTY]
address.active = json[cls.FLAG_ACTIVE]
return address
class Supplier_Address_Temp(db.Model, Store_Base):
__tablename__: ClassVar[str] = 'Shop_Supplier_Address_Temp'
__table_args__ = { 'extend_existing': True }
id_address: int = db.Column(db.Integer, primary_key=True)
id_supplier: int = db.Column(db.Integer)
id_region: int = db.Column(db.Integer)
postcode: str = db.Column(db.String(20))
address_line_1: str = db.Column(db.String(256))
address_line_2: str = db.Column(db.String(256))
city: str = db.Column(db.String(256))
county: str = db.Column(db.String(256))
active: bool = db.Column(db.Boolean)
guid: str = db.Column(db.String(36))
@classmethod
def from_supplier_address(cls, address):
row = cls()
row.id_address = address.id_address
row.id_supplier = address.id_supplier
row.id_region = address.id_region
row.postcode = address.postcode
row.address_line_1 = address.address_line_1
row.address_line_2 = address.address_line_2
row.city = address.city
row.county = address.county
row.active = 1 if address.active else 0
return row
def __repr__(self):
return f'''
id_address: {self.id_address}
id_supplier: {self.id_supplier}
id_region: {self.id_region}
postcode: {self.postcode}
address_line_1: {self.address_line_1}
address_line_2: {self.address_line_2}
city: {self.city}
county: {self.county}
active: {self.active}
guid: {self.guid}
'''

View File

@@ -0,0 +1,289 @@
"""
Project: PARTS Website
Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: Business Objects
Feature: Supplier_Purchase_Order Business Object
Description:
Business object for supplier_purchase_order
"""
# internal
import lib.argument_validation as av
from business_objects.db_base import Get_Many_Parameters_Base
from business_objects.store.store_base import Store_Base
from extensions import db
# external
from pydantic import BaseModel
from typing import ClassVar, Optional
from datetime import datetime
class Supplier_Purchase_Order(db.Model, Store_Base):
NAME_ATTR_OPTION_VALUE: ClassVar[str] = Store_Base.ATTR_ID_SUPPLIER_PURCHASE_ORDER
NAME_ATTR_OPTION_TEXT: ClassVar[str] = Store_Base.FLAG_NAME
# __tablename__ = 'Shop_Supplier_Purchase_Order_Temp'
id_order = db.Column(db.Integer, primary_key=True)
id_supplier = db.Column(db.Integer)
id_currency = db.Column(db.Integer)
cost_total_local_VAT_excl = db.Column(db.Float)
cost_total_local_VAT_incl = db.Column(db.Float)
active = db.Column(db.Boolean)
created_on = db.Column(db.DateTime)
created_by = db.Column(db.Integer)
name = db.Column(db.String(255))
# items: list = None
def __init__(self):
super().__init__()
Store_Base.__init__(self)
self.items = None
@classmethod
def from_DB_supplier_purchase_order(cls, query_row):
supplier_purchase_order = cls()
supplier_purchase_order.id_order = query_row[0]
supplier_purchase_order.id_supplier = query_row[1]
supplier_purchase_order.id_currency = query_row[2]
supplier_purchase_order.cost_total_local_VAT_excl = query_row[3]
supplier_purchase_order.cost_total_local_VAT_incl = query_row[4]
supplier_purchase_order.active = av.input_bool(query_row[5], 'active', f'{cls.__name__}.from_DB_supplier_purchase_order')
supplier_purchase_order.created_on = query_row[6]
supplier_purchase_order.name = query_row[7]
return supplier_purchase_order
def __repr__(self):
return f'''
{self.ATTR_ID_SUPPLIER_PURCHASE_ORDER}: {self.id_order},
{self.ATTR_ID_SUPPLIER}: {self.id_supplier},
{self.ATTR_ID_CURRENCY}: {self.id_currency},
{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_ACTIVE}: {self.active},
{self.FLAG_CREATED_ON}: {self.created_on},
{self.FLAG_NAME}: {self.name}
'''
def to_json(self):
return {
**self.get_shared_json_attributes(self),
self.ATTR_ID_SUPPLIER_PURCHASE_ORDER: self.id_order,
self.ATTR_ID_SUPPLIER: self.id_supplier,
self.ATTR_ID_CURRENCY: self.id_currency,
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_ACTIVE: av.input_bool(self.active, self.FLAG_ACTIVE, f'{self.__class__.__name__}.to_json'),
self.FLAG_CREATED_ON: self.created_on,
self.FLAG_NAME: self.name,
}
def to_json_option(self):
return {
'value': self.id_order,
'text': self.name,
}
@classmethod
def from_json(cls, json):
print(f'{cls.__name__}.from_json: {json}')
supplier_purchase_order = cls()
supplier_purchase_order.id_order = json[cls.ATTR_ID_SUPPLIER_PURCHASE_ORDER]
supplier_purchase_order.id_supplier = json[cls.ATTR_ID_SUPPLIER]
supplier_purchase_order.id_currency = json[cls.ATTR_ID_CURRENCY]
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.active = json[cls.FLAG_ACTIVE]
supplier_purchase_order.created_on = json[cls.FLAG_CREATED_ON]
supplier_purchase_order.name = json[cls.FLAG_NAME]
return supplier_purchase_order
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_TEXT: ClassVar[str] = Store_Base.FLAG_NAME
__tablename__ = 'Shop_Supplier_Purchase_Order_Temp'
id_link = db.Column(db.Integer, primary_key=True)
id_order = db.Column(db.Integer)
id_permutation = db.Column(db.Integer)
id_unit_quantity = db.Column(db.Integer)
name_permutation = db.Column(db.String(255))
quantity_ordered = db.Column(db.Float)
quantity_received = db.Column(db.Float)
latency_delivery_days = db.Column(db.Integer)
display_order = db.Column(db.Integer)
cost_total_local_VAT_excl = db.Column(db.Float)
cost_total_local_VAT_incl = db.Column(db.Float)
active = db.Column(db.Boolean)
created_on = db.Column(db.DateTime)
created_by = db.Column(db.Integer)
def __init__(self):
super().__init__()
Store_Base.__init__(self)
@classmethod
def from_DB_supplier_purchase_order(cls, query_row):
link = cls()
link.id_link = query_row[0]
link.id_order = query_row[1]
link.id_permutation = query_row[2]
link.name_permutation = query_row[3]
link.id_unit_quantity = query_row[4]
link.quantity_ordered = query_row[5]
link.quantity_received = query_row[6]
link.latency_delivery_days = query_row[7]
link.display_order = query_row[8]
link.cost_total_local_VAT_excl = query_row[9]
link.cost_total_local_VAT_incl = query_row[10]
link.active = query_row[11]
return link
def __repr__(self):
return f'''
{self.ATTR_ID_SUPPLIER_PURCHASE_ORDER_PRODUCT_LINK}: {self.id_link},
{self.ATTR_ID_SUPPLIER_PURCHASE_ORDER}: {self.id_order},
{self.ATTR_ID_PRODUCT_PERMUTATION}: {self.id_permutation},
{self.FLAG_NAME}: {self.name_permutation},
{self.ATTR_ID_UNIT_MEASUREMENT_QUANTITY}: {self.id_unit_quantity},
{self.FLAG_QUANTITY_ORDERED}: {self.quantity_ordered},
{self.FLAG_QUANTITY_RECEIVED}: {self.quantity_received},
{self.FLAG_LATENCY_DELIVERY_DAYS}: {self.latency_delivery_days},
{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_INCL}: {self.cost_total_local_VAT_incl},
{self.FLAG_ACTIVE}: {self.active}
'''
def to_json(self):
return {
**self.get_shared_json_attributes(self),
self.ATTR_ID_SUPPLIER_PURCHASE_ORDER_PRODUCT_LINK: self.id_link,
self.ATTR_ID_SUPPLIER_PURCHASE_ORDER: self.id_order,
self.ATTR_ID_PRODUCT_PERMUTATION: self.id_permutation,
self.FLAG_NAME: self.name_permutation,
self.ATTR_ID_UNIT_MEASUREMENT_QUANTITY: self.id_unit_quantity,
self.FLAG_QUANTITY_ORDERED: self.quantity_ordered,
self.FLAG_QUANTITY_RECEIVED: self.quantity_received,
self.FLAG_LATENCY_DELIVERY_DAYS: self.latency_delivery_days,
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_INCL: self.cost_total_local_VAT_incl,
self.FLAG_ACTIVE: av.input_bool(self.active, self.FLAG_ACTIVE, f'{self.__class__.__name__}.to_json'),
}
def to_json_option(self):
return {
'value': self.id_order,
'text': self.name_permutation,
}
@classmethod
def from_json(cls, json):
print(f'{cls.__name__}.from_json: {json}')
link = cls()
link.id_link = json[cls.ATTR_ID_SUPPLIER_PURCHASE_ORDER_PRODUCT_LINK]
link.id_order = json[cls.ATTR_ID_SUPPLIER_PURCHASE_ORDER]
link.id_permutation = json[cls.ATTR_ID_PRODUCT_PERMUTATION]
link.name_permutation = json[cls.FLAG_NAME]
link.id_unit_quantity = json[cls.ATTR_ID_UNIT_MEASUREMENT_QUANTITY]
link.quantity_ordered = json[cls.FLAG_QUANTITY_ORDERED]
link.quantity_received = json[cls.FLAG_QUANTITY_RECEIVED]
link.latency_delivery_days = json[cls.FLAG_LATENCY_DELIVERY_DAYS]
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_incl = json[cls.FLAG_COST_TOTAL_LOCAL_VAT_INCL]
link.active = json[cls.FLAG_ACTIVE]
return link
class Parameters_Supplier_Purchase_Order(Get_Many_Parameters_Base):
a_get_all_supplier: bool
a_get_inactive_supplier: bool
a_ids_supplier: str
a_get_all_order: bool
a_get_inactive_order: bool
a_ids_order: str
a_ids_permutation: str
a_date_from: Optional[datetime]
a_date_to: Optional[datetime]
def __init__(self, **kwargs):
super().__init__(**kwargs)
@classmethod
def get_default(cls):
return cls(
a_get_all_supplier = True,
a_get_inactive_supplier = False,
a_ids_supplier = '',
a_get_all_order = True,
a_get_inactive_order = False,
a_ids_order = '',
a_ids_permutation = '',
a_date_from = None,
a_date_to = None
)
@classmethod
def from_filters_supplier_purchase_order(cls, form):
parameters = cls.get_default()
parameters.a_get_inactive_order = form.active.data
parameters.a_date_from = form.date_from.data
parameters.a_date_to = form.date_to.data
return parameters
class Supplier_Purchase_Order_Temp(db.Model, Store_Base):
__tablename__: ClassVar[str] = 'Shop_Supplier_Purchase_Order_Temp'
__table_args__ = { 'extend_existing': True }
id_order: int = db.Column(db.Integer, primary_key=True)
id_supplier: int = db.Column(db.Integer)
id_currency: int = db.Column(db.Integer)
active: bool = db.Column(db.Boolean)
guid: str = db.Column(db.String(36))
@classmethod
def from_supplier_purchase_order(cls, supplier_purchase_order):
row = cls()
row.id_order = supplier_purchase_order.id_order
row.id_supplier = supplier_purchase_order.id_supplier
row.id_currency = supplier_purchase_order.id_currency
row.active = 1 if supplier_purchase_order.active else 0
return row
def __repr__(self):
return f'''
id_order: {self.id_order}
id_supplier: {self.id_supplier}
id_currency: {self.id_currency}
active: {self.active}
guid: {self.guid}
'''
class Supplier_Purchase_Order_Product_Link_Temp(db.Model, Store_Base):
__tablename__: ClassVar[str] = 'Shop_Supplier_Purchase_Order_Product_Link_Temp'
__table_args__ = { 'extend_existing': True }
id_link: int = db.Column(db.Integer, primary_key=True)
id_order: int = db.Column(db.Integer)
id_permutation: int = db.Column(db.Integer)
id_unit_quantity: int = db.Column(db.Integer)
quantity_ordered: float = db.Column(db.Float)
quantity_received: float = db.Column(db.Float)
latency_delivery_days: int = db.Column(db.Integer)
display_order: int = db.Column(db.Integer)
cost_total_local_VAT_excl: float = db.Column(db.Float)
cost_total_local_VAT_incl: float = db.Column(db.Float)
active: bool = db.Column(db.Boolean)
guid: str = db.Column(db.String(36))
@classmethod
def from_supplier_purchase_order_product_link(cls, supplier_purchase_order_product_link):
row = cls()
row.id_link = supplier_purchase_order_product_link.id_link
row.id_order = supplier_purchase_order_product_link.id_order
row.id_permutation = supplier_purchase_order_product_link.id_permutation
row.id_unit_quantity = supplier_purchase_order_product_link.id_unit_quantity
row.quantity_ordered = supplier_purchase_order_product_link.quantity_ordered
row.quantity_received = supplier_purchase_order_product_link.quantity_received
row.latency_delivery_days = supplier_purchase_order_product_link.latency_delivery_days
row.display_order = supplier_purchase_order_product_link.display_order
row.cost_total_local_VAT_excl = supplier_purchase_order_product_link.cost_total_local_VAT_excl
row.cost_total_local_VAT_incl = supplier_purchase_order_product_link.cost_total_local_VAT_incl
row.active = 1 if supplier_purchase_order_product_link.active else 0
return row
def __repr__(self):
return f'''
id_link: {self.id_link}
id_order: {self.id_order}
id_permutation: {self.id_permutation}
id_unit_quantity: {self.id_unit_quantity}
quantity_ordered: {self.quantity_ordered}
quantity_received: {self.quantity_received}
latency_delivery_days: {self.latency_delivery_days}
display_order: {self.display_order}
cost_total_local_VAT_excl: {self.cost_total_local_VAT_excl}
cost_total_local_VAT_incl: {self.cost_total_local_VAT_incl}
active: {self.active}
guid: {self.guid}
'''

View File

@@ -0,0 +1,114 @@
"""
Project: PARTS Website
Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: App Routing
Feature: Store Manufacturing_Purchase_Order Routes
Description:
Initializes the Flask application, sets the configuration based on the environment, and defines two routes (/ and /about) that render templates with the specified titles.
"""
# internal
from business_objects.store.manufacturing_purchase_order import Manufacturing_Purchase_Order
from forms.store.manufacturing_purchase_order import Filters_Manufacturing_Purchase_Order
from models.model_view_store_manufacturing_purchase_order import Model_View_Store_Manufacturing_Purchase_Order
from helpers.helper_app import Helper_App
import lib.argument_validation as av
# external
from datetime import datetime
from flask import Flask, render_template, jsonify, request, render_template_string, send_from_directory, redirect, url_for, session, Blueprint, current_app
from extensions import db, oauth
from urllib.parse import quote_plus, urlencode
from authlib.integrations.flask_client import OAuth
from authlib.integrations.base_client import OAuthError
from urllib.parse import quote, urlparse, parse_qs
import requests
routes_store_manufacturing_purchase_order = Blueprint('routes_store_manufacturing_purchase_order', __name__)
@routes_store_manufacturing_purchase_order.route(Model_View_Store_Manufacturing_Purchase_Order.HASH_PAGE_STORE_MANUFACTURING_PURCHASE_ORDERS, methods=['GET'])
def manufacturing_purchase_orders():
print('manufacturing_purchase_orders')
try:
form_filters = Filters_Manufacturing_Purchase_Order.from_json(request.args)
except Exception as e:
print(f'Error: {e}')
form_filters = Filters_Manufacturing_Purchase_Order()
print(f'form_filters={form_filters}')
model = Model_View_Store_Manufacturing_Purchase_Order(form_filters)
if not model.is_user_logged_in:
return redirect(url_for('routes_core.home'))
return render_template('pages/store/_manufacturing_purchase_orders.html', model = model, datetime = datetime)
@routes_store_manufacturing_purchase_order.route(Model_View_Store_Manufacturing_Purchase_Order.HASH_GET_STORE_MANUFACTURING_PURCHASE_ORDER, methods=['POST'])
def filter_manufacturing_purchase_order():
data = Helper_App.get_request_data(request)
try:
form_filters = Filters_Manufacturing_Purchase_Order.from_json(data)
if not form_filters.validate_on_submit():
error_keys = list(form_filters.errors.keys())
try:
error_keys.remove(Manufacturing_Purchase_Order.ATTR_ID_PRODUCT_CATEGORY)
except:
pass
try:
error_keys.remove(Manufacturing_Purchase_Order.ATTR_ID_PRODUCT)
except:
pass
if error_keys:
return jsonify({
Model_View_Store_Manufacturing_Purchase_Order.FLAG_STATUS: Model_View_Store_Manufacturing_Purchase_Order.FLAG_FAILURE,
Model_View_Store_Manufacturing_Purchase_Order.FLAG_MESSAGE: f'Form invalid.\n{form_filters.errors}'
})
model = Model_View_Store_Manufacturing_Purchase_Order(filters_manufacturing_purchase_order = form_filters)
if not model.is_user_logged_in:
raise Exception('User not logged in.')
return jsonify({
Model_View_Store_Manufacturing_Purchase_Order.FLAG_STATUS: Model_View_Store_Manufacturing_Purchase_Order.FLAG_SUCCESS,
Model_View_Store_Manufacturing_Purchase_Order.FLAG_DATA: model.category_list.to_json()
})
except Exception as e:
return jsonify({
Model_View_Store_Manufacturing_Purchase_Order.FLAG_STATUS: Model_View_Store_Manufacturing_Purchase_Order.FLAG_FAILURE,
Model_View_Store_Manufacturing_Purchase_Order.FLAG_MESSAGE: f'Bad data received by controller.\n{e}'
})
@routes_store_manufacturing_purchase_order.route(Model_View_Store_Manufacturing_Purchase_Order.HASH_SAVE_STORE_MANUFACTURING_PURCHASE_ORDER, methods=['POST'])
def save_manufacturing_purchase_order():
data = Helper_App.get_request_data(request)
try:
form_filters = Filters_Manufacturing_Purchase_Order.from_json(data[Model_View_Store_Manufacturing_Purchase_Order.FLAG_FORM_FILTERS])
print(f'form_filters: {form_filters}')
manufacturing_purchase_orders = data[Model_View_Store_Manufacturing_Purchase_Order.FLAG_MANUFACTURING_PURCHASE_ORDER]
if len(manufacturing_purchase_orders) == 0:
return jsonify({
Model_View_Store_Manufacturing_Purchase_Order.FLAG_STATUS: Model_View_Store_Manufacturing_Purchase_Order.FLAG_FAILURE,
Model_View_Store_Manufacturing_Purchase_Order.FLAG_MESSAGE: f'No stock items.'
})
print(f'manufacturing_purchase_orders={manufacturing_purchase_orders}')
objs_manufacturing_purchase_order = []
for manufacturing_purchase_order in manufacturing_purchase_orders:
objs_manufacturing_purchase_order.append(Manufacturing_Purchase_Order.from_json(manufacturing_purchase_order))
print(f'objs_manufacturing_purchase_order={objs_manufacturing_purchase_order}')
save_errors = Model_View_Store_Manufacturing_Purchase_Order.save_manufacturing_purchase_orders(data.get('comment', 'No comment'), objs_manufacturing_purchase_order)
if len(save_errors) > 0:
return jsonify({
Model_View_Store_Manufacturing_Purchase_Order.FLAG_STATUS: Model_View_Store_Manufacturing_Purchase_Order.FLAG_FAILURE,
Model_View_Store_Manufacturing_Purchase_Order.FLAG_MESSAGE: f'Save errors: {save_errors}'
})
model_return = Model_View_Store_Manufacturing_Purchase_Order(filters_manufacturing_purchase_order_old = form_filters)
if not model_return.is_user_logged_in:
raise Exception('User not logged in.')
return jsonify({
Model_View_Store_Manufacturing_Purchase_Order.FLAG_STATUS: Model_View_Store_Manufacturing_Purchase_Order.FLAG_SUCCESS,
Model_View_Store_Manufacturing_Purchase_Order.FLAG_DATA: model_return.category_list.to_json()
})
except Exception as e:
return jsonify({
Model_View_Store_Manufacturing_Purchase_Order.FLAG_STATUS: Model_View_Store_Manufacturing_Purchase_Order.FLAG_FAILURE,
Model_View_Store_Manufacturing_Purchase_Order.FLAG_MESSAGE: f'Bad data received by controller.\n{e}'
})

View File

@@ -14,7 +14,7 @@ Initializes the Flask application, sets the configuration based on the environme
# internal
from models.model_view_store import Model_View_Store
# external
from flask import Flask, render_template, jsonify, request, render_template_string, send_from_directory, redirect, url_for, session, Blueprint, current_app
from flask import Flask, render_template, jsonify, request, render_template_string, send_from_directory, redirect, url_for, session, Blueprint, current_app, Response
from extensions import db, oauth
from urllib.parse import quote_plus, urlencode
from authlib.integrations.flask_client import OAuth
@@ -27,4 +27,5 @@ routes_store = Blueprint('routes_store', __name__)
def scripts_section_store():
hash_page_current = request.args.get('hash_page_current', default = Model_View_Store.HASH_SCRIPTS_SECTION_STORE, type = str)
model = Model_View_Store(hash_page_current=hash_page_current)
return render_template('js/sections/store.js', model = model)
template = render_template('js/sections/store.js', model = model)
return Response(template, mimetype='application/javascript')

View File

@@ -10,62 +10,106 @@ Description:
Initializes the Flask application, sets the configuration based on the environment, and defines two routes (/ and /about) that render templates with the specified titles.
"""
# internal
from business_objects.store.product import Product, Parameters_Product, Product_Permutation
from business_objects.store.stock_item import Stock_Item
from forms.forms import Form_Supplier
from models.model_view_base import Model_View_Base
from models.model_view_store import Model_View_Store
from business_objects.store.supplier import Supplier
from forms.store.supplier import Filters_Supplier
from models.model_view_store_supplier import Model_View_Store_Supplier
from models.model_view_store_product_category import Model_View_Store_Product_Category
from models.model_view_store_product_permutation import Model_View_Store_Product_Permutation
from models.model_view_store_stock_item import Model_View_Store_Stock_Item
from helpers.helper_app import Helper_App
import lib.argument_validation as av
# external
from datetime import datetime
from flask import Flask, render_template, jsonify, request, render_template_string, send_from_directory, redirect, url_for, session, Blueprint, current_app
from extensions import db, oauth
from urllib.parse import quote_plus, urlencode
from authlib.integrations.flask_client import OAuth
from authlib.integrations.base_client import OAuthError
from urllib.parse import quote, urlparse, parse_qs
import requests
routes_store_supplier = Blueprint('routes_store_supplier', __name__)
routes_store_supplier= Blueprint('routes_store_supplier', __name__)
@routes_store_supplier.route('/supplier', methods=['GET'])
def supplier():
@routes_store_supplier.route(Model_View_Store_Supplier.HASH_PAGE_STORE_SUPPLIERS, methods=['GET'])
def suppliers():
print('suppliers')
try:
data = request.json
except:
data = {}
print(f'data={data}')
form_data = data[Model_View_Store_Supplier.key_form]
print(f'form_data: {form_data}')
form = Form_Supplier(**form_data)
print('form acquired')
print(form.__repr__)
if form.validate_on_submit():
print('valid form')
# model = input_JSON_basket(model, data)
# if not logged in:
try:
model = Model_View_Store_Supplier(form)
if not model.is_user_logged_in:
# return redirect(url_for('routes_user.login', data = jsonify({ Model_View_Store_Supplier.FLAG_CALLBACK: Model_View_Store_Supplier.HASH_PAGE_STORE_SUPPLIERS })))
return redirect(url_for('routes_core.home'))
# print('importing basket')
# model.import_JSON_basket(data)
model.get_basket(data)
permutation_id, quantity = model.import_JSON_basket_item(data, form)
model.basket_item_edit(permutation_id, quantity, False) # new_basket =
form_filters = Filters_Supplier.from_json(request.args)
except Exception as e:
return jsonify({Model_View_Base.FLAG_STATUS: Model_View_Base.FLAG_FAILURE, Model_View_Base.FLAG_MESSAGE: f'Bad data received by controller.\n{e}'})
# return jsonify(Success = True, data = { html_block: render_template(), Model_View_Store.key_basket: new_basket })
# html_block = render_template('_block_store_basket.html', model = model)
# print(f'html_block:\n{html_block}')
# return jsonify(Success = True, data = { 'html_block': html_block, 'basket': {'items': model.basket.to_json_list()}})
return render_template('pages/store/_supplier.html', model = model)
return jsonify({Model_View_Base.FLAG_STATUS: Model_View_Base.FLAG_FAILURE, Model_View_Base.FLAG_MESSAGE: f'Invalid supplier details.\n{form.errors}'})
print(f'Error: {e}')
form_filters = Filters_Supplier()
print(f'form_filters={form_filters}')
model = Model_View_Store_Supplier(form_filters)
if not model.is_user_logged_in:
return redirect(url_for('routes_core.home'))
return render_template('pages/store/_suppliers.html', model = model, datetime = datetime)
@routes_store_supplier.route(Model_View_Store_Supplier.HASH_GET_STORE_SUPPLIER, methods=['POST'])
def filter_supplier():
data = Helper_App.get_request_data(request)
try:
form_filters = Filters_Supplier.from_json(data)
if not form_filters.validate_on_submit():
error_keys = list(form_filters.errors.keys())
try:
error_keys.remove(Supplier.ATTR_ID_PRODUCT_CATEGORY)
except:
pass
try:
error_keys.remove(Supplier.ATTR_ID_PRODUCT)
except:
pass
if error_keys:
return jsonify({
Model_View_Store_Supplier.FLAG_STATUS: Model_View_Store_Supplier.FLAG_FAILURE,
Model_View_Store_Supplier.FLAG_MESSAGE: f'Form invalid.\n{form_filters.errors}'
})
model = Model_View_Store_Supplier(filters_supplier = form_filters)
if not model.is_user_logged_in:
raise Exception('User not logged in.')
return jsonify({
Model_View_Store_Supplier.FLAG_STATUS: Model_View_Store_Supplier.FLAG_SUCCESS,
Model_View_Store_Supplier.FLAG_DATA: {supplier.id_supplier: supplier.to_json() for supplier in model.suppliers}
})
except Exception as e:
return jsonify({
Model_View_Store_Supplier.FLAG_STATUS: Model_View_Store_Supplier.FLAG_FAILURE,
Model_View_Store_Supplier.FLAG_MESSAGE: f'Bad data received by controller.\n{e}'
})
@routes_store_supplier.route(Model_View_Store_Supplier.HASH_SAVE_STORE_SUPPLIER, methods=['POST'])
def save_supplier():
data = Helper_App.get_request_data(request)
try:
form_filters = Filters_Supplier.from_json(data[Model_View_Store_Supplier.FLAG_FORM_FILTERS])
print(f'form_filters: {form_filters}')
suppliers = data[Model_View_Store_Supplier.FLAG_SUPPLIER]
if len(suppliers) == 0:
return jsonify({
Model_View_Store_Supplier.FLAG_STATUS: Model_View_Store_Supplier.FLAG_FAILURE,
Model_View_Store_Supplier.FLAG_MESSAGE: f'No stock items.'
})
print(f'suppliers={suppliers}')
objs_supplier = []
for supplier in suppliers:
objs_supplier.append(Supplier.from_json(supplier))
print(f'objs_supplier={objs_supplier}')
save_errors = Model_View_Store_Supplier.save_suppliers(data.get('comment', 'No comment'), objs_supplier)
if len(save_errors) > 0:
return jsonify({
Model_View_Store_Supplier.FLAG_STATUS: Model_View_Store_Supplier.FLAG_FAILURE,
Model_View_Store_Supplier.FLAG_MESSAGE: f'Save errors: {save_errors}'
})
model_return = Model_View_Store_Supplier(form_filters_old = form_filters)
if not model_return.is_user_logged_in:
raise Exception('User not logged in.')
return jsonify({
Model_View_Store_Supplier.FLAG_STATUS: Model_View_Store_Supplier.FLAG_SUCCESS,
Model_View_Store_Supplier.FLAG_DATA: {supplier.id_supplier: supplier.to_json() for supplier in model_return.suppliers}
})
except Exception as e:
return jsonify({
Model_View_Store_Supplier.FLAG_STATUS: Model_View_Store_Supplier.FLAG_FAILURE,
Model_View_Store_Supplier.FLAG_MESSAGE: f'Bad data received by controller.\n{e}'
})

View File

@@ -0,0 +1,114 @@
"""
Project: PARTS Website
Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: App Routing
Feature: Store Supplier_Purchase_Order Routes
Description:
Initializes the Flask application, sets the configuration based on the environment, and defines two routes (/ and /about) that render templates with the specified titles.
"""
# internal
from business_objects.store.supplier_purchase_order import Supplier_Purchase_Order
from forms.store.supplier_purchase_order import Filters_Supplier_Purchase_Order
from models.model_view_store_supplier_purchase_order import Model_View_Store_Supplier_Purchase_Order
from helpers.helper_app import Helper_App
import lib.argument_validation as av
# external
from datetime import datetime
from flask import Flask, render_template, jsonify, request, render_template_string, send_from_directory, redirect, url_for, session, Blueprint, current_app
from extensions import db, oauth
from urllib.parse import quote_plus, urlencode
from authlib.integrations.flask_client import OAuth
from authlib.integrations.base_client import OAuthError
from urllib.parse import quote, urlparse, parse_qs
import requests
routes_store_supplier_purchase_order = Blueprint('routes_store_supplier_purchase_order', __name__)
@routes_store_supplier_purchase_order.route(Model_View_Store_Supplier_Purchase_Order.HASH_PAGE_STORE_SUPPLIER_PURCHASE_ORDERS, methods=['GET'])
def supplier_purchase_orders():
print('supplier_purchase_orders')
try:
form_filters = Filters_Supplier_Purchase_Order.from_json(request.args)
except Exception as e:
print(f'Error: {e}')
form_filters = Filters_Supplier_Purchase_Order()
print(f'form_filters={form_filters}')
model = Model_View_Store_Supplier_Purchase_Order(form_filters)
if not model.is_user_logged_in:
return redirect(url_for('routes_core.home'))
return render_template('pages/store/_supplier_purchase_orders.html', model = model, datetime = datetime)
@routes_store_supplier_purchase_order.route(Model_View_Store_Supplier_Purchase_Order.HASH_GET_STORE_SUPPLIER_PURCHASE_ORDER, methods=['POST'])
def filter_supplier_purchase_order():
data = Helper_App.get_request_data(request)
try:
form_filters = Filters_Supplier_Purchase_Order.from_json(data)
if not form_filters.validate_on_submit():
error_keys = list(form_filters.errors.keys())
try:
error_keys.remove(Supplier_Purchase_Order.ATTR_ID_PRODUCT_CATEGORY)
except:
pass
try:
error_keys.remove(Supplier_Purchase_Order.ATTR_ID_PRODUCT)
except:
pass
if error_keys:
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_MESSAGE: f'Form invalid.\n{form_filters.errors}'
})
model = Model_View_Store_Supplier_Purchase_Order(filters_supplier_purchase_order = form_filters)
if not model.is_user_logged_in:
raise Exception('User not logged in.')
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_DATA: model.category_list.to_json()
})
except Exception as e:
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_MESSAGE: f'Bad data received by controller.\n{e}'
})
@routes_store_supplier_purchase_order.route(Model_View_Store_Supplier_Purchase_Order.HASH_SAVE_STORE_SUPPLIER_PURCHASE_ORDER, methods=['POST'])
def save_supplier_purchase_order():
data = Helper_App.get_request_data(request)
try:
form_filters = Filters_Supplier_Purchase_Order.from_json(data[Model_View_Store_Supplier_Purchase_Order.FLAG_FORM_FILTERS])
print(f'form_filters: {form_filters}')
supplier_purchase_orders = data[Model_View_Store_Supplier_Purchase_Order.FLAG_SUPPLIER_PURCHASE_ORDER]
if len(supplier_purchase_orders) == 0:
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_MESSAGE: f'No stock items.'
})
print(f'supplier_purchase_orders={supplier_purchase_orders}')
objs_supplier_purchase_order = []
for supplier_purchase_order in supplier_purchase_orders:
objs_supplier_purchase_order.append(Supplier_Purchase_Order.from_json(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)
if len(save_errors) > 0:
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_MESSAGE: f'Save errors: {save_errors}'
})
model_return = Model_View_Store_Supplier_Purchase_Order(filters_supplier_purchase_order_old = form_filters)
if not model_return.is_user_logged_in:
raise Exception('User not logged in.')
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_DATA: model_return.category_list.to_json()
})
except Exception as e:
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_MESSAGE: f'Bad data received by controller.\n{e}'
})

View File

@@ -0,0 +1,132 @@
"""
Project: PARTS Website
Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: DataStores
Feature: Store Manufacturing Purchase Order Purchase Order DataStore
Description:
Datastore for Store Manufacturing Purchase Order Purchase Orders
"""
# internal
# from routes import bp_home
import lib.argument_validation as av
from business_objects.sql_error import SQL_Error
from business_objects.store.manufacturing_purchase_order import Manufacturing_Purchase_Order, Manufacturing_Purchase_Order_Product_Link, Parameters_Manufacturing_Purchase_Order, Manufacturing_Purchase_Order_Temp, Manufacturing_Purchase_Order_Product_Link_Temp
from datastores.datastore_store_base import DataStore_Store_Base
from helpers.helper_db_mysql import Helper_DB_MySQL
from extensions import db
# external
# from abc import ABC, abstractmethod, abstractproperty
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy import text
import stripe
import os
from flask import Flask, session, current_app
from pydantic import BaseModel, ConfigDict
from typing import ClassVar
from datetime import datetime
class DataStore_Store_Manufacturing_Purchase_Order(DataStore_Store_Base):
def __init__(self):
super().__init__()
def get_many_manufacturing_purchase_order(self, parameters_manufacturing_purchase_order):
_m = 'DataStore_Store_Manufacturing_Purchase_Order.get_many_manufacturing_purchase_order'
av.val_instance(parameters_manufacturing_purchase_order, 'parameters_manufacturing_purchase_order', _m, Parameters_Manufacturing_Purchase_Order)
argument_dict = parameters_manufacturing_purchase_order.to_json()
user = self.get_user_session()
argument_dict = {
'a_id_user': user.id_user
, **argument_dict
, 'a_debug': 0
}
print(f'argument_dict: {argument_dict}')
print('executing p_shop_get_many_manufacturing_purchase_order')
result = self.db_procedure_execute('p_shop_get_many_manufacturing_purchase_order', argument_dict)
cursor = result.cursor
print('data received')
# Manufacturing_Purchase_Orders
result_set_1 = cursor.fetchall()
print(f'raw manufacturing_purchase_orders: {result_set_1}')
manufacturing_purchase_orders = []
for row in result_set_1:
new_manufacturing_purchase_order = Manufacturing_Purchase_Order.from_DB_manufacturing_purchase_order(row)
manufacturing_purchase_orders.append(new_manufacturing_purchase_order)
# Manufacturing_Purchase_Orders Items
result_set_1 = cursor.fetchall()
print(f'raw manufacturing_purchase_order_product_links: {result_set_1}')
order_product_links = []
for row in result_set_1:
new_link = Manufacturing_Purchase_Order_Product_Link.from_DB_manufacturing_purchase_order(row)
manufacturing_purchase_orders.append(new_manufacturing_purchase_order)
# Errors
cursor.nextset()
result_set_e = cursor.fetchall()
print(f'raw errors: {result_set_e}')
errors = []
if len(result_set_e) > 0:
errors = [SQL_Error.from_DB_record(row) for row in result_set_e] # (row[0], row[1])
for error in errors:
print(f"Error [{error.code}]: {error.msg}")
DataStore_Store_Manufacturing_Purchase_Order.db_cursor_clear(cursor)
return manufacturing_purchase_orders, errors
@classmethod
def save_manufacturing_purchase_orders(cls, comment, manufacturing_purchase_orders):
_m = 'DataStore_Store_Manufacturing_Purchase_Order.save_manufacturing_purchase_orders'
av.val_str(comment, 'comment', _m)
guid = Helper_DB_MySQL.create_guid_str()
now = datetime.now()
user = cls.get_user_session()
rows_order = []
for manufacturing_purchase_order in manufacturing_purchase_orders:
row = Manufacturing_Purchase_Order_Temp.from_manufacturing_purchase_order(manufacturing_purchase_order)
row.guid = guid
rows_order.append(row)
print(f'order rows: {rows_order}')
DataStore_Store_Base.upload_bulk(Manufacturing_Purchase_Order_Temp.__tablename__, rows_order, 1000)
print('bulk uploaded orders')
rows_link = []
for manufacturing_purchase_order in manufacturing_purchase_orders:
for link in manufacturing_purchase_order.items:
row = Manufacturing_Purchase_Order_Product_Link_Temp.from_manufacturing_purchase_order_product_link(link)
row.guid = guid
rows_link.append(row)
print(f'link rows: {rows_link}')
DataStore_Store_Base.upload_bulk(Manufacturing_Purchase_Order_Product_Link_Temp.__tablename__, rows_link, 1000)
print('bulk uploaded links')
argument_dict_list = {
'a_comment': comment,
'a_guid': guid,
'a_id_user': user.id_user,
'a_debug': 0
}
result = cls.db_procedure_execute('p_shop_save_manufacturing_purchase_order', argument_dict_list)
print('saved manufacturing purchase orders')
# Errors
cursor = result.cursor
cursor.nextset()
result_set_e = cursor.fetchall()
print(f'raw errors: {result_set_e}')
errors = []
if len(result_set_e) > 0:
errors = [SQL_Error.from_DB_record(row) for row in result_set_e]
for error in errors:
print(f"Error [{error.code}]: {error.msg}")
DataStore_Store_Manufacturing_Purchase_Order.db_cursor_clear(cursor)
return errors

View File

@@ -47,10 +47,6 @@ class DataStore_Store_Stock_Item(DataStore_Store_Base):
av.val_instance(parameters_stock_item, 'parameters_stock_item', _m, Parameters_Stock_Item)
argument_dict = parameters_stock_item.to_json()
user = self.get_user_session()
"""
argument_dict['a_id_user'] = user.id_user # 'auth0|6582b95c895d09a70ba10fef' # id_user
argument_dict['a_debug'] = 0
"""
argument_dict = {
'a_id_user': user.id_user
, **argument_dict
@@ -64,11 +60,10 @@ class DataStore_Store_Stock_Item(DataStore_Store_Base):
result = self.db_procedure_execute('p_shop_get_many_stock_item', argument_dict)
cursor = result.cursor
print('data received')
# categories, category_index = DataStore_Store_Stock_Item.input_many_product(cursor)
category_list, errors = DataStore_Store_Stock_Item.input_many_stock_item(cursor, category_list)
DataStore_Store_Stock_Item.db_cursor_clear(cursor)
return category_list, errors # categories, category_index
return category_list, errors
def input_many_stock_item(cursor, category_list):

View File

@@ -4,20 +4,20 @@ Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: DataStores
Feature: Store Stock Item DataStore
Feature: Store Supplier DataStore
Description:
Datastore for Store Stock Items
Datastore for Store Suppliers
"""
# internal
# from routes import bp_home
import lib.argument_validation as av
from business_objects.sql_error import SQL_Error
from business_objects.store.supplier_address import Supplier_Address, Supplier_Address_Temp
from business_objects.store.supplier import Supplier, Parameters_Supplier, Supplier_Temp
from datastores.datastore_store_base import DataStore_Store_Base
from helpers.helper_db_mysql import Helper_DB_MySQL
# from models.model_view_store_checkout import Model_View_Store_Checkout # circular!
from extensions import db
# external
# from abc import ABC, abstractmethod, abstractproperty
@@ -30,54 +30,46 @@ from pydantic import BaseModel, ConfigDict
from typing import ClassVar
from datetime import datetime
# db = SQLAlchemy()
class DataStore_Store_Supplier(DataStore_Store_Base):
# Global constants
# Attributes
def __init__(self):
super().__init__()
# Stock Items
def get_many_supplier(self, parameters_supplier, category_list):
# redundant argument validation?
def get_many_supplier(self, parameters_supplier):
_m = 'DataStore_Store_Supplier.get_many_supplier'
av.val_instance(parameters_supplier, 'parameters_supplier', _m, Parameters_Supplier)
argument_dict = parameters_supplier.to_json()
user = self.get_user_session()
"""
argument_dict['a_id_user'] = user.id_user # 'auth0|6582b95c895d09a70ba10fef' # id_user
argument_dict['a_debug'] = 0
"""
argument_dict = {
'a_id_user': user.id_user
, **argument_dict
, 'a_debug': 0
}
ids_permutation = category_list.get_csv_ids_permutation()
print(f'ids_permutation: {ids_permutation}')
argument_dict['a_ids_product_permutation'] = ids_permutation
print(f'argument_dict: {argument_dict}')
print('executing p_shop_get_many_supplier')
result = self.db_procedure_execute('p_shop_get_many_supplier', argument_dict)
cursor = result.cursor
print('data received')
# categories, category_index = DataStore_Store_Supplier.input_many_product(cursor)
category_list, errors = DataStore_Store_Supplier.input_many_supplier(cursor, category_list)
DataStore_Store_Supplier.db_cursor_clear(cursor)
return category_list, errors # categories, category_index
def input_many_supplier(cursor, category_list):
_m = 'DataStore_Store_Supplier.input_many_supplier'
# Suppliers
result_set_1 = cursor.fetchall()
print(f'raw categories: {result_set_1}')
print(f'raw suppliers: {result_set_1}')
suppliers = []
supplier_indexes = {}
for row in result_set_1:
new_supplier = Supplier.from_DB_supplier(row)
category_list.add_supplier(new_supplier) # , row)
supplier_indexes[new_supplier.id_supplier] = len(suppliers)
suppliers.append(new_supplier)
# Supplier Addresses
cursor.nextset()
result_set_1 = cursor.fetchall()
print(f'raw supplier addresses: {result_set_1}')
for row in result_set_1:
new_address = Supplier_Address.from_DB_supplier(row)
index_supplier = supplier_indexes[new_address.id_supplier]
suppliers[index_supplier].addresses.append(new_address)
# Errors
cursor.nextset()
@@ -88,44 +80,42 @@ class DataStore_Store_Supplier(DataStore_Store_Base):
errors = [SQL_Error.from_DB_record(row) for row in result_set_e] # (row[0], row[1])
for error in errors:
print(f"Error [{error.code}]: {error.msg}")
"""
if len(errors) > 0:
for error in errors:
if error.code == 'PRODUCT_AVAILABILITY':
ids_permutation_unavailable = DataStore_Store_Supplier.get_ids_permutation_from_error_availability(error.msg)
for id_permutation in ids_permutation_unavailable:
index_category = category_list.get_index_category_from_id_permutation(id_permutation)
category = category_list.categories[index_category]
index_product = category.get_index_product_from_id_permutation(id_permutation)
product = category.products[index_product]
index_permutation = product.get_index_permutation_from_id(id_permutation)
permutation = product.permutations[index_permutation]
permutation.is_available = False
if 'region' in error.msg or 'currency' in error.msg:
permutation.is_unavailable_in_currency_or_region = True
"""
DataStore_Store_Supplier.db_cursor_clear(cursor)
return category_list, errors # categories, category_index
return suppliers, errors
@classmethod
def save_suppliers(cls, comment, suppliers):
_m = 'DataStore_Store_Supplier.save_suppliers'
print(f'{_m}\n{suppliers}')
av.val_str(comment, 'comment', _m)
guid = Helper_DB_MySQL.create_guid_str()
now = datetime.now()
user = cls.get_user_session()
rows = []
for supplier in suppliers:
# row = permutation.to_temporary_record()
row = Supplier_Temp.from_supplier(supplier)
row.guid = guid
rows.append(row)
print(f'rows: {rows}')
DataStore_Store_Base.upload_bulk(Supplier_Temp.__tablename__, rows, 1000)
print('bulk uploaded')
print('bulk uploaded suppliers')
rows = []
for supplier in suppliers:
print(f'supplier: {supplier}')
for supplier_address in supplier.addresses:
row = Supplier_Address_Temp.from_supplier_address(supplier_address)
row.guid = guid
rows.append(row)
print(f'rows: {rows}')
DataStore_Store_Base.upload_bulk(Supplier_Address_Temp.__tablename__, rows, 1000)
print('bulk uploaded supplier addresses')
argument_dict_list = {
'a_comment': comment,
@@ -134,7 +124,7 @@ class DataStore_Store_Supplier(DataStore_Store_Base):
'a_debug': 0
}
result = cls.db_procedure_execute('p_shop_save_supplier', argument_dict_list)
print('saved product permutations')
print('saved suppliers')
# Errors
cursor = result.cursor
@@ -146,5 +136,6 @@ class DataStore_Store_Supplier(DataStore_Store_Base):
errors = [SQL_Error.from_DB_record(row) for row in result_set_e] # (row[0], row[1])
for error in errors:
print(f"Error [{error.code}]: {error.msg}")
DataStore_Store_Supplier.db_cursor_clear(cursor)
return errors

View File

@@ -0,0 +1,129 @@
"""
Project: PARTS Website
Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: DataStores
Feature: Store Supplier Purchase Order Purchase Order DataStore
Description:
Datastore for Store Supplier Purchase Order Purchase Orders
"""
# internal
# from routes import bp_home
import lib.argument_validation as av
from business_objects.sql_error import SQL_Error
from business_objects.store.supplier_purchase_order import Supplier_Purchase_Order, Supplier_Purchase_Order_Product_Link, Parameters_Supplier_Purchase_Order, Supplier_Purchase_Order_Temp, Supplier_Purchase_Order_Product_Link_Temp
from datastores.datastore_store_base import DataStore_Store_Base
from helpers.helper_db_mysql import Helper_DB_MySQL
from extensions import db
# external
# from abc import ABC, abstractmethod, abstractproperty
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy import text
import stripe
import os
from flask import Flask, session, current_app
from pydantic import BaseModel, ConfigDict
from typing import ClassVar
from datetime import datetime
class DataStore_Store_Supplier_Purchase_Order(DataStore_Store_Base):
def __init__(self):
super().__init__()
def get_many_supplier_purchase_order(self, parameters_supplier_purchase_order):
_m = 'DataStore_Store_Supplier_Purchase_Order.get_many_supplier_purchase_order'
av.val_instance(parameters_supplier_purchase_order, 'parameters_supplier_purchase_order', _m, Parameters_Supplier_Purchase_Order)
argument_dict = parameters_supplier_purchase_order.to_json()
user = self.get_user_session()
argument_dict = {
'a_id_user': user.id_user
, **argument_dict
, 'a_debug': 0
}
print(f'argument_dict: {argument_dict}')
print('executing p_shop_get_many_supplier_purchase_order')
result = self.db_procedure_execute('p_shop_get_many_supplier_purchase_order', argument_dict)
cursor = result.cursor
print('data received')
# Supplier_Purchase_Orders
result_set_1 = cursor.fetchall()
print(f'raw supplier_purchase_orders: {result_set_1}')
supplier_purchase_orders = []
for row in result_set_1:
new_supplier_purchase_order = Supplier_Purchase_Order.from_DB_supplier_purchase_order(row)
supplier_purchase_orders.append(new_supplier_purchase_order) # , row)
# Errors
cursor.nextset()
result_set_e = cursor.fetchall()
print(f'raw errors: {result_set_e}')
errors = []
if len(result_set_e) > 0:
errors = [SQL_Error.from_DB_record(row) for row in result_set_e] # (row[0], row[1])
for error in errors:
print(f"Error [{error.code}]: {error.msg}")
DataStore_Store_Supplier_Purchase_Order.db_cursor_clear(cursor)
return supplier_purchase_orders, errors
@classmethod
def save_supplier_purchase_orders(cls, comment, supplier_purchase_orders):
_m = 'DataStore_Store_Supplier_Purchase_Order.save_supplier_purchase_orders'
av.val_str(comment, 'comment', _m)
guid = Helper_DB_MySQL.create_guid_str()
now = datetime.now()
user = cls.get_user_session()
rows_order = []
for supplier_purchase_order in supplier_purchase_orders:
row = Supplier_Purchase_Order_Temp.from_supplier_purchase_order(supplier_purchase_order)
row.guid = guid
rows_order.append(row)
print(f'order rows: {rows_order}')
DataStore_Store_Base.upload_bulk(Supplier_Purchase_Order_Temp.__tablename__, rows_order, 1000)
print('bulk uploaded orders')
rows_link = []
for supplier_purchase_order in supplier_purchase_orders:
for link in supplier_purchase_order.items:
row = Supplier_Purchase_Order_Product_Link_Temp.from_supplier_purchase_order_product_link(link)
row.guid = guid
rows_link.append(row)
print(f'link rows: {rows_link}')
DataStore_Store_Base.upload_bulk(Supplier_Purchase_Order_Product_Link_Temp.__tablename__, rows_link, 1000)
print('bulk uploaded links')
argument_dict_list = {
'a_comment': comment,
'a_guid': guid,
'a_id_user': user.id_user,
'a_debug': 0
}
result = cls.db_procedure_execute('p_shop_save_supplier_purchase_order', argument_dict_list)
print('saved supplier purchase orders')
# Errors
cursor = result.cursor
cursor.nextset()
result_set_e = cursor.fetchall()
print(f'raw errors: {result_set_e}')
errors = []
warnings = []
if len(result_set_e) > 0:
for row in result_set_e:
new_error = SQL_Error.from_DB_record(row)
if new_error.code == 'WARNING':
warnings.append(new_error)
else:
errors.append(new_error)
print(f"Error [{new_error.code}]: {new_error.msg}")
cls.db_cursor_clear(cursor)
return errors, warnings

View File

@@ -0,0 +1,38 @@
"""
Project: PARTS Website
Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: Backend
Feature: Forms - Manufacturing Purchase Order Filters data input
Description:
Defines Flask-WTF forms for handling manufacturing purchase order filter input.
"""
# internal
from business_objects.store.store_base import Store_Base
from forms.base import Form_Base
import lib.argument_validation as av
# external
from flask_wtf import FlaskForm
from wtforms import StringField, TextAreaField, SubmitField, BooleanField, IntegerField, SelectField, FloatField, DateField
from wtforms.validators import InputRequired, NumberRange, Regexp, DataRequired, Optional
from flask_wtf.recaptcha import RecaptchaField
from abc import ABCMeta, abstractmethod
class Filters_Manufacturing_Purchase_Order(Form_Base):
active = BooleanField("Active only?", default = True)
date_from = DateField('Date from')
date_to = DateField('Date to')
def __repr__(self):
return f'Filters_Manufacturing_Purchase_Order(active={self.active.data}, date_from={self.date_from.data}, date_to={self.date_to.data})'
@classmethod
def from_json(cls, json):
_m = f'{cls.__name__}.from_json'
form = cls()
form.active.data = av.input_bool(json[Store_Base.FLAG_ACTIVE], 'active', _m)
form.date_from.data = json[Store_Base.FLAG_DATE_FROM]
form.date_to.data = json[Store_Base.FLAG_DATE_TO]
return form

34
forms/store/supplier.py Normal file
View File

@@ -0,0 +1,34 @@
"""
Project: PARTS Website
Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: Backend
Feature: Forms - Supplier Filters data input
Description:
Defines Flask-WTF forms for handling supplier filter input.
"""
# internal
from business_objects.store.store_base import Store_Base
from forms.base import Form_Base
import lib.argument_validation as av
# external
from flask_wtf import FlaskForm
from wtforms import StringField, TextAreaField, SubmitField, BooleanField, IntegerField, SelectField, FloatField
from wtforms.validators import InputRequired, NumberRange, Regexp, DataRequired, Optional
from flask_wtf.recaptcha import RecaptchaField
from abc import ABCMeta, abstractmethod
class Filters_Supplier(Form_Base):
active = BooleanField("Active only?", default = True)
def __repr__(self):
return f'Filters_Supplier(active={self.active.data})'
@classmethod
def from_json(cls, json):
_m = f'{cls.__name__}.from_json'
form = cls()
form.active.data = av.input_bool(json[Store_Base.FLAG_ACTIVE], 'active', _m)
return form

View File

@@ -0,0 +1,38 @@
"""
Project: PARTS Website
Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: Backend
Feature: Forms - Supplier Purchase Order Filters data input
Description:
Defines Flask-WTF forms for handling supplier purchase order filter input.
"""
# internal
from business_objects.store.store_base import Store_Base
from forms.base import Form_Base
import lib.argument_validation as av
# external
from flask_wtf import FlaskForm
from wtforms import StringField, TextAreaField, SubmitField, BooleanField, IntegerField, SelectField, FloatField, DateField
from wtforms.validators import InputRequired, NumberRange, Regexp, DataRequired, Optional
from flask_wtf.recaptcha import RecaptchaField
from abc import ABCMeta, abstractmethod
class Filters_Supplier_Purchase_Order(Form_Base):
active = BooleanField("Active only?", default = True)
date_from = DateField('Date from')
date_to = DateField('Date to')
def __repr__(self):
return f'Filters_Supplier_Purchase_Order(active={self.active.data}, date_from={self.date_from.data}, date_to={self.date_to.data})'
@classmethod
def from_json(cls, json):
_m = f'{cls.__name__}.from_json'
form = cls()
form.active.data = av.input_bool(json[Store_Base.FLAG_ACTIVE], 'active', _m)
form.date_from.data = json[Store_Base.FLAG_DATE_FROM]
form.date_to.data = json[Store_Base.FLAG_DATE_TO]
return form

View File

@@ -49,31 +49,42 @@ class Model_View_Base(BaseModel, ABC):
FLAG_ACCESS_LEVEL_REQUIRED: ClassVar[str] = Product_Category.FLAG_ACCESS_LEVEL_REQUIRED
FLAG_ACTIVE: ClassVar[str] = Base.FLAG_ACTIVE
FLAG_ADD: ClassVar[str] = 'add'
# FLAG_ADD_DELETE: ClassVar[str] = 'add-delete'
FLAG_ADDRESS: ClassVar[str] = Base.FLAG_ADDRESS
FLAG_ADDRESS_LINE_1: ClassVar[str] = Base.FLAG_ADDRESS_LINE_1
FLAG_ADDRESS_LINE_2: ClassVar[str] = Base.FLAG_ADDRESS_LINE_2
FLAG_BOOL_FALSE: ClassVar[str] = 'false'
FLAG_BOOL_TRUE: ClassVar[str] = 'true'
FLAG_CANCEL: ClassVar[str] = 'button-cancel'
# FLAG_CONTACT_US: ClassVar[str] = 'button-contact'
FLAG_CLOSE_TEMPORARY_ELEMENT: ClassVar[str] = 'button-temporary-element-close'
FLAG_CALLBACK: ClassVar[str] = 'callback'
FLAG_CARD: ClassVar[str] = 'card'
FLAG_CITY: ClassVar[str] = Base.FLAG_CITY
FLAG_CLOSE_TEMPORARY_ELEMENT: ClassVar[str] = 'button-temporary-element-close'
FLAG_CODE: ClassVar[str] = Base.FLAG_CODE
FLAG_COLLAPSED: ClassVar[str] = 'collapsed'
FLAG_COLLAPSIBLE: ClassVar[str] = 'collapsible'
FLAG_COLUMN: ClassVar[str] = 'column'
FLAG_COMMENT: ClassVar[str] = 'comment'
# FLAG_CONTACT_US: ClassVar[str] = 'button-contact'
FLAG_CONTAINER: ClassVar[str] = 'container'
FLAG_CONTAINER_INPUT: ClassVar[str] = FLAG_CONTAINER + '-input'
FLAG_COUNTY: ClassVar[str] = Base.FLAG_COUNTY
FLAG_CURRENCY: ClassVar[str] = 'currency'
FLAG_DATA: ClassVar[str] = 'data'
FLAG_DATE_FROM: ClassVar[str] = Base.FLAG_DATE_FROM
FLAG_DATE_TO: ClassVar[str] = Base.FLAG_DATE_TO
FLAG_DELETE: ClassVar[str] = 'delete'
FLAG_DESCRIPTION: ClassVar[str] = Base.FLAG_DESCRIPTION
FLAG_DETAIL: ClassVar[str] = 'detail'
FLAG_DIALOG: ClassVar[str] = 'dialog' # try <dialog> element
FLAG_DIRTY: ClassVar[str] = 'dirty'
FLAG_DISPLAY_ORDER: ClassVar[str] = Base.FLAG_DISPLAY_ORDER
FLAG_EDIT: ClassVar[str] = 'edit'
FLAG_EMAIL: ClassVar[str] = Base.FLAG_EMAIL
FLAG_ERROR: ClassVar[str] = 'error'
FLAG_EXPANDED: ClassVar[str] = 'expanded'
FLAG_FAILURE: ClassVar[str] = 'failure'
FLAG_FAX: ClassVar[str] = Base.FLAG_FAX
FLAG_FILTER: ClassVar[str] = 'filter'
FLAG_FORM: ClassVar[str] = 'form'
FLAG_FORM_FILTERS: ClassVar[str] = 'form-filters'
@@ -93,18 +104,23 @@ class Model_View_Base(BaseModel, ABC):
FLAG_NAV_HOME: ClassVar[str] = 'navHome'
FLAG_NAV_SERVICES: ClassVar[str] = 'navServices'
FLAG_NAV_STORE_HOME: ClassVar[str] = 'navStoreHome'
FLAG_NAV_STORE_MANUFACTURING_PURCHASE_ORDERS: ClassVar[str] = 'navStoreManufacturingPurchaseOrders'
FLAG_NAV_STORE_PRODUCTS: ClassVar[str] = 'navStoreProducts'
FLAG_NAV_STORE_PRODUCT_CATEGORIES: ClassVar[str] = 'navStoreProductCategories'
FLAG_NAV_STORE_PRODUCT_PERMUTATIONS: ClassVar[str] = 'navStoreProductPermutations'
FLAG_NAV_STORE_PRODUCT_PRICES: ClassVar[str] = 'navStoreProductPrices'
FLAG_NAV_STORE_PRODUCT_VARIATIONS: ClassVar[str] = 'navStoreProductVariations'
FLAG_NAV_STORE_STOCK_ITEMS: ClassVar[str] = 'navStoreStockItems'
FLAG_NAV_STORE_SUPPLIERS: ClassVar[str] = 'navStoreSuppliers'
FLAG_NAV_STORE_SUPPLIER_PURCHASE_ORDERS: ClassVar[str] = 'navStoreSupplierPurchaseOrders'
FLAG_NAV_USER_ACCOUNT: ClassVar[str] = 'navUserAccount'
FLAG_NAV_USER_ADMIN: ClassVar[str] = 'navUserAdmin'
FLAG_NAV_USER_LOGIN: ClassVar[str] = 'navUserLogin'
FLAG_NAV_USER_LOGOUT: ClassVar[str] = 'navUserLogout'
FLAG_OVERLAY: ClassVar[str] = 'overlay'
FLAG_PAGE_BODY: ClassVar[str] = 'page-body'
FLAG_PHONE_NUMBER: ClassVar[str] = Base.FLAG_PHONE_NUMBER
FLAG_POSTCODE: ClassVar[str] = Base.FLAG_POSTCODE
FLAG_ROW: ClassVar[str] = 'row'
FLAG_ROW_NEW: ClassVar[str] = 'row-new'
FLAG_ROWS: ClassVar[str] = Base.FLAG_ROWS
@@ -117,6 +133,7 @@ class Model_View_Base(BaseModel, ABC):
FLAG_SUCCESS: ClassVar[str] = 'success'
FLAG_TEMPORARY_ELEMENT: ClassVar[str] = 'temporary-element'
FLAG_USER: ClassVar[str] = User.FLAG_USER
FLAG_WEBSITE: ClassVar[str] = Base.FLAG_WEBSITE
# flagIsDatePicker: ClassVar[str] = 'is-date-picker'
HASH_APPLY_FILTERS_STORE_PRODUCT_PERMUTATION: ClassVar[str] = '/store/permutation_filter'
HASH_CALLBACK_LOGIN: ClassVar[str] = '/callback-login'
@@ -132,7 +149,9 @@ class Model_View_Base(BaseModel, ABC):
HASH_PAGE_SERVICES: ClassVar[str] = '/services'
# HASH_PAGE_STORE_ADMIN: ClassVar[str] = '/store/admin'
HASH_PAGE_STORE_BASKET: ClassVar[str] = '/store/basket'
HASH_PAGE_STORE_CUSTOMER_SALES_ORDERS: ClassVar[str] = '/store/customer_sales_orders'
HASH_PAGE_STORE_HOME: ClassVar[str] = '/store'
HASH_PAGE_STORE_MANUFACTURING_PURCHASE_ORDERS: ClassVar[str] = '/store/manufacturing_purchase_orders'
HASH_PAGE_STORE_PRODUCT_CATEGORIES: ClassVar[str] = '/store/categories'
HASH_PAGE_STORE_PRODUCTS: ClassVar[str] = '/store/products'
HASH_PAGE_STORE_PRODUCT_PERMUTATIONS: ClassVar[str] = '/store/permutations'
@@ -140,6 +159,7 @@ class Model_View_Base(BaseModel, ABC):
HASH_PAGE_STORE_PRODUCT_VARIATIONS: ClassVar[str] = '/store/variations'
HASH_PAGE_STORE_STOCK_ITEMS: ClassVar[str] = '/store/stock_items'
HASH_PAGE_STORE_SUPPLIERS: ClassVar[str] = '/store/suppliers'
HASH_PAGE_STORE_SUPPLIER_PURCHASE_ORDERS: ClassVar[str] = '/store/supplier_purchase_orders'
HASH_PAGE_USER_ACCOUNT: ClassVar[str] = '/user'
HASH_PAGE_USER_ADMIN: ClassVar[str] = '/user/admin'
HASH_PAGE_USER_LOGIN: ClassVar[str] = '/login'

View File

@@ -42,8 +42,12 @@ from abc import abstractmethod
class Model_View_Store(Model_View_Base):
# Global constants
ATTR_FORM_TYPE: ClassVar[str] = 'form-type'
ATTR_ID_CUSTOMER: ClassVar[str] = 'id-customer'
ATTR_ID_CUSTOMER_ADDRESS: ClassVar[str] = Store_Base.ATTR_ID_CUSTOMER_ADDRESS
ATTR_ID_CUSTOMER_SALES_ORDER: ClassVar[str] = 'id-customer-sales-order'
ATTR_ID_DELIVERY_OPTION: ClassVar[str] = Store_Base.ATTR_ID_DELIVERY_OPTION
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_PLANT: ClassVar[str] = 'id-plant'
ATTR_ID_PRODUCT : ClassVar[str] = Product.ATTR_ID_PRODUCT # 'id-product'
ATTR_ID_PRODUCT_CATEGORY: ClassVar[str] = Product.ATTR_ID_PRODUCT_CATEGORY
@@ -53,15 +57,27 @@ class Model_View_Store(Model_View_Base):
ATTR_ID_PRODUCT_VARIATION_TYPE : ClassVar[str] = Product_Variation.ATTR_ID_PRODUCT_VARIATION_TYPE # 'id-variation-type'
ATTR_ID_STOCK_ITEM: ClassVar[str] = Store_Base.ATTR_ID_STOCK_ITEM
ATTR_ID_STORAGE_LOCATION: ClassVar[str] = Store_Base.ATTR_ID_STORAGE_LOCATION
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_PURCHASE_ORDER: ClassVar[str] = Store_Base.ATTR_ID_SUPPLIER_PURCHASE_ORDER
FLAG_BUTTON_BASKET_ADD : ClassVar[str] = Model_View_Base.FLAG_SUBMIT + '.buttonAddToBasket'
FLAG_BUTTON_BUY_NOW : ClassVar[str] = 'buttonBuyNow'
"""
FLAG_COST_LOCAL: ClassVar[str] = Store_Base.FLAG_COST_LOCAL
FLAG_COST_LOCAL_VAT_EXCL: ClassVar[str] = Store_Base.FLAG_COST_LOCAL_VAT_EXCL
FLAG_COST_LOCAL_VAT_INCL: ClassVar[str] = Store_Base.FLAG_COST_LOCAL_VAT_INCL
"""
FLAG_COST_TOTAL_LOCAL_VAT_EXCL: ClassVar[str] = Store_Base.FLAG_COST_TOTAL_LOCAL_VAT_EXCL
FLAG_COST_TOTAL_LOCAL_VAT_INCL: ClassVar[str] = Store_Base.FLAG_COST_TOTAL_LOCAL_VAT_INCL
FLAG_COST_UNIT_LOCAL_VAT_EXCL: ClassVar[str] = Store_Base.FLAG_COST_UNIT_LOCAL_VAT_EXCL
FLAG_COST_UNIT_LOCAL_VAT_INCL: ClassVar[str] = Store_Base.FLAG_COST_UNIT_LOCAL_VAT_INCL
FLAG_COUNT_UNIT_MEASUREMENT_INTERVAL_EXPIRATION_UNSEALED: ClassVar[str] = Product_Permutation.FLAG_COUNT_UNIT_MEASUREMENT_INTERVAL_EXPIRATION_UNSEALED
FLAG_COUNT_UNIT_MEASUREMENT_INTERVAL_RECURRENCE: ClassVar[str] = Product_Permutation.FLAG_COUNT_UNIT_MEASUREMENT_INTERVAL_RECURRENCE
FLAG_COUNT_UNIT_MEASUREMENT_PER_QUANTITY_STEP: ClassVar[str] = Product_Permutation.FLAG_COUNT_UNIT_MEASUREMENT_PER_QUANTITY_STEP
FLAG_CURRENCY_COST: ClassVar[str] = Product_Permutation.FLAG_CURRENCY_COST
FLAG_CUSTOMER: ClassVar[str] = Store_Base.FLAG_CUSTOMER
FLAG_CUSTOMER_ADDRESS: ClassVar[str] = Store_Base.FLAG_CUSTOMER_ADDRESS
FLAG_CUSTOMER_SALES_ORDER: ClassVar[str] = Store_Base.FLAG_CUSTOMER_SALES_ORDER
FLAG_DATE_CONSUMED: ClassVar[str] = Stock_Item.FLAG_DATE_CONSUMED
FLAG_DATE_EXPIRATION: ClassVar[str] = Stock_Item.FLAG_DATE_EXPIRATION
FLAG_DATE_PURCHASED: ClassVar[str] = Stock_Item.FLAG_DATE_PURCHASED
@@ -77,6 +93,7 @@ class Model_View_Store(Model_View_Base):
FLAG_IS_SEALED: ClassVar[str] = Stock_Item.FLAG_IS_SEALED
FLAG_IS_SUBSCRIPTION: ClassVar[str] = Product_Permutation.FLAG_IS_SUBSCRIPTION
FLAG_LATENCY_MANUFACTURE_DAYS: ClassVar[str] = Product_Permutation.FLAG_LATENCY_MANUFACTURE_DAYS
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_RECURRENCE: ClassVar[str] = Product_Permutation.FLAG_NAME_PLURAL_UNIT_MEASUREMENT_INTERVAL_RECURRENCE
FLAG_NAME_PLURAL_UNIT_MEASUREMENT_QUANTITY: ClassVar[str] = Product_Permutation.FLAG_NAME_PLURAL_UNIT_MEASUREMENT_QUANTITY
@@ -84,6 +101,10 @@ class Model_View_Store(Model_View_Base):
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_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_INCL: ClassVar[str] = Store_Base.FLAG_PRICE_TOTAL_LOCAL_VAT_INCL
FLAG_PRICE_UNIT_LOCAL_VAT_EXCL: ClassVar[str] = Store_Base.FLAG_PRICE_UNIT_LOCAL_VAT_EXCL
FLAG_PRICE_UNIT_LOCAL_VAT_INCL: ClassVar[str] = Store_Base.FLAG_PRICE_UNIT_LOCAL_VAT_INCL
FLAG_PRODUCT: ClassVar[str] = Store_Base.FLAG_PRODUCT
FLAG_PRODUCT_CATEGORY: ClassVar[str] = Store_Base.FLAG_PRODUCT_CATEGORY
FLAG_PRODUCT_PERMUTATION: ClassVar[str] = Store_Base.FLAG_PRODUCT_PERMUTATION
@@ -99,6 +120,9 @@ class Model_View_Store(Model_View_Base):
FLAG_REGION: ClassVar[str] = Store_Base.FLAG_REGION
FLAG_STOCK_ITEM: ClassVar[str] = Store_Base.FLAG_STOCK_ITEM
FLAG_STORAGE_LOCATION: ClassVar[str] = Store_Base.FLAG_STORAGE_LOCATION
FLAG_SUPPLIER: ClassVar[str] = Store_Base.FLAG_SUPPLIER
FLAG_SUPPLIER_ADDRESS: ClassVar[str] = Store_Base.FLAG_SUPPLIER_ADDRESS
FLAG_SUPPLIER_PURCHASE_ORDER: ClassVar[str] = Store_Base.FLAG_SUPPLIER_PURCHASE_ORDER
FLAG_SYMBOL_CURRENCY_COST: ClassVar[str] = Product_Permutation.FLAG_SYMBOL_CURRENCY_COST
FLAG_SYMBOL_IS_SUFFIX_NOT_PREFIX_UNIT_MEASUREMENT_INTERVAL_EXPIRATION_UNSEALED: ClassVar[str] = Product_Permutation.FLAG_SYMBOL_IS_SUFFIX_NOT_PREFIX_UNIT_MEASUREMENT_INTERVAL_EXPIRATION_UNSEALED
FLAG_SYMBOL_IS_SUFFIX_NOT_PREFIX_UNIT_MEASUREMENT_INTERVAL_RECURRENCE: ClassVar[str] = Product_Permutation.FLAG_SYMBOL_IS_SUFFIX_NOT_PREFIX_UNIT_MEASUREMENT_INTERVAL_RECURRENCE
@@ -109,15 +133,23 @@ class Model_View_Store(Model_View_Base):
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_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_MANUFACTURING_PURCHASE_ORDER: ClassVar[str] = '/store/manufacturing_purchase_order_get'
HASH_GET_STORE_PRODUCT: ClassVar[str] = '/store/product_get'
HASH_GET_STORE_PRODUCT_CATEGORY: ClassVar[str] = '/store/category_get'
HASH_GET_STORE_PRODUCT_PERMUTATION: ClassVar[str] = '/store/permutation_get'
HASH_GET_STORE_STOCK_ITEM: ClassVar[str] = '/store/stock_item_get'
HASH_GET_STORE_SUPPLIER: ClassVar[str] = '/store/supplier_get'
HASH_GET_STORE_SUPPLIER_PURCHASE_ORDER: ClassVar[str] = '/store/supplier_purchase_order_get'
HASH_PAGE_STORE_BASKET : ClassVar[str] = '/store/basket'
HASH_SAVE_STORE_CUSTOMER_SALES_ORDER: ClassVar[str] = '/store/save_customer_sales_order'
HASH_SAVE_STORE_MANUFACTURING_PURCHASE_ORDER: ClassVar[str] = '/store/save_manufacturing_purchase_order'
HASH_SAVE_STORE_PRODUCT: ClassVar[str] = '/store/save_product'
HASH_SAVE_STORE_PRODUCT_CATEGORY: ClassVar[str] = '/store/save_category'
HASH_SAVE_STORE_PRODUCT_PERMUTATION: ClassVar[str] = '/store/save_permutation'
HASH_SAVE_STORE_STOCK_ITEM: ClassVar[str] = '/store/save_stock_item'
HASH_SAVE_STORE_SUPPLIER: ClassVar[str] = '/store/save_supplier'
HASH_SAVE_STORE_SUPPLIER_PURCHASE_ORDER: ClassVar[str] = '/store/save_supplier_purchase_order'
HASH_STORE_BASKET_ADD : ClassVar[str] = '/store/basket_add'
HASH_STORE_BASKET_DELETE : ClassVar[str] = '/store/basket_delete'
HASH_STORE_BASKET_EDIT : ClassVar[str] = '/store/basket_edit'

View File

@@ -0,0 +1,49 @@
"""
Project: PARTS Website
Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: View Models
Feature: Manufacturing Purchase Order View Model
Description:
Data model for manufacturing purchase order view page
"""
# internal
from models.model_view_store import Model_View_Store
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 forms.store.manufacturing_purchase_order import Filters_Manufacturing_Purchase_Order
import lib.argument_validation as av
class Model_View_Store_Manufacturing_Purchase_Order(Model_View_Store):
currencies: list = None
currency_options: list = None
form_filters: Filters_Manufacturing_Purchase_Order = None
form_filters_old: Filters_Manufacturing_Purchase_Order
manufacturing_purchase_orders: list = None
units_measurement: list = None
units_measurement_time: list = None
@property
def title(self):
return 'Store Manufacturing Purchase Order'
def __init__(self, form_filters_old, hash_page_current=Model_View_Store.HASH_PAGE_STORE_MANUFACTURING_PURCHASE_ORDERS):
_m = 'Model_View_Store_Manufacturing.__init__'
print(f'{_m}\nstarting...')
super().__init__(hash_page_current = hash_page_current, form_filters_old = form_filters_old)
self.form_filters = form_filters_old # Filters_Manufacturing_Purchase_Order.from_json(form_filters_old.to_json())
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()
self.manufacturing_purchase_orders, errors = datastore_manufacturing_purchase_order.get_many_manufacturing_purchase_order(parameters_manufacturing_purchase_order)
self.units_measurement = self.get_many_unit_measurement()
self.units_measurement_time = [unit_measurement for unit_measurement in self.units_measurement if unit_measurement.is_unit_of_time]
self.currencies = self.get_many_currency()
self.currency_options = [currency.to_json_option() for currency in self.currencies]
@classmethod
def save_manufacturing_purchase_orders(cls, comment, list_orders):
_m = f'{cls.__name__}.save_manufacturing_purchase_orders'
return DataStore_Store_Manufacturing_Purchase_Order().save_manufacturing_purchase_orders(comment, list_orders)

View File

@@ -25,16 +25,6 @@ from pydantic import BaseModel
from typing import ClassVar
class Model_View_Store_Product_Permutation(Model_View_Store):
"""
ID_FILTER_CATEGORY: ClassVar[str] = 'id_category'
ID_FILTER_PRODUCT: ClassVar[str] = 'id_product'
ID_FILTER_IS_OUT_OF_STOCK: ClassVar[str] = 'is_out_of_stock'
ID_FILTER_QUANTITY_MIN: ClassVar[str] = 'quantity_min'
ID_FILTER_QUANTITY_MAX: ClassVar[str] = 'quantity_max'
"""
# ID_Filters_Product_Permutation: ClassVar[str] = 'Filters_Product_Permutation'
# KEY_PERMUTATIONS: ClassVar[str] = 'permutations'
category_list: Product_Category_Container = None
category_list_filters: Product_Category_Container = None
currencies: list = None

View File

@@ -25,16 +25,6 @@ from pydantic import BaseModel
from typing import ClassVar
class Model_View_Store_Stock_Item(Model_View_Store):
"""
ID_FILTER_CATEGORY: ClassVar[str] = 'id_category'
ID_FILTER_PRODUCT: ClassVar[str] = 'id_product'
ID_FILTER_IS_OUT_OF_STOCK: ClassVar[str] = 'is_out_of_stock'
ID_FILTER_QUANTITY_MIN: ClassVar[str] = 'quantity_min'
ID_FILTER_QUANTITY_MAX: ClassVar[str] = 'quantity_max'
ID_Form_Filters_Permutation: ClassVar[str] = 'Form_Filters_Permutation'
"""
KEY_PERMUTATIONS: ClassVar[str] = 'permutations'
category_list: Product_Category_Container = None
category_list_filters: Product_Category_Container = None
currencies: list = None

View File

@@ -11,28 +11,52 @@ Data model for supplier view page
"""
# internal
from models.model_view_base import Model_View_Base
from models.model_view_store import Model_View_Store
# from routes import bp_home
from lib import argument_validation as av
from forms.forms import Form_Supplier
from datastores.datastore_store_supplier import DataStore_Store_Supplier
from business_objects.store.supplier import Supplier, Parameters_Supplier
from forms.store.supplier import Filters_Supplier
import lib.argument_validation as av
# external
from typing import ClassVar
class Model_View_Store_Supplier(Model_View_Store):
# Attributes
form: Form_Supplier
FLAG_DEPARTMENT_CONTACT: ClassVar[str] = Supplier.FLAG_DEPARTMENT_CONTACT
FLAG_NAME_COMPANY: ClassVar[str] = Supplier.FLAG_NAME_COMPANY
FLAG_NAME_CONTACT: ClassVar[str] = Supplier.FLAG_NAME_CONTACT
supplier_addresses: list = None
currencies: list = None
currency_options: list = None
form_filters: Filters_Supplier = None
form_filters_old: Filters_Supplier
regions: list = None
suppliers: list = None
units_measurement: list = None
units_measurement_time: list = None
@property
def title(self):
return 'Supplier'
return 'Store Supplier'
def __init__(self, form_filters_old, hash_page_current=Model_View_Store.HASH_PAGE_STORE_SUPPLIERS):
_m = 'Model_View_Store_Supplier.__init__'
print(f'{_m}\nstarting...')
super().__init__(hash_page_current = hash_page_current, form_filters_old = form_filters_old)
self.form_filters = form_filters_old # Filters_Supplier.from_json(form_filters_old.to_json())
parameters_supplier = Parameters_Supplier.from_filters_supplier(self.form_filters)
datastore_supplier = DataStore_Store_Supplier()
self.suppliers, errors = datastore_supplier.get_many_supplier(parameters_supplier)
"""
def __new__(cls, db, info_user, app, form):
# Initialiser - validation
_m = 'Model_View_Supplier.__new__'
av.val_instance(form, 'form', _m, FlaskForm)
return super(Model_View_Supplier, cls).__new__(cls, db, info_user, app)
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]
"""
def __init__(self,form, hash_page_current=Model_View_Base.HASH_PAGE_STORE_SUPPLIERS):
super().__init__(hash_page_current=hash_page_current, form=form)
self.currencies = self.get_many_currency()
self.currency_options = [currency.to_json_option() for currency in self.currencies]
self.supplier_addresses = {}
for supplier in self.suppliers:
self.supplier_addresses[supplier.id_supplier] = [address.to_json() for address in supplier.addresses] if supplier.addresses else []
self.regions = self.get_many_region()
@classmethod
def save_suppliers(cls, comment, list_suppliers):
_m = f'{cls.__name__}.save_suppliers'
return DataStore_Store_Supplier().save_suppliers(comment, list_suppliers)

View File

@@ -0,0 +1,50 @@
"""
Project: PARTS Website
Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: View Models
Feature: Supplier Purchase Order View Model
Description:
Data model for supplier purchase order view page
"""
# internal
from models.model_view_store import Model_View_Store
from datastores.datastore_store_supplier_purchase_order import DataStore_Store_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
import lib.argument_validation as av
class Model_View_Store_Supplier_Purchase_Order(Model_View_Store):
currencies: list = None
currency_options: list = None
form_filters: Filters_Supplier_Purchase_Order = None
form_filters_old: Filters_Supplier_Purchase_Order
supplier_purchase_orders: list = None
units_measurement: list = None
units_measurement_time: list = None
@property
def title(self):
return 'Store Supplier Purchase Order'
def __init__(self, form_filters_old, hash_page_current=Model_View_Store.HASH_PAGE_STORE_SUPPLIER_PURCHASE_ORDERS):
_m = 'Model_View_Store_Supplier.__init__'
print(f'{_m}\nstarting...')
super().__init__(hash_page_current = hash_page_current, form_filters_old = form_filters_old)
self.form_filters = form_filters_old # Filters_Supplier_Purchase_Order.from_json(form_filters_old.to_json())
parameters_supplier_purchase_order = Parameters_Supplier_Purchase_Order.from_filters_supplier_purchase_order(self.form_filters)
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.units_measurement = self.get_many_unit_measurement()
self.units_measurement_time = [unit_measurement for unit_measurement in self.units_measurement if unit_measurement.is_unit_of_time]
self.currencies = self.get_many_currency()
self.currency_options = [currency.to_json_option() for currency in self.currencies]
@classmethod
def save_supplier_purchase_orders(cls, comment, list_orders):
_m = f'{cls.__name__}.save_supplier_purchase_orders'
return DataStore_Store_Supplier_Purchase_Order().save_supplier_purchase_orders(comment, list_orders)

File diff suppressed because it is too large Load Diff

View File

@@ -16,29 +16,42 @@ DROP TABLE IF EXISTS tmp_Price;
DROP TABLE IF EXISTS tmp_Shop_User;
DROP TABLE IF EXISTS tmp_Shop_Order;
DROP TABLE IF EXISTS tmp_Shop_Product;
DROP TABLE IF EXISTS tmp_Product;
DROP TABLE IF EXISTS tmp_Product_Permutation;
DROP TABLE IF EXISTS tmp_Permutation;
DROP TABLE IF EXISTS tmp_Shop_Product_p_shop_calc_user;
DROP TABLE IF EXISTS tmp_Shop_Product_p_Shop_Calc_User;
DROP TABLE IF EXISTS tmp_Shop_Image;
DROP TABLE IF EXISTS tmp_Image;
DROP TABLE IF EXISTS tmp_Product_Image;
DROP TABLE IF EXISTS tmp_Shop_Variation;
DROP TABLE IF EXISTS tmp_Variation;
DROP TABLE IF EXISTS tmp_Variation_Type;
DROP TABLE IF EXISTS tmp_Shop_Discount;
DROP TABLE IF EXISTS tmp_Discount;
DROP TABLE IF EXISTS tmp_Shop_Category;
DROP TABLE IF EXISTS tmp_Category;
DROP TABLE IF EXISTS tmp_Shop_Product_Category;
DROP TABLE IF EXISTS tmp_Product_Category;
DROP TABLE IF EXISTS tmp_Shop_Product_Currency_Region_Link;
DROP TABLE IF EXISTS tmp_Shop_Product_Currency_Link;
DROP TABLE IF EXISTS tmp_User_Role_Link;
DROP TABLE IF EXISTS tmp_Shop_Basket;
DROP TABLE IF EXISTS tmp_Shop_Supplier_Purchase_Order_Product_Link;
DROP TABLE IF EXISTS tmp_Supplier_Purchase_Order_Product_Link;
DROP TABLE IF EXISTS tmp_Shop_Supplier_Purchase_Order;
DROP TABLE IF EXISTS tmp_Supplier_Purchase_Order;
DROP TABLE IF EXISTS tmp_Shop_Supplier;
DROP TABLE IF EXISTS tmp_Supplier;
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_Shop_Manufacturing_Purchase_Order;
DROP TABLE IF EXISTS tmp_Manufacturing_Purchase_Order;
DROP TABLE IF EXISTS tmp_Shop_Customer;
DROP TABLE IF EXISTS tmp_Shop_Customer_Sale_Order_Product_Link;
DROP TABLE IF EXISTS tmp_Shop_Customer_Sale_Order;
# Delete old tables
DROP TABLE IF EXISTS Split_Temp;
DROP TABLE IF EXISTS Split_Key_Value_Pair_Csv_Temp;
@@ -62,6 +75,7 @@ DROP TABLE IF EXISTS Shop_Manufacturing_Purchase_Order_Product_Link_Temp;
DROP TABLE IF EXISTS Shop_Manufacturing_Purchase_Order_Product_Link_Audit;
DROP TABLE IF EXISTS Shop_Manufacturing_Purchase_Order_Product_Link;
DROP TABLE IF EXISTS Shop_Manufacturing_Purchase_Order_Temp;
DROP TABLE IF EXISTS Shop_Manufacturing_Purchase_Order_Audit;
DROP TABLE IF EXISTS Shop_Manufacturing_Purchase_Order;
@@ -69,9 +83,14 @@ DROP TABLE IF EXISTS Shop_Supplier_Purchase_Order_Product_Link_Temp;
DROP TABLE IF EXISTS Shop_Supplier_Purchase_Order_Product_Link_Audit;
DROP TABLE IF EXISTS Shop_Supplier_Purchase_Order_Product_Link;
DROP TABLE IF EXISTS Shop_Supplier_Purchase_Order_Temp;
DROP TABLE IF EXISTS Shop_Supplier_Purchase_Order_Audit;
DROP TABLE IF EXISTS Shop_Supplier_Purchase_Order;
DROP TABLE IF EXISTS Shop_Supplier_Address_Temp;
DROP TABLE IF EXISTS Shop_Supplier_Address_Audit;
DROP TABLE IF EXISTS Shop_Supplier_Address;
DROP TABLE IF EXISTS Shop_Supplier_Temp;
DROP TABLE IF EXISTS Shop_Supplier_Audit;
DROP TABLE IF EXISTS Shop_Supplier;

View File

@@ -5,18 +5,27 @@
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Address';
CREATE TABLE Shop_Address (
id_address INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
id_region INT NOT NULL,
postcode VARCHAR(20) NOT NULL,
address_line_1 VARCHAR(256) NOT NULL,
address_line_2 VARCHAR(256) NOT NULL,
city VARCHAR(256) NOT NULL,
county VARCHAR(256) NOT NULL,
active BIT NOT NULL DEFAULT 1,
created_on DATETIME,
created_by INT,
id_change_set INT,
CONSTRAINT FK_Shop_Address_id_change_set
id_address INT NOT NULL AUTO_INCREMENT PRIMARY KEY
, id_region INT NOT NULL
, CONSTRAINT FK_Shop_Address_id_region
FOREIGN KEY (id_region)
REFERENCES partsltd_prod.Shop_Region(id_region)
/*
, id_supplier INT NULL
, CONSTRAINT FK_Shop_Address_id_supplier
FOREIGN KEY (id_supplier)
REFERENCES partsltd_prod.Shop_Supplier(id_supplier)
*/
, postcode VARCHAR(20) NOT NULL
, address_line_1 VARCHAR(256) NOT NULL
, address_line_2 VARCHAR(256) NOT NULL
, city VARCHAR(256) NOT NULL
, county VARCHAR(256) NOT NULL
, active BIT NOT NULL DEFAULT 1
, created_on DATETIME
, created_by INT
, id_change_set INT
, CONSTRAINT FK_Shop_Address_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES Shop_User_Change_Set(id_change_set)
REFERENCES partsltd_prod.Shop_User_Change_Set(id_change_set)
);

View File

@@ -1,8 +1,6 @@
# Address Audits
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Address_Audit';
CREATE TABLE IF NOT EXISTS Shop_Address_Audit (

View File

@@ -8,10 +8,12 @@ CREATE TABLE IF NOT EXISTS Shop_Supplier (
name_company VARCHAR(255) NOT NULL,
name_contact VARCHAR(255) NULL,
department_contact VARCHAR(255) NULL,
/*
id_address INT NOT NULL,
CONSTRAINT FK_Shop_Supplier_id_address
FOREIGN KEY (id_address)
REFERENCES Shop_Address(id_address),
*/
phone_number VARCHAR(50) NULL,
fax VARCHAR(50) NULL,
email VARCHAR(255) NOT NULL,

View File

@@ -8,11 +8,12 @@ CREATE TABLE IF NOT EXISTS Shop_Supplier_Temp (
name_company VARCHAR(255) NOT NULL,
name_contact VARCHAR(255) NULL,
department_contact VARCHAR(255) NULL,
id_address INT NOT NULL,
-- id_address INT NOT NULL,
phone_number VARCHAR(50) NULL,
fax VARCHAR(50) NULL,
email VARCHAR(255) NOT NULL,
website VARCHAR(255) NULL,
id_currency INT NOT NULL,
active BIT NULL
active BIT NULL,
GUID BINARY(36) NOT NULL
);

View File

@@ -0,0 +1,29 @@
# Supplier Addresses
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Supplier_Address';
CREATE TABLE Shop_Supplier_Address (
id_address INT NOT NULL AUTO_INCREMENT PRIMARY KEY
, id_supplier INT NOT NULL
, CONSTRAINT FK_Shop_Supplier_Address_id_supplier
FOREIGN KEY (id_supplier)
REFERENCES partsltd_prod.Shop_Supplier(id_supplier)
ON UPDATE RESTRICT
, id_region INT NOT NULL
, CONSTRAINT FK_Shop_Supplier_Address_id_region
FOREIGN KEY (id_region)
REFERENCES partsltd_prod.Shop_Region(id_region)
, postcode VARCHAR(20) NOT NULL
, address_line_1 VARCHAR(256) NOT NULL
, address_line_2 VARCHAR(256) NOT NULL
, city VARCHAR(256) NOT NULL
, county VARCHAR(256) NOT NULL
, active BIT NOT NULL DEFAULT 1
, created_on DATETIME
, created_by INT
, id_change_set INT
, CONSTRAINT FK_Shop_Supplier_Address_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES partsltd_prod.Shop_User_Change_Set(id_change_set)
);

View File

@@ -0,0 +1,21 @@
# Supplier Address Audits
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Supplier_Address_Audit';
CREATE TABLE IF NOT EXISTS Shop_Supplier_Address_Audit (
id_audit INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
id_address INT NOT NULL,
CONSTRAINT FK_Shop_Supplier_Address_Audit_id_address
FOREIGN KEY (id_address)
REFERENCES Shop_Supplier_Address(id_address)
ON UPDATE RESTRICT,
name_field VARCHAR(50),
value_prev VARCHAR(500),
value_new VARCHAR(500),
id_change_set INT NOT NULL,
CONSTRAINT FK_Shop_Supplier_Address_Audit_id_change_set
FOREIGN KEY (id_change_set)
REFERENCES Shop_User_Change_Set(id_change_set)
ON UPDATE RESTRICT
);

View File

@@ -0,0 +1,17 @@
# Supplier Addresses Staging
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Supplier_Address_Temp';
CREATE TABLE Shop_Supplier_Address_Temp (
id_address INT NOT NULL AUTO_INCREMENT PRIMARY KEY
, id_supplier INT NOT NULL
, id_region INT NOT NULL
, postcode VARCHAR(20) NOT NULL
, address_line_1 VARCHAR(256) NOT NULL
, address_line_2 VARCHAR(256) NOT NULL
, city VARCHAR(256) NOT NULL
, county VARCHAR(256) NOT NULL
, active BIT NOT NULL DEFAULT 1
, GUID BINARY(36) NOT NULL
);

View File

@@ -15,7 +15,7 @@ CREATE TABLE IF NOT EXISTS Shop_Supplier_Purchase_Order_Product_Link (
CONSTRAINT FK_Shop_Supplier_Purchase_Order_Product_Link_id_permutation
FOREIGN KEY (id_permutation)
REFERENCES Shop_Product_Permutation(id_permutation),
id_currency_cost INT NOT NULL,
-- id_currency_cost INT NOT NULL,
id_unit_quantity INT NOT NULL,
CONSTRAINT FK_Shop_Supplier_Purchase_Order_Product_Link_id_unit_quantity
FOREIGN KEY (id_unit_quantity)

View File

@@ -1,16 +1,22 @@
# Manufacturing Purchase Order
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Manufacturing_Purchase_Order';
CREATE TABLE IF NOT EXISTS Shop_Manufacturing_Purchase_Order (
id_order INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
/*
cost_total_local FLOAT NOT NULL,
id_currency_cost INT NOT NULL,
value_produced_total_local FLOAT NOT NULL,
*/
id_currency INT NOT NULL,
CONSTRAINT FK_Manufacturing_Purchase_Order_id_currency
FOREIGN KEY (id_currency)
REFERENCES Shop_Currency(id_currency),
cost_total_local_VAT_excl FLOAT NOT NULL,
cost_total_local_VAT_incl FLOAT NOT NULL,
price_total_local_VAT_excl FLOAT NOT NULL,
price_total_local_VAT_incl FLOAT NOT NULL,
/*
latency_delivery INT NOT NULL,
quantity_ordered FLOAT NOT NULL,

View File

@@ -0,0 +1,28 @@
# Manufacturing Purchase Order Temp
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Manufacturing_Purchase_Order_Temp';
CREATE TABLE IF NOT EXISTS Shop_Manufacturing_Purchase_Order_Temp (
id_order INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
/*
cost_total_local FLOAT NOT NULL,
*/
id_currency_cost INT NOT NULL,
cost_total_local_VAT_excl FLOAT NOT NULL,
cost_total_local_VAT_incl FLOAT NOT NULL,
price_total_local_VAT_excl FLOAT NOT NULL,
price_total_local_VAT_incl FLOAT NOT NULL,
/*
latency_delivery INT NOT NULL,
quantity_ordered FLOAT NOT NULL,
id_unit_quantity INT NOT NULL,
CONSTRAINT FK_Shop_Manufacturing_Purchase_Order_id_unit_quantity
FOREIGN KEY (id_unit_quantity)
REFERENCES Shop_Unit_Measurement(id_unit),
quantity_received INT NULL,
display_order INT NOT NULL,
*/
active BIT NOT NULL DEFAULT 1,
GUID BINARY(36) NOT NULL
);

View File

@@ -15,16 +15,17 @@ CREATE TABLE IF NOT EXISTS Shop_Manufacturing_Purchase_Order_Product_Link (
CONSTRAINT FK_Manufacturing_Purchase_Order_Product_Link_id_permutation
FOREIGN KEY (id_permutation)
REFERENCES Shop_Product_Permutation(id_permutation),
cost_total_local FLOAT NOT NULL,
id_currency_cost INT NOT NULL,
value_produced_total_local FLOAT NOT NULL,
quantity_used FLOAT NOT NULL,
cost_unit_local_VAT_excl FLOAT NOT NULL,
cost_unit_local_VAT_incl FLOAT NOT NULL,
price_unit_local_VAT_excl FLOAT NOT NULL,
price_unit_local_VAT_incl FLOAT NOT NULL,
id_unit_quantity INT NOT NULL,
CONSTRAINT FK_Manufacturing_Purchase_Order_id_unit_quantity
FOREIGN KEY (id_unit_quantity)
REFERENCES Shop_Unit_Measurement(id_unit_measurement),
latency_manufacture_days INT NOT NULL,
quantity_used FLOAT NOT NULL,
quantity_produced FLOAT NOT NULL,
latency_manufacture_days INT NOT NULL,
display_order INT NOT NULL,
active BIT NOT NULL,
created_on DATETIME,

View File

@@ -1,8 +1,6 @@
# Manufacturing Purchase Order Product Link Temp
-- DROP TABLE Shop_Manufacturing_Purchase_Order_Product_Link_Temp;
-- SELECT * FROM Shop_Manufacturing_Purchase_Order_Product_Link_Temp;
@@ -10,26 +8,17 @@ SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning
CREATE TABLE IF NOT EXISTS Shop_Manufacturing_Purchase_Order_Product_Link_Temp (
id_link INT NOT NULL PRIMARY KEY,
GUID BINARY(36) NOT NULL,
id_order INT NOT NULL,
/*
CONSTRAINT FK_Manuf_Purch_Order_Product_Link_Temp_id_order
FOREIGN KEY (id_order)
REFERENCES Shop_Manufacturing_Purchase_Order(id_order),
*/
id_permutation INT NOT NULL,
CONSTRAINT FK_Manuf_Purch_Order_Product_Link_Temp_id_permutation
FOREIGN KEY (id_permutation)
REFERENCES Shop_Product_Permutation(id_permutation),
cost_total_local FLOAT NOT NULL,
id_currency_cost INT NOT NULL,
quantity_used FLOAT NOT NULL,
id_unit_quantity INT NOT NULL,
CONSTRAINT FK_Manuf_Purch_Order_Product_Link_Temp_id_unit_quantity
FOREIGN KEY (id_unit_quantity)
REFERENCES Shop_Unit_Measurement(id_unit_measurement),
quantity_produced FLOAT NULL,
quantity_used FLOAT NOT NULL,
latency_manufacture_days INT NOT NULL,
quantity_produced FLOAT 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_incl FLOAT NULL,
price_unit_local_VAT_excl FLOAT NULL,
price_unit_local_VAT_incl FLOAT NULL,
GUID BINARY(36) NOT NULL
);

View File

@@ -47,10 +47,12 @@ BEGIN
SELECT NEW.id_supplier, 'department_contact', OLD.department_contact, NEW.department_contact, NEW.id_change_set
WHERE NOT OLD.department_contact <=> NEW.department_contact
UNION
/*
# Changed id_address
SELECT NEW.id_supplier, 'id_address', OLD.id_address, NEW.id_address, NEW.id_change_set
WHERE NOT OLD.id_address <=> NEW.id_address
UNION
*/
# Changed phone_number
SELECT NEW.id_supplier, 'phone_number', OLD.phone_number, NEW.phone_number, NEW.id_change_set
WHERE NOT OLD.phone_number <=> NEW.phone_number

View File

@@ -0,0 +1,65 @@
# Shop Supplier Address
DROP TRIGGER IF EXISTS before_insert_Shop_Supplier_Address;
DROP TRIGGER IF EXISTS before_update_Shop_Supplier_Address;
DELIMITER //
CREATE TRIGGER before_insert_Shop_Supplier_Address
BEFORE INSERT ON Shop_Supplier_Address
FOR EACH ROW
BEGIN
SET NEW.created_on := IFNULL(NEW.created_on, NOW());
SET NEW.created_by := IFNULL(NEW.created_by, IFNULL((SELECT id_user FROM Shop_User WHERE firstname = CURRENT_USER()), -1));
END //
DELIMITER ;;
DELIMITER //
CREATE TRIGGER before_update_Shop_Supplier_Address
BEFORE UPDATE ON Shop_Supplier_Address
FOR EACH ROW
BEGIN
IF OLD.id_change_set <=> NEW.id_change_set THEN
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'New change Set ID must be provided.';
END IF;
INSERT INTO Shop_Supplier_Address_Audit (
id_address,
name_field,
value_prev,
value_new,
id_change_set
)
# Changed region
SELECT NEW.id_address, 'id_region', OLD.id_region, NEW.id_region, NEW.id_change_set
WHERE NOT OLD.id_region <=> NEW.id_region
UNION
# Changed postcode
SELECT NEW.id_address, 'postcode', OLD.postcode, NEW.postcode, NEW.id_change_set
WHERE NOT OLD.postcode <=> NEW.postcode
UNION
# Changed address_line_1
SELECT NEW.id_address, 'address_line_1', OLD.address_line_1, NEW.address_line_1, NEW.id_change_set
WHERE NOT OLD.address_line_1 <=> NEW.address_line_1
UNION
# Changed address_line_2
SELECT NEW.id_address, 'address_line_2', OLD.address_line_2, NEW.address_line_2, NEW.id_change_set
WHERE NOT OLD.address_line_2 <=> NEW.address_line_2
UNION
# Changed city
SELECT NEW.id_address, 'city', OLD.city, NEW.city, NEW.id_change_set
WHERE NOT OLD.city <=> NEW.city
UNION
# Changed county
SELECT NEW.id_address, 'county', OLD.county, NEW.county, NEW.id_change_set
WHERE NOT OLD.county <=> NEW.county
UNION
# Changed active
SELECT NEW.id_address, 'active', CONVERT(CONVERT(OLD.active, SIGNED), CHAR), CONVERT(CONVERT(NEW.active, SIGNED), CHAR), NEW.id_change_set
WHERE NOT (OLD.active <=> NEW.active)
;
END //
DELIMITER ;;

View File

@@ -38,14 +38,18 @@ BEGIN
# Changed id_supplier_ordered
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
UNION
# Changed cost_total_local
SELECT NEW.id_order, 'cost_total_local', OLD.cost_total_local, NEW.cost_total_local, NEW.id_change_set
WHERE NOT OLD.cost_total_local <=> NEW.cost_total_local
UNION
# Changed id_currency_cost
SELECT NEW.id_order, 'id_currency_cost', OLD.id_currency_cost, NEW.id_currency_cost, NEW.id_change_set
WHERE NOT OLD.id_currency_cost <=> NEW.id_currency_cost
UNION
# Changed cost_total_local_VAT_excl
SELECT NEW.id_order, 'cost_total_local_VAT_excl', OLD.cost_total_local_VAT_excl, NEW.cost_total_local_VAT_excl, NEW.id_change_set
WHERE NOT OLD.cost_total_local_VAT_excl <=> NEW.cost_total_local_VAT_excl
UNION
# Changed cost_total_local_VAT_incl
SELECT NEW.id_order, 'cost_total_local_VAT_incl', OLD.cost_total_local_VAT_incl, NEW.cost_total_local_VAT_incl, NEW.id_change_set
WHERE NOT OLD.cost_total_local_VAT_incl <=> NEW.cost_total_local_VAT_incl
/*
UNION
# Changed latency_delivery

View File

@@ -43,14 +43,12 @@ BEGIN
SELECT NEW.id_link, 'id_permutation', OLD.id_permutation, NEW.id_permutation, NEW.id_change_set
WHERE NOT OLD.id_permutation <=> NEW.id_permutation
UNION
# Changed cost_total_local
SELECT NEW.id_link, 'cost_total_local', OLD.cost_total_local, NEW.cost_total_local, NEW.id_change_set
WHERE NOT OLD.cost_total_local <=> NEW.cost_total_local
UNION
/*
# Changed id_currency_cost
SELECT NEW.id_link, 'id_currency_cost', OLD.id_currency_cost, NEW.id_currency_cost, NEW.id_change_set
WHERE NOT OLD.id_currency_cost <=> NEW.id_currency_cost
UNION
*/
# Changed quantity_ordered
SELECT NEW.id_link, 'quantity_ordered', OLD.quantity_ordered, NEW.quantity_ordered, NEW.id_change_set
WHERE NOT OLD.quantity_ordered <=> NEW.quantity_ordered
@@ -74,6 +72,22 @@ BEGIN
# Changed active
SELECT NEW.id_link, 'active', OLD.active, NEW.active, NEW.id_change_set
WHERE NOT OLD.active <=> NEW.active
UNION
# Changed cost_total_local_VAT_excl
SELECT NEW.id_link, 'cost_total_local_VAT_excl', OLD.cost_total_local_VAT_excl, NEW.cost_total_local_VAT_excl, NEW.id_change_set
WHERE NOT OLD.cost_total_local_VAT_excl <=> NEW.cost_total_local_VAT_excl
UNION
# Changed cost_total_local_VAT_incl
SELECT NEW.id_link, 'cost_total_local_VAT_incl', OLD.cost_total_local_VAT_incl, NEW.cost_total_local_VAT_incl, NEW.id_change_set
WHERE NOT OLD.cost_total_local_VAT_incl <=> NEW.cost_total_local_VAT_incl
UNION
# Changed cost_unit_local_VAT_excl
SELECT NEW.id_link, 'cost_unit_local_VAT_excl', OLD.cost_unit_local_VAT_excl, NEW.cost_unit_local_VAT_excl, NEW.id_change_set
WHERE NOT OLD.cost_unit_local_VAT_excl <=> NEW.cost_unit_local_VAT_excl
UNION
# Changed cost_unit_local_VAT_incl
SELECT NEW.id_link, 'cost_unit_local_VAT_incl', OLD.cost_unit_local_VAT_incl, NEW.cost_unit_local_VAT_incl, NEW.id_change_set
WHERE NOT OLD.cost_unit_local_VAT_incl <=> NEW.cost_unit_local_VAT_incl
;
END //
DELIMITER ;;

View File

@@ -35,17 +35,25 @@ BEGIN
value_new,
id_change_set
)
# Changed cost_total_local
SELECT NEW.id_order, 'cost_total_local', OLD.cost_total_local, NEW.cost_total_local, NEW.id_change_set
WHERE NOT OLD.cost_total_local <=> NEW.cost_total_local
# Changed id_currency
SELECT NEW.id_order, 'id_currency', OLD.id_currency, NEW.id_currency, NEW.id_change_set
WHERE NOT OLD.id_currency <=> NEW.id_currency
UNION
# Changed value_produced_total_local
SELECT NEW.id_order, 'value_produced_total_local', OLD.value_produced_total_local, NEW.value_produced_total_local, NEW.id_change_set
WHERE NOT OLD.value_produced_total_local <=> NEW.value_produced_total_local
# Changed cost_total_local_VAT_excl
SELECT NEW.id_order, 'cost_total_local_VAT_excl', OLD.cost_total_local_VAT_excl, NEW.cost_total_local_VAT_excl, NEW.id_change_set
WHERE NOT OLD.cost_total_local_VAT_excl <=> NEW.cost_total_local_VAT_excl
UNION
# Changed id_currency_cost
SELECT NEW.id_order, 'id_currency_cost', OLD.id_currency_cost, NEW.id_currency_cost, NEW.id_change_set
WHERE NOT OLD.id_currency_cost <=> NEW.id_currency_cost
# Changed cost_total_local_VAT_incl
SELECT NEW.id_order, 'cost_total_local_VAT_incl', OLD.cost_total_local_VAT_incl, NEW.cost_total_local_VAT_incl, NEW.id_change_set
WHERE NOT OLD.cost_total_local_VAT_incl <=> NEW.cost_total_local_VAT_incl
UNION
# Changed price_total_local_VAT_excl
SELECT NEW.id_order, 'price_total_local_VAT_excl', OLD.price_total_local_VAT_excl, NEW.price_total_local_VAT_excl, NEW.id_change_set
WHERE NOT OLD.price_total_local_VAT_excl <=> NEW.price_total_local_VAT_excl
UNION
# Changed price_total_local_VAT_incl
SELECT NEW.id_order, 'price_total_local_VAT_incl', OLD.price_total_local_VAT_incl, NEW.price_total_local_VAT_incl, NEW.id_change_set
WHERE NOT OLD.price_total_local_VAT_incl <=> NEW.price_total_local_VAT_incl
UNION
# Changed active
SELECT NEW.id_order, 'active', OLD.active, NEW.active, NEW.id_change_set

View File

@@ -43,25 +43,33 @@ BEGIN
SELECT NEW.id_link, 'id_permutation', OLD.id_permutation, NEW.id_permutation, NEW.id_change_set
WHERE NOT OLD.id_permutation <=> NEW.id_permutation
UNION
# Changed cost_total_local
SELECT NEW.id_link, 'cost_total_local', OLD.cost_total_local, NEW.cost_total_local, NEW.id_change_set
WHERE NOT OLD.cost_total_local <=> NEW.cost_total_local
UNION
# Changed id_currency_cost
SELECT NEW.id_link, 'id_currency_cost', OLD.id_currency_cost, NEW.id_currency_cost, NEW.id_change_set
WHERE NOT OLD.id_currency_cost <=> NEW.id_currency_cost
# Changed id_unit_quantity
SELECT NEW.id_link, 'id_unit_quantity', OLD.id_unit_quantity, NEW.id_unit_quantity, NEW.id_change_set
WHERE NOT OLD.id_unit_quantity <=> NEW.id_unit_quantity
UNION
# Changed quantity_used
SELECT NEW.id_link, 'quantity_used', OLD.quantity_used, NEW.quantity_used, NEW.id_change_set
WHERE NOT OLD.quantity_used <=> NEW.quantity_used
UNION
# Changed id_unit_quantity
SELECT NEW.id_link, 'id_unit_quantity', OLD.id_unit_quantity, NEW.id_unit_quantity, NEW.id_change_set
WHERE NOT OLD.id_unit_quantity <=> NEW.id_unit_quantity
UNION
# Changed quantity_produced
SELECT NEW.id_link, 'quantity_produced', OLD.quantity_produced, NEW.quantity_produced, NEW.id_change_set
WHERE NOT OLD.quantity_produced <=> NEW.quantity_produced
UNION
# Changed cost_unit_local_VAT_excl
SELECT NEW.id_order, 'cost_unit_local_VAT_excl', OLD.cost_unit_local_VAT_excl, NEW.cost_unit_local_VAT_excl, NEW.id_change_set
WHERE NOT OLD.cost_unit_local_VAT_excl <=> NEW.cost_unit_local_VAT_excl
UNION
# Changed cost_unit_local_VAT_incl
SELECT NEW.id_order, 'cost_unit_local_VAT_incl', OLD.cost_unit_local_VAT_incl, NEW.cost_unit_local_VAT_incl, NEW.id_change_set
WHERE NOT OLD.cost_unit_local_VAT_incl <=> NEW.cost_unit_local_VAT_incl
UNION
# Changed price_unit_local_VAT_excl
SELECT NEW.id_order, 'price_unit_local_VAT_excl', OLD.price_unit_local_VAT_excl, NEW.price_unit_local_VAT_excl, NEW.id_change_set
WHERE NOT OLD.price_unit_local_VAT_excl <=> NEW.price_unit_local_VAT_excl
UNION
# Changed price_unit_local_VAT_incl
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
UNION
# Changed latency_manufacture_days
SELECT NEW.id_link, 'latency_manufacture_days', OLD.latency_manufacture_days, NEW.latency_manufacture_days, NEW.id_change_set

View File

@@ -17,27 +17,25 @@ BEGIN
SET v_time_end := CURRENT_TIMESTAMP(6);
SELECT
a_time_start
, UNIX_DATETIME(a_time_start)
, UNIX_TIMESTAMP(a_time_start)
, MICROSECOND(a_time_start) / 1000
, v_time_end
, UNIX_DATETIME(v_time_end)
, UNIX_TIMESTAMP(v_time_end)
, MICROSECOND(v_time_end) / 1000
, v_time_end - a_time_start AS timestamp_delta
, UNIX_DATETIME(v_time_end - a_time_start) AS UNIX_DATETIME_timestamp_delta
, UNIX_TIMESTAMP(v_time_end - a_time_start) AS UNIX_TIMESTAMP_timestamp_delta
, MICROSECOND(v_time_end - a_time_start) AS MICROSECOND_timestamp_delta
-- , TIME_FORMAT(TIMEDIFF(v_time_end, a_time_start), '%H:%i:%s') AS time_difference
, CONCAT(
TIME_FORMAT(TIMEDIFF(v_time_end, a_time_start), '%H hours, %i minutes, %s seconds'),
', ',
DATETIMEDIFF(MICROSECOND, a_time_start, v_time_end) % 1000000 / 1000, ' milliseconds'
TIMESTAMPDIFF(MICROSECOND, a_time_start, v_time_end) % 1000000 / 1000, ' milliseconds'
) AS time_difference
;
END //
DELIMITER ;;
/*
CALL partsltd_prod.p_debug_timing_reporting (
CURRENT_TIMESTAMP(6)

View File

@@ -373,8 +373,8 @@ BEGIN
)
)
AND (
a_get_products_quantity_stock_below_min = 1
AND PP.quantity_stock < PP.quantity_min
a_get_products_quantity_stock_below_min = 0
OR PP.quantity_stock < PP.quantity_min
)
AND (
a_get_inactive_permutation = 1

View File

@@ -447,8 +447,13 @@ BEGIN
-- WHERE guid = v_guid
;
IF a_debug = 1 THEN
SELECT * FROM tmp_Category;
SELECT * FROM tmp_Product;
SELECT * FROM tmp_Permutation;
SELECT * FROM tmp_Image;
END IF;
-- Clean up
DROP TEMPORARY TABLE IF EXISTS tmp_Split;
DROP TEMPORARY TABLE IF EXISTS tmp_Image;
DROP TEMPORARY TABLE IF EXISTS tmp_Category;
@@ -481,7 +486,7 @@ CALL partsltd_prod.p_shop_get_many_product (
, 0 # a_get_inactive_image
, '' # a_ids_image
, 0 # a_get_products_quantity_stock_below_minimum
, 0 # a_debug
, 1 # a_debug
);
select * FROM partsltd_prod.Shop_Calc_User_Temp;

View File

@@ -45,9 +45,11 @@ BEGIN
, msg
)
SELECT
NULL
id_type
, @errno
, @text
FROM partsltd_prod.Shop_Msg_Error_Type MET
WHERE code = 'MYSQL_ERROR'
;
SELECT *
FROM tmp_Msg_Error;
@@ -55,12 +57,12 @@ BEGIN
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');
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);
SET v_code_type_error_no_permission := (SELECT code FROM partsltd_prod.Shop_Msg_Error_Type WHERE code = 'NO_PERMISSION');
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);
SET v_id_permission_supplier = (SELECT id_permission FROM partsltd_prod.Shop_Permission WHERE code = 'STORE_SUPPLIER' LIMIT 1);
SET v_id_access_level_EDIT = (SELECT id_access_level FROM partsltd_prod.Shop_Access_Level WHERE code = 'EDIT');
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_id_permission_supplier := (SELECT id_permission FROM partsltd_prod.Shop_Permission WHERE code = 'STORE_SUPPLIER' LIMIT 1);
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, ''));
@@ -84,6 +86,18 @@ BEGIN
, is_new BIT NOT NULL
);
CREATE TEMPORARY TABLE tmp_Supplier_Address (
id_address INT NOT NULL
, id_supplier INT NOT NULL
, id_region INT NOT NULL
, postcode VARCHAR(20) NOT NULL
, address_line_1 VARCHAR(256) NOT NULL
, address_line_2 VARCHAR(256) NOT NULL
, city VARCHAR(256) NOT NULL
, county VARCHAR(256) NOT NULL
, active BIT NOT NULL
);
CREATE TEMPORARY TABLE IF NOT EXISTS tmp_Msg_Error (
display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT
, id_type INT NOT NULL
@@ -125,7 +139,38 @@ BEGIN
WHERE GUID = a_guid
;
INSERT INTO tmp_Supplier_Address (
id_address
, id_supplier
, id_region
, postcode
, address_line_1
, address_line_2
, city
, county
, active
, name_error
, is_new
)
SELECT
SA_T.id_address
, SA_T.id_supplier
, SA_T.id_region
, SA_T.postcode
, SA_T.address_line_1
, SA_T.address_line_2
, SA_T.city
, SA_T.county
, SA_T.active
, IFNULL(SA_T.postcode, IFNULL(SA_T.city, IFNULL(SA_T.county, IFNULL(SA_T.address_line_1, IFNULL(SA_T.address_line_2, '(No Supplier)'))))) AS name_error
, IFNULL(SA_T.id_address, 0) < 1 AS is_new
FROM partsltd_prod.Shop_Supplier_Address_Temp SA_T
WHERE GUID = a_guid
;
-- Validation
-- Suppliers
/*
# id_address
IF EXISTS (
SELECT *
@@ -159,6 +204,7 @@ BEGIN
)
;
END IF;
*/
# id_currency
IF EXISTS (
SELECT *
@@ -222,6 +268,106 @@ BEGIN
WHERE ISNULL(t_S.email)
;
END IF;
# duplicate
IF EXISTS (SELECT COUNT(*) FROM tmp_Supplier t_S WHERE COUNT(*) > 1 GROUP BY t_S.id_supplier) THEN
INSERT INTO tmp_Msg_Error (
id_type
, code
, msg
)
SELECT
v_id_type_error_bad_data
, v_code_type_error_bad_data
, CONCAT('The following supplier(s) are duplicates: ', GROUP_CONCAT(IFNULL(t_S.name_error, 'NULL') SEPARATOR ', ')) AS msg
FROM tmp_Supplier t_S
WHERE COUNT(*) > 1
GROUP BY t_S.id_supplier
;
END IF;
-- Addresses
# id_supplier
IF EXISTS (
SELECT *
FROM tmp_Supplier_Address t_SA
LEFT JOIN partsltd_prod.Shop_Supplier S ON t_SA.id_supplier = S.id_supplier
WHERE 1=1
AND (
t_SA.id_supplier = 0
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(
'The following supplier address(es) have an invalid or inactive Supplier: '
, GROUP_CONCAT(t_S.name_error SEPARATOR ', ')
) AS msg
FROM tmp_Supplier t_S
LEFT JOIN partsltd_prod.Shop_Supplier S ON t_SA.id_supplier = S.id_supplier
WHERE 1=1
AND (
t_SA.id_supplier = 0
OR S.active = 0
)
;
END IF;
# id_region
IF EXISTS (
SELECT *
FROM tmp_Supplier_Address t_SA
LEFT JOIN partsltd_prod.Shop_Region R ON t_SA.id_region = R.id_region
WHERE 1=1
AND (
t_SA.id_region = 0
OR R.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(
'The following supplier address(es) have an invalid or inactive Supplier: '
, GROUP_CONCAT(t_S.name_error SEPARATOR ', ')
) AS msg
FROM tmp_Supplier t_S
LEFT JOIN partsltd_prod.Shop_Region R ON t_SA.id_region = R.id_region
WHERE 1=1
AND (
t_SA.id_region = 0
OR R.active = 0
)
;
END IF;
# duplicate
IF EXISTS (SELECT COUNT(*) FROM tmp_Supplier_Address t_SA WHERE COUNT(*) > 1 GROUP BY t_SA.id_address) THEN
INSERT INTO tmp_Msg_Error (
id_type
, code
, msg
)
SELECT
v_id_type_error_bad_data
, v_code_type_error_bad_data
, CONCAT('The following supplier address(es) are duplicates: ', GROUP_CONCAT(IFNULL(t_S.name_error, 'NULL') SEPARATOR ', ')) AS msg
FROM tmp_Supplier_Address t_SA
WHERE COUNT(*) > 1
GROUP BY t_SA.id_address
;
END IF;
-- Permissions
IF a_debug = 1 THEN
@@ -262,7 +408,7 @@ BEGIN
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))
, 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;
@@ -291,7 +437,6 @@ BEGIN
SET v_id_change_set := LAST_INSERT_ID();
INSERT INTO partsltd_prod.Shop_Supplier (
-- id_supplier,
id_address
, id_currency
, name_company
@@ -350,6 +495,47 @@ BEGIN
S.id_change_set = v_id_change_set
*/
;
INSERT INTO partsltd_prod.Shop_Supplier_Address (
id_address
, id_supplier
, id_region
, postcode
, address_line_1
, address_line_2
, city
, county
, active
)
SELECT
t_SA.id_address
, t_SA.id_supplier
, t_SA.id_region
, t_SA.postcode
, t_SA.address_line_1
, t_SA.address_line_2
, t_SA.city
, t_SA.county
, t_SA.active
FROM tmp_Supplier_Address t_SA
WHERE t_SA.is_new = 1
;
UPDATE partsltd_prod.Shop_Supplier_Address SA
INNER JOIN tmp_Supplier_Address t_SA
ON SA.id_address = t_SA.id_address
AND t_SA.is_new = 0
SET
SA.id_address = t_SA.id_address
, SA.id_supplier = t_SA.id_supplier
, SA.id_region = t_SA.id_region
, SA.postcode = t_SA.postcode
, SA.address_line_1 = t_SA.address_line_1
, SA.address_line_2 = t_SA.address_line_2
, SA.city = t_SA.city
, SA.county = t_SA.county
, SA.active = t_SA.active
;
COMMIT;
END IF;

View File

@@ -23,24 +23,26 @@ BEGIN
SET v_time_start := CURRENT_TIMESTAMP(6);
SET v_guid := UUID();
SET v_id_access_level_view := (SELECT id_access_level FROM Shop_Access_Level WHERE code = 'VIEW' LIMIT 1);
SET v_code_type_error_bad_data := (SELECT code FROM Shop_Msg_Error_Type WHERE code = 'BAD_DATA' LIMIT 1);
SET v_id_type_error_bad_data := (SELECT id_type FROM Shop_Msg_Error_Type WHERE code = v_code_type_error_bad_data LIMIT 1);
SET v_code_type_error_no_permission := (SELECT code FROM Shop_Msg_Error_Type WHERE code = 'NO_PERMISSION');
SET v_id_type_error_no_permission := (SELECT id_type FROM Shop_Msg_Error_Type WHERE code = v_code_type_error_no_permission);
SET v_id_permission_supplier := (SELECT id_permission FROM Shop_Permission WHERE code = 'STORE_SUPPLIER' LIMIT 1);
SET v_id_access_level_view := (SELECT id_access_level FROM partsltd_prod.Shop_Access_Level WHERE code = 'VIEW' LIMIT 1);
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');
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);
SET v_id_permission_supplier := (SELECT id_permission FROM partsltd_prod.Shop_Permission WHERE code = 'STORE_SUPPLIER' LIMIT 1);
SET a_get_all_supplier := IFNULL(a_get_all_supplier, 0);
SET a_get_inactive_supplier := IFNULL(a_get_inactive_supplier, 0);
SET a_ids_supplier := TRIM(IFNULL(a_ids_supplier, ''));
DROP TEMPORARY TABLE IF EXISTS tmp_Supplier;
DROP TEMPORARY TABLE IF EXISTS tmp_Msg_Error;
DROP TEMPORARY TABLE IF EXISTS tmp_Split;
CREATE TEMPORARY TABLE tmp_Supplier (
id_supplier INT NOT NULL
);
CREATE TABLE IF NOT EXISTS tmp_Msg_Error (
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,
@@ -94,7 +96,7 @@ BEGIN
OR ISNULL(S.id_supplier)
OR (
S.active = 0
AND v_get_inactive_supplier = 0
AND a_get_inactive_supplier = 0
)
) THEN
INSERT INTO tmp_Msg_Error (
@@ -113,7 +115,7 @@ BEGIN
OR ISNULL(S.id_supplier)
OR (
S.active = 0
AND v_get_inactive_supplier = 0
AND a_get_inactive_supplier = 0
)
;
ELSE
@@ -173,14 +175,14 @@ BEGIN
DELETE FROM tmp_Msg_Error;
INSERT INTO tmp_Msg_Error (
, id_type
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 Shop_Permission WHERE id_permission = v_id_permission_supplier LIMIT 1))
, CONCAT('You do not have view permissions for ', (SELECT name FROM Shop_Permission WHERE id_permission = v_id_permission_supplier LIMIT 1))
)
;
END IF;
@@ -193,8 +195,9 @@ BEGIN
# Suppliers
SELECT
t_S.id_supplier,
S.id_address,
S.id_currency,
C.symbol AS symbol_currency,
C.code AS code_currency,
S.name_company,
S.name_contact,
S.department_contact,
@@ -204,14 +207,32 @@ BEGIN
S.website,
S.active
FROM tmp_Supplier t_S
INNER JOIN Shop_Supplier S
ON t_S.id_supplier = S.id_supplier
INNER JOIN partsltd_prod.Shop_Supplier S ON t_S.id_supplier = S.id_supplier
LEFT JOIN partsltd_prod.Shop_Currency C ON S.id_currency = C.id_currency
;
# Supplier Addresses
SELECT
t_S.id_supplier
, SA.id_address
, SA.id_region
, R.name AS name_region
, SA.postcode
, SA.address_line_1
, SA.address_line_2
, SA.city
, SA.county
, SA.active
FROM tmp_Supplier t_S
INNER JOIN partsltd_prod.Shop_Supplier S ON t_S.id_supplier = S.id_supplier
INNER JOIN partsltd_prod.Shop_Supplier_Address SA ON S.id_supplier = SA.id_supplier
LEFT JOIN partsltd_prod.Shop_Region R ON SA.id_region = R.id_region
;
# Errors
SELECT *
FROM tmp_Msg_Error t_ME
INNER JOIN Shop_Msg_Error_Type MET ON t_ME.id_type = MET.id_type
INNER JOIN partsltd_prod.Shop_Msg_Error_Type MET ON t_ME.id_type = MET.id_type
;
IF a_debug = 1 THEN
@@ -220,6 +241,7 @@ BEGIN
DROP TEMPORARY TABLE IF EXISTS tmp_Supplier;
DROP TEMPORARY TABLE IF EXISTS tmp_Msg_Error;
DROP TEMPORARY TABLE IF EXISTS tmp_Split;
IF a_debug = 1 THEN
CALL p_debug_timing_reporting( v_time_start );
@@ -228,6 +250,7 @@ END //
DELIMITER ;;
/*
CALL p_shop_get_many_supplier (
1 -- 'auth0|6582b95c895d09a70ba10fef' # a_id_user
@@ -237,5 +260,4 @@ CALL p_shop_get_many_supplier (
, 0 # a_debug
);
/*
*/

View File

@@ -21,7 +21,7 @@ BEGIN
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 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;
@@ -66,8 +66,8 @@ BEGIN
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);
SET v_code_type_error_warning := (SELECT code FROM partsltd_prod.Shop_Msg_Error_Type WHERE code = 'WARNING');
SET v_id_type_error_warning := (SELECT id_type FROM partsltd_prod.Shop_Msg_Error_Type WHERE code = v_code_type_error_warning);
SET v_id_permission_supplier_purchase_order = (SELECT id_permission FROM partsltd_prod.Shop_Permission WHERE code = 'STORE_SUPPLIER_PURCHASE_ORDER' LIMIT 1);
SET v_id_access_level_edit = (SELECT id_access_level FROM partsltd_prod.Shop_Access_Level WHERE code = 'EDIT');
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') LIMIT 1);
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, ''));
@@ -81,13 +81,14 @@ BEGIN
, id_supplier_ordered INT NOT NULL
, id_currency_cost INT NOT NULL
-- , cost_total_local FLOAT NOT NULL
, active BIT 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
-- , id_currency_cost INT NOT NULL
, quantity_ordered FLOAT NOT NULL
, id_unit_quantity INT NOT NULL
, quantity_received FLOAT NULL
@@ -127,9 +128,9 @@ BEGIN
id_link
, id_order
, id_permutation
, id_currency_cost
, quantity_ordered
-- , id_currency_cost
, id_unit_quantity
, quantity_ordered
, quantity_received
, latency_delivery_days
, display_order
@@ -144,14 +145,14 @@ BEGIN
)
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(SPOPL_T.id_order, SPOPL.id_order), 0) AS id_order
, IFNULL(IFNULL(SPOPL_T.id_permutation, 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.quantity_ordered, SPOPL.quantity_ordered), 0) AS quantity_ordered
-- , 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
, 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.active, SPOPL.active), 1) AS active
, CONCAT(
fn_shop_get_product_permutation_name(SPOPL_T.id_permutation)
@@ -285,8 +286,8 @@ BEGIN
# id_unit_quantity
IF EXISTS (
SELECT *
FROM tmp_Supplier_Purchase_Order t_SPO
LEFT JOIN partsltd_prod.Shop_Unit_Measurement UM ON t_SPO.id_unit_quantity = UM.id_unit_measurement
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)
@@ -306,8 +307,8 @@ BEGIN
'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_Stock_Item t_SPO
LEFT JOIN partsltd_prod.Shop_Unit_Measurement UM ON t_SPO.id_unit_quantity = UM.id_unit_measurement
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)
@@ -318,7 +319,7 @@ BEGIN
# Invalid quantity ordered
IF EXISTS (
SELECT *
FROM tmp_Supplier_Purchase_Order_Product_Link
FROM tmp_Supplier_Purchase_Order_Product_Link t_SPOPL
WHERE
ISNULL(t_SPOPL.quantity_ordered)
OR t_SPOPL.quantity_ordered <= 0
@@ -342,7 +343,7 @@ BEGIN
# Invalid quantity received
IF EXISTS (
SELECT *
FROM tmp_Supplier_Purchase_Order_Product_Link
FROM tmp_Supplier_Purchase_Order_Product_Link t_SPOPL
WHERE t_SPOPL.quantity_received < 0
) THEN
INSERT INTO tmp_Msg_Error (
@@ -362,7 +363,7 @@ BEGIN
# Invalid delivery latency
IF EXISTS (
SELECT *
FROM tmp_Supplier_Purchase_Order_Product_Link
FROM tmp_Supplier_Purchase_Order_Product_Link t_SPOPL
WHERE t_SPOPL.latency_delivery_days < 0
) THEN
INSERT INTO tmp_Msg_Error (
@@ -494,7 +495,7 @@ BEGIN
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))
, 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;
@@ -513,8 +514,30 @@ BEGIN
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
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;
-- Transaction
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error) THEN
@@ -559,7 +582,7 @@ BEGIN
INSERT INTO Shop_Supplier_Purchase_Order_Product_Link (
id_order
, id_permutation
, id_currency_cost
-- , id_currency_cost
, id_unit_quantity
, quantity_ordered
, quantity_received
@@ -574,7 +597,7 @@ BEGIN
SELECT
t_SPOPL.id_order
, t_SPOPL.id_permutation
, t_SPOPL.id_currency_cost
-- , t_SPOPL.id_currency_cost
, t_SPOPL.id_unit_quantity
, t_SPOPL.quantity_ordered
, t_SPOPL.quantity_received
@@ -583,8 +606,8 @@ BEGIN
, t_SPOPL.active
, t_SPOPL.cost_total_local_VAT_excl
, t_SPOPL.cost_total_local_VAT_incl
a_id_user
v_id_change_set
, a_id_user
, v_id_change_set
FROM tmp_Supplier_Purchase_Order_Product_Link t_SPOPL
WHERE t_SPOPL.is_new = 1
;
@@ -610,7 +633,7 @@ BEGIN
SET
SPOPL.id_order = t_SPOPL.id_order,
SPOPL.id_permutation = t_SPOPL.id_permutation,
SPOPL.id_currency_cost = t_SPOPL.id_currency_cost,
-- SPOPL.id_currency_cost = t_SPOPL.id_currency_cost,
SPOPL.id_unit_quantity = t_SPOPL.id_unit_quantity,
SPOPL.quantity_ordered = t_SPOPL.quantity_ordered,
SPOPL.quantity_received = t_SPOPL.quantity_received,
@@ -632,6 +655,7 @@ BEGIN
;
COMMIT;
END IF;
# Errors
SELECT *

View File

@@ -26,19 +26,19 @@ BEGIN
DECLARE v_has_filter_date_from BIT;
DECLARE v_has_filter_date_to BIT;
DECLARE v_id_access_level_view INT;
DECLARE v_ids_permission_supplier_purchase_order INT;
DECLARE v_ids_permission_supplier_purchase_order VARCHAR(100);
DECLARE v_id_type_error_bad_data INT;
DECLARE v_id_type_error_no_permission INT;
DECLARE v_time_start TIMESTAMP(6);
SET v_time_start := CURRENT_TIMESTAMP(6);
SET v_guid := UUID();
SET v_id_access_level_view := (SELECT id_access_level FROM Shop_Access_Level WHERE code = 'VIEW' LIMIT 1);
SET v_code_type_error_bad_data := (SELECT code FROM Shop_Msg_Error_Type WHERE code = 'BAD_DATA' LIMIT 1);
SET v_id_type_error_bad_data := (SELECT id_type FROM Shop_Msg_Error_Type WHERE code = v_code_type_error_bad_data LIMIT 1);
SET v_code_type_error_no_permission := (SELECT code FROM Shop_Msg_Error_Type WHERE code = 'NO_PERMISSION');
SET v_id_type_error_no_permission := (SELECT id_type FROM Shop_Msg_Error_Type WHERE code = v_code_type_error_no_permission);
SET v_ids_permission_supplier_purchase_order := (SELECT id_permission FROM Shop_Permission WHERE code = 'STORE_SUPPLIER_PURCHASE_ORDER' LIMIT 1);
SET v_id_access_level_view := (SELECT id_access_level FROM partsltd_prod.Shop_Access_Level WHERE code = 'VIEW' LIMIT 1);
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_ids_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 a_get_all_supplier := IFNULL(a_get_all_supplier, 1);
SET a_get_inactive_supplier := IFNULL(a_get_inactive_supplier, 0);
@@ -51,32 +51,38 @@ BEGIN
SET a_date_to := IFNULL(a_date_to, NULL);
SET a_debug := IFNULL(a_debug, 0);
DROP TABLE IF EXISTS tmp_Supplier_Purchase_Order_Product_Link;
DROP TABLE IF EXISTS tmp_Supplier_Purchase_Order;
DROP TABLE IF EXISTS tmp_Supplier;
DROP TABLE IF EXISTS tmp_Product;
DROP TEMPORARY TABLE IF EXISTS tmp_Supplier_Purchase_Order_Product_Link;
DROP TEMPORARY TABLE IF EXISTS tmp_Supplier_Purchase_Order;
DROP TEMPORARY TABLE IF EXISTS tmp_Supplier;
DROP TEMPORARY TABLE IF EXISTS tmp_Permutation;
DROP TEMPORARY TABLE IF EXISTS tmp_Msg_Error;
DROP TEMPORARY TABLE IF EXISTS tmp_Split;
CREATE TABLE tmp_Supplier (
CREATE TEMPORARY TABLE tmp_Supplier (
id_supplier INT NOT NULL PRIMARY KEY
);
CREATE TABLE tmp_Supplier_Purchase_Order (
CREATE TEMPORARY TABLE tmp_Supplier_Purchase_Order (
id_order INT NOT NULL PRIMARY KEY
);
CREATE TABLE tmp_Supplier_Purchase_Order_Product_Link (
id_link INT NOT NULL PRIMARY KEY,
id_order INT NOT NULL,
id_permutation INT NOT NULL
CREATE TEMPORARY TABLE tmp_Permutation (
id_permutation INT NOT NULL PRIMARY KEY
);
CREATE TABLE IF NOT EXISTS tmp_Msg_Error (
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
);
CREATE TEMPORARY TABLE IF NOT EXISTS tmp_Split (
substring VARCHAR(4000) NOT NULL
, as_int INT NULL
);
DELETE FROM tmp_Split;
SET v_has_filter_supplier = CASE WHEN a_ids_supplier = '' THEN 0 ELSE 1 END;
SET v_has_filter_order = CASE WHEN a_ids_order = '' THEN 0 ELSE 1 END;
SET v_has_filter_permutation = CASE WHEN a_ids_permutation = '' THEN 0 ELSE 1 END;
@@ -189,7 +195,7 @@ BEGIN
OR ISNULL(S.id_supplier)
OR (
S.active = 0
AND v_get_inactive_supplier = 0
AND a_get_inactive_supplier = 0
)
) THEN
INSERT INTO tmp_Msg_Error (
@@ -208,7 +214,7 @@ BEGIN
OR ISNULL(S.id_supplier)
OR (
S.active = 0
AND v_get_inactive_supplier = 0
AND a_get_inactive_supplier = 0
)
;
ELSE
@@ -267,7 +273,7 @@ BEGIN
OR ISNULL(SPO.id_order)
OR (
SPO.active = 0
AND v_get_inactive_order = 0
AND a_get_inactive_order = 0
)
) THEN
INSERT INTO tmp_Msg_Error (
@@ -286,7 +292,7 @@ BEGIN
OR ISNULL(SPO.id_order)
OR (
SPO.active = 0
AND v_get_inactive_order = 0
AND a_get_inactive_order = 0
)
;
ELSE
@@ -340,40 +346,40 @@ BEGIN
v_guid
, a_id_user
, FALSE -- get inactive users
, v_id_permission_supplier_purchase_order
, v_ids_permission_supplier_purchase_order
, v_id_access_level_view
, '' -- ids_product
, 0 -- a_debug
;
SELECT * from Shop_Calc_User_Temp;
SELECT * from partsltd_prod.Shop_Calc_User_Temp;
END IF;
CALL p_shop_calc_user(
v_guid
, a_id_user
, FALSE -- get inactive users
, v_id_permission_supplier_purchase_order
, v_ids_permission_supplier_purchase_order
, v_id_access_level_view
, '' -- ids_product
, 0 -- a_debug
);
IF a_debug = 1 THEN
SELECT * from Shop_Calc_User_Temp;
SELECT * from partsltd_prod.Shop_Calc_User_Temp;
END IF;
IF NOT EXISTS (SELECT can_view FROM 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 = v_guid) THEN
DELETE FROM tmp_Msg_Error;
INSERT INTO tmp_Msg_Error (
, id_type
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 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_id_permission_supplier LIMIT 1))
)
;
END IF;
@@ -399,7 +405,7 @@ BEGIN
S.id_currency,
t_S.active
FROM tmp_Supplier t_S
INNER JOIN Shop_Supplier S
INNER JOIN partsltd_prod.Shop_Supplier S
ON t_S.id_supplier = S.id_supplier
;
*/
@@ -412,6 +418,12 @@ BEGIN
, SPO.cost_total_local_VAT_excl
, SPO.cost_total_local_VAT_incl
, SPO.active
, SPO.created_on
, CONCAT(
SPO.cost_total_local_VAT_excl
, ' on '
, SPO.created_on
) AS name
FROM tmp_Supplier_Purchase_Order t_SPO
INNER JOIN partsltd_prod.Shop_Supplier_Purchase_Order SPO ON SPO.id_order = t_SPO.id_order
;
@@ -422,23 +434,25 @@ BEGIN
, SPOPL.id_order
, SPOPL.id_permutation
, fn_shop_get_product_permutation_name(SPOPL.id_permutation) AS name_permutation
, SPOPL.id_currency_cost
-- , SPOPL.id_currency_cost
, SPOPL.id_unit_quantity
, SPOPL.quantity_ordered
, SPOPL.quantity_received
, SPOPL.latency_delivery_days
, SPOPL.display_order
, SPO.cost_total_local_VAT_excl
, SPO.cost_total_local_VAT_incl
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 tmp_Supplier_Purchase_Order t_SPO ON SPOPL.id_order = t_SPO.id_order
, SPOPL.cost_total_local_VAT_excl
, SPOPL.cost_total_local_VAT_incl
, SPOPL.cost_unit_local_VAT_excl
, SPOPL.cost_unit_local_VAT_incl
, SPOPL.active
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
;
# Errors
SELECT *
FROM tmp_Msg_Error t_ME
INNER JOIN Shop_Msg_Error_Type MET ON t_ME.id_type = MET.id_type
INNER JOIN partsltd_prod.Shop_Msg_Error_Type MET ON t_ME.id_type = MET.id_type
;
IF a_debug = 1 THEN
@@ -450,7 +464,9 @@ BEGIN
DROP TEMPORARY TABLE IF EXISTS tmp_Supplier_Purchase_Order_Product_Link;
DROP TEMPORARY TABLE IF EXISTS tmp_Supplier_Purchase_Order;
DROP TEMPORARY TABLE IF EXISTS tmp_Supplier;
DROP TEMPORARY TABLE IF EXISTS tmp_Permutation;
DROP TEMPORARY TABLE IF EXISTS tmp_Msg_Error;
DROP TEMPORARY TABLE IF EXISTS tmp_Split;
IF a_debug = 1 THEN
CALL p_debug_timing_reporting( v_time_start );
@@ -459,15 +475,14 @@ END //
DELIMITER ;;
/*
CALL p_shop_get_many_supplier_purchase_order (
'', # a_id_user
1, # a_id_user
1, # a_get_all_supplier
0, # a_get_inactive_supplier
'', # a_ids_supplier
1, # a_get_all_order
-- 0, # a_get_inactive_order
0, # a_get_inactive_order
'', # a_ids_order
'', # a_ids_permutation
NULL, # a_date_from
@@ -475,4 +490,5 @@ CALL p_shop_get_many_supplier_purchase_order (
, 0 # a_debug
);
/*
*/

View File

@@ -20,7 +20,7 @@ BEGIN
DECLARE v_code_type_error_no_permission VARCHAR(50);
DECLARE v_id_access_level_edit INT;
DECLARE v_id_change_set INT;
DECLARE v_id_permission_manufacturing_purchase_order INT;
DECLARE v_ids_permission_manufacturing_purchase_order VARCHAR(100);
DECLARE v_id_type_error_bad_data INT;
DECLARE v_id_type_error_no_permission INT;
DECLARE v_ids_product_permission TEXT;
@@ -58,12 +58,12 @@ BEGIN
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');
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);
SET v_code_type_error_no_permission := (SELECT code FROM partsltd_prod.Shop_Msg_Error_Type WHERE code = 'NO_PERMISSION');
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);
SET v_id_permission_manufacturing_purchase_order = (SELECT id_permission FROM partsltd_prod.Shop_Permission WHERE code = 'STORE_SUPPLIER_PURCHASE_ORDER' LIMIT 1);
SET v_id_access_level_edit = (SELECT id_access_level FROM partsltd_prod.Shop_Access_Level WHERE code = 'EDIT');
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_ids_permission_manufacturing_purchase_order := (SELECT GROUP_CONCAT(id_permission SEPARATOR ',') FROM partsltd_prod.Shop_Permission WHERE code IN ('STORE_MANUFACTURING_PURCHASE_ORDER', 'STORE_PRODUCT'));
SET v_id_access_level_edit := (SELECT id_access_level FROM partsltd_prod.Shop_Access_Level WHERE code = 'EDIT' LIMIT 1);
CALL p_validate_guid ( a_guid );
SET a_comment := TRIM(IFNULL(a_comment, ''));
@@ -136,14 +136,14 @@ BEGIN
)
SELECT
IFNULL(SPOPL_T.id_link, 0) AS id_link
, IFNULL(IFNULL(SPOPL_T.id_order, MPOPL.id_order) 0) AS id_order
, IFNULL(IFNULL(SPOPL_T.id_order, MPOPL.id_order), 0) AS id_order
, IFNULL(IFNULL(SPOPL_T.id_permutation, MPOPL.id_permutation), 0) AS id_permutation
, IFNULL(IFNULL(SPOPL_T.id_currency_cost, MPOPL.id_currency_cost) 0) AS id_currency_cost
, IFNULL(IFNULL(SPOPL_T.id_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(SPOPL_T.quantity_received, MPOPL.quantity_received) AS quantity_received
, IFNULL(SPOPL_T.latency_delivery_days, MPOPL.latency_delivery_days) AS latency_delivery_days
, 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
, RANK() OVER (PARTITION BY IFNULL(IFNULL(SPOPL_T.id_order, MPOPL.id_order), 0) ORDER BY IFNULL(IFNULL(SPOPL_T.display_order, MPOPL.display_order), 0)) AS display_order
, IFNULL(IFNULL(SPOPL_T.active, MPOPL.active), 1) AS active
, CONCAT(
fn_shop_get_product_permutation_name(SPOPL_T.id_permutation)
@@ -418,7 +418,7 @@ BEGIN
v_guid
, a_id_user
, FALSE -- get inactive users
, v_id_permission_manufacturing_purchase_order
, v_ids_permission_manufacturing_purchase_order
, v_id_access_level_edit
, v_ids_product_permission -- ids_product
, 0 -- a_debug
@@ -430,7 +430,7 @@ BEGIN
v_guid
, a_id_user
, FALSE -- get inactive users
, v_id_permission_manufacturing_purchase_order
, v_ids_permission_manufacturing_purchase_order
, v_id_access_level_edit
, v_ids_product_permission -- ids_product
, 0 -- a_debug
@@ -451,7 +451,7 @@ BEGIN
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_manufacturing LIMIT 1))
, CONCAT('You do not have view permissions for ', (SELECT name FROM partsltd_prod.Shop_Permission WHERE id_permission = v_id_permission_manufacturing LIMIT 1))
)
;
END IF;
@@ -527,8 +527,8 @@ BEGIN
, t_MPOPL.active
, t_MPOPL.cost_total_local_VAT_excl
, t_MPOPL.cost_total_local_VAT_incl
a_id_user
v_id_change_set
, a_id_user
, v_id_change_set
FROM tmp_Manufacturing_Purchase_Order_Product_Link t_MPOPL
WHERE t_MPOPL.is_new = 1
;
@@ -575,6 +575,7 @@ BEGIN
;
COMMIT;
END IF;
# Errors
SELECT *

View File

@@ -5,9 +5,6 @@ DROP PROCEDURE IF EXISTS p_shop_get_many_manufacturing_purchase_order;
DELIMITER //
CREATE PROCEDURE p_shop_get_many_manufacturing_purchase_order (
IN a_id_user INT,
IN a_get_all_manufacturing BIT,
IN a_get_inactive_manufacturing BIT,
IN a_ids_manufacturing TEXT,
IN a_get_all_order BIT,
IN a_get_inactive_order BIT,
IN a_ids_order TEXT,
@@ -25,19 +22,19 @@ BEGIN
DECLARE v_has_filter_date_from BIT;
DECLARE v_has_filter_date_to BIT;
DECLARE v_id_access_level_view INT;
DECLARE v_ids_permission_manufacturing_purchase_order INT;
DECLARE v_ids_permission_manufacturing_purchase_order VARCHAR(100);
DECLARE v_id_type_error_bad_data INT;
DECLARE v_id_type_error_no_permission INT;
DECLARE v_time_start TIMESTAMP(6);
SET v_time_start := CURRENT_TIMESTAMP(6);
SET v_guid := UUID();
SET v_id_access_level_view := (SELECT id_access_level FROM Shop_Access_Level WHERE code = 'VIEW' LIMIT 1);
SET v_code_type_error_bad_data := (SELECT code FROM Shop_Msg_Error_Type WHERE code = 'BAD_DATA' LIMIT 1);
SET v_id_type_error_bad_data := (SELECT id_type FROM Shop_Msg_Error_Type WHERE code = v_code_type_error_bad_data LIMIT 1);
SET v_code_type_error_no_permission := (SELECT code FROM Shop_Msg_Error_Type WHERE code = 'NO_PERMISSION');
SET v_id_type_error_no_permission := (SELECT id_type FROM Shop_Msg_Error_Type WHERE code = v_code_type_error_no_permission);
SET v_ids_permission_manufacturing_purchase_order := (SELECT id_permission FROM Shop_Permission WHERE code = 'STORE_SUPPLIER_PURCHASE_ORDER' LIMIT 1);
SET v_id_access_level_view := (SELECT id_access_level FROM partsltd_prod.Shop_Access_Level WHERE code = 'VIEW' LIMIT 1);
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');
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);
SET v_ids_permission_manufacturing_purchase_order := (SELECT GROUP_CONCAT(id_permission SEPARATOR ',') FROM partsltd_prod.Shop_Permission WHERE code IN ('STORE_MANUFACTURING_PURCHASE_ORDER', 'STORE_PRODUCT'));
SET a_get_all_order := IFNULL(a_get_all_order, 1);
SET a_get_inactive_order := IFNULL(a_get_inactive_order, 0);
@@ -47,27 +44,33 @@ BEGIN
SET a_date_to := IFNULL(a_date_to, NULL);
SET a_debug := IFNULL(a_debug, 0);
DROP TABLE IF EXISTS tmp_Manufacturing_Purchase_Order_Product_Link;
DROP TABLE IF EXISTS tmp_Manufacturing_Purchase_Order;
DROP TABLE IF EXISTS tmp_Product;
DROP TEMPORARY TABLE IF EXISTS tmp_Manufacturing_Purchase_Order_Product_Link;
DROP TEMPORARY TABLE IF EXISTS tmp_Manufacturing_Purchase_Order;
DROP TEMPORARY TABLE IF EXISTS tmp_Permutation;
DROP TEMPORARY TABLE IF EXISTS tmp_Msg_Error;
DROP TEMPORARY TABLE IF EXISTS tmp_Split;
CREATE TABLE tmp_Manufacturing_Purchase_Order (
CREATE TEMPORARY TABLE tmp_Manufacturing_Purchase_Order (
id_order INT NOT NULL PRIMARY KEY
);
CREATE TABLE tmp_Manufacturing_Purchase_Order_Product_Link (
id_link INT NOT NULL PRIMARY KEY,
id_order INT NOT NULL,
id_permutation INT NOT NULL
CREATE TEMPORARY TABLE tmp_Permutation (
id_permutation INT NOT NULL PRIMARY KEY
);
CREATE TABLE IF NOT EXISTS tmp_Msg_Error (
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
);
CREATE TEMPORARY TABLE IF NOT EXISTS tmp_Split (
substring VARCHAR(4000) NOT NULL
, as_int INT NULL
);
DELETE FROM tmp_Split;
SET v_has_filter_order = CASE WHEN a_ids_order = '' THEN 0 ELSE 1 END;
SET v_has_filter_permutation = CASE WHEN a_ids_permutation = '' THEN 0 ELSE 1 END;
SET v_has_filter_date_from = CASE WHEN ISNULL(a_date_from) THEN 0 ELSE 1 END;
@@ -172,13 +175,13 @@ BEGIN
IF EXISTS (
SELECT *
FROM tmp_Split t_S
LEFT JOIN partsltd_prod.Shop_Manufacturing_Purchase_Order SPO ON t_S.as_int = SPO.id_order
LEFT JOIN partsltd_prod.Shop_Manufacturing_Purchase_Order MPO ON t_S.as_int = MPO.id_order
WHERE
ISNULL(t_S.as_int)
OR ISNULL(SPO.id_order)
OR ISNULL(MPO.id_order)
OR (
SPO.active = 0
AND v_get_inactive_order = 0
MPO.active = 0
AND a_get_inactive_order = 0
)
) THEN
INSERT INTO tmp_Msg_Error (
@@ -191,13 +194,13 @@ BEGIN
v_code_type_error_bad_data,
CONCAT('Invalid or inactive Manufacturing Purchase Order IDs: ', IFNULL(GROUP_CONCAT(t_S.substring SEPARATOR ', '), 'NULL'))
FROM tmp_Split t_S
LEFT JOIN partsltd_prod.Shop_Manufacturing_Purchase_Order SPO ON t_S.as_int = SPO.id_order
LEFT JOIN partsltd_prod.Shop_Manufacturing_Purchase_Order MPO ON t_S.as_int = MPO.id_order
WHERE
ISNULL(t_S.as_int)
OR ISNULL(SPO.id_order)
OR ISNULL(MPO.id_order)
OR (
SPO.active = 0
AND v_get_inactive_order = 0
MPO.active = 0
AND a_get_inactive_order = 0
)
;
ELSE
@@ -205,11 +208,11 @@ BEGIN
id_order
)
SELECT
SPO.id_order
MPO.id_order
FROM tmp_Split t_S
RIGHT JOIN partsltd_prod.Shop_Manufacturing_Purchase_Order SPO ON t_S.as_int = SPO.id_order
INNER JOIN partsltd_prod.Shop_Manufacturing_Purchase_Order_Product_Link SPOPL ON SPO.id_order = SPOPL.id_order
INNER JOIN tmp_Permutation t_PP ON SPOPL.id_permutation = t_PP.id_permutation
RIGHT JOIN partsltd_prod.Shop_Manufacturing_Purchase_Order MPO ON t_S.as_int = MPO.id_order
INNER JOIN partsltd_prod.Shop_Manufacturing_Purchase_Order_Product_Link MPOPL ON MPO.id_order = MPOPL.id_order
INNER JOIN tmp_Permutation t_PP ON MPOPL.id_permutation = t_PP.id_permutation
WHERE (
a_get_all_order = 1
OR (
@@ -223,15 +226,15 @@ BEGIN
)
AND (
a_get_inactive_order = 1
OR SPO.active = 1
OR MPO.active = 1
)
AND (
v_has_filter_date_from = 0
OR SPO.created_on > a_date_from
OR MPO.created_on > a_date_from
)
AND (
v_has_filter_date_to = 0
OR SPO.created_on < a_date_to
OR MPO.created_on < a_date_to
)
;
@@ -246,40 +249,40 @@ BEGIN
v_guid
, a_id_user
, FALSE -- get inactive users
, v_id_permission_manufacturing_purchase_order
, v_ids_permission_manufacturing_purchase_order
, v_id_access_level_view
, '' -- ids_product
, 0 -- a_debug
;
SELECT * from Shop_Calc_User_Temp;
SELECT * FROM partsltd_prod.Shop_Calc_User_Temp;
END IF;
CALL p_shop_calc_user(
v_guid
, a_id_user
, FALSE -- get inactive users
, v_id_permission_manufacturing_purchase_order
, v_ids_permission_manufacturing_purchase_order
, v_id_access_level_view
, '' -- ids_product
, 0 -- a_debug
);
IF a_debug = 1 THEN
SELECT * from Shop_Calc_User_Temp;
SELECT * FROM partsltd_prod.Shop_Calc_User_Temp;
END IF;
IF NOT EXISTS (SELECT can_view FROM 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 = v_guid) THEN
DELETE FROM tmp_Msg_Error;
INSERT INTO tmp_Msg_Error (
, id_type
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 Shop_Permission WHERE id_permission = v_id_permission_manufacturing LIMIT 1))
, CONCAT('You do not have view permissions for ', (SELECT name FROM partsltd_prod.Shop_Permission WHERE id_permission = v_id_permission_manufacturing LIMIT 1))
)
;
END IF;
@@ -305,60 +308,66 @@ BEGIN
S.id_currency,
t_S.active
FROM tmp_Manufacturing t_S
INNER JOIN Shop_Manufacturing S
INNER JOIN partsltd_prod.Shop_Manufacturing S
ON t_S.id_manufacturing = S.id_manufacturing
;
*/
# Manufacturing Purchase Order
SELECT
t_SPO.id_order
, SPO.id_manufacturing_ordered
, SPO.id_currency_cost
, SPO.cost_total_local_VAT_excl
, SPO.cost_total_local_VAT_incl
, SPO.active
FROM tmp_Manufacturing_Purchase_Order t_SPO
INNER JOIN partsltd_prod.Shop_Manufacturing_Purchase_Order SPO ON SPO.id_order = t_SPO.id_order
t_MPO.id_order
, MPO.id_currency
, MPO.cost_total_local_VAT_excl
, MPO.cost_total_local_VAT_incl
, MPO.price_total_local_VAT_excl
, MPO.price_total_local_VAT_incl
, MPO.active
, MPO.created_on
, CONCAT(
MPO.cost_total_local_VAT_excl
, ' on '
, MPO.created_on
) AS name
FROM tmp_Manufacturing_Purchase_Order t_MPO
INNER JOIN partsltd_prod.Shop_Manufacturing_Purchase_Order MPO ON MPO.id_order = t_MPO.id_order
;
# Manufacturing Purchase Order Product Link
SELECT
SPOPL.id_link
, SPOPL.id_order
, SPOPL.id_permutation
, fn_shop_get_product_permutation_name(SPOPL.id_permutation) AS name_permutation
, SPOPL.id_currency_cost
, SPOPL.id_unit_quantity
, SPOPL.quantity_ordered
, SPOPL.quantity_received
, SPOPL.latency_delivery_days
, SPOPL.display_order
, SPO.cost_total_local_VAT_excl
, SPO.cost_total_local_VAT_incl
, SPO.cost_unit_local_VAT_excl
, SPO.cost_unit_local_VAT_incl
FROM tmp_Manufacturing_Purchase_Order_Product_Link t_SPOPL
INNER JOIN partsltd_prod.Shop_Manufacturing_Purchase_Order_Product_Link SPOPL ON t_SPOPL.id_link = SPOPL.id_link
INNER JOIN tmp_Manufacturing_Purchase_Order t_SPO ON SPOPL.id_order = t_SPO.id_order
MPOPL.id_link
, MPOPL.id_order
, MPOPL.id_permutation
, fn_shop_get_product_permutation_name(MPOPL.id_permutation) AS name_permutation
, MPOPL.id_unit_quantity
, MPOPL.quantity_used
, MPOPL.quantity_produced
, MPOPL.latency_manufacture_days
, MPOPL.display_order
, MPOPL.cost_unit_local_VAT_excl
, MPOPL.cost_unit_local_VAT_incl
, MPOPL.price_unit_local_VAT_excl
, MPOPL.price_unit_local_VAT_incl
, MPOPL.active
FROM tmp_Manufacturing_Purchase_Order t_MPO
INNER JOIN partsltd_prod.Shop_Manufacturing_Purchase_Order_Product_Link MPOPL ON t_MPO.id_order = MPOPL.id_order
;
# Errors
SELECT *
FROM tmp_Msg_Error t_ME
INNER JOIN Shop_Msg_Error_Type MET ON t_ME.id_type = MET.id_type
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_Manufacturing_Purchase_Order_Product_Link;
SELECT * from tmp_Manufacturing_Purchase_Order;
SELECT * from tmp_Manufacturing;
SELECT * from tmp_Permutation;
END IF;
DROP TEMPORARY TABLE IF EXISTS tmp_Manufacturing_Purchase_Order_Product_Link;
DROP TEMPORARY TABLE IF EXISTS tmp_Manufacturing_Purchase_Order;
DROP TEMPORARY TABLE IF EXISTS tmp_Manufacturing;
DROP TEMPORARY TABLE IF EXISTS tmp_Permutation;
DROP TEMPORARY TABLE IF EXISTS tmp_Msg_Error;
DROP TEMPORARY TABLE IF EXISTS tmp_Split;
IF a_debug = 1 THEN
CALL p_debug_timing_reporting( v_time_start );
@@ -367,20 +376,17 @@ END //
DELIMITER ;;
/*
CALL p_shop_get_many_manufacturing_purchase_order (
'', # a_id_user
1, # a_get_all_manufacturing
0, # a_get_inactive_manufacturing
'', # a_ids_manufacturing
1, # a_get_all_order
-- 0, # a_get_inactive_order
'', # a_ids_order
'', # a_ids_permutation
NULL, # a_date_from
NULL # a_date_to
1 # a_id_user
, 1 # a_get_all_order
, 0 # a_get_inactive_order
, '' # a_ids_order
, '' # a_ids_permutation
, NULL # a_date_from
, NULL # a_date_to
, 0 # a_debug
);
/*
*/

View File

@@ -689,19 +689,11 @@ VALUES
*/
# Supplier
INSERT INTO Shop_Supplier (
name_company, name_contact, department_contact, id_address, phone_number, fax, email, website, id_currency
)
VALUES
('Precision And Research Technology Systems Limited', 'Teddy Middleton-Smith', 'Executive Management', 1, '07375571430', '', 'teddy@partsltd.co.uk', 'www.partsltd.co.uk', 1)
;
# Suppliers
INSERT INTO Shop_Supplier (
name_company
, name_contact
, department_contact
, id_address
-- , id_address
, phone_number
, fax
, email
@@ -709,7 +701,77 @@ INSERT INTO Shop_Supplier (
, id_currency
)
VALUES
('Malt Kiln Farm Shop', NULL, NULL, 1, '01788 832640', NULL, 'farmshop@maltkilnfarmshop.co.uk', 'https://www.maltkilnfarmshop.co.uk/', 1)
(
'Precision And Research Technology Systems Limited'
, 'Teddy Middleton-Smith'
, 'Executive Management'
-- , 1
, '07375571430'
, ''
, 'teddy@partsltd.co.uk'
, 'www.partsltd.co.uk'
, 1
)
;
# Suppliers
INSERT INTO Shop_Supplier (
name_company
, name_contact
, department_contact
-- , id_address
, phone_number
, fax
, email
, website
, id_currency
)
VALUES
(
'Malt Kiln Farm Shop'
, NULL
, NULL
-- , 1
, '01788 832640'
, NULL
, 'farmshop@maltkilnfarmshop.co.uk'
, 'https://www.maltkilnfarmshop.co.uk/'
, 1
)
;
# Supplier Addresses
INSERT INTO Shop_Supplier_Address (
id_supplier
, id_region
, postcode
, address_line_1
, address_line_2
, city
, county
, active
)
VALUES
(
1
, 1
, 'CV22 6DN'
, '53 Alfred Green Close'
, ''
, 'Rugby'
, 'Warwickshire'
, 1
),
(
2
, 1
, 'CV22 6DN'
, '53 Alfred Green Close'
, ''
, 'Rugby'
, 'Warwickshire'
, 1
)
;
/*

View File

@@ -91,13 +91,19 @@
1398_tbl_Shop_Order_Status_Audit.sql
1400_tbl_Shop_Supplier.sql
1401_tbl_Shop_Supplier_Audit.sql
1402_tbl_Shop_Supplier_Temp.sql
1403_tbl_Shop_Supplier_Address.sql
1403_tbl_Shop_Supplier_Address_Temp.sql
1404_tbl_Shop_Supplier_Address.sql
1409_tbl_Shop_Supplier_Purchase_Order.sql
1410_tbl_Shop_Supplier_Purchase_Order_Audit.sql
1411_tbl_Shop_Supplier_Purchase_Order_Temp.sql
1412_tbl_Shop_Supplier_Purchase_Order_Product_Link.sql
1413_tbl_Shop_Supplier_Purchase_Order_Product_Link_Audit.sql
1414_tbl_Shop_Supplier_Purchase_Order_Product_Link_Temp.sql
1415_tbl_Shop_Manufacturing_Purchase_Order.sql
1416_tbl_Shop_Manufacturing_Purchase_Order_Audit.sql
1417_tbl_Shop_Manufacturing_Purchase_Order_Temp.sql
1418_tbl_Shop_Manufacturing_Purchase_Order_Product_Link.sql
1419_tbl_Shop_Manufacturing_Purchase_Order_Product_Link_Audit.sql
1420_tbl_Shop_Manufacturing_Purchase_Order_Product_Link_Temp.sql
@@ -146,6 +152,7 @@
3321_tri_Shop_User_Basket.sql
3324_tri_Shop_User_Order_Status.sql
3400_tri_Shop_Supplier.sql
3403_tri_Shop_Supplier_Address.sql
3403_tri_Shop_Unit_Measurement.sql
3406_tri_Shop_Unit_Of_Measurement_Conversion.sql
3409_tri_Shop_Supplier_Purchase_Order.sql
@@ -162,6 +169,7 @@
6003_p_split_key_value_pair_csv.sql
6004_p_clear_split_key_value_pair_csv_temp.sql
6206_fn_shop_get_product_permutation_name.sql
6210_fn_shop_get_id_product_permutation_from_variation_csv_list.sql
6500_p_shop_calc_user.sql
6501_p_shop_clear_calc_user.sql
7003_p_shop_get_many_access_level.sql
@@ -179,7 +187,6 @@
7204_p_shop_get_many_product.sql
7205_p_shop_get_many_stripe_product_new.sql
7206_p_shop_save_product_permutation.sql
7210_fn_shop_get_id_product_permutation_from_variation_csv_list.sql
7210_p_shop_get_many_product_variation.sql
7219_p_shop_get_many_stock_item.sql
7220_p_shop_save_stock_item.sql

View File

@@ -1,4 +1,8 @@
#formFilters .container {
max-width: fit-content;
}
thead, tbody {
padding-top: 0px !important;
padding-bottom: 0px !important;
@@ -45,3 +49,12 @@ table select {
table input {
width: 90% !important;
}
table button {
margin: 0.25vh;
padding: 0.5vh 1vh;
}
tr.delete {
background-color: red;
}

View File

@@ -500,10 +500,6 @@ button:hover, input[type="submit"]:hover, #overlayHamburger .row *:hover {
text-decoration: none;
}
.delete {
text-decoration: underline;
}
/* Overlay modal */
.overlay {

View File

@@ -0,0 +1,38 @@
#formFilters {
width: 50vh;
}
#formFilters .container-input.filter.active {
width: 8vh;
}
#formFilters .container-input.filter.date_from,
#formFilters .container-input.filter.date_to {
width: 8vh;
}
#tableMain thead tr th.currency.collapsed, #tableMain tbody tr td.currency.collapsed {
width: 9vh;
min-width: 9vh;
}
#tableMain thead tr th.currency, #tableMain tbody tr td.currency {
width: 11vh;
min-width: 11vh;
}
#tableMain tbody tr td.cost_total_local_vat_excl, #tableMain thead tr th.cost_total_local_vat_excl,
#tableMain tbody tr td.cost_total_local_vat_incl, #tableMain thead tr th.cost_total_local_vat_incl,
#tableMain tbody tr td.price_total_local_vat_excl, #tableMain thead tr th.price_total_local_vat_excl,
#tableMain tbody tr td.price_total_local_vat_incl, #tableMain thead tr th.price_total_local_vat_incl {
width: 5vh;
min-width: 5vh;
}
#tableMain tbody tr td.items, #tableMain thead tr th.items {
width: 40vh;
min-width: 40vh;
}
#tableMain tbody tr td.active, #tableMain thead tr th.active {
width: 5vh;
min-width: 5vh;
}

View File

@@ -25,14 +25,15 @@
display: table-cell !important;
}
#tableMain thead tr th.product_variations, #tableMain tbody tr td.product_variations {
width: 20vh;
min-width: 20vh;
width: 24vh;
min-width: 24vh;
}
#tableMain tbody tr td.product_variations table thead tr th, #tableMain tbody tr td.product_variations table tbody tr td {
#tableMain tbody tr td.product_variations table thead tr th.product_variation_type, #tableMain tbody tr td.product_variations table tbody tr td.product_variation_type,
#tableMain tbody tr td.product_variations table thead tr th.product_variation, #tableMain tbody tr td.product_variations table tbody tr td.product_variation {
width: 8vh;
min-width: 8vh;
}
#tableMain tbody tr td.product_variations table thead tr th:last-of-type, #tableMain tbody tr td.product_variations table tbody tr td:last-of-type {
#tableMain tbody tr td.product_variations table thead tr th.add, #tableMain tbody tr td.product_variations table tbody tr td.delete {
width: 4vh;
min-width: 4vh;
}

View File

@@ -0,0 +1,59 @@
#formFilters {
width: 50vh;
}
#formFilters .container-input.filter.active {
width: 8vh;
}
#tableMain tbody tr td.name_company, #tableMain thead tr th.name_company,
#tableMain tbody tr td.name_contact, #tableMain thead tr th.name_contact,
#tableMain tbody tr td.department_contact, #tableMain thead tr th.department_contact,
#tableMain tbody tr td.phone_number, #tableMain thead tr th.phone_number {
width: 10vh;
min-width: 10vh;
}
#tableMain tbody tr td.email, #tableMain thead tr th.email,
#tableMain tbody tr td.website, #tableMain thead tr th.website {
width: 15vh;
min-width: 15vh;
}
#tableMain thead tr th.address.collapsed, #tableMain tbody tr td.address.collapsed {
width: 9vh;
min-width: 9vh;
display: table-cell !important;
}
#tableMain thead tr th.address, #tableMain tbody tr td.address {
width: 108vh;
min-width: 108vh;
}
#tableMain tbody tr td.address table thead tr th.postcode, #tableMain tbody tr td.address table tbody tr td.postcode,
#tableMain tbody tr td.address table thead tr th.address_line_1, #tableMain tbody tr td.address table tbody tr td.address_line_1,
#tableMain tbody tr td.address table thead tr th.address_line_2, #tableMain tbody tr td.address table tbody tr td.address_line_2,
#tableMain tbody tr td.address table thead tr th.city, #tableMain tbody tr td.address table tbody tr td.city,
#tableMain tbody tr td.address table thead tr th.county, #tableMain tbody tr td.address table tbody tr td.county,
#tableMain tbody tr td.address table thead tr th.region, #tableMain tbody tr td.address table tbody tr td.region {
width: 15vh;
min-width: 15vh;
}
#tableMain tbody tr td.address table thead tr th.active, #tableMain tbody tr td.address table tbody tr td.active,
#tableMain tbody tr td.address table thead tr th.add, #tableMain tbody tr td.address table tbody tr td.delete {
width: 5vh;
min-width: 5vh;
}
#tableMain thead tr th.currency.collapsed, #tableMain tbody tr td.currency.collapsed {
width: 9vh;
min-width: 9vh;
}
#tableMain thead tr th.currency, #tableMain tbody tr td.currency {
width: 11vh;
min-width: 11vh;
}
#tableMain tbody tr td.active, #tableMain thead tr th.active {
width: 5vh;
min-width: 5vh;
}

View File

@@ -0,0 +1,40 @@
#formFilters {
width: 100vh;
}
#formFilters .container-input.filter.active {
width: 8vh;
}
#formFilters .container-input.filter.date_from,
#formFilters .container-input.filter.date_to {
width: 8vh;
}
#tableMain tbody tr td.supplier, #tableMain thead tr th.supplier {
width: 15vh;
min-width: 15vh;
}
#tableMain thead tr th.currency.collapsed, #tableMain tbody tr td.currency.collapsed {
width: 9vh;
min-width: 9vh;
}
#tableMain thead tr th.currency, #tableMain tbody tr td.currency {
width: 11vh;
min-width: 11vh;
}
#tableMain tbody tr td.cost_total_local_vat_excl, #tableMain thead tr th.cost_total_local_vat_excl,
#tableMain tbody tr td.cost_total_local_vat_incl, #tableMain thead tr th.cost_total_local_vat_incl {
width: 10vh;
min-width: 10vh;
}
#tableMain tbody tr td.items, #tableMain thead tr th.items {
width: 40vh;
min-width: 40vh;
}
#tableMain tbody tr td.active, #tableMain thead tr th.active {
width: 5vh;
min-width: 5vh;
}

View File

@@ -500,10 +500,6 @@ button:hover, input[type="submit"]:hover, #overlayHamburger .row *:hover {
text-decoration: none;
}
.delete {
text-decoration: underline;
}
/* Overlay modal */
.overlay {
@@ -609,6 +605,10 @@ td.dirty {
height: 50vh;
}
#formFilters .container {
max-width: fit-content;
}
thead, tbody {
padding-top: 0px !important;
padding-bottom: 0px !important;
@@ -656,6 +656,15 @@ table input {
width: 90% !important;
}
table button {
margin: 0.25vh;
padding: 0.5vh 1vh;
}
tr.delete {
background-color: red;
}
button.collapsed {
display: block;

View File

@@ -78,14 +78,15 @@
display: table-cell !important;
}
#tableMain thead tr th.product_variations, #tableMain tbody tr td.product_variations {
width: 20vh;
min-width: 20vh;
width: 24vh;
min-width: 24vh;
}
#tableMain tbody tr td.product_variations table thead tr th, #tableMain tbody tr td.product_variations table tbody tr td {
#tableMain tbody tr td.product_variations table thead tr th.product_variation_type, #tableMain tbody tr td.product_variations table tbody tr td.product_variation_type,
#tableMain tbody tr td.product_variations table thead tr th.product_variation, #tableMain tbody tr td.product_variations table tbody tr td.product_variation {
width: 8vh;
min-width: 8vh;
}
#tableMain tbody tr td.product_variations table thead tr th:last-of-type, #tableMain tbody tr td.product_variations table tbody tr td:last-of-type {
#tableMain tbody tr td.product_variations table thead tr th.add, #tableMain tbody tr td.product_variations table tbody tr td.delete {
width: 4vh;
min-width: 4vh;
}

File diff suppressed because one or more lines are too long

View File

@@ -139,6 +139,51 @@ export default class API {
dataRequest[flagComment] = comment;
return await API.request(hashSaveStoreStockItem, 'POST', dataRequest);
}
// suppliers
static async getSuppliers() {
return await API.request(hashGetStoreSupplier);
}
static async getSuppliersByFilters(filtersJson) {
API.goToHash(hashPageStoreSuppliers, filtersJson);
}
static async saveSuppliers(suppliers, formFilters, comment) {
let dataRequest = {};
dataRequest[flagFormFilters] = DOM.convertForm2JSON(formFilters);
dataRequest[flagSupplier] = suppliers;
dataRequest[flagComment] = comment;
return await API.request(hashSaveStoreSupplier, 'POST', dataRequest);
}
// supplier purchase orders
static async getSupplierPurchaseOrders() {
return await API.request(hashGetStoreSupplierPurchaseOrder);
}
static async getSupplierPurchaseOrdersByFilters(filtersJson) {
API.goToHash(hashPageStoreSupplierPurchaseOrders, filtersJson);
}
static async saveSupplierPurchaseOrders(supplierPurchaseOrders, formFilters, comment) {
let dataRequest = {};
dataRequest[flagFormFilters] = DOM.convertForm2JSON(formFilters);
dataRequest[flagSupplierPurchaseOrder] = supplierPurchaseOrders;
dataRequest[flagComment] = comment;
return await API.request(hashSaveStoreSupplierPurchaseOrder, 'POST', dataRequest);
}
// manufacturing purchase orders
static async getManufacturingPurchaseOrders() {
return await API.request(hashGetStoreManufacturingPurchaseOrder);
}
static async getManufacturingPurchaseOrdersByFilters(filtersJson) {
API.goToHash(hashPageStoreManufacturingPurchaseOrders, filtersJson);
}
static async saveManufacturingPurchaseOrders(manufacturingPurchaseOrders, formFilters, comment) {
let dataRequest = {};
dataRequest[flagFormFilters] = DOM.convertForm2JSON(formFilters);
dataRequest[flagManufacturingPurchaseOrder] = manufacturingPurchaseOrders;
dataRequest[flagComment] = comment;
return await API.request(hashSaveStoreManufacturingPurchaseOrder, 'POST', dataRequest);
}
}
/*

View File

@@ -91,6 +91,10 @@ export default class DOM {
if (container == null) return false;
return container.querySelector('.' + flagDirty) != null;
}
static hasDirtyChildrenNotDeletedContainer(container) {
if (container == null) return false;
return container.querySelector('.' + flagDirty + ':not(.' + flagDelete + ')') != null;
}
static getElementValueCurrent(element) {
let returnVal = '';
@@ -117,6 +121,7 @@ export default class DOM {
return returnVal;
}
static getElementAttributeValueCurrent(element) {
if (Validation.isEmpty(element)) return null;
return element.getAttribute(attrValueCurrent);
if (!Validation.isEmpty(value) && element.type === "checkbox") {
value = (value === 'true');
@@ -124,6 +129,7 @@ export default class DOM {
return value;
}
static getElementAttributeValuePrevious(element) {
if (Validation.isEmpty(element)) return null;
return element.getAttribute(attrValuePrevious);
if (!Validation.isEmpty(value) && element.type === "checkbox") {
value = (value === 'true');
@@ -134,13 +140,13 @@ export default class DOM {
static updateAndCheckIsTableElementDirty(element) {
let wasDirty = DOM.isElementDirty(element);
let row = DOM.getRowFromElement(element);
let wasDirtyRow = DOM.hasDirtyChildrenContainer(row);
let wasDirtyRow = DOM.hasDirtyChildrenNotDeletedContainer(row);
let isDirty = DOM.updateAndCheckIsElementDirty(element);
let cell = DOM.getCellFromElement(element);
console.log({element, row, cell, isDirty, wasDirty});
if (isDirty != wasDirty) {
DOM.handleDirtyElement(cell, isDirty);
let isDirtyRow = DOM.hasDirtyChildrenContainer(row);
let isDirtyRow = DOM.hasDirtyChildrenNotDeletedContainer(row);
console.log({isDirtyRow, wasDirtyRow});
if (isDirtyRow != wasDirtyRow) {
DOM.handleDirtyElement(row, isDirtyRow);

View File

@@ -45,6 +45,7 @@ export default class BasePage {
// hookupVideos();
this.hookupNavigation();
this.hookupImagesLogo();
this.hookupOverlays();
}
hookupNavigation() {
@@ -75,8 +76,11 @@ export default class BasePage {
this.hookupButtonsNavUserLogout();
this.hookupButtonsNavUserLogin();
this.hookupButtonsNavStoreHome();
this.hookupButtonsNavStoreManufacturingPurchaseOrders();
this.hookupButtonsNavStoreProductPermutations();
this.hookupButtonsNavStoreStockItems();
this.hookupButtonsNavStoreSuppliers();
this.hookupButtonsNavStoreSupplierPurchaseOrders();
this.hookupButtonsNavAdminHome();
}
hookupEventHandler(eventType, selector, callback) {
@@ -131,6 +135,9 @@ export default class BasePage {
hookupButtonsNavStoreHome() {
this.hookupButtonsNav('.' + flagNavStoreHome, hashPageStoreHome);
}
hookupButtonsNavStoreManufacturingPurchaseOrders() {
this.hookupButtonsNav('.' + flagNavStoreManufacturingPurchaseOrders, hashPageStoreManufacturingPurchaseOrders);
}
hookupButtonsNavStoreProductCategories() {
this.hookupButtonsNav('.' + flagNavStoreProductCategories, hashPageStoreProductCategories);
}
@@ -152,14 +159,25 @@ export default class BasePage {
hookupButtonsNavAdminHome() {
this.hookupButtonsNav('.' + flagNavAdminHome, hashPageAdminHome);
}
hookupButtonsNavStoreSuppliers() {
this.hookupButtonsNav('.' + flagNavStoreSuppliers, hashPageStoreSuppliers);
}
hookupButtonsNavStoreSupplierPurchaseOrders() {
this.hookupButtonsNav('.' + flagNavStoreSupplierPurchaseOrders, hashPageStoreSupplierPurchaseOrders);
}
hookupImagesLogo() {
this.hookupButtonsNav("img." + flagImageLogo, hashPageHome);
}
hookupOverlays() {
this.hookupOverlayFromId(idOverlayConfirm);
this.hookupOverlayFromId(idOverlayError);
}
hookupOverlayFromId(idOverlay) {
Events.initialiseEventHandler(idOverlay, flagInitialised, (overlay) => {
overlay.querySelector('button.' + flagClose).addEventListener("click", (event) => {
overlay.querySelector('button.' + flagCancel).addEventListener("click", (event) => {
event.stopPropagation();
overlay.css('display', 'none');
});

View File

@@ -168,10 +168,10 @@ export default class TableBasePage extends BasePage {
.catch(error => console.error('Error:', error));
}
getTableRecords(dirtyOnly = false) {
let table = this.getTableMain();
// let table = this.getTableMain();
let records = [];
let record;
table.querySelectorAll('tbody tr').forEach((row) => {
document.querySelectorAll(idTableMain + ' > tbody > tr').forEach((row) => {
if (dirtyOnly && !row.classList.contains(flagDirty)) return;
record = this.getJsonRow(row);
records.push(record);
@@ -221,6 +221,8 @@ export default class TableBasePage extends BasePage {
row.querySelectorAll('.' + flagInitialised).forEach(function(element) {
element.classList.remove(flagInitialised);
});
let countRows = document.querySelectorAll(idTableMain + ' > tbody > tr').length;
row.setAttribute(this.constructor.attrIdRowObject, -1 - countRows);
/* Shared nethods
let newDisplayOrder = parseInt(tbody.querySelector('tr:last-child').querySelector('td.' + flagDisplayOrder + ' .' + flagSlider).getAttribute(attrValueCurrent)) + 1;
let slider = tbody.querySelector('tr:last-child').querySelector('td.' + flagDisplayOrder + ' .' + flagSlider);
@@ -285,19 +287,19 @@ export default class TableBasePage extends BasePage {
input.addEventListener("change", (event) => {
handler(event, input);
});
this.handleChangeElementCellTable(null, input);
handler(null, input);
});
// this.hookupEventHandler("change", inputSelector, handler);
}
handleChangeElementCellTable(event, element) {
let row = DOM.getRowFromElement(element);
let td = DOM.getCellFromElement(element);
let wasDirtyRow = DOM.hasDirtyChildrenContainer(row);
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.hasDirtyChildrenContainer(row);
let isNowDirtyRow = DOM.hasDirtyChildrenNotDeletedContainer(row);
if (isNowDirtyRow != wasDirtyRow) {
DOM.handleDirtyElement(row, isNowDirtyRow);
let rows = this.getTableRecords(true);
@@ -419,7 +421,7 @@ export default class TableBasePage extends BasePage {
let row = DOM.getRowFromElement(ddl);
let td = DOM.getCellFromElement(ddl);
console.log("td: ", td);
let wasDirtyRow = DOM.hasDirtyChildrenContainer(row);
let wasDirtyRow = DOM.hasDirtyChildrenNotDeletedContainer(row);
let wasDirtyElement = ddl.classList.contains(flagDirty);
let isDirtyElement = DOM.updateAndCheckIsElementDirty(ddl);
console.log("isDirtyElement: ", isDirtyElement);
@@ -428,7 +430,7 @@ export default class TableBasePage extends BasePage {
DOM.handleDirtyElement(td, isDirtyElement);
let optionSelected = ddl.options[ddl.selectedIndex];
DOM.setElementAttributeValueCurrent(td, optionSelected.value);
let isNowDirtyRow = DOM.hasDirtyChildrenContainer(row);
let isNowDirtyRow = DOM.hasDirtyChildrenNotDeletedContainer(row);
console.log("isNowDirtyRow: ", isNowDirtyRow);
console.log("wasDirtyRow: ", wasDirtyRow);
if (isNowDirtyRow != wasDirtyRow) {
@@ -460,13 +462,16 @@ export default class TableBasePage extends BasePage {
let thead = document.createElement("thead");
let tr = document.createElement("tr");
let thVariationType = document.createElement("th");
thVariationType.classList.add(flagProductVariationType);
thVariationType.textContent = 'Type';
let thNameVariation = document.createElement("th");
thNameVariation.classList.add(flagProductVariation);
thNameVariation.textContent = 'Name';
let buttonAdd = document.createElement("button");
buttonAdd.classList.add(flagAdd);
buttonAdd.textContent = '+';
let thAddDelete = document.createElement("th");
thAddDelete.classList.add(flagAdd);
thAddDelete.appendChild(buttonAdd);
tr.appendChild(thVariationType);
tr.appendChild(thNameVariation);
@@ -484,9 +489,10 @@ export default class TableBasePage extends BasePage {
});
}
tblVariations.appendChild(tbody);
let parent = element.parentElement;
parent.innerHTML = '';
parent.appendChild(tblVariations);
let cellParent = element.closest(idTableMain + ' tbody tr td.' + flagProductVariations);
cellParent.innerHTML = '';
cellParent.appendChild(tblVariations);
console.log("tblVariations: ", tblVariations);
let selectorButtonAdd = idTableMain + ' td.' + flagProductVariations + ' button.' + flagAdd;
this.hookupEventHandler("click", selectorButtonAdd, this.handleClickButtonProductPermutationVariationsAdd);
@@ -496,6 +502,9 @@ export default class TableBasePage extends BasePage {
toggleColumnCollapsed(flagColumn, isCollapsed) {
this.toggleColumnHasClassnameFlag(flagColumn, isCollapsed, flagCollapsed);
}
toggleColumnHeaderCollapsed(flagColumn, isCollapsed) {
this.toggleColumnHasClassnameFlag(flagColumn, isCollapsed, flagCollapsed);
}
getElementProductVariations(element) {
let permutationVariations = element.getAttribute(attrValueCurrent);
let objVariations = [];
@@ -636,6 +645,10 @@ export default class TableBasePage extends BasePage {
return variationPairsString;
}
hookupCurrencyFields() {
this.hookupTableCellDdlPreviews(idTableMain + ' td.' + flagCurrency, Utils.getListFromDict(currencies));
}
leave() {
if (this.constructor === TableBasePage) {
throw new Error("Must implement leave() method.");
@@ -653,12 +666,17 @@ export default class TableBasePage extends BasePage {
let columnTh = table.querySelector('th.' + columnFlag);
let columnThHasFlag = columnTh.classList.contains(classnameFlag);
if (isRequiredFlag == columnThHasFlag) return;
let columnTds = table.querySelectorAll('td.' + columnFlag);
DOM.toggleElementHasClassnameFlag(columnTh, isRequiredFlag, classnameFlag);
let columnTds = table.querySelectorAll('td.' + columnFlag);
columnTds.forEach((columnTd) => {
DOM.toggleElementHasClassnameFlag(columnTd, isRequiredFlag, classnameFlag);
});
}
toggleColumnHeaderHasClassnameFlag(columnFlag, isRequiredFlag, classnameFlag) {
let table = this.getTableMain();
let columnTh = table.querySelector('th.' + columnFlag);
DOM.toggleElementHasClassnameFlag(columnTh, isRequiredFlag, classnameFlag);
}
}
@@ -669,7 +687,9 @@ import DOM from "../dom.js";
export class PageStoreProductCategories extends TableBasePage {
static hash = hashPageStoreProductCategories;
static attrIdRowObject = attrIdProductCategory;
callFilterTableContent = API.getCategoriesByFilters;
callSaveTableContent = API.saveCategories;
constructor() {}
initialize() {}

View File

@@ -0,0 +1,82 @@
import API from "../../api.js";
import BusinessObjects from "../../lib/business_objects.js";
import DOM from "../../dom.js";
import Events from "../../lib/events.js";
import TableBasePage from "../base_table.js";
import Utils from "../../lib/utils.js";
import Validation from "../../lib/validation.js";
import StoreTableMixinPage from "./mixin_table.js";
export default class PageStoreSupplierPurchaseOrders extends TableBasePage {
static hash = hashPageStoreSupplierPurchaseOrders;
static attrIdRowObject = attrIdSupplierPurchaseOrder;
callFilterTableContent = API.getSupplierPurchaseOrdersByFilters;
callSaveTableContent = API.saveSupplierPurchaseOrders;
constructor(router) {
super(router);
this.storeMixin = new StoreTableMixinPage(this);
}
initialize() {
this.sharedInitialize();
}
hookupFilters() {
this.sharedHookupFilters();
this.hookupFilterActive();
}
loadRowTable(rowJson) {
}
getJsonRow(row) {
if (row == null) return;
let tdCurrency = row.querySelector('td.' + flagCurrency);
let inputCostTotalLocalVatExcl = row.querySelector('td.' + flagCostTotalLocalVatExcl + ' input');
let inputCostTotalLocalVatIncl = row.querySelector('td.' + flagCostTotalLocalVatIncl + ' input');
let inputPriceTotalLocalVatExcl = row.querySelector('td.' + flagPriceTotalLocalVatExcl + ' input');
let inputPriceTotalLocalVatIncl = row.querySelector('td.' + flagPriceTotalLocalVatIncl + ' input');
let tdItems = row.querySelector('td.' + flagItems);
let checkboxActive = row.querySelector('td.' + flagActive + ' textarea');
let jsonRow = {};
jsonRow[attrIdSupplierPurchaseOrder] = row.getAttribute(attrIdSupplierPurchaseOrder);
jsonRow[attrIdCurrency] = DOM.getElementAttributeValueCurrent(tdCurrency);
jsonRow[flagCostTotalLocalVatExcl] = DOM.getElementAttributeValueCurrent(inputCostTotalLocalVatExcl);
jsonRow[flagCostTotalLocalVatIncl] = DOM.getElementAttributeValueCurrent(inputCostTotalLocalVatIncl);
jsonRow[flagPriceTotalLocalVatExcl] = DOM.getElementAttributeValueCurrent(inputPriceTotalLocalVatExcl);
jsonRow[flagPriceTotalLocalVatIncl] = DOM.getElementAttributeValueCurrent(inputPriceTotalLocalVatIncl);
jsonRow[flagItems] = DOM.getElementAttributeValueCurrent(tdItems);
jsonRow[flagActive] = DOM.getElementAttributeValueCurrent(checkboxActive);
return jsonRow;
}
initialiseRowNew(row) {
super.initialiseRowNew(row);
}
hookupTableMain() {
super.hookupTableMain();
this.hookupCurrencyFields();
this.hookupCostInputs();
this.hookupOrderItemsFields();
this.hookupActiveCheckboxes();
}
hookupCostInputs() {
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagCostTotalLocalVatExcl + ' input');
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagCostTotalLocalVatIncl + ' input');
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagPriceTotalLocalVatExcl + ' input');
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagPriceTotalLocalVatIncl + ' input');
}
hookupOrderItemsFields() {
}
hookupActiveCheckboxes(){
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagActive + ' input');
}
leave() {
super.leave();
}
}

View File

@@ -7,6 +7,7 @@ import StoreTableMixinPage from "./mixin_table.js";
export default class PageStoreProductCategories extends TableBasePage {
static hash = hashPageStoreProductCategories;
static attrIdRowObject = attrIdProductCategory;
callFilterTableContent = API.getCategoriesByFilters;
callSaveTableContent = API.saveCategories;

View File

@@ -10,6 +10,7 @@ import StoreTableMixinPage from "./mixin_table.js";
export default class PageStoreProductPermutations extends TableBasePage {
static hash = hashPageStoreProductPermutations;
static attrIdRowObject = attrIdProductPermutation;
callFilterTableContent = API.getProductPermutationsByFilters;
callSaveTableContent = API.saveProductPermutations;

View File

@@ -8,6 +8,7 @@ import Utils from "../../lib/utils.js";
export default class PageStoreProducts extends TableBasePage {
static hash = hashPageStoreProducts;
static attrIdRowObject = attrIdProduct;
callFilterTableContent = API.getProductsByFilters;
callSaveTableContent = API.saveProducts;

View File

@@ -10,6 +10,7 @@ import StoreTableMixinPage from "./mixin_table.js";
export default class PageStoreStockItems extends TableBasePage {
static hash = hashPageStoreStockItems;
static attrIdRowObject = attrIdStockItem;
callFilterTableContent = API.getStockItemsByFilters;
callSaveTableContent = API.saveStockItems;
@@ -73,8 +74,8 @@ export default class PageStoreStockItems extends TableBasePage {
let tdProduct = row.querySelector('td.' + flagProduct);
let tdProductVariations = row.querySelector('td.' + flagProductVariations);
let tdCurrencyCost = row.querySelector('td.' + flagCurrencyCost);
let inputCostLocalVatExcl = row.querySelector('td.' + flagCostLocalVatExcl + ' input');
let inputCostLocalVatIncl = row.querySelector('td.' + flagCostLocalVatIncl + ' input');
let inputCostLocalVatExcl = row.querySelector('td.' + flagCostUnitLocalVatExcl + ' input');
let inputCostLocalVatIncl = row.querySelector('td.' + flagCostUnitLocalVatIncl + ' input');
let inputDatePurchased = row.querySelector('td.' + flagDatePurchased + ' input');
let inputDateReceived = row.querySelector('td.' + flagDateReceived + ' input');
let tdStorageLocation = row.querySelector('td.' + flagStorageLocation);
@@ -93,8 +94,8 @@ export default class PageStoreStockItems extends TableBasePage {
jsonRow[flagProductVariations] = DOM.getElementAttributeValueCurrent(tdProductVariations);
jsonRow[flagHasVariations] = jsonRow[flagProductVariations] != '';
jsonRow[flagCurrencyCost] = DOM.getElementAttributeValueCurrent(tdCurrencyCost);
jsonRow[flagCostLocalVatExcl] = DOM.getElementAttributeValueCurrent(inputCostLocalVatExcl);
jsonRow[flagCostLocalVatIncl] = DOM.getElementAttributeValueCurrent(inputCostLocalVatIncl);
jsonRow[flagCostUnitLocalVatExcl] = DOM.getElementAttributeValueCurrent(inputCostLocalVatExcl);
jsonRow[flagCostUnitLocalVatIncl] = DOM.getElementAttributeValueCurrent(inputCostLocalVatIncl);
jsonRow[flagDatePurchased] = DOM.getElementAttributeValueCurrent(inputDatePurchased);
jsonRow[flagDateReceived] = DOM.getElementAttributeValueCurrent(inputDateReceived);
jsonRow[attrIdStorageLocation] = DOM.getElementAttributeValueCurrent(tdStorageLocation);
@@ -189,8 +190,8 @@ export default class PageStoreStockItems extends TableBasePage {
this.hookupTableCellDdlPreviews(idTableMain + ' td.' + flagCurrencyCost, Utils.getListFromDict(currencies));
}
hookupCostInputs(){
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagCostLocalVatExcl + ' input');
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagCostLocalVatIncl + ' input');
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagCostUnitLocalVatExcl + ' input');
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagCostUnitLocalVatIncl + ' input');
}
hookupOrderDateInputs(){
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagDatePurchased + ' input');

View File

@@ -0,0 +1,82 @@
import API from "../../api.js";
import BusinessObjects from "../../lib/business_objects.js";
import DOM from "../../dom.js";
import Events from "../../lib/events.js";
import TableBasePage from "../base_table.js";
import Utils from "../../lib/utils.js";
import Validation from "../../lib/validation.js";
import StoreTableMixinPage from "./mixin_table.js";
export default class PageStoreSupplierPurchaseOrders extends TableBasePage {
static hash = hashPageStoreSupplierPurchaseOrders;
static attrIdRowObject = attrIdSupplierPurchaseOrder;
callFilterTableContent = API.getSupplierPurchaseOrdersByFilters;
callSaveTableContent = API.saveSupplierPurchaseOrders;
constructor(router) {
super(router);
this.storeMixin = new StoreTableMixinPage(this);
}
initialize() {
this.sharedInitialize();
}
hookupFilters() {
this.sharedHookupFilters();
this.hookupFilterActive();
}
loadRowTable(rowJson) {
}
getJsonRow(row) {
if (row == null) return;
let tdSupplier = row.querySelector('td.' + flagSupplier);
let tdCurrency = row.querySelector('td.' + flagCurrency);
let inputCostTotalLocalVatExcl = row.querySelector('td.' + flagCostTotalLocalVatExcl + ' input');
let inputCostTotalLocalVatIncl = row.querySelector('td.' + flagCostTotalLocalVatIncl + ' input');
let tdItems = row.querySelector('td.' + flagItems);
let checkboxActive = row.querySelector('td.' + flagActive + ' textarea');
let jsonRow = {};
jsonRow[attrIdSupplierPurchaseOrder] = row.getAttribute(attrIdSupplierPurchaseOrder);
jsonRow[attrIdSupplier] = DOM.getElementAttributeValueCurrent(tdSupplier);
jsonRow[attrIdCurrency] = DOM.getElementAttributeValueCurrent(tdCurrency);
jsonRow[flagCostTotalLocalVatExcl] = DOM.getElementAttributeValueCurrent(inputCostTotalLocalVatExcl);
jsonRow[flagCostTotalLocalVatIncl] = DOM.getElementAttributeValueCurrent(inputCostTotalLocalVatIncl);
jsonRow[flagItems] = DOM.getElementAttributeValueCurrent(tdItems);
jsonRow[flagActive] = DOM.getElementAttributeValueCurrent(checkboxActive);
return jsonRow;
}
initialiseRowNew(row) {
super.initialiseRowNew(row);
}
hookupTableMain() {
super.hookupTableMain();
this.hookupSupplierFields();
this.hookupCurrencyFields();
this.hookupCostInputs();
this.hookupOrderItemsFields();
this.hookupActiveCheckboxes();
}
hookupSupplierFields() {
this.hookupTableCellDdlPreviews(idTableMain + ' td.' + flagSupplier, Utils.getListFromDict(suppliers));
}
hookupCostInputs() {
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagCostTotalLocalVatExcl + ' input');
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagCostTotalLocalVatIncl + ' input');
}
hookupOrderItemsFields() {
}
hookupActiveCheckboxes(){
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagActive + ' input');
}
leave() {
super.leave();
}
}

View File

@@ -0,0 +1,388 @@
import API from "../../api.js";
import BusinessObjects from "../../lib/business_objects.js";
import DOM from "../../dom.js";
import Events from "../../lib/events.js";
import TableBasePage from "../base_table.js";
import Utils from "../../lib/utils.js";
import Validation from "../../lib/validation.js";
import StoreTableMixinPage from "./mixin_table.js";
export default class PageStoreSuppliers extends TableBasePage {
static hash = hashPageStoreSuppliers;
static attrIdRowObject = attrIdSupplier;
callFilterTableContent = API.getSuppliersByFilters;
callSaveTableContent = API.saveSuppliers;
constructor(router) {
super(router);
this.storeMixin = new StoreTableMixinPage(this);
}
initialize() {
this.sharedInitialize();
}
hookupFilters() {
this.sharedHookupFilters();
this.hookupFilterActive();
}
loadRowTable(rowJson) {
}
getJsonRow(row) {
if (row == null) return;
let textareaNameCompany = row.querySelector('td.' + flagNameCompany + ' textarea');
let textareaNameContact = row.querySelector('td.' + flagNameContact + ' textarea');
let textareaDepartmentContact = row.querySelector('td.' + flagDepartmentContact + ' textarea');
let tdAddress = row.querySelector('td.' + flagAddress);
let textareaPhoneNumber = row.querySelector('td.' + flagPhoneNumber + ' textarea');
let textareaFax = row.querySelector('td.' + flagFax + ' textarea');
let textareaEmail = row.querySelector('td.' + flagEmail + ' textarea');
let textareaWebsite = row.querySelector('td.' + flagWebsite + ' textarea');
let tdCurrency = row.querySelector('td.' + flagCurrency);
let checkboxActive = row.querySelector('td.' + flagActive + ' input[type="checkbox"]');
let jsonRow = {};
jsonRow[attrIdSupplier] = row.getAttribute(attrIdSupplier);
jsonRow[flagNameCompany] = DOM.getElementAttributeValueCurrent(textareaNameCompany);
jsonRow[flagNameContact] = DOM.getElementAttributeValueCurrent(textareaNameContact);
jsonRow[flagDepartmentContact] = DOM.getElementAttributeValueCurrent(textareaDepartmentContact);
jsonRow[attrIdSupplierAddress] = DOM.getElementAttributeValueCurrent(tdAddress);
jsonRow[flagSupplierAddress] = this.getSupplierAddressesFromRow(row);
jsonRow[flagPhoneNumber] = DOM.getElementAttributeValueCurrent(textareaPhoneNumber);
jsonRow[flagFax] = DOM.getElementAttributeValueCurrent(textareaFax);
jsonRow[flagEmail] = DOM.getElementAttributeValueCurrent(textareaEmail);
jsonRow[flagWebsite] = DOM.getElementAttributeValueCurrent(textareaWebsite);
jsonRow[attrIdCurrency] = DOM.getElementAttributeValueCurrent(tdCurrency);
jsonRow[flagActive] = DOM.getElementAttributeValueCurrent(checkboxActive);
return jsonRow;
}
getSupplierAddressesFromRow(row) {
let supplierAddresses = [];
let trs = row.querySelectorAll('td.' + flagAddress + ' tr');
let address, inputPostcode, inputAddressLine1, inputAddressLine2, inputCity, inputCounty, ddlRegion, inputActive;
trs.forEach((tr) => {
inputPostcode = tr.querySelector('td.' + flagPostcode + ' textarea');
inputAddressLine1 = tr.querySelector('td.' + flagAddressLine1 + ' textarea');
inputAddressLine2 = tr.querySelector('td.' + flagAddressLine2 + ' textarea');
inputCity = tr.querySelector('td.' + flagCity + ' textarea');
inputCounty = tr.querySelector('td.' + flagCounty + ' textarea');
ddlRegion = tr.querySelector('td.' + flagRegion + ' select');
inputActive = tr.querySelector('td.' + flagActive + ' input');
address = {
[attrIdSupplierAddress]: tr.getAttribute(attrIdSupplierAddress),
[flagPostcode]: DOM.getElementAttributeValueCurrent(inputPostcode),
[flagAddressLine1]: DOM.getElementAttributeValueCurrent(inputAddressLine1),
[flagAddressLine2]: DOM.getElementAttributeValueCurrent(inputAddressLine2),
[flagCity]: DOM.getElementAttributeValueCurrent(inputCity),
[flagCounty]: DOM.getElementAttributeValueCurrent(inputCounty),
[attrIdRegion]: DOM.getElementAttributeValueCurrent(ddlRegion),
[flagActive]: DOM.getElementAttributeValueCurrent(inputActive),
};
supplierAddresses.push(address);
});
return supplierAddresses;
}
initialiseRowNew(row) {
super.initialiseRowNew(row);
}
hookupTableMain() {
super.hookupTableMain();
this.hookupNameCompanyInputs();
this.hookupNameContactInputs();
this.hookupDepartmentContactInputs();
this.hookupAddressFields();
this.hookupPhoneNumberInputs();
this.hookupFaxInputs();
this.hookupEmailInputs();
this.hookupWebsiteInputs();
this.hookupCurrencyFields();
this.hookupActiveCheckboxes();
}
hookupNameCompanyInputs() {
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagNameCompany + ' textarea');
}
hookupNameContactInputs() {
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagNameContact + ' textarea');
}
hookupDepartmentContactInputs() {
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagDepartmentContact + ' textarea');
}
hookupAddressFields() {
this.hookupAddressPreviews();
this.hookupAddressPostcodeInputs();
this.hookupAddressLine1Inputs();
this.hookupAddressLine2Inputs();
this.hookupAddressCityInputs();
this.hookupAddressCountyInputs();
this.hookupAddressRegionDdls();
this.hookupAddressActiveCheckboxes();
this.hookupAddressDeleteButtons();
this.hookupAddressUndeleteButtons();
this.hookupAddressAddButtons();
}
hookupAddressPreviews() {
this.hookupEventHandler("click", idTableMain + ' td.' + flagAddress, (event, td) => {
if (!td.classList.contains(flagCollapsed)) return;
this.handleClickAddressPreview(event, td);
});
}
handleClickAddressPreview(event, element) {
console.log("click address preview");
this.toggleColumnHeaderCollapsed(flagAddress, false);
element.classList.remove(flagCollapsed);
let row = DOM.getRowFromElement(element);
let idSupplier = row.getAttribute(attrIdSupplier);
let supplierAddressList = idSupplier > 0 ? supplierAddresses[idSupplier] : [];
let tblAddresses = document.createElement("table");
tblAddresses.classList.add(flagAddress);
let thead = document.createElement("thead");
let tr = document.createElement("tr");
let thPostcode = document.createElement("th");
thPostcode.classList.add(flagPostcode);
thPostcode.textContent = 'Postcode';
let thAddressLine1 = document.createElement("th");
thAddressLine1.classList.add(flagAddressLine1);
thAddressLine1.textContent = 'Address Line 1';
let thAddressLine2 = document.createElement("th");
thAddressLine2.classList.add(flagAddressLine2);
thAddressLine2.textContent = 'Address Line 2';
let thCity = document.createElement("th");
thCity.classList.add(flagCity);
thCity.textContent = 'City';
let thCounty = document.createElement("th");
thCounty.classList.add(flagCounty);
thCounty.textContent = 'County';
let thRegion = document.createElement("th");
thRegion.classList.add(flagRegion);
thRegion.textContent = 'Region';
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(thPostcode);
tr.appendChild(thAddressLine1);
tr.appendChild(thAddressLine2);
tr.appendChild(thCity);
tr.appendChild(thCounty);
tr.appendChild(thRegion);
tr.appendChild(thActive);
tr.appendChild(thAddDelete);
thead.appendChild(tr);
tblAddresses.appendChild(thead);
let tbody = document.createElement("tbody");
let regionOptions = Utils.getListFromDict(regions);
supplierAddressList.forEach((supplierAddress, index) => {
this.addRowSupplierAddress(tbody, supplierAddress, regionOptions);
});
tblAddresses.appendChild(tbody);
let cell = DOM.getCellFromElement(element);
let cellNew = cell.cloneNode(false);
cellNew.appendChild(tblAddresses);
row.replaceChild(cellNew, cell);
console.log("tblAddresses: ", tblAddresses);
this.hookupAddressFields();
}
addRowSupplierAddress(tbody, supplierAddress, regionOptions) {
console.log("addRowSupplierAddress: ", supplierAddress);
let tdPostcode = document.createElement("td");
tdPostcode.classList.add(flagPostcode);
let textareaPostcode = document.createElement("textarea");
textareaPostcode.classList.add(flagPostcode);
DOM.setElementValuesCurrentAndPrevious(textareaPostcode, supplierAddress[flagPostcode]);
tdPostcode.appendChild(textareaPostcode);
let tdAddressLine1 = document.createElement("td");
tdAddressLine1.classList.add(flagAddressLine1);
let textareaAddressLine1 = document.createElement("textarea");
textareaAddressLine1.classList.add(flagAddressLine1);
DOM.setElementValuesCurrentAndPrevious(textareaAddressLine1, supplierAddress[flagAddressLine1]);
tdAddressLine1.appendChild(textareaAddressLine1);
let tdAddressLine2 = document.createElement("td");
tdAddressLine2.classList.add(flagAddressLine2);
let textareaAddressLine2 = document.createElement("textarea");
textareaAddressLine2.classList.add(flagAddressLine2);
DOM.setElementValuesCurrentAndPrevious(textareaAddressLine2, supplierAddress[flagAddressLine2]);
tdAddressLine2.appendChild(textareaAddressLine2);
let tdCity = document.createElement("td");
tdCity.classList.add(flagCity);
let textareaCity = document.createElement("textarea");
textareaCity.classList.add(flagCity);
DOM.setElementValuesCurrentAndPrevious(textareaCity, supplierAddress[flagCity]);
tdCity.appendChild(textareaCity);
let tdCounty = document.createElement("td");
tdCounty.classList.add(flagCounty);
let textareaCounty = document.createElement("textarea");
textareaCounty.classList.add(flagCounty);
DOM.setElementValuesCurrentAndPrevious(textareaCounty, supplierAddress[flagCounty]);
tdCounty.appendChild(textareaCounty);
let region = supplierAddress[flagRegion];
if (!region) region = {[attrIdRegion]: ''};
let tdRegion = document.createElement("td");
tdRegion.classList.add(flagRegion);
DOM.setElementAttributesValuesCurrentAndPrevious(tdRegion, region[attrIdRegion]);
let ddlRegion = document.createElement("select");
ddlRegion.classList.add(flagRegion);
let optionJson, option;
regionOptions.forEach((regionOption) => {
optionJson = BusinessObjects.getOptionJsonFromObjectJson(regionOption);
option = DOM.createOption(optionJson);
ddlRegion.appendChild(option);
});
DOM.setElementValuesCurrentAndPrevious(ddlRegion, region[attrIdRegion]);
tdRegion.appendChild(ddlRegion);
let tdActive = document.createElement("td");
tdActive.classList.add(flagActive);
let checkboxActive = document.createElement("input");
checkboxActive.classList.add(flagActive);
checkboxActive.type = 'checkbox';
DOM.setElementValuesCurrentAndPrevious(checkboxActive, supplierAddress[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.setAttribute(attrIdSupplierAddress, supplierAddress[attrIdSupplierAddress]);
tr.appendChild(tdPostcode);
tr.appendChild(tdAddressLine1);
tr.appendChild(tdAddressLine2);
tr.appendChild(tdCity);
tr.appendChild(tdCounty);
tr.appendChild(tdRegion);
tr.appendChild(tdActive);
tr.appendChild(tdDelete);
tbody.appendChild(tr);
}
hookupAddressPostcodeInputs() {
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagAddress + ' textarea.' + flagPostcode);
}
hookupAddressLine1Inputs() {
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagAddress + ' textarea.' + flagAddressLine1);
}
hookupAddressLine2Inputs() {
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagAddress + ' textarea.' + flagAddressLine2);
}
hookupAddressCityInputs() {
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagAddress + ' textarea.' + flagCity);
}
hookupAddressCountyInputs() {
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagAddress + ' textarea.' + flagCounty);
}
hookupAddressRegionDdls() {
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagAddress + ' select.' + flagRegion);
}
hookupAddressActiveCheckboxes() {
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagAddress + ' input.' + flagActive, (event, element) => {
let rowSupplierAddress = element.closest('tr');
let idAddress = rowSupplierAddress.getAttribute(attrIdSupplierAddress);
DOM.setElementAttributeValueCurrent(rowSupplierAddress, idAddress);
let rowSupplier = rowSupplierAddress.closest(idTableMain + ' > tbody > tr');
let checkboxesActive = rowSupplier.querySelectorAll('td.' + flagAddress + ' input.' + flagActive);
let isActive = element.checked;
if (isActive) {
checkboxesActive.forEach((checkbox) => {
if (checkbox == element) return;
DOM.setElementValueCurrent(checkbox, false);
});
}
/*
else if (checkboxesActive.length > 0) {
DOM.setElementValueCurrent(checkboxesActive[0], false);
}
*/
});
}
hookupAddressDeleteButtons() {
this.hookupEventHandler("click", idTableMain + ' td.' + flagAddress + ' button.' + flagDelete, (event, element) => {
let row = DOM.getRowFromElement(element);
row.classList.add(flagDelete);
let buttonAdd = document.createElement("button");
buttonAdd.classList.add(flagAdd);
buttonAdd.textContent = '+';
element.replaceWith(buttonAdd);
this.hookupAddressUndeleteButtons();
});
}
hookupAddressUndeleteButtons() {
this.hookupEventHandler("click", idTableMain + ' td.' + flagAddress + ' td button.' + flagAdd, (event, element) => {
let row = DOM.getRowFromElement(element);
row.classList.remove(flagDelete);
let buttonDelete = document.createElement("button");
buttonDelete.classList.add(flagDelete);
buttonDelete.textContent = 'x';
element.replaceWith(buttonDelete);
this.hookupAddressDeleteButtons();
});
}
hookupAddressAddButtons() {
this.hookupEventHandler("click", idTableMain + ' td.' + flagAddress + ' th button.' + flagAdd, (event, element) => {
let row = element.closest(idTableMain + ' > tbody > tr');
let idSupplier = row.getAttribute(attrIdSupplier);
let hasActiveAddress = row.querySelectorAll('td.' + flagAddress + ' input.' + flagActive + ':checked').length > 0;
let countSupplierAddresses = row.querySelectorAll('td.' + flagAddress + ' td.' + flagAddress).length;
let supplierAddress = {
[attrIdSupplier]: idSupplier,
[attrIdSupplierAddress]: -1 - countSupplierAddresses,
[flagPostcode]: '',
[flagAddressLine1]: '',
[flagAddressLine2]: '',
[flagCity]: '',
[flagCounty]: '',
[attrIdRegion]: '',
[flagActive]: !hasActiveAddress,
};
let tbody = row.querySelector('td.' + flagAddress + ' table tbody');
this.addRowSupplierAddress(tbody, supplierAddress, Utils.getListFromDict(regions));
if (!hasActiveAddress) {
let tdAddress = row.querySelector('td.' + flagAddress);
// tdAddress.setAttribute(attrIdSupplierAddress, supplierAddress[attrIdSupplierAddress]);
DOM.setElementAttributeValueCurrent(tdAddress, supplierAddress[attrIdSupplierAddress]);
}
this.hookupAddressFields();
});
}
hookupPhoneNumberInputs() {
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagPhoneNumber + ' textarea');
}
hookupFaxInputs() {
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagFax + ' textarea');
}
hookupEmailInputs() {
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagEmail + ' textarea');
}
hookupWebsiteInputs() {
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagWebsite + ' textarea');
}
hookupActiveCheckboxes(){
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagActive + ' input');
}
leave() {
super.leave();
}
}

View File

@@ -12,12 +12,15 @@ import PageLicense from './pages/legal/license.js';
// Store
import PageStoreBasket from './pages/store/basket.js';
import PageStoreHome from './pages/store/home.js';
import PageStoreManufacturingPurchaseOrders from './pages/store/manufacturing_purchase_orders.js';
import PageStoreProductCategories from './pages/store/product_categories.js';
import PageStoreProductPermutations from './pages/store/product_permutations.js';
// import PageStoreProductPrices from './pages/store/product_prices.js';
import PageStoreProducts from './pages/store/products.js';
// import PageStoreProductVariations from './pages/store/product_variations.js';
import PageStoreStockItems from './pages/store/stock_items.js';
import PageStoreSuppliers from './pages/store/suppliers.js';
import PageStoreSupplierPurchaseOrders from './pages/store/supplier_purchase_orders.js';
// User
// import PageUserLogin from './pages/user/login.js';
// import PageUserLogout from './pages/user/logout.js';
@@ -77,12 +80,15 @@ export default class Router {
this.pages[hashPageLicense] = { name: 'PageLicense', module: PageLicense }; // pathModule: './pages/legal/license.js' };
this.pages[hashPagePrivacyPolicy] = { name: 'PagePrivacyPolicy', module: PagePrivacyPolicy }; // pathModule: './pages/legal/privacy_policy.js' }; // importModule: () => {return import(/* webpackChunkName: "page_privacy_policy" */ './pages/legal/privacy_policy.js'); }
// Store
this.pages[hashPageStoreManufacturingPurchaseOrders] = { name: 'PageManufacturingPurchaseOrders', module: PageStoreManufacturingPurchaseOrders }; // pathModule
this.pages[hashPageStoreProductCategories] = { name: 'PageStoreProductCategories', module: PageStoreProductCategories }; // pathModule: './pages/store/product_categories.js' };
this.pages[hashPageStoreProductPermutations] = { name: 'PageStoreProductPermutations', module: PageStoreProductPermutations }; // pathModule: './pages/store/product_permutations.js' };
// this.pages[hashPageStoreProductPrices] = { name: 'PageStoreProductPrices', module: PageStoreProductPrices }; // pathModule: './pages/store/product_prices.js' };
this.pages[hashPageStoreProducts] = { name: 'PageStoreProducts', module: PageStoreProducts }; // pathModule: './pages/store/products.js' };
// this.pages[hashPageStoreProductVariations] = { name: 'PageStoreProductVariations', module: PageStoreProductVariations }; // pathModule: './pages/store/product_variations.js' };
this.pages[hashPageStoreStockItems] = { name: 'PageStoreStockItems', module: PageStoreStockItems };
this.pages[hashPageStoreSuppliers] = { name: 'PageStoreSuppliers', module: PageStoreSuppliers };
this.pages[hashPageStoreSupplierPurchaseOrders] = { name: 'PageSupplierPurchaseOrders', module: PageStoreSupplierPurchaseOrders };
// User
// this.pages[hashPageUserLogin] = { name: 'PageUserLogin', module: PageUserLogin }; // pathModule: './pages/user/login.js' };
// this.pages[hashPageUserLogout] = { name: 'PageUserLogout', module: PageUserLogout }; // pathModule: './pages/user/logout.js' };
@@ -101,12 +107,15 @@ export default class Router {
this.routes[hashPageLicense] = (isPopState = false) => this.navigateToHash(hashPageLicense, isPopState);
this.routes[hashPagePrivacyPolicy] = (isPopState = false) => this.navigateToHash(hashPagePrivacyPolicy, isPopState);
// Store
this.routes[hashPageStoreManufacturingPurchaseOrders] = (isPopState = false) => this.navigateToHash(hashPageStoreManufacturingPurchaseOrders, isPopState);
this.routes[hashPageStoreProductCategories] = (isPopState = false) => this.navigateToHash(hashPageStoreProductCategories, isPopState);
this.routes[hashPageStoreProductPermutations] = (isPopState = false) => this.navigateToHash(hashPageStoreProductPermutations, isPopState);
// this.routes[hashPageStoreProductPrices] = (isPopState = false) => this.navigateToHash(hashPageStoreProductPrices, isPopState);
this.routes[hashPageStoreProducts] = (isPopState = false) => this.navigateToHash(hashPageStoreProducts, isPopState);
// this.routes[hashPageStoreProductVariations] = (isPopState = false) => this.navigateToHash(hashPageStoreProductVariations, isPopState);
this.routes[hashPageStoreStockItems] = (isPopState = false) => this.navigateToHash(hashPageStoreStockItems, isPopState);
this.routes[hashPageStoreSuppliers] = (isPopState = false) => this.navigateToHash(hashPageStoreSuppliers, isPopState);
this.routes[hashPageStoreSupplierPurchaseOrders] = (isPopState = false) => this.navigateToHash(hashPageStoreSupplierPurchaseOrders, isPopState);
// User
// this.routes[hashPageUserLogin] = (isPopState = false) => this.navigateToHash(hashPageUserLogin, isPopState);
// this.routes[hashPageUserLogout] = (isPopState = false) => this.navigateToHash(hashPageUserLogout, isPopState);

View File

@@ -1,6 +1,6 @@
{% with _is_blank_row = (is_blank_row or model.currencies | length == 0 or currency is none) %}
{% with _is_blank_row = (is_blank_row or model.currencies | length == 0 or currency is not defined or currency is none) %}
{% if not _is_blank_row %}
<div
class="{{ model.FLAG_CURRENCY }}"

View File

@@ -0,0 +1,13 @@
{% with _is_blank_row = (is_blank_row or address is not defined or address is none or is_blank_row is not defined) %}
{% if not _is_blank_row %}
{% set json_str = address.to_json_str() %}
<div
class="{{ model.FLAG_ADDRESS }}"
{{ model.ATTR_VALUE_CURRENT }}="{{ json_str }}"
{{ model.ATTR_VALUE_PREVIOUS }}="{{ json_str }}"
>{{ address.postcode }}</div>
{% else %}
<div class="{{ model.FLAG_ADDRESS }}" {{ model.ATTR_VALUE_CURRENT }} {{ model.ATTR_VALUE_PREVIOUS }}></div>
{% endif %}
{% endwith %}

View File

@@ -0,0 +1,13 @@
{% with _is_blank_row = (is_blank_row or order_items is not defined or order_items is none or is_blank_row is not defined) %}
{% if not _is_blank_row %}
{% set str_items = order_items.to_preview_str() %}
<div
class="{{ model.FLAG_ITEMS }}"
{{ model.ATTR_VALUE_CURRENT }}="{{ json_str_items }}"
{{ model.ATTR_VALUE_PREVIOUS }}="{{ json_str_items }}"
>{{ str_items }}</div>
{% else %}
<div class="{{ model.FLAG_ITEMS }}" {{ model.ATTR_VALUE_CURRENT }} {{ model.ATTR_VALUE_PREVIOUS }}></div>
{% endif %}
{% endwith %}

View File

@@ -0,0 +1,13 @@
{% with _is_blank_row = (is_blank_row or order_items is not defined or order_items is none or is_blank_row is not defined) %}
{% if not _is_blank_row %}
{% set str_items = order_items.to_preview_str() %}
<div
class="{{ model.FLAG_ITEMS }}"
{{ model.ATTR_VALUE_CURRENT }}="{{ json_str_items }}"
{{ model.ATTR_VALUE_PREVIOUS }}="{{ json_str_items }}"
>{{ str_items }}</div>
{% else %}
<div class="{{ model.FLAG_ITEMS }}" {{ model.ATTR_VALUE_CURRENT }} {{ model.ATTR_VALUE_PREVIOUS }}></div>
{% endif %}
{% endwith %}

View File

@@ -1,13 +1,5 @@
{#
{% if variation_tree is not defined %}
{% set is_blank_row = True %}
{% endif %}
{% if is_blank_row is not defined %}
{% set is_blank_row = True %}
{% endif %}
#}
{% with _is_blank_row = (is_blank_row or variation_tree is not defined or variation_tree is none or is_blank_row is not defined or is_blank_row) %}
{% with _is_blank_row = (is_blank_row or variation_tree is not defined or variation_tree is none or is_blank_row is not defined) %}
{% if not _is_blank_row %}
{% set str_ids_variations = variation_tree.to_variation_id_pairs_str() %}
{% set str_variations = variation_tree.to_preview_str() %}

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