From a511d72248d20ba2fcb436b58ee2459d422d80b7 Mon Sep 17 00:00:00 2001 From: Joe Carstairs Date: Sat, 29 Aug 2026 15:19:15 +0100 Subject: task-001: adds Transaction::new() with RNG for id field --- schist_core/schist_models/src/transaction.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'schist_core/schist_models/src') diff --git a/schist_core/schist_models/src/transaction.rs b/schist_core/schist_models/src/transaction.rs index ef0a0ab..5b75b22 100644 --- a/schist_core/schist_models/src/transaction.rs +++ b/schist_core/schist_models/src/transaction.rs @@ -26,3 +26,24 @@ pub struct Transaction { pub date: DateUtc, pub description: String, } + +impl Transaction { + pub fn new( + account_id: i32, + amount: i32, + bucket_id: Option, + counterparty: &str, + date: DateUtc, + description: &str, + ) -> Self { + Self { + id: rand::random(), + account_id, + amount, + bucket_id, + counterparty: String::from(counterparty), + date, + description: String::from(description), + } + } +} -- cgit v1.2.3