Compare commits
1 Commits
v1.1.0.0
...
5ba286d926
| Author | SHA1 | Date | |
|---|---|---|---|
| 5ba286d926 |
@@ -92,6 +92,14 @@ namespace Elwig.Helpers.Billing {
|
|||||||
Mode = (mode == "elwig") ? CalculationMode.Elwig : CalculationMode.WgMaster;
|
Mode = (mode == "elwig") ? CalculationMode.Elwig : CalculationMode.WgMaster;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BillingData() {
|
||||||
|
Data = new JsonObject {
|
||||||
|
["mode"] = "elwig",
|
||||||
|
["version"] = 1,
|
||||||
|
};
|
||||||
|
Mode = CalculationMode.Elwig;
|
||||||
|
}
|
||||||
|
|
||||||
protected static JsonObject ParseJson(string json) {
|
protected static JsonObject ParseJson(string json) {
|
||||||
if (Schema == null) throw new InvalidOperationException("Schema has to be initialized first");
|
if (Schema == null) throw new InvalidOperationException("Schema has to be initialized first");
|
||||||
try {
|
try {
|
||||||
@@ -107,6 +115,10 @@ namespace Elwig.Helpers.Billing {
|
|||||||
return new(ParseJson(json));
|
return new(ParseJson(json));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string ToJsonString() {
|
||||||
|
return Data.ToJsonString();
|
||||||
|
}
|
||||||
|
|
||||||
protected JsonArray GetCurvesEntry() {
|
protected JsonArray GetCurvesEntry() {
|
||||||
return Data[Mode == CalculationMode.Elwig ? "curves" : "Kurven"]?.AsArray() ?? throw new InvalidOperationException();
|
return Data[Mode == CalculationMode.Elwig ? "curves" : "Kurven"]?.AsArray() ?? throw new InvalidOperationException();
|
||||||
}
|
}
|
||||||
@@ -412,7 +424,7 @@ namespace Elwig.Helpers.Billing {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static JsonObject FromGraphEntries(
|
public static BillingData FromGraphEntries(
|
||||||
IEnumerable<GraphEntry> graphEntries,
|
IEnumerable<GraphEntry> graphEntries,
|
||||||
BillingData? origData = null,
|
BillingData? origData = null,
|
||||||
IEnumerable<RawVaribute>? vaributes = null,
|
IEnumerable<RawVaribute>? vaributes = null,
|
||||||
@@ -449,37 +461,30 @@ namespace Elwig.Helpers.Billing {
|
|||||||
CollapsePaymentData(payment, payment.DeepClone().AsObject(), vaributes ?? payment.Select(e => new RawVaribute(e.Key)).ToList(), useDefaultPayment);
|
CollapsePaymentData(payment, payment.DeepClone().AsObject(), vaributes ?? payment.Select(e => new RawVaribute(e.Key)).ToList(), useDefaultPayment);
|
||||||
CollapsePaymentData(qualityWei, qualityWei.DeepClone().AsObject(), vaributes ?? qualityWei.Select(e => new RawVaribute(e.Key)).ToList(), useDefaultQuality);
|
CollapsePaymentData(qualityWei, qualityWei.DeepClone().AsObject(), vaributes ?? qualityWei.Select(e => new RawVaribute(e.Key)).ToList(), useDefaultQuality);
|
||||||
|
|
||||||
var data = new JsonObject {
|
BillingData data;
|
||||||
["mode"] = "elwig",
|
if (origData != null && origData.Mode == CalculationMode.Elwig) {
|
||||||
["version"] = 1,
|
data = new BillingData((JsonObject)origData.Data.DeepClone());
|
||||||
};
|
} else {
|
||||||
|
data = new BillingData();
|
||||||
if (origData?.ConsiderDelieryModifiers == true)
|
}
|
||||||
data["consider_delivery_modifiers"] = true;
|
|
||||||
if (origData?.ConsiderContractPenalties == true)
|
|
||||||
data["consider_contract_penalties"] = true;
|
|
||||||
if (origData?.ConsiderTotalPenalty == true)
|
|
||||||
data["consider_total_penalty"] = true;
|
|
||||||
if (origData?.ConsiderAutoBusinessShares == true)
|
|
||||||
data["consider_auto_business_shares"] = true;
|
|
||||||
|
|
||||||
if (payment.Count == 0) {
|
if (payment.Count == 0) {
|
||||||
data["payment"] = 0;
|
data.Data["payment"] = 0;
|
||||||
} else if (payment.Count == 1 && payment.First().Key == "default") {
|
} else if (payment.Count == 1 && payment.First().Key == "default") {
|
||||||
data["payment"] = payment.Single().Value?.DeepClone();
|
data.Data["payment"] = payment.Single().Value?.DeepClone();
|
||||||
} else {
|
} else {
|
||||||
data["payment"] = payment;
|
data.Data["payment"] = payment;
|
||||||
}
|
}
|
||||||
if (qualityWei.Count == 1 && qualityWei.First().Key == "default") {
|
if (qualityWei.Count == 1 && qualityWei.First().Key == "default") {
|
||||||
data["quality"] = new JsonObject() {
|
data.Data["quality"] = new JsonObject() {
|
||||||
["WEI"] = qualityWei.Single().Value?.DeepClone()
|
["WEI"] = qualityWei.Single().Value?.DeepClone()
|
||||||
};
|
};
|
||||||
} else if (qualityWei.Count >= 1) {
|
} else if (qualityWei.Count >= 1) {
|
||||||
data["quality"] = new JsonObject() {
|
data.Data["quality"] = new JsonObject() {
|
||||||
["WEI"] = qualityWei
|
["WEI"] = qualityWei
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
data["curves"] = curves;
|
data.Data["curves"] = curves;
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user