Skip to content

Commit

Permalink
Add "null" handling for monthlytotal
Browse files Browse the repository at this point in the history
Also updates error messages to be more detailed
  • Loading branch information
FirestarJes committed Oct 3, 2024
1 parent 7b5a49c commit 92c168f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ public SettlementReportMonthlyAmountRowMap()
Resolution.Hour => "PT1H",
Resolution.Day => "P1D",
Resolution.Month => "P1M",
_ => throw new ArgumentOutOfRangeException(nameof(row.Value.Resolution)),
_ => throw new ArgumentOutOfRangeException(
nameof(row.Value.Resolution),
row.Value.Resolution,
"Value does not contain a enum representation of a Resolution"),
});

Map(r => r.QuantityUnit)
Expand All @@ -86,7 +89,10 @@ public SettlementReportMonthlyAmountRowMap()
null => string.Empty,
QuantityUnit.Kwh => "KWH",
QuantityUnit.Pieces => "PCS",
_ => throw new ArgumentOutOfRangeException(nameof(row.Value.QuantityUnit)),
_ => throw new ArgumentOutOfRangeException(
nameof(row.Value.QuantityUnit),
row.Value.QuantityUnit,
string.Empty),
});

Map(r => r.Currency)
Expand All @@ -95,7 +101,10 @@ public SettlementReportMonthlyAmountRowMap()
.Convert(row => row.Value.Currency switch
{
Currency.DKK => "DKK",
_ => throw new ArgumentOutOfRangeException(nameof(row.Value.Currency)),
_ => throw new ArgumentOutOfRangeException(
nameof(row.Value.Currency),
row.Value.Currency,
"Value does not contain a enum representation of a Currency"),
});

Map(r => r.Amount)
Expand All @@ -112,7 +121,10 @@ public SettlementReportMonthlyAmountRowMap()
ChargeType.Tariff => "D03",
ChargeType.Fee => "D02",
ChargeType.Subscription => "D01",
_ => throw new ArgumentOutOfRangeException(nameof(row.Value.ChargeType)),
_ => throw new ArgumentOutOfRangeException(
nameof(row.Value.ChargeType),
row.Value.ChargeType,
"Value does not contain a enum representation of a ChargeType"),
});

Map(r => r.ChargeCode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,24 @@ public SettlementReportTotalMonthlyAmountRowMap(SettlementReportRequestedByActor
Resolution.Hour => "PT1H",
Resolution.Day => "P1D",
Resolution.Month => "P1M",
_ => throw new ArgumentOutOfRangeException(nameof(row.Value.Resolution)),
_ => throw new ArgumentOutOfRangeException(
nameof(row.Value.Resolution),
row.Value.Resolution,
"Value does not contain a enum representation of a Resolution."),
});

Map(r => r.QuantityUnit)
.Name("MEASUREUNIT")
.Index(6)
.Convert(row => row.Value.QuantityUnit switch
{
null => string.Empty,
QuantityUnit.Kwh => "KWH",
QuantityUnit.Pieces => "PCS",
_ => throw new ArgumentOutOfRangeException(nameof(row.Value.QuantityUnit)),
_ => throw new ArgumentOutOfRangeException(
nameof(row.Value.QuantityUnit),
row.Value.QuantityUnit,
"Value does not contain a enum representation of a quantity unit."),
});

Map(r => r.Currency)
Expand All @@ -100,7 +107,10 @@ public SettlementReportTotalMonthlyAmountRowMap(SettlementReportRequestedByActor
.Convert(row => row.Value.Currency switch
{
Currency.DKK => "DKK",
_ => throw new ArgumentOutOfRangeException(nameof(row.Value.Currency)),
_ => throw new ArgumentOutOfRangeException(
nameof(row.Value.Currency),
row.Value.Currency,
"Value does not contain a enum representation of a Currency"),
});

Map(r => r.Amount)
Expand All @@ -117,7 +127,10 @@ public SettlementReportTotalMonthlyAmountRowMap(SettlementReportRequestedByActor
ChargeType.Tariff => "D03",
ChargeType.Fee => "D02",
ChargeType.Subscription => "D01",
_ => throw new ArgumentOutOfRangeException(nameof(row.Value.ChargeType)),
_ => throw new ArgumentOutOfRangeException(
nameof(row.Value.ChargeType),
row.Value.ChargeType,
"Value does not contain a enum representation of a ChargeType."),
});

Map(r => r.ChargeCode)
Expand Down

0 comments on commit 92c168f

Please sign in to comment.