public void TestInitialise() { this.testData = new FixedBudgetProjectBucket(FixedProjectCode, "Foo bar dum-de-dum", 1000); PrivateAccessor.SetProperty(this.testData, "Created", this.testDataCreatedDate); var subject = new Mapper_BudgetBucketDto_BudgetBucket(new BudgetBucketFactory()); this.result = subject.ToDto(this.testData); }
/// <summary> /// Validates the bucket provided is valid for use with this LedgerBucket. There is an explicit relationship between /// <see cref="BudgetBucket" />s and <see cref="LedgerBucket" />s. /// </summary> /// <exception cref="System.NotSupportedException"> /// Invalid budget bucket used, only Spent-Monthly-Expense-Bucket can be /// used with an instance of Spent-Monthly-Ledger. /// </exception> protected override void ValidateBucketSet(BudgetBucket bucket) { if (bucket is SpentMonthlyExpenseBucket) { return; } throw new NotSupportedException( "Invalid budget bucket used, only Spent-Monthly-Expense-Bucket can be used with an instance of Spent-Monthly-Ledger."); }
/// <summary> /// Validates the bucket provided is valid for use with this LedgerBucket. There is an explicit relationship between /// <see cref="BudgetBucket" />s and <see cref="LedgerBucket" />s. /// </summary> /// <exception cref="System.NotSupportedException"> /// Invalid budget bucket used, only the Surplus bucket can be used with an /// instance of Surplus-Ledger. /// </exception> protected override void ValidateBucketSet(BudgetBucket bucket) { if (bucket is SurplusBucket) { return; } throw new NotSupportedException( "Invalid budget bucket used, only the Surplus bucket can be used with an instance of Surplus-Ledger."); }
public bool OfSameBucketFamily(BudgetBucket bucket1, BudgetBucket bucket2) { // TODO is this the same as BucketComparer? if (bucket1 is SurplusBucket && bucket2 is SurplusBucket) { // All surplus subclasses are considered a subset of Surplus. return true; } return bucket1 == bucket2; }
public void TestInitialise() { this.testData = new FixedBudgetBucketDto { Code = FixedBudgetProjectBucket.CreateCode(TestDataCode), Description = "Foo bar tiddle-de-dum", FixedBudgetAmount = 2000 }; var subject = new Mapper_BudgetBucketDto_BudgetBucket(new BudgetBucketFactory()); this.result = subject.ToModel(this.testData); }
public bool OfSameBucketFamily(BudgetBucket bucket1, BudgetBucket bucket2) { // TODO is this the same as BucketComparer? if (bucket1 is SurplusBucket && bucket2 is SurplusBucket) { // All surplus subclasses are considered a subset of Surplus. return(true); } return(bucket1 == bucket2); }
/// <summary> /// Validates the bucket provided is valid for use with this LedgerBucket. There is an explicit relationship between /// <see cref="BudgetBucket" />s and <see cref="LedgerBucket" />s. /// </summary> /// <exception cref="System.NotSupportedException"> /// Invalid budget bucket used, only Saved-Up-For-Expense-Buckets or /// Savings-Commitment-Buckets can be used with an instance of Saved-Up-For-Ledger. /// </exception> protected override void ValidateBucketSet(BudgetBucket bucket) { if (bucket is SavedUpForExpenseBucket) { return; } if (bucket is SavingsCommitmentBucket) { return; } throw new NotSupportedException( "Invalid budget bucket used, only Saved-Up-For-Expense-Buckets or Savings-Commitment-Buckets can be used with an instance of Saved-Up-For-Ledger."); }
public RulesGroupedByBucket([NotNull] BudgetBucket bucket, [NotNull] IEnumerable<MatchingRule> rules) { if (bucket == null) { throw new ArgumentNullException("bucket"); } if (rules == null) { throw new ArgumentNullException("rules"); } this.doNotUseBucket = bucket; this.doNotUseRules = new ObservableCollection<MatchingRule>(rules.ToList()); }
public void ShowDialog(Transaction transaction, Guid correlationId) { Transaction = transaction; this.originalBucket = Transaction.BudgetBucket; Buckets = this.bucketRepo.Buckets.Where(b => b.Active); MessengerInstance.Send( new ShellDialogRequestMessage( BudgetAnalyserFeature.Transactions, this, ShellDialogType.SaveCancel) { CorrelationId = correlationId, Title = "Edit Transaction" }); }
/// <summary> /// Adds the bucket. /// </summary> /// <exception cref="ArgumentNullException"></exception> protected void AddBucket([NotNull] BudgetBucket bucket) { if (bucket == null) { throw new ArgumentNullException(nameof(bucket)); } if (IsValidCode(bucket.Code)) { return; } lock (this.syncRoot) { if (IsValidCode(bucket.Code)) { return; } this.lookupTable.Add(bucket.Code, bucket); } }
private void OnShellDialogResponseReceived(ShellDialogResponseMessage message) { if (!message.IsItForMe(this.dialogCorrelationId)) { return; } ResetFilter(); if (message.Response == ShellDialogButton.Cancel) { Selected = null; } CompleteSelection(); }
private static Func<BudgetModel, decimal> BuildIncomeFinder(BudgetBucket bucket) { return b => { var first = b.Incomes.FirstOrDefault(e => e.Bucket == bucket); if (first == null) { return 0; } return first.Amount; }; }
private static bool AddSelectedCommandCanExecute(BudgetBucket parameter) { return parameter != null; }
private void OnRemoveSelectedCommandExecute(BudgetBucket parameter) { SelectedBuckets.Remove(parameter); UnselectedBuckets.Add(parameter); }
public TransactionGroupedByBucket(IEnumerable<Transaction> transactions, BudgetBucket groupByThisBucket) { Bucket = groupByThisBucket; Transactions = new ObservableCollection<Transaction>(transactions.Where(t => t.BudgetBucket == groupByThisBucket).OrderBy(t => t.Date)); }
/// <summary> /// Initialises the mandatory special buckets. /// </summary> protected void InitialiseMandatorySpecialBuckets() { SurplusBucket = new SurplusBucket(); AddBucket(SurplusBucket); AddBucket(new PayCreditCardBucket(PayCreditCardBucket.PayCreditCardCode, "A special bucket to allocate internal transfers.")); }
public BudgetBucketChosenEventArgs(Guid correlationId, BudgetBucket bucket) : this(correlationId, false) { SelectedBucket = bucket; }
private static decimal GetLedgerBalanceForBucket(BudgetModel budgetModel, LedgerEntryLine applicableLine, BudgetBucket bucket) { if (bucket is SurplusBucket) { return applicableLine.CalculatedSurplus; } var ledger = applicableLine.Entries.FirstOrDefault(e => e.LedgerBucket.BudgetBucket == bucket); if (ledger != null) { return ledger.Balance; } // The Ledger line might not actually have a ledger for the given bucket. return GetBudgetModelTotalForBucket(budgetModel, bucket); }
public BudgetBucketChosenEventArgs(Guid correlationId, BudgetBucket bucket, Account storeInThisAccount) : this(correlationId, bucket) { StoreInThisAccount = storeInThisAccount; }
/// <summary> /// Validates the bucket provided is valid for use with this LedgerBucket. There is an explicit relationship between /// <see cref="BudgetBucket" />s and <see cref="LedgerBucket" />s. /// </summary> protected abstract void ValidateBucketSet(BudgetBucket bucket);
/// <summary> /// 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. /// </summary> /// <exception cref="System.ArgumentNullException"> /// </exception> public void SplitTransaction(Transaction originalTransaction, decimal splinterAmount1, decimal splinterAmount2, BudgetBucket splinterBucket1, BudgetBucket splinterBucket2) { if (originalTransaction == null) { throw new ArgumentNullException(nameof(originalTransaction)); } if (splinterBucket1 == null) { throw new ArgumentNullException(nameof(splinterBucket1)); } if (splinterBucket2 == null) { throw new ArgumentNullException(nameof(splinterBucket2)); } StatementModel.SplitTransaction( originalTransaction, splinterAmount1, splinterAmount2, splinterBucket1, splinterBucket2); }
private static decimal GetBudgetModelTotalForBucket(BudgetModel budgetModel, BudgetBucket bucket) { if (bucket is PayCreditCardBucket) { // Ignore return 0; } if (bucket is IncomeBudgetBucket) { throw new InvalidOperationException( "Code Error: Income bucket detected when Bucket Spending only applies to Expenses."); } // Use budget values instead if (bucket is SurplusBucket) { return budgetModel.Surplus; } var budget = budgetModel.Expenses.FirstOrDefault(e => e.Bucket == bucket); if (budget != null) { return budget.Amount; } return 0; }
public void ShowDialog(Transaction originalTransaction, Guid correlationId) { BudgetBuckets = bucketRepo.Buckets; this.dialogCorrelationId = correlationId; OriginalTransaction = originalTransaction; SplinterAmount1 = OriginalTransaction.Amount; SplinterAmount2 = 0M; SplinterBucket2 = SplinterBucket1 = OriginalTransaction.BudgetBucket; var dialogRequest = new ShellDialogRequestMessage(BudgetAnalyserFeature.Transactions, this, ShellDialogType.SaveCancel) { CorrelationId = correlationId, Title = "Split Transaction", }; MessengerInstance.Send(dialogRequest); }
internal override void SplitTransaction(Transaction originalTransaction, decimal splinterAmount1, decimal splinterAmount2, BudgetBucket splinterBucket1, BudgetBucket splinterBucket2) { SplitTransactionWasCalled++; }
private BurnDownChartAnalyserResult AnalyseDataForChart(StatementModel statementModel, BudgetModel budgetModel, LedgerBook ledgerBookModel, BudgetBucket bucket, DateTime beginDate) { var analyser = this.chartAnalyserFactory(); var result = analyser.Analyse(statementModel, budgetModel, new[] { bucket }, ledgerBookModel, beginDate); return result; }
private void OnAddSelectedCommandExecute(BudgetBucket parameter) { this.UnselectedBuckets.Remove(parameter); this.SelectedBuckets.Add(parameter); }
private static decimal GetLedgerBalance(LedgerEntryLine applicableLine, BudgetBucket bucket) { if (applicableLine == null) { return -1; } if (bucket is SurplusBucket) { return applicableLine.CalculatedSurplus; } LedgerEntry ledger = applicableLine.Entries.FirstOrDefault(e => e.LedgerColumn.BudgetBucket == bucket); if (ledger != null) { return ledger.Balance; } return -1; }
protected void InitialiseMandatorySpecialBuckets() { SurplusBucket = new SurplusBucket(); AddBucket(SurplusBucket); AddBucket(new JournalBucket(JournalBucket.JournalCode, "A special bucket to allocate internal transfers.")); }