|
|
|
|
@@ -0,0 +1,175 @@
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
using System.Windows.Forms.VisualStyles;
|
|
|
|
|
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 LebenshilfeCoburg.Invoicing
|
|
|
|
|
{
|
|
|
|
|
public class LhCoburgWohnheimInvoiceCreation : InvoiceCreation
|
|
|
|
|
{
|
|
|
|
|
private DateTime? accountingPeriodStart = null;
|
|
|
|
|
private DateTime? accountingPeriodEnd = null;
|
|
|
|
|
|
|
|
|
|
public override void SetInvoiceId(ServiceInvoice invoice)
|
|
|
|
|
{
|
|
|
|
|
invoice.InvoiceBase.InvoiceId = "Wohnheim";
|
|
|
|
|
invoice.InvoiceBase.InvoiceTypeText = "Wohnheim";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 SetInvoiceItems(ServiceInvoice invoice,
|
|
|
|
|
ServiceInvoicePeriod serviceInvoicePeriod,
|
|
|
|
|
SupportConceptApprovalPeriodDC supportConceptApprovalPeriod,
|
|
|
|
|
CostBearer2SupportConcept cb2sc,
|
|
|
|
|
DateTimeSpan invoicePeriod,
|
|
|
|
|
List<ServiceRecordDC> serviceRecords)
|
|
|
|
|
{
|
|
|
|
|
CreateFixedAmounts(serviceInvoicePeriod, supportConceptApprovalPeriod, cb2sc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override ServiceInvoice CreateSingleInvoice(int invoiceCounter, CostBearer costBearer, DateTimeSpan invoicePeriod, CompactSupportConceptDC supportConcept, List<ServiceRecordDC> serviceRecords)
|
|
|
|
|
{
|
|
|
|
|
if (supportConcept.IsApproved)
|
|
|
|
|
{
|
|
|
|
|
var invoice = new ServiceInvoice();
|
|
|
|
|
|
|
|
|
|
var supportConceptList = new List<CompactSupportConceptDC> { supportConcept };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SetSenderInformation(invoice);
|
|
|
|
|
SetInvoiceBaseData(invoiceCounter, invoice, costBearer, invoicePeriod, supportConceptList);
|
|
|
|
|
SetSingleInvoiceBaseData(invoiceCounter, invoice, costBearer, invoicePeriod, supportConcept);
|
|
|
|
|
|
|
|
|
|
SetRecipientInformation(invoice, costBearer);
|
|
|
|
|
|
|
|
|
|
serviceRecords = MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDCs(DAOFactory.SearchDAO.FindServiceRecordsInSpan(invoicePeriod, null))
|
|
|
|
|
.Where(s => s.ServiceDescription.CategoryName == "Arbeitszeitstunden" || s.ServiceDescription.CategoryName == "Nachtdienst" || s.ServiceDescription.CategoryName == "individuelle Begleitung Hilfskraft").ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SetServiceInvoicePeriods(invoice, invoice.InvoiceBase.CostBearer2SupportConcept, invoicePeriod,
|
|
|
|
|
serviceRecords);
|
|
|
|
|
|
|
|
|
|
SetServiceInvoicePeriodAmounts(invoice);
|
|
|
|
|
|
|
|
|
|
// Spitzabrechnung
|
|
|
|
|
if (invoicePeriod == null)
|
|
|
|
|
{
|
|
|
|
|
SetAmountAdvancePayments(invoice);
|
|
|
|
|
SetAmountEquityContribution(invoice);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return invoice;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override void SetServiceInvoicePeriods(ServiceInvoice invoice, CostBearer2SupportConcept costBearer2SupportConcept, DateTimeSpan invoicePeriod, List<ServiceRecordDC> serviceRecords)
|
|
|
|
|
{
|
|
|
|
|
var invoiceAccountingPeriodSpan = new DateTimeSpan
|
|
|
|
|
{
|
|
|
|
|
StartDateTime = invoice.InvoiceBase.AccountingPeriodStart.Value,
|
|
|
|
|
EndDateTime = invoice.InvoiceBase.AccountingPeriodEnd.Value
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//foreach (SupportConceptApprovalPeriod iPeriod in costBearer2SupportConcept.ApprovalPeriodList)
|
|
|
|
|
//{
|
|
|
|
|
// SupportConceptApprovalPeriodDC approvalPeriodDC = MapperFactory.SupportConceptApprovalPeriodDC_SupportConceptApprovalPeriod.MapToNewDC(iPeriod);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//if (approvalPeriodDC.Span.EndDateTime < invoiceAccountingPeriodSpan.StartDateTime || approvalPeriodDC.Span.StartDateTime > invoiceAccountingPeriodSpan.EndDate)
|
|
|
|
|
//{
|
|
|
|
|
// continue;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//ServiceInvoicePeriod serviceInvoicePeriod = CreateServiceInvoicePeriod(approvalPeriodDC, invoiceAccountingPeriodSpan);
|
|
|
|
|
//serviceInvoicePeriod.SupportConceptApprovalPeriod = iPeriod;
|
|
|
|
|
//serviceInvoicePeriod.Customer = costBearer2SupportConcept.SupportConcept.Customer;
|
|
|
|
|
|
|
|
|
|
//CostBearer costBearer = costBearer2SupportConcept.CostBearer;
|
|
|
|
|
//List<CostRatePeriodDC> costRates = MapperFactory.CostRatePeriodDC_CostRatePeriod.MapToNewDCs(costBearer.CostRatePeriods);
|
|
|
|
|
|
|
|
|
|
//CostRatePeriodDC serviceUnit = costRates.GetCostRatePeriodForDate(CostRatePeriodType.MinutesPerServiceUnit, DateTime.Now);
|
|
|
|
|
//serviceInvoicePeriod.ServiceUnitName = serviceUnit.UnitName;
|
|
|
|
|
|
|
|
|
|
//Calculations calc = PluginLoader.FindClass<Calculations>(_SpecificID) ?? Calculations.GetInstance(_SpecificID);
|
|
|
|
|
|
|
|
|
|
//decimal amountPerUnit;
|
|
|
|
|
//decimal unitCount;
|
|
|
|
|
|
|
|
|
|
//serviceInvoicePeriod.ApprovedFixedAmount = calc.GetApprovedFixedAmountForPeriod(approvalPeriodDC, serviceInvoicePeriod.Start.Value, serviceInvoicePeriod.End.Value, out amountPerUnit, out unitCount);
|
|
|
|
|
|
|
|
|
|
//if (!serviceInvoicePeriod.ApprovedFixedAmount.HasValue)
|
|
|
|
|
//{
|
|
|
|
|
// serviceInvoicePeriod.ApprovedHours = calc.GetApprovedHoursForPeriod(approvalPeriodDC,
|
|
|
|
|
// costRates,
|
|
|
|
|
// serviceInvoicePeriod.Start.Value,
|
|
|
|
|
// serviceInvoicePeriod.End.Value);
|
|
|
|
|
// if (serviceInvoicePeriod.ApprovedHours.HasValue)
|
|
|
|
|
// serviceInvoicePeriod.ApprovedBE = serviceUnit.GetHoursInBE(serviceInvoicePeriod.ApprovedHours.Value);
|
|
|
|
|
|
|
|
|
|
// serviceInvoicePeriod.ApprovedAmountDefaultHourlyRate = calc.GetApprovedAmountDefaultHourlyRateForPeriod(approvalPeriodDC,
|
|
|
|
|
// costRates,
|
|
|
|
|
// serviceInvoicePeriod.Start,
|
|
|
|
|
// serviceInvoicePeriod.End);
|
|
|
|
|
//}
|
|
|
|
|
//SetInvoiceItems(invoice, serviceInvoicePeriod, approvalPeriodDC, costBearer2SupportConcept, invoicePeriod, serviceRecords);
|
|
|
|
|
|
|
|
|
|
//CheckMaxApprovedAmount(invoice, serviceInvoicePeriod, approvalPeriodDC, costBearer2SupportConcept, invoicePeriod, serviceRecords);
|
|
|
|
|
|
|
|
|
|
//if (serviceInvoicePeriod.InvoiceItemList.Count > 0)
|
|
|
|
|
// invoice.ServiceInvoicePeriodList.Add(serviceInvoicePeriod);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void CreateFixedAmounts(ServiceInvoicePeriod serviceInvoicePeriod, SupportConceptApprovalPeriodDC supportConceptApprovalPeriod, CostBearer2SupportConcept cb2sc)
|
|
|
|
|
{
|
|
|
|
|
var calc = PluginLoader.FindClass<Calculations>(_SpecificID) ?? Calculations.GetInstance(_SpecificID);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//var data = calc.GetFixedBillingData(supportConceptApprovalPeriod, serviceInvoicePeriod.Start, serviceInvoicePeriod.End);
|
|
|
|
|
|
|
|
|
|
//foreach (var billingData in data)
|
|
|
|
|
//{
|
|
|
|
|
// serviceInvoicePeriod.InvoiceItemList.Add(new InvoiceItem
|
|
|
|
|
// {
|
|
|
|
|
// AmountTotal = billingData.AmountTotal,
|
|
|
|
|
// GrossAmountTotal = billingData.GrossAmountTotal,
|
|
|
|
|
// ItemPeriodStart = billingData.BillingPeriodStart,
|
|
|
|
|
// ItemPeriodEnd = billingData.BillingPeriodEnd,
|
|
|
|
|
// AccountingInterval = billingData.AccountingInterval,
|
|
|
|
|
// AmountPerUnit = billingData.AmountPerUnit,
|
|
|
|
|
// UnitCount = billingData.UnitCount
|
|
|
|
|
// });
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|