C# Класс BudgetAnalyser.Engine.Services.TransactionManagerService

Наследование: ITransactionManagerService, ISupportsModelPersistence
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
ClearBucketAndTextFilters ( ) : ObservableCollection

Clears the bucket and text filters.

Close ( ) : void

Closes the currently loaded file. No warnings will be raised if there is unsaved data.

CreateAsync ( ApplicationDatabase applicationDatabase ) : System.Threading.Tasks.Task

Create a new StatementModel.

DetectDuplicateTransactions ( ) : string

Detects duplicate transactions in the current StatementModel and returns a summary string for displaying in the UI. Each individual duplicate transactions will be flagged by the Transaction.IsSuspectedDuplicate property.

FilterByBucket ( string bucketCode ) : ObservableCollection

Returns a filtered list of Transactions by bucket code.

FilterBySearchText ( string searchText ) : ObservableCollection

Returns a filtered list of Transactions using the provided search text. All following transaction fields are searched: Description, Reference1, Reference2, Reference3.

FilterTransactions ( GlobalFilterCriteria criteria ) : void

Filters the transactions using the filter object provided.

FilterableBuckets ( ) : IEnumerable

Provides a list of buckets for display purposes for filtering the transactions shown. This list will include a blank item to represent no filtering, and a [Uncategorised] to represent a filter to show only transactions with no bucket allocation.

ImportAndMergeBankStatementAsync ( string storageKey, Account account ) : System.Threading.Tasks.Task

Imports a bank's transaction extract and merges it with the currently loaded Budget Analyser Statement. This method should not be used without a StatementModel loaded. It is recommended to follow this up with ValidateWithCurrentBudgetsAsync.

Initialise ( StatementApplicationState stateData ) : void

Parses and loads the persisted state data from the provided object.

LoadAsync ( ApplicationDatabase applicationDatabase ) : System.Threading.Tasks.Task

Loads a data source with the provided database reference data asynchronously.

PopulateGroupByBucketCollection ( bool groupByBucket ) : IEnumerable

Populates a collection grouped by bucket with date sorted transactions contained in each group.

PreparePersistentStateData ( ) : StatementApplicationState

Prepares the persistent state data to save to storage.

RemoveTransaction ( BudgetAnalyser.Engine.Statement.Transaction transactionToRemove ) : void

Removes the provided transaction from the currently loaded Budget Analyser Statement.

SaveAsync ( ApplicationDatabase applicationDatabase ) : System.Threading.Tasks.Task

Saves the application database asynchronously. This may be called using a background worker thread.

SavePreview ( ) : void

Called before Save is called. This will be called on the UI Thread. Objects can optionally add some context data that will be passed to the SaveAsync method call. This can be used to finalise any edits or prompt the user for closing data, ie, a "what-did-you-change" comment; this can't be done during save as it may not be called using the UI Thread.

SplitTransaction ( BudgetAnalyser.Engine.Statement.Transaction originalTransaction, decimal splinterAmount1, decimal splinterAmount2, BudgetBucket splinterBucket1, BudgetBucket splinterBucket2 ) : void

Splits the provided transaction into two. The provided transactions is removed, and two new transactions are created. Both transactions must add up to the existing transaction amount.

