Files
BeWoPlaner/ReportImp/AwoKreisverbandPloen/Invoicing/CustomInvoiceFactory.cs

56 lines
1.7 KiB
C#

using System;
using System.Collections.Generic;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BeWo.Service.Invoicing;
using BeWo.Service.ServiceImplementations;
using BS.Shared.DataContracts;
using BS.Shared.DataContracts.Compact;
namespace AwoKreisverbandPloen.Invoicing
{
public class CustomInvoiceFactory : InvoiceFactory
{
public override InvoiceCreation CreateInvoiceCreator(string specificId, string tenant, Dictionary<CompactSupportConceptDC, List<ServiceRecordDC>> supportConcepts2ServiceRecords)
{
foreach (var list in supportConcepts2ServiceRecords)
{
var os = new OperationsServiceImp();
var sc = os.GetSupportConceptsById(new List<long>() { list.Key.SupportConceptOid });
var cat = sc[0].CostBearerRelations[0].ApprovalPeriodList[0].ServiceCategory;
if (cat != null && cat.Name.ToLower().Contains("tagesstätte"))
{
return new TagesstaetteInvoiceCreation();
}
else if (list.Value.Count > 0)
{
foreach (var sr in list.Value)
{
var sd = sr.ServiceDescription.Category;
var ic = GetInvoiceCreatorForCategory(sd);
if (ic != null)
return ic;
}
}
}
return new DefaultInvoiceCreation();
}
private InvoiceCreation GetInvoiceCreatorForCategory(ServiceCategoryDC sd)
{
if (sd != null && !String.IsNullOrEmpty(sd.Name))
{
String cat = sd.Name.ToLower().Trim();
if (cat.Contains("assistenz"))
{
return new CustomAssistenzInvoiceCreation();
}
else if (cat.ToLower().Contains("tagesstätte"))
return new TagesstaetteInvoiceCreation();
}
return null;
}
}
}