Dtos: merge under/over delivery with percent column

This commit is contained in:
2023-11-15 22:16:13 +01:00
parent 6e0da28ea3
commit 22318e1b9a
2 changed files with 7 additions and 16 deletions

View File

@ -18,8 +18,7 @@ namespace Elwig.Models.Dtos {
("DeliveryObligation", "Lieferpflicht", "kg", 22),
("DeliveryRight", "Lieferrecht", "kg", 22),
("Weight", "Geliefert", "kg", 22),
("OverUnderDelivery", "Über-/Unterliefert", "kg", 35),
("Percent", "Prozent", "%", 16),
("OverUnderDelivery", "Über-/Unterliefert", "kg|%", 34),
};
public OverUnderDeliveryData(IEnumerable<OverUnderDeliveryRow> rows, int year) :
@ -70,12 +69,8 @@ namespace Elwig.Models.Dtos {
[Column("sum")]
public int Weight { get; set; }
[NotMapped]
public int? OverUnderDelivery =>
Weight < DeliveryObligation ? Weight - DeliveryObligation :
Weight > DeliveryRight ? Weight - DeliveryRight : null;
[NotMapped]
public double? Percent =>
Weight < DeliveryObligation ? Weight * 100.0 / DeliveryObligation - 100.0 :
Weight > DeliveryRight ? Weight * 100.0 / DeliveryRight - 100 : null;
public (int? Kg, double? Percent) OverUnderDelivery =>
Weight < DeliveryObligation ? (Weight - DeliveryObligation, Weight * 100.0 / DeliveryObligation - 100.0) :
Weight > DeliveryRight ? (Weight - DeliveryRight, Weight * 100.0 / DeliveryRight - 100) : (null, null);
}
}