CaritasverbandDuerenJuelichEV/Invoicing/CustomInvoiceCreation + CustomAccountingService
Bugfixes, wenn Hilfepläne kein Enddatum haben
This commit is contained in:
@@ -116,6 +116,7 @@
|
||||
<Compile Include="ServiceInvoiceReport.Designer.cs">
|
||||
<DependentUpon>ServiceInvoiceReport.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Service\CustomAccountingService.cs" />
|
||||
<Compile Include="Service\CustomVacationService.cs" />
|
||||
<Compile Include="Service\ServiceRecordValidator.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -46,6 +46,37 @@ namespace CaritasverbandDuerenJuelichEV.Invoicing
|
||||
// return null;
|
||||
//}
|
||||
|
||||
public override void SetSingleInvoiceBaseData(int invoiceCounter, ServiceInvoice invoice, CostBearer costBearer, DateTimeSpan invoicePeriod, CompactSupportConceptDC supportConcept)
|
||||
{
|
||||
//Nur SingleInvoice und nicht Collective
|
||||
invoice.InvoiceBase.SupportConceptOid = supportConcept.SupportConceptOid;
|
||||
invoice.InvoiceBase.CostBearer2SupportConcept = DAOFactory.GenericDAO.LoadByID<CostBearer2SupportConcept>(supportConcept.CostBearerRelOids[0]);
|
||||
|
||||
if (supportConcept.CustomerReferenceNumbers.Count > 0)
|
||||
{
|
||||
invoice.InvoiceBase.CustomerReferenceNumber = supportConcept.CustomerReferenceNumbers[0];
|
||||
}
|
||||
Person p = invoice.InvoiceBase.CostBearer2SupportConcept.SupportConcept.Customer.Person;
|
||||
DateTimeSpan span = invoice.InvoiceBase.CostBearer2SupportConcept.GetApprovedSpan();
|
||||
if (span == null)
|
||||
{
|
||||
span = invoice.InvoiceBase.CostBearer2SupportConcept.GetRequestedSpan();
|
||||
}
|
||||
if (span != null)
|
||||
{
|
||||
invoice.InvoiceBase.InvoiceTitle = String.Format("{0}, {1}, {2:dd.MM.yyy}-{3:dd.MM.yy}", p.LastName,
|
||||
p.FirstName, span.StartDate, span.EndDate);
|
||||
}
|
||||
else
|
||||
{
|
||||
invoice.InvoiceBase.InvoiceTitle = String.Format("{0}, {1}", p.LastName, p.FirstName);
|
||||
if (invoice.InvoiceBase.CostBearer2SupportConcept.StartDate.HasValue)
|
||||
{
|
||||
invoice.InvoiceBase.InvoiceTitle += String.Format(", {0:dd.MM.yyy}-", invoice.InvoiceBase.CostBearer2SupportConcept.StartDate.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override InvoiceItem CreateInvoiceItem(ServiceRecordDC iServiceRecord, SupportConceptApprovalPeriod scap, BS.Shared.Services.Calculations calc)
|
||||
{
|
||||
var ii = base.CreateInvoiceItem(iServiceRecord, scap, calc);
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Windows;
|
||||
using BeWo.Data;
|
||||
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;
|
||||
|
||||
namespace CaritasverbandDuerenJuelichEV.Service
|
||||
{
|
||||
public class CustomAccountingService : AccountingService
|
||||
{
|
||||
// entspricht dem Original, außer dass die Bewilligung des Hilfeplans abgelaufen sein kann, wenn die Beantragten-Daten länger laufen bzw. kein Enddate haben
|
||||
public override List<ServiceInvoiceDC> GenerateInitialServiceInvoices(long costBearerOid, long? supportConceptOid, DateTimeSpan invoicePeriod)
|
||||
{
|
||||
var cs = PluginLoader.FindClass<CustomerService>();
|
||||
IEnumerable<CompactSupportConceptDC> supportConcepts;
|
||||
// GetAllActiveSupportConceptCostbearer returns a "Flat" SupportConcept List, one for each CostBearer2SupportConcept!
|
||||
if (!supportConceptOid.HasValue)
|
||||
{
|
||||
supportConcepts = cs.GetAllActiveSupportConceptCostbearer(false, true, 0)
|
||||
.Where(i => i.CostBearerOids2CostBearerRelOids.ContainsKey(costBearerOid));
|
||||
}
|
||||
else
|
||||
{
|
||||
supportConcepts = cs.GetCompactSupportConcepts(supportConceptOid.Value, null)
|
||||
.Where(i => i.CostBearerOids2CostBearerRelOids.ContainsKey(costBearerOid));
|
||||
}
|
||||
|
||||
DateTimeSpan newSpan = null;
|
||||
if (invoicePeriod != null)
|
||||
{
|
||||
//invoicePeriod.StartDateTime = invoicePeriod.StartDateTime.Date;
|
||||
//invoicePeriod.EndDateTime = invoicePeriod.EndDateTime.Date;
|
||||
newSpan = new DateTimeSpan();
|
||||
newSpan.StartDateTime = invoicePeriod.StartDateTime.Date;
|
||||
newSpan.EndDateTime = invoicePeriod.EndDateTime.Date.AddDays(1).AddTicks(-1);
|
||||
//if (!supportConceptOid.HasValue)
|
||||
//{
|
||||
// supportConcepts =
|
||||
// supportConcepts.Where(sc => sc.StartDate < newSpan.EndDateTime && sc.EndDate >= newSpan.StartDate);
|
||||
//}
|
||||
}
|
||||
var supportConcepts2ServiceRecords = supportConcepts.ToDictionary(
|
||||
i => i,
|
||||
i => MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDCs(
|
||||
DAOFactory.SearchDAO.FindServiceRecordsInSpan(i.CostBearerRelOids[0], newSpan)));
|
||||
var cb = DAOFactory.GenericDAO.LoadByID<CostBearer>(costBearerOid);
|
||||
String tenant = PluginLoader.Tenant;
|
||||
var factory = PluginLoader.FindClass<InvoiceFactory>(cb.ID);
|
||||
if (factory == null)
|
||||
{
|
||||
factory = InvoiceFactory.GetInstance(cb.ID, tenant);
|
||||
}
|
||||
|
||||
var creator = factory.CreateInvoiceCreator(cb.ID, tenant, supportConcepts2ServiceRecords);
|
||||
var newInvoices = creator.GenerateServiceInvoices(costBearerOid, invoicePeriod, supportConcepts2ServiceRecords);
|
||||
|
||||
|
||||
//Prüfe ob Rechnungen neu sind oder Diff vorhanden
|
||||
var differenzRechnungChecks = GetNewInvoices(newInvoices, invoicePeriod?.StartDate, invoicePeriod?.EndDate);
|
||||
var resultList = ErstelleNeueRechnungen(differenzRechnungChecks);
|
||||
|
||||
|
||||
return resultList;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user