transaction imp
Signed-off-by: thatscringebro <thatscringebro@tutanota.com>
This commit is contained in:
parent
8a862a444f
commit
6fda1192fa
@ -1,18 +1,66 @@
|
||||
use crate::entities::Account;
|
||||
use crate::{data_layer, entities::Account};
|
||||
use chrono::{DateTime, Utc};
|
||||
use sqlite::Connection;
|
||||
|
||||
pub struct Transaction {
|
||||
id: i32,
|
||||
account_id: i32,
|
||||
id: i64,
|
||||
account_id: i64,
|
||||
amount: f64,
|
||||
date: DateTime<Utc>,
|
||||
description: String,
|
||||
type_id: i32,
|
||||
type_id: i64,
|
||||
|
||||
account: Account,
|
||||
tr_type: TransactionType,
|
||||
}
|
||||
|
||||
impl Transaction {
|
||||
pub fn new(
|
||||
id: i64,
|
||||
ac_id: i64,
|
||||
amount: f64,
|
||||
date: DateTime<Utc>,
|
||||
desc: String,
|
||||
type_id: i64,
|
||||
con: &Connection,
|
||||
) -> Self {
|
||||
Transaction {
|
||||
id: id,
|
||||
account_id: ac_id,
|
||||
amount: amount,
|
||||
date: date,
|
||||
description: desc,
|
||||
type_id: type_id,
|
||||
account: data_layer::get_account(con, id),
|
||||
tr_type: data_layer::get_transaction_type(con, type_id),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_id(&self) -> i64 {
|
||||
return self.id;
|
||||
}
|
||||
|
||||
pub fn get_amount(&self) -> f64 {
|
||||
return self.amount;
|
||||
}
|
||||
|
||||
pub fn get_date(&self) -> DateTime<Utc> {
|
||||
return self.date;
|
||||
}
|
||||
|
||||
pub fn get_desc(&self) -> String {
|
||||
return self.description;
|
||||
}
|
||||
|
||||
pub fn get_account(&self) -> Account {
|
||||
return self.account;
|
||||
}
|
||||
|
||||
pub fn get_type(&self) -> TransactionType {
|
||||
return self.tr_type;
|
||||
}
|
||||
}
|
||||
|
||||
pub struct TransactionType {
|
||||
id: i64,
|
||||
description: String,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user