open box bug

This commit is contained in:
zman 2025-02-10 20:35:26 -05:00
parent c896a6ea0f
commit c7686fb239
4 changed files with 12 additions and 14 deletions

View File

@ -243,7 +243,7 @@ class File(Base):
filepath = Column(String) # backup location
filesize_kb = Column(Float)
status = Column(String)
box_id = Column(String, ForeignKey("boxes.product_id"), nullable=True)
box_id = Column(String, nullable=True)
date_created = Column(DateTime, default=datetime.now)
date_modified = Column(DateTime, default=datetime.now, onupdate=datetime.now)

View File

@ -57,7 +57,7 @@ class CreateOpenBoxRequest(BaseModel):
product_id: str = Field(..., title="Product ID")
file_ids: list[str] = Field(None, title="File IDs")
num_cards_actual: Optional[int] = Field(None, title="Number of cards actual")
date_opened: Optional [str] = Field(None, title="Date Opened")
date_opened: Optional[str] = Field(None, title="Date Opened")
# RESPONSE
class CreateOpenBoxResponse(BaseModel):

View File

@ -150,6 +150,7 @@ class BoxService:
date_opened=datetime.strptime(box_data.date_opened, "%Y-%m-%d") if box_data.date_opened else datetime.now()
)
self.db.add(open_box)
self.db.flush()
staged_product_data = self.get_staged_product_data(box_data.file_ids)
product_data = self.aggregate_staged_product_data(staged_product_data)

View File

@ -11,15 +11,12 @@ curl -X POST http://192.168.1.41:8000/api/boxes \
-F "sku=195166231631" \
-F "num_cards_expected=540"
curl -X POST http://192.168.1.41:8000/api/boxes/588dddad-0661-4541-a16c-beba1c564b4f/open \
-F "product_id=588dddad-0661-4541-a16c-beba1c564b4f" \
-F "file_ids=b06c8808-d024-4bb4-8b77-89d4f8b92938,8349456c-d588-4c50-bfd4-f5895d3b4a43,33fee9cf-790a-4f50-91b9-dfdf1adc75c7,12f848c7-80b9-4ce2-8be8-1f36e714bd6f,f5b6513c-97e3-423c-9f4d-73f058529e4f,995249ac-97df-40be-a779-3acca32eb186" \
-F "date_opened=2025-02-10"
b06c8808-d024-4bb4-8b77-89d4f8b92938
8349456c-d588-4c50-bfd4-f5895d3b4a43
33fee9cf-790a-4f50-91b9-dfdf1adc75c7
12f848c7-80b9-4ce2-8be8-1f36e714bd6f
f5b6513c-97e3-423c-9f4d-73f058529e4f
995249ac-97df-40be-a779-3acca32eb186
curl -X POST "http://192.168.1.41:8000/api/boxes/588dddad-0661-4541-a16c-beba1c564b4f/open" \
-F "product_id=588dddad-0661-4541-a16c-beba1c564b4f" \
-F "file_ids=b06c8808-d024-4bb4-8b77-89d4f8b92938" \
-F "file_ids=8349456c-d588-4c50-bfd4-f5895d3b4a43" \
-F "file_ids=33fee9cf-790a-4f50-91b9-dfdf1adc75c7" \
-F "file_ids=12f848c7-80b9-4ce2-8be8-1f36e714bd6f" \
-F "file_ids=f5b6513c-97e3-423c-9f4d-73f058529e4f" \
-F "file_ids=995249ac-97df-40be-a779-3acca32eb186" \
-F "date_opened=2025-02-10"