Commit 26c0f97

mokhan <mokhan@ce5e1baf-6525-42e4-a1b2-857ea38da20a>
2009-04-30 19:05:45
git-svn-id: https://svn.xp-dev.com/svn/mokhan-mo.money@198 ce5e1baf-6525-42e4-a1b2-857ea38da20a
1 parent 34593ac
Changed files (6)
trunk/product/Gorilla.Commons.Utility/Date.cs
@@ -14,7 +14,7 @@ namespace Gorilla.Commons.Utility
             ticks = new DateTime(year, month, day).Ticks;
         }
 
-        public bool is_in(IYear the_year)
+        public bool is_in(Year the_year)
         {
             return the_year.represents(to_date_time());
         }
trunk/product/Gorilla.Commons.Utility/Gorilla.Commons.Utility.csproj
@@ -114,9 +114,9 @@
     <Compile Include="Extensions\TypeExtensions.cs" />
     <Compile Include="Extensions\TypeExtensionsSpecs.cs" />
     <Compile Include="Extensions\VisitorExtensions.cs" />
-    <Compile Include="IYear.cs" />
     <Compile Include="Percent.cs" />
     <Compile Include="PercentSpecs.cs" />
+    <Compile Include="Year.cs" />
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="..\Gorilla.Commons.Testing\Gorilla.Commons.Testing.csproj">
trunk/product/Gorilla.Commons.Utility/IYear.cs → trunk/product/Gorilla.Commons.Utility/Year.cs
@@ -2,14 +2,9 @@ using System;
 
 namespace Gorilla.Commons.Utility
 {
-    public interface IYear
+    public class Year
     {
-        bool represents(DateTime time);
-    }
-
-    public class Year : IYear
-    {
-        private readonly int the_underlying_year;
+        readonly int the_underlying_year;
 
         public Year(DateTime date)
         {
trunk/product/MoMoney.Domain/Accounting/Growth/IncomeExtensions.cs
@@ -1,19 +1,16 @@
 using System.Collections.Generic;
 using Gorilla.Commons.Utility;
+using Gorilla.Commons.Utility.Extensions;
 using MoMoney.Domain.Core;
 
 namespace MoMoney.Domain.Accounting.Growth
 {
-    public static class IncomeExtensions
+    static public class IncomeExtensions
     {
-        public static Money in_the(this IEnumerable<IIncome> income_collected, IYear year)
+        static public Money in_the(this IEnumerable<IIncome> income_collected, Year year)
         {
-            Money income_for_year = new Money(0);
-            foreach (var income in income_collected) {
-                if (income.date_of_issue.is_in(year)) {
-                    income_for_year = income_for_year.add(income.amount_tendered);
-                }
-            }
+            var income_for_year = new Money(0);
+            income_collected.each(x => { if (x.date_of_issue.is_in(year)) income_for_year = income_for_year.add(x.amount_tendered); });
             return income_for_year;
         }
     }
trunk/product/MoMoney.Domain/Accounting/AccountHolder.cs
@@ -13,7 +13,7 @@ namespace MoMoney.Domain.accounting
         void receive(IBill bill);
         void receive(IIncome income);
         IEnumerable<IBill> collect_all_the_unpaid_bills();
-        Money calculate_income_for(IYear year);
+        Money calculate_income_for(Year year);
     }
 
     [Serializable]
@@ -38,7 +38,7 @@ namespace MoMoney.Domain.accounting
             return all_bills.where(bill => bill.is_not_paid());
         }
 
-        public Money calculate_income_for(IYear year)
+        public Money calculate_income_for(Year year)
         {
             return income_collected.in_the(year);
         }
trunk/product/MoMoney.Domain/Core/DateExtensions.cs
@@ -5,7 +5,7 @@ namespace MoMoney.Domain.Core
 {
     public static class DateExtensions
     {
-        public static IYear as_a_year(this int year)
+        public static Year as_a_year(this int year)
         {
             return new Year(new DateTime(year, 01, 01));
         }