SBBMainzReports/Invoicing/CustomInvoiceCreationQA - NPE gefixt, wenn keine ServiceCategory vergeben
SupportOID=167690
This commit is contained in:
@@ -110,69 +110,72 @@ namespace SBBMainzReports.Invoicing
|
||||
{
|
||||
var calc = PluginLoader.FindClass<Calculations>(_SpecificID) ?? Calculations.GetInstance(_SpecificID);
|
||||
var scap = supportConceptApprovalPeriod;
|
||||
if (scap.ServiceCategory != null)
|
||||
{
|
||||
var crList = scap.ServiceCategory.CostRatePeriods;
|
||||
var cr = crList.GetCostRatePeriodForDate(BS.Shared.CostRatePeriodType.AmountOfMoney, serviceInvoicePeriod.Start.Value);
|
||||
if (cr != null && cr.CostRateValue.HasValue)
|
||||
{
|
||||
decimal? hourlyRate = cr.CostRateValue.Value;
|
||||
decimal weeklyFactor = 4.33m;
|
||||
// Anteilige Berechnung nur in dem Monat, in dem der HP tatsächlich beginnt bzw. endet -
|
||||
// in allen anderen (vollen) Monaten wird der volle Monatsfaktor berechnet
|
||||
if (scap.StartDate.HasValue && scap.StartDate.Value.Day > 7 && serviceInvoicePeriod.Start.HasValue
|
||||
&& scap.StartDate.Value.Year == serviceInvoicePeriod.Start.Value.Year && scap.StartDate.Value.Month == serviceInvoicePeriod.Start.Value.Month)
|
||||
if (cr != null && cr.CostRateValue.HasValue)
|
||||
{
|
||||
int startDay = scap.StartDate.Value.Day;
|
||||
if (startDay <= 14)
|
||||
decimal? hourlyRate = cr.CostRateValue.Value;
|
||||
decimal weeklyFactor = 4.33m;
|
||||
// Anteilige Berechnung nur in dem Monat, in dem der HP tatsächlich beginnt bzw. endet -
|
||||
// in allen anderen (vollen) Monaten wird der volle Monatsfaktor berechnet
|
||||
if (scap.StartDate.HasValue && scap.StartDate.Value.Day > 7 && serviceInvoicePeriod.Start.HasValue
|
||||
&& scap.StartDate.Value.Year == serviceInvoicePeriod.Start.Value.Year && scap.StartDate.Value.Month == serviceInvoicePeriod.Start.Value.Month)
|
||||
{
|
||||
weeklyFactor = Math.Min(weeklyFactor, 3m);
|
||||
int startDay = scap.StartDate.Value.Day;
|
||||
if (startDay <= 14)
|
||||
{
|
||||
weeklyFactor = Math.Min(weeklyFactor, 3m);
|
||||
}
|
||||
else if (startDay <= 21)
|
||||
{
|
||||
weeklyFactor = Math.Min(weeklyFactor, 2m);
|
||||
}
|
||||
else
|
||||
{
|
||||
weeklyFactor = Math.Min(weeklyFactor, 1m);
|
||||
}
|
||||
}
|
||||
else if (startDay <= 21)
|
||||
if (scap.EndDate.HasValue && scap.EndDate.Value.Day < 22 && serviceInvoicePeriod.End.HasValue
|
||||
&& scap.EndDate.Value.Year == serviceInvoicePeriod.End.Value.Year && scap.EndDate.Value.Month == serviceInvoicePeriod.End.Value.Month)
|
||||
{
|
||||
weeklyFactor = Math.Min(weeklyFactor, 2m);
|
||||
int endDay = scap.EndDate.Value.Day;
|
||||
if (endDay >= 15)
|
||||
{
|
||||
weeklyFactor = Math.Min(weeklyFactor, 3m);
|
||||
}
|
||||
else if (endDay >= 8)
|
||||
{
|
||||
weeklyFactor = Math.Min(weeklyFactor, 2m);
|
||||
}
|
||||
else
|
||||
{
|
||||
weeklyFactor = Math.Min(weeklyFactor, 1m);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
weeklyFactor = Math.Min(weeklyFactor, 1m);
|
||||
}
|
||||
}
|
||||
if (scap.EndDate.HasValue && scap.EndDate.Value.Day < 22 && serviceInvoicePeriod.End.HasValue
|
||||
&& scap.EndDate.Value.Year == serviceInvoicePeriod.End.Value.Year && scap.EndDate.Value.Month == serviceInvoicePeriod.End.Value.Month)
|
||||
{
|
||||
int endDay = scap.EndDate.Value.Day;
|
||||
if (endDay >= 15)
|
||||
{
|
||||
weeklyFactor = Math.Min(weeklyFactor, 3m);
|
||||
}
|
||||
else if (endDay >= 8)
|
||||
{
|
||||
weeklyFactor = Math.Min(weeklyFactor, 2m);
|
||||
}
|
||||
else
|
||||
{
|
||||
weeklyFactor = Math.Min(weeklyFactor, 1m);
|
||||
}
|
||||
}
|
||||
|
||||
decimal approvedHours = 0;
|
||||
decimal approvedHoursMonth = 0;
|
||||
if (scap.ApprovedBEInterval.HasValue && scap.ApprovedBEInterval.Value == SupportConceptApprovalInterval.Weekly && scap.ApprovedBEPerInterval.HasValue)
|
||||
{
|
||||
approvedHours = scap.ApprovedBEPerInterval.Value;
|
||||
approvedHoursMonth = weeklyFactor * scap.ApprovedBEPerInterval.Value;
|
||||
decimal approvedHours = 0;
|
||||
decimal approvedHoursMonth = 0;
|
||||
if (scap.ApprovedBEInterval.HasValue && scap.ApprovedBEInterval.Value == SupportConceptApprovalInterval.Weekly && scap.ApprovedBEPerInterval.HasValue)
|
||||
{
|
||||
approvedHours = scap.ApprovedBEPerInterval.Value;
|
||||
approvedHoursMonth = weeklyFactor * scap.ApprovedBEPerInterval.Value;
|
||||
}
|
||||
decimal amount = approvedHoursMonth * hourlyRate.Value;
|
||||
serviceInvoicePeriod.InvoiceItemList.Add(new InvoiceItem
|
||||
{
|
||||
AmountTotal = amount,
|
||||
GrossAmountTotal = amount,
|
||||
ItemPeriodStart = serviceInvoicePeriod.Start,
|
||||
ItemPeriodEnd = serviceInvoicePeriod.End,
|
||||
AmountPerUnit = hourlyRate.Value,
|
||||
ItemDescription = "Fachleistungseinheiten/Woche",
|
||||
UnitDescription = "QA/Woche",
|
||||
UnitCount = approvedHours,
|
||||
Notice = approvedHoursMonth.ToString("n2")
|
||||
});
|
||||
}
|
||||
decimal amount = approvedHoursMonth * hourlyRate.Value;
|
||||
serviceInvoicePeriod.InvoiceItemList.Add(new InvoiceItem
|
||||
{
|
||||
AmountTotal = amount,
|
||||
GrossAmountTotal = amount,
|
||||
ItemPeriodStart = serviceInvoicePeriod.Start,
|
||||
ItemPeriodEnd = serviceInvoicePeriod.End,
|
||||
AmountPerUnit = hourlyRate.Value,
|
||||
ItemDescription = "Fachleistungseinheiten/Woche",
|
||||
UnitDescription = "QA/Woche",
|
||||
UnitCount = approvedHours,
|
||||
Notice = approvedHoursMonth.ToString("n2")
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user