86 lines
4.7 KiB
C#
86 lines
4.7 KiB
C#
using BeWo.Data.Entities;
|
|
using BeWo.Service.Invoicing;
|
|
using System.Linq;
|
|
using BeWo.Data.Access;
|
|
|
|
namespace BeWoTrio.Invoicing
|
|
{
|
|
|
|
public class CustomInvoiceCreation : InvoiceCreation
|
|
{
|
|
public override void SetRecipientInformation(ServiceInvoice serviceInvoice, CostBearer costBearer)
|
|
{
|
|
if (costBearer.Organisation.Name.ToLower().Contains("selbstzahler") || costBearer.Organisation.Name.ToLower().Contains("budget"))
|
|
{
|
|
serviceInvoice.InvoiceBase.RecipientDivision = costBearer.Organisation.Name2;
|
|
serviceInvoice.InvoiceBase.RecipientOrganisationOid = costBearer.Organisation.Oid;
|
|
serviceInvoice.InvoiceBase.RecipientOrganisation = costBearer.Organisation.Name;
|
|
if(costBearer.Organisation.Name.ToLower().Contains("selbstzahler"))
|
|
{
|
|
serviceInvoice.InvoiceBase.RecipientOrganisation = "Selbstzahler";
|
|
}
|
|
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 != null && cust.Person.InvoiceAddress.AddressLine1 != null) // Anderer Rechnungsempfänger z.B. Vormund
|
|
{
|
|
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();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
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();
|
|
}
|
|
|
|
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;
|
|
|
|
//serviceInvoice.InvoiceBase. = c2s.CostBearer.Organisation.Contacts.FirstOrDefault(f => f.Type.Equals(ContactType.business_POBox)) != null ? c2s.CostBearer.Organisation.Contacts.FirstOrDefault(f => f.Type.Equals(ContactType.business_POBox)).Value : String.Empty;
|
|
|
|
if (serviceInvoice.InvoiceBase.CostBearer2SupportConcept != null &&
|
|
serviceInvoice.InvoiceBase.CostBearer2SupportConcept.CostBearerContactPerson != null)
|
|
{
|
|
serviceInvoice.InvoiceBase.RecipientPersonFirstName = serviceInvoice.InvoiceBase.CostBearer2SupportConcept.CostBearerContactPerson.FirstName;
|
|
serviceInvoice.InvoiceBase.RecipientPersonLastName = serviceInvoice.InvoiceBase.CostBearer2SupportConcept.CostBearerContactPerson.LastName;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |