342 lines
14 KiB
C#
342 lines
14 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Report;
|
|
using BeWo.Report.ReportObjects;
|
|
using BS.Shared;
|
|
using BS.Shared.DataContracts;
|
|
|
|
namespace ABWElsebrock
|
|
{
|
|
public partial class Spitzabrechnung : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<SettlementRO>
|
|
{
|
|
public Spitzabrechnung()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void SetReportDataSource(SettlementRO pRO)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
if (!String.IsNullOrEmpty(pRO.RecipientOrganisation))
|
|
{
|
|
sb.AppendLine(pRO.RecipientOrganisation);
|
|
}
|
|
if (!String.IsNullOrEmpty(pRO.RecipientContactPerson))
|
|
{
|
|
sb.AppendLine(pRO.RecipientContactPerson);
|
|
}
|
|
if (!String.IsNullOrEmpty(pRO.RecipientDivision))
|
|
{
|
|
sb.AppendLine(pRO.RecipientDivision);
|
|
}
|
|
if (!String.IsNullOrEmpty(pRO.RecipientStreet))
|
|
{
|
|
sb.AppendLine(pRO.RecipientStreet);
|
|
}
|
|
if (!String.IsNullOrEmpty(pRO.RecipientPostCodeAndTown))
|
|
{
|
|
sb.AppendLine(pRO.RecipientPostCodeAndTown);
|
|
}
|
|
lblAdresse.Text = sb.ToString();
|
|
|
|
if (pRO.Salutation1 == "Frau")
|
|
{
|
|
lblBetreff.Text =
|
|
String.Format(
|
|
"Spitzabrechnung unserer Klientin Frau {0}, {1}, geb. am {2}",
|
|
pRO.CustomerLastName, pRO.CustomerFirstName, pRO.CustomerBirthdayString);
|
|
lblAnrede2.Text =
|
|
String.Format(
|
|
"anliegend überreichen wir Ihnen unsere Spitzabrechnung für unsere Klientin Frau {0}, {1}.",
|
|
pRO.CustomerLastName, pRO.CustomerFirstName);
|
|
}
|
|
else
|
|
{
|
|
lblBetreff.Text =
|
|
String.Format(
|
|
"Spitzabrechnung unseres Klienten Herrn {0}, {1}, geb. am {2}",
|
|
pRO.CustomerLastName, pRO.CustomerFirstName, pRO.CustomerBirthdayString);
|
|
|
|
lblAnrede2.Text =
|
|
String.Format(
|
|
"anliegend überreichen wir Ihnen unsere Spitzabrechnung für unseren Klienten Herrn {0}, {1}.",
|
|
pRO.CustomerLastName, pRO.CustomerFirstName);
|
|
}
|
|
bool isDefaultSpitzabrechnung = false;
|
|
|
|
|
|
//if (String.IsNullOrEmpty(pRO.Notice))
|
|
//{
|
|
// lblNotice.Text = "";
|
|
//}
|
|
|
|
if (pRO.InvoiceItems != null && pRO.InvoiceItems.Count == 1)
|
|
{
|
|
var ii = pRO.InvoiceItems[0];
|
|
if ((ii.ItemDescription == "Spitzabrechung" || ii.ItemDescription == "Spitzabrechnung") && ii.GrossAmountTotal == null && ii.RateFactor == null)
|
|
{
|
|
isDefaultSpitzabrechnung = true;
|
|
}
|
|
}
|
|
if (!isDefaultSpitzabrechnung)
|
|
{
|
|
if (pRO.DifferentHourlyRateCount > 0 && pRO.HourlyRateNew.HasValue)
|
|
{
|
|
isDefaultSpitzabrechnung = true;
|
|
}
|
|
}
|
|
|
|
if (isDefaultSpitzabrechnung)
|
|
{
|
|
//UpdateAbrechnungsFelder(pRO);
|
|
|
|
pRO.InvoiceItems = CreateDefaultSpitzabrechnungInvoiceItems(pRO);
|
|
}
|
|
else
|
|
{
|
|
if (pRO.InvoiceItems != null)
|
|
{
|
|
foreach (var ii in pRO.InvoiceItems)
|
|
{
|
|
ii.ItemDescription = String.Format("{0:dd.MM.yyyy} bis {1:dd.MM.yyyy}: {2:0.##} FLS {3}x {4:c}",
|
|
ii.ItemPeriodStart, ii.ItemPeriodEnd,
|
|
ii.UnitCount, ii.RateFactor == 0 ? "" : "x " + pRO.RateFactorText2 + " ",
|
|
ii.AmountPerUnit);
|
|
}
|
|
}
|
|
var id = GetCustomerId(pRO);
|
|
if (id == "LWLNEU")
|
|
{
|
|
pRO.RateFactorText = null;
|
|
pRO.RateFactorText2 = null;
|
|
}
|
|
}
|
|
|
|
lblMitarbeiter.Text = GetMitarbeiter(pRO);
|
|
|
|
if (pRO.InvoiceItems != null)
|
|
{
|
|
foreach (var invoiceItemDc in pRO.InvoiceItems)
|
|
{
|
|
DateTime dt = DateTime.Now.Date.AddMinutes((double)(invoiceItemDc.UnitCount ?? 0) * 60);
|
|
TimeSpan tspan = dt.Subtract(DateTime.Now.Date);
|
|
|
|
double d = tspan.TotalHours;
|
|
|
|
d = Math.Floor(d);
|
|
|
|
invoiceItemDc.Notice = String.Format("{0:00}:{1:00}", d, tspan.Minutes);
|
|
}
|
|
}
|
|
this.bindingSource1.DataSource = pRO;
|
|
}
|
|
|
|
private string GetMitarbeiter(SettlementRO pRo)
|
|
{
|
|
String mitarbeiter = "";
|
|
|
|
var cb2sc = DAOFactory.GenericDAO.LoadByID<CostBearer2SupportConcept>(pRo.CostBearer2SupportConceptOid);
|
|
var customer = cb2sc.SupportConcept.Customer;
|
|
|
|
foreach (var item in customer.Employee2CustomerList)
|
|
{
|
|
foreach (var valueEntry in item.ValueList)
|
|
{
|
|
if (valueEntry.Entry.SystemEntryID != null && valueEntry.Entry.SystemEntryID.Value == SystemEntryID.EmployeeRoleMainAttendant)
|
|
{
|
|
var empName = item.Employee.Person.FirstName + " " + item.Employee.Person.LastName;
|
|
var empName2 = string.Format("{0}, {1}", item.Employee.Person.LastName, item.Employee.Person.FirstName);
|
|
|
|
if (String.IsNullOrEmpty(mitarbeiter))
|
|
{
|
|
mitarbeiter = empName;
|
|
}
|
|
else
|
|
{
|
|
if (!mitarbeiter.Contains(empName))
|
|
{
|
|
mitarbeiter += ", " + empName;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
return mitarbeiter;
|
|
}
|
|
|
|
private String GetCustomerId(SettlementRO pRO)
|
|
{
|
|
var cb2sc = DAOFactory.GenericDAO.LoadByID<CostBearer2SupportConcept>(pRO.CostBearer2SupportConceptOid);
|
|
return cb2sc.CostBearer.ID;
|
|
}
|
|
|
|
private IList<InvoiceItemDC> CreateDefaultSpitzabrechnungInvoiceItems(SettlementRO pRO)
|
|
{
|
|
IList<InvoiceItemDC> itemList = new List<InvoiceItemDC>();
|
|
if (pRO.DifferentHourlyRateCount == 3)
|
|
{
|
|
|
|
itemList.Add(new InvoiceItemDC
|
|
{
|
|
ItemDescription = String.Format("{0} bis {1}: {2:0.##} FLS {3}x {4:c}",
|
|
pRO.AccountingStartDateString, pRO.HourlyRate3EndDateString,
|
|
pRO.GeleisteteFLSMitStundensatz3, pRO.RateFactor == 1 ? "" : "x " + pRO.RateFactorText2 + " ", pRO.HourlyRate3),
|
|
|
|
GrossAmountTotal = pRO.GeleisteteFLSMitStundensatz3 * pRO.RateFactor * pRO.HourlyRate3,
|
|
ItemPeriodStart = pRO.AccountingStartDate,
|
|
ItemPeriodEnd = pRO.HourlyRateEndDate3,
|
|
AmountPerUnit = pRO.HourlyRate3,
|
|
RateFactor = pRO.RateFactor,
|
|
UnitCount = pRO.GeleisteteFLSMitStundensatz3
|
|
});
|
|
|
|
itemList.Add(new InvoiceItemDC
|
|
{
|
|
ItemDescription = String.Format("{0} bis {1}: {2:0.##} FLS {3}x {4:c}",
|
|
pRO.HourlyRateOldStartDateString, pRO.HourlyRateOldEndDateString,
|
|
pRO.GeleisteteFLSMitStundensatzAlt, pRO.RateFactor == 1 ? "" : "x " + pRO.RateFactorText2 + " ", pRO.HourlyRateOld),
|
|
|
|
GrossAmountTotal = pRO.GeleisteteFLSMitStundensatzAlt * pRO.RateFactor * pRO.HourlyRateOld,
|
|
ItemPeriodStart = pRO.HourlyRateOldStartDate,
|
|
ItemPeriodEnd = pRO.HourlyRateOldEndDate,
|
|
AmountPerUnit = pRO.HourlyRateOld,
|
|
RateFactor = pRO.RateFactor,
|
|
UnitCount = pRO.GeleisteteFLSMitStundensatzAlt
|
|
});
|
|
|
|
itemList.Add(new InvoiceItemDC
|
|
{
|
|
ItemDescription = String.Format("{0} bis {1}: {2:0.##} FLS {3}x {4:c}",
|
|
pRO.HourlyRateNewStartDateString, pRO.AccountingEndDateString,
|
|
pRO.GeleisteteFLSMitStundensatzAktuell, pRO.RateFactor == 1 ? "" : "x " + pRO.RateFactorText2 + " ", pRO.HourlyRateNew),
|
|
|
|
GrossAmountTotal = pRO.GeleisteteFLSMitStundensatzAktuell * pRO.RateFactor * pRO.HourlyRateNew,
|
|
ItemPeriodStart = pRO.HourlyRateNewStartDate,
|
|
ItemPeriodEnd = pRO.AccountingEndDate,
|
|
AmountPerUnit = pRO.HourlyRateNew,
|
|
RateFactor = pRO.RateFactor,
|
|
UnitCount = pRO.GeleisteteFLSMitStundensatzAktuell
|
|
});
|
|
|
|
}
|
|
else if (pRO.DifferentHourlyRateCount == 2)
|
|
{
|
|
itemList.Add(new InvoiceItemDC
|
|
{
|
|
ItemDescription = String.Format("{0} bis {1}: {2:0.##} FLS {3}x {4:c}",
|
|
pRO.AccountingStartDateString, pRO.HourlyRateOldEndDateString,
|
|
pRO.GeleisteteFLSMitStundensatzAlt, pRO.RateFactor == 1 ? "" : "x " + pRO.RateFactorText2 + " ", pRO.HourlyRateOld),
|
|
|
|
GrossAmountTotal = pRO.GeleisteteFLSMitStundensatzAlt * (decimal)pRO.RateFactor * pRO.HourlyRateOld,
|
|
ItemPeriodStart = pRO.AccountingStartDate,
|
|
ItemPeriodEnd = pRO.HourlyRateOldEndDate,
|
|
AmountPerUnit = pRO.HourlyRateOld,
|
|
RateFactor = pRO.RateFactor,
|
|
UnitCount = pRO.GeleisteteFLSMitStundensatzAlt
|
|
});
|
|
|
|
itemList.Add(new InvoiceItemDC
|
|
{
|
|
ItemDescription = String.Format("{0} bis {1}: {2:0.##} FLS {3}x {4:c}",
|
|
pRO.HourlyRateNewStartDateString, pRO.AccountingEndDateString,
|
|
pRO.GeleisteteFLSMitStundensatzAktuell, pRO.RateFactor == 1 ? "" : "x " + pRO.RateFactorText2 + " ", pRO.HourlyRateNew),
|
|
|
|
GrossAmountTotal = pRO.GeleisteteFLSMitStundensatzAktuell * pRO.RateFactor * pRO.HourlyRateNew,
|
|
ItemPeriodStart = pRO.HourlyRateNewStartDate,
|
|
ItemPeriodEnd = pRO.AccountingEndDate,
|
|
AmountPerUnit = pRO.HourlyRateNew,
|
|
RateFactor = pRO.RateFactor,
|
|
UnitCount = pRO.GeleisteteFLSMitStundensatzAktuell
|
|
});
|
|
|
|
}
|
|
else
|
|
{
|
|
itemList.Add(new InvoiceItemDC
|
|
{
|
|
ItemDescription = String.Format("{0} bis {1}: {2:0.##} FLS {3}x {4:c}",
|
|
pRO.AccountingStartDateString, pRO.AccountingEndDateString,
|
|
pRO.GeleisteteFLSMitStundensatzAktuell, pRO.RateFactor == 1 ? "" : "x " + pRO.RateFactorText2 + " ", pRO.HourlyRateNew),
|
|
|
|
GrossAmountTotal = pRO.GeleisteteFLSMitStundensatzAktuell * pRO.RateFactor * pRO.HourlyRateNew,
|
|
ItemPeriodStart = pRO.AccountingStartDate,
|
|
ItemPeriodEnd = pRO.AccountingEndDate,
|
|
AmountPerUnit = pRO.HourlyRateNew,
|
|
RateFactor = pRO.RateFactor,
|
|
UnitCount = pRO.GeleisteteFLSMitStundensatzAktuell
|
|
});
|
|
|
|
}
|
|
|
|
return itemList;
|
|
}
|
|
|
|
private void UpdateAbrechnungsFelder(SettlementRO pRO)
|
|
{
|
|
if (pRO.DifferentHourlyRateCount == 3)
|
|
{
|
|
//Erbrachte Leistungen (FLS) - bis [HourlyRateOldEndDateString] à [HourlyRateOldString] €
|
|
|
|
pRO.Abrechnungstext1 = String.Format("{0} bis {1}",
|
|
pRO.AccountingStartDateString, pRO.HourlyRate3EndDateString);
|
|
|
|
pRO.Abrechnungstext1 += String.Format(": {0:0.##} FLS {1}x {2:c}",
|
|
pRO.GeleisteteFLSMitStundensatz3, pRO.RateFactor == 1 ? "" : "x " + pRO.RateFactorText2 + " ", pRO.HourlyRate3);
|
|
|
|
//[AccountingStartDateString] - [HourlyRate3EndDateString] sind [RecordedFLSWithHourlyRate3String] Std. x [HourlyRate3String] € =";
|
|
|
|
pRO.Betrag1 = String.Format("{0:c}", pRO.GeleisteteFLSMitStundensatz3 * (decimal)pRO.RateFactor * pRO.HourlyRate3);
|
|
|
|
|
|
pRO.Abrechnungstext2 = String.Format("{0} bis {1}",
|
|
pRO.HourlyRateOldStartDateString, pRO.HourlyRateOldEndDateString);
|
|
pRO.Abrechnungstext2 += String.Format(": {0:0.##} FLS {1}x {2:c}",
|
|
pRO.GeleisteteFLSMitStundensatzAlt, pRO.RateFactor == 1 ? "" : "x " + pRO.RateFactorText2 + " ", pRO.HourlyRateOld);
|
|
|
|
pRO.Betrag2 = String.Format("{0:c}", pRO.GeleisteteFLSMitStundensatzAlt * (decimal)pRO.RateFactor * pRO.HourlyRateOld);
|
|
|
|
|
|
pRO.Abrechnungstext3 = String.Format("{0} bis {1}",
|
|
pRO.HourlyRateNewStartDateString, pRO.AccountingEndDateString);
|
|
pRO.Abrechnungstext3 += String.Format(": {0:0.##} FLS {1}x {2:c}",
|
|
pRO.GeleisteteFLSMitStundensatzAktuell, pRO.RateFactor == 1 ? "" : "x " + pRO.RateFactorText2 + " ", pRO.HourlyRateNew);
|
|
|
|
pRO.Betrag3 = String.Format("{0:c}", pRO.GeleisteteFLSMitStundensatzAktuell * (decimal)pRO.RateFactor * pRO.HourlyRateNew);
|
|
}
|
|
else if (pRO.DifferentHourlyRateCount == 2)
|
|
{
|
|
|
|
pRO.Abrechnungstext2 = String.Format("{0} bis {1}",
|
|
pRO.AccountingStartDateString, pRO.HourlyRateOldEndDateString);
|
|
pRO.Abrechnungstext2 += String.Format(": {0:0.##} FLS {1}x {2:c}",
|
|
pRO.GeleisteteFLSMitStundensatzAlt, pRO.RateFactor == 1 ? "" : "x " + pRO.RateFactorText2 + " ", pRO.HourlyRateOld);
|
|
|
|
pRO.Betrag2 = String.Format("{0:c}", pRO.GeleisteteFLSMitStundensatzAlt * (decimal)pRO.RateFactor * pRO.HourlyRateOld);
|
|
|
|
|
|
pRO.Abrechnungstext3 = String.Format("{0} bis {1}",
|
|
pRO.HourlyRateNewStartDateString, pRO.AccountingEndDateString);
|
|
pRO.Abrechnungstext3 += String.Format(": {0:0.##} FLS {1}x {2:c}",
|
|
pRO.GeleisteteFLSMitStundensatzAktuell, pRO.RateFactor == 1 ? "" : "x " + pRO.RateFactorText2 + " ", pRO.HourlyRateNew);
|
|
|
|
pRO.Betrag3 = String.Format("{0:c}", pRO.GeleisteteFLSMitStundensatzAktuell * (decimal)pRO.RateFactor * pRO.HourlyRateNew);
|
|
}
|
|
else
|
|
{
|
|
pRO.Abrechnungstext3 = String.Format("{0} bis {1}",
|
|
pRO.AccountingStartDateString, pRO.AccountingEndDateString);
|
|
pRO.Abrechnungstext3 += String.Format(": {0:0.##} FLS {1}x {2:c}",
|
|
pRO.GeleisteteFLSMitStundensatzAktuell, pRO.RateFactor == 1 ? "" : "x " + pRO.RateFactorText2 + " ", pRO.HourlyRateNew);
|
|
|
|
pRO.Betrag3 = String.Format("{0:c}", pRO.GeleisteteFLSMitStundensatzAktuell * (decimal)pRO.RateFactor * pRO.HourlyRateNew);
|
|
}
|
|
}
|
|
}
|
|
}
|