feat(defter): özet ve bütçeye gerçekleşen harcama eklendi (backend)
- Dönem özeti: spent_total ve remaining (harcanabilir − harcanan) - Bütçe görünümü: grup ve hafta bazında spent - Değerler saklanmaz, kayıtlardan anlık toplanır; silinenler sayılmaz Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
//!
|
||||
//! | Yöntem | Yol | İş |
|
||||
//! |---|---|---|
|
||||
//! | GET | `/api/periods/{id}/summary` | gelir/gider/birikim/devir → harcanabilir |
|
||||
//! | GET | `/api/periods/{id}/budget` | 4 grup: aylık + haftalık döküm |
|
||||
//! | GET | `/api/periods/{id}/summary` | gelir/gider/birikim/devir → harcanabilir, harcanan, kalan |
|
||||
//! | GET | `/api/periods/{id}/budget` | 4 grup: aylık + haftalık döküm, her birinde harcanan |
|
||||
//! | PUT | `/api/periods/{id}/budget` | 4 grubun aylık tutarları |
|
||||
//! | PUT | `/api/periods/{id}/budget/weeks` | bir haftayı elle ayarla / otomatiğe döndür |
|
||||
//! | GET | `/api/periods/{id}/budget/suggestion?method=…` | `default` · `previous` · `avg3` |
|
||||
@@ -81,6 +81,12 @@ pub struct SummaryDto {
|
||||
/// harcanabilir − dağıtılan (negatifse fazla dağıtılmış)
|
||||
#[ts(type = "number")]
|
||||
unallocated: i64,
|
||||
/// Dönemde gerçekleşen harcama
|
||||
#[ts(type = "number")]
|
||||
spent_total: i64,
|
||||
/// Kalan harcanabilir: harcanabilir − gerçekleşen (negatifse aşılmış)
|
||||
#[ts(type = "number")]
|
||||
remaining: i64,
|
||||
}
|
||||
|
||||
#[derive(Serialize, TS)]
|
||||
@@ -89,6 +95,9 @@ pub struct GroupBudgetDto {
|
||||
group: Group,
|
||||
#[ts(type = "number")]
|
||||
monthly: i64,
|
||||
/// Dönem boyunca gerçekleşen harcama
|
||||
#[ts(type = "number")]
|
||||
spent: i64,
|
||||
/// Elle girilen haftaların toplamı aylık tutarı aşıyor
|
||||
weekly_over: bool,
|
||||
weeks: Vec<WeekBudgetDto>,
|
||||
@@ -105,6 +114,9 @@ struct WeekBudgetDto {
|
||||
amount: i64,
|
||||
/// Elle girildi (otomatik değil)
|
||||
is_manual: bool,
|
||||
/// Bu haftada gerçekleşen harcama
|
||||
#[ts(type = "number")]
|
||||
spent: i64,
|
||||
}
|
||||
|
||||
impl From<GroupBudget> for GroupBudgetDto {
|
||||
@@ -112,6 +124,7 @@ impl From<GroupBudget> for GroupBudgetDto {
|
||||
Self {
|
||||
group: g.group,
|
||||
monthly: g.monthly,
|
||||
spent: g.spent,
|
||||
weekly_over: g.weekly_over,
|
||||
weeks: g
|
||||
.weeks
|
||||
@@ -123,6 +136,7 @@ impl From<GroupBudget> for GroupBudgetDto {
|
||||
days: w.days,
|
||||
amount: w.amount,
|
||||
is_manual: w.is_manual,
|
||||
spent: w.spent,
|
||||
})
|
||||
.collect(),
|
||||
}
|
||||
@@ -182,6 +196,8 @@ pub async fn summary(
|
||||
spendable: x.spendable,
|
||||
budget_total: x.budget_total,
|
||||
unallocated: x.spendable - x.budget_total,
|
||||
spent_total: x.spent_total,
|
||||
remaining: x.spendable - x.spent_total,
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user