- 판매 관리 기능 추가 - 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>
94 lines
3.0 KiB
Python
94 lines
3.0 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
판매 관리 시스템 - 신규 테이블 생성
|
|
"""
|
|
|
|
import sqlite3
|
|
from datetime import datetime
|
|
|
|
def create_sales_tables():
|
|
"""판매 관련 신규 테이블 생성"""
|
|
conn = sqlite3.connect('database/kdrug.db')
|
|
cursor = conn.cursor()
|
|
|
|
# 1. sales_transactions 테이블 생성
|
|
cursor.execute("""
|
|
CREATE TABLE IF NOT EXISTS sales_transactions (
|
|
transaction_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
compound_id INTEGER REFERENCES compounds(compound_id),
|
|
transaction_date DATETIME NOT NULL,
|
|
transaction_type TEXT NOT NULL, -- SALE, REFUND, CANCEL
|
|
amount REAL NOT NULL,
|
|
payment_method TEXT,
|
|
payment_status TEXT, -- PENDING, COMPLETED, FAILED
|
|
notes TEXT,
|
|
created_by TEXT,
|
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
)
|
|
""")
|
|
print("✓ sales_transactions 테이블 생성 완료")
|
|
|
|
# 2. price_policies 테이블 생성
|
|
cursor.execute("""
|
|
CREATE TABLE IF NOT EXISTS price_policies (
|
|
policy_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
formula_id INTEGER REFERENCES formulas(formula_id),
|
|
base_price REAL NOT NULL,
|
|
dispensing_fee REAL DEFAULT 0,
|
|
is_active BOOLEAN DEFAULT 1,
|
|
effective_date DATE,
|
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
)
|
|
""")
|
|
print("✓ price_policies 테이블 생성 완료")
|
|
|
|
# 3. sales_status_history 테이블 생성
|
|
cursor.execute("""
|
|
CREATE TABLE IF NOT EXISTS sales_status_history (
|
|
history_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
compound_id INTEGER REFERENCES compounds(compound_id),
|
|
old_status TEXT,
|
|
new_status TEXT NOT NULL,
|
|
changed_by TEXT,
|
|
change_reason TEXT,
|
|
changed_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
)
|
|
""")
|
|
print("✓ sales_status_history 테이블 생성 완료")
|
|
|
|
# 인덱스 생성
|
|
cursor.execute("""
|
|
CREATE INDEX IF NOT EXISTS idx_sales_transactions_compound
|
|
ON sales_transactions(compound_id)
|
|
""")
|
|
|
|
cursor.execute("""
|
|
CREATE INDEX IF NOT EXISTS idx_price_policies_formula
|
|
ON price_policies(formula_id)
|
|
""")
|
|
|
|
cursor.execute("""
|
|
CREATE INDEX IF NOT EXISTS idx_sales_status_history_compound
|
|
ON sales_status_history(compound_id)
|
|
""")
|
|
print("✓ 인덱스 생성 완료")
|
|
|
|
conn.commit()
|
|
|
|
# 생성된 테이블 확인
|
|
cursor.execute("""
|
|
SELECT name FROM sqlite_master
|
|
WHERE type='table'
|
|
AND name IN ('sales_transactions', 'price_policies', 'sales_status_history')
|
|
""")
|
|
tables = cursor.fetchall()
|
|
print("\n생성된 테이블:")
|
|
for table in tables:
|
|
print(f" - {table[0]}")
|
|
|
|
conn.close()
|
|
print("\n판매 관련 테이블 생성 완료!")
|
|
|
|
if __name__ == "__main__":
|
|
create_sales_tables() |