Просмотр исходного кода

Berechnung der Verhandlungsquote angepasst!

Arne Diekmann 8 лет назад
Родитель
Сommit
40d7e64494

+ 92 - 5
GreenTree.Nachtragsmanagement.Web/Extensions/GridViewSettingsHelper.cs

@@ -1035,7 +1035,7 @@ namespace GreenTree.Nachtragsmanagement.Web.Extensions
             });
             s.Columns.Add(column =>
             {
-                column.Caption = "Anteil Verh. zu Angeb.";
+                column.Caption = "Verh.-Quote";
                 column.FieldName = "RelationOfferingToNegotiation";
                 column.PropertiesEdit.DisplayFormatString = "p2";
                 column.MinWidth = 115;
@@ -1142,6 +1142,67 @@ namespace GreenTree.Nachtragsmanagement.Web.Extensions
                 column.Width = new Unit(200, UnitType.Pixel);
             });
 
+            var totalRelationOfferingToDeviationsSum = (decimal)0;
+            var totalRelationOfferingToDeviationsCount = 0;
+
+            var totalPercentageValueSum = (decimal)0;
+            var totalNegotiationValueSum = (decimal)0;
+
+            s.CustomSummaryCalculate = (sender, e) =>
+            {
+                if (e.SummaryProcess == CustomSummaryProcess.Start)
+                {
+                    totalRelationOfferingToDeviationsSum = 0;
+                    totalRelationOfferingToDeviationsCount = 0;
+
+                    totalPercentageValueSum = 0;
+                    totalNegotiationValueSum = 0;
+                }
+
+                if (e.SummaryProcess == CustomSummaryProcess.Calculate)
+                {
+                    var relationOfferingToDeviationsVal = e.GetValue("RelationOfferingToDeviations");
+
+                    if (relationOfferingToDeviationsVal != null)
+                    {
+                        totalRelationOfferingToDeviationsCount++;
+                        totalRelationOfferingToDeviationsSum += Convert.ToDecimal(relationOfferingToDeviationsVal);
+                    }
+
+                    var percentageVal = e.GetValue("PercentageValue");
+
+                    if (percentageVal != null)
+                        totalPercentageValueSum += Convert.ToDecimal(percentageVal);
+
+                    var negotiationVal = e.GetValue("NegotiationValue");
+
+                    if (negotiationVal != null)
+                        totalNegotiationValueSum += Convert.ToDecimal(negotiationVal);
+                }
+
+                if (e.SummaryProcess == CustomSummaryProcess.Finalize)
+                {
+                    var summaryItem = (ASPxSummaryItem)e.Item;
+
+                    if (summaryItem.FieldName == "PercentageValue")
+                        e.TotalValue = totalPercentageValueSum;
+
+                    if (summaryItem.FieldName == "NegotiationValue")
+                        e.TotalValue = totalNegotiationValueSum;
+
+                    if (summaryItem.FieldName == "RelationOfferingToDeviations")
+                    {
+                        if (totalRelationOfferingToDeviationsSum == 0 || totalRelationOfferingToDeviationsCount == 0)
+                            e.TotalValue = 0;
+                        else
+                            e.TotalValue = totalRelationOfferingToDeviationsSum / totalRelationOfferingToDeviationsCount;
+                    }
+
+                    if (summaryItem.FieldName == "RelationOfferingToNegotiation")
+                        e.TotalValue = totalNegotiationValueSum / totalPercentageValueSum;
+                }
+            };
+
             s.TotalSummary.Add(new ASPxSummaryItem
             {
                 SummaryType = DevExpress.Data.SummaryItemType.Count,
@@ -1184,29 +1245,55 @@ namespace GreenTree.Nachtragsmanagement.Web.Extensions
             s.TotalSummary.Add(new ASPxSummaryItem
             {
                 FieldName = "PercentageValue",
-                SummaryType = DevExpress.Data.SummaryItemType.Sum,
+                SummaryType = DevExpress.Data.SummaryItemType.Custom,
                 DisplayFormat = "Schätz. bew. ∑<br/><i>{0:c2}</i>"
             });
             s.GroupSummary.Add(new ASPxSummaryItem
             {
                 FieldName = "PercentageValue",
-                SummaryType = DevExpress.Data.SummaryItemType.Sum,
+                SummaryType = DevExpress.Data.SummaryItemType.Custom,
                 DisplayFormat = "Schätz. bew. ∑ = <i>{0:c2}</i>"
             });
 
             s.TotalSummary.Add(new ASPxSummaryItem
             {
-                SummaryType = DevExpress.Data.SummaryItemType.Sum,
+                SummaryType = DevExpress.Data.SummaryItemType.Custom,
                 FieldName = "NegotiationValue",
                 DisplayFormat = "Verhand. ∑<br/><i>{0:c2}</i>"
             });
             s.GroupSummary.Add(new ASPxSummaryItem
             {
-                SummaryType = DevExpress.Data.SummaryItemType.Sum,
+                SummaryType = DevExpress.Data.SummaryItemType.Custom,
                 FieldName = "NegotiationValue",
                 DisplayFormat = "Verhand.-∑ = {0:c2}"
             });
 
+            s.TotalSummary.Add(new ASPxSummaryItem
+            {
+                SummaryType = DevExpress.Data.SummaryItemType.Custom,
+                FieldName = "RelationOfferingToNegotiation",
+                DisplayFormat = "Verh. Quo. Ø<br/><i>{0:p2}</i>"
+            });
+            s.GroupSummary.Add(new ASPxSummaryItem
+            {
+                SummaryType = DevExpress.Data.SummaryItemType.Custom,
+                FieldName = "RelationOfferingToNegotiation",
+                DisplayFormat = "Verh. Quo. Ø = {0:p2}"
+            });
+
+            s.TotalSummary.Add(new ASPxSummaryItem
+            {
+                SummaryType = DevExpress.Data.SummaryItemType.Custom,
+                FieldName = "RelationOfferingToDeviations",
+                DisplayFormat = "Fak. A./VA Ø<br/><i>{0:n2}</i>"
+            });
+            s.GroupSummary.Add(new ASPxSummaryItem
+            {
+                SummaryType = DevExpress.Data.SummaryItemType.Custom,
+                FieldName = "RelationOfferingToDeviations",
+                DisplayFormat = "Fak. A./VA Ø = {0:n2}"
+            });
+
             s.HtmlRowPrepared = (sender, e) =>
             {
                 var state = e.GetValue("State") as StateDataModel;

+ 13 - 9
GreenTree.Nachtragsmanagement.Web/Models/Appendix/AppendixDataModel.cs

@@ -91,19 +91,23 @@ namespace GreenTree.Nachtragsmanagement.Web.Models.Appendix
                 OfferingValue = appendixEntity.Value.Value,
                 RelationOfferingToDeviations =
                     appendixEntity.Value.HasValue && appendixEntity.Deviations.Any()
-                        ? (decimal?)Convert.ToDecimal(
-                            appendixEntity.Value /
-                                (appendixEntity.Deviations
-                                    .Sum(r => r.Value.HasValue && r.Percentage.HasValue ? r.Value.Value * r.Percentage.Value : 0) != 0
-                                        ? appendixEntity.Deviations
-                                            .Sum(r => r.Value.HasValue && r.Percentage.HasValue ? r.Value.Value * r.Percentage.Value : 0)
-                                        : 1))
+                        ? appendixEntity.Deviations
+                            .Sum(r => r.Value.HasValue && r.Percentage.HasValue ? r.Value.Value * r.Percentage.Value : 0) != 0
+                                ? (decimal?)Convert.ToDecimal(
+                                    (appendixEntity.Value.Value * appendixEntity.Percentage.Value) / appendixEntity.Deviations
+                                        .Sum(r => r.Value.HasValue && r.Percentage.HasValue 
+                                            ? r.Value.Value * r.Percentage.Value 
+                                            : 0))
+                                : null
                         : null,
                 NegotiationDate = appendixEntity.NegotiationDate,
                 NegotiationValue = appendixEntity.NegotiationValue,
                 RelationOfferingToNegotiation =
-                    appendixEntity.Value.HasValue && appendixEntity.NegotiationValue.HasValue
-                        ? appendixEntity.NegotiationValue / (appendixEntity.Value == 0 ? 1 : appendixEntity.Value)
+                    appendixEntity.Percentage.HasValue && appendixEntity.NegotiationValue.HasValue
+                        ? appendixEntity.NegotiationValue / 
+                            (appendixEntity.Value == 0 
+                                ? 1 
+                                : (appendixEntity.Value.Value * appendixEntity.Percentage.Value))
                         : null,
                 ProtocolExists = appendixEntity.ProtocolExists,
                 OrderNumber = appendixEntity.OrderNumber,