Implemented missing dumping of cost entry details model to billing.
This commit is contained in:
@@ -162,7 +162,7 @@ namespace UCalc
|
|||||||
var billing = Model.Dump();
|
var billing = Model.Dump();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
new BillingLoader().Store(FilePath, billing);
|
BillingLoader.Store(FilePath, billing);
|
||||||
Model.ResetModified();
|
Model.ResetModified();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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)
|
private static string AsString(JObject parent, string name, bool optional = false)
|
||||||
{
|
{
|
||||||
@@ -171,7 +171,7 @@ namespace UCalc.Data
|
|||||||
target.BankName = AsString(bankAccount, "bank_name");
|
target.BankName = AsString(bankAccount, "bank_name");
|
||||||
}
|
}
|
||||||
|
|
||||||
private Billing LoadFormat1(string path)
|
private static Billing LoadFormat1(string path)
|
||||||
{
|
{
|
||||||
var content = File.ReadAllText(path);
|
var content = File.ReadAllText(path);
|
||||||
try
|
try
|
||||||
@@ -289,7 +289,7 @@ namespace UCalc.Data
|
|||||||
}
|
}
|
||||||
|
|
||||||
[SuppressMessage("ReSharper", "PossibleNullReferenceException")]
|
[SuppressMessage("ReSharper", "PossibleNullReferenceException")]
|
||||||
private Billing LoadFormat2(string path)
|
private static Billing LoadFormat2(string path)
|
||||||
{
|
{
|
||||||
var content = File.ReadAllText(path);
|
var content = File.ReadAllText(path);
|
||||||
try
|
try
|
||||||
@@ -337,7 +337,7 @@ namespace UCalc.Data
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Billing Load(string path)
|
public static Billing Load(string path)
|
||||||
{
|
{
|
||||||
try
|
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));
|
File.WriteAllText(path, JsonConvert.SerializeObject(billing, Formatting.Indented));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ namespace UCalc
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var billing = new BillingLoader().Load(path);
|
var billing = BillingLoader.Load(path);
|
||||||
App.RecentlyOpenedList.Add(new RecentlyOpenedItem(path));
|
App.RecentlyOpenedList.Add(new RecentlyOpenedItem(path));
|
||||||
|
|
||||||
new BillingWindow(path, billing).Show();
|
new BillingWindow(path, billing).Show();
|
||||||
|
|||||||
+14
-2
@@ -240,7 +240,7 @@ namespace UCalc.Models
|
|||||||
DepartureDate = tenant.DepartureDate.Value,
|
DepartureDate = tenant.DepartureDate.Value,
|
||||||
RentedFlats =
|
RentedFlats =
|
||||||
new HashSet<Flat>(tenant.RentedFlats.Select(rentedFlat => flatPropertyToFlat[rentedFlat])),
|
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,
|
CustomMessage1 = tenant.CustomMessage1.Value,
|
||||||
CustomMessage2 = tenant.CustomMessage2.Value
|
CustomMessage2 = tenant.CustomMessage2.Value
|
||||||
}).ToList();
|
}).ToList();
|
||||||
@@ -253,7 +253,19 @@ namespace UCalc.Models
|
|||||||
IncludeUnrented = cost.IncludeUnrented.Value,
|
IncludeUnrented = cost.IncludeUnrented.Value,
|
||||||
AffectedFlats =
|
AffectedFlats =
|
||||||
new HashSet<Flat>(cost.AffectedFlats.Select(rentedFlat => flatPropertyToFlat[rentedFlat])),
|
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
|
DisplayInBill = cost.DisplayInBill.Value
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user