SBBMainzReports - Zwischenstand Invoicing
This commit is contained in:
57
ReportImp/SBBMainzReports/Invoicing/CustomInvoiceCreation.cs
Normal file
57
ReportImp/SBBMainzReports/Invoicing/CustomInvoiceCreation.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using BeWo.Data.Entities;
|
||||
using BeWo.Service.DCEntityMapper;
|
||||
using BeWo.Service.Invoicing;
|
||||
using BeWo.Service.Plugins;
|
||||
using BS.Shared.Core;
|
||||
using BS.Shared.DataContracts;
|
||||
using BS.Shared.DataContracts.Compact;
|
||||
using BS.Shared.Extensions;
|
||||
using BS.Shared.Services;
|
||||
|
||||
namespace SbbMainzReports.Invoicing
|
||||
{
|
||||
public class CustomInvoiceCreation : InvoiceCreation
|
||||
{
|
||||
public override void SetInvoiceItems(ServiceInvoice invoice,
|
||||
ServiceInvoicePeriod serviceInvoicePeriod,
|
||||
SupportConceptApprovalPeriodDC supportConceptApprovalPeriod,
|
||||
CostBearer2SupportConcept cb2sc,
|
||||
DateTimeSpan invoicePeriod,
|
||||
List<ServiceRecordDC> serviceRecords)
|
||||
{
|
||||
var calc = PluginLoader.FindClass<BS.Shared.Services.Calculations>(_SpecificID) ?? BS.Shared.Services.Calculations.GetInstance(_SpecificID);
|
||||
|
||||
if (ShouldCreateFixedAmounts(serviceInvoicePeriod, supportConceptApprovalPeriod, cb2sc))
|
||||
{
|
||||
CreateFixedAmounts(serviceInvoicePeriod, supportConceptApprovalPeriod, cb2sc);
|
||||
}
|
||||
else
|
||||
{
|
||||
List<ServiceRecordDC> serviceRecordsInPeriod = serviceRecords.Where(
|
||||
i =>
|
||||
{
|
||||
bool valid = i.Start.Value.InBetween(serviceInvoicePeriod.Start.Value,
|
||||
serviceInvoicePeriod.End.Value, true);
|
||||
|
||||
if (valid && serviceInvoicePeriod.SupportConceptApprovalPeriod != null && serviceInvoicePeriod.SupportConceptApprovalPeriod.ServiceCategory != null)
|
||||
valid = serviceInvoicePeriod.SupportConceptApprovalPeriod.ServiceCategory.Oid ==
|
||||
i.ServiceDescription.Category.ServiceCategoryOid;
|
||||
return valid;
|
||||
}).ToList();
|
||||
|
||||
if (serviceRecordsInPeriod.Count > 0)
|
||||
{
|
||||
var itemList = CreateInvoiceItems(serviceRecordsInPeriod, invoicePeriod, serviceInvoicePeriod.SupportConceptApprovalPeriod, calc);
|
||||
serviceInvoicePeriod.InvoiceItemList.AddRange(itemList);
|
||||
}
|
||||
}
|
||||
}
|
||||
public override string GetSummaryItemKey(SupportConceptApprovalPeriod scap, InvoiceItem iitem, bool summaryPerMonth)
|
||||
{
|
||||
return String.Format("{0}_{1}_{2}", iitem.AmountPerUnit, iitem.RateFactor, iitem.ItemDescription);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -76,6 +76,8 @@
|
||||
<Compile Include="CustomerDataReport.designer.cs">
|
||||
<DependentUpon>CustomerDataReport.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Invoicing\CustomInvoiceCreation.cs" />
|
||||
<Compile Include="Invoicing\CustomInvoiceFactory.cs" />
|
||||
<Compile Include="LeistungsbestaetigungRlpTs.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
|
||||
Reference in New Issue
Block a user