feat(borç): borç takibi backend (ölçümler, taksit planları, yol haritası, dönem borcu, içe aktarma)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -89,6 +89,18 @@ fn definitions() -> Vec<(&'static str, Vec<IndexModel>)> {
|
||||
col::IMPORT_RULES,
|
||||
vec![idx(doc! { "household_id": 1, "pattern": 1 })],
|
||||
),
|
||||
(
|
||||
col::DEBT_SNAPSHOTS,
|
||||
vec![idx(doc! { "household_id": 1, "date": -1 })],
|
||||
),
|
||||
(
|
||||
col::INSTALLMENT_PLANS,
|
||||
vec![idx(doc! { "household_id": 1, "first_month": 1 })],
|
||||
),
|
||||
(
|
||||
col::DEBT_TARGETS,
|
||||
vec![idx(doc! { "household_id": 1, "month": 1 })],
|
||||
),
|
||||
(
|
||||
col::RESTORE_POINTS,
|
||||
vec![idx(doc! { "household_id": 1, "created_at": -1 })],
|
||||
|
||||
@@ -40,6 +40,11 @@ const MIGRATIONS: &[Migration] = &[
|
||||
name: "restore_points",
|
||||
run: |db| Box::pin(m003_restore_points(db)),
|
||||
},
|
||||
Migration {
|
||||
version: 4,
|
||||
name: "debt_tracking",
|
||||
run: |db| Box::pin(m004_debt_tracking(db)),
|
||||
},
|
||||
];
|
||||
|
||||
/// En son şema sürümü (JSON yedeğine yazılır; daha yeni yedek reddedilir).
|
||||
@@ -126,6 +131,21 @@ async fn m003_restore_points(db: &Database) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// v4: borç takibi koleksiyonları (transaction içinde ilk yazımdan önce var olmalı).
|
||||
async fn m004_debt_tracking(db: &Database) -> Result<()> {
|
||||
let existing = db.list_collection_names().await?;
|
||||
for name in [
|
||||
col::DEBT_SNAPSHOTS,
|
||||
col::INSTALLMENT_PLANS,
|
||||
col::DEBT_TARGETS,
|
||||
] {
|
||||
if !existing.iter().any(|n| n == name) {
|
||||
db.create_collection(name).await?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
@@ -75,6 +75,12 @@ pub mod col {
|
||||
pub const SCHEMA_MIGRATIONS: &str = "schema_migrations";
|
||||
/// JSON geri yüklemeden önce alınan, sıkıştırılmış hane kopyaları ("geri al")
|
||||
pub const RESTORE_POINTS: &str = "restore_points";
|
||||
/// Banka borcu ölçümleri (KMH, kart, kalan taksit, artı bakiye)
|
||||
pub const DEBT_SNAPSHOTS: &str = "debt_snapshots";
|
||||
/// Taksit planları (ilk taksit ayı + adet → aylık yük kendiliğinden)
|
||||
pub const INSTALLMENT_PLANS: &str = "installment_plans";
|
||||
/// Borç yol haritası: ay sonu toplam borç hedefleri
|
||||
pub const DEBT_TARGETS: &str = "debt_targets";
|
||||
|
||||
/// Hane verisi taşıyan koleksiyonlar (`household_id` alanı var).
|
||||
pub const HOUSEHOLD_SCOPED: &[&str] = &[
|
||||
@@ -92,5 +98,8 @@ pub mod col {
|
||||
ASSETS,
|
||||
ASSET_TRANSACTIONS,
|
||||
IMPORT_RULES,
|
||||
DEBT_SNAPSHOTS,
|
||||
INSTALLMENT_PLANS,
|
||||
DEBT_TARGETS,
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user