Files
BeWoPlaner/Service/Plugins/AccountingService.cs
Christian 00dab4f3c8 Merge branch 'master' of ssh://float.beyondsoft.de/git/beyondSoft/BeWo
# Conflicts:
#	BeWoAllReports.sln
#	Service/Plugins/AccountingService.cs
2024-04-11 09:27:49 +02:00

593 lines
24 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BeWo.Service.Core;
using BeWo.Service.DCEntityMapper;
using BeWo.Service.Invoicing;
using BeWo.Service.ServiceContracts;
using BS.Shared;
using BS.Shared.Core;
using BS.Shared.DataContracts;
using BS.Shared.DataContracts.Compact;
using BS.Shared.Extensions;
namespace BeWo.Service.Plugins
{
public class AccountingService : AbstractIDSpecificDefaultClass<AccountingService>
{
public virtual List<ServiceInvoiceDC> GenerateInitialServiceInvoices(long costBearerOid, long? supportConceptOid, DateTimeSpan invoicePeriod)
{
var cs = PluginLoader.FindClass<CustomerService>();
IEnumerable<CompactSupportConceptDC> supportConcepts;
// GetAllActiveSupportConceptCostbearer returns a "Flat" SupportConcept List, one for each CostBearer2SupportConcept!
if (!supportConceptOid.HasValue)
{
supportConcepts = cs.GetAllActiveSupportConceptCostbearer(false, true, 0)
.Where(i => i.CostBearerOids2CostBearerRelOids.ContainsKey(costBearerOid));
}
else
{
supportConcepts = cs.GetCompactSupportConcepts(supportConceptOid.Value, null)
.Where(i => i.CostBearerOids2CostBearerRelOids.ContainsKey(costBearerOid));
}
DateTimeSpan newSpan = null;
if (invoicePeriod != null)
{
//invoicePeriod.StartDateTime = invoicePeriod.StartDateTime.Date;
//invoicePeriod.EndDateTime = invoicePeriod.EndDateTime.Date;
newSpan = new DateTimeSpan();
newSpan.StartDateTime = invoicePeriod.StartDateTime.Date;
newSpan.EndDateTime = invoicePeriod.EndDateTime.Date.AddDays(1).AddTicks(-1);
if (!supportConceptOid.HasValue)
{
supportConcepts =
supportConcepts.Where(sc => sc.StartDate < newSpan.EndDateTime && sc.EndDate >= newSpan.StartDate);
}
}
var supportConcepts2ServiceRecords = supportConcepts.ToDictionary(
i => i,
i => MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDCs(
DAOFactory.SearchDAO.FindServiceRecordsInSpan(i.CostBearerRelOids[0], newSpan)));
var cb = DAOFactory.GenericDAO.LoadByID<CostBearer>(costBearerOid);
String tenant = PluginLoader.Tenant;
var factory = PluginLoader.FindClass<InvoiceFactory>(cb.ID);
if (factory == null)
{
factory = InvoiceFactory.GetInstance(cb.ID, tenant);
}
var creator = factory.CreateInvoiceCreator(cb.ID, tenant, supportConcepts2ServiceRecords);
var newInvoices = creator.GenerateServiceInvoices(costBearerOid, invoicePeriod, supportConcepts2ServiceRecords);
//Prüfe ob Rechnungen neu sind oder Diff vorhanden
var differenzRechnungChecks = GetNewInvoices(newInvoices, invoicePeriod?.StartDate, invoicePeriod?.EndDate);
var resultList = ErstelleNeueRechnungen(differenzRechnungChecks);
return resultList;
}
protected virtual List<ServiceInvoiceDC> ErstelleNeueRechnungen(List<DifferenzRechnungCheck> differenzRechnungChecks)
{
var rechnungen = new List<ServiceInvoiceDC>();
foreach (var item in differenzRechnungChecks)
{
if (item.VorhandeneRechungen.Count == 0)
{
item.NeueRechnung.InvoiceBase.NeuErstellen = true;
rechnungen.Add(item.NeueRechnung);
}
else
{
rechnungen.Add(ErstelleDifferenzRechnung(item));
}
}
return rechnungen;
}
protected virtual ServiceInvoiceDC ErstelleDifferenzRechnung(DifferenzRechnungCheck item)
{
ServiceInvoiceDC diffRechnung = null;
var alterBetrag = item.VorhandeneRechungen.Sum(i => i.ClaimSum ?? 0);
if (item.NeueRechnung.ClaimSum == alterBetrag)
{
diffRechnung = item.NeueRechnung;
diffRechnung.InvoiceBase.NeuErstellen = false;
diffRechnung.InvoiceBase.Hinweise = String.Format("Rechnung wurde bereits erstellt");
}
else
{
diffRechnung = new ServiceInvoiceDC();
diffRechnung.OriginalZurDifferenz = item.NeueRechnung;
diffRechnung.InvoiceBase = new InvoiceBaseDC();
CopyInvoiceBaseDC(item.NeueRechnung.InvoiceBase, diffRechnung);
var newItem = new InvoiceItemDC();
newItem.ItemPeriodStart = item.NeueRechnung.InvoiceBase.AccountingPeriodStart;
newItem.ItemPeriodEnd = item.NeueRechnung.InvoiceBase.AccountingPeriodEnd;
newItem.UnitCount = 1;
newItem.AmountPerUnit = item.NeueRechnung.ClaimSum - alterBetrag;
newItem.AmountTotal = newItem.AmountPerUnit;
newItem.GrossAmountTotal = newItem.AmountTotal;
newItem.ItemDescription = String.Format("Rechnungsdifferenz zu Rechnung {0} in Höhe von {1:c}", item.VorhandeneRechungen[0].InvoiceBase.InvoiceNumber, alterBetrag);
diffRechnung.InvoiceBase.Hinweise = String.Format("Rechnungsdifferenz zu Rechnung {0} in Höhe von {1:c}", item.VorhandeneRechungen[0].InvoiceBase.InvoiceNumber, alterBetrag);
var newSip = new ServiceInvoicePeriodDC();
newSip.Claim = newItem.AmountTotal;
newSip.Start = item.NeueRechnung.InvoiceBase.AccountingPeriodStart;
newSip.End = item.NeueRechnung.InvoiceBase.AccountingPeriodEnd;
diffRechnung.ServiceInvoicePeriods = new List<ServiceInvoicePeriodDC>();
diffRechnung.ServiceInvoicePeriods.Add(newSip);
newSip.InvoiceItems = new List<InvoiceItemDC>();
newSip.InvoiceItems.Add(newItem);
}
return diffRechnung;
}
protected virtual List<DifferenzRechnungCheck> GetNewInvoices(List<ServiceInvoiceDC> invoices, DateTime? start, DateTime? end)
{
List<DifferenzRechnungCheck> result = new List<DifferenzRechnungCheck>();
var existingInvoices = DAOFactory.SearchDAO.GetInvoiceBases(start, end, false);
foreach (var si in invoices)
{
var checkResult = new DifferenzRechnungCheck();
result.Add(checkResult);
checkResult.NeueRechnung = si;
checkResult.VorhandeneRechungen = new List<ServiceInvoiceDC>();
foreach (var i2 in existingInvoices.Where(i => i.Type == InvoiceType.Service))
{
if (si.InvoiceBase.SupportConceptCostBearerRelDc != null && si.InvoiceBase.SupportConceptCostBearerRelDc.CostBearer2SupportConceptOid == i2.CostBearer2SupportConceptOid)
{
var siAlt = DAOFactory.SearchDAO.GetServiceInvoiceByInvoiceBaseOid(i2.Oid.Value);
var siDCAlt = MapperFactory.ServiceInvoiceDC_ServiceInvoice.MapToNewDC(siAlt);
//InvoiceItems vergleichen?
//foreach (var sip in si.ServiceInvoicePeriods)
//{
// foreach (var ii in sip.InvoiceItems)
// {
// typNeu = ii.ItemDescription;
// }
//}
//foreach (var sip in siAlt.ServiceInvoicePeriodList)
//{
// foreach (var ii in sip.InvoiceItemList)
// {
// typAlt = ii.ItemDescription;
// }
//}
//if (typAlt == typNeu)
//{
// exist = true;
//}
checkResult.VorhandeneRechungen.Add(siDCAlt);
}
}
}
return result;
}
public virtual List<long> UpdateServiceInvoices(List<ServiceInvoiceDC> invoices)
{
//if (!Data.Security.UserRightHelper.LoggedInUserHasRight(UserRightType.AccountingTransactionView_Create))
//{
// throw new FaultException<BeWoFault>(new BeWoFault("Du kommst hier nicht rein!", BeWoFaultType.CustomWithoutDetails));
//}
var originals = DAOFactory.GenericDAO.LoadByIDs<ServiceInvoice>(invoices.Select(i => i.ServiceInvoiceOid.Value));
MapperFactory.ServiceInvoiceDC_ServiceInvoice.MergeWithEntitys(invoices, originals);
DAOFactory.GenericDAO.Update(originals);
return originals.Select(e => e.Version.Value).ToList();
}
public virtual List<InvoiceBaseDC> GetInvoiceBases(DateTime? startDate, DateTime? endDate)
{
DateTime? end = endDate;
if (end.HasValue)
{
end = end.Value.Date.AddDays(1).AddTicks(-1);
}
var list = DAOFactory.SearchDAO.GetInvoiceBases(startDate, end);
return MapperFactory.InvoiceBaseDC_InvoiceBase.MapToNewDCs(list);
}
public virtual List<InvoiceBaseDC> GetInvoiceBases(DateTime? startDate, DateTime? endDate, bool filterByInvoiceDate)
{
DateTime? end = endDate;
if (end.HasValue)
{
end = end.Value.Date.AddDays(1).AddTicks(-1);
}
var list = DAOFactory.SearchDAO.GetInvoiceBases(startDate, end, filterByInvoiceDate);
return MapperFactory.InvoiceBaseDC_InvoiceBase.MapToNewDCs(list);
}
public virtual List<InvoiceBaseDC> GetInvoiceBases(DateTime? startDate, DateTime? endDate, long costBearerOid, String invoiceId)
{
DateTime? end = endDate;
if (end.HasValue)
{
end = end.Value.Date.AddDays(1).AddTicks(-1);
}
var list = DAOFactory.SearchDAO.GetInvoiceBases(startDate, end, costBearerOid, invoiceId);
return MapperFactory.InvoiceBaseDC_InvoiceBase.MapToNewDCs(list);
}
public virtual void DeactivateInvoiceBases(List<InvoiceBaseDC> invoices)
{
ServiceLogic.SetActivationType<InvoiceBase>(invoices.ToDictionary(i => i.InvoiceBaseOid.Value, i => i.InvoiceBaseVersion.Value), ActivationTypeId.Deleted);
}
public virtual void DeactivateServiceInvoices(List<ServiceInvoiceDC> invoices)
{
ServiceLogic.SetActivationType<ServiceInvoice>(invoices.ToDictionary(i => i.ServiceInvoiceOid.Value, i => i.ServiceInvoiceVersion.Value), ActivationTypeId.Deleted);
ServiceLogic.SetActivationType<InvoiceBase>(invoices.ToDictionary(i => i.InvoiceBase.InvoiceBaseOid.Value, i => i.InvoiceBase.InvoiceBaseVersion.Value), ActivationTypeId.Deleted);
}
public virtual void StorniereInvoiceBases(List<InvoiceBaseDC> invoices)
{
foreach (var item in invoices)
{
if (item.Type == InvoiceType.Service)
{
ErstelleStornoRechnung(item);
}
else if (item.Type == InvoiceType.Settlement)
{
//ErstelleStornoSpitzabrechnung(item);
}
else
{
ErstelleStornoAllgemeineRechnung(item);
}
}
}
public virtual InvoiceBase ErstelleStornoAllgemeineRechnung(InvoiceBaseDC ibdc)
{
InvoiceBase newInvoice = new InvoiceBase();
var oldInvoice = DAOFactory.GenericDAO.LoadByID<InvoiceBase>(ibdc.InvoiceBaseOid.Value);
CopyInvoiceBase(oldInvoice, newInvoice);
SetzeStornoInfos(newInvoice);
return newInvoice;
}
public virtual ServiceInvoice ErstelleStornoRechnung(InvoiceBaseDC ibdc)
{
ServiceInvoice newInvoice = new ServiceInvoice();
var serviceInvoice = DAOFactory.SearchDAO.GetServiceInvoiceByInvoiceBaseOid(ibdc.InvoiceBaseOid.Value);
CopyServiceInvoice(serviceInvoice, newInvoice);
SetzeStornoInfos(newInvoice);
return newInvoice;
}
//public virtual InvoiceBase ErstelleStornoSpitzabrechnung(InvoiceBaseDC ibdc)
//{
// InvoiceBase newInvoice = new InvoiceBase();
// var oldInvoice = DAOFactory.GenericDAO.LoadByID<InvoiceBase>(ibdc.InvoiceBaseOid.Value);
// CopyInvoiceBase(oldInvoice, newInvoice);
// SetzeStornoInfos(newInvoice);
// return newInvoice;
//}
public virtual ServiceInvoice ErstelleStornoRechnung(ServiceInvoiceDC sidc)
{
ServiceInvoice newInvoice = new ServiceInvoice();
var serviceInvoice = DAOFactory.GenericDAO.LoadByID<ServiceInvoice>(sidc.ServiceInvoiceOid.Value);
CopyServiceInvoice(serviceInvoice, newInvoice);
SetzeStornoInfos(newInvoice);
return newInvoice;
}
public virtual void SaveStornoRechnung(InvoiceBase originalInvoice, ServiceInvoice stornoInvoice)
{
DAOFactory.GenericDAO.Insert(stornoInvoice);
originalInvoice.StornoInvoiceBaseOid = stornoInvoice.Oid;
DAOFactory.GenericDAO.Update(originalInvoice);
}
public virtual void SetzeStornoInfos(InvoiceBase newInvoice)
{
foreach (var ii in newInvoice.InvoiceItems)
{
if (ii.AmountTotal.HasValue)
{
ii.AmountTotal *= -1;
}
if (ii.GrossAmountTotal.HasValue)
{
ii.GrossAmountTotal *= -1;
}
}
}
public virtual void SetzeStornoInfos(ServiceInvoice newInvoice)
{
foreach (var sip in newInvoice.ServiceInvoicePeriodList)
{
sip.HoursNotBillableAbsence = 0;
sip.HoursNotBillableNotApproved = 0;
if (sip.Claim.HasValue)
{
sip.Claim *= -1;
}
foreach (var ii in sip.InvoiceItemList)
{
if (ii.AmountTotal.HasValue)
{
ii.AmountTotal *= -1;
}
if (ii.GrossAmountTotal.HasValue)
{
ii.GrossAmountTotal *= -1;
}
}
}
}
private void CopyServiceInvoice(ServiceInvoice existingInvoice, ServiceInvoice copyInvoice)
{
copyInvoice.AmountAdvancePayments = existingInvoice.AmountAdvancePayments;
copyInvoice.AmountEquityContribution = existingInvoice.AmountEquityContribution;
copyInvoice.ServiceUnitOid = existingInvoice.ServiceUnitOid;
CopyInvoiceBase(existingInvoice.InvoiceBase, copyInvoice.InvoiceBase);
foreach (var sip in existingInvoice.ServiceInvoicePeriodList)
{
var copySip = new ServiceInvoicePeriod();
copyInvoice.ServiceInvoicePeriodList.Add(copySip);
CopyServiceInvoicePeriod(sip, copySip);
}
}
//private void CopySettlementInvoice(SettlementInvoice existingInvoice, SettlementInvoice copyInvoice)
// {
// CopyInvoiceBase(existingInvoice.InvoiceBase, copyInvoice.InvoiceBase);
// }
private void CopyInvoiceBase(InvoiceBase existing, InvoiceBase copy)
{
copy.AccountingPeriodEnd = existing.AccountingPeriodEnd;
copy.AccountingPeriodStart = existing.AccountingPeriodStart;
copy.CostBearer2SupportConcept = existing.CostBearer2SupportConcept;
copy.CreatorFirstName = existing.CreatorFirstName;
copy.CreatorLastName = existing.CreatorLastName;
copy.CustomerReferenceNumber = existing.CustomerReferenceNumber;
copy.DueDate = existing.DueDate;
copy.DunningLetterCount = existing.DunningLetterCount;
copy.InvoiceDate = existing.InvoiceDate;
copy.InvoiceId = existing.InvoiceId;
copy.InvoiceNumber = existing.InvoiceNumber;
copy.InvoiceTitle = existing.InvoiceTitle;
copy.InvoiceTypeText = existing.InvoiceTypeText;
copy.IsPaid = existing.IsPaid;
copy.IsPrinted = existing.IsPrinted;
copy.RecipientCostBearerOid = existing.RecipientCostBearerOid;
copy.RecipientCustomerOid = existing.RecipientCustomerOid;
copy.RecipientDivision = existing.RecipientDivision;
copy.RecipientOrganisation = existing.RecipientOrganisation;
copy.RecipientOrganisationOid = existing.RecipientOrganisationOid;
copy.RecipientPersonFirstName = existing.RecipientPersonFirstName;
copy.RecipientPersonLastName = existing.RecipientPersonLastName;
copy.RecipientPersonOid = existing.RecipientPersonOid;
copy.SenderDivision = existing.SenderDivision;
copy.SenderFirstName = existing.SenderFirstName;
copy.SenderLastName = existing.SenderLastName;
copy.SenderOrganisation = existing.SenderOrganisation;
copy.SupportConceptOid = existing.SupportConceptOid;
copy.Type = existing.Type;
copy.XMLData = existing.XMLData;
foreach (var ii in existing.InvoiceItems)
{
var copyItem = new InvoiceItem();
copy.InvoiceItems.Add(copyItem);
CopyInvoiceItem(ii, copyItem);
}
if (existing.RecipientAddress != null)
{
copy.RecipientAddress = CreateCopyAddress(existing.RecipientAddress);
}
if (existing.RecipientContacts != null)
{
copy.RecipientContacts = new List<Contact>();
foreach (var existingContact in existing.RecipientContacts)
{
copy.RecipientContacts.Add(CreateCopyContact(existingContact));
}
}
if (existing.SenderAddress != null)
{
copy.SenderAddress = existing.SenderAddress;
}
if (existing.SenderContacts != null)
{
copy.SenderContacts = new List<Contact>();
foreach (var existingContact in existing.SenderContacts)
{
copy.SenderContacts.Add(CreateCopyContact(existingContact));
}
}
}
public void CopyInvoiceBaseDC(InvoiceBaseDC orgRechnung, ServiceInvoiceDC diffRechnung)
{
diffRechnung.InvoiceBase.DiffErstellen = true;
diffRechnung.InvoiceBase.AccountingPeriodStart = orgRechnung.AccountingPeriodStart;
diffRechnung.InvoiceBase.AccountingPeriodEnd = orgRechnung.AccountingPeriodEnd;
diffRechnung.InvoiceBase.CustomerLastName = orgRechnung.CustomerLastName;
diffRechnung.InvoiceBase.CustomerFirstName = orgRechnung.CustomerFirstName;
diffRechnung.InvoiceBase.CustomerReferenceNumber = orgRechnung.CustomerReferenceNumber;
diffRechnung.InvoiceBase.InvoiceBaseOid = orgRechnung.InvoiceBaseOid;
diffRechnung.InvoiceBase.InvoiceDate = orgRechnung.InvoiceDate;
diffRechnung.InvoiceBase.InvoiceId = orgRechnung.InvoiceId;
diffRechnung.InvoiceBase.InvoiceNumber = orgRechnung.InvoiceNumber;
diffRechnung.InvoiceBase.InvoiceTitle = orgRechnung.InvoiceTitle;
diffRechnung.InvoiceBase.InvoiceTypeText = orgRechnung.InvoiceTypeText;
diffRechnung.InvoiceBase.RecipientAddressLine1 = orgRechnung.RecipientAddressLine1;
diffRechnung.InvoiceBase.RecipientAddressOid = orgRechnung.RecipientAddressOid;
diffRechnung.InvoiceBase.RecipientAddressVersion = orgRechnung.RecipientAddressVersion;
diffRechnung.InvoiceBase.RecipientContactInformations = orgRechnung.RecipientContactInformations;
diffRechnung.InvoiceBase.RecipientCostBearerOid = orgRechnung.RecipientCostBearerOid;
diffRechnung.InvoiceBase.RecipientCustomerOid = orgRechnung.RecipientCustomerOid;
diffRechnung.InvoiceBase.RecipientDivision = orgRechnung.RecipientDivision;
diffRechnung.InvoiceBase.RecipientOrganisation = orgRechnung.RecipientOrganisation;
diffRechnung.InvoiceBase.RecipientOrganisationOid = orgRechnung.RecipientOrganisationOid;
diffRechnung.InvoiceBase.RecipientPersonFirstName = orgRechnung.RecipientPersonFirstName;
diffRechnung.InvoiceBase.RecipientPersonLastName = orgRechnung.RecipientPersonLastName;
diffRechnung.InvoiceBase.RecipientPersonOid = orgRechnung.RecipientPersonOid;
diffRechnung.InvoiceBase.RecipientPostCode = orgRechnung.RecipientPostCode;
diffRechnung.InvoiceBase.RecipientSalutationAddressField = orgRechnung.RecipientSalutationAddressField;
diffRechnung.InvoiceBase.RecipientStreet = orgRechnung.RecipientStreet;
diffRechnung.InvoiceBase.RecipientTown = orgRechnung.RecipientTown;
diffRechnung.InvoiceBase.SenderAddressOid = orgRechnung.SenderAddressOid;
diffRechnung.InvoiceBase.SenderAddressVersion = orgRechnung.SenderAddressVersion;
diffRechnung.InvoiceBase.SenderContactInformations = orgRechnung.SenderContactInformations;
diffRechnung.InvoiceBase.SenderDivision = orgRechnung.SenderDivision;
diffRechnung.InvoiceBase.SenderFirstName = orgRechnung.SenderFirstName;
diffRechnung.InvoiceBase.SenderLastName = orgRechnung.SenderLastName;
diffRechnung.InvoiceBase.SenderOrganisation = orgRechnung.SenderOrganisation;
diffRechnung.InvoiceBase.SenderPostCode = orgRechnung.SenderPostCode;
diffRechnung.InvoiceBase.SenderStreet = orgRechnung.SenderStreet;
diffRechnung.InvoiceBase.SenderTown = orgRechnung.SenderTown;
diffRechnung.InvoiceBase.SupportConceptCostBearerRelDc = orgRechnung.SupportConceptCostBearerRelDc;
diffRechnung.InvoiceBase.SupportConceptOid = orgRechnung.SupportConceptOid;
diffRechnung.InvoiceBase.TotalAmount = orgRechnung.TotalAmount;
diffRechnung.InvoiceBase.Type = orgRechnung.Type;
}
private Contact CreateCopyContact(Contact existingContact)
{
Contact newContact = new Contact();
newContact.Value = existingContact.Value;
newContact.Type = existingContact.Type;
return newContact;
}
private Address CreateCopyAddress(Address address)
{
Address newAddress = new Address();
newAddress.AddressLine1 = address.AddressLine1;
newAddress.AddressLine2 = address.AddressLine2;
newAddress.Country = address.Country;
newAddress.PostalCode = address.PostalCode;
newAddress.State = address.State;
newAddress.Street = address.Street;
newAddress.Town = address.Town;
return newAddress;
}
private void CopyServiceInvoicePeriod(ServiceInvoicePeriod existingSip, ServiceInvoicePeriod copySip)
{
copySip.AccountingInterval = existingSip.AccountingInterval;
copySip.ApprovedAmountDefaultHourlyRate = existingSip.ApprovedAmountDefaultHourlyRate;
copySip.ApprovedBE = existingSip.ApprovedBE;
copySip.ApprovedFixedAmount = existingSip.ApprovedFixedAmount;
copySip.ApprovedHours = existingSip.ApprovedHours;
copySip.Claim = existingSip.Claim;
copySip.End = existingSip.End;
copySip.HoursNotBillableAbsence = existingSip.HoursNotBillableAbsence;
copySip.HoursNotBillableNotApproved = existingSip.HoursNotBillableNotApproved;
copySip.ServiceUnitName = existingSip.ServiceUnitName;
copySip.Start = existingSip.Start;
copySip.Notice = existingSip.Notice;
copySip.Customer = existingSip.Customer;
copySip.SupportConceptApprovalPeriod = existingSip.SupportConceptApprovalPeriod;
foreach (var ii in existingSip.InvoiceItemList)
{
var copyItem = new InvoiceItem();
copySip.InvoiceItemList.Add(copyItem);
CopyInvoiceItem(ii, copyItem);
}
}
private void CopyInvoiceItem(InvoiceItem existingItem, InvoiceItem copyItem)
{
copyItem.AccountingInterval = existingItem.AccountingInterval;
copyItem.AmountPerUnit = existingItem.AmountPerUnit;
copyItem.AmountTotal = existingItem.AmountTotal;
copyItem.ApprovalUnit = existingItem.AccountingInterval;
copyItem.ApprovedPerUnit = existingItem.ApprovedPerUnit;
copyItem.GrossAmountTotal = existingItem.GrossAmountTotal;
copyItem.ItemDescription = existingItem.ItemDescription;
copyItem.ItemPeriodEnd = existingItem.ItemPeriodEnd;
copyItem.ItemPeriodStart = existingItem.ItemPeriodStart;
copyItem.MaxApprovedAmount = existingItem.MaxApprovedAmount;
copyItem.MaxApprovedUnitCount = existingItem.MaxApprovedUnitCount;
copyItem.RateFactor = existingItem.RateFactor;
copyItem.ReceivedAmount = existingItem.ReceivedAmount;
copyItem.SupportConceptApprovalPeriodOid = existingItem.SupportConceptApprovalPeriodOid;
copyItem.UnitCount = existingItem.UnitCount;
copyItem.UnitDescription = existingItem.UnitDescription;
copyItem.Notice = existingItem.Notice;
copyItem.ServiceRecord = existingItem.ServiceRecord;
}
public virtual Settlement2DC ErstelleDifferenzSpitzabrechnung(Settlement2DC neueRechnung, Settlement2DC letzteRechnung)
{
var diff = neueRechnung.Claim - letzteRechnung.Claim;
var ii = new InvoiceItemDC();
neueRechnung.Claim = diff;
neueRechnung.InvoiceItems = new List<InvoiceItemDC>();
neueRechnung.InvoiceItems.Add(ii);
return neueRechnung;
}
}
public class DifferenzRechnungCheck
{
public ServiceInvoiceDC NeueRechnung { get; set; }
public IList<ServiceInvoiceDC> VorhandeneRechungen { get; set; }
}
}