- 판매 관리 기능 추가 - compounds 테이블에 판매 관련 컬럼 추가 (payment_method, discount_rate, delivery_method 등) - 판매 상태 관리 (조제완료→결제대기→결제완료→배송대기→배송완료) - 판매 처리 모달 UI 구현 - 9가지 상태별 뱃지 표시 - 마일리지 시스템 구축 - patients 테이블에 마일리지 컬럼 추가 (balance, earned, used) - mileage_transactions 테이블 생성 (거래 이력 관리) - 마일리지 사용/적립 기능 구현 - 복합 결제 기능 - 할인율(%) / 할인액(원) 직접 입력 선택 가능 - 마일리지 + 현금 + 카드 + 계좌이체 복합 결제 - 결제 금액 자동 검증 - 결제 방법 자동 분류 (복합결제 지원) - API 엔드포인트 추가 - POST /api/compounds/<id>/status (상태 업데이트) - PUT /api/compounds/<id>/price (가격 조정) - GET /api/sales/statistics (판매 통계) - 데이터베이스 설정 통합 - config.py 생성하여 DB 경로 중앙화 TODO: 처방별 기본가격 정책 시스템 (price_policies 테이블 활용) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
131 lines
3.9 KiB
Python
131 lines
3.9 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
판매 관리 시스템 Phase 1 - compounds 테이블에 판매 관련 컬럼 추가
|
|
"""
|
|
|
|
import sqlite3
|
|
from datetime import datetime
|
|
|
|
def add_sales_columns():
|
|
"""compounds 테이블에 판매 관련 컬럼 추가"""
|
|
conn = sqlite3.connect('database/kdrug.db')
|
|
cursor = conn.cursor()
|
|
|
|
try:
|
|
# 1. payment_method 컬럼 추가
|
|
cursor.execute("""
|
|
ALTER TABLE compounds
|
|
ADD COLUMN payment_method TEXT
|
|
""")
|
|
print("✓ payment_method 컬럼 추가 완료")
|
|
except sqlite3.OperationalError as e:
|
|
if "duplicate column name" in str(e):
|
|
print("- payment_method 컬럼 이미 존재")
|
|
else:
|
|
raise
|
|
|
|
try:
|
|
# 2. payment_date 컬럼 추가
|
|
cursor.execute("""
|
|
ALTER TABLE compounds
|
|
ADD COLUMN payment_date DATETIME
|
|
""")
|
|
print("✓ payment_date 컬럼 추가 완료")
|
|
except sqlite3.OperationalError as e:
|
|
if "duplicate column name" in str(e):
|
|
print("- payment_date 컬럼 이미 존재")
|
|
else:
|
|
raise
|
|
|
|
try:
|
|
# 3. discount_rate 컬럼 추가
|
|
cursor.execute("""
|
|
ALTER TABLE compounds
|
|
ADD COLUMN discount_rate REAL DEFAULT 0
|
|
""")
|
|
print("✓ discount_rate 컬럼 추가 완료")
|
|
except sqlite3.OperationalError as e:
|
|
if "duplicate column name" in str(e):
|
|
print("- discount_rate 컬럼 이미 존재")
|
|
else:
|
|
raise
|
|
|
|
try:
|
|
# 4. discount_reason 컬럼 추가
|
|
cursor.execute("""
|
|
ALTER TABLE compounds
|
|
ADD COLUMN discount_reason TEXT
|
|
""")
|
|
print("✓ discount_reason 컬럼 추가 완료")
|
|
except sqlite3.OperationalError as e:
|
|
if "duplicate column name" in str(e):
|
|
print("- discount_reason 컬럼 이미 존재")
|
|
else:
|
|
raise
|
|
|
|
try:
|
|
# 5. delivery_method 컬럼 추가
|
|
cursor.execute("""
|
|
ALTER TABLE compounds
|
|
ADD COLUMN delivery_method TEXT
|
|
""")
|
|
print("✓ delivery_method 컬럼 추가 완료")
|
|
except sqlite3.OperationalError as e:
|
|
if "duplicate column name" in str(e):
|
|
print("- delivery_method 컬럼 이미 존재")
|
|
else:
|
|
raise
|
|
|
|
try:
|
|
# 6. delivery_date 컬럼 추가
|
|
cursor.execute("""
|
|
ALTER TABLE compounds
|
|
ADD COLUMN delivery_date DATETIME
|
|
""")
|
|
print("✓ delivery_date 컬럼 추가 완료")
|
|
except sqlite3.OperationalError as e:
|
|
if "duplicate column name" in str(e):
|
|
print("- delivery_date 컬럼 이미 존재")
|
|
else:
|
|
raise
|
|
|
|
try:
|
|
# 7. invoice_number 컬럼 추가
|
|
cursor.execute("""
|
|
ALTER TABLE compounds
|
|
ADD COLUMN invoice_number TEXT
|
|
""")
|
|
print("✓ invoice_number 컬럼 추가 완료")
|
|
except sqlite3.OperationalError as e:
|
|
if "duplicate column name" in str(e):
|
|
print("- invoice_number 컬럼 이미 존재")
|
|
else:
|
|
raise
|
|
|
|
try:
|
|
# 8. actual_payment_amount 컬럼 추가 (실제 결제 금액)
|
|
cursor.execute("""
|
|
ALTER TABLE compounds
|
|
ADD COLUMN actual_payment_amount REAL
|
|
""")
|
|
print("✓ actual_payment_amount 컬럼 추가 완료")
|
|
except sqlite3.OperationalError as e:
|
|
if "duplicate column name" in str(e):
|
|
print("- actual_payment_amount 컬럼 이미 존재")
|
|
else:
|
|
raise
|
|
|
|
conn.commit()
|
|
print("\n판매 관련 컬럼 추가 완료!")
|
|
|
|
# 현재 compounds 테이블 구조 확인
|
|
cursor.execute("PRAGMA table_info(compounds)")
|
|
columns = cursor.fetchall()
|
|
print("\n현재 compounds 테이블 구조:")
|
|
for col in columns:
|
|
print(f" - {col[1]}: {col[2]}")
|
|
|
|
conn.close()
|
|
|
|
if __name__ == "__main__":
|
|
add_sales_columns() |