Commit ec400fa

mo <email@solidware.ca>
2011-03-18 04:21:14
create class for calculate federal taxes.
1 parent dcfbbb4
product/desktop.ui/bootstrappers/ComposeShell.cs
@@ -39,7 +39,7 @@ namespace solidware.financials.windows.ui.bootstrappers
         void launch<Presenter, Dialog>() where Presenter : DialogPresenter
             where Dialog : FrameworkElement, Dialog<Presenter>, new()
         {
-            controller.launch_dialog<Presenter, Dialog>();
+            controller.launch<Presenter, Dialog>();
         }
     }
 }
\ No newline at end of file
product/desktop.ui/model/FederalTaxes.cs
@@ -0,0 +1,27 @@
+namespace solidware.financials.windows.ui.model
+{
+    public class FederalTaxes
+    {
+        public decimal CalculateFederalTaxesFor(decimal totalIncome)
+        {
+            var taxes = 0m;
+            if (totalIncome <= 41544.00m)
+            {
+                taxes = ((totalIncome - 0m)*0.15m) + 0m;
+            }
+            if (totalIncome > 41544.00m && totalIncome <= 83088.00m)
+            {
+                taxes = ((totalIncome - 41544m)*0.22m) + 6232m;
+            }
+            if (totalIncome > 83088.00m && totalIncome <= 128800.00m)
+            {
+                taxes = ((totalIncome - 83088m)*0.26m) + 15371m;
+            }
+            if (totalIncome > 128800.00m)
+            {
+                taxes = ((totalIncome - 128800m)*0.29m) + 27256m;
+            }
+            return taxes;
+        }
+    }
+}
\ No newline at end of file
product/desktop.ui/model/TaxesForIndividual.cs
@@ -1,30 +1,24 @@
-namespace solidware.financials.windows.ui.model
+using System;
+
+namespace solidware.financials.windows.ui.model
 {
     public class TaxesForIndividual : Observable<TaxesForIndividual>
     {
+        public TaxesForIndividual(Guid id)
+        {
+            Id = id;
+        }
+
+        public Guid Id { get; private set; }
         public decimal TotalIncome { get; private set; }
-        public decimal Taxes { get; private set; }
+        public decimal FederalTaxes { get; private set; }
 
         public void AddIncome(decimal amount)
         {
             TotalIncome += amount;
-            if (TotalIncome <= 41544.00m)
-            {
-                Taxes = ((TotalIncome - 0m)*0.15m) + 0m;
-            }
-            if (TotalIncome > 41544.00m && TotalIncome <= 83088.00m)
-            {
-                Taxes = ((TotalIncome - 41544m)*0.22m) + 6232m;
-            }
-            if (TotalIncome > 83088.00m && TotalIncome <= 128800.00m)
-            {
-                Taxes = ((TotalIncome - 83088m)*0.26m) + 15371m;
-            }
-            if (TotalIncome > 128800.00m)
-            {
-                Taxes = ((TotalIncome - 128800m)*0.29m) + 27256m;
-            }
-            update(x => x.Taxes, x => x.TotalIncome);
+            FederalTaxes = new FederalTaxes().CalculateFederalTaxesFor(TotalIncome);
+            update(x => x.FederalTaxes, x => x.TotalIncome);
         }
+
     }
 }
\ No newline at end of file
product/desktop.ui/presenters/TaxSummaryPresenter.cs
@@ -35,7 +35,7 @@ namespace solidware.financials.windows.ui.presenters
         public void notify(SelectedFamilyMember message)
         {
             if (!family.ContainsKey(message.id))
-                family[message.id] = new TaxesForIndividual();
+                family[message.id] = new TaxesForIndividual(message.id);
             Selected = family[message.id];
             update(x => x.Selected);
         }
product/desktop.ui/Properties/AssemblyInfo.cs
@@ -1,6 +1,4 @@
 using System.Reflection;
-using System.Resources;
-using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 using System.Windows;
 
@@ -51,5 +49,5 @@ using System.Windows;
 // You can specify all the values or you can default the Build and Revision Numbers 
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("2011.3.17.1758")]
-[assembly: AssemblyFileVersion("2011.3.17.1758")]
+[assembly: AssemblyVersion("2011.3.17.2218")]
+[assembly: AssemblyFileVersion("2011.3.17.2218")]
product/desktop.ui/Properties/AssemblyInfo.cs.template
@@ -1,6 +1,4 @@
 using System.Reflection;
-using System.Resources;
-using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 using System.Windows;
 
product/desktop.ui/views/TaxSummaryTab.xaml
@@ -4,19 +4,23 @@
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
              mc:Ignorable="d" >
-    <StackPanel DataContext="{Binding Path=Selected}">
-        <Label>Tax Summary</Label>
-        <Label>Federal Tax Rates for 2011</Label>
-        <TextBlock>
-    * 15% on the first $41,544 of taxable income, +
-    * 22% on the next $41,544 of taxable income (on the portion of taxable income between $41,544 and $83,088), +
-    * 26% on the next $45,712 of taxable income (on the portion of taxable income between $83,088 and $128,800), +
-    * 29% of taxable income over $128,800.
-        </TextBlock>
-        <Label>Total Income:</Label>
-        <Label Content="{Binding Path=TotalIncome}"></Label>
-        
-        <Label>Total Taxes:</Label>
-        <Label Content="{Binding Path=Taxes}"></Label>
+    <StackPanel>
+        <StackPanel DataContext="{Binding Path=Selected}">
+            <Label>Total Income:</Label>
+            <Label>Federal Tax Rates for 2011</Label>
+            <ListView>
+                <ListViewItem> * 15% on the first $41,544 of taxable income, + </ListViewItem>
+                <ListViewItem> * 22% on the next $41,544 of taxable income (on the portion of taxable income between $41,544 and $83,088), + </ListViewItem>
+                <ListViewItem> * 26% on the next $45,712 of taxable income (on the portion of taxable income between $83,088 and $128,800), + </ListViewItem>
+                <ListViewItem> * 29% of taxable income over $128,800. </ListViewItem>
+            </ListView>
+            <Label Content="{Binding Path=TotalIncome}"></Label>
+            <Label>Federal Taxes:</Label>
+            <Label Content="{Binding Path=FederalTaxes}"></Label>
+            <Label>Provincial Tax Rates for 2011</Label>
+            <ListView>
+                <ListViewItem> * 10% of taxable income </ListViewItem>
+            </ListView>
+        </StackPanel>
     </StackPanel>
 </UserControl>
