Dtos: merge under/over delivery with percent column
This commit is contained in:
@ -19,8 +19,7 @@ namespace Elwig.Models.Dtos {
|
|||||||
("Areas", "Fläche", "m²", 16),
|
("Areas", "Fläche", "m²", 16),
|
||||||
("DeliveryObligations", "Lieferpflicht", "kg", 22),
|
("DeliveryObligations", "Lieferpflicht", "kg", 22),
|
||||||
("Weights", "Geliefert", "kg", 22),
|
("Weights", "Geliefert", "kg", 22),
|
||||||
("UnderDeliveries", "Unterliefert", "kg", 22),
|
("UnderDeliveries", "Unterliefert", "kg|%", 34),
|
||||||
("Percents", "Prozent", "%", 16),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public AreaComUnderDeliveryData(IEnumerable<AreaComUnderDeliveryRow> rows, int year) :
|
public AreaComUnderDeliveryData(IEnumerable<AreaComUnderDeliveryRow> rows, int year) :
|
||||||
@ -61,11 +60,8 @@ namespace Elwig.Models.Dtos {
|
|||||||
public int[] Areas;
|
public int[] Areas;
|
||||||
public int[] DeliveryObligations;
|
public int[] DeliveryObligations;
|
||||||
public int[] Weights;
|
public int[] Weights;
|
||||||
public int?[] UnderDeliveries => Weights.Zip(DeliveryObligations)
|
public (int? Kg, double? Percent)[] UnderDeliveries => Weights.Zip(DeliveryObligations)
|
||||||
.Select(v => v.First < v.Second ? (int?)v.First - v.Second : null)
|
.Select(v => v.First < v.Second ? ((int?, double?))(v.First - v.Second, v.First * 100.0 / v.Second - 100.0) : (null, null))
|
||||||
.ToArray();
|
|
||||||
public double?[] Percents => Weights.Zip(DeliveryObligations)
|
|
||||||
.Select(v => v.First < v.Second ? (double?)v.First * 100.0 / v.Second - 100.0 : null)
|
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
public AreaComUnderDeliveryRow(IEnumerable<AreaComUnderDeliveryRowSingle> rows) {
|
public AreaComUnderDeliveryRow(IEnumerable<AreaComUnderDeliveryRowSingle> rows) {
|
||||||
|
@ -18,8 +18,7 @@ namespace Elwig.Models.Dtos {
|
|||||||
("DeliveryObligation", "Lieferpflicht", "kg", 22),
|
("DeliveryObligation", "Lieferpflicht", "kg", 22),
|
||||||
("DeliveryRight", "Lieferrecht", "kg", 22),
|
("DeliveryRight", "Lieferrecht", "kg", 22),
|
||||||
("Weight", "Geliefert", "kg", 22),
|
("Weight", "Geliefert", "kg", 22),
|
||||||
("OverUnderDelivery", "Über-/Unterliefert", "kg", 35),
|
("OverUnderDelivery", "Über-/Unterliefert", "kg|%", 34),
|
||||||
("Percent", "Prozent", "%", 16),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public OverUnderDeliveryData(IEnumerable<OverUnderDeliveryRow> rows, int year) :
|
public OverUnderDeliveryData(IEnumerable<OverUnderDeliveryRow> rows, int year) :
|
||||||
@ -70,12 +69,8 @@ namespace Elwig.Models.Dtos {
|
|||||||
[Column("sum")]
|
[Column("sum")]
|
||||||
public int Weight { get; set; }
|
public int Weight { get; set; }
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public int? OverUnderDelivery =>
|
public (int? Kg, double? Percent) OverUnderDelivery =>
|
||||||
Weight < DeliveryObligation ? Weight - DeliveryObligation :
|
Weight < DeliveryObligation ? (Weight - DeliveryObligation, Weight * 100.0 / DeliveryObligation - 100.0) :
|
||||||
Weight > DeliveryRight ? Weight - DeliveryRight : null;
|
Weight > DeliveryRight ? (Weight - DeliveryRight, Weight * 100.0 / DeliveryRight - 100) : (null, null);
|
||||||
[NotMapped]
|
|
||||||
public double? Percent =>
|
|
||||||
Weight < DeliveryObligation ? Weight * 100.0 / DeliveryObligation - 100.0 :
|
|
||||||
Weight > DeliveryRight ? Weight * 100.0 / DeliveryRight - 100 : null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user