提交
This commit is contained in:
1 parent
012a2ad68e
commit
5fe53c5481
4775 files changed
+2190111
-40277
No files matched your search
@@ -28,6 +28,7 @@ from app.services.db.mappers import (
|
||||
EMPTY_INVENTORY_DATE,
|
||||
inventory_to_read,
|
||||
is_empty_inventory_date,
|
||||
load_user_display_name_map,
|
||||
parse_date_str,
|
||||
plan_to_read,
|
||||
weighing_to_read,
|
||||
@@ -256,12 +257,14 @@ def list_inventory(
|
||||
weighing_map[weighing.inbound_outbound_id] = weighing
|
||||
|
||||
result_list: list[InboundOutboundRead] = []
|
||||
user_name_map = load_user_display_name_map(db, [inv.create_by for inv in inventories])
|
||||
for inventory in inventories:
|
||||
try:
|
||||
result_list.append(
|
||||
inventory_to_read(
|
||||
inventory,
|
||||
weighing=weighing_map.get(inventory.id),
|
||||
user_name_map=user_name_map,
|
||||
)
|
||||
)
|
||||
except Exception:
|
||||
@@ -310,7 +313,7 @@ def create_inventory(
|
||||
db.add(row)
|
||||
db.commit()
|
||||
db.refresh(row)
|
||||
return inventory_to_read(row)
|
||||
return inventory_to_read(row, db=db)
|
||||
|
||||
|
||||
@router.post(
|
||||
@@ -365,7 +368,7 @@ def create_link_for_plan(
|
||||
db.add(row)
|
||||
db.commit()
|
||||
db.refresh(row)
|
||||
return inventory_to_read(row)
|
||||
return inventory_to_read(row, db=db)
|
||||
|
||||
|
||||
@router.get("/{id}/site-url", response_model=InventorySiteUrlRead)
|
||||
@@ -398,7 +401,7 @@ def get_inventory(
|
||||
.order_by(DbWeighingSlip.id.asc())
|
||||
.first()
|
||||
)
|
||||
return inventory_to_read(row, weighing=weighing)
|
||||
return inventory_to_read(row, weighing=weighing, db=db)
|
||||
|
||||
|
||||
@router.patch("/{id}", response_model=InboundOutboundRead)
|
||||
@@ -416,7 +419,7 @@ def update_inventory(
|
||||
_maybe_promote_third_party_status(row)
|
||||
db.commit()
|
||||
db.refresh(row)
|
||||
return inventory_to_read(row)
|
||||
return inventory_to_read(row, db=db)
|
||||
|
||||
|
||||
@router.delete("/{id}", status_code=status.HTTP_204_NO_CONTENT)
|
||||
@@ -475,6 +478,6 @@ def get_inventory_related(
|
||||
)
|
||||
|
||||
return InventoryRelatedData(
|
||||
plan=plan_to_read(plan) if plan else None,
|
||||
weighing=weighing_to_read(weighing) if weighing else None,
|
||||
plan=plan_to_read(plan, db=db) if plan else None,
|
||||
weighing=weighing_to_read(weighing, db=db) if weighing else None,
|
||||
)
|
||||
Reference in new issue
Block a user