|
|
|
|
@@ -65,9 +65,6 @@ namespace LebenshilfeCoburg.Invoicing
|
|
|
|
|
|
|
|
|
|
SetRecipientInformation(invoice, costBearer);
|
|
|
|
|
|
|
|
|
|
serviceRecords = MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDCs(DAOFactory.SearchDAO.FindServiceRecordsInSpan(invoicePeriod, null))
|
|
|
|
|
.Where(s => s.ServiceDescription.CategoryName == "Arbeitszeitstunden" || s.ServiceDescription.CategoryName == "Nachtdienst" || s.ServiceDescription.CategoryName == "individuelle Begleitung Hilfskraft").ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SetServiceInvoicePeriods(invoice, invoice.InvoiceBase.CostBearer2SupportConcept, invoicePeriod,
|
|
|
|
|
serviceRecords);
|
|
|
|
|
@@ -87,89 +84,176 @@ namespace LebenshilfeCoburg.Invoicing
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Ein Mal pro Hilfeplan aufgerufen.
|
|
|
|
|
public override void SetServiceInvoicePeriods(ServiceInvoice invoice, CostBearer2SupportConcept costBearer2SupportConcept, DateTimeSpan invoicePeriod, List<ServiceRecordDC> serviceRecords)
|
|
|
|
|
{
|
|
|
|
|
{
|
|
|
|
|
var alleBookings = DAOFactory.SearchDAO.GetAdditionalServiceBookings(null, invoicePeriod.StartDate, invoicePeriod.EndDate);
|
|
|
|
|
var alleWohnheime = MapperFactory.WohnheimDC_Wohnheim.MapToNewDCs(DAOFactory.GenericDAO.GetAllActive<Wohnheim>());
|
|
|
|
|
var supportConcept = costBearer2SupportConcept.SupportConcept;
|
|
|
|
|
// Wohnheim, in dem der aktuelle Klient drin ist
|
|
|
|
|
WohnheimDC wohnheim = null;
|
|
|
|
|
// Alle An-/Abwesenheitseinträge für das entsprechende Wohnheim
|
|
|
|
|
List<AdditionalServiceBooking> bookings = new List<AdditionalServiceBooking>();
|
|
|
|
|
foreach (var wh in alleWohnheime)
|
|
|
|
|
{
|
|
|
|
|
var customersInWohnheim = new List<CompactCustomerDC>();
|
|
|
|
|
foreach (var rel in wh.RelatedCustomers)
|
|
|
|
|
customersInWohnheim.Add(rel.Customer);
|
|
|
|
|
|
|
|
|
|
if (customersInWohnheim.Any(c => c.CustomerOid == supportConcept.Customer.Oid))
|
|
|
|
|
{
|
|
|
|
|
wohnheim = wh;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
foreach (var b in alleBookings)
|
|
|
|
|
if (b.AdditionalServiceRegion.Name == wohnheim.WohnheimName)
|
|
|
|
|
bookings.Add(b);
|
|
|
|
|
|
|
|
|
|
Console.WriteLine();
|
|
|
|
|
|
|
|
|
|
var invoiceAccountingPeriodSpan = new DateTimeSpan
|
|
|
|
|
{
|
|
|
|
|
StartDateTime = invoice.InvoiceBase.AccountingPeriodStart.Value,
|
|
|
|
|
EndDateTime = invoice.InvoiceBase.AccountingPeriodEnd.Value
|
|
|
|
|
};
|
|
|
|
|
ServiceInvoicePeriodDC period = new ServiceInvoicePeriodDC()
|
|
|
|
|
{
|
|
|
|
|
Start = invoiceAccountingPeriodSpan.StartDate,
|
|
|
|
|
End = invoiceAccountingPeriodSpan.EndDate,
|
|
|
|
|
InvoiceItems = new List<InvoiceItemDC>()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region ServiceInvoicePeriod-Variablen setzen (optional für diese Rechnung? Stellt sich am Ende raus
|
|
|
|
|
ServiceInvoicePeriod serviceInvoicePeriod = CreateServiceInvoicePeriod(MapperFactory.SupportConceptApprovalPeriodDC_SupportConceptApprovalPeriod.MapToNewDC(costBearer2SupportConcept.ApprovalPeriodList[0]), invoiceAccountingPeriodSpan);
|
|
|
|
|
serviceInvoicePeriod.SupportConceptApprovalPeriod = costBearer2SupportConcept.ApprovalPeriodList[0];
|
|
|
|
|
serviceInvoicePeriod.Customer = supportConcept.Customer;
|
|
|
|
|
|
|
|
|
|
SupportConceptApprovalPeriodDC approvalPeriodDC = MapperFactory.SupportConceptApprovalPeriodDC_SupportConceptApprovalPeriod.MapToNewDC(costBearer2SupportConcept.ApprovalPeriodList[0]);
|
|
|
|
|
|
|
|
|
|
CostBearer costBearer = costBearer2SupportConcept.CostBearer;
|
|
|
|
|
List<CostRatePeriodDC> costRates = MapperFactory.CostRatePeriodDC_CostRatePeriod.MapToNewDCs(costBearer.CostRatePeriods);
|
|
|
|
|
CostRatePeriodDC serviceUnit = costRates.GetCostRatePeriodForDate(CostRatePeriodType.MinutesPerServiceUnit, DateTime.Now);
|
|
|
|
|
serviceInvoicePeriod.ServiceUnitName = serviceUnit.UnitName;
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
SetInvoiceItems(invoice, serviceInvoicePeriod, approvalPeriodDC, costBearer2SupportConcept, invoicePeriod, serviceRecords);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//foreach (SupportConceptApprovalPeriod iPeriod in costBearer2SupportConcept.ApprovalPeriodList)
|
|
|
|
|
//{
|
|
|
|
|
// SupportConceptApprovalPeriodDC approvalPeriodDC = MapperFactory.SupportConceptApprovalPeriodDC_SupportConceptApprovalPeriod.MapToNewDC(iPeriod);
|
|
|
|
|
foreach (SupportConceptApprovalPeriod iPeriod in costBearer2SupportConcept.ApprovalPeriodList)
|
|
|
|
|
{
|
|
|
|
|
#region auskommentierer Standardkram
|
|
|
|
|
//SupportConceptApprovalPeriodDC approvalPeriodDC = MapperFactory.SupportConceptApprovalPeriodDC_SupportConceptApprovalPeriod.MapToNewDC(iPeriod);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//if (approvalPeriodDC.Span.EndDateTime < invoiceAccountingPeriodSpan.StartDateTime || approvalPeriodDC.Span.StartDateTime > invoiceAccountingPeriodSpan.EndDate)
|
|
|
|
|
//{
|
|
|
|
|
// continue;
|
|
|
|
|
//}
|
|
|
|
|
//if (approvalPeriodDC.Span.EndDateTime < invoiceAccountingPeriodSpan.StartDateTime || approvalPeriodDC.Span.StartDateTime > invoiceAccountingPeriodSpan.EndDate)
|
|
|
|
|
//{
|
|
|
|
|
// continue;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//ServiceInvoicePeriod serviceInvoicePeriod = CreateServiceInvoicePeriod(approvalPeriodDC, invoiceAccountingPeriodSpan);
|
|
|
|
|
//serviceInvoicePeriod.SupportConceptApprovalPeriod = iPeriod;
|
|
|
|
|
//serviceInvoicePeriod.Customer = costBearer2SupportConcept.SupportConcept.Customer;
|
|
|
|
|
//ServiceInvoicePeriod serviceInvoicePeriod = CreateServiceInvoicePeriod(approvalPeriodDC, invoiceAccountingPeriodSpan);
|
|
|
|
|
//serviceInvoicePeriod.SupportConceptApprovalPeriod = iPeriod;
|
|
|
|
|
//serviceInvoicePeriod.Customer = costBearer2SupportConcept.SupportConcept.Customer;
|
|
|
|
|
|
|
|
|
|
//CostBearer costBearer = costBearer2SupportConcept.CostBearer;
|
|
|
|
|
//List<CostRatePeriodDC> costRates = MapperFactory.CostRatePeriodDC_CostRatePeriod.MapToNewDCs(costBearer.CostRatePeriods);
|
|
|
|
|
//CostBearer costBearer = costBearer2SupportConcept.CostBearer;
|
|
|
|
|
//List<CostRatePeriodDC> costRates = MapperFactory.CostRatePeriodDC_CostRatePeriod.MapToNewDCs(costBearer.CostRatePeriods);
|
|
|
|
|
|
|
|
|
|
//CostRatePeriodDC serviceUnit = costRates.GetCostRatePeriodForDate(CostRatePeriodType.MinutesPerServiceUnit, DateTime.Now);
|
|
|
|
|
//serviceInvoicePeriod.ServiceUnitName = serviceUnit.UnitName;
|
|
|
|
|
//CostRatePeriodDC serviceUnit = costRates.GetCostRatePeriodForDate(CostRatePeriodType.MinutesPerServiceUnit, DateTime.Now);
|
|
|
|
|
//serviceInvoicePeriod.ServiceUnitName = serviceUnit.UnitName;
|
|
|
|
|
|
|
|
|
|
//Calculations calc = PluginLoader.FindClass<Calculations>(_SpecificID) ?? Calculations.GetInstance(_SpecificID);
|
|
|
|
|
//Calculations calc = PluginLoader.FindClass<Calculations>(_SpecificID) ?? Calculations.GetInstance(_SpecificID);
|
|
|
|
|
|
|
|
|
|
//decimal amountPerUnit;
|
|
|
|
|
//decimal unitCount;
|
|
|
|
|
//decimal amountPerUnit;
|
|
|
|
|
//decimal unitCount;
|
|
|
|
|
|
|
|
|
|
//serviceInvoicePeriod.ApprovedFixedAmount = calc.GetApprovedFixedAmountForPeriod(approvalPeriodDC, serviceInvoicePeriod.Start.Value, serviceInvoicePeriod.End.Value, out amountPerUnit, out unitCount);
|
|
|
|
|
//serviceInvoicePeriod.ApprovedFixedAmount = calc.GetApprovedFixedAmountForPeriod(approvalPeriodDC, serviceInvoicePeriod.Start.Value, serviceInvoicePeriod.End.Value, out amountPerUnit, out unitCount);
|
|
|
|
|
|
|
|
|
|
//if (!serviceInvoicePeriod.ApprovedFixedAmount.HasValue)
|
|
|
|
|
//{
|
|
|
|
|
// serviceInvoicePeriod.ApprovedHours = calc.GetApprovedHoursForPeriod(approvalPeriodDC,
|
|
|
|
|
// costRates,
|
|
|
|
|
// serviceInvoicePeriod.Start.Value,
|
|
|
|
|
// serviceInvoicePeriod.End.Value);
|
|
|
|
|
// if (serviceInvoicePeriod.ApprovedHours.HasValue)
|
|
|
|
|
// serviceInvoicePeriod.ApprovedBE = serviceUnit.GetHoursInBE(serviceInvoicePeriod.ApprovedHours.Value);
|
|
|
|
|
//if (!serviceInvoicePeriod.ApprovedFixedAmount.HasValue)
|
|
|
|
|
//{
|
|
|
|
|
// serviceInvoicePeriod.ApprovedHours = calc.GetApprovedHoursForPeriod(approvalPeriodDC,
|
|
|
|
|
// costRates,
|
|
|
|
|
// serviceInvoicePeriod.Start.Value,
|
|
|
|
|
// serviceInvoicePeriod.End.Value);
|
|
|
|
|
// if (serviceInvoicePeriod.ApprovedHours.HasValue)
|
|
|
|
|
// serviceInvoicePeriod.ApprovedBE = serviceUnit.GetHoursInBE(serviceInvoicePeriod.ApprovedHours.Value);
|
|
|
|
|
|
|
|
|
|
// serviceInvoicePeriod.ApprovedAmountDefaultHourlyRate = calc.GetApprovedAmountDefaultHourlyRateForPeriod(approvalPeriodDC,
|
|
|
|
|
// costRates,
|
|
|
|
|
// serviceInvoicePeriod.Start,
|
|
|
|
|
// serviceInvoicePeriod.End);
|
|
|
|
|
//}
|
|
|
|
|
//SetInvoiceItems(invoice, serviceInvoicePeriod, approvalPeriodDC, costBearer2SupportConcept, invoicePeriod, serviceRecords);
|
|
|
|
|
// serviceInvoicePeriod.ApprovedAmountDefaultHourlyRate = calc.GetApprovedAmountDefaultHourlyRateForPeriod(approvalPeriodDC,
|
|
|
|
|
// costRates,
|
|
|
|
|
// serviceInvoicePeriod.Start,
|
|
|
|
|
// serviceInvoicePeriod.End);
|
|
|
|
|
//}
|
|
|
|
|
//SetInvoiceItems(invoice, serviceInvoicePeriod, approvalPeriodDC, costBearer2SupportConcept, invoicePeriod, serviceRecords);
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
//CheckMaxApprovedAmount(invoice, serviceInvoicePeriod, approvalPeriodDC, costBearer2SupportConcept, invoicePeriod, serviceRecords);
|
|
|
|
|
CheckMaxApprovedAmount(invoice, serviceInvoicePeriod, approvalPeriodDC, costBearer2SupportConcept, invoicePeriod, serviceRecords);
|
|
|
|
|
|
|
|
|
|
//if (serviceInvoicePeriod.InvoiceItemList.Count > 0)
|
|
|
|
|
// invoice.ServiceInvoicePeriodList.Add(serviceInvoicePeriod);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (serviceInvoicePeriod.InvoiceItemList.Count > 0)
|
|
|
|
|
invoice.ServiceInvoicePeriodList.Add(serviceInvoicePeriod);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void CreateFixedAmounts(ServiceInvoicePeriod serviceInvoicePeriod, SupportConceptApprovalPeriodDC supportConceptApprovalPeriod, CostBearer2SupportConcept cb2sc)
|
|
|
|
|
{
|
|
|
|
|
var calc = PluginLoader.FindClass<Calculations>(_SpecificID) ?? Calculations.GetInstance(_SpecificID);
|
|
|
|
|
|
|
|
|
|
// HIER DIE DATEN AUS SetServiceInvoicePeriods HOLEN UND DANN DIE ITEMS ERSTELLEN & BERECHNEN
|
|
|
|
|
var alleBookings = DAOFactory.SearchDAO.GetAdditionalServiceBookings(null, serviceInvoicePeriod.Start.Value, serviceInvoicePeriod.End.Value);
|
|
|
|
|
var alleWohnheime = MapperFactory.WohnheimDC_Wohnheim.MapToNewDCs(DAOFactory.GenericDAO.GetAllActive<Wohnheim>());
|
|
|
|
|
var supportConcept = cb2sc.SupportConcept;
|
|
|
|
|
var serviceRecords = MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDCs(DAOFactory.SearchDAO.FindServiceRecords(null, null, null, serviceInvoicePeriod.Start.Value, serviceInvoicePeriod.End.Value))
|
|
|
|
|
.Where(s => s.ServiceDescription.CategoryName == "Arbeitszeitstunden" || s.ServiceDescription.CategoryName == "Nachtdienst" || s.ServiceDescription.CategoryName == "individuelle Begleitung Hilfskraft").ToList();
|
|
|
|
|
|
|
|
|
|
var bewilligteLeistungen = new List<SupportConceptApprovalPeriodDC>();
|
|
|
|
|
foreach (SupportConceptApprovalPeriod iPeriod in cb2sc.ApprovalPeriodList)
|
|
|
|
|
bewilligteLeistungen.Add(MapperFactory.SupportConceptApprovalPeriodDC_SupportConceptApprovalPeriod.MapToNewDC(iPeriod));
|
|
|
|
|
// Wohnheim, in dem der aktuelle Klient drin ist
|
|
|
|
|
WohnheimDC wohnheim = null;
|
|
|
|
|
// Alle An-/Abwesenheitseinträge für das entsprechende Wohnheim
|
|
|
|
|
List<AdditionalServiceBooking> bookings = new List<AdditionalServiceBooking>();
|
|
|
|
|
#region richtiges Wohnheim und dazugehörige ergänzende Dienste setzen
|
|
|
|
|
foreach (var wh in alleWohnheime)
|
|
|
|
|
{
|
|
|
|
|
var customersInWohnheim = new List<CompactCustomerDC>();
|
|
|
|
|
foreach (var rel in wh.RelatedCustomers)
|
|
|
|
|
customersInWohnheim.Add(rel.Customer);
|
|
|
|
|
|
|
|
|
|
if (customersInWohnheim.Any(c => c.CustomerOid == supportConcept.Customer.Oid))
|
|
|
|
|
{
|
|
|
|
|
wohnheim = wh;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
foreach (var b in alleBookings)
|
|
|
|
|
if (b.AdditionalServiceRegion.Name == wohnheim.WohnheimName)
|
|
|
|
|
bookings.Add(b);
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
// Für jede der bewilligten Leistungen die entsprechende Regel zur Berechnung des Betrags anwenden.
|
|
|
|
|
foreach (var leistung in bewilligteLeistungen)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//var data = calc.GetFixedBillingData(supportConceptApprovalPeriod, serviceInvoicePeriod.Start, serviceInvoicePeriod.End);
|
|
|
|
|
#region auskommentierter Standardkram
|
|
|
|
|
//var data = calc.GetFixedBillingData(supportConceptApprovalPeriod, serviceInvoicePeriod.Start, serviceInvoicePeriod.End);
|
|
|
|
|
|
|
|
|
|
//foreach (var billingData in data)
|
|
|
|
|
//{
|
|
|
|
|
// serviceInvoicePeriod.InvoiceItemList.Add(new InvoiceItem
|
|
|
|
|
// {
|
|
|
|
|
// AmountTotal = billingData.AmountTotal,
|
|
|
|
|
// GrossAmountTotal = billingData.GrossAmountTotal,
|
|
|
|
|
// ItemPeriodStart = billingData.BillingPeriodStart,
|
|
|
|
|
// ItemPeriodEnd = billingData.BillingPeriodEnd,
|
|
|
|
|
// AccountingInterval = billingData.AccountingInterval,
|
|
|
|
|
// AmountPerUnit = billingData.AmountPerUnit,
|
|
|
|
|
// UnitCount = billingData.UnitCount
|
|
|
|
|
// });
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//foreach (var billingData in data)
|
|
|
|
|
//{
|
|
|
|
|
// serviceInvoicePeriod.InvoiceItemList.Add(new InvoiceItem
|
|
|
|
|
// {
|
|
|
|
|
// AmountTotal = billingData.AmountTotal,
|
|
|
|
|
// GrossAmountTotal = billingData.GrossAmountTotal,
|
|
|
|
|
// ItemPeriodStart = billingData.BillingPeriodStart,
|
|
|
|
|
// ItemPeriodEnd = billingData.BillingPeriodEnd,
|
|
|
|
|
// AccountingInterval = billingData.AccountingInterval,
|
|
|
|
|
// AmountPerUnit = billingData.AmountPerUnit,
|
|
|
|
|
// UnitCount = billingData.UnitCount
|
|
|
|
|
// });
|
|
|
|
|
//}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|