2019-02-12 19:32:04 +01:00
using System ;
using System.Collections.Generic ;
using System.Linq ;
2023-08-15 16:43:05 +02:00
using System.ServiceModel ;
2019-02-12 19:32:04 +01:00
using BeWo.Data.Access ;
using BeWo.Data.Entities ;
using BeWo.Service.Core ;
using BeWo.Service.DCEntityMapper ;
2023-12-13 12:53:20 +01:00
using BeWo.Service.Invoicing ;
2023-08-15 16:43:05 +02:00
using BeWo.Service.ServiceContracts ;
2019-02-12 19:32:04 +01:00
using BS.Shared ;
using BS.Shared.Core ;
using BS.Shared.DataContracts ;
2023-12-13 12:53:20 +01:00
using BS.Shared.DataContracts.Compact ;
2019-02-12 19:32:04 +01:00
using BS.Shared.Extensions ;
namespace BeWo.Service.Plugins
{
public class AccountingService : AbstractIDSpecificDefaultClass < AccountingService >
{
2023-12-13 12:53:20 +01:00
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 =
2024-01-15 17:49:32 +01:00
supportConcepts . Where ( sc = > sc . StartDate < newSpan . EndDateTime & & sc . EndDate > = newSpan . StartDate ) ;
2023-12-13 12:53:20 +01:00
}
}
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 ) ;
2024-03-27 18:25:18 +01:00
var newInvoices = creator . GenerateServiceInvoices ( costBearerOid , invoicePeriod , supportConcepts2ServiceRecords ) ;
2024-04-11 09:27:49 +02:00
2023-12-13 12:53:20 +01:00
//Prüfe ob Rechnungen neu sind oder Diff vorhanden
2024-04-11 09:19:36 +02:00
var differenzRechnungChecks = GetNewInvoices ( newInvoices , invoicePeriod ? . StartDate , invoicePeriod ? . EndDate ) ;
2023-12-13 12:53:20 +01:00
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 ;
}
2024-04-11 09:19:36 +02:00
protected virtual List < DifferenzRechnungCheck > GetNewInvoices ( List < ServiceInvoiceDC > invoices , DateTime ? start , DateTime ? end )
2023-12-13 12:53:20 +01:00
{
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 )
2023-08-15 16:43:05 +02:00
{
//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 ( ) ;
}
2019-02-12 19:32:04 +01:00
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 ) ;
}
2023-06-13 23:52:52 +02:00
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 ) ;
2024-02-20 11:50:46 +01:00
}
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 ) ;
2023-06-13 23:52:52 +02:00
}
2024-02-20 11:50:46 +01:00
2023-06-13 23:52:52 +02:00
public virtual void DeactivateInvoiceBases ( List < InvoiceBaseDC > invoices )
2019-02-12 19:32:04 +01:00
{
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 ) ;
}
2021-12-05 19:21:17 +01:00
public virtual void StorniereInvoiceBases ( List < InvoiceBaseDC > invoices )
{
2022-01-04 12:13:52 +01:00
foreach ( var item in invoices )
{
2022-12-29 12:15:47 +01:00
if ( item . Type = = InvoiceType . Service )
{
ErstelleStornoRechnung ( item ) ;
}
else if ( item . Type = = InvoiceType . Settlement )
{
//ErstelleStornoSpitzabrechnung(item);
}
else
{
ErstelleStornoAllgemeineRechnung ( item ) ;
}
}
2021-12-05 19:21:17 +01:00
}
2019-02-12 19:32:04 +01:00
2022-12-29 12:15:47 +01:00
public virtual InvoiceBase ErstelleStornoAllgemeineRechnung ( InvoiceBaseDC ibdc )
{
InvoiceBase newInvoice = new InvoiceBase ( ) ;
2019-02-12 19:32:04 +01:00
2022-12-29 12:15:47 +01:00
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 ( ) ;
2019-02-12 19:32:04 +01:00
2022-12-29 12:15:47 +01:00
var serviceInvoice = DAOFactory . SearchDAO . GetServiceInvoiceByInvoiceBaseOid ( ibdc . InvoiceBaseOid . Value ) ;
2019-02-12 19:32:04 +01:00
2022-12-29 12:15:47 +01:00
CopyServiceInvoice ( serviceInvoice , newInvoice ) ;
SetzeStornoInfos ( newInvoice ) ;
2019-02-12 19:32:04 +01:00
return newInvoice ;
}
2022-12-29 12:15:47 +01:00
//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 )
2019-02-12 19:32:04 +01:00
{
ServiceInvoice newInvoice = new ServiceInvoice ( ) ;
var serviceInvoice = DAOFactory . GenericDAO . LoadByID < ServiceInvoice > ( sidc . ServiceInvoiceOid . Value ) ;
CopyServiceInvoice ( serviceInvoice , newInvoice ) ;
SetzeStornoInfos ( newInvoice ) ;
return newInvoice ;
}
2023-08-16 10:25:05 +02:00
public virtual void SaveStornoRechnung ( InvoiceBase originalInvoice , ServiceInvoice stornoInvoice )
{
DAOFactory . GenericDAO . Insert ( stornoInvoice ) ;
originalInvoice . StornoInvoiceBaseOid = stornoInvoice . Oid ;
DAOFactory . GenericDAO . Update ( originalInvoice ) ;
}
2022-12-29 12:15:47 +01:00
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 ;
}
}
}
2022-09-28 15:49:22 +02:00
public virtual void SetzeStornoInfos ( ServiceInvoice newInvoice )
2019-02-12 19:32:04 +01:00
{
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 ;
2022-01-04 12:13:52 +01:00
2019-02-12 19:32:04 +01:00
2022-01-04 12:13:52 +01:00
CopyInvoiceBase ( existingInvoice . InvoiceBase , copyInvoice . InvoiceBase ) ;
2019-02-12 19:32:04 +01:00
foreach ( var sip in existingInvoice . ServiceInvoicePeriodList )
{
var copySip = new ServiceInvoicePeriod ( ) ;
copyInvoice . ServiceInvoicePeriodList . Add ( copySip ) ;
CopyServiceInvoicePeriod ( sip , copySip ) ;
}
}
2023-12-13 12:53:20 +01:00
2022-12-29 12:15:47 +01:00
//private void CopySettlementInvoice(SettlementInvoice existingInvoice, SettlementInvoice copyInvoice)
// {
// CopyInvoiceBase(existingInvoice.InvoiceBase, copyInvoice.InvoiceBase);
// }
2019-02-12 19:32:04 +01:00
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 ) ) ;
}
}
}
2023-12-13 12:53:20 +01:00
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 )
2019-02-12 19:32:04 +01:00
{
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 ;
}
2023-12-20 00:51:44 +01:00
public virtual Settlement2DC ErstelleDifferenzSpitzabrechnung ( Settlement2DC neueRechnung , Settlement2DC letzteRechnung )
{
var diff = neueRechnung . Claim - letzteRechnung . Claim ;
var ii = new InvoiceItemDC ( ) ;
2023-12-22 00:24:48 +01:00
neueRechnung . Claim = diff ;
2023-12-20 00:51:44 +01:00
neueRechnung . InvoiceItems = new List < InvoiceItemDC > ( ) ;
neueRechnung . InvoiceItems . Add ( ii ) ;
return neueRechnung ;
}
2019-02-12 19:32:04 +01:00
}
2023-12-13 12:53:20 +01:00
public class DifferenzRechnungCheck
{
public ServiceInvoiceDC NeueRechnung { get ; set ; }
public IList < ServiceInvoiceDC > VorhandeneRechungen { get ; set ; }
2023-12-20 00:51:44 +01:00
}
2019-02-12 19:32:04 +01:00
}