Skip to content
This repository has been archived by the owner on Oct 26, 2019. It is now read-only.

Commit

Permalink
More changes
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrolamas committed Oct 26, 2019
1 parent ddfda56 commit 6de016b
Show file tree
Hide file tree
Showing 28 changed files with 1,040 additions and 295 deletions.
Binary file modified src/PedroLamas.Vencimento.WP7/IRSTables.sdf
Binary file not shown.
4 changes: 2 additions & 2 deletions src/PedroLamas.Vencimento.WP7/Model/IMainModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ namespace PedroLamas.Vencimento.Model
{
public interface IMainModel
{
IList<SimulationModel2> Simulations { get; }
IList<SimulationModel> Simulations { get; }

SimulationModel2 SelectedSimulation { get; set; }
SimulationModel SelectedSimulation { get; set; }

void Save();
}
Expand Down
11 changes: 5 additions & 6 deletions src/PedroLamas.Vencimento.WP7/Model/MainModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ public class MainModel : IMainModel

#region Properties

public IList<SimulationModel2> Simulations { get; private set; }
public IList<SimulationModel> Simulations { get; private set; }

public SimulationModel2 SelectedSimulation { get; set; }
public SimulationModel SelectedSimulation { get; set; }

#endregion

Expand All @@ -27,10 +27,9 @@ public MainModel(IStorageService storageService)

private void Load()
{
if (_storageService.FileExists(SimulationsFilename))
Simulations = JsonConvert.DeserializeObject<List<SimulationModel2>>(_storageService.ReadAllText(SimulationsFilename));
else
Simulations = new List<SimulationModel2>();
Simulations = _storageService.FileExists(SimulationsFilename)
? JsonConvert.DeserializeObject<List<SimulationModel>>(_storageService.ReadAllText(SimulationsFilename))
: new List<SimulationModel>();
}

public void Save()
Expand Down
95 changes: 48 additions & 47 deletions src/PedroLamas.Vencimento.WP7/Model/SimulationModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,54 @@

namespace PedroLamas.Vencimento.Model
{
public class SimulationModel : ObservableObject
public class SimulationModel
{
#region Properties

public double MonthlyBaseIncome { get; set; }

public int YearId { get; set; }

public int FiscalResidenceId { get; set; }

public int RegimeId { get; set; }

public int MaritalStateId { get; set; }

public int DependentId { get; set; }

public int SocialSecurityRegimeId { get; set; }

public double DailyLunchAllowance { get; set; }

public int WorkingDays { get; set; }

public bool ChristmasVacationsAllowancesInTwelfths { get; set; }

public bool ChristmasOvertaxed { get; set; }

#endregion

public SimulationModel Clone()
{
return new SimulationModel()
{
MonthlyBaseIncome = this.MonthlyBaseIncome,
YearId = this.YearId,
FiscalResidenceId = this.FiscalResidenceId,
RegimeId = this.RegimeId,
MaritalStateId = this.MaritalStateId,
DependentId = this.DependentId,
SocialSecurityRegimeId = this.SocialSecurityRegimeId,
DailyLunchAllowance = this.DailyLunchAllowance,
WorkingDays = this.WorkingDays,
ChristmasVacationsAllowancesInTwelfths = this.ChristmasVacationsAllowancesInTwelfths,
ChristmasOvertaxed = this.ChristmasOvertaxed
};
}
}

public class SimulationModel3 : ObservableObject
{
private double _monthlyBaseIncome;
private IrsYear _year;
Expand Down Expand Up @@ -200,50 +247,4 @@ public bool ChristmasOvertaxed

#endregion
}

public class SimulationModel2
{
#region Properties

public double MonthlyBaseIncome { get; set; }

public int YearId { get; set; }

public int FiscalResidenceId { get; set; }

public int RegimeId { get; set; }

public int MaritalStateId { get; set; }

public int DependentId { get; set; }

public int SocialSecurityRegimeId { get; set; }

public double DailyLunchAllowance { get; set; }

public int WorkingDays { get; set; }

public bool ChristmasVacationsAllowancesInTwelfths { get; set; }

public bool ChristmasOvertaxed { get; set; }

#endregion

public SimulationModel2 Clone()
{
return new SimulationModel2()
{
MonthlyBaseIncome = this.MonthlyBaseIncome,
FiscalResidenceId = this.FiscalResidenceId,
RegimeId = this.RegimeId,
MaritalStateId = this.MaritalStateId,
DependentId = this.DependentId,
SocialSecurityRegimeId = this.SocialSecurityRegimeId,
DailyLunchAllowance = this.DailyLunchAllowance,
WorkingDays = this.WorkingDays,
ChristmasVacationsAllowancesInTwelfths = this.ChristmasVacationsAllowancesInTwelfths,
ChristmasOvertaxed = this.ChristmasOvertaxed
};
}
}
}
78 changes: 65 additions & 13 deletions src/PedroLamas.Vencimento.WP7/ViewModel/EditViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ public class EditViewModel : ViewModelBase
private readonly IDataModel _dataModel;
private readonly INavigationService _navigationService;

private SimulationModel2 _model;
private SimulationModel _model;

#region Properties

public SimulationModel2 Model
public SimulationModel Model
{
get
{
Expand Down Expand Up @@ -51,6 +51,9 @@ public string MonthlyBaseIncome
{
get
{
if (_model == null)
return null;

return Model.MonthlyBaseIncome.ToString(CultureInfo.InvariantCulture);
}
set
Expand All @@ -73,6 +76,9 @@ public IrsYear Year
{
get
{
if (_model == null)
return null;

return _dataModel.YearList.FirstOrDefault(x => x.Year == Model.YearId);
}
set
Expand All @@ -92,6 +98,9 @@ public IrsFiscalResidence FiscalResidence
{
get
{
if (_model == null)
return null;

return _dataModel.FiscalResidenceList.FirstOrDefault(x => x.FiscalResidenceId == Model.FiscalResidenceId);
}
set
Expand All @@ -111,6 +120,9 @@ public IrsRegime Regime
{
get
{
if (_model == null)
return null;

return _dataModel.RegimeList.FirstOrDefault(x => x.RegimeId == Model.RegimeId);
}
set
Expand All @@ -130,6 +142,9 @@ public IrsMaritalState MaritalState
{
get
{
if (_model == null)
return null;

return _dataModel.MaritalStateList.FirstOrDefault(x => x.MaritalStateId == Model.MaritalStateId);
}
set
Expand All @@ -149,6 +164,9 @@ public IrsDependent Dependent
{
get
{
if (_model == null)
return null;

return _dataModel.DependentList.FirstOrDefault(x => x.DependentId == Model.DependentId);
}
set
Expand All @@ -168,6 +186,9 @@ public SocialSecurityRegime SocialSecurityRegime
{
get
{
if (_model == null)
return null;

return _dataModel.SocialSecurityRegimeList.FirstOrDefault(x => x.SocialSecurityRegimeId == Model.SocialSecurityRegimeId);
}
set
Expand All @@ -187,6 +208,9 @@ public string DailyLunchAllowance
{
get
{
if (_model == null)
return null;

return Model.DailyLunchAllowance.ToString(CultureInfo.InvariantCulture);
}
set
Expand All @@ -209,6 +233,9 @@ public string WorkingDays
{
get
{
if (_model == null)
return null;

return Model.WorkingDays.ToString(CultureInfo.InvariantCulture);
}
set
Expand All @@ -231,6 +258,9 @@ public bool ChristmasVacationsAllowancesInTwelfths
{
get
{
if (_model == null)
return false;

return Model.ChristmasVacationsAllowancesInTwelfths;
}
set
Expand All @@ -248,6 +278,9 @@ public bool ChristmasOvertaxed
{
get
{
if (_model == null)
return false;

return Model.ChristmasOvertaxed;
}
set
Expand Down Expand Up @@ -323,7 +356,7 @@ public EditViewModel(IMainModel mainModel, IDataModel dataModel, INavigationServ

ConfirmCommand = new RelayCommand(() =>
{
MessengerInstance.Send(new SimulationChangedMessage(Model));
MessengerInstance.Send(new SimulationChangedMessage(_mainModel.SelectedSimulation, _model));
_navigationService.GoBack();
});
Expand All @@ -332,16 +365,35 @@ public EditViewModel(IMainModel mainModel, IDataModel dataModel, INavigationServ
{
if (_mainModel.SelectedSimulation == null)
{
Model = new SimulationModel2
{
YearId = (_dataModel.YearList.FirstOrDefault(x => x.Year == DateTime.Today.Year) ?? _dataModel.YearList.Last()).Year,
FiscalResidenceId = _dataModel.FiscalResidenceList.First().FiscalResidenceId,
RegimeId = _dataModel.RegimeList.First().RegimeId,
MaritalStateId = _dataModel.MaritalStateList.First().MaritalStateId,
DependentId = _dataModel.DependentList.First().DependentId,
SocialSecurityRegimeId = _dataModel.SocialSecurityRegimeList.First().SocialSecurityRegimeId,
WorkingDays = 22
};
_model = new SimulationModel();
MonthlyBaseIncome = "0";
Year = _dataModel.YearList
.FirstOrDefault(x => x.Year == DateTime.Today.Year) ?? dataModel.YearList.LastOrDefault();
FiscalResidence = dataModel.FiscalResidenceList
.FirstOrDefault();
Regime = dataModel.RegimeList
.FirstOrDefault();
MaritalState = dataModel.MaritalStateList
.FirstOrDefault();
Dependent = dataModel.DependentList
.FirstOrDefault();
SocialSecurityRegime = dataModel.SocialSecurityRegimeList
.FirstOrDefault();
DailyLunchAllowance = "0";
WorkingDays = "22";
ChristmasVacationsAllowancesInTwelfths = false;
ChristmasOvertaxed = false;
}
else
{
Expand Down
Loading

0 comments on commit 6de016b

Please sign in to comment.