Spaces:
Sleeping
Sleeping
Update utils/reporting_utils.py
Browse files- utils/reporting_utils.py +83 -0
utils/reporting_utils.py
CHANGED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
๋ณด๊ณ ์ ์์ฑ ๋ฐ ์์ฝ ๊ด๋ จ ์ ํธ๋ฆฌํฐ
|
| 3 |
+
"""
|
| 4 |
+
from typing import Dict, Any
|
| 5 |
+
import pandas as pd
|
| 6 |
+
|
| 7 |
+
def print_data_summary(summary: Dict[str, Any], company_config: Dict[str, Any]) -> None:
|
| 8 |
+
"""
|
| 9 |
+
๋ฐ์ดํฐ ์ฒ๋ฆฌ ๊ฒฐ๊ณผ ์์ฝ ์ถ๋ ฅ
|
| 10 |
+
|
| 11 |
+
Args:
|
| 12 |
+
summary: ๋ฐ์ดํฐ ์์ฝ ์ ๋ณด
|
| 13 |
+
company_config: ๋ ํ์ฌ ์ค์ ์ ๋ณด
|
| 14 |
+
"""
|
| 15 |
+
total_count = summary['total_count']
|
| 16 |
+
total_amount = summary['total_amount']
|
| 17 |
+
account_counts = summary['account_counts']
|
| 18 |
+
mapping_summary = summary['mapping_summary']
|
| 19 |
+
|
| 20 |
+
print(f"\n์ด ์ฒ๋ฆฌ ๊ฑด์: {total_count + 1}๊ฑด (์ฐจ๋ณ {total_count}๊ฑด, ๋๋ณ 1๊ฑด)")
|
| 21 |
+
print(f"์ด ๊ธ์ก: {total_amount:,.0f}์")
|
| 22 |
+
print(f"์ฐจ๋ณ ๊ณ์ : {len(account_counts)}๊ฐ ๊ณ์ ์ฌ์ฉ")
|
| 23 |
+
print(f"๋๋ณ ๊ณ์ : {company_config['payable_acct']} (๋ฏธ์ง๊ธ๊ธ) 1๊ฐ ๊ณ์ ์ฌ์ฉ")
|
| 24 |
+
|
| 25 |
+
# ๊ด๋ฆฌํญ๋ชฉ ์ค์ ๋ด์ฉ ์ถ๋ ฅ
|
| 26 |
+
print("\n๊ด๋ฆฌํญ๋ชฉ ์ค์ ์ ๋ณด:")
|
| 27 |
+
print(f"- CD_CC (์ฝ์คํธ์ผํฐ): {company_config['cost_center']} (๊ณ ์ )")
|
| 28 |
+
print(f"- CD_PARTNER (๊ฑฐ๋์ฒ์ฝ๋): {company_config['partner_code']} (๊ณ ์ )")
|
| 29 |
+
print(f"- CD_PJT (ํ๋ก์ ํธ์ฝ๋): ๊ฐ ํ๋ณ ๋งคํ๋ ์ฝ๋ ์ฌ์ฉ")
|
| 30 |
+
|
| 31 |
+
# ๋งคํ ์ ๋ณด ์์ฝ
|
| 32 |
+
print("\n๋งคํ ์ฑ๊ณต ํ๋ช
:")
|
| 33 |
+
mapped_teams = mapping_summary['mapped_teams']
|
| 34 |
+
for idx, team in enumerate(mapped_teams[:10]):
|
| 35 |
+
if len(mapped_teams) > 10 and idx == 9:
|
| 36 |
+
print(f"- {team['original']} ... ์ธ {len(mapped_teams)-10}๊ฐ")
|
| 37 |
+
else:
|
| 38 |
+
print(f"- {team['original']} -> {team['mapped']} (ACCT: {team['acct']}, PJT: {team['pjt']})")
|
| 39 |
+
|
| 40 |
+
def generate_report_file(summary: Dict[str, Any], erp_df: pd.DataFrame, report_file: str) -> None:
|
| 41 |
+
"""
|
| 42 |
+
์ฒ๋ฆฌ ๊ฒฐ๊ณผ ๋ณด๊ณ ์ ํ์ผ ์์ฑ
|
| 43 |
+
|
| 44 |
+
Args:
|
| 45 |
+
summary: ๋ฐ์ดํฐ ์์ฝ ์ ๋ณด
|
| 46 |
+
erp_df: ERP ๋ฐ์ดํฐํ๋ ์
|
| 47 |
+
report_file: ๋ณด๊ณ ์ ํ์ผ ๊ฒฝ๋ก
|
| 48 |
+
"""
|
| 49 |
+
with open(report_file, 'w', encoding='utf-8') as f:
|
| 50 |
+
f.write("# ERP ์ ํ ์์ฑ ๊ฒฐ๊ณผ ๋ณด๊ณ ์\n\n")
|
| 51 |
+
|
| 52 |
+
# ๊ธฐ๋ณธ ์ ๋ณด
|
| 53 |
+
f.write("## 1. ๊ธฐ๋ณธ ์ ๋ณด\n")
|
| 54 |
+
f.write(f"- ์์ฑ ์ผ์: {pd.Timestamp.now().strftime('%Y-%m-%d %H:%M:%S')}\n")
|
| 55 |
+
f.write(f"- ์ฒ๋ฆฌ ๊ฑด์: ์ฐจ๋ณ {summary['total_count']}๊ฑด, ๋๋ณ 1๊ฑด\n")
|
| 56 |
+
f.write(f"- ์ด ๊ธ์ก: {summary['total_amount']:,.0f}์\n\n")
|
| 57 |
+
|
| 58 |
+
# ๊ณ์ ๋ถํฌ
|
| 59 |
+
f.write("## 2. ๊ณ์ ์ฝ๋๋ณ ์ฌ์ฉ ํํฉ\n")
|
| 60 |
+
for acct, count in summary['account_counts'].items():
|
| 61 |
+
f.write(f"- {acct}: {count}๊ฑด\n")
|
| 62 |
+
f.write("\n")
|
| 63 |
+
|
| 64 |
+
# ํ๋ณ ๋ถํฌ
|
| 65 |
+
f.write("## 3. ํ๋ณ ๋งคํ ์ ๋ณด\n")
|
| 66 |
+
for team in summary['mapping_summary']['mapped_teams']:
|
| 67 |
+
f.write(f"- {team['original']} -> {team['mapped']} (๊ณ์ : {team['acct']}, ํ๋ก์ ํธ: {team['pjt']})\n")
|
| 68 |
+
|
| 69 |
+
f.write("\n## 4. ์ ํ ์ฃผ์ ์ ๋ณด\n")
|
| 70 |
+
# ์ฐจ๋ณ ํ ์ ๋ณด
|
| 71 |
+
debit_rows = erp_df[erp_df["TP_DRCR"] == "1"]
|
| 72 |
+
f.write(f"- ์ฐจ๋ณ ๊ฑด์: {len(debit_rows)}๊ฑด\n")
|
| 73 |
+
f.write(f"- ์ฐจ๋ณ ๊ณ์ : {len(debit_rows['CD_ACCT'].unique())}๊ฐ ๊ณ์ ์ฌ์ฉ\n")
|
| 74 |
+
|
| 75 |
+
# ๋๋ณ ํ ์ ๋ณด
|
| 76 |
+
credit_rows = erp_df[erp_df["TP_DRCR"] == "2"]
|
| 77 |
+
f.write(f"- ๋๋ณ ๊ฑด์: {len(credit_rows)}๊ฑด\n")
|
| 78 |
+
f.write(f"- ๋๋ณ ๊ณ์ : {credit_rows['CD_ACCT'].iloc[0]} (๋ฏธ์ง๊ธ๊ธ)\n")
|
| 79 |
+
|
| 80 |
+
# ์ ํ ๋ฒํธ ์ ๋ณด
|
| 81 |
+
f.write(f"- ์ ํ ๋ฒํธ: {erp_df['NO_DOCU'].iloc[0]}\n")
|
| 82 |
+
|
| 83 |
+
print(f"\n์ฒ๋ฆฌ ๊ฒฐ๊ณผ ๋ณด๊ณ ์๊ฐ '{report_file}'์ ์ ์ฅ๋์์ต๋๋ค.")
|