fix
This commit is contained in:
@@ -194,4 +194,66 @@ public class AccountRepository : AppRepository<Account>, IAccountRepository
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<MotionTotalSimple> GetIncomeByCategories(Guid userId, DateTime from, DateTime to)
|
||||
{
|
||||
return _context.Motions
|
||||
.Where(x => x.DateTime >= from && x.DateTime <= to)
|
||||
.Where(x => x.Item.Category!.UserId == userId)
|
||||
.Where(x => !x.Item.Category!.IsInternal)
|
||||
.GroupBy(x => new { x.Item.CategoryId, x.Item.Category!.Name })
|
||||
.Select(x => new MotionTotalSimple
|
||||
{
|
||||
Id = x.Key.CategoryId,
|
||||
Name = x.Key.Name,
|
||||
Amount = x.Sum(a => a.AmountPlus)
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
public List<MotionTotalSimple> GetIncomeByCategory(Guid userId, Guid categoryId, DateTime from, DateTime to)
|
||||
{
|
||||
return _context.Motions
|
||||
.Where(x => x.DateTime >= from && x.DateTime <= to)
|
||||
.Where(x => x.Item.CategoryId == categoryId)
|
||||
.Where(x => !x.Item.Category!.IsInternal)
|
||||
.Where(x => x.Item.Category!.UserId == userId)
|
||||
.GroupBy(x => new { Id = x.Item.ItemGlobalId, x.Item.ItemGlobal.Name })
|
||||
.Select(x => new MotionTotalSimple
|
||||
{
|
||||
Name = x.Key.Name,
|
||||
Amount = x.Sum(a => a.AmountPlus),
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
|
||||
public List<MotionTotalSimple> GetOutcomeByCategories(Guid userId, DateTime from, DateTime to)
|
||||
{
|
||||
return _context.Motions
|
||||
.Where(x => x.DateTime >= from && x.DateTime <= to)
|
||||
.Where(x => x.Item.Category!.UserId == userId)
|
||||
.Where(x => !x.Item.Category!.IsInternal)
|
||||
.GroupBy(x => new { x.Item.CategoryId, x.Item.Category!.Name })
|
||||
.Select(x => new MotionTotalSimple
|
||||
{
|
||||
Id = x.Key.CategoryId,
|
||||
Name = x.Key.Name,
|
||||
Amount = x.Sum(a => a.AmountMinus)
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
|
||||
public List<MotionTotalSimple> GetOutcomeByCategory(Guid userId, Guid categoryId, DateTime from, DateTime to)
|
||||
{
|
||||
return _context.Motions
|
||||
.Where(x => x.DateTime >= from && x.DateTime <= to)
|
||||
.Where(x => x.Item.CategoryId == categoryId)
|
||||
.Where(x => !x.Item.Category!.IsInternal)
|
||||
.Where(x => x.Item.Category!.UserId == userId)
|
||||
.GroupBy(x => new { Id = x.Item.ItemGlobalId, x.Item.ItemGlobal.Name })
|
||||
.Select(x => new MotionTotalSimple
|
||||
{
|
||||
Name = x.Key.Name,
|
||||
Amount = x.Sum(a => a.AmountMinus)
|
||||
}).ToList();
|
||||
}
|
||||
}
|
||||
@@ -18,4 +18,8 @@ public interface IAccountRepository
|
||||
decimal GetPeriodIncome(Guid userId, DateTime from, DateTime to);
|
||||
decimal GetPeriodOutcome(Guid userId, DateTime from, DateTime to);
|
||||
List<AccountSimple> GetRestAtDate(Guid userId, DateTime date);
|
||||
List<MotionTotalSimple> GetIncomeByCategories(Guid userId, DateTime from, DateTime to);
|
||||
List<MotionTotalSimple> GetIncomeByCategory(Guid userId, Guid categoryId, DateTime from, DateTime to);
|
||||
List<MotionTotalSimple> GetOutcomeByCategories(Guid userId, DateTime from, DateTime to);
|
||||
List<MotionTotalSimple> GetOutcomeByCategory(Guid userId, Guid categoryId, DateTime from, DateTime to);
|
||||
}
|
||||
Reference in New Issue
Block a user