Spaces:
Sleeping
Sleeping
| """ | |
| ๋ณด๊ณ ์ ์์ฑ ๋ฐ ์์ฝ ๊ด๋ จ ์ ํธ๋ฆฌํฐ | |
| """ | |
| from typing import Dict, Any | |
| import pandas as pd | |
| def print_data_summary(summary: Dict[str, Any], company_config: Dict[str, Any]) -> None: | |
| """ | |
| ๋ฐ์ดํฐ ์ฒ๋ฆฌ ๊ฒฐ๊ณผ ์์ฝ ์ถ๋ ฅ | |
| Args: | |
| summary: ๋ฐ์ดํฐ ์์ฝ ์ ๋ณด | |
| company_config: ๋ ํ์ฌ ์ค์ ์ ๋ณด | |
| """ | |
| total_count = summary['total_count'] | |
| total_amount = summary['total_amount'] | |
| account_counts = summary['account_counts'] | |
| mapping_summary = summary['mapping_summary'] | |
| print(f"\n์ด ์ฒ๋ฆฌ ๊ฑด์: {total_count + 1}๊ฑด (์ฐจ๋ณ {total_count}๊ฑด, ๋๋ณ 1๊ฑด)") | |
| print(f"์ด ๊ธ์ก: {total_amount:,.0f}์") | |
| print(f"์ฐจ๋ณ ๊ณ์ : {len(account_counts)}๊ฐ ๊ณ์ ์ฌ์ฉ") | |
| print(f"๋๋ณ ๊ณ์ : {company_config['payable_acct']} (๋ฏธ์ง๊ธ๊ธ) 1๊ฐ ๊ณ์ ์ฌ์ฉ") | |
| # ๊ด๋ฆฌํญ๋ชฉ ์ค์ ๋ด์ฉ ์ถ๋ ฅ | |
| print("\n๊ด๋ฆฌํญ๋ชฉ ์ค์ ์ ๋ณด:") | |
| print(f"- CD_CC (์ฝ์คํธ์ผํฐ): {company_config['cost_center']} (๊ณ ์ )") | |
| print(f"- CD_PARTNER (๊ฑฐ๋์ฒ์ฝ๋): {company_config['partner_code']} (๊ณ ์ )") | |
| print(f"- CD_PJT (ํ๋ก์ ํธ์ฝ๋): ๊ฐ ํ๋ณ ๋งคํ๋ ์ฝ๋ ์ฌ์ฉ") | |
| # ๋งคํ ์ ๋ณด ์์ฝ | |
| print("\n๋งคํ ์ฑ๊ณต ํ๋ช :") | |
| mapped_teams = mapping_summary['mapped_teams'] | |
| for idx, team in enumerate(mapped_teams[:10]): | |
| if len(mapped_teams) > 10 and idx == 9: | |
| print(f"- {team['original']} ... ์ธ {len(mapped_teams)-10}๊ฐ") | |
| else: | |
| print(f"- {team['original']} -> {team['mapped']} (ACCT: {team['acct']}, PJT: {team['pjt']})") | |
| def generate_report_file(summary: Dict[str, Any], erp_df: pd.DataFrame, report_file: str) -> None: | |
| """ | |
| ์ฒ๋ฆฌ ๊ฒฐ๊ณผ ๋ณด๊ณ ์ ํ์ผ ์์ฑ | |
| Args: | |
| summary: ๋ฐ์ดํฐ ์์ฝ ์ ๋ณด | |
| erp_df: ERP ๋ฐ์ดํฐํ๋ ์ | |
| report_file: ๋ณด๊ณ ์ ํ์ผ ๊ฒฝ๋ก | |
| """ | |
| with open(report_file, 'w', encoding='utf-8') as f: | |
| f.write("# ERP ์ ํ ์์ฑ ๊ฒฐ๊ณผ ๋ณด๊ณ ์\n\n") | |
| # ๊ธฐ๋ณธ ์ ๋ณด | |
| f.write("## 1. ๊ธฐ๋ณธ ์ ๋ณด\n") | |
| f.write(f"- ์์ฑ ์ผ์: {pd.Timestamp.now().strftime('%Y-%m-%d %H:%M:%S')}\n") | |
| f.write(f"- ์ฒ๋ฆฌ ๊ฑด์: ์ฐจ๋ณ {summary['total_count']}๊ฑด, ๋๋ณ 1๊ฑด\n") | |
| f.write(f"- ์ด ๊ธ์ก: {summary['total_amount']:,.0f}์\n\n") | |
| # ๊ณ์ ๋ถํฌ | |
| f.write("## 2. ๊ณ์ ์ฝ๋๋ณ ์ฌ์ฉ ํํฉ\n") | |
| for acct, count in summary['account_counts'].items(): | |
| f.write(f"- {acct}: {count}๊ฑด\n") | |
| f.write("\n") | |
| # ํ๋ณ ๋ถํฌ | |
| f.write("## 3. ํ๋ณ ๋งคํ ์ ๋ณด\n") | |
| for team in summary['mapping_summary']['mapped_teams']: | |
| f.write(f"- {team['original']} -> {team['mapped']} (๊ณ์ : {team['acct']}, ํ๋ก์ ํธ: {team['pjt']})\n") | |
| f.write("\n## 4. ์ ํ ์ฃผ์ ์ ๋ณด\n") | |
| # ์ฐจ๋ณ ํ ์ ๋ณด | |
| debit_rows = erp_df[erp_df["TP_DRCR"] == "1"] | |
| f.write(f"- ์ฐจ๋ณ ๊ฑด์: {len(debit_rows)}๊ฑด\n") | |
| f.write(f"- ์ฐจ๋ณ ๊ณ์ : {len(debit_rows['CD_ACCT'].unique())}๊ฐ ๊ณ์ ์ฌ์ฉ\n") | |
| # ๋๋ณ ํ ์ ๋ณด | |
| credit_rows = erp_df[erp_df["TP_DRCR"] == "2"] | |
| f.write(f"- ๋๋ณ ๊ฑด์: {len(credit_rows)}๊ฑด\n") | |
| f.write(f"- ๋๋ณ ๊ณ์ : {credit_rows['CD_ACCT'].iloc[0]} (๋ฏธ์ง๊ธ๊ธ)\n") | |
| # ์ ํ ๋ฒํธ ์ ๋ณด | |
| f.write(f"- ์ ํ ๋ฒํธ: {erp_df['NO_DOCU'].iloc[0]}\n") | |
| print(f"\n์ฒ๋ฆฌ ๊ฒฐ๊ณผ ๋ณด๊ณ ์๊ฐ '{report_file}'์ ์ ์ฅ๋์์ต๋๋ค.") |