BetreutesWohnenWoellReports/Invoicing/JugendamtInvoiceCreation - Erweiterung für Selbstzahler mit Fahrtkosten
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using BeWo.Data.Entities;
|
||||
using BeWo.Service.DCEntityMapper;
|
||||
using BeWo.Service.Invoicing;
|
||||
using BS.Shared;
|
||||
using BS.Shared.Core;
|
||||
@@ -18,20 +19,91 @@ namespace BetreutesWohnenWoellReports.Invoicing
|
||||
{
|
||||
var inv = base.CreateSingleInvoice(invoiceCounter, costBearer, invoicePeriod, supportConcept, serviceRecords);
|
||||
|
||||
// war bis 05.11.2024 nötig, jetzt sind alles Jugendamtsrechnungen
|
||||
// war bis 05.11.2024 nötig, jetzt sind alles Jugendamtsrechnungen bzw. Selbstzahler nach gleicher Logik
|
||||
//if (inv.InvoiceBase.CostBearer2SupportConcept.CostBearer.Organisation.Function != null && inv.InvoiceBase.CostBearer2SupportConcept.CostBearer.Organisation.Function.Value == "Jugendamt")
|
||||
inv.InvoiceBase.InvoiceId = "Jugendamt";
|
||||
|
||||
return inv;
|
||||
}
|
||||
|
||||
public override void SetRecipientInformation(ServiceInvoice serviceInvoice, CostBearer costBearer)
|
||||
{
|
||||
if (costBearer.Organisation.Name.ToLower() == "selbstzahler" || costBearer.Organisation.Name.ToLower().StartsWith("sz -") || costBearer.Organisation.Name.ToLower().Contains("selbstzahler"))
|
||||
{
|
||||
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 != 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;
|
||||
}
|
||||
serviceInvoice.InvoiceBase.RecipientPersonOid = cust.Person.Oid;
|
||||
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;
|
||||
serviceInvoice.InvoiceBase.RecipientPersonOid = serviceInvoice.InvoiceBase.CostBearer2SupportConcept.CostBearerContactPerson.Oid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override IList<InvoiceItem> CreateInvoiceItems(List<ServiceRecordDC> serviceRecordsInPeriod, DateTimeSpan invoicePeriod, SupportConceptApprovalPeriod scap, Calculations calc)
|
||||
{
|
||||
var list = new List<InvoiceItem>();
|
||||
foreach (ServiceRecordDC iServiceRecord in serviceRecordsInPeriod)
|
||||
{
|
||||
if (iServiceRecord.ServiceDescription.Name.Contains("face to face"))
|
||||
{ }
|
||||
|
||||
if (iServiceRecord.ServiceDescription.Category.IsBillable)
|
||||
{
|
||||
if (!iServiceRecord.AlreadyAccounted)
|
||||
@@ -42,10 +114,11 @@ namespace BetreutesWohnenWoellReports.Invoicing
|
||||
invoiceItem.Notice = iServiceRecord.ServiceDescription.CategoryName;
|
||||
if (invoiceItem != null)
|
||||
{
|
||||
var name = scap.CostBearer2SupportConcept.CostBearer.Organisation.Name;
|
||||
var function = scap.CostBearer2SupportConcept.CostBearer.Organisation.Function;
|
||||
list.Add(invoiceItem);
|
||||
if (iServiceRecord.DistanceInMeter.HasValue && iServiceRecord.DistanceInMeter.Value > 0)
|
||||
list.Add(CreateFahrtkostenItem(invoiceItem, function));
|
||||
list.Add(CreateFahrtkostenItem(invoiceItem, function, name));
|
||||
}
|
||||
iServiceRecord.AlreadyAccounted = true;
|
||||
}
|
||||
@@ -60,16 +133,58 @@ namespace BetreutesWohnenWoellReports.Invoicing
|
||||
//return CreateSummaryInvoiceItems(list, invoicePeriod, scap, calc);
|
||||
}
|
||||
|
||||
private InvoiceItem CreateFahrtkostenItem(InvoiceItem item, ValueListEntry function)
|
||||
public override InvoiceItem CreateInvoiceItem(ServiceRecordDC iServiceRecord, SupportConceptApprovalPeriod scap, BS.Shared.Services.Calculations calc)
|
||||
{
|
||||
var preis = GetPreis("Fahrkosten", item.ServiceRecord.Start.Value);
|
||||
var ii = base.CreateInvoiceItem(iServiceRecord, scap, calc);
|
||||
if (iServiceRecord.CostBearer.Name == "EB-Selbstzahler")
|
||||
{
|
||||
var stundensatz = GetStundensatz(scap.CostBearer2SupportConcept, null, iServiceRecord.Start);
|
||||
if (stundensatz != 0)
|
||||
{
|
||||
ii.AmountPerUnit = stundensatz;
|
||||
ii.AmountTotal = stundensatz * ii.UnitCount;
|
||||
ii.GrossAmountTotal = stundensatz * ii.UnitCount;
|
||||
}
|
||||
}
|
||||
return ii;
|
||||
}
|
||||
|
||||
if (function != null && function.Value.IsNotNullOrEmpty())
|
||||
private decimal GetStundensatz(CostBearer2SupportConcept c2s, long? vleOid, DateTime? date)
|
||||
{
|
||||
if (c2s.CostBearer.CostRatePeriods != null)
|
||||
{
|
||||
var crpList = MapperFactory.CostRatePeriodDC_CostRatePeriod.MapToNewDCs(c2s.CostBearer.CostRatePeriods);
|
||||
var cp = crpList.GetCostRatePeriodForDate(CostRatePeriodType.HourlyRate, (DateTime)date);
|
||||
if (vleOid != null)
|
||||
{
|
||||
cp = crpList.GetCostRatePeriodForDate(CostRatePeriodType.HourlyRate, (DateTime)date, vleOid.Value);
|
||||
}
|
||||
if (cp != null && cp.CostRateValue.HasValue)
|
||||
{
|
||||
return cp.CostRateValue.Value;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private InvoiceItem CreateFahrtkostenItem(InvoiceItem item, ValueListEntry function, string name)
|
||||
{
|
||||
var preis = GetPreis("Fahrtkosten Jugendamt", item.ServiceRecord.Start.Value);
|
||||
|
||||
if (name != null && name == "EB-Selbstzahler")
|
||||
{
|
||||
preis = GetPreis("Fahrkosten EB Selbstzahler", item.ServiceRecord.Start.Value);
|
||||
}
|
||||
else if (name != null && name == "SZ - Assistenz")
|
||||
{
|
||||
preis = GetPreis("Fahrkosten SZ ASS", item.ServiceRecord.Start.Value);
|
||||
}
|
||||
else if (function != null && function.Value.IsNotNullOrEmpty())
|
||||
{
|
||||
if (function.Value == "Pflegekassen")
|
||||
preis = GetPreis("Fahrtkosten Pflegekasse", item.ServiceRecord.Start.Value);
|
||||
else if (function.Value == "Jugendamt")
|
||||
preis = GetPreis("Fahrtkosten Jugendamt", item.ServiceRecord.Start.Value);
|
||||
//else if (function.Value == "Jugendamt")
|
||||
// preis = GetPreis("Fahrtkosten Jugendamt", item.ServiceRecord.Start.Value);
|
||||
}
|
||||
InvoiceItem fahrtkostenItem = new InvoiceItem();
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ namespace BetreutesWohnenWoellReports
|
||||
private void SetzeAdresse(ServiceInvoiceRO pRO)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (!String.IsNullOrEmpty(pRO.RecipientOrganisation) && pRO.RecipientOrganisation.ToLower() != "selbstzahler")
|
||||
if (!String.IsNullOrEmpty(pRO.RecipientOrganisation) && !pRO.RecipientOrganisation.ToLower().StartsWith("sz -") && !pRO.RecipientOrganisation.ToLower().Contains("selbstzahler"))
|
||||
{
|
||||
sb.AppendLine(pRO.RecipientOrganisation);
|
||||
}
|
||||
@@ -130,7 +130,7 @@ namespace BetreutesWohnenWoellReports
|
||||
{
|
||||
sb.AppendLine(pRO.RecipientContactPerson);
|
||||
}
|
||||
if (!String.IsNullOrEmpty(pRO.RecipientDivision) && !String.IsNullOrEmpty(pRO.RecipientOrganisation) && pRO.RecipientOrganisation.ToLower() != "selbstzahler")
|
||||
if (!String.IsNullOrEmpty(pRO.RecipientDivision) && !String.IsNullOrEmpty(pRO.RecipientOrganisation) && !pRO.RecipientOrganisation.ToLower().Contains("selbstzahler") && !pRO.RecipientOrganisation.ToLower().StartsWith("sz -"))
|
||||
{
|
||||
sb.AppendLine(pRO.RecipientDivision);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user