fix: 품목 바코드 조회 개선
- CD_GOODS.Barcode가 없으면 CD_ITEM_UNIT_MEMBER에서 조회 - 중복 제거 로직 추가 (drug_code 기준)
This commit is contained in:
parent
0e954ac749
commit
007b37e6c6
@ -5070,7 +5070,7 @@ def api_admin_pos_live_detail(order_no):
|
|||||||
mssql_conn = mssql_engine.raw_connection()
|
mssql_conn = mssql_engine.raw_connection()
|
||||||
cursor = mssql_conn.cursor()
|
cursor = mssql_conn.cursor()
|
||||||
|
|
||||||
# 품목 상세 조회 (바코드 포함)
|
# 품목 상세 조회 (바코드 포함 - CD_GOODS 또는 CD_ITEM_UNIT_MEMBER에서)
|
||||||
cursor.execute("""
|
cursor.execute("""
|
||||||
SELECT
|
SELECT
|
||||||
S.DrugCode AS drug_code,
|
S.DrugCode AS drug_code,
|
||||||
@ -5078,7 +5078,9 @@ def api_admin_pos_live_detail(order_no):
|
|||||||
S.SL_NM_item AS quantity,
|
S.SL_NM_item AS quantity,
|
||||||
S.SL_NM_cost_a AS unit_price,
|
S.SL_NM_cost_a AS unit_price,
|
||||||
S.SL_TOTAL_PRICE AS total_price,
|
S.SL_TOTAL_PRICE AS total_price,
|
||||||
G.Barcode AS barcode
|
COALESCE(NULLIF(G.Barcode, ''),
|
||||||
|
(SELECT TOP 1 CD_CD_BARCODE FROM PM_DRUG.dbo.CD_ITEM_UNIT_MEMBER WHERE DrugCode = S.DrugCode)
|
||||||
|
) AS barcode
|
||||||
FROM SALE_SUB S
|
FROM SALE_SUB S
|
||||||
LEFT JOIN PM_DRUG.dbo.CD_GOODS G ON S.DrugCode = G.DrugCode
|
LEFT JOIN PM_DRUG.dbo.CD_GOODS G ON S.DrugCode = G.DrugCode
|
||||||
WHERE S.SL_NO_order = ?
|
WHERE S.SL_NO_order = ?
|
||||||
@ -5087,9 +5089,14 @@ def api_admin_pos_live_detail(order_no):
|
|||||||
|
|
||||||
rows = cursor.fetchall()
|
rows = cursor.fetchall()
|
||||||
items = []
|
items = []
|
||||||
|
seen_drugs = set() # 중복 제거용
|
||||||
for row in rows:
|
for row in rows:
|
||||||
|
drug_code = row[0]
|
||||||
|
if drug_code in seen_drugs:
|
||||||
|
continue
|
||||||
|
seen_drugs.add(drug_code)
|
||||||
items.append({
|
items.append({
|
||||||
'drug_code': row[0],
|
'drug_code': drug_code,
|
||||||
'product_name': row[1],
|
'product_name': row[1],
|
||||||
'quantity': int(row[2]) if row[2] else 0,
|
'quantity': int(row[2]) if row[2] else 0,
|
||||||
'unit_price': float(row[3]) if row[3] else 0,
|
'unit_price': float(row[3]) if row[3] else 0,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user