cb reports

This commit is contained in:
Christian
2019-10-10 21:33:34 +02:00
parent a896a7bfec
commit b4c6a3fab1
67 changed files with 4337 additions and 3480 deletions

View File

@@ -16,14 +16,16 @@ using BeWo.Service.Invoicing;
using BeWo.Service.Plugins;
using BeWo.Service.ServiceImplementations;
using BS.Shared.DataContracts.Compact;
using BS.Shared.Extensions;
using DevExpress.Data.Helpers;
using DevExpress.XtraEditors.Controls;
namespace Humanitas
{
public partial class Finanzauswertung : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<FinanceRO>
{
private Dictionary<long, List<CostBearer2SupportConcept>> customer2CostbearerSupportConcepts = new Dictionary<long, List<CostBearer2SupportConcept>>();
public Finanzauswertung()
{
InitializeComponent();
@@ -51,15 +53,8 @@ namespace Humanitas
cellGeleistetImZeitraumHeader.Text = String.Format("geleistete Std. {0:dd.MM.yyyy}-{1:dd.MM.yyyy}", start, end);
}
if (pRO.RateFactor.HasValue)
{
cellRateFactorHeader.Text = String.Format("geleistete Std. x {0:0.##}", pRO.RateFactor);
}
else
{
cellRateFactorHeader.Visible = false;
cellRateFactor.Visible = false;
}
cellRateFactorHeader.Text = String.Format("geleistete Std. x {0:0.##}", 1.2);
}
else
@@ -72,7 +67,7 @@ namespace Humanitas
cellRateFactor.Visible = false;
}
var srList = DAOFactory.GenericDAO.GetAllActiveAndArchived<SupportConcept>();
var srList = DAOFactory.GenericDAO.GetAllActive<SupportConcept>();
foreach (var sc in srList)
{
@@ -87,7 +82,7 @@ namespace Humanitas
}
}
this.bindingSource1.DataSource = CreateReportObjects(pRO);
}
@@ -99,9 +94,12 @@ namespace Humanitas
{
foreach (var scRo in ro.SupportConceptFinanceList)
{
var entry = CreateEntry(ro, scRo);
if (scRo.Costbearer2Supportconcept.SupportConcept.ActivationType == ActivationTypeId.Active)
{
var entry = CreateEntry(ro, scRo);
result.Entries.Add(entry);
result.Entries.Add(entry);
}
}
}
@@ -118,6 +116,7 @@ namespace Humanitas
var c2s = DAOFactory.GenericDAO.LoadByID<CostBearer2SupportConcept>(entry.SupportConceptFinance.Costbearer2Supportconcept
.CostBearer2SupportConceptOid.Value);
BerechneStunden(fro, entry, c2s, scRo);
SetzeHilfeplanInfos(entry, c2s);
SetzeCustomerInfos(entry, c2s.SupportConcept.Customer);
@@ -128,6 +127,93 @@ namespace Humanitas
return entry;
}
private void BerechneStunden(FinanceRO fro, CustomFinanzauswertungEntry entry, CostBearer2SupportConcept c2S, FinanceRO.SupportConceptFinanceRO scRo)
{
var calc = Calculations.GetInstance(c2S.CostBearer.ID);
var relDC = MapperFactory.SupportConceptCostBearerRelDC_CostBearer2SupportConcept.MapToNewDC(c2S);
if (fro.ReportEndDate.HasValue && fro.ReportEndDate < DateTime.MaxValue.AddDays(-1))
{
scRo.ApprovedHours = calc.GetApprovedHoursTillNow(relDC, fro.ReportEndDate.Value) ?? 0;
//ro.ApprovedHours = calc.GetApprovedHoursTillNow(relDC, null) ?? 0;
scRo.BillableHours =
calc.GetBillableDurationInMinutes(scRo.ServiceRecords.Where(sr => sr.Start.Value.Date < fro.ReportEndDate.Value.AddDays(1)).ToList()) / 60;
}
else
{
scRo.ApprovedHours = calc.GetApprovedHoursTillNow(relDC, null) ?? 0;
scRo.BillableHours = calc.GetBillableDurationInMinutes(scRo.ServiceRecords) / 60;
}
if (fro.ReportStartDate.HasValue && fro.ReportEndDate.HasValue)
{
scRo.ApprovedHoursInReportTimeSpan = calc.GetApprovedHoursForPeriod(relDC, fro.ReportStartDate.Value, fro.ReportEndDate.Value);
//ro.BillableHoursInReportTimeSpan =
// calc.GetBillableDurationInMinutes(
// cb2sc.ServiceRecords.Where(sr => sr.Start >= start && sr.Start.Value.Date <= end.Value.Date).ToList().
// MapToNewDCs())/60;
var costRateDcs =
MapperFactory.CostRatePeriodDC_CostRatePeriod.MapToNewDCs(c2S.CostBearer.CostRatePeriods);
scRo.AmountInReportTimeSpan = 0;
foreach (var serviceRecordtemp in c2S.ServiceRecords)
{
if (serviceRecordtemp.Start >= fro.ReportStartDate && serviceRecordtemp.Start.Value.Date <= fro.ReportEndDate.Value.Date)
{
var dc = MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDC(serviceRecordtemp);
var billable = calc.GetBillableDurationInMinutes(dc) / 60;
scRo.BillableHoursInReportTimeSpan += billable;
var rfcr = costRateDcs.GetCostRatePeriodForDate(CostRatePeriodType.RateFactor, serviceRecordtemp.Start.Value);
if (rfcr != null && rfcr.CostRateValue.HasValue)
{
var billableRateFactor = billable * (rfcr.CostRateValue.Value + 100m) / 100m;
scRo.BillableHoursInReportTimeSpanWithFactor += billableRateFactor;
billable = billableRateFactor;
}
decimal stundensatz = 0;
var hcr = costRateDcs.GetCostRatePeriodForDate(CostRatePeriodType.HourlyRate, serviceRecordtemp.Start.Value);
if (hcr != null && hcr.CostRateValue.HasValue)
{
stundensatz = hcr.CostRateValue.Value;
}
var betrag = billable * stundensatz;
scRo.AmountInReportTimeSpan += betrag;
}
}
var rfcrEnd = costRateDcs.GetCostRatePeriodForDate(CostRatePeriodType.RateFactor, fro.ReportEndDate.Value);
if (rfcrEnd != null && rfcrEnd.CostRateValue.HasValue)
{
scRo.RateFactor = (rfcrEnd.CostRateValue.Value + 100m) / 100m;
if (!fro.RateFactor.HasValue)
{
fro.RateFactor = scRo.RateFactor;
}
}
var hcrEnd = costRateDcs.GetCostRatePeriodForDate(CostRatePeriodType.HourlyRate, fro.ReportEndDate.Value);
if (hcrEnd != null && hcrEnd.CostRateValue.HasValue)
{
scRo.HourlyRate = hcrEnd.CostRateValue.Value;
}
}
}
private void SetzeCustomerInfos(CustomFinanzauswertungEntry entry, Customer customer)
{
entry.Kostenstelle = customer.CostCenter;
@@ -210,6 +296,10 @@ namespace Humanitas
dict.Add(sc, scRo.ServiceRecords);
if (scRo.CustomerName.Contains("Amri"))
{
int test = 0;
}
var creator = factory.CreateInvoiceCreator(null, tenant, dict);
//String text = String.Format("Tenant={0}, Context=Null? {1}, Factory = {2}", tenant,
@@ -239,7 +329,7 @@ namespace Humanitas
dc.SupportConceptOid = c2s.SupportConcept.SupportConceptOid;
dc.CostBearerRelOids = new List<long>();
dc.CostBearerRelOids.Add(c2s.CostBearer2SupportConceptOid.Value);
dc.IsApproved = c2s.ApprovedStartDate.HasValue && c2s.ApprovedEndDate.HasValue;
dc.IsApproved = true;
return dc;
}
@@ -273,44 +363,100 @@ namespace Humanitas
StringBuilder rnrSb = new StringBuilder();
StringBuilder bezahltSb = new StringBuilder();
var invoices = DAOFactory.SearchDAO.GetServiceInvoices(c2s.Oid.Value, span);
var invoices = DAOFactory.SearchDAO.GetServiceInvoices(c2s.Oid.Value, null);
foreach (var i in invoices)
{
if (betragSb.Length > 0)
if (i.InvoiceBase.InvoiceDate >= span.StartDateTime && i.InvoiceBase.InvoiceDate <= span.EndDateTime)
{
betragSb.AppendLine();
}
if (datumSb.Length > 0)
{
datumSb.AppendLine();
}
if (rnrSb.Length > 0)
{
rnrSb.AppendLine();
}
if (bezahltSb.Length > 0)
{
bezahltSb.AppendLine();
}
decimal rechnungsBetrag = 0;
decimal rechnungsBetrag = 0;
foreach (var sip in i.ServiceInvoicePeriodList)
{
rechnungsBetrag += sip.Claim ?? 0;
}
foreach (var sip in i.ServiceInvoicePeriodList)
{
rechnungsBetrag += sip.Claim ?? 0;
}
betragSb.Append(String.Format("{0:c}", rechnungsBetrag));
datumSb.Append(String.Format("{0:dd.MM.yyyy}", i.InvoiceBase.InvoiceDate));
rnrSb.Append(i.InvoiceBase.InvoiceNumber);
bezahltSb.Append(i.InvoiceBase.IsPaid ? "Ja" : "Nein");
AddRechnung(rechnungsBetrag, i.InvoiceBase.InvoiceDate, i.InvoiceBase.InvoiceNumber,
i.InvoiceBase.IsPaid, betragSb, datumSb, rnrSb, bezahltSb);
}
}
var settlementInvoices = DAOFactory.SearchDAO.GetSettlementInvoiceByCostBearer2SupportConceptOid(c2s.Oid.Value);
foreach (var si in settlementInvoices)
{
if (si.InvoiceBase.InvoiceDate >= span.StartDateTime && si.InvoiceBase.InvoiceDate <= span.EndDateTime)
{
AddRechnung(si.AmountBillableTotal ?? 0, si.InvoiceBase.InvoiceDate, si.InvoiceBase.InvoiceNumber, si.InvoiceBase.IsPaid, betragSb, datumSb, rnrSb, bezahltSb);
entry.SpitzabrechnungDifferenz = String.Format("{0:c}", si.Claim);
}
}
var allgemeine = DAOFactory.SearchDAO.GetInvoiceBaseByCustomerOid(InvoiceType.General, c2s.SupportConcept.Customer.Oid.Value);
foreach (var ibAllgemein in allgemeine)
{
if (ibAllgemein.InvoiceDate >= span.StartDateTime && ibAllgemein.InvoiceDate <= span.EndDateTime)
{
decimal rechnungsBetrag = 0;
foreach (var ii in ibAllgemein.InvoiceItems)
{
rechnungsBetrag += ii.AmountTotal ?? 0;
}
AddRechnung(rechnungsBetrag, ibAllgemein.InvoiceDate, ibAllgemein.InvoiceNumber, ibAllgemein.IsPaid, betragSb, datumSb, rnrSb, bezahltSb);
}
}
IList<InvoiceBase> eigenanteil = DAOFactory.SearchDAO.GetInvoiceBaseByTypeAndSupportConceptOid(InvoiceType.CustomerEquity, c2s.SupportConcept.Oid.Value);
foreach (var ibEigen in eigenanteil)
{
if (ibEigen.InvoiceDate >= span.StartDateTime && ibEigen.InvoiceDate <= span.EndDateTime)
{
decimal rechnungsBetrag = 0;
foreach (var ii in ibEigen.InvoiceItems)
{
rechnungsBetrag += ii.AmountTotal ?? 0;
}
AddRechnung(rechnungsBetrag, ibEigen.InvoiceDate, ibEigen.InvoiceNumber, ibEigen.IsPaid, betragSb, datumSb, rnrSb, bezahltSb);
}
}
entry.RechnungsBetrag = betragSb.ToString();
entry.RechnungsDatum = datumSb.ToString();
entry.RechnungsNummer = rnrSb.ToString();
entry.RechnungBezahlt = bezahltSb.ToString();
}
private void AddRechnung(decimal betrag, DateTime? invoiceDate, String invoiceNumber, bool isPaid, StringBuilder betragSb, StringBuilder datumSb, StringBuilder rnrSb, StringBuilder bezahltSb)
{
if (betragSb.Length > 0)
{
betragSb.AppendLine();
}
if (datumSb.Length > 0)
{
datumSb.AppendLine();
}
if (rnrSb.Length > 0)
{
rnrSb.AppendLine();
}
if (bezahltSb.Length > 0)
{
bezahltSb.AppendLine();
}
betragSb.Append(String.Format("{0:c}", betrag));
datumSb.Append(String.Format("{0:dd.MM.yyyy}", invoiceDate));
rnrSb.Append(invoiceNumber);
bezahltSb.Append(isPaid ? "Ja" : "Nein");
}
}
@@ -330,6 +476,7 @@ namespace Humanitas
public DateTime? BewilligungEnde { get; set; }
public decimal Abschlagszahlungen { get; set; }
public String RechnungsBetrag { get; set; }
public String SpitzabrechnungDifferenz { get; set; }
public String RechnungsDatum { get; set; }
public String RechnungsNummer { get; set; }
public String RechnungBezahlt { get; set; }

