summaryrefslogtreecommitdiff
path: root/product/Domain/Accounting/AccountHolder.cs
blob: 228bfed61078fdd274a02dad0a474a0e313de8ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
using System.Collections.Generic;
using gorilla.commons.utility;
using Gorilla.Commons.Utility;
using MoMoney.Domain.Accounting;
using MoMoney.Domain.Core;

namespace MoMoney.Domain.accounting
{
    public interface IAccountHolder : IEntity
    {
        void receive(IBill bill);
        void receive(IIncome income);
        IEnumerable<IBill> collect_all_the_unpaid_bills();
        Money calculate_income_for(Year year);
    }

    [Serializable]
    public class AccountHolder : Entity<IAccountHolder>, IAccountHolder
    {
        IList<IBill> all_bills { get; set; }
        IList<IIncome> income_collected { get; set; }

        public AccountHolder()
        {
            all_bills = new List<IBill>();
            income_collected = new List<IIncome>();
        }

        public void receive(IBill bill)
        {
            all_bills.Add(bill);
        }

        public IEnumerable<IBill> collect_all_the_unpaid_bills()
        {
            return all_bills.where(bill => bill.is_not_paid());
        }

        public Money calculate_income_for(Year year)
        {
            return income_collected.in_the(year);
        }

        public void receive(IIncome income)
        {
            income_collected.Add(income);
        }
    }
}