LebenshilfeStade/Invoicing/CustomInvoiceCreation - Rundung und Nullpointer
This commit is contained in:
@@ -29,10 +29,11 @@ namespace LebenshilfeStade.Invoicing
|
||||
var minutesPerServiceUnit = crp.FirstOrDefault(c => c.CostRateType == BS.Shared.CostRatePeriodType.MinutesPerServiceUnit);
|
||||
var minsProFLS = minutesPerServiceUnit != null ? minutesPerServiceUnit.CostRateValue : 60;
|
||||
|
||||
//invoiceItem.UnitCount = invoiceItem.UnitCount * 60 / minsProFLS;
|
||||
invoiceItem.GrossAmountTotal = invoiceItem.GrossAmountTotal * 60 / minsProFLS;
|
||||
invoiceItem.AmountTotal = invoiceItem.AmountTotal * 60 / minsProFLS;
|
||||
}
|
||||
// der Kostenträger braucht die Zwischenrundung auf 2 Nachkommastellen
|
||||
invoiceItem.UnitCount = (decimal)Math.Round((double)(invoiceItem.UnitCount * 60 / minsProFLS), 2, MidpointRounding.AwayFromZero);
|
||||
invoiceItem.GrossAmountTotal = invoiceItem.AmountPerUnit * invoiceItem.UnitCount;
|
||||
invoiceItem.AmountTotal = invoiceItem.AmountPerUnit * invoiceItem.UnitCount;
|
||||
}
|
||||
|
||||
return invoiceItem;
|
||||
}
|
||||
@@ -76,54 +77,56 @@ namespace LebenshilfeStade.Invoicing
|
||||
{
|
||||
// Rausfinden, ob FLS 50 statt 60 Minuten gehen
|
||||
//
|
||||
var oid = newlist.FirstOrDefault(i => i.SupportConceptApprovalPeriodOid != null).SupportConceptApprovalPeriodOid;
|
||||
SupportConceptApprovalPeriod ap = null;
|
||||
if (oid != null)
|
||||
ap = DAOFactory.GenericDAO.GetByID<SupportConceptApprovalPeriod>(oid.Value);
|
||||
if (newlist != null && newlist.Count > 0)
|
||||
{
|
||||
var oid = newlist.FirstOrDefault(i => i.SupportConceptApprovalPeriodOid != null).SupportConceptApprovalPeriodOid;
|
||||
SupportConceptApprovalPeriod ap = null;
|
||||
if (oid != null)
|
||||
ap = DAOFactory.GenericDAO.GetByID<SupportConceptApprovalPeriod>(oid.Value);
|
||||
|
||||
List<CostRatePeriod> crp = null;
|
||||
if (ap != null)
|
||||
crp = ap.CostBearer2SupportConcept.CostBearer.CostRatePeriods.ToList();
|
||||
List<CostRatePeriod> crp = null;
|
||||
if (ap != null)
|
||||
crp = ap.CostBearer2SupportConcept.CostBearer.CostRatePeriods.ToList();
|
||||
|
||||
if (crp != null && crp.Count > 0)
|
||||
{
|
||||
var minutesPerServiceUnit = crp.FirstOrDefault(c => c.CostRateType == BS.Shared.CostRatePeriodType.MinutesPerServiceUnit);
|
||||
var minsProFLS = minutesPerServiceUnit != null ? minutesPerServiceUnit.CostRateValue : 60;
|
||||
|
||||
foreach (InvoiceItem invoiceItem in newlist)
|
||||
if (crp != null && crp.Count > 0)
|
||||
{
|
||||
if (!invoiceItem.AmountPerUnit.HasValue)
|
||||
var minutesPerServiceUnit = crp.FirstOrDefault(c => c.CostRateType == BS.Shared.CostRatePeriodType.MinutesPerServiceUnit);
|
||||
var minsProFLS = minutesPerServiceUnit != null ? minutesPerServiceUnit.CostRateValue : 60;
|
||||
|
||||
foreach (InvoiceItem invoiceItem in newlist)
|
||||
{
|
||||
invoiceItem.AmountPerUnit = 0;
|
||||
}
|
||||
invoiceItem.AmountPerUnit = Math.Round(invoiceItem.AmountPerUnit.Value, 2, MidpointRounding.AwayFromZero);
|
||||
if (!invoiceItem.AmountPerUnit.HasValue)
|
||||
{
|
||||
invoiceItem.AmountPerUnit = 0;
|
||||
}
|
||||
invoiceItem.AmountPerUnit = Math.Round(invoiceItem.AmountPerUnit.Value, 2, MidpointRounding.AwayFromZero);
|
||||
|
||||
if (!invoiceItem.UnitCount.HasValue)
|
||||
{
|
||||
invoiceItem.UnitCount = 0;
|
||||
}
|
||||
if (!invoiceItem.UnitCount.HasValue)
|
||||
{
|
||||
invoiceItem.UnitCount = 0;
|
||||
}
|
||||
|
||||
if (addRateFactorToUnitCount && invoiceItem.RateFactor.HasValue)
|
||||
{
|
||||
invoiceItem.UnitCount = (invoiceItem.UnitCount ?? 0) * ((invoiceItem.RateFactor + 100) / 100);
|
||||
}
|
||||
if (addRateFactorToUnitCount && invoiceItem.RateFactor.HasValue)
|
||||
{
|
||||
invoiceItem.UnitCount = (invoiceItem.UnitCount ?? 0) * ((invoiceItem.RateFactor + 100) / 100);
|
||||
}
|
||||
|
||||
invoiceItem.UnitCount = Math.Round(invoiceItem.UnitCount.Value, 2, MidpointRounding.AwayFromZero);
|
||||
invoiceItem.UnitCount = Math.Round(invoiceItem.UnitCount.Value, 2, MidpointRounding.AwayFromZero);
|
||||
|
||||
|
||||
// Änderung: Eine FLS hat 50 statt 60 Minuten
|
||||
invoiceItem.AmountTotal = invoiceItem.AmountPerUnit * (invoiceItem.UnitCount * 60 / minsProFLS);
|
||||
invoiceItem.AmountTotal = Math.Round(invoiceItem.AmountTotal.Value, 2, MidpointRounding.AwayFromZero);
|
||||
// Änderung: Eine FLS hat 50 statt 60 Minuten
|
||||
invoiceItem.AmountTotal = invoiceItem.AmountPerUnit * (invoiceItem.UnitCount * 60 / minsProFLS);
|
||||
invoiceItem.AmountTotal = Math.Round(invoiceItem.AmountTotal.Value, 2, MidpointRounding.AwayFromZero);
|
||||
|
||||
invoiceItem.GrossAmountTotal = invoiceItem.AmountTotal;
|
||||
invoiceItem.GrossAmountTotal = invoiceItem.AmountTotal;
|
||||
|
||||
|
||||
if (!addRateFactorToUnitCount && invoiceItem.RateFactor.HasValue)
|
||||
{
|
||||
invoiceItem.GrossAmountTotal *= (invoiceItem.RateFactor + 100) / 100;
|
||||
if (!addRateFactorToUnitCount && invoiceItem.RateFactor.HasValue)
|
||||
{
|
||||
invoiceItem.GrossAmountTotal *= (invoiceItem.RateFactor + 100) / 100;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user