TransactionManagerService ( [ bucketRepository, [ statementRepository, [ logger, [ monitorableDependencies ) : System

Initializes a new instance of the TransactionManagerService class.

ValidateModel ( StringBuilder messages ) : bool

Validates the model owned by the service.

ValidateWithCurrentBudgetsAsync ( BudgetCollection budgets = null ) : Task

Validates the currently loaded StatementModel against the provided budgets and ensures all buckets used by the transactions exist in the budgets. This is performed asynchronously. This method can be called when a budget is loaded or changed or when a new Budget Analyser Statement is loaded.

Приватные методы

Метод Описание
MatchTransactionText ( BudgetAnalyser.Engine.Statement.Transaction t, string textFilter ) : bool
NewDataAvailable ( ) : void
ResetTransactionsCollection ( ) : void

Описание методов

ClearBucketAndTextFilters() публичный Метод

Clears the bucket and text filters.
public ClearBucketAndTextFilters ( ) : ObservableCollection
Результат ObservableCollection

Close() публичный Метод

Closes the currently loaded file. No warnings will be raised if there is unsaved data.
public Close ( ) : void
Результат void

CreateAsync() публичный Метод

Create a new StatementModel.
public CreateAsync ( ApplicationDatabase applicationDatabase ) : System.Threading.Tasks.Task
applicationDatabase BudgetAnalyser.Engine.Persistence.ApplicationDatabase
Результат System.Threading.Tasks.Task

DetectDuplicateTransactions() публичный Метод

Detects duplicate transactions in the current StatementModel and returns a summary string for displaying in the UI. Each individual duplicate transactions will be flagged by the Transaction.IsSuspectedDuplicate property.
public DetectDuplicateTransactions ( ) : string
Результат string

FilterByBucket() публичный Метод

Returns a filtered list of Transactions by bucket code.
public FilterByBucket ( string bucketCode ) : ObservableCollection
bucketCode string /// The bucket code as text. This can be null or return all, and /// to /// only return transactions without a bucket classification. ///
Результат ObservableCollection

FilterBySearchText() публичный Метод

Returns a filtered list of Transactions using the provided search text. All following transaction fields are searched: Description, Reference1, Reference2, Reference3.
public FilterBySearchText ( string searchText ) : ObservableCollection
searchText string The search text. Minimum 3 characters.
Результат ObservableCollection

FilterTransactions() публичный Метод

Filters the transactions using the filter object provided.
public FilterTransactions ( GlobalFilterCriteria criteria ) : void
criteria GlobalFilterCriteria
Результат void

FilterableBuckets() публичный Метод

Provides a list of buckets for display purposes for filtering the transactions shown. This list will include a blank item to represent no filtering, and a [Uncategorised] to represent a filter to show only transactions with no bucket allocation.
public FilterableBuckets ( ) : IEnumerable
Результат IEnumerable

ImportAndMergeBankStatementAsync() публичный Метод

Imports a bank's transaction extract and merges it with the currently loaded Budget Analyser Statement. This method should not be used without a StatementModel loaded. It is recommended to follow this up with ValidateWithCurrentBudgetsAsync.
/// /// There are no transactions loaded, you must first load an existing /// file or create a new one. ///
public ImportAndMergeBankStatementAsync ( string storageKey, Account account ) : System.Threading.Tasks.Task
storageKey string
account BudgetAnalyser.Engine.BankAccount.Account
Результат System.Threading.Tasks.Task

Initialise() публичный Метод

Parses and loads the persisted state data from the provided object.
public Initialise ( StatementApplicationState stateData ) : void
stateData BudgetAnalyser.Engine.Statement.StatementApplicationState The state data loaded from persistent storage.
Результат void

LoadAsync() публичный Метод

Loads a data source with the provided database reference data asynchronously.
Statement Model data is corrupt and has been tampered with. Unable to load.
public LoadAsync ( ApplicationDatabase applicationDatabase ) : System.Threading.Tasks.Task
applicationDatabase BudgetAnalyser.Engine.Persistence.ApplicationDatabase
Результат System.Threading.Tasks.Task

PopulateGroupByBucketCollection() публичный Метод

Populates a collection grouped by bucket with date sorted transactions contained in each group.
public PopulateGroupByBucketCollection ( bool groupByBucket ) : IEnumerable
groupByBucket bool True if the UI is currently showing the transactions grouped by bucket, false if not.
Результат IEnumerable

PreparePersistentStateData() публичный Метод

Prepares the persistent state data to save to storage.
public PreparePersistentStateData ( ) : StatementApplicationState
Результат BudgetAnalyser.Engine.Statement.StatementApplicationState

RemoveTransaction() публичный Метод

Removes the provided transaction from the currently loaded Budget Analyser Statement.
public RemoveTransaction ( BudgetAnalyser.Engine.Statement.Transaction transactionToRemove ) : void
transactionToRemove BudgetAnalyser.Engine.Statement.Transaction The transaction to remove.
Результат void

SaveAsync() публичный Метод

Saves the application database asynchronously. This may be called using a background worker thread.
/// Unable to save transactions at this time, some data is invalid. + /// messages ///
public SaveAsync ( ApplicationDatabase applicationDatabase ) : System.Threading.Tasks.Task
applicationDatabase BudgetAnalyser.Engine.Persistence.ApplicationDatabase
Результат System.Threading.Tasks.Task

SavePreview() публичный Метод

Called before Save is called. This will be called on the UI Thread. Objects can optionally add some context data that will be passed to the SaveAsync method call. This can be used to finalise any edits or prompt the user for closing data, ie, a "what-did-you-change" comment; this can't be done during save as it may not be called using the UI Thread.
public SavePreview ( ) : void
Результат void

SplitTransaction() публичный Метод

Splits the provided transaction into two. The provided transactions is removed, and two new transactions are created. Both transactions must add up to the existing transaction amount.
///
public SplitTransaction ( BudgetAnalyser.Engine.Statement.Transaction originalTransaction, decimal splinterAmount1, decimal splinterAmount2, BudgetBucket splinterBucket1, BudgetBucket splinterBucket2 ) : void
originalTransaction BudgetAnalyser.Engine.Statement.Transaction
splinterAmount1 decimal
splinterAmount2 decimal
splinterBucket1 BudgetAnalyser.Engine.Budget.BudgetBucket
splinterBucket2 BudgetAnalyser.Engine.Budget.BudgetBucket
Результат void

TransactionManagerService() публичный Метод

Initializes a new instance of the TransactionManagerService class.
///
public TransactionManagerService ( [ bucketRepository, [ statementRepository, [ logger, [ monitorableDependencies ) : System
bucketRepository [ The bucket repository.
statementRepository [ The statement repository.
logger [ The logger.
monitorableDependencies [ The dependency monitor manager
Результат System

ValidateModel() публичный Метод

Validates the model owned by the service.
public ValidateModel ( StringBuilder messages ) : bool
messages StringBuilder
Результат bool

ValidateWithCurrentBudgetsAsync() публичный Метод

Validates the currently loaded StatementModel against the provided budgets and ensures all buckets used by the transactions exist in the budgets. This is performed asynchronously. This method can be called when a budget is loaded or changed or when a new Budget Analyser Statement is loaded.
public ValidateWithCurrentBudgetsAsync ( BudgetCollection budgets = null ) : Task
budgets BudgetCollection /// The current budgets. This must be provided at least once. It can be omitted when /// calling this method after the statement model has changed if the budget was previously provided. ///
Результат Task