View File

@@ -61,6 +61,7 @@ namespace Humanitas
this.xrTableCell38 = new DevExpress.XtraReports.UI.XRTableCell();
this.xrTableCell50 = new DevExpress.XtraReports.UI.XRTableCell();
this.xrTableCell51 = new DevExpress.XtraReports.UI.XRTableCell();
this.xrTableCell71 = new DevExpress.XtraReports.UI.XRTableCell();
this.xrTableCell52 = new DevExpress.XtraReports.UI.XRTableCell();
this.xrTableCell54 = new DevExpress.XtraReports.UI.XRTableCell();
this.xrTableCell55 = new DevExpress.XtraReports.UI.XRTableCell();
@@ -92,6 +93,7 @@ namespace Humanitas
this.xrTableCell37 = new DevExpress.XtraReports.UI.XRTableCell();
this.xrTableCell40 = new DevExpress.XtraReports.UI.XRTableCell();
this.xrTableCell41 = new DevExpress.XtraReports.UI.XRTableCell();
this.xrTableCell70 = new DevExpress.XtraReports.UI.XRTableCell();
this.xrTableCell42 = new DevExpress.XtraReports.UI.XRTableCell();
this.xrTableCell43 = new DevExpress.XtraReports.UI.XRTableCell();
this.xrTableCell44 = new DevExpress.XtraReports.UI.XRTableCell();
@@ -120,6 +122,7 @@ namespace Humanitas
this.xrTableCell39 = new DevExpress.XtraReports.UI.XRTableCell();
this.xrTableCell60 = new DevExpress.XtraReports.UI.XRTableCell();
this.xrTableCell61 = new DevExpress.XtraReports.UI.XRTableCell();
this.xrTableCell72 = new DevExpress.XtraReports.UI.XRTableCell();
this.xrTableCell62 = new DevExpress.XtraReports.UI.XRTableCell();
this.xrTableCell63 = new DevExpress.XtraReports.UI.XRTableCell();
this.xrTableCell64 = new DevExpress.XtraReports.UI.XRTableCell();
@@ -128,6 +131,7 @@ namespace Humanitas
this.xrTableCell67 = new DevExpress.XtraReports.UI.XRTableCell();
this.xrTableCell68 = new DevExpress.XtraReports.UI.XRTableCell();
this.xrTableCell69 = new DevExpress.XtraReports.UI.XRTableCell();
this.bindingSource1 = new System.Windows.Forms.BindingSource(this.components);
this.ReportHeader = new DevExpress.XtraReports.UI.ReportHeaderBand();
this.pageFooterBand1 = new DevExpress.XtraReports.UI.PageFooterBand();
this.Title = new DevExpress.XtraReports.UI.XRControlStyle();
@@ -139,7 +143,6 @@ namespace Humanitas
this.bottomMarginBand1 = new DevExpress.XtraReports.UI.BottomMarginBand();
this.TESTPARAMTER = new DevExpress.XtraReports.Parameters.Parameter();
this.parameter1 = new DevExpress.XtraReports.Parameters.Parameter();
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.xrTable3)).BeginInit();
@@ -173,7 +176,7 @@ namespace Humanitas
this.xrTable2.Padding = new DevExpress.XtraPrinting.PaddingInfo(3, 3, 0, 0, 100F);
this.xrTable2.Rows.AddRange(new DevExpress.XtraReports.UI.XRTableRow[] {
this.xrTableRow2});
this.xrTable2.SizeF = new System.Drawing.SizeF(2550F, 25F);
this.xrTable2.SizeF = new System.Drawing.SizeF(2650F, 25F);
this.xrTable2.StylePriority.UseBorders = false;
this.xrTable2.StylePriority.UseFont = false;
this.xrTable2.StylePriority.UsePadding = false;
@@ -200,6 +203,7 @@ namespace Humanitas
this.xrTableCell38,
this.xrTableCell50,
this.xrTableCell51,
this.xrTableCell71,
this.xrTableCell52,
this.xrTableCell54,
this.xrTableCell55,
@@ -374,6 +378,15 @@ namespace Humanitas
this.xrTableCell51.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight;
this.xrTableCell51.Weight = 0.44313146230871525D;
//
// xrTableCell71
//
this.xrTableCell71.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
new DevExpress.XtraReports.UI.XRBinding("Text", null, "Entries.SpitzabrechnungDifferenz")});
this.xrTableCell71.Name = "xrTableCell71";
this.xrTableCell71.StylePriority.UseTextAlignment = false;
this.xrTableCell71.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight;
this.xrTableCell71.Weight = 0.44313146230871525D;
//
// xrTableCell52
//
this.xrTableCell52.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
@@ -497,7 +510,7 @@ namespace Humanitas
this.xrTable1.Padding = new DevExpress.XtraPrinting.PaddingInfo(3, 3, 0, 0, 100F);
this.xrTable1.Rows.AddRange(new DevExpress.XtraReports.UI.XRTableRow[] {
this.xrTableRow1});
this.xrTable1.SizeF = new System.Drawing.SizeF(2550F, 50F);
this.xrTable1.SizeF = new System.Drawing.SizeF(2650F, 50F);
this.xrTable1.StylePriority.UseBorders = false;
this.xrTable1.StylePriority.UseFont = false;
this.xrTable1.StylePriority.UsePadding = false;
@@ -524,6 +537,7 @@ namespace Humanitas
this.xrTableCell37,
this.xrTableCell40,
this.xrTableCell41,
this.xrTableCell70,
this.xrTableCell42,
this.xrTableCell43,
this.xrTableCell44,
@@ -674,6 +688,15 @@ namespace Humanitas
this.xrTableCell41.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
this.xrTableCell41.Weight = 0.44313146230871525D;
//
// xrTableCell70
//
this.xrTableCell70.Multiline = true;
this.xrTableCell70.Name = "xrTableCell70";
this.xrTableCell70.StylePriority.UseTextAlignment = false;
this.xrTableCell70.Text = "Spitzabr.\r\nDifferenz";
this.xrTableCell70.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
this.xrTableCell70.Weight = 0.44313146230871525D;
//
// xrTableCell42
//
this.xrTableCell42.Multiline = true;
@@ -760,7 +783,7 @@ namespace Humanitas
this.xrTable3.Padding = new DevExpress.XtraPrinting.PaddingInfo(3, 3, 0, 0, 100F);
this.xrTable3.Rows.AddRange(new DevExpress.XtraReports.UI.XRTableRow[] {
this.xrTableRow3});
this.xrTable3.SizeF = new System.Drawing.SizeF(2550F, 25F);
this.xrTable3.SizeF = new System.Drawing.SizeF(2650F, 25F);
this.xrTable3.StylePriority.UseBorders = false;
this.xrTable3.StylePriority.UseFont = false;
this.xrTable3.StylePriority.UsePadding = false;
@@ -787,6 +810,7 @@ namespace Humanitas
this.xrTableCell39,
this.xrTableCell60,
this.xrTableCell61,
this.xrTableCell72,
this.xrTableCell62,
this.xrTableCell63,
this.xrTableCell64,
@@ -984,6 +1008,13 @@ namespace Humanitas
this.xrTableCell61.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight;
this.xrTableCell61.Weight = 0.44313146230871536D;
//
// xrTableCell72
//
this.xrTableCell72.Name = "xrTableCell72";
this.xrTableCell72.StylePriority.UseTextAlignment = false;
this.xrTableCell72.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight;
this.xrTableCell72.Weight = 0.44313146230871536D;
//
// xrTableCell62
//
this.xrTableCell62.Name = "xrTableCell62";
@@ -1040,6 +1071,10 @@ namespace Humanitas
this.xrTableCell69.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight;
this.xrTableCell69.Weight = 0.44313146230871536D;
//
// bindingSource1
//
this.bindingSource1.DataSource = typeof(Humanitas.CustomFinanzauswertungRO);
//
// ReportHeader
//
this.ReportHeader.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] {
@@ -1123,10 +1158,6 @@ namespace Humanitas
this.parameter1.Type = typeof(bool);
this.parameter1.ValueInfo = "False";
//
// bindingSource1
//
this.bindingSource1.DataSource = typeof(Humanitas.CustomFinanzauswertungRO);
//
// Finanzauswertung
//
this.Bands.AddRange(new DevExpress.XtraReports.UI.Band[] {
@@ -1140,7 +1171,7 @@ namespace Humanitas
this.Landscape = true;
this.Margins = new System.Drawing.Printing.Margins(50, 50, 50, 30);
this.PageHeight = 827;
this.PageWidth = 2660;
this.PageWidth = 2760;
this.PaperKind = System.Drawing.Printing.PaperKind.Custom;
this.Parameters.AddRange(new DevExpress.XtraReports.Parameters.Parameter[] {
this.TESTPARAMTER,
@@ -1261,5 +1292,8 @@ namespace Humanitas
private DevExpress.XtraReports.UI.XRTableCell xrTableCell57;
private DevExpress.XtraReports.UI.XRTableCell xrTableCell58;
private DevExpress.XtraReports.UI.XRTableCell xrTableCell59;
private DevExpress.XtraReports.UI.XRTableCell xrTableCell71;
private DevExpress.XtraReports.UI.XRTableCell xrTableCell70;
private DevExpress.XtraReports.UI.XRTableCell xrTableCell72;
}
}

View File

@@ -49,6 +49,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="CustomMitarbeiterstundenkontoBerechnung.cs" />
<Compile Include="CustomReportCreator.cs" />
<Compile Include="Export\CustomDataExporter.cs" />
<Compile Include="Export\DatevExporter.cs" />
<Compile Include="Finanzauswertung.cs">