feat(transactions): implement transaction management commands
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
pub mod accounts;
|
||||
pub mod exchange_rate;
|
||||
pub mod settings;
|
||||
pub mod transactions;
|
||||
|
||||
66
src-tauri/src/commands/transactions.rs
Normal file
66
src-tauri/src/commands/transactions.rs
Normal file
@@ -0,0 +1,66 @@
|
||||
use crate::errors::CommandResult;
|
||||
use crate::services::transactions::types::inputs::{CreateTransactionInput, TransactionFilter, UpdateTransactionInput};
|
||||
use crate::services::transactions::types::outputs::TransactionWithTags;
|
||||
use crate::state::AppState;
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn create_transaction(
|
||||
state: tauri::State<'_, AppState>,
|
||||
input: CreateTransactionInput,
|
||||
) -> CommandResult<TransactionWithTags> {
|
||||
state.transaction_service().create_transaction(input, None).await
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn get_transactions(
|
||||
state: tauri::State<'_, AppState>,
|
||||
filter: TransactionFilter,
|
||||
) -> CommandResult<Vec<TransactionWithTags>> {
|
||||
state.transaction_service().get_transactions(filter, None).await
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn get_transaction(
|
||||
state: tauri::State<'_, AppState>,
|
||||
id: String,
|
||||
) -> CommandResult<TransactionWithTags> {
|
||||
state.transaction_service().get_transaction(id, None).await
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn update_transaction(
|
||||
state: tauri::State<'_, AppState>,
|
||||
id: String,
|
||||
updates: UpdateTransactionInput,
|
||||
) -> CommandResult<TransactionWithTags> {
|
||||
state
|
||||
.transaction_service()
|
||||
.update_transaction(id, updates, None)
|
||||
.await
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn delete_transaction(
|
||||
state: tauri::State<'_, AppState>,
|
||||
id: String,
|
||||
) -> CommandResult<()> {
|
||||
state.transaction_service().delete_transaction(id, None).await
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn get_transactions_needing_review(
|
||||
state: tauri::State<'_, AppState>,
|
||||
) -> CommandResult<Vec<TransactionWithTags>> {
|
||||
state
|
||||
.transaction_service()
|
||||
.get_transactions_needing_review(None)
|
||||
.await
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn confirm_transaction(
|
||||
state: tauri::State<'_, AppState>,
|
||||
id: String,
|
||||
) -> CommandResult<()> {
|
||||
state.transaction_service().confirm_transaction(id, None).await
|
||||
}
|
||||
Reference in New Issue
Block a user