diff --git a/Core/Core/Controllers/HistoryController.cs b/Core/Core/Controllers/HistoryController.cs index 4f67247848b6cfa43cc70de68277c799cc98a05b..40c0b72d7c1b269ba63cca271f63cda1f62b50bb 100644 --- a/Core/Core/Controllers/HistoryController.cs +++ b/Core/Core/Controllers/HistoryController.cs @@ -89,7 +89,7 @@ namespace Core.Controllers }; } - private List<TransactionContainer> MakeGroup(IQueryable<Tuple<double, AbstractConstantSymbolVariation>> transactions, double undeterminedAmount) + private List<TransactionContainer> MakeGroup(IQueryable<Tuple<double, AbstractConstantSymbolVariation>> transactions, double undeterminedAmount = 0) { const string labelUndefined = "Nezařazeno"; @@ -99,6 +99,9 @@ namespace Core.Controllers group.First().Item2 != null ? group.First().Item2.Value : labelUndefined )).ToList(); + if (undeterminedAmount == 0) + return list; + int index = list.FindIndex(t => t.name == labelUndefined); @@ -116,12 +119,21 @@ namespace Core.Controllers .Where(t => t.ConstantSymbol != null) .Select(t => new { t.Amount, t.ConstantSymbol }); - decimal undeterminedAmount = transactions.Where(t => t.ConstantSymbol == null || t.ConstantSymbol.LastNumber == null).Sum(t => t.Amount); - var paymentTypes = MakeGroup(symbols.Select(t => new Tuple<double, AbstractConstantSymbolVariation>((double)t.Amount, t.ConstantSymbol.LastNumber)), (double)undeterminedAmount); + //if reserved symbol = other symbols not possible + var reserved = symbols.Where(t => t.ConstantSymbol.ReservedSymbol != null); + var reservedSymbols = MakeGroup(reserved.Select(t => new Tuple<double, AbstractConstantSymbolVariation>((double)t.Amount, t.ConstantSymbol.ReservedSymbol))); + - undeterminedAmount = transactions.Where(t => t.ConstantSymbol == null || t.ConstantSymbol.MinistryPredefined == null).Sum(t => t.Amount); + decimal undeterminedAmount = transactions.Where(t => t.ConstantSymbol == null).Sum(t => t.Amount); + symbols = symbols.Where(t => t.ConstantSymbol.ReservedSymbol == null); + + //var paymentTypes = MakeGroup(symbols.Select(t => new Tuple<double, AbstractConstantSymbolVariation>((double)t.Amount, t.ConstantSymbol.LastNumber)), (double)undeterminedAmount); + var paymentTypes = MakeGroup(symbols.Select(t => new Tuple<double, AbstractConstantSymbolVariation>((double)t.Amount, t.ConstantSymbol.Kind)), (double)undeterminedAmount); var paymentCategories = MakeGroup(symbols.Select(t => new Tuple<double, AbstractConstantSymbolVariation>((double)t.Amount, t.ConstantSymbol.MinistryPredefined)), (double)undeterminedAmount); + paymentCategories.AddRange(reservedSymbols); + paymentTypes.AddRange(reservedSymbols); + return (paymentTypes, paymentCategories); }