feat(rapor): aylık değerlendirme raporu backend (şablon, yorumlar, öneriler)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-13 21:36:43 +03:00
parent b974525cf6
commit dc0d783e46
14 changed files with 1772 additions and 3 deletions
+2
View File
@@ -9,6 +9,7 @@ mod catalog;
mod entry;
mod health;
mod household;
mod monthly_report;
mod note;
mod period;
mod plan;
@@ -90,6 +91,7 @@ pub fn router(state: AppState) -> Router {
.route("/periods/{id}/notes", get(note::list).post(note::create))
.route("/periods/{id}/summary", get(budget::summary))
.route("/periods/{id}/review", get(review::get))
.route("/periods/{id}/report.md", get(monthly_report::get))
.route("/periods/{id}/daily", get(stats::daily))
.route("/stats/periods", get(stats::periods))
.route("/reports/breakdown", get(reports::breakdown))
+44
View File
@@ -0,0 +1,44 @@
//! Aylık değerlendirme raporu (`services::monthly_report`, şablon `templates/monthly_report.md`).
//!
//! | Yöntem | Yol | İş |
//! |---|---|---|
//! | GET | `/api/periods/{id}/report.md` | dönemin raporu (Markdown); açık dönem → ara rapor |
use axum::{
extract::{Path, State},
http::header,
response::IntoResponse,
};
use mongodb::bson::Uuid;
use crate::{
auth::AuthUser,
error::{AppError, AppResult},
services::{backup::slug, monthly_report, period},
state::AppState,
};
pub async fn get(
State(s): State<AppState>,
auth: AuthUser,
Path(id): Path<String>,
) -> AppResult<impl IntoResponse> {
let id = Uuid::parse_str(&id).map_err(|_| AppError::NotFound)?;
let p = period::get(&s.db, auth.household_id, id).await?;
let body = monthly_report::markdown(&s.db, auth.household_id, id).await?;
let file = format!("kakeibo-rapor-{}.md", slug(&p.name));
Ok((
[
(
header::CONTENT_TYPE,
"text/markdown; charset=utf-8".to_string(),
),
(
header::CONTENT_DISPOSITION,
format!("inline; filename=\"{file}\""),
),
(header::CACHE_CONTROL, "no-store".to_string()),
],
body,
))
}