Commit 145f304
Changed files (2)
product
desktop.ui
model
presenters
product/desktop.ui/model/TaxesForIndividual.cs
@@ -2,7 +2,29 @@
{
public class TaxesForIndividual : Observable<TaxesForIndividual>
{
- public decimal TotalIncome { get; set; }
- public decimal Taxes { get; set; }
+ public decimal TotalIncome { get; private set; }
+ public decimal Taxes { 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);
+ }
}
}
\ No newline at end of file
product/desktop.ui/presenters/TaxSummaryPresenter.cs
@@ -29,36 +29,17 @@ namespace desktop.ui.presenters
public void notify(AddIncomeCommandMessage message)
{
- Selected.TotalIncome += message.amount;
- if (Selected.TotalIncome <= 41544.00m)
- {
- Selected.Taxes = ((Selected.TotalIncome - 0m)*0.15m) + 0m;
- }
- if (Selected.TotalIncome > 41544.00m && Selected.TotalIncome <= 83088.00m)
- {
- Selected.Taxes = ((Selected.TotalIncome - 41544m)*0.22m) + 6232m;
- }
- if (Selected.TotalIncome > 83088.00m && Selected.TotalIncome <= 128800.00m)
- {
- Selected.Taxes = ((Selected.TotalIncome - 83088m)*0.26m) + 15371m;
- }
- if (Selected.TotalIncome > 128800.00m)
- {
- Selected.Taxes = ((Selected.TotalIncome - 128800m)*0.29m) + 27256m;
- }
- Selected.update(x => x.Taxes, x => x.TotalIncome);
+ Selected.AddIncome(message.amount);
}
public void notify(SelectedFamilyMember message)
{
- if (!people.ContainsKey(message.id))
- {
- people[message.id] = new TaxesForIndividual();
- }
- Selected = people[message.id];
+ if (!family.ContainsKey(message.id))
+ family[message.id] = new TaxesForIndividual();
+ Selected = family[message.id];
update(x => x.Selected);
}
- IDictionary<Guid, TaxesForIndividual> people = new Dictionary<Guid, TaxesForIndividual>();
+ IDictionary<Guid, TaxesForIndividual> family = new Dictionary<Guid, TaxesForIndividual>();
}
}
\ No newline at end of file