Files
HM_project_Viewer_Board/scripts/activate_hanmac_voucher_existence_snapshot.py
T

44 lines
1.4 KiB
Python

from __future__ import annotations
import argparse
import json
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
from main import engine
from wehago_compare import activate_erp_voucher_existence_snapshot, init_wehago_compare_db
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(
description=(
"이미 적재된 Hanmac ERP 전표 원천(source_file_id)을 최신 전표 존재 스냅샷으로 활성화합니다. "
"WEHAGO anchor 매칭은 이 스냅샷에 실제 존재하는 Hanmac draft만 확정 후보로 사용합니다."
)
)
parser.add_argument("--year", type=int, required=True, help="스냅샷을 활성화할 회계연도")
parser.add_argument("--source-file-id", type=int, required=True, help="wehago_source_files.id")
parser.add_argument("--label", default="", help="운영자가 식별할 수 있는 스냅샷 설명")
return parser.parse_args()
def main() -> int:
args = parse_args()
init_wehago_compare_db(engine)
with engine.begin() as conn:
result = activate_erp_voucher_existence_snapshot(
conn,
args.year,
source_file_id=args.source_file_id,
source_label=args.label,
snapshot_mode="full",
)
print(json.dumps(result, ensure_ascii=False, indent=2))
return 0
if __name__ == "__main__":
raise SystemExit(main())