import psycopg2
conn = psycopg2.connect(host='192.168.0.61', port=55432, dbname='njts_acct', user='njts_app', password='njts_app2025')
cur = conn.cursor()

# 子ども・子育て支援金の保険料率を確認
cur.execute("""
    SELECT * FROM insurance_rates
    WHERE rate_type = '子ども・子育て支援金'
    ORDER BY rate_year, calculation_target
""")
rows = cur.fetchall()
print("子ども・子育て支援金 rates:")
for r in rows:
    print(r)

print()

# 王珏の賞与再確認（再計算後）
cur.execute("""
    SELECT b.bonus_id, b.bonus_year, b.bonus_month, b.bonus_type, b.payment_date, b.child_support, b.total_bonus
    FROM bonus_payments b
    JOIN employees e ON b.employee_id = e.employee_id
    WHERE e.employee_code = '20190001'
    ORDER BY b.bonus_year DESC, b.bonus_month DESC LIMIT 5
""")
print("王珏 bonus:")
for r in cur.fetchall():
    print(r)

cur.close()
conn.close()
