Commit e1132f2
Changed files (6)
product
desktop.ui
product/desktop.ui/model/TaxesForIndividual.cs
@@ -1,44 +1,33 @@
using System;
using System.Collections.Generic;
+using solidware.financials.windows.ui.presenters;
namespace solidware.financials.windows.ui.model
{
public class TaxesForIndividual : Observable<TaxesForIndividual>
{
- public TaxesForIndividual(Guid id)
+ public TaxesForIndividual(Guid id, FederalTaxesViewModel federalTaxes)
{
+ FederalTaxes = federalTaxes;
Id = id;
ProvincialTaxesGrid = new List<TaxRow>
{
new TaxRow {Name = "john doe", Tax = 23456.09m},
new TaxRow {Name = "sally doe", Tax = 9456.09m},
};
- FederalTaxesGrid = new List<TaxRow>
- {
- new TaxRow {Name = "john doe", Tax = 23456.09m},
- new TaxRow {Name = "sally doe", Tax = 9456.09m},
- };
}
public Guid Id { get; private set; }
public decimal TotalIncome { get; private set; }
public decimal TotalFamilyIncome { get; private set; }
- public decimal FederalTaxes { get; private set; }
- public decimal FederalFamilyTaxes { get; private set; }
public IEnumerable<TaxRow> ProvincialTaxesGrid { get; private set; }
- public IEnumerable<TaxRow> FederalTaxesGrid { get; private set; }
+ public FederalTaxesViewModel FederalTaxes { get; set; }
public void AddIncome(decimal amount)
{
TotalIncome += amount;
- FederalTaxes = new FederalTaxes().CalculateFederalTaxesFor(TotalIncome);
- update(x => x.FederalTaxes, x => x.TotalIncome);
+ FederalTaxes.ChangeTotalIncomeTo(TotalIncome);
+ update(x => x.TotalIncome);
}
}
-
- public class TaxRow
- {
- public string Name { get; set; }
- public decimal Tax { get; set; }
- }
}
\ No newline at end of file
product/desktop.ui/model/TaxRow.cs
@@ -0,0 +1,8 @@
+namespace solidware.financials.windows.ui.model
+{
+ public class TaxRow
+ {
+ public string Name { get; set; }
+ public decimal Tax { get; set; }
+ }
+}
\ No newline at end of file
product/desktop.ui/presenters/FederalTaxesViewModel.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using solidware.financials.windows.ui.model;
+
+namespace solidware.financials.windows.ui.presenters
+{
+ public class FederalTaxesViewModel : Observable<FederalTaxesViewModel>
+ {
+ public FederalTaxesViewModel(Guid id)
+ {
+ Id = id;
+ FederalTaxesGrid = new List<TaxRow>
+ {
+ new TaxRow {Name = "john doe", Tax = 23456.09m},
+ new TaxRow {Name = "sally doe", Tax = 9456.09m},
+ };
+ }
+
+ public Guid Id { get; private set; }
+ public decimal FederalTaxes { get; set; }
+ public decimal FederalFamilyTaxes { get; private set; }
+ public IEnumerable<TaxRow> FederalTaxesGrid { get; private set; }
+
+ public void ChangeTotalIncomeTo(decimal totalIncome)
+ {
+ FederalTaxes = new FederalTaxes().CalculateFederalTaxesFor(totalIncome);
+ update(x => x.FederalTaxes);
+ }
+ }
+}
\ No newline at end of file
product/desktop.ui/presenters/TaxSummaryPresenter.cs
@@ -30,6 +30,7 @@ namespace solidware.financials.windows.ui.presenters
}
public TaxesForIndividual Selected { get; set; }
+ public FederalTaxesViewModel FederalTaxes { get { return Selected.FederalTaxes; } }
public void notify(IncomeMessage message)
{
@@ -45,7 +46,7 @@ namespace solidware.financials.windows.ui.presenters
TaxesForIndividual TaxesFor(Guid id)
{
if (!family.ContainsKey(id))
- family[id] = new TaxesForIndividual(id);
+ family[id] = new TaxesForIndividual(id, new FederalTaxesViewModel(id));
return family[id];
}
product/desktop.ui/views/TaxSummaryTab.xaml
@@ -5,16 +5,16 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d" >
<DockPanel MinWidth="1024">
- <StackPanel DataContext="{Binding Path=Selected}">
+ <StackPanel>
<StackPanel Margin="5,5,5,5">
<Label FontWeight="Bold">Income</Label>
<DockPanel>
<Label Width="100">Individual:</Label>
- <Label Content="{Binding Path=TotalIncome}" FontWeight="Bold"></Label>
+ <Label Content="{Binding Path=Selected.TotalIncome}" FontWeight="Bold"></Label>
</DockPanel>
<DockPanel>
<Label Width="100">Family:</Label>
- <Label Content="{Binding Path=TotalFamilyIncome}" FontWeight="Bold"></Label>
+ <Label Content="{Binding Path=Selected.TotalFamilyIncome}" FontWeight="Bold"></Label>
</DockPanel>
</StackPanel>
<DockPanel LastChildFill="False" HorizontalAlignment="Stretch">
@@ -33,13 +33,13 @@
</Expander>
<DockPanel>
<Label Width="100">Individual:</Label>
- <Label Content="{Binding Path=FederalTaxes}" FontWeight="Bold"/>
+ <Label Content="{Binding Path=FederalTaxes.FederalTaxes}" FontWeight="Bold"/>
</DockPanel>
<DockPanel>
<Label Width="100">Family:</Label>
- <Label Content="{Binding Path=FederalFamilyTaxes}" FontWeight="Bold"/>
+ <Label Content="{Binding Path=FederalTaxes.FederalFamilyTaxes}" FontWeight="Bold"/>
</DockPanel>
- <DataGrid Margin="5,5,5,5" ItemsSource="{Binding FederalTaxesGrid, Mode=OneWay}" IsReadOnly="True"></DataGrid>
+ <DataGrid Margin="5,5,5,5" ItemsSource="{Binding FederalTaxes.FederalTaxesGrid, Mode=OneWay}" IsReadOnly="True"></DataGrid>
</StackPanel>
<StackPanel Margin="5,5,5,5" Width="500">
<Label FontWeight="Bold">Provincial Taxes</Label>
@@ -53,13 +53,13 @@
</Expander>
<DockPanel>
<Label Width="100">Individual:</Label>
- <Label Content="{Binding Path=ProvincialTaxes}" FontWeight="Bold"/>
+ <Label Content="{Binding Path=Selected.ProvincialTaxes}" FontWeight="Bold"/>
</DockPanel>
<DockPanel>
<Label Width="100">Family:</Label>
- <Label Content="{Binding Path=FamilyProvincialTaxes}" FontWeight="Bold"/>
+ <Label Content="{Binding Path=Selected.FamilyProvincialTaxes}" FontWeight="Bold"/>
</DockPanel>
- <DataGrid Margin="5,5,5,5" ItemsSource="{Binding ProvincialTaxesGrid, Mode=OneWay}" IsReadOnly="true"></DataGrid>
+ <DataGrid Margin="5,5,5,5" ItemsSource="{Binding Selected.ProvincialTaxesGrid, Mode=OneWay}" IsReadOnly="true"></DataGrid>
</StackPanel>
</DockPanel>
</StackPanel>
product/desktop.ui/solidware.financials.csproj
@@ -125,6 +125,7 @@
<Compile Include="IObservableCommand.cs" />
<Compile Include="model\FederalTaxes.cs" />
<Compile Include="model\TaxesForIndividual.cs" />
+ <Compile Include="model\TaxRow.cs" />
<Compile Include="Observable.cs" />
<Compile Include="Presenter.cs" />
<Compile Include="PresenterFactory.cs" />
@@ -133,6 +134,7 @@
<Compile Include="ApplicationState.cs" />
<Compile Include="presenters\DisplayCanadianTaxInformationViewModel.cs" />
<Compile Include="model\PersonDetails.cs" />
+ <Compile Include="presenters\FederalTaxesViewModel.cs" />
<Compile Include="presenters\specifications\IfFamilyMemberIsSelected.cs" />
<Compile Include="presenters\ButtonBarPresenter.cs" />
<Compile Include="presenters\TaxSummaryPresenter.cs" />