From 4b2d934839cd56cca19d0b192a4f1b68f1b699af Mon Sep 17 00:00:00 2001 From: thug0bin Date: Fri, 6 Mar 2026 17:57:06 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=B0=B1=EC=A0=9C=EC=95=BD=ED=92=88=20?= =?UTF-8?q?=EC=9B=94=EA=B0=84=20=EB=A7=A4=EC=B6=9C=20API=20=EB=9D=BC?= =?UTF-8?q?=EC=9A=B0=ED=8A=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/baekje_api.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/backend/baekje_api.py b/backend/baekje_api.py index b8ff837..8539291 100644 --- a/backend/baekje_api.py +++ b/backend/baekje_api.py @@ -260,3 +260,46 @@ def api_get_balance(): session = get_baekje_session() result = session.get_balance(year if year else None) return jsonify(result) + + +@baekje_bp.route('/monthly-sales', methods=['GET']) +def api_get_monthly_sales(): + """ + 월간 매출(주문) 합계 조회 + + GET /api/baekje/monthly-sales?year=2026&month=3 + + Returns: + { + "success": true, + "total_amount": 7305877, // 월간 매출 합계 + "total_returns": 0, // 월간 반품 합계 + "net_amount": 7305877, // 순매출 (매출 - 반품) + "total_paid": 0, // 월간 입금 합계 + "ending_balance": 14563978, // 월말 잔액 + "prev_balance": 14565453, // 전월이월금 + "from_date": "2026-03-01", + "to_date": "2026-03-31", + "rotate_days": 58.4 // 회전일수 + } + """ + from datetime import datetime + + year = flask_request.args.get('year', '').strip() + month = flask_request.args.get('month', '').strip() + + # 기본값: 현재 연월 + now = datetime.now() + if not year: + year = now.year + else: + year = int(year) + + if not month: + month = now.month + else: + month = int(month) + + session = get_baekje_session() + result = session.get_monthly_sales(year, month) + return jsonify(result)