public static MoneyBag MoneyBagForTag(this TranWithTags tran, Account tag) { if (!tran.CollectionContainsTag(tag)) { return(null); } var result = new MoneyBag(); switch (tran.Operation) { case OperationType.Доход: return(new MoneyBag(new Money(tran.Currency.GetValueOrDefault(), tran.Amount))); case OperationType.асход: return(new MoneyBag(new Money(tran.Currency.GetValueOrDefault(), -tran.Amount))); case OperationType.Перенос: return(null); case OperationType.Обмен: result = result - new Money(tran.Currency.GetValueOrDefault(), tran.Amount); result = result + new Money(tran.CurrencyInReturn.GetValueOrDefault(), tran.AmountInReturn); return(result); default: return(null); } }
public static decimal AmountForTag(this TranWithTags tran, Account tag, CurrencyCodes?currency) { switch (tran.Operation) { case OperationType.Доход: return(tran.CollectionContainsTag(tag) && tran.Currency == currency ? tran.Amount : 0); case OperationType.асход: return(tran.CollectionContainsTag(tag) && tran.Currency == currency ? -tran.Amount : 0); case OperationType.Перенос: return(0); case OperationType.Обмен: return(0); default: return(0); } }