fix: Excel 입고 시 보험코드 9자리 패딩 처리

- Excel 읽기 시 제품코드를 문자열로 처리하여 앞자리 0 보존
- 한의사랑/한의정보 형식 모두 보험코드 9자리 패딩 적용
- 예: 60600420 → 060600420 자동 변환

이제 Excel 파일의 보험코드가 숫자로 읽혀도 정상 처리됨

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
시골약사 2026-02-16 14:36:52 +00:00
parent 116712aa24
commit 1198c22083

View File

@ -64,7 +64,8 @@ class ExcelProcessor:
def read_excel(self, file_path):
"""Excel 파일 읽기"""
try:
self.df_original = pd.read_excel(file_path)
# 제품코드를 문자열로 읽기 위한 dtype 설정
self.df_original = pd.read_excel(file_path, dtype={'제품코드': str})
self.format_type = self.detect_format(self.df_original)
return True
except Exception as e:
@ -82,6 +83,12 @@ class ExcelProcessor:
if old_col in df.columns:
df_mapped[new_col] = df[old_col]
# 보험코드 9자리 패딩 처리
if 'insurance_code' in df_mapped.columns:
df_mapped['insurance_code'] = df_mapped['insurance_code'].apply(
lambda x: str(x).zfill(9) if pd.notna(x) and str(x).isdigit() else str(x) if pd.notna(x) else None
)
# 업체명 추가 (기본값)
df_mapped['supplier_name'] = '한의사랑'
@ -112,6 +119,12 @@ class ExcelProcessor:
if old_col in df.columns:
df_mapped[new_col] = df[old_col]
# 보험코드 9자리 패딩 처리
if 'insurance_code' in df_mapped.columns:
df_mapped['insurance_code'] = df_mapped['insurance_code'].apply(
lambda x: str(x).zfill(9) if pd.notna(x) and str(x).isdigit() else str(x) if pd.notna(x) else None
)
# 날짜 처리 (YYYYMMDD 형식)
if 'receipt_date' in df_mapped.columns:
df_mapped['receipt_date'] = df_mapped['receipt_date'].astype(str)