Work on order related endpoints.
This commit is contained in:
@@ -11,7 +11,7 @@ from .common_field_schema import base_fields, default_num_bytes
|
||||
|
||||
|
||||
class Order_Line_Base(BaseModel):
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
id_random: Optional[str] = Field(
|
||||
@@ -29,6 +29,11 @@ class Order_Line_Base(BaseModel):
|
||||
product_id_random: str
|
||||
product_id: Optional[int]
|
||||
|
||||
account_id_random: Optional[str]
|
||||
account_id: Optional[int]
|
||||
|
||||
account_name: Optional[str]
|
||||
|
||||
product_for_type: Optional[str] # Copied from product record
|
||||
product_for_id_random: Optional[str] # Copied from product record NOPE
|
||||
product_for_id: Optional[int] # Copied from product record
|
||||
@@ -65,11 +70,14 @@ class Order_Line_Base(BaseModel):
|
||||
for_person_id: Optional[int]
|
||||
for_person_id_random: Optional[str]
|
||||
for_person_given_name: Optional[str] # Dynamic from v_order_line
|
||||
for_person_family_name: Optional[str] # Dynamic from v_order_line
|
||||
for_person_display_name: Optional[str] # Dynamic from v_order_line
|
||||
for_person_full_name: Optional[str] # Dynamic from v_order_line
|
||||
|
||||
name: Optional[str] # Should be the same as product_name above
|
||||
quantity: int = Field(0, ge=0, lt=150)
|
||||
amount: int = Field(0, ge=0, lt=1500000)
|
||||
dollar_amount: Optional[str]
|
||||
recurring: Optional[bool] = False
|
||||
message: Optional[str]
|
||||
|
||||
@@ -78,6 +86,13 @@ class Order_Line_Base(BaseModel):
|
||||
created_on: Optional[datetime.datetime] = None
|
||||
updated_on: Optional[datetime.datetime] = None
|
||||
|
||||
# Including convenience data
|
||||
# This is only for convenience. Probably going to keep unless it causes a problem.
|
||||
order_status: Optional[str]
|
||||
order_notes: Optional[str]
|
||||
order_created_on: Optional[datetime.datetime] = None
|
||||
order_updated_on: Optional[datetime.datetime] = None
|
||||
|
||||
# Including other related objects
|
||||
# product: Optional[Union[Product_Base, None]] # Future use?
|
||||
# for_person: Optional[Union[Person_Base, None]] # Future use?
|
||||
@@ -157,6 +172,15 @@ class Order_Line_Base(BaseModel):
|
||||
# return redis_lookup_id_random(record_id_random=values['curr_product_for_id_random'], table_name=values['curr_product_for_type'])
|
||||
# return None
|
||||
|
||||
@validator('account_id', always=True)
|
||||
def account_id_lookup(cls, v, values, **kwargs):
|
||||
log.setLevel(logging.WARNING)
|
||||
log.debug(locals())
|
||||
|
||||
if values.get('account_id_random', None):
|
||||
return redis_lookup_id_random(record_id_random=values['account_id_random'], table_name='account')
|
||||
return None
|
||||
|
||||
class Config:
|
||||
underscore_attrs_are_private = True
|
||||
allow_population_by_field_name = True
|
||||
@@ -164,7 +188,7 @@ class Order_Line_Base(BaseModel):
|
||||
|
||||
|
||||
class Order_Line_DB_Base(BaseModel):
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
id_random: Optional[str] = Field(
|
||||
@@ -209,4 +233,67 @@ class Order_Line_DB_Base(BaseModel):
|
||||
underscore_attrs_are_private = True
|
||||
allow_population_by_field_name = True
|
||||
|
||||
|
||||
class Order_Line_Full_Detail_Base(Order_Line_Base):
|
||||
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
person_id: Optional[int]
|
||||
person_id_random: Optional[str]
|
||||
person_given_name: Optional[str]
|
||||
person_family_name: Optional[str]
|
||||
person_display_name: Optional[str]
|
||||
person_full_name: Optional[str]
|
||||
|
||||
person_contact_id: Optional[int]
|
||||
person_contact_id_random: Optional[str]
|
||||
|
||||
person_contact_for_type: Optional[str]
|
||||
person_contact_for_id: Optional[int]
|
||||
|
||||
person_contact_name: Optional[str]
|
||||
person_contact_email: Optional[str]
|
||||
person_contact_cc_email: Optional[str]
|
||||
|
||||
person_contact_phone_mobile: Optional[str]
|
||||
person_contact_phone_home: Optional[str]
|
||||
person_contact_phone_office: Optional[str]
|
||||
person_contact_phone_land: Optional[str]
|
||||
person_contact_phone_fax: Optional[str]
|
||||
person_contact_phone_other: Optional[str]
|
||||
|
||||
person_contact_address_id: Optional[int]
|
||||
person_contact_address_id_random: Optional[str]
|
||||
|
||||
person_contact_address_for_type: Optional[str]
|
||||
person_contact_address_for_id: Optional[int]
|
||||
|
||||
person_contact_address_name: Optional[str]
|
||||
person_contact_address_organization_name: Optional[str]
|
||||
person_contact_address_line_1: Optional[str]
|
||||
person_contact_address_line_2: Optional[str]
|
||||
person_contact_address_line_3: Optional[str]
|
||||
person_contact_address_city: Optional[str]
|
||||
person_contact_address_country_subdivision_code: Optional[str]
|
||||
person_contact_address_country_subdivision_name: Optional[str] # From country subdivision lookup table
|
||||
person_contact_address_state_province: Optional[str] # Avoid using
|
||||
person_contact_address_postal_code: Optional[str]
|
||||
person_contact_address_country_alpha_2_code: Optional[str]
|
||||
person_contact_address_country_name: Optional[str] # From country lookup table
|
||||
person_contact_address_country: Optional[str] # Avoid using
|
||||
|
||||
person_contact_address_lu_time_zone_id: Optional[str]
|
||||
|
||||
# Including convenience data
|
||||
# This is only for convenience. Probably going to keep unless it causes a problem.
|
||||
person_email: Optional[str]
|
||||
person_cc_email: Optional[str]
|
||||
# Maybe add timezone in the future?
|
||||
|
||||
class Config:
|
||||
underscore_attrs_are_private = True
|
||||
allow_population_by_field_name = True
|
||||
|
||||
|
||||
|
||||
Order_Line_Base.update_forward_refs()
|
||||
|
||||
@@ -15,7 +15,7 @@ from app.models.user_models import User_Base
|
||||
|
||||
|
||||
class Order_Base(BaseModel):
|
||||
log.setLevel(logging.WARNING)
|
||||
log.setLevel(logging.INFO)
|
||||
log.debug(locals())
|
||||
|
||||
id_random: Optional[str] = Field(
|
||||
@@ -118,7 +118,7 @@ class Order_Base(BaseModel):
|
||||
|
||||
|
||||
class Order_DB_Base(BaseModel):
|
||||
log.setLevel(logging.WARNING)
|
||||
log.setLevel(logging.INFO)
|
||||
log.debug(locals())
|
||||
|
||||
account_id_random: Optional[str]
|
||||
|
||||
Reference in New Issue
Block a user