diff --git a/app.py b/app.py index 6bce373..cd0134e 100644 --- a/app.py +++ b/app.py @@ -813,17 +813,23 @@ def get_purchase_receipt_detail(receipt_id): receipt_data = dict(receipt) - # 입고장 상세 라인 조회 + # 입고장 상세 라인 조회 (display_name 포함) cursor.execute(""" SELECT prl.*, h.herb_name, h.insurance_code, il.lot_id, - il.quantity_onhand as current_stock + il.quantity_onhand as current_stock, + il.display_name, + lv.form, + lv.processing, + lv.selection_state, + lv.grade FROM purchase_receipt_lines prl JOIN herb_items h ON prl.herb_item_id = h.herb_item_id LEFT JOIN inventory_lots il ON prl.line_id = il.receipt_line_id + LEFT JOIN lot_variants lv ON il.lot_id = lv.lot_id WHERE prl.receipt_id = ? ORDER BY prl.line_id """, (receipt_id,)) @@ -1402,20 +1408,26 @@ def get_available_lots(herb_item_id): if not herb: return jsonify({'success': False, 'error': '약재를 찾을 수 없습니다'}), 404 - # 가용 로트 목록 (소진되지 않은 재고) + # 가용 로트 목록 (소진되지 않은 재고) - display_name 포함 cursor.execute(""" SELECT - lot_id, - origin_country, - quantity_onhand, - unit_price_per_g, - received_date, - supplier_id - FROM inventory_lots - WHERE herb_item_id = ? - AND is_depleted = 0 - AND quantity_onhand > 0 - ORDER BY origin_country, unit_price_per_g, received_date + il.lot_id, + il.origin_country, + il.quantity_onhand, + il.unit_price_per_g, + il.received_date, + il.supplier_id, + il.display_name, + lv.form, + lv.processing, + lv.selection_state, + lv.grade + FROM inventory_lots il + LEFT JOIN lot_variants lv ON il.lot_id = lv.lot_id + WHERE il.herb_item_id = ? + AND il.is_depleted = 0 + AND il.quantity_onhand > 0 + ORDER BY il.origin_country, il.unit_price_per_g, il.received_date """, (herb_item_id,)) lots = [] @@ -1426,7 +1438,12 @@ def get_available_lots(herb_item_id): 'quantity_onhand': row[2], 'unit_price_per_g': row[3], 'received_date': row[4], - 'supplier_id': row[5] + 'supplier_id': row[5], + 'display_name': row[6], + 'form': row[7], + 'processing': row[8], + 'selection_state': row[9], + 'grade': row[10] }) # 원산지별 요약 @@ -1553,7 +1570,7 @@ def get_inventory_detail(herb_item_id): herb_data = dict(herb) - # 원산지별 재고 정보 + # 원산지별 재고 정보 (display_name 포함) cursor.execute(""" SELECT il.lot_id, @@ -1563,9 +1580,15 @@ def get_inventory_detail(herb_item_id): il.received_date, il.supplier_id, s.name as supplier_name, - il.quantity_onhand * il.unit_price_per_g as lot_value + il.quantity_onhand * il.unit_price_per_g as lot_value, + il.display_name, + lv.form, + lv.processing, + lv.selection_state, + lv.grade FROM inventory_lots il LEFT JOIN suppliers s ON il.supplier_id = s.supplier_id + LEFT JOIN lot_variants lv ON il.lot_id = lv.lot_id WHERE il.herb_item_id = ? AND il.is_depleted = 0 ORDER BY il.origin_country, il.unit_price_per_g, il.received_date """, (herb_item_id,))