C# Class BudgetAnalyser.Engine.Services.TransactionManagerService

Inheritance: ITransactionManagerService, ISupportsModelPersistence
Mostrar archivo Open project: Benrnz/BudgetAnalyser Class Usage Examples

Public Methods

Method Description
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.

Private Methods

Method Description
MatchTransactionText ( BudgetAnalyser.Engine.Statement.Transaction t, string textFilter ) : bool
NewDataAvailable ( ) : void
ResetTransactionsCollection ( ) : void

Method Details

ClearBucketAndTextFilters() public method

Clears the bucket and text filters.
public ClearBucketAndTextFilters ( ) : ObservableCollection
return ObservableCollection

Close() public method

Closes the currently loaded file. No warnings will be raised if there is unsaved data.
public Close ( ) : void
return void

CreateAsync() public method

Create a new StatementModel.
public CreateAsync ( ApplicationDatabase applicationDatabase ) : System.Threading.Tasks.Task
applicationDatabase BudgetAnalyser.Engine.Persistence.ApplicationDatabase
return System.Threading.Tasks.Task

DetectDuplicateTransactions() public method

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
return string

FilterByBucket() public method

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. ///
return ObservableCollection

FilterBySearchText() public method

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.
return ObservableCollection

FilterTransactions() public method

Filters the transactions using the filter object provided.
public FilterTransactions ( GlobalFilterCriteria criteria ) : void
criteria GlobalFilterCriteria
return void

FilterableBuckets() public method

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
return IEnumerable

ImportAndMergeBankStatementAsync() public method

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
return System.Threading.Tasks.Task

Initialise() public method

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.
return void

LoadAsync() public method

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
return System.Threading.Tasks.Task

PopulateGroupByBucketCollection() public method

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.
return IEnumerable

PreparePersistentStateData() public method

Prepares the persistent state data to save to storage.
public PreparePersistentStateData ( ) : StatementApplicationState
return BudgetAnalyser.Engine.Statement.StatementApplicationState

RemoveTransaction() public method

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.
return void

SaveAsync() public method

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
return System.Threading.Tasks.Task

SavePreview() public method

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
return void

SplitTransaction() public method

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
return void

TransactionManagerService() public method

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
return System

ValidateModel() public method

Validates the model owned by the service.
public ValidateModel ( StringBuilder messages ) : bool
messages StringBuilder
return bool

ValidateWithCurrentBudgetsAsync() public method

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. ///
return Task