feat: 특이사항(CUSETC) 영수증 인쇄 기능 추가
- pos_printer.py: print_cusetc() 함수 추가 (ESC/POS 영수증 출력)
- admin.html: 회원 상세 모달에 🖨️ 인쇄 버튼 추가
- 즉시 피드백 토스트 + API 응답 후 결과 표시
This commit is contained in:
@@ -98,7 +98,7 @@ def print_text(text: str, cut: bool = True) -> bool:
|
||||
|
||||
def print_cusetc(customer_name: str, cusetc: str, phone: str = None) -> bool:
|
||||
"""
|
||||
특이(참고)사항 영수증 출력
|
||||
특이(참고)사항 영수증 출력 (단순 텍스트 방식)
|
||||
|
||||
Args:
|
||||
customer_name: 고객 이름
|
||||
@@ -119,66 +119,27 @@ def print_cusetc(customer_name: str, cusetc: str, phone: str = None) -> bool:
|
||||
else:
|
||||
phone_display = phone
|
||||
|
||||
try:
|
||||
# ESC/POS 명령어 조합
|
||||
commands = bytearray()
|
||||
commands.extend(INIT)
|
||||
|
||||
# 헤더 (중앙 정렬, 크게)
|
||||
commands.extend(ALIGN_CENTER)
|
||||
commands.extend(DOUBLE_SIZE)
|
||||
commands.extend("[ 특이사항 ]\n".encode('euc-kr'))
|
||||
commands.extend(NORMAL_SIZE)
|
||||
|
||||
# 구분선
|
||||
commands.extend("================================\n".encode('euc-kr'))
|
||||
|
||||
# 고객 정보 (왼쪽 정렬)
|
||||
commands.extend(ALIGN_LEFT)
|
||||
commands.extend(BOLD_ON)
|
||||
commands.extend(f"고객: {customer_name}\n".encode('euc-kr'))
|
||||
commands.extend(BOLD_OFF)
|
||||
|
||||
if phone_display:
|
||||
commands.extend(f"연락처: {phone_display}\n".encode('euc-kr'))
|
||||
|
||||
commands.extend(f"출력: {now}\n".encode('euc-kr'))
|
||||
|
||||
# 구분선
|
||||
commands.extend("--------------------------------\n".encode('euc-kr'))
|
||||
|
||||
# 특이사항 내용 (굵게)
|
||||
commands.extend(BOLD_ON)
|
||||
|
||||
# 긴 텍스트 줄바꿈 처리 (32자 기준)
|
||||
lines = []
|
||||
for line in cusetc.split('\n'):
|
||||
while len(line) > 32:
|
||||
lines.append(line[:32])
|
||||
line = line[32:]
|
||||
lines.append(line)
|
||||
|
||||
for line in lines:
|
||||
commands.extend(f"{line}\n".encode('euc-kr', errors='replace'))
|
||||
|
||||
commands.extend(BOLD_OFF)
|
||||
|
||||
# 하단 구분선
|
||||
commands.extend("================================\n".encode('euc-kr'))
|
||||
|
||||
# 약국명 (중앙 정렬)
|
||||
commands.extend(ALIGN_CENTER)
|
||||
commands.extend("청춘약국\n".encode('euc-kr'))
|
||||
|
||||
# 피드 + 커트
|
||||
commands.extend(b'\n\n\n')
|
||||
commands.extend(CUT)
|
||||
|
||||
return print_raw(bytes(commands))
|
||||
|
||||
except Exception as e:
|
||||
logging.error(f"[POS Printer] 특이사항 인쇄 실패: {e}")
|
||||
return False
|
||||
# 80mm 프린터 = 48자 기준
|
||||
LINE = "=" * 48
|
||||
THIN = "-" * 48
|
||||
|
||||
message = f"""
|
||||
{LINE}
|
||||
[ 특이사항 ]
|
||||
{LINE}
|
||||
고객: {customer_name}
|
||||
"""
|
||||
if phone_display:
|
||||
message += f"연락처: {phone_display}\n"
|
||||
|
||||
message += f"""출력: {now}
|
||||
{THIN}
|
||||
{cusetc}
|
||||
{LINE}
|
||||
청춘약국
|
||||
"""
|
||||
|
||||
return print_text(message, cut=True)
|
||||
|
||||
|
||||
def test_print() -> bool:
|
||||
|
||||
Reference in New Issue
Block a user