Implemented missing dumping of cost entry details model to billing.

This commit is contained in:
Tobias Erbshäußer
2020-06-19 08:10:29 +02:00
parent 55c9871d9a
commit 03b09ca3b0
4 changed files with 21 additions and 9 deletions
+1 -1
View File
@@ -162,7 +162,7 @@ namespace UCalc
var billing = Model.Dump();
try
{
new BillingLoader().Store(FilePath, billing);
BillingLoader.Store(FilePath, billing);
Model.ResetModified();
return true;
}
+5 -5
View File
@@ -69,7 +69,7 @@ namespace UCalc.Data
}
}
public class BillingLoader
public static class BillingLoader
{
private static string AsString(JObject parent, string name, bool optional = false)
{
@@ -171,7 +171,7 @@ namespace UCalc.Data
target.BankName = AsString(bankAccount, "bank_name");
}
private Billing LoadFormat1(string path)
private static Billing LoadFormat1(string path)
{
var content = File.ReadAllText(path);
try
@@ -289,7 +289,7 @@ namespace UCalc.Data
}
[SuppressMessage("ReSharper", "PossibleNullReferenceException")]
private Billing LoadFormat2(string path)
private static Billing LoadFormat2(string path)
{
var content = File.ReadAllText(path);
try
@@ -337,7 +337,7 @@ namespace UCalc.Data
}
}
public Billing Load(string path)
public static Billing Load(string path)
{
try
{
@@ -349,7 +349,7 @@ namespace UCalc.Data
}
}
public void Store(string path, Billing billing)
public static void Store(string path, Billing billing)
{
File.WriteAllText(path, JsonConvert.SerializeObject(billing, Formatting.Indented));
}
+1 -1
View File
@@ -71,7 +71,7 @@ namespace UCalc
{
try
{
var billing = new BillingLoader().Load(path);
var billing = BillingLoader.Load(path);
App.RecentlyOpenedList.Add(new RecentlyOpenedItem(path));
new BillingWindow(path, billing).Show();
+14 -2
View File
@@ -240,7 +240,7 @@ namespace UCalc.Models
DepartureDate = tenant.DepartureDate.Value,
RentedFlats =
new HashSet<Flat>(tenant.RentedFlats.Select(rentedFlat => flatPropertyToFlat[rentedFlat])),
PaidRent = decimal.TryParse(tenant.PaidRent.Value, out var d) ? d : 0,
PaidRent = tenant.PaidRent.ConvertedValue ?? 0,
CustomMessage1 = tenant.CustomMessage1.Value,
CustomMessage2 = tenant.CustomMessage2.Value
}).ToList();
@@ -253,7 +253,19 @@ namespace UCalc.Models
IncludeUnrented = cost.IncludeUnrented.Value,
AffectedFlats =
new HashSet<Flat>(cost.AffectedFlats.Select(rentedFlat => flatPropertyToFlat[rentedFlat])),
// TODO: Entries = {},
Entries = cost.Entries.Select(entry => new CostEntry
{
StartDate = entry.StartDate.Value ?? StartDate,
EndDate = entry.EndDate.Value ?? EndDate,
Amount = entry.Amount.ConvertedValue ?? 0,
Details = new CostEntryDetails
{
TotalAmount = entry.Details.TotalAmount.ConvertedValue ?? 0,
UnitCount = entry.Details.UnitCount.ConvertedValue ?? 0,
DiscountsInUnits = entry.Details.DiscountsInUnits
.Select(discount => discount.ConvertedValue ?? 0).ToList()
}
}).ToList(),
DisplayInBill = cost.DisplayInBill.Value
}).ToList();