MH: Wöll Differenzrechnung und Kappung
This commit is contained in:
@@ -132,6 +132,7 @@
|
||||
<Compile Include="ServiceInvoiceReport.Designer.cs">
|
||||
<DependentUpon>ServiceInvoiceReport.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Service\CustomAccountingService.cs" />
|
||||
<Compile Include="Service\CustomVacationService.cs" />
|
||||
<Compile Include="SettlementReport.cs">
|
||||
<SubType>Component</SubType>
|
||||
|
||||
@@ -29,11 +29,16 @@ namespace BetreutesWohnenWoellReports.Invoicing
|
||||
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)
|
||||
{
|
||||
InvoiceItem invoiceItem = CreateInvoiceItem(iServiceRecord, scap, calc);
|
||||
if (iServiceRecord.ServiceDescription.Name.Contains("face to face"))
|
||||
{ }
|
||||
invoiceItem.Notice = iServiceRecord.ServiceDescription.CategoryName;
|
||||
if (invoiceItem != null)
|
||||
{
|
||||
@@ -204,23 +209,45 @@ namespace BetreutesWohnenWoellReports.Invoicing
|
||||
}
|
||||
decimal totalHours = 0;
|
||||
|
||||
foreach (var ii in sip.InvoiceItemList.Where(ii => ii.UnitCount.HasValue && ii.ItemDescription != "Fahrkosten pro km")) // KM werden immer abgerechnet, wie werden nicht vom Budget abgezogen
|
||||
{
|
||||
if (totalHours + ii.UnitCount.Value > sip.ApprovedHours)
|
||||
{
|
||||
ii.UnitCount = Math.Round(sip.ApprovedHours.Value - totalHours, 2, MidpointRounding.AwayFromZero);
|
||||
if (ii.AmountPerUnit.HasValue)
|
||||
{
|
||||
ii.AmountTotal = ii.AmountPerUnit.Value * ii.UnitCount;
|
||||
ii.GrossAmountTotal = ii.AmountTotal;
|
||||
}
|
||||
totalHours = sip.ApprovedHours.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
totalHours += ii.UnitCount.Value;
|
||||
}
|
||||
}
|
||||
//foreach (var ii in sip.InvoiceItemList.Where(ii => ii.UnitCount.HasValue && ii.ItemDescription != "Fahrkosten pro km")) // KM werden immer abgerechnet, wie werden nicht vom Budget abgezogen
|
||||
//{
|
||||
// if (ii.ItemDescription == "Medienkommunikation")
|
||||
// { }
|
||||
// if (totalHours + ii.UnitCount.Value > sip.ApprovedHours)
|
||||
// {
|
||||
// ii.UnitCount = Math.Round(sip.ApprovedHours.Value - totalHours, 2, MidpointRounding.AwayFromZero);
|
||||
// if (ii.AmountPerUnit.HasValue)
|
||||
// {
|
||||
// ii.AmountTotal = ii.AmountPerUnit.Value * ii.UnitCount;
|
||||
// ii.GrossAmountTotal = ii.AmountTotal;
|
||||
// }
|
||||
// totalHours = sip.ApprovedHours.Value;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// totalHours += ii.UnitCount.Value;
|
||||
// }
|
||||
//}
|
||||
|
||||
//foreach (var ii in sip.InvoiceItemList.Where(ii => ii.UnitCount.HasValue && ii.ItemDescription != "Fahrkosten pro km")) // KM werden immer abgerechnet, wie werden nicht vom Budget abgezogen
|
||||
//{
|
||||
// if (ii.ItemDescription == "Medienkommunikation")
|
||||
// { }
|
||||
// if (totalHours + ii.UnitCount.Value > sip.ApprovedHours)
|
||||
// {
|
||||
// ii.UnitCount = Math.Round(sip.ApprovedHours.Value - totalHours, 2, MidpointRounding.AwayFromZero);
|
||||
// if (ii.AmountPerUnit.HasValue)
|
||||
// {
|
||||
// ii.AmountTotal = ii.AmountPerUnit.Value * ii.UnitCount;
|
||||
// ii.GrossAmountTotal = ii.AmountTotal;
|
||||
// }
|
||||
// totalHours = sip.ApprovedHours.Value;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// totalHours += ii.UnitCount.Value;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace BetreutesWohnenWoellReports
|
||||
this.xrLabel6 = new DevExpress.XtraReports.UI.XRLabel();
|
||||
this.lblAdresse = new DevExpress.XtraReports.UI.XRLabel();
|
||||
this.lblUeberschrift = new DevExpress.XtraReports.UI.XRLabel();
|
||||
this.xrLabel2 = new DevExpress.XtraReports.UI.XRLabel();
|
||||
this.lblRechnungOderDifferenz = new DevExpress.XtraReports.UI.XRLabel();
|
||||
this.xrLabel8 = new DevExpress.XtraReports.UI.XRLabel();
|
||||
this.lblAbrechnungszeitraum = new DevExpress.XtraReports.UI.XRLabel();
|
||||
this.DetailReport = new DevExpress.XtraReports.UI.DetailReportBand();
|
||||
@@ -90,9 +90,9 @@ namespace BetreutesWohnenWoellReports
|
||||
this.xrTableCell45 = new DevExpress.XtraReports.UI.XRTableCell();
|
||||
this.xrTableCell2 = new DevExpress.XtraReports.UI.XRTableCell();
|
||||
this.xrTableCell47 = new DevExpress.XtraReports.UI.XRTableCell();
|
||||
this.bindingSource1 = new System.Windows.Forms.BindingSource(this.components);
|
||||
this.ReportFooter1 = new DevExpress.XtraReports.UI.ReportFooterBand();
|
||||
this.xrLabel1 = new DevExpress.XtraReports.UI.XRLabel();
|
||||
this.bindingSource1 = new System.Windows.Forms.BindingSource(this.components);
|
||||
((System.ComponentModel.ISupportInitialize)(this.xrTable2)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.xrTable1)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.xrTable5)).BeginInit();
|
||||
@@ -190,7 +190,7 @@ namespace BetreutesWohnenWoellReports
|
||||
this.xrLabel6,
|
||||
this.lblAdresse,
|
||||
this.lblUeberschrift,
|
||||
this.xrLabel2,
|
||||
this.lblRechnungOderDifferenz,
|
||||
this.xrLabel8,
|
||||
this.lblAbrechnungszeitraum});
|
||||
this.Page1.Font = new DevExpress.Drawing.DXFont("Verdana", 10F);
|
||||
@@ -431,19 +431,19 @@ namespace BetreutesWohnenWoellReports
|
||||
this.lblUeberschrift.Text = "Sozialpädagogische Familienhilfe gem. §§27, 31 SGB VIII";
|
||||
this.lblUeberschrift.WordWrap = false;
|
||||
//
|
||||
// xrLabel2
|
||||
// lblRechnungOderDifferenz
|
||||
//
|
||||
this.xrLabel2.BackColor = System.Drawing.Color.Transparent;
|
||||
this.xrLabel2.CanShrink = true;
|
||||
this.xrLabel2.Font = new DevExpress.Drawing.DXFont("Verdana", 9.75F);
|
||||
this.xrLabel2.LocationFloat = new DevExpress.Utils.PointFloat(0F, 203.25F);
|
||||
this.xrLabel2.Name = "xrLabel2";
|
||||
this.xrLabel2.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F);
|
||||
this.xrLabel2.SizeF = new System.Drawing.SizeF(362.5F, 23.00002F);
|
||||
this.xrLabel2.StylePriority.UseBackColor = false;
|
||||
this.xrLabel2.StylePriority.UseFont = false;
|
||||
this.xrLabel2.Text = "Rechnung Nr. [InvoiceNumber]";
|
||||
this.xrLabel2.WordWrap = false;
|
||||
this.lblRechnungOderDifferenz.BackColor = System.Drawing.Color.Transparent;
|
||||
this.lblRechnungOderDifferenz.CanShrink = true;
|
||||
this.lblRechnungOderDifferenz.Font = new DevExpress.Drawing.DXFont("Verdana", 9.75F);
|
||||
this.lblRechnungOderDifferenz.LocationFloat = new DevExpress.Utils.PointFloat(0F, 203.25F);
|
||||
this.lblRechnungOderDifferenz.Name = "lblRechnungOderDifferenz";
|
||||
this.lblRechnungOderDifferenz.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F);
|
||||
this.lblRechnungOderDifferenz.SizeF = new System.Drawing.SizeF(362.5F, 23.00002F);
|
||||
this.lblRechnungOderDifferenz.StylePriority.UseBackColor = false;
|
||||
this.lblRechnungOderDifferenz.StylePriority.UseFont = false;
|
||||
this.lblRechnungOderDifferenz.Text = "Rechnung Nr. [InvoiceNumber]";
|
||||
this.lblRechnungOderDifferenz.WordWrap = false;
|
||||
//
|
||||
// xrLabel8
|
||||
//
|
||||
@@ -792,10 +792,6 @@ namespace BetreutesWohnenWoellReports
|
||||
this.xrTableCell47.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft;
|
||||
this.xrTableCell47.Weight = 0.59582550260409617D;
|
||||
//
|
||||
// bindingSource1
|
||||
//
|
||||
this.bindingSource1.DataSource = typeof(BeWo.Report.ReportObjects.ServiceInvoiceRO);
|
||||
//
|
||||
// ReportFooter1
|
||||
//
|
||||
this.ReportFooter1.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] {
|
||||
@@ -819,6 +815,10 @@ namespace BetreutesWohnenWoellReports
|
||||
this.xrLabel1.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft;
|
||||
this.xrLabel1.TextFormatString = "{0}";
|
||||
//
|
||||
// bindingSource1
|
||||
//
|
||||
this.bindingSource1.DataSource = typeof(BeWo.Report.ReportObjects.ServiceInvoiceRO);
|
||||
//
|
||||
// JugendamtServiceInvoiceReport
|
||||
//
|
||||
this.Bands.AddRange(new DevExpress.XtraReports.UI.Band[] {
|
||||
@@ -859,7 +859,7 @@ namespace BetreutesWohnenWoellReports
|
||||
private DevExpress.XtraReports.UI.BottomMarginBand bottomMarginBand1;
|
||||
private DevExpress.XtraReports.UI.GroupHeaderBand Page1;
|
||||
private DevExpress.XtraReports.UI.XRLabel lblUeberschrift;
|
||||
private DevExpress.XtraReports.UI.XRLabel xrLabel2;
|
||||
private DevExpress.XtraReports.UI.XRLabel lblRechnungOderDifferenz;
|
||||
private DevExpress.XtraReports.UI.XRLabel xrLabel8;
|
||||
private DevExpress.XtraReports.UI.XRLabel lblAbrechnungszeitraum;
|
||||
private DevExpress.XtraReports.UI.DetailReportBand DetailReport;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using BeWo.Report;
|
||||
using BeWo.Report.ReportObjects;
|
||||
@@ -25,6 +26,12 @@ namespace BetreutesWohnenWoellReports
|
||||
// Überschrift je nach Leistung setzen und Briefkopf nach Kostenträgerfunktion
|
||||
foreach (var ip in pRO.ServiceInvoicePeriods)
|
||||
{
|
||||
if (ip.ServiceInvoiceItems.Any(i => i.NetAmount < 0))
|
||||
{
|
||||
lblRechnungOderDifferenz.Text = lblRechnungOderDifferenz.Text.Replace("Rechnung", "Differenzrechnung");
|
||||
ip.ServiceInvoiceItems = ip.ServiceInvoiceItems.OrderBy(i => i.NetAmount).ToList();
|
||||
}
|
||||
|
||||
foreach (var ap in ip.CostBearer2SupportConcept.ApprovalPeriodList)
|
||||
{
|
||||
if (ap.CostBearer2SupportConcept.CostBearer.Organisation.Function != null && ap.CostBearer2SupportConcept.CostBearer.Organisation.Function.Value == "Jugendamt")
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -9,6 +9,8 @@ using System.Text.RegularExpressions;
|
||||
using System.Drawing;
|
||||
using BS.Shared.Core;
|
||||
using System.IO;
|
||||
using BS.Shared.DataContracts;
|
||||
using BeWo.Service.ServiceImplementations;
|
||||
|
||||
namespace BeWo.BetreutesWohnenWoellReports
|
||||
{
|
||||
@@ -21,6 +23,7 @@ namespace BeWo.BetreutesWohnenWoellReports
|
||||
|
||||
public void SetReportDataSource(ServicesOverviewRO pRO)
|
||||
{
|
||||
string cat = "";
|
||||
double total = 0;
|
||||
if (pRO.Services != null)
|
||||
{
|
||||
@@ -39,6 +42,8 @@ namespace BeWo.BetreutesWohnenWoellReports
|
||||
}
|
||||
total += s.Minutes;
|
||||
servicesBillable.Add(s);
|
||||
|
||||
cat = s.ServiceCategory;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,9 +52,49 @@ namespace BeWo.BetreutesWohnenWoellReports
|
||||
|
||||
pRO.TotalFLMBillable = total;
|
||||
|
||||
SetBewilligung(pRO, cat);
|
||||
|
||||
|
||||
this.bindingSource1.DataSource = pRO;
|
||||
}
|
||||
|
||||
private void SetBewilligung(ServicesOverviewRO pRO, String name)
|
||||
{
|
||||
var stats = GetStatistics(pRO, name);
|
||||
if (stats != null)
|
||||
{
|
||||
pRO.ApprovedFLSPerWeek = stats.MinutesApprovedPerWeek / 60;
|
||||
}
|
||||
}
|
||||
|
||||
private SupportConceptPeriodStatisticsDC GetStatistics(ServicesOverviewRO ro, String name)
|
||||
{
|
||||
if (ro.CostBearer2SupportConceptList != null && ro.CostBearer2SupportConceptList.Count > 0)
|
||||
{
|
||||
var service = new OperationsServiceImp();
|
||||
|
||||
foreach (var cb2sc in ro.CostBearer2SupportConceptList)
|
||||
{
|
||||
long cb2scOid = cb2sc.Oid.Value;
|
||||
var stats = service.CreateSupportConceptStatistics(cb2scOid, ro.EndDate);
|
||||
|
||||
if (stats.PeriodStatistics != null && stats.PeriodStatistics.Count > 0)
|
||||
{
|
||||
foreach (var ps in stats.PeriodStatistics)
|
||||
{
|
||||
if (ps.SupportConceptApprovalPeriod != null && ps.SupportConceptApprovalPeriod.ServiceCategory != null &&
|
||||
ps.SupportConceptApprovalPeriod.ServiceCategory.Name.StartsWith(name))
|
||||
{
|
||||
return ps;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void picSignature_BeforePrint(object sender, CancelEventArgs e)
|
||||
{
|
||||
XRPictureBox xrBox = sender as XRPictureBox;
|
||||
|
||||
@@ -0,0 +1,293 @@
|
||||
using BeWo.Data.Access;
|
||||
using BeWo.Data.Entities;
|
||||
using BeWo.Service.DCEntityMapper;
|
||||
using BeWo.Service.Plugins;
|
||||
using BS.Shared.DataContracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BetreutesWohnenWoellReports.Service
|
||||
{
|
||||
public class CustomAccountingService : AccountingService
|
||||
{
|
||||
protected override List<ServiceInvoiceDC> ErstelleNeueRechnungen(List<DifferenzRechnungCheck> differenzRechnungChecks)
|
||||
{
|
||||
var rechnungen = new List<ServiceInvoiceDC>();
|
||||
foreach (var item in differenzRechnungChecks)
|
||||
{
|
||||
if (item.VorhandeneRechungen.Count == 0 || !item.VorhandeneRechungen.Any(r => item.NeueRechnung.InvoiceBase.CustomerLastName == r.InvoiceBase.CustomerLastName &&
|
||||
item.NeueRechnung.InvoiceBase.CustomerFirstName == r.InvoiceBase.CustomerFirstName))
|
||||
{
|
||||
item.NeueRechnung.InvoiceBase.NeuErstellen = true;
|
||||
rechnungen.Add(item.NeueRechnung);
|
||||
}
|
||||
else
|
||||
{
|
||||
var diffRechnung = ErstelleDifferenzRechnung(item);
|
||||
if (diffRechnung != null)
|
||||
{
|
||||
diffRechnung.InvoiceBase.NeuErstellen = false;
|
||||
rechnungen.Add(diffRechnung);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rechnungen;
|
||||
}
|
||||
protected override ServiceInvoiceDC ErstelleDifferenzRechnung(DifferenzRechnungCheck item)
|
||||
{
|
||||
ServiceInvoiceDC diffRechnung = null;
|
||||
//var alterBetrag = item.VorhandeneRechungen.Sum(i => i.ClaimSum ?? 0);
|
||||
var letzteRg = item.VorhandeneRechungen.OrderByDescending(r => r.ServiceInvoiceOid).FirstOrDefault();
|
||||
|
||||
letzteRg = item.VorhandeneRechungen.FirstOrDefault(r => item.NeueRechnung.InvoiceBase.CustomerLastName == r.InvoiceBase.CustomerLastName &&
|
||||
item.NeueRechnung.InvoiceBase.CustomerFirstName == r.InvoiceBase.CustomerFirstName);
|
||||
if (letzteRg != null)
|
||||
{
|
||||
if (item.NeueRechnung.ClaimSum == letzteRg.ClaimSum)
|
||||
{
|
||||
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);
|
||||
|
||||
ServiceInvoice counterInvoice = new ServiceInvoice();
|
||||
var serviceInvoice = DAOFactory.SearchDAO.GetServiceInvoiceByInvoiceBaseOid(letzteRg.InvoiceBase.InvoiceBaseOid.Value);
|
||||
|
||||
CopyServiceInvoice(serviceInvoice, counterInvoice);
|
||||
SetzeStornoInfos(counterInvoice);
|
||||
SetzeRechnungspositionenServiceInvoice(diffRechnung, counterInvoice, item);
|
||||
|
||||
diffRechnung.InvoiceBase.NeuErstellen = true;
|
||||
diffRechnung.InvoiceBase.Hinweise = String.Format("Rechnungsdifferenz zu Rechnung {0} in Höhe von {1:c}", letzteRg.InvoiceBase.InvoiceNumber, letzteRg.InvoiceBase.TotalAmount.Value);
|
||||
}
|
||||
}
|
||||
|
||||
return diffRechnung;
|
||||
}
|
||||
// Standard, aber in der Basis private und dahar musste es hier mit rein da ich sonst nicht nicht SetzeRechnungspositionenServiceInvoice überschreiben konnte
|
||||
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);
|
||||
}
|
||||
}
|
||||
// Standard, aber in der Basis private und dahar musste es hier mit rein da ich sonst nicht nicht SetzeRechnungspositionenServiceInvoice überschreiben konnte
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// Standard, aber in der Basis private und dahar musste es hier mit rein da ich sonst nicht nicht SetzeRechnungspositionenServiceInvoice überschreiben konnte
|
||||
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;
|
||||
}
|
||||
// Standard, aber in der Basis private und dahar musste es hier mit rein da ich sonst nicht nicht SetzeRechnungspositionenServiceInvoice überschreiben konnte
|
||||
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;
|
||||
}
|
||||
// Standard, aber in der Basis private und dahar musste es hier mit rein da ich sonst nicht nicht SetzeRechnungspositionenServiceInvoice überschreiben konnte
|
||||
private Contact CreateCopyContact(Contact existingContact)
|
||||
{
|
||||
Contact newContact = new Contact();
|
||||
newContact.Value = existingContact.Value;
|
||||
newContact.Type = existingContact.Type;
|
||||
|
||||
return newContact;
|
||||
}
|
||||
|
||||
private void SetzeRechnungspositionenServiceInvoice(ServiceInvoiceDC diffRechnung, ServiceInvoice counterInvoice, DifferenzRechnungCheck item)
|
||||
{
|
||||
var siDCAlt = MapperFactory.ServiceInvoiceDC_ServiceInvoice.MapToNewDC(counterInvoice);
|
||||
if (siDCAlt.ServiceInvoicePeriods != null && siDCAlt.ServiceInvoicePeriods.Count > 0)
|
||||
{
|
||||
diffRechnung.ServiceInvoicePeriods = siDCAlt.ServiceInvoicePeriods;
|
||||
}
|
||||
|
||||
if (item.NeueRechnung.ServiceInvoicePeriods != null && item.NeueRechnung.ServiceInvoicePeriods.Count > 0)
|
||||
{
|
||||
if (diffRechnung.ServiceInvoicePeriods == null)
|
||||
{
|
||||
diffRechnung.ServiceInvoicePeriods = item.NeueRechnung.ServiceInvoicePeriods;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var NewSip in item.NeueRechnung.ServiceInvoicePeriods)
|
||||
{
|
||||
if (NewSip.InvoiceItems != null && NewSip.InvoiceItems.Count > 0)
|
||||
{
|
||||
if (NewSip.Customer != null && diffRechnung.ServiceInvoicePeriods.Any(s => s.Customer.CustomerOid == NewSip.Customer.CustomerOid) &&
|
||||
NewSip.SupportConceptApprovalPeriod != null && NewSip.SupportConceptApprovalPeriod.SupportConceptApprovalPeriodOid.HasValue
|
||||
&& diffRechnung.ServiceInvoicePeriods.Any(s => s.SupportConceptApprovalPeriod.SupportConceptApprovalPeriodOid.HasValue
|
||||
&& s.SupportConceptApprovalPeriod.SupportConceptApprovalPeriodOid.Value == NewSip.SupportConceptApprovalPeriod.SupportConceptApprovalPeriodOid.Value))
|
||||
{
|
||||
var ip = diffRechnung.ServiceInvoicePeriods.Where(s => s.SupportConceptApprovalPeriod.SupportConceptApprovalPeriodOid.Value == NewSip.SupportConceptApprovalPeriod.SupportConceptApprovalPeriodOid.Value).First();
|
||||
if (ip.InvoiceItems != null && ip.InvoiceItems.Count > 0)
|
||||
{
|
||||
ip.Claim += NewSip.Claim;
|
||||
foreach (var ii in NewSip.InvoiceItems)
|
||||
{
|
||||
ip.InvoiceItems.Add(ii);
|
||||
}
|
||||
|
||||
// Bei Rechnungspositionen mit negativem Betrag auf alte Rechnung verweisen
|
||||
foreach (var iitem in ip.InvoiceItems)
|
||||
{
|
||||
if (iitem.AmountTotal < 0)
|
||||
{
|
||||
iitem.ItemDescription += string.Format(" (am {0:dd.MM.yyyy} in Rechnung {1} berechnet)", item.VorhandeneRechungen[0].InvoiceBase.InvoiceDate, item.VorhandeneRechungen[0].InvoiceBase.InvoiceNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
diffRechnung.ServiceInvoicePeriods.Add(NewSip);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Standard, aber in der Basis private und dahar musste es hier mit rein da ich sonst nicht nicht SetzeRechnungspositionenServiceInvoice überschreiben konnte
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user