DiakonischesWerkPassau/Invoicing
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using BeWo.Data.Access;
|
||||
using BeWo.Data.Entities;
|
||||
using BeWo.Service.Invoicing;
|
||||
using BS.Shared.DataContracts;
|
||||
using BS.Shared.DataContracts.Compact;
|
||||
using BS.Shared.Services;
|
||||
|
||||
namespace DiakonischesWerkPassau.Invoicing
|
||||
{
|
||||
public class CustomInvoiceFactory : InvoiceFactory
|
||||
{
|
||||
|
||||
public override InvoiceCreation CreateInvoiceCreator(string specificId, string tenant, Dictionary<CompactSupportConceptDC, List<ServiceRecordDC>> supportConcepts2ServiceRecords)
|
||||
{
|
||||
foreach (var list in supportConcepts2ServiceRecords.Values)
|
||||
{
|
||||
|
||||
foreach (var sr in list)
|
||||
{
|
||||
if (sr.CostBearer != null)
|
||||
{
|
||||
if (sr.CostBearer.Name.ToLower().Contains("selbstzahler"))
|
||||
{
|
||||
return new SelbstzahlerInvoiceCreation();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new InvoiceCreation();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
using BeWo.Data.Entities;
|
||||
using BeWo.Service.Invoicing;
|
||||
using BS.Shared.Core;
|
||||
using BS.Shared.DataContracts.Compact;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace DiakonischesWerkPassau.Invoicing
|
||||
{
|
||||
|
||||
public class SelbstzahlerInvoiceCreation : InvoiceCreation
|
||||
{
|
||||
private DateTime? accountingPeriodStart = null;
|
||||
private DateTime? accountingPeriodEnd = null;
|
||||
|
||||
public override void SetInvoiceBaseData(int invoiceCounter, ServiceInvoice invoice, CostBearer costBearer, DateTimeSpan invoicePeriod,
|
||||
IList<CompactSupportConceptDC> supportConceptList)
|
||||
{
|
||||
if (invoicePeriod != null)
|
||||
{
|
||||
accountingPeriodStart = invoicePeriod.StartDate;
|
||||
accountingPeriodEnd = invoicePeriod.EndDate;
|
||||
}
|
||||
base.SetInvoiceBaseData(invoiceCounter, invoice, costBearer, invoicePeriod, supportConceptList);
|
||||
}
|
||||
|
||||
public override void SetRecipientInformation(ServiceInvoice serviceInvoice, CostBearer costBearer)
|
||||
{
|
||||
serviceInvoice.InvoiceBase.RecipientDivision = costBearer.Organisation.Name2;
|
||||
serviceInvoice.InvoiceBase.RecipientOrganisationOid = costBearer.Organisation.Oid;
|
||||
serviceInvoice.InvoiceBase.RecipientOrganisation = costBearer.Organisation.Name;
|
||||
serviceInvoice.InvoiceBase.RecipientContacts = costBearer.Organisation.Contacts.Select(i => i.CopyToNew()).ToList();
|
||||
serviceInvoice.InvoiceBase.RecipientCostBearerOid = costBearer.Oid;
|
||||
|
||||
if (serviceInvoice.InvoiceBase.CostBearer2SupportConcept != null)
|
||||
{
|
||||
var cust = serviceInvoice.InvoiceBase.CostBearer2SupportConcept.SupportConcept.Customer;
|
||||
|
||||
if (cust.Person.InvoiceAddress != null)
|
||||
{
|
||||
serviceInvoice.InvoiceBase.RecipientAddress = cust.Person.InvoiceAddress.CopyToNew();
|
||||
}
|
||||
else if (cust.Person.Address != null)
|
||||
{
|
||||
serviceInvoice.InvoiceBase.RecipientAddress = cust.Person.Address.CopyToNew();
|
||||
}
|
||||
|
||||
if (cust.Person.InvoiceAddress.AddressLine1 != null)
|
||||
{
|
||||
serviceInvoice.InvoiceBase.RecipientPersonFirstName = cust.Person.InvoiceAddress.AddressLine1;
|
||||
serviceInvoice.InvoiceBase.RecipientPersonLastName = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
serviceInvoice.InvoiceBase.RecipientPersonFirstName = cust.Person.FirstName;
|
||||
serviceInvoice.InvoiceBase.RecipientPersonLastName = cust.Person.LastName;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (costBearer.Organisation.InvoiceAddress != null)
|
||||
{
|
||||
serviceInvoice.InvoiceBase.RecipientAddress = costBearer.Organisation.InvoiceAddress.CopyToNew();
|
||||
}
|
||||
else if (costBearer.Organisation.Address != null)
|
||||
{
|
||||
serviceInvoice.InvoiceBase.RecipientAddress = costBearer.Organisation.Address.CopyToNew();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user