Пример #1
0
        public IEnumerable <IOutgoingTax> GetOutgoingTaxes(IOutgoingTaxFilter outgoingPaymentFilter)
        {
            Expression <Func <IOutgoingTax, bool> > predicate = tax => IsPaymentMatch(outgoingPaymentFilter, tax) &&
                                                                IsTypeMatch(outgoingPaymentFilter, tax);

            return(dataStore.OutgoingTaxes.AsQueryable().Where(predicate.Compile()));
        }
 private IObservable <OutgoingTaxesResult> CreateOutgoingTaxesObservable(IObservable <OutgoingPaymentsResult> outgoingPaymentsObservable)
 {
     return(outgoingPaymentsObservable
            .Select(paymentsResult =>
     {
         IOutgoingTaxFilter outgoingTaxFilter = CreateOutgoingTaxFilter(paymentsResult.OutgoingPayments.Select(payment => payment.Id));
         IReadOnlyCollection <IOutgoingTax> outgoingTaxes = outgoingTaxRepository.GetOutgoingTaxes(outgoingTaxFilter).ToList();
         return new OutgoingTaxesResult(outgoingTaxFilter, outgoingTaxes);
     }));
 }
 private IObservable <OutgoingTaxesResult> CreateOutgoingTaxesObservable()
 {
     return(Observable.Return(GetSelectedIds(outgoingPaymentIdList))
            .Select(paymentIds =>
     {
         IOutgoingTaxFilter outgoingTaxFilter = CreateOutgoingTaxFilter(paymentIds);
         IReadOnlyCollection <IOutgoingTax> outgoingTaxes = outgoingTaxRepository.GetOutgoingTaxes(outgoingTaxFilter).ToList();
         return new OutgoingTaxesResult(outgoingTaxFilter, outgoingTaxes);
     }));
 }
Пример #4
0
        private static IDictionary <string, float> GetAmountPercentData(IReadOnlyCollection <IOutgoingTax> outgoingTaxes, IOutgoingTaxFilter outgoingTaxFilter)
        {
            Dictionary <string, List <IOutgoingTax> > outgoingTaxesWithType = outgoingTaxFilter.Types.ToDictionary(type => type.ToString(), type => outgoingTaxes.Where(tax => tax.Type == type).ToList());
            float totalAmount = outgoingTaxesWithType.Sum(taxGroup => taxGroup.Value.Sum(tax => tax.Amount));

            return(outgoingTaxesWithType.ToDictionary(taxGroup => taxGroup.Key, taxGroup => taxGroup.Value.Sum(tax => tax.Amount) * 100 / totalAmount));
        }
Пример #5
0
 public IChartPairData GetChartData(IReadOnlyCollection <IOutgoingTax> outgoingTaxes, IOutgoingTaxFilter outgoingTaxFilter)
 {
     return(new ChartPairData
     {
         Ids = outgoingTaxes.Select(tax => tax.Id).ToList(),
         AmountPercentData = GetAmountPercentData(outgoingTaxes, outgoingTaxFilter),
         AmountDateData = GetAmountTimeData(outgoingTaxes, outgoingTaxFilter)
     });
 }
Пример #6
0
 public OutgoingTaxesResult(IOutgoingTaxFilter outgoingTaxFilter, IReadOnlyCollection <IOutgoingTax> outgoingTaxes)
 {
     OutgoingTaxFilter = outgoingTaxFilter;
     OutgoingTaxes     = outgoingTaxes;
 }
Пример #7
0
 private static bool IsTypeMatch(IOutgoingTaxFilter taxFilter, IOutgoingTax tax)
 {
     return(taxFilter.Types.Contains(tax.Type));
 }