feat: Shop Supplier Purchase Order get, filter, and add new.
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -35,6 +35,7 @@ class Base():
|
||||
FLAG_CITY: ClassVar[str] = 'city'
|
||||
FLAG_CODE: ClassVar[str] = 'code'
|
||||
FLAG_COUNTY: ClassVar[str] = 'county'
|
||||
FLAG_CREATED_BY: ClassVar[str] = 'created_by'
|
||||
FLAG_CREATED_ON: ClassVar[str] = 'created_on'
|
||||
FLAG_CURRENCY: ClassVar[str] = 'currency'
|
||||
FLAG_CURRENCY_COST: ClassVar[str] = 'currency_cost'
|
||||
|
||||
@@ -68,8 +68,6 @@ class Currency(db.Model, Store_Base):
|
||||
return currency
|
||||
@classmethod
|
||||
def from_DB_get_many_product_catalogue_product_permutation(cls, query_row):
|
||||
_m = 'Currency.from_DB_get_many_product_catalogue_product_permutation'
|
||||
v_arg_type = 'class attribute'
|
||||
currency = cls()
|
||||
currency.id_currency = query_row[5]
|
||||
currency.code = query_row[6]
|
||||
@@ -77,14 +75,10 @@ class Currency(db.Model, Store_Base):
|
||||
return currency
|
||||
@classmethod
|
||||
def from_DB_get_many_product_price_and_discount_and_delivery_region(cls, query_row):
|
||||
_m = 'Currency.from_DB_get_many_product_price_and_discount_and_delivery_region'
|
||||
v_arg_type = 'class attribute'
|
||||
currency = cls()
|
||||
return currency
|
||||
@classmethod
|
||||
def from_DB_stock_item(cls, query_row):
|
||||
_m = 'Currency.from_DB_get_many_stock_item'
|
||||
v_arg_type = 'class attribute'
|
||||
currency = cls()
|
||||
currency.id_currency = query_row[12]
|
||||
currency.code = query_row[13]
|
||||
@@ -92,12 +86,24 @@ class Currency(db.Model, Store_Base):
|
||||
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]
|
||||
currency.code = query_row[2]
|
||||
currency.symbol = query_row[3]
|
||||
return currency
|
||||
@classmethod
|
||||
def from_DB_supplier_purchase_order(cls, query_row):
|
||||
currency = cls()
|
||||
currency.id_currency = query_row[3]
|
||||
currency.code = query_row[4]
|
||||
currency.symbol = query_row[5]
|
||||
return currency
|
||||
@classmethod
|
||||
def from_DB_manufacturing_purchase_order(cls, query_row):
|
||||
currency = cls()
|
||||
currency.id_currency = query_row[1]
|
||||
currency.code = query_row[2]
|
||||
currency.symbol = query_row[3]
|
||||
return currency
|
||||
def __repr__(self):
|
||||
return f'''
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -12,6 +12,7 @@ Business object for manufacturing_purchase_order
|
||||
|
||||
# internal
|
||||
import lib.argument_validation as av
|
||||
from business_objects.currency import Currency
|
||||
from business_objects.db_base import Get_Many_Parameters_Base
|
||||
from business_objects.store.store_base import Store_Base
|
||||
from extensions import db
|
||||
@@ -38,19 +39,21 @@ class Manufacturing_Purchase_Order(db.Model, Store_Base):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
Store_Base.__init__(self)
|
||||
self.items = None
|
||||
self.items = []
|
||||
self.currency = 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]
|
||||
manufacturing_purchase_order.currency = Currency.from_DB_manufacturing_purchase_order(query_row)
|
||||
manufacturing_purchase_order.cost_total_local_VAT_excl = query_row[4]
|
||||
manufacturing_purchase_order.cost_total_local_VAT_incl = query_row[5]
|
||||
manufacturing_purchase_order.price_total_local_VAT_excl = query_row[6]
|
||||
manufacturing_purchase_order.price_total_local_VAT_incl = query_row[7]
|
||||
manufacturing_purchase_order.active = av.input_bool(query_row[8], 'active', f'{cls.__name__}.from_DB_manufacturing_purchase_order')
|
||||
manufacturing_purchase_order.created_on = query_row[9]
|
||||
manufacturing_purchase_order.name = query_row[10]
|
||||
return manufacturing_purchase_order
|
||||
|
||||
def __repr__(self):
|
||||
@@ -74,6 +77,7 @@ class Manufacturing_Purchase_Order(db.Model, Store_Base):
|
||||
self.FLAG_COST_TOTAL_LOCAL_VAT_INCL: self.cost_total_local_VAT_incl,
|
||||
self.FLAG_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_ORDER_ITEMS: [item.to_json() for item in self.items],
|
||||
self.FLAG_ACTIVE: av.input_bool(self.active, self.FLAG_ACTIVE, f'{self.__class__.__name__}.to_json'),
|
||||
self.FLAG_CREATED_ON: self.created_on,
|
||||
self.FLAG_NAME: self.name,
|
||||
@@ -107,7 +111,6 @@ class Manufacturing_Purchase_Order(db.Model, Store_Base):
|
||||
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
|
||||
@@ -120,7 +123,8 @@ class Manufacturing_Purchase_Order_Product_Link(db.Model, Store_Base):
|
||||
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)
|
||||
id_unit_latency_manufacture = db.Column(db.Integer)
|
||||
latency_manufacture = 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)
|
||||
@@ -142,13 +146,14 @@ class Manufacturing_Purchase_Order_Product_Link(db.Model, Store_Base):
|
||||
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]
|
||||
link.id_unit_latency_manufacture = query_row[7]
|
||||
link.latency_manufacture = query_row[8]
|
||||
link.display_order = query_row[9]
|
||||
link.cost_unit_local_VAT_excl = query_row[10]
|
||||
link.cost_unit_local_VAT_incl = query_row[11]
|
||||
link.price_unit_local_VAT_excl = query_row[12]
|
||||
link.price_unit_local_VAT_incl = query_row[13]
|
||||
link.active = query_row[14]
|
||||
return link
|
||||
def __repr__(self):
|
||||
return f'''
|
||||
@@ -159,7 +164,8 @@ class Manufacturing_Purchase_Order_Product_Link(db.Model, Store_Base):
|
||||
{self.ATTR_ID_UNIT_MEASUREMENT_QUANTITY}: {self.id_unit_quantity},
|
||||
{self.FLAG_QUANTITY_USED}: {self.quantity_used},
|
||||
{self.FLAG_QUANTITY_PRODUCED}: {self.quantity_produced},
|
||||
{self.FLAG_LATENCY_MANUFACTURE_DAYS}: {self.latency_manufacture_days},
|
||||
{self.ATTR_ID_UNIT_MEASUREMENT_LATENCY_MANUFACTURE}: {self.id_unit_latency_manufacture},
|
||||
{self.FLAG_LATENCY_MANUFACTURE}: {self.latency_manufacture},
|
||||
{self.FLAG_DISPLAY_ORDER}: {self.display_order},
|
||||
{self.FLAG_COST_UNIT_LOCAL_VAT_EXCL}: {self.cost_unit_local_VAT_excl},
|
||||
{self.FLAG_COST_UNIT_LOCAL_VAT_INCL}: {self.cost_unit_local_VAT_incl},
|
||||
@@ -177,7 +183,8 @@ class Manufacturing_Purchase_Order_Product_Link(db.Model, Store_Base):
|
||||
self.ATTR_ID_UNIT_MEASUREMENT_QUANTITY: self.id_unit_quantity,
|
||||
self.FLAG_QUANTITY_USED: self.quantity_used,
|
||||
self.FLAG_QUANTITY_PRODUCED: self.quantity_produced,
|
||||
self.FLAG_LATENCY_MANUFACTURE_DAYS: self.latency_manufacture_days,
|
||||
self.ATTR_ID_UNIT_MEASUREMENT_LATENCY_MANUFACTURE: self.id_unit_latency_manufacture,
|
||||
self.FLAG_LATENCY_MANUFACTURE: self.latency_manufacture,
|
||||
self.FLAG_DISPLAY_ORDER: self.display_order,
|
||||
self.FLAG_COST_UNIT_LOCAL_VAT_EXCL: self.cost_unit_local_VAT_excl,
|
||||
self.FLAG_COST_UNIT_LOCAL_VAT_INCL: self.cost_unit_local_VAT_incl,
|
||||
@@ -201,7 +208,8 @@ class Manufacturing_Purchase_Order_Product_Link(db.Model, Store_Base):
|
||||
link.id_unit_quantity = json[cls.ATTR_ID_UNIT_MEASUREMENT_QUANTITY]
|
||||
link.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.id_unit_latency_manufacture = json[cls.ATTR_ID_UNIT_MEASUREMENT_LATENCY_MANUFACTURE]
|
||||
link.latency_manufacture = json[cls.FLAG_LATENCY_MANUFACTURE]
|
||||
link.display_order = json[cls.FLAG_DISPLAY_ORDER]
|
||||
link.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]
|
||||
@@ -269,7 +277,8 @@ class Manufacturing_Purchase_Order_Product_Link_Temp(db.Model, Store_Base):
|
||||
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)
|
||||
id_unit_latency_manufacture = db.Column(db.Integer)
|
||||
latency_manufacture: 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)
|
||||
@@ -286,7 +295,8 @@ class Manufacturing_Purchase_Order_Product_Link_Temp(db.Model, Store_Base):
|
||||
row.id_unit_quantity = manufacturing_purchase_order_product_link.id_unit_quantity
|
||||
row.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.id_unit_latency_manufacture = manufacturing_purchase_order_product_link.id_unit_latency_manufacture
|
||||
row.latency_manufacture = manufacturing_purchase_order_product_link.latency_manufacture
|
||||
row.display_order = manufacturing_purchase_order_product_link.display_order
|
||||
row.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
|
||||
@@ -302,7 +312,8 @@ 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}
|
||||
{self.ATTR_ID_UNIT_MEASUREMENT_LATENCY_MANUFACTURE}: {self.id_unit_latency_manufacture}
|
||||
latency_manufacture: {self.latency_manufacture}
|
||||
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}
|
||||
|
||||
@@ -40,7 +40,7 @@ class Product_Permutation(db.Model, Store_Base):
|
||||
FLAG_COST_LOCAL = 'cost_local'
|
||||
FLAG_PROFIT_LOCAL_MIN = 'profit_local_min'
|
||||
FLAG_HAS_VARIATIONS = 'has_variations'
|
||||
FLAG_LATENCY_MANUFACTURE_DAYS = 'latency_manufacture_days'
|
||||
FLAG_LATENCY_MANUFACTURE = 'latency_manufacture'
|
||||
FLAG_UNIT_MEASUREMENT_QUANTITY = f'{Unit_Measurement.ATTR_ID_UNIT_MEASUREMENT}_quantity'
|
||||
FLAG_SYMBOL_UNIT_MEASUREMENT_QUANTITY = f'{Unit_Measurement.FLAG_SYMBOL}_quantity'
|
||||
FLAG_SYMBOL_IS_SUFFIX_NOT_PREFIX_UNIT_MEASUREMENT_QUANTITY = f'{Unit_Measurement.FLAG_SYMBOL_IS_SUFFIX_NOT_PREFIX}_quantity'
|
||||
@@ -80,7 +80,7 @@ class Product_Permutation(db.Model, Store_Base):
|
||||
cost_local = db.Column(db.Float)
|
||||
profit_local_min = db.Column(db.Float)
|
||||
has_variations = db.Column(db.Boolean)
|
||||
latency_manufacture_days = db.Column(db.Integer)
|
||||
latency_manufacture = db.Column(db.Integer)
|
||||
id_unit_measurement_quantity = db.Column(db.Integer)
|
||||
symbol_unit_measurement_quantity = db.Column(db.String(50))
|
||||
symbol_is_suffix_not_prefix_unit_measurement_quantity = db.Column(db.Boolean)
|
||||
@@ -151,7 +151,7 @@ class Product_Permutation(db.Model, Store_Base):
|
||||
permutation.cost_local = query_row[4]
|
||||
permutation.currency_cost = Currency.from_DB_get_many_product_catalogue_product_permutation(query_row)
|
||||
permutation.profit_local_min = query_row[8]
|
||||
permutation.latency_manufacture_days = query_row[9]
|
||||
permutation.latency_manufacture = query_row[9]
|
||||
permutation.id_unit_measurement_quantity = query_row[10]
|
||||
permutation.symbol_unit_measurement_quantity = query_row[11]
|
||||
permutation.symbol_is_suffix_not_prefix_unit_measurement_quantity = av.input_bool(query_row[12], cls.FLAG_SYMBOL_IS_SUFFIX_NOT_PREFIX_UNIT_MEASUREMENT_QUANTITY, _m, v_arg_type=v_arg_type)
|
||||
@@ -224,7 +224,7 @@ class Product_Permutation(db.Model, Store_Base):
|
||||
permutation.cost_local = json[cls.FLAG_COST_LOCAL]
|
||||
permutation.currency_cost = Currency.from_json(json, '_cost')
|
||||
permutation.profit_local_min = json[cls.FLAG_PROFIT_LOCAL_MIN]
|
||||
permutation.latency_manufacture_days = json[cls.FLAG_LATENCY_MANUFACTURE_DAYS]
|
||||
permutation.latency_manufacture = json[cls.FLAG_LATENCY_MANUFACTURE]
|
||||
permutation.id_unit_measurement_quantity = json[cls.FLAG_UNIT_MEASUREMENT_QUANTITY]
|
||||
permutation.symbol_unit_measurement_quantity = json.get(cls.FLAG_SYMBOL_UNIT_MEASUREMENT_QUANTITY)
|
||||
permutation.symbol_is_suffix_not_prefix_unit_measurement_quantity = json.get(cls.FLAG_SYMBOL_IS_SUFFIX_NOT_PREFIX_UNIT_MEASUREMENT_QUANTITY)
|
||||
@@ -269,7 +269,7 @@ class Product_Permutation(db.Model, Store_Base):
|
||||
self.FLAG_COST_LOCAL: self.cost_local,
|
||||
self.FLAG_CURRENCY_COST: self.currency_cost.to_json(),
|
||||
self.FLAG_PROFIT_LOCAL_MIN: self.profit_local_min,
|
||||
self.FLAG_LATENCY_MANUFACTURE_DAYS: self.latency_manufacture_days,
|
||||
self.FLAG_LATENCY_MANUFACTURE: self.latency_manufacture,
|
||||
self.FLAG_UNIT_MEASUREMENT_QUANTITY: self.id_unit_measurement_quantity,
|
||||
self.FLAG_SYMBOL_UNIT_MEASUREMENT_QUANTITY: self.symbol_unit_measurement_quantity,
|
||||
self.FLAG_SYMBOL_IS_SUFFIX_NOT_PREFIX_UNIT_MEASUREMENT_QUANTITY: self.symbol_is_suffix_not_prefix_unit_measurement_quantity,
|
||||
@@ -320,11 +320,11 @@ class Product_Permutation(db.Model, Store_Base):
|
||||
return self.prices[0]
|
||||
|
||||
def output_delivery_date(self):
|
||||
return (datetime.now() + timedelta(days=self.latency_manufacture_days)).strftime('%A, %d %B %Y')
|
||||
return (datetime.now() + timedelta(days=self.latency_manufacture)).strftime('%A, %d %B %Y')
|
||||
|
||||
"""
|
||||
def output_lead_time(self):
|
||||
return '1 day' if self.latency_manufacture_days == 1 else f'{self.latency_manufacture_days} days'
|
||||
return '1 day' if self.latency_manufacture == 1 else f'{self.latency_manufacture} days'
|
||||
|
||||
def output_price(self, is_included_VAT):
|
||||
if self.is_unavailable_in_currency_or_region:
|
||||
@@ -353,7 +353,7 @@ class Product_Permutation(db.Model, Store_Base):
|
||||
description: {self.description}
|
||||
cost_local: {self.cost_local}
|
||||
currency_cost: {self.currency_cost}
|
||||
latency_manufacture_days: {self.latency_manufacture_days}
|
||||
latency_manufacture: {self.latency_manufacture}
|
||||
id_unit_measurement_quantity: {self.id_unit_measurement_quantity}
|
||||
symbol_unit_measurement_quantity: {self.symbol_unit_measurement_quantity}
|
||||
symbol_is_suffix_not_prefix_unit_measurement_quantity: {self.symbol_is_suffix_not_prefix_unit_measurement_quantity}
|
||||
@@ -500,7 +500,7 @@ class Product_Permutation_Temp(db.Model, Store_Base):
|
||||
cost_local: float = db.Column(db.Float)
|
||||
id_currency_cost: int = db.Column(db.Integer)
|
||||
profit_local_min: float = db.Column(db.Float)
|
||||
latency_manufacture_days: int = db.Column(db.Integer)
|
||||
latency_manufacture: int = db.Column(db.Integer)
|
||||
id_unit_measurement_quantity: int = db.Column(db.Integer)
|
||||
count_unit_measurement_per_quantity_step: int = db.Column(db.Float)
|
||||
quantity_min: int = db.Column(db.Integer)
|
||||
@@ -525,7 +525,7 @@ class Product_Permutation_Temp(db.Model, Store_Base):
|
||||
row.cost_local = product_permutation.cost_local
|
||||
row.id_currency_cost = product_permutation.currency_cost.id_currency
|
||||
row.profit_local_min = product_permutation.profit_local_min
|
||||
row.latency_manufacture_days = product_permutation.latency_manufacture_days
|
||||
row.latency_manufacture = product_permutation.latency_manufacture
|
||||
row.id_unit_measurement_quantity = product_permutation.id_unit_measurement_quantity
|
||||
row.count_unit_measurement_per_quantity_step = product_permutation.count_unit_measurement_per_quantity_step
|
||||
row.quantity_min = product_permutation.quantity_min
|
||||
@@ -548,7 +548,7 @@ class Product_Permutation_Temp(db.Model, Store_Base):
|
||||
cost_local: {self.cost_local}
|
||||
id_currency_cost: {self.id_currency_cost}
|
||||
profit_local_min: {self.profit_local_min}
|
||||
latency_manufacture_days: {self.latency_manufacture_days}
|
||||
latency_manufacture: {self.latency_manufacture}
|
||||
id_unit_measurement_quantity: {self.id_unit_measurement_quantity}
|
||||
{Product_Permutation.FLAG_COUNT_UNIT_MEASUREMENT_PER_QUANTITY_STEP}: {self.count_unit_measurement_per_quantity_step}
|
||||
quantity_min: {self.quantity_min}
|
||||
@@ -573,7 +573,7 @@ class Product_Permutation_Temp(db.Model, Store_Base):
|
||||
Product_Permutation.FLAG_COST_LOCAL: float(self.cost_local),
|
||||
Product_Permutation.FLAG_CURRENCY_COST: int(self.id_currency_cost),
|
||||
Product_Permutation.FLAG_PROFIT_LOCAL_MIN: float(self.profit_local_min),
|
||||
Product_Permutation.FLAG_LATENCY_MANUFACTURE_DAYS: int(self.latency_manufacture_days),
|
||||
Product_Permutation.FLAG_LATENCY_MANUFACTURE: int(self.latency_manufacture),
|
||||
Product_Permutation.FLAG_UNIT_MEASUREMENT_QUANTITY: int(self.id_unit_measurement_quantity),
|
||||
Product_Permutation.FLAG_COUNT_UNIT_MEASUREMENT_PER_QUANTITY_STEP: float(self.count_unit_measurement_per_quantity_step),
|
||||
self.FLAG_QUANTITY_MIN: float(self.quantity_min),
|
||||
|
||||
@@ -80,6 +80,7 @@ class Store_Base(Base):
|
||||
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_LATENCY_MANUFACTURE: ClassVar[str] = 'id_unit_latency_manufacture'
|
||||
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'
|
||||
@@ -94,7 +95,9 @@ class Store_Base(Base):
|
||||
FLAG_HAS_VARIATIONS: ClassVar[str] = 'has_variations'
|
||||
FLAG_IS_OUT_OF_STOCK: ClassVar[str] = 'is_out_of_stock'
|
||||
FLAG_LATENCY_DELIVERY_DAYS: ClassVar[str] = 'latency_delivery_days'
|
||||
FLAG_LATENCY_MANUFACTURE: ClassVar[str] = 'latency_manufacture'
|
||||
FLAG_MANUFACTURING_PURCHASE_ORDER: ClassVar[str] = 'manufacturing_purchase_order'
|
||||
FLAG_ORDER_ITEMS: ClassVar[str] = 'order_items'
|
||||
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'
|
||||
@@ -118,5 +121,7 @@ class Store_Base(Base):
|
||||
FLAG_SUPPLIER_ADDRESS: ClassVar[str] = 'supplier_address'
|
||||
FLAG_SUPPLIER_PURCHASE_ORDER: ClassVar[str] = 'supplier_purchase_order'
|
||||
FLAG_TEXT: ClassVar[str] = 'text'
|
||||
FLAG_UNIT_MEASUREMENT_LATENCY_MANUFACTURE: ClassVar[str] = 'unit_measurement_latency_manufacture'
|
||||
FLAG_UNIT_MEASUREMENT_QUANTITY: ClassVar[str] = 'unit_measurement_quantity'
|
||||
FLAG_VALUE_TEXT: ClassVar[str] = 'value_text'
|
||||
|
||||
@@ -27,7 +27,7 @@ class Supplier(db.Model, Store_Base):
|
||||
FLAG_NAME_COMPANY: ClassVar[str] = 'name_company'
|
||||
FLAG_NAME_CONTACT: ClassVar[str] = 'name_contact'
|
||||
NAME_ATTR_OPTION_VALUE: ClassVar[str] = Store_Base.ATTR_ID_SUPPLIER
|
||||
NAME_ATTR_OPTION_TEXT: ClassVar[str] = Store_Base.FLAG_NAME
|
||||
NAME_ATTR_OPTION_TEXT: ClassVar[str] = FLAG_NAME_COMPANY
|
||||
__tablename__ = 'Shop_Supplier_Temp'
|
||||
id_supplier = db.Column(db.Integer, primary_key=True)
|
||||
# id_address = db.Column(db.Integer)
|
||||
@@ -64,7 +64,12 @@ class Supplier(db.Model, Store_Base):
|
||||
supplier.website = query_row[10]
|
||||
supplier.active = av.input_bool(query_row[11], 'active', f'{cls.__name__}.from_DB_supplier')
|
||||
return supplier
|
||||
|
||||
@classmethod
|
||||
def from_DB_supplier_purchase_order(cls, query_row):
|
||||
supplier = cls()
|
||||
supplier.id_supplier = query_row[1]
|
||||
supplier.name_company = query_row[2]
|
||||
return supplier
|
||||
def __repr__(self):
|
||||
return f'''
|
||||
id: {self.id_supplier},
|
||||
|
||||
@@ -12,8 +12,10 @@ Business object for supplier_purchase_order
|
||||
|
||||
# internal
|
||||
import lib.argument_validation as av
|
||||
from business_objects.currency import Currency
|
||||
from business_objects.db_base import Get_Many_Parameters_Base
|
||||
from business_objects.store.store_base import Store_Base
|
||||
from business_objects.store.supplier import Supplier
|
||||
from extensions import db
|
||||
# external
|
||||
from pydantic import BaseModel
|
||||
@@ -23,7 +25,7 @@ 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'
|
||||
__tablename__ = 'Shop_Supplier_Purchase_Order'
|
||||
id_order = db.Column(db.Integer, primary_key=True)
|
||||
id_supplier = db.Column(db.Integer)
|
||||
id_currency = db.Column(db.Integer)
|
||||
@@ -37,25 +39,31 @@ class Supplier_Purchase_Order(db.Model, Store_Base):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
Store_Base.__init__(self)
|
||||
self.items = None
|
||||
self.currency = None
|
||||
self.items = []
|
||||
self.supplier = 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]
|
||||
supplier_purchase_order.supplier = Supplier.from_DB_supplier_purchase_order(query_row)
|
||||
supplier_purchase_order.id_currency = query_row[3]
|
||||
supplier_purchase_order.currency = Currency.from_DB_supplier_purchase_order(query_row)
|
||||
supplier_purchase_order.cost_total_local_VAT_excl = query_row[6]
|
||||
supplier_purchase_order.cost_total_local_VAT_incl = query_row[7]
|
||||
supplier_purchase_order.active = av.input_bool(query_row[8], 'active', f'{cls.__name__}.from_DB_supplier_purchase_order')
|
||||
supplier_purchase_order.created_on = query_row[9]
|
||||
supplier_purchase_order.name = query_row[10]
|
||||
return supplier_purchase_order
|
||||
|
||||
def __repr__(self):
|
||||
return f'''
|
||||
{self.ATTR_ID_SUPPLIER_PURCHASE_ORDER}: {self.id_order},
|
||||
{self.ATTR_ID_SUPPLIER}: {self.id_supplier},
|
||||
{self.FLAG_SUPPLIER}: {self.supplier},
|
||||
{self.ATTR_ID_CURRENCY}: {self.id_currency},
|
||||
{self.FLAG_CURRENCY}: {self.currency},
|
||||
{self.FLAG_COST_TOTAL_LOCAL_VAT_EXCL}: {self.cost_total_local_VAT_excl},
|
||||
{self.FLAG_COST_TOTAL_LOCAL_VAT_INCL}: {self.cost_total_local_VAT_incl},
|
||||
{self.FLAG_ACTIVE}: {self.active},
|
||||
@@ -67,9 +75,12 @@ class Supplier_Purchase_Order(db.Model, Store_Base):
|
||||
**self.get_shared_json_attributes(self),
|
||||
self.ATTR_ID_SUPPLIER_PURCHASE_ORDER: self.id_order,
|
||||
self.ATTR_ID_SUPPLIER: self.id_supplier,
|
||||
self.FLAG_SUPPLIER: self.supplier.to_json(),
|
||||
self.ATTR_ID_CURRENCY: self.id_currency,
|
||||
self.FLAG_CURRENCY: self.currency.to_json(),
|
||||
self.FLAG_COST_TOTAL_LOCAL_VAT_EXCL: self.cost_total_local_VAT_excl,
|
||||
self.FLAG_COST_TOTAL_LOCAL_VAT_INCL: self.cost_total_local_VAT_incl,
|
||||
self.FLAG_ORDER_ITEMS: [item.to_json() for item in self.items],
|
||||
self.FLAG_ACTIVE: av.input_bool(self.active, self.FLAG_ACTIVE, f'{self.__class__.__name__}.to_json'),
|
||||
self.FLAG_CREATED_ON: self.created_on,
|
||||
self.FLAG_NAME: self.name,
|
||||
@@ -89,16 +100,19 @@ class Supplier_Purchase_Order(db.Model, Store_Base):
|
||||
supplier_purchase_order.cost_total_local_VAT_excl = json[cls.FLAG_COST_TOTAL_LOCAL_VAT_EXCL]
|
||||
supplier_purchase_order.cost_total_local_VAT_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]
|
||||
supplier_purchase_order.created_on = json.get(cls.FLAG_CREATED_ON, None)
|
||||
supplier_purchase_order.created_by = json.get(cls.FLAG_CREATED_BY, None)
|
||||
supplier_purchase_order.name = json.get(cls.FLAG_NAME, None)
|
||||
return supplier_purchase_order
|
||||
|
||||
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'
|
||||
__tablename__ = 'Shop_Supplier_Purchase_Order_Product_Link'
|
||||
id_link = db.Column(db.Integer, primary_key=True)
|
||||
id_order = db.Column(db.Integer)
|
||||
id_category = db.Column(db.Integer)
|
||||
id_product = db.Column(db.Integer)
|
||||
id_permutation = db.Column(db.Integer)
|
||||
id_unit_quantity = db.Column(db.Integer)
|
||||
name_permutation = db.Column(db.String(255))
|
||||
@@ -108,32 +122,41 @@ class Supplier_Purchase_Order_Product_Link(db.Model, Store_Base):
|
||||
display_order = db.Column(db.Integer)
|
||||
cost_total_local_VAT_excl = db.Column(db.Float)
|
||||
cost_total_local_VAT_incl = db.Column(db.Float)
|
||||
cost_unit_local_VAT_excl = db.Column(db.Float)
|
||||
cost_unit_local_VAT_incl = db.Column(db.Float)
|
||||
active = db.Column(db.Boolean)
|
||||
created_on = db.Column(db.DateTime)
|
||||
created_by = db.Column(db.Integer)
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
Store_Base.__init__(self)
|
||||
# self.unit_quantity = None
|
||||
@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]
|
||||
link.id_category = query_row[2]
|
||||
link.id_product = query_row[3]
|
||||
link.id_permutation = query_row[4]
|
||||
link.name_permutation = query_row[5]
|
||||
link.id_unit_quantity = query_row[6]
|
||||
link.quantity_ordered = query_row[7]
|
||||
link.quantity_received = query_row[8]
|
||||
link.latency_delivery_days = query_row[9]
|
||||
link.display_order = query_row[10]
|
||||
link.cost_total_local_VAT_excl = query_row[11]
|
||||
link.cost_total_local_VAT_incl = query_row[12]
|
||||
link.cost_unit_local_VAT_excl = query_row[13]
|
||||
link.cost_unit_local_VAT_incl = query_row[14]
|
||||
link.active = query_row[15]
|
||||
return link
|
||||
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_CATEGORY}: {self.id_category},
|
||||
{self.ATTR_ID_PRODUCT}: {self.id_product},
|
||||
{self.ATTR_ID_PRODUCT_PERMUTATION}: {self.id_permutation},
|
||||
{self.FLAG_NAME}: {self.name_permutation},
|
||||
{self.ATTR_ID_UNIT_MEASUREMENT_QUANTITY}: {self.id_unit_quantity},
|
||||
@@ -143,6 +166,8 @@ class Supplier_Purchase_Order_Product_Link(db.Model, Store_Base):
|
||||
{self.FLAG_DISPLAY_ORDER}: {self.display_order},
|
||||
{self.FLAG_COST_TOTAL_LOCAL_VAT_EXCL}: {self.cost_total_local_VAT_excl},
|
||||
{self.FLAG_COST_TOTAL_LOCAL_VAT_INCL}: {self.cost_total_local_VAT_incl},
|
||||
{self.FLAG_COST_UNIT_LOCAL_VAT_EXCL}: {self.cost_unit_local_VAT_excl},
|
||||
{self.FLAG_COST_UNIT_LOCAL_VAT_INCL}: {self.cost_unit_local_VAT_incl},
|
||||
{self.FLAG_ACTIVE}: {self.active}
|
||||
'''
|
||||
def to_json(self):
|
||||
@@ -150,6 +175,8 @@ class Supplier_Purchase_Order_Product_Link(db.Model, Store_Base):
|
||||
**self.get_shared_json_attributes(self),
|
||||
self.ATTR_ID_SUPPLIER_PURCHASE_ORDER_PRODUCT_LINK: self.id_link,
|
||||
self.ATTR_ID_SUPPLIER_PURCHASE_ORDER: self.id_order,
|
||||
self.ATTR_ID_PRODUCT_CATEGORY: self.id_category,
|
||||
self.ATTR_ID_PRODUCT: self.id_product,
|
||||
self.ATTR_ID_PRODUCT_PERMUTATION: self.id_permutation,
|
||||
self.FLAG_NAME: self.name_permutation,
|
||||
self.ATTR_ID_UNIT_MEASUREMENT_QUANTITY: self.id_unit_quantity,
|
||||
@@ -159,6 +186,8 @@ class Supplier_Purchase_Order_Product_Link(db.Model, Store_Base):
|
||||
self.FLAG_DISPLAY_ORDER: self.display_order,
|
||||
self.FLAG_COST_TOTAL_LOCAL_VAT_EXCL: self.cost_total_local_VAT_excl,
|
||||
self.FLAG_COST_TOTAL_LOCAL_VAT_INCL: self.cost_total_local_VAT_incl,
|
||||
self.FLAG_COST_UNIT_LOCAL_VAT_EXCL: self.cost_unit_local_VAT_excl,
|
||||
self.FLAG_COST_UNIT_LOCAL_VAT_INCL: self.cost_unit_local_VAT_incl,
|
||||
self.FLAG_ACTIVE: av.input_bool(self.active, self.FLAG_ACTIVE, f'{self.__class__.__name__}.to_json'),
|
||||
}
|
||||
def to_json_option(self):
|
||||
@@ -172,8 +201,10 @@ class Supplier_Purchase_Order_Product_Link(db.Model, Store_Base):
|
||||
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_category = json.get(cls.ATTR_ID_PRODUCT_CATEGORY, None)
|
||||
link.id_product = json.get(cls.ATTR_ID_PRODUCT, None)
|
||||
link.id_permutation = json[cls.ATTR_ID_PRODUCT_PERMUTATION]
|
||||
link.name_permutation = json[cls.FLAG_NAME]
|
||||
link.name_permutation = json.get(cls.FLAG_NAME, None)
|
||||
link.id_unit_quantity = json[cls.ATTR_ID_UNIT_MEASUREMENT_QUANTITY]
|
||||
link.quantity_ordered = json[cls.FLAG_QUANTITY_ORDERED]
|
||||
link.quantity_received = json[cls.FLAG_QUANTITY_RECEIVED]
|
||||
@@ -181,6 +212,8 @@ class Supplier_Purchase_Order_Product_Link(db.Model, Store_Base):
|
||||
link.display_order = json[cls.FLAG_DISPLAY_ORDER]
|
||||
link.cost_total_local_VAT_excl = json[cls.FLAG_COST_TOTAL_LOCAL_VAT_EXCL]
|
||||
link.cost_total_local_VAT_incl = json[cls.FLAG_COST_TOTAL_LOCAL_VAT_INCL]
|
||||
link.cost_unit_local_VAT_excl = json.get(cls.FLAG_COST_UNIT_LOCAL_VAT_EXCL, None)
|
||||
link.cost_unit_local_VAT_incl = json(cls.FLAG_COST_UNIT_LOCAL_VAT_INCL, None)
|
||||
link.active = json[cls.FLAG_ACTIVE]
|
||||
return link
|
||||
|
||||
@@ -213,31 +246,31 @@ class Parameters_Supplier_Purchase_Order(Get_Many_Parameters_Base):
|
||||
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
|
||||
parameters.a_date_from = None if form.date_from.data == '' else form.date_from.data
|
||||
parameters.a_date_to = None if form.date_to.data == '' else 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)
|
||||
id_supplier_ordered: int = db.Column(db.Integer)
|
||||
id_currency_cost: 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.id_supplier_ordered = supplier_purchase_order.id_supplier
|
||||
row.id_currency_cost = 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}
|
||||
id_supplier_ordered: {self.id_supplier_ordered}
|
||||
id_currency_cost: {self.id_currency_cost}
|
||||
active: {self.active}
|
||||
guid: {self.guid}
|
||||
'''
|
||||
@@ -245,23 +278,25 @@ 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))
|
||||
id_link = db.Column(db.Integer, primary_key=True)
|
||||
id_order = db.Column(db.Integer)
|
||||
id_product = db.Column(db.Integer)
|
||||
id_permutation = db.Column(db.Integer)
|
||||
id_unit_quantity = db.Column(db.Integer)
|
||||
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)
|
||||
guid = 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_product = supplier_purchase_order_product_link.id_product
|
||||
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
|
||||
@@ -276,6 +311,7 @@ class Supplier_Purchase_Order_Product_Link_Temp(db.Model, Store_Base):
|
||||
return f'''
|
||||
id_link: {self.id_link}
|
||||
id_order: {self.id_order}
|
||||
id_product: {self.id_product}
|
||||
id_permutation: {self.id_permutation}
|
||||
id_unit_quantity: {self.id_unit_quantity}
|
||||
quantity_ordered: {self.quantity_ordered}
|
||||
|
||||
Reference in New Issue
Block a user