Work on redoing orders and related. A lot of code clean up. I think it works pretty well.

This commit is contained in:
Scott Idem
2022-01-19 18:51:24 -05:00
parent 9dbbc26d06
commit d1d3b30ece
8 changed files with 281 additions and 102 deletions

View File

@@ -196,6 +196,13 @@ def sql_update(
fields_string.append('`'+str(key) + '` = :' + str(key))
sql_set = ', '.join(fields_string)
log.debug(sql_set)
if len(sql_set) < 4:
# NOTE: Returning None instead of False since technically the SQL query did not fail. Just that nothing was updated related to that record. I have been returning False if there is a SQL query problem. STI 2022-01-19
# NOTE: A better check might be specifically for 'id' and no other dict values.
log.warning('The SQL SET is unexpectedly short and may not have data. Returning None')
return None
if record_id:
log.info(f'Update record with ID: {record_id}')
@@ -693,7 +700,7 @@ def sql_delete(
sql: str|None = None,
data: dict|None = None
):
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
if table_name and (record_id or record_id_random) and not (field_name or field_value or sql or data):
@@ -747,7 +754,6 @@ def sql_delete(
WHERE {sql_where_string}
"""
)
log.debug(sql)
elif sql and not (table_name or record_id or record_id_random or field_name or field_value or data):
# Delete records based on the SQL statement given
log.info('Delete records based on the SQL statement given')
@@ -763,6 +769,8 @@ def sql_delete(
log.debug(sql)
# return False
try:
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
if data:

View File

@@ -7,7 +7,7 @@ from pydantic import BaseModel, EmailStr, Field, PrivateAttr, ValidationError, v
from app.db_sql import redis_lookup_id_random, sql_delete, sql_enable_part, sql_insert, sql_limit_offset_part, sql_select, sql_update
from app.lib_general import log, logging, logger_reset
from app.models.common_field_schema import default_num_bytes
from app.models.order_line_models import Order_Line_Base, Order_Line_Full_Detail_Base
@@ -34,7 +34,7 @@ def create_order_obj_line(
order_obj = order_line_dict_obj
# order_obj.order_id = order_id
order_line_dict = order_obj.dict(by_alias=False, exclude_defaults=False, exclude_unset=True, exclude={'product', 'created_on', 'updated_on'})
order_line_dict = order_obj.dict(by_alias=False, exclude_defaults=False, exclude_unset=True, exclude={'product', 'remove_line', 'created_on', 'updated_on'})
log.debug(order_obj)
# ### SECTION ### Process data
@@ -95,6 +95,9 @@ def update_order_obj_line(
log.debug(locals())
# ### SECTION ### Secondary data validation
if order_line_id := redis_lookup_id_random(record_id_random=order_line_id, table_name='order_line'): pass
else: return False
log.info('Create dictionary or Pydantic object')
log.debug(type(order_line_dict_obj))
if isinstance(order_line_dict_obj, dict):
@@ -108,12 +111,12 @@ def update_order_obj_line(
order_line_obj = order_line_dict_obj
# order_line_obj.order_line_id = order_line_id
order_line_dict = order_line_obj.dict(by_alias=False, exclude_defaults=False, exclude_unset=True, exclude={'product', 'updated_on', 'updated_on'})
order_line_dict = order_line_obj.dict(by_alias=False, exclude_defaults=False, exclude_unset=True, exclude={'product', 'remove_line', 'updated_on', 'updated_on'})
log.debug(order_line_obj)
# ### SECTION ### Process data
order_line_obj.order_line_id = order_line_id # Is this needed?
order_line_dict['order_line_id'] = order_line_id
order_line_obj.id = order_line_id # Is this needed?
order_line_dict['id'] = order_line_id
if order_line_dict_up_result := sql_update(
data = order_line_dict,
@@ -131,68 +134,68 @@ def update_order_obj_line(
# ### END ### API Order Methods ### update_order_obj_line() ###
# ### BEGIN ### API Order Line Methods ### update_order_obj_line() ###
@logger_reset
def update_order_obj_line(
order_line_id: int|str, # Ideally the int ID should be passed. This allows for updating of the id_random value.
order_obj_line_obj_up: Order_Line_Base,
create_sub_obj: bool = False,
) -> bool:
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
# # ### BEGIN ### API Order Line Methods ### update_order_obj_line() ###
# @logger_reset
# def update_order_obj_line(
# order_line_id: int|str, # Ideally the int ID should be passed. This allows for updating of the id_random value.
# order_obj_line_obj_up: Order_Line_Base,
# create_sub_obj: bool = False,
# ) -> bool:
# log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
# log.debug(locals())
if order_line_id := redis_lookup_id_random(record_id_random=order_line_id, table_name='order_line'): pass
else: return False
# if order_line_id := redis_lookup_id_random(record_id_random=order_line_id, table_name='order_line'): pass
# else: return False
order_obj_line_obj_up.id = order_line_id
# order_obj_line_obj_up.id = order_line_id
log.debug(order_obj_line_obj_up)
# log.debug(order_obj_line_obj_up.dict(by_alias=True, exclude_unset=True))
log.debug(order_obj_line_obj_up.dict(by_alias=False, exclude_unset=True))
# log.debug(order_obj_line_obj_up.dict(by_alias=False, exclude_unset=False))
# log.debug(order_obj_line_obj_up)
# # log.debug(order_obj_line_obj_up.dict(by_alias=True, exclude_unset=True))
# log.debug(order_obj_line_obj_up.dict(by_alias=False, exclude_unset=True))
# # log.debug(order_obj_line_obj_up.dict(by_alias=False, exclude_unset=False))
#order_line_dict_up = order_obj_line_obj_up.dict(by_alias=False, exclude_unset=True)
# #order_line_dict_up = order_obj_line_obj_up.dict(by_alias=False, exclude_unset=True)
# if order_obj_line_obj_up.person_id and order_obj_line_obj_up.person:
# person_id = order_obj_line_obj_up.person_id
# person_obj_up = order_obj_line_obj_up.person
# log.debug(person_id)
# log.debug(person_obj_up)
# if person_obj_up_result := update_person_obj(
# person_id = person_id,
# person_obj_up = person_obj_up,
# create_sub_obj = create_sub_obj,
# ):
# log.debug(person_obj_up_result)
# else:
# log.debug(person_obj_up_result)
# return False
# # if order_obj_line_obj_up.person_id and order_obj_line_obj_up.person:
# # person_id = order_obj_line_obj_up.person_id
# # person_obj_up = order_obj_line_obj_up.person
# # log.debug(person_id)
# # log.debug(person_obj_up)
# # if person_obj_up_result := update_person_obj(
# # person_id = person_id,
# # person_obj_up = person_obj_up,
# # create_sub_obj = create_sub_obj,
# # ):
# # log.debug(person_obj_up_result)
# # else:
# # log.debug(person_obj_up_result)
# # return False
# if order_obj_line_obj_up.user_id and order_obj_line_obj_up.user:
# user_id = order_obj_line_obj_up.user_id
# user_obj_up = order_obj_line_obj_up.user
# log.debug(user_id)
# log.debug(user_obj_up)
# if user_obj_up_result := update_user_obj(
# user_id = user_id,
# user_dict_obj = user_obj_up,
# create_sub_obj = create_sub_obj,
# ):
# log.debug(user_obj_up_result)
# else:
# log.debug(user_obj_up_result)
# return False
# # if order_obj_line_obj_up.user_id and order_obj_line_obj_up.user:
# # user_id = order_obj_line_obj_up.user_id
# # user_obj_up = order_obj_line_obj_up.user
# # log.debug(user_id)
# # log.debug(user_obj_up)
# # if user_obj_up_result := update_user_obj(
# # user_id = user_id,
# # user_dict_obj = user_obj_up,
# # create_sub_obj = create_sub_obj,
# # ):
# # log.debug(user_obj_up_result)
# # else:
# # log.debug(user_obj_up_result)
# # return False
order_line_dict_up = order_obj_line_obj_up.dict(by_alias=False, exclude_unset=True, exclude={'user'})
log.debug(order_line_dict_up)
# order_line_dict_up = order_obj_line_obj_up.dict(by_alias=False, exclude_unset=True, exclude={'user'})
# log.debug(order_line_dict_up)
if order_obj_line_obj_up_result := sql_update(data=order_line_dict_up, table_name='order_line', rm_id_random=True):
log.debug(order_obj_line_obj_up_result)
return True
else:
log.debug(order_obj_line_obj_up_result)
return False
# ### END ### API Order Line Methods ### update_order_obj_line() ###
# if order_obj_line_obj_up_result := sql_update(data=order_line_dict_up, table_name='order_line', rm_id_random=True):
# log.debug(order_obj_line_obj_up_result)
# return True
# else:
# log.debug(order_obj_line_obj_up_result)
# return False
# # ### END ### API Order Line Methods ### update_order_obj_line() ###
# ### BEGIN ### API Order Line Methods ### load_order_obj_line() ###
@@ -265,14 +268,14 @@ def get_order_line_rec_list(
for_obj_id: str,
from_datetime: datetime.datetime = None, # For the order, not order_line
to_datetime: datetime.datetime = None, # For the order, not order_line
prod_type = 'all', # all, cont_edu_cert, event, fundraising, membership, etc
status: str = 'closed', # started, in progress, complete, all
product_for_type: str = 'all', # all, cont_edu_cert, event, fundraising, membership, etc
status: str = 'all', # started, in progress, complete, all
full_detail: bool = False,
# enabled: str = 'enabled', # enabled, disabled, all
limit: int = 500,
offset: int = 0,
) -> list|bool:
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
if for_obj_id := redis_lookup_id_random(record_id_random=for_obj_id, table_name=for_obj_type): pass
@@ -284,21 +287,21 @@ def get_order_line_rec_list(
sql_obj_type_id = f'`order_line`.{for_obj_type}_id = :{for_obj_type}_id'
allowed_prod_type_li = ['cont_edu_cert', 'event', 'fundraising', 'membership', 'other'] # TEMPORARY list...
sql_prod_type = ''
if prod_type in allowed_prod_type_li:
if prod_type == 'closed' or prod_type == 'complete':
data['prod_type'] = ['closed', 'complete']
sql_prod_type = f'AND `order_line`.product_type IN :prod_type'
elif prod_type == 'locked' or prod_type == 'in progress':
data['prod_type'] = ['locked', 'in progress']
sql_prod_type = f'AND `order_line`.product_type IN :prod_type'
sql_product_for_type = ''
if product_for_type in allowed_prod_type_li:
if product_for_type == 'closed' or product_for_type == 'complete':
data['product_for_type'] = ['closed', 'complete']
sql_product_for_type = f'AND `order_line`.product_for_type IN :product_for_type'
elif product_for_type == 'locked' or product_for_type == 'in progress':
data['product_for_type'] = ['locked', 'in progress']
sql_product_for_type = f'AND `order_line`.product_for_type IN :product_for_type'
else:
data['prod_type'] = prod_type
sql_prod_type = f'AND `order_line`.product_type = :prod_type'
elif prod_type == 'all':
sql_prod_type = f'AND `order_line`.product_type IS NOT NULL'
data['product_for_type'] = product_for_type
sql_product_for_type = f'AND `order_line`.product_for_type = :product_for_type'
elif product_for_type == 'all':
sql_product_for_type = f'AND (`order_line`.product_for_type IS NULL OR `order_line`.product_for_type IS NOT NULL)'
else:
log.warning('The prod_type value passed is not allowed. Returning None')
log.warning('The product_for_type value passed is not allowed. Returning None')
return False
allowed_status_li = ['open', 'locked', 'in progress', 'reopened', 'closed', 'complete', 'canceled', 'other'] # TEMPORARY list...
@@ -343,7 +346,7 @@ def get_order_line_rec_list(
FROM `v_order_line` AS `order_line`
WHERE
{sql_obj_type_id}
{sql_prod_type}
{sql_product_for_type}
{sql_status}
{sql_from_to_datetime}
ORDER BY order_line.name, `order_line`.created_on DESC, `order_line`.updated_on DESC
@@ -355,7 +358,7 @@ def get_order_line_rec_list(
FROM `v_order_line_full_detail` AS `order_line`
WHERE
{sql_obj_type_id}
{sql_prod_type}
{sql_product_for_type}
{sql_status}
{sql_from_to_datetime}
ORDER BY `order_line`.created_on DESC, `order_line`.updated_on DESC
@@ -365,9 +368,141 @@ def get_order_line_rec_list(
if order_line_rec_li_result := sql_select(data=data, sql=sql, as_list=True):
order_line_rec_li = order_line_rec_li_result
else:
order_line_rec_li = []
else: # [] or False
order_line_rec_li = order_line_rec_li_result
log.debug(order_line_rec_li_result)
return order_line_rec_li
# ### END ### API Order Line Methods ### get_order_line_rec_list() ###
# ### BEGIN ### API Order Line Methods ### check_order_obj_line_list() ###
@logger_reset
def check_order_obj_line_list(
order_id: int|str,
product_id: int|str = None,
# product_for_id: int|str = 'all',
product_for_type: str = 'all', # all, cont_edu_cert, event, fundraising, membership, etc
for_person_id: int|str = None,
limit: int = 50,
offset: int = 0,
) -> list|bool:
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
if order_id := redis_lookup_id_random(record_id_random=order_id, table_name='order'): pass
else: return False
if product_id := redis_lookup_id_random(record_id_random=product_id, table_name='product'): pass
elif product_id is None: pass
else: return False
if for_person_id := redis_lookup_id_random(record_id_random=for_person_id, table_name='person'): pass
elif for_person_id is None: pass
else: return False
data = {}
data['order_id'] = order_id
sql_order_id = f'`order_line`.order_id = :order_id'
if product_id:
data['product_id'] = product_id
sql_product_id = f'AND `order_line`.product_id = :product_id'
allowed_prod_type_li = ['cont_edu_cert', 'event', 'fundraising', 'membership', 'other'] # TEMPORARY list...
sql_product_for_type = ''
if product_for_type in allowed_prod_type_li:
if product_for_type == 'closed' or product_for_type == 'complete':
data['product_for_type'] = ['closed', 'complete']
sql_product_for_type = f'AND `order_line`.product_for_type IN :prod_type'
elif product_for_type == 'locked' or product_for_type == 'in progress':
data['product_for_type'] = ['locked', 'in progress']
sql_product_for_type = f'AND `order_line`.product_for_type IN :prod_type'
else:
data['product_for_type'] = prod_type
sql_product_for_type = f'AND `order_line`.product_for_type = :prod_type'
elif product_for_type == 'all':
sql_product_for_type = f'AND (`order_line`.product_for_type IS NULL OR `order_line`.product_for_type IS NOT NULL)'
else:
log.warning('The product_for_type value passed is not allowed. Returning None')
return False
sql_for_person_id = ''
if for_person_id:
data['for_person_id'] = for_person_id
sql_for_person_id = f'AND `order_line`.for_person_id = :for_person_id'
# sql_enabled, data['enable'] = sql_enable_part(table_name='order', enabled=enabled) # Reasonably safe return str and bool
sql_limit = sql_limit_offset_part(limit=limit, offset=offset) # Reasonably safe return str
log.debug(data)
sql = f"""
SELECT `order_line`.id AS 'order_line_id', `order_line`.id_random AS 'order_line_id_random'
FROM `order_line` AS `order_line`
WHERE
{sql_order_id}
{sql_product_id}
{sql_product_for_type}
{sql_for_person_id}
ORDER BY order_line.name, `order_line`.created_on DESC, `order_line`.updated_on DESC
{sql_limit};
"""
log.debug(sql)
if order_line_rec_li_result := sql_select(data=data, sql=sql, as_list=True):
order_line_rec_li = order_line_rec_li_result
else: # [] or False
order_line_rec_li = order_line_rec_li_result
log.debug(order_line_rec_li_result)
return order_line_rec_li
# ### END ### API Order Line Methods ### check_order_obj_line_list() ###
# ### BEGIN ### API Order Line Methods ### remove_order_obj_line() ###
# Updated 2022-01-19
def remove_order_obj_line(
order_id: int,
order_line_id: int,
product_id: int,
) -> bool|None:
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
# ### SECTION ### Secondary data validation
if order_id := redis_lookup_id_random(record_id_random=order_id, table_name='order'): pass
elif order_id is None: pass
else: return False
if order_line_id := redis_lookup_id_random(record_id_random=order_line_id, table_name='order_line'): pass
elif order_line_id is None: pass
else: return False
if product_id := redis_lookup_id_random(record_id_random=product_id, table_name='product'): pass
elif product_id is None: pass
else: return False
if order_line_id:
log.info(f'Deleting Order Line ID: {order_line_id}')
if order_line_del_result := sql_delete(
table_name = 'order_line',
record_id = order_line_id
):
log.debug(order_line_del_result)
return True
else: return False
elif order_id and product_id:
log.info(f'Deleting Order Line with Order ID: {order_id} and Product ID {product_id}')
data = { 'order_id': order_id, 'product_id': product_id}
if order_line_del_result := sql_delete(
table_name = 'order_line',
data = data,
):
log.debug(order_line_del_result)
return True
else: return False
# ### END ### API Order Line Methods ### remove_order_obj_line() ###

View File

@@ -4,18 +4,17 @@ import datetime
from typing import Dict, List, Optional, Set, Union
from pydantic import BaseModel, EmailStr, Field, PrivateAttr, ValidationError, validator
from app.db_sql import redis_lookup_id_random, sql_delete, sql_enable_part, sql_insert_or_update, sql_limit_offset_part, sql_select
from app.db_sql import redis_lookup_id_random, sql_delete, sql_enable_part, sql_insert, sql_insert_or_update, sql_limit_offset_part, sql_select, sql_update
from app.lib_general import log, logging, logger_reset
from app.methods.order_cfg_methods import load_order_cfg_obj
from app.methods.order_line_methods import create_order_obj_line, get_order_line_rec_list, load_order_obj_line, update_order_obj_line
from app.methods.order_line_methods import check_order_obj_line_list, create_order_obj_line, get_order_line_rec_list, load_order_obj_line, remove_order_obj_line, update_order_obj_line
# from app.methods.person_methods import load_person_obj
# from app.methods.user_methods import load_user_obj
from app.models.common_field_schema import default_num_bytes
from app.models.order_models import Order_Base
from app.models.order_line_models import Order_Line_Base, Order_Line_DB_Base # This should go away later.
# from app.models.person_models import Person_Base
# from app.models.user_models import User_Base
# ### BEGIN ### API Order Methods ### create_order_obj() ###
@@ -42,7 +41,7 @@ def create_order_obj(
order_obj = order_dict_obj
# order_obj.account_id = account_id
order_dict = order_obj.dict(by_alias=False, exclude_defaults=False, exclude_unset=True, exclude={'cfg', 'person', 'user', 'created_on', 'updated_on'})
order_dict = order_obj.dict(by_alias=False, exclude_defaults=False, exclude_unset=True, exclude={'cfg', 'order_line_list', 'person', 'user', 'created_on', 'updated_on'})
log.debug(order_obj)
# ### SECTION ### Process data
@@ -76,7 +75,11 @@ def create_order_obj(
if order_obj.order_line_list:
log.info('Looping through Order Line list')
for order_line in order_obj.order_line_list:
if order_line.id:
# NOTE: Should there be a check here using check_order_obj_line_list()???
# In theory there should not already be any order_line records associated with the new order_id.
order_line_id = order_line.id
if order_line_id:
log.info('Updating Order Line')
if update_order_obj_result := update_order_obj_line(
order_line_id = order_line_id,
@@ -102,7 +105,7 @@ def create_order_obj(
def update_order_obj(
order_id: int,
order_dict_obj: Order_Base,
person_id: int|None = None,
# person_id: int|None = None,
) -> int|bool:
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
@@ -121,24 +124,25 @@ def update_order_obj(
order_obj = order_dict_obj
# order_obj.account_id = account_id
order_dict = order_obj.dict(by_alias=False, exclude_defaults=False, exclude_unset=True, exclude={'cfg', 'person', 'user', 'created_on', 'updated_on'})
order_dict = order_obj.dict(by_alias=False, exclude_defaults=False, exclude_unset=True, exclude={'cfg', 'order_line_list', 'person', 'user', 'created_on', 'updated_on'})
log.debug(order_obj)
# ### SECTION ### Process data
order_obj.id = order_id # Is this needed?
order_dict['id'] = order_id
# Look for a person_id in the order_obj
if person_id:
order_obj.person_id = person_id # Is this needed?
order_dict['person_id'] = person_id
elif person_id := order_obj.person.id: pass
# # Look for a person_id in the order_obj
# if person_id:
# order_obj.person_id = person_id # Is this needed?
# order_dict['person_id'] = person_id
# elif person_id := order_obj.person.id: pass
if order_dict_up_result := sql_update(
data = order_dict,
table_name = 'order',
rm_id_random = True,
): pass
elif order_dict_up_result is None: pass # More than likely no order specific data was passed. There might be order lines though.
else:
log.warning(f'Person not updated.')
log.debug(order_dict_up_result)
@@ -149,7 +153,35 @@ def update_order_obj(
if order_obj.order_line_list:
log.info('Looping through Order Line list')
for order_line in order_obj.order_line_list:
if order_line.id:
order_line_id = order_line.id
product_id = order_line.product_id
if order_line.remove_line:
remove_order_obj_line(
order_id = order_id,
order_line_id = order_line_id,
product_id = product_id,
)
continue # Do not need to check for anything else on this loop
order_line_id = order_line.id
product_id = order_line.product_id
if for_person_id := order_line.for_person_id: pass
log.info(f'Checking for matching order lines. Order ID: {order_id}; Product ID: {product_id}; For Person ID: {for_person_id}')
order_line_id_found = None
if check_order_obj_line_list_result := check_order_obj_line_list(
order_id = order_id,
product_id = product_id,
for_person_id = for_person_id,
):
for order_line_rec in check_order_obj_line_list_result:
order_line_id_found = order_line_rec.get('order_line_id')
if order_line_id == order_line_id_found: pass
elif order_line_id := order_line_id_found: pass
if order_line_id:
log.info('Updating Order Line')
if update_order_obj_result := update_order_obj_line(
order_line_id = order_line_id,
@@ -222,6 +254,8 @@ def load_order_obj(
if order_line_rec_list_result := get_order_line_rec_list(
for_obj_type = 'order',
for_obj_id = order_id,
# product_for_type = 'all',
# status = 'all',
limit = limit,
):
order_line_result_list = []

View File

@@ -48,7 +48,7 @@ class Order_Line_Base(BaseModel):
product_unit_price: Optional[int] # Copied from product record
product_recurring: Optional[bool] # Copied from product record
curr_product_id_random: str # Should be the same as product_id_random above
curr_product_id_random: Optional[str] # Should be the same as product_id_random above
curr_product_id: Optional[int] # Should be the same as product_id above
# NOTE: This is reversed with for_id_random

View File

@@ -26,7 +26,7 @@ class Order_Line_Base(BaseModel):
order_id_random: Optional[str]
order_id: Optional[int]
product_id_random: str
product_id_random: str = None
product_id: Optional[int]
account_id_random: Optional[str]
@@ -48,7 +48,7 @@ class Order_Line_Base(BaseModel):
product_unit_price: Optional[int] # Copied from product record
product_recurring: Optional[bool] # Copied from product record
curr_product_id_random: str # Should be the same as product_id_random above
curr_product_id_random: Optional[str] # Should be the same as product_id_random above
curr_product_id: Optional[int] # Should be the same as product_id above
# NOTE: This is reversed with for_id_random
@@ -93,6 +93,8 @@ class Order_Line_Base(BaseModel):
order_created_on: Optional[datetime.datetime] = None
order_updated_on: Optional[datetime.datetime] = None
remove_line: bool = False
# Including other related objects
# product: Optional[Union[Product_Base, None]] # Future use?
# for_person: Optional[Union[Person_Base, None]] # Future use?

View File

@@ -9,7 +9,7 @@ from app.lib_general import log, logging
from app.models.common_field_schema import base_fields, default_num_bytes
from app.models.order_cfg_models import Order_Cfg_Base
from app.models.order_line_models import Order_Line_Base
from app.models.order_line_models_v3 import Order_Line_Base
from app.models.person_models import Person_Base

View File

@@ -51,7 +51,7 @@ async def get_obj_id_order_line_list(
for_obj_id = obj_id,
from_datetime = from_datetime,
to_datetime = to_datetime,
prod_type = prod_type,
product_for_type = prod_type,
status = status,
full_detail = full_detail,
# enabled = enabled,

View File

@@ -95,7 +95,7 @@ async def patch_order_obj(
commons: Common_Route_Params = Depends(common_route_params),
):
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
# ### SECTION ### Secondary data validation
@@ -424,7 +424,7 @@ async def get_order_obj(
# model_as_dict = model_as_dict,
):
log.debug(load_order_obj_result)
order_dict = load_order_obj_result.dict(by_alias=by_alias, exclude_unset=False) # NOTE NOTE NOTE NOTE exclude_unset is forced to False for now. Will return more fields than is ideal. Need to create another Order_Line_Base. Probably Order_Line_OUT_Base
order_dict = load_order_obj_result.dict(by_alias=commons.by_alias, exclude_unset=False) # NOTE NOTE NOTE NOTE exclude_unset is forced to False for now. Will return more fields than is ideal. Need to create another Order_Line_Base. Probably Order_Line_OUT_Base
log.info('Loading successful. Returning result')
return mk_resp(data=order_dict, response=commons.response)
elif isinstance(load_order_obj_result, list) or load_order_obj_result is None: # Empty list or None