Work on updating order and order line models. Some code clean up.
This commit is contained in:
@@ -10,6 +10,7 @@ from app.lib_general import log, logging
|
|||||||
from .common_field_schema import base_fields, default_num_bytes
|
from .common_field_schema import base_fields, default_num_bytes
|
||||||
|
|
||||||
|
|
||||||
|
# Updated 2022-01-20
|
||||||
class Order_Line_Base(BaseModel):
|
class Order_Line_Base(BaseModel):
|
||||||
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||||
log.debug(locals())
|
log.debug(locals())
|
||||||
@@ -77,7 +78,8 @@ class Order_Line_Base(BaseModel):
|
|||||||
name: Optional[str] # Should be the same as product_name above
|
name: Optional[str] # Should be the same as product_name above
|
||||||
quantity: int = Field(0, ge=0, lt=150)
|
quantity: int = Field(0, ge=0, lt=150)
|
||||||
amount: int = Field(0, ge=0, lt=1500000)
|
amount: int = Field(0, ge=0, lt=1500000)
|
||||||
dollar_amount: Optional[str]
|
total: int = Field(0, ge=0, lt=1500000) # Calculated with trigger
|
||||||
|
|
||||||
recurring: Optional[bool] = False
|
recurring: Optional[bool] = False
|
||||||
message: Optional[str]
|
message: Optional[str]
|
||||||
|
|
||||||
@@ -88,6 +90,9 @@ class Order_Line_Base(BaseModel):
|
|||||||
|
|
||||||
# Including convenience data
|
# Including convenience data
|
||||||
# This is only for convenience. Probably going to keep unless it causes a problem.
|
# This is only for convenience. Probably going to keep unless it causes a problem.
|
||||||
|
dollar_amount: Optional[str] # From SQL view
|
||||||
|
dollar_total: int = Optional[str] # From SQL view
|
||||||
|
|
||||||
order_status: Optional[str]
|
order_status: Optional[str]
|
||||||
order_notes: Optional[str]
|
order_notes: Optional[str]
|
||||||
order_created_on: Optional[datetime.datetime] = None
|
order_created_on: Optional[datetime.datetime] = None
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ from app.models.order_line_models_v3 import Order_Line_Base
|
|||||||
from app.models.person_models import Person_Base
|
from app.models.person_models import Person_Base
|
||||||
|
|
||||||
|
|
||||||
|
# Updated 2022-01-20
|
||||||
class Order_Base(BaseModel):
|
class Order_Base(BaseModel):
|
||||||
log.setLevel(logging.INFO)
|
log.setLevel(logging.INFO)
|
||||||
log.debug(locals())
|
log.debug(locals())
|
||||||
@@ -31,10 +32,10 @@ class Order_Base(BaseModel):
|
|||||||
person_id_random: Optional[str]
|
person_id_random: Optional[str]
|
||||||
person_id: Optional[int]
|
person_id: Optional[int]
|
||||||
|
|
||||||
total_quantity: Optional[int] = Field(0, ge=0, lt=150)
|
total_quantity: Optional[int] = Field(0, ge=0, lt=150) # Set with triggers
|
||||||
total_bill: Optional[int] = Field(0, ge=0, lt=1500000) # NOTE: This is total_amount in the order_cart
|
total_bill: Optional[int] = Field(0, ge=0, lt=1500000) # Set with triggers; matches total_amount in order_cart
|
||||||
total_paid: Optional[int] = Field(0, ge=0, lt=1500000)
|
total_paid: Optional[int] = Field(0, ge=0, lt=1500000)
|
||||||
balance: Optional[int] = Field(0, ge=-1500000, lt=1500000) # Balance needs to be calculated
|
balance: Optional[int] = Field(0, ge=-1500000, lt=1500000) # Calculated with trigger
|
||||||
status: Optional[str] # open, locked, reopened, closed, canceled, other
|
status: Optional[str] # open, locked, reopened, closed, canceled, other
|
||||||
# open = building or creating cart, payment failed and no partial payment already processed
|
# open = building or creating cart, payment failed and no partial payment already processed
|
||||||
# locked = processing payment, partial payment processed, admin lock? (no changes allowed)
|
# locked = processing payment, partial payment processed, admin lock? (no changes allowed)
|
||||||
@@ -54,6 +55,12 @@ class Order_Base(BaseModel):
|
|||||||
created_on: Optional[datetime.datetime] = None
|
created_on: Optional[datetime.datetime] = None
|
||||||
updated_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.
|
||||||
|
dollar_total_bill: Optional[str] # From SQL view
|
||||||
|
dollar_total_paid: int = Optional[str] # From SQL view
|
||||||
|
dollar_balance: int = Optional[str] # From SQL view
|
||||||
|
|
||||||
# Including other related objects
|
# Including other related objects
|
||||||
cfg: Optional[Order_Cfg_Base]
|
cfg: Optional[Order_Cfg_Base]
|
||||||
order_line_list: Optional[list[Order_Line_Base]]
|
order_line_list: Optional[list[Order_Line_Base]]
|
||||||
|
|||||||
Reference in New Issue
Block a user