product/desktop.ui/ApplicationController.cs
@@ -10,9 +10,4 @@ namespace solidware.financials.windows.ui
         void load_region<Presenter, Region>() where Presenter : ui.Presenter
             where Region : FrameworkElement, View<Presenter>, new();
     }
-
-    public interface DialogLauncher
-    {
-        void launch_dialog<Presenter, Dialog>() where Presenter : DialogPresenter where Dialog : FrameworkElement, Dialog<Presenter>, new();
-    }
 }
\ No newline at end of file
product/desktop.ui/DialogLauncher.cs
@@ -0,0 +1,9 @@
+using System.Windows;
+
+namespace solidware.financials.windows.ui
+{
+    public interface DialogLauncher
+    {
+        void launch<Presenter, Dialog>() where Presenter : DialogPresenter where Dialog : FrameworkElement, Dialog<Presenter>, new();
+    }
+}
\ No newline at end of file
product/desktop.ui/solidware.financials.csproj
@@ -15,6 +15,21 @@
     <FileAlignment>512</FileAlignment>
     <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
     <WarningLevel>4</WarningLevel>
+    <PublishUrl>publish\</PublishUrl>
+    <Install>true</Install>
+    <InstallFrom>Disk</InstallFrom>
+    <UpdateEnabled>false</UpdateEnabled>
+    <UpdateMode>Foreground</UpdateMode>
+    <UpdateInterval>7</UpdateInterval>
+    <UpdateIntervalUnits>Days</UpdateIntervalUnits>
+    <UpdatePeriodically>false</UpdatePeriodically>
+    <UpdateRequired>false</UpdateRequired>
+    <MapFileExtensions>true</MapFileExtensions>
+    <ApplicationRevision>0</ApplicationRevision>
+    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
+    <IsWebBootstrapper>false</IsWebBootstrapper>
+    <UseApplicationTrust>false</UseApplicationTrust>
+    <BootstrapperEnabled>true</BootstrapperEnabled>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
     <PlatformTarget>x86</PlatformTarget>
@@ -79,11 +94,13 @@
     <Compile Include="bootstrappers\WireUpSubscribers.cs" />
     <Compile Include="CancelCommand.cs" />
     <Compile Include="Dialog.cs" />
+    <Compile Include="DialogLauncher.cs" />
     <Compile Include="DialogPresenter.cs" />
     <Compile Include="events\SelectedFamilyMember.cs" />
     <Compile Include="events\UpdateOnLongRunningProcess.cs" />
     <Compile Include="handlers\PublishEventHandler.cs" />
     <Compile Include="IObservableCommand.cs" />
+    <Compile Include="model\FederalTaxes.cs" />
     <Compile Include="model\TaxesForIndividual.cs" />
     <Compile Include="Observable.cs" />
     <Compile Include="Presenter.cs" />
@@ -217,7 +234,28 @@
       <Name>service</Name>
     </ProjectReference>
   </ItemGroup>
-  <ItemGroup />
+  <ItemGroup>
+    <BootstrapperPackage Include=".NETFramework,Version=v4.0,Profile=Client">
+      <Visible>False</Visible>
+      <ProductName>Microsoft .NET Framework 4 Client Profile %28x86 and x64%29</ProductName>
+      <Install>true</Install>
+    </BootstrapperPackage>
+    <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
+      <Visible>False</Visible>
+      <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
+      <Install>false</Install>
+    </BootstrapperPackage>
+    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
+      <Visible>False</Visible>
+      <ProductName>.NET Framework 3.5 SP1</ProductName>
+      <Install>false</Install>
+    </BootstrapperPackage>
+    <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
+      <Visible>False</Visible>
+      <ProductName>Windows Installer 3.1</ProductName>
+      <Install>true</Install>
+    </BootstrapperPackage>
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
        Other similar extension points exist, see Microsoft.Common.targets.
product/desktop.ui/WPFApplicationController.cs
@@ -29,14 +29,11 @@ namespace solidware.financials.windows.ui
                                                                }));
         }
 
-        public void launch_dialog<Presenter, Dialog>() where Presenter : DialogPresenter where Dialog : FrameworkElement, Dialog<Presenter>, new()
+        public void launch<Presenter, Dialog>() where Presenter : DialogPresenter where Dialog : FrameworkElement, Dialog<Presenter>, new()
         {
             var presenter = factory.create<Presenter>();
             var dialog = new Dialog {DataContext = presenter};
-            presenter.close = () =>
-            {
-                dialog.Close();
-            };
+            presenter.close = () => dialog.Close();
             presenter.present();
             dialog.open();
         }
support/default.build
@@ -87,4 +87,8 @@
     <property name="target" value="${src.dir}/desktop.ui/Properties/AssemblyInfo.cs" />
     <call target="expand.template.file" />
   </target>
+
+  <target name="run" depends="compile">
+    <exec program="${tmp.dir}/solidware.financials.exe" />
+  </target>
 </project>