HausDuelken/Invoicing/AssistenzInvoiceCreation - Trennung ASS und FLS
This commit is contained in:
@@ -70,6 +70,7 @@
|
||||
<Compile Include="FLSListReport.Designer.cs">
|
||||
<DependentUpon>FLSListReport.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Invoicing\AssistenzInvoiceCreation.cs" />
|
||||
<Compile Include="Invoicing\CustomInvoiceCreation.cs" />
|
||||
<Compile Include="Invoicing\CustomInvoiceFactory.cs" />
|
||||
<Compile Include="Invoicing\CustomSettlementInvoiceCreation.cs" />
|
||||
|
||||
102
ReportImp/HausDuelken/Invoicing/AssistenzInvoiceCreation.cs
Normal file
102
ReportImp/HausDuelken/Invoicing/AssistenzInvoiceCreation.cs
Normal file
@@ -0,0 +1,102 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using BeWo.Data.Access;
|
||||
using BeWo.Data.Entities;
|
||||
using BeWo.Service.DCEntityMapper;
|
||||
using BeWo.Service.Invoicing;
|
||||
using BeWo.Service.Plugins;
|
||||
using BS.Shared;
|
||||
using BS.Shared.Core;
|
||||
using BS.Shared.DataContracts;
|
||||
using BS.Shared.DataContracts.Compact;
|
||||
using BS.Shared.Extensions;
|
||||
using BS.Shared.Services;
|
||||
|
||||
namespace HausDuelken.Invoicing
|
||||
{
|
||||
|
||||
public class CustomAssistenzInvoiceCreation : InvoiceCreation
|
||||
{
|
||||
public override void SetInvoiceBaseData(int invoiceCounter, ServiceInvoice invoice, CostBearer costBearer, DateTimeSpan invoicePeriod, IList<CompactSupportConceptDC> supportConceptList)
|
||||
{
|
||||
base.SetInvoiceBaseData(invoiceCounter, invoice, costBearer, invoicePeriod, supportConceptList);
|
||||
invoice.InvoiceBase.InvoiceDate = invoice.InvoiceBase.AccountingPeriodEnd;
|
||||
}
|
||||
|
||||
|
||||
public override void SetAmountAdvancePayments(ServiceInvoice invoice)
|
||||
{
|
||||
//do nothing
|
||||
}
|
||||
|
||||
public override void SetAmountEquityContribution(ServiceInvoice invoice)
|
||||
{
|
||||
//do nothing
|
||||
}
|
||||
|
||||
public override InvoiceItem CreateInvoiceItem(ServiceRecordDC iServiceRecord, SupportConceptApprovalPeriod scap, BS.Shared.Services.Calculations calc)
|
||||
{
|
||||
if (!iServiceRecord.ServiceDescription.CategoryName.Contains("Assistenz"))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var ii = base.CreateInvoiceItem(iServiceRecord, scap, calc);
|
||||
ii.ItemDescription = "Assistenzleistung";
|
||||
return ii;
|
||||
}
|
||||
|
||||
public override void SetInvoiceItems(ServiceInvoice invoice,
|
||||
ServiceInvoicePeriod serviceInvoicePeriod,
|
||||
SupportConceptApprovalPeriodDC supportConceptApprovalPeriod,
|
||||
CostBearer2SupportConcept cb2sc,
|
||||
DateTimeSpan invoicePeriod,
|
||||
List<ServiceRecordDC> serviceRecords)
|
||||
{
|
||||
BS.Shared.Services.Calculations calc = PluginLoader.FindClass<BS.Shared.Services.Calculations>(_SpecificID) ?? BS.Shared.Services.Calculations.GetInstance(_SpecificID);
|
||||
|
||||
if (ShouldCreateFixedAmounts(serviceInvoicePeriod, supportConceptApprovalPeriod, cb2sc))
|
||||
{
|
||||
CreateFixedAmounts(serviceInvoicePeriod, supportConceptApprovalPeriod, cb2sc);
|
||||
}
|
||||
else
|
||||
{
|
||||
List<ServiceRecordDC> serviceRecordsInPeriod = serviceRecords.Where(
|
||||
i =>
|
||||
{
|
||||
bool valid = i.Start.Value.InBetween(serviceInvoicePeriod.Start.Value,
|
||||
serviceInvoicePeriod.End.Value, true);
|
||||
|
||||
if (valid && serviceInvoicePeriod.SupportConceptApprovalPeriod != null && serviceInvoicePeriod.SupportConceptApprovalPeriod.ServiceCategory != null)
|
||||
valid = serviceInvoicePeriod.SupportConceptApprovalPeriod.ServiceCategory.Oid ==
|
||||
i.ServiceDescription.Category.ServiceCategoryOid;
|
||||
return valid;
|
||||
}).ToList();
|
||||
|
||||
if (serviceRecordsInPeriod.Count > 0)
|
||||
{
|
||||
var absenceTimes = MapperFactory.AbsenceTimeDC_AbsenceTime.MapToNewDCs(cb2sc.SupportConcept.Customer.AbsenceTimes);
|
||||
Dictionary<DateTimeSpan, decimal> span2Hours = calc.GetAbsencesTimesNotBillable(absenceTimes);
|
||||
|
||||
// serviceInvoicePeriod.HoursNotBillableAbsence - eingeschränkte Anzahl bei Abwesenheit GILT laut LVR ausdrücklich nicht bei Assistenzleistungen
|
||||
serviceInvoicePeriod.HoursNotBillableNotApproved +=
|
||||
calc.GetHoursNotBillableDueToMoreThanApproved(supportConceptApprovalPeriod,
|
||||
cb2sc.CostBearer.CostRatePeriods.MapToNewDCs(),
|
||||
serviceRecordsInPeriod,
|
||||
true, true);
|
||||
|
||||
var itemList = CreateInvoiceItems(serviceRecordsInPeriod, invoicePeriod, serviceInvoicePeriod.SupportConceptApprovalPeriod, calc);
|
||||
serviceInvoicePeriod.InvoiceItemList.AddRange(itemList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override IList<InvoiceItem> CreateSummaryInvoiceItems(IList<InvoiceItem> itemList, DateTimeSpan invoicePeriod, SupportConceptApprovalPeriod scap,
|
||||
BS.Shared.Services.Calculations calc, bool summaryPerMonth, bool addRateFactorToUnitCount)
|
||||
{
|
||||
return base.CreateSummaryInvoiceItems(itemList, invoicePeriod, scap, calc, false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,32 @@ namespace HausDuelken.Invoicing
|
||||
return new CustomStationaerInvoiceCreation();
|
||||
}
|
||||
}
|
||||
return new InvoiceCreation();
|
||||
|
||||
foreach (var list in supportConcepts2ServiceRecords.Values)
|
||||
{
|
||||
foreach (var sr in list)
|
||||
{
|
||||
var sd = sr.ServiceDescription.Category;
|
||||
var ic = GetInvoiceCreatorForCategory(sd);
|
||||
if (ic != null)
|
||||
return ic;
|
||||
}
|
||||
}
|
||||
return new InvoiceCreation();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private InvoiceCreation GetInvoiceCreatorForCategory(ServiceCategoryDC sd)
|
||||
{
|
||||
if (sd != null && !String.IsNullOrEmpty(sd.Name))
|
||||
{
|
||||
String cat = sd.Name.ToLower().Trim();
|
||||
if (cat.IndexOf("assistenz") >= 0)
|
||||
{
|
||||
return new CustomAssistenzInvoiceCreation();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,15 +57,15 @@ namespace HausDuelken
|
||||
}
|
||||
}
|
||||
|
||||
public override InvoiceItemDC CreateInvoiceItemForAccountingPeriod(AccountingPeriod accountingPeriod)
|
||||
{
|
||||
var item = base.CreateInvoiceItemForAccountingPeriod(accountingPeriod);
|
||||
if (item.ItemDescription != null && item.ItemDescription.StartsWith("Assistenzleistung"))
|
||||
{
|
||||
item.RateFactor = null;
|
||||
}
|
||||
return item;
|
||||
}
|
||||
//public override InvoiceItemDC CreateInvoiceItemForAccountingPeriod(AccountingPeriod accountingPeriod)
|
||||
//{
|
||||
// var item = base.CreateInvoiceItemForAccountingPeriod(accountingPeriod);
|
||||
// if (item.ItemDescription != null && item.ItemDescription.StartsWith("Assistenzleistung"))
|
||||
// {
|
||||
// item.RateFactor = null;
|
||||
// }
|
||||
// return item;
|
||||
//}
|
||||
|
||||
public override bool IsServiceRecordBillable(ServiceRecord iRecord)
|
||||
{
|
||||
@@ -73,7 +73,40 @@ namespace HausDuelken
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (iRecord.ServiceDescription.ServiceCategory.Name.Contains("Assistenz"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool CanCreateInvoiceTheOldWay(Settlement2DC si, CostBearer2SupportConcept c2s)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void CalculateSettlementInvoiceApprovedAmounts(Settlement2DC si, SupportConceptCostBearerRelDC relDC, BS.Shared.Services.Calculations calc)
|
||||
{
|
||||
si.ApprovedFLSWeekly = 0;
|
||||
si.ApprovedFLS = 0;
|
||||
foreach (var sp in relDC.ApprovalPeriodList)
|
||||
{
|
||||
if (sp.ServiceCategory == null || !sp.ServiceCategory.Name.Contains("Assistenz"))
|
||||
{
|
||||
si.ApprovedFLSWeekly += calc.GetApprovedHoursPerWeek(sp, relDC.CostBearer.CostRatePeriods) ?? 0m;
|
||||
|
||||
decimal flsTotal = calc.GetApprovedHoursTotal(sp, relDC.CostBearer.CostRatePeriods) ?? 0m;
|
||||
flsTotal = Math.Round(flsTotal, 2, MidpointRounding.AwayFromZero);
|
||||
|
||||
si.ApprovedFLS += flsTotal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override IList<ServiceRecord> GetBillableServiceRecords(CostBearer2SupportConcept c2s)
|
||||
{
|
||||
return c2s.ServiceRecords.OrderBy(s => s.Start).Where(s => !s.ServiceDescription.ServiceCategory.Name.ToLower().Contains("assistenz")).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace HausDuelken.Alt
|
||||
pRO.ApprovedFLS = null;
|
||||
foreach (var ap in sc.ApprovalPeriodList)
|
||||
{
|
||||
if (ap.ServiceCategory != null)
|
||||
if (ap.ServiceCategory != null && !ap.ServiceCategory.Name.Contains("Assistenz"))
|
||||
{
|
||||
{
|
||||
if (pRO.ApprovedFLS != null)
|
||||
|
||||
Reference in New Issue
Block a user