Zuverdienst
This commit is contained in:
@@ -50,6 +50,108 @@ namespace DomizielAnsbach.Invoicing
|
||||
serviceInvoice.InvoiceBase.RecipientAddress = address.CopyToNew();
|
||||
}
|
||||
|
||||
public override IList<InvoiceItem> CreateInvoiceItems(List<ServiceRecordDC> serviceRecordsInPeriod, DateTimeSpan invoicePeriod, SupportConceptApprovalPeriod scap,
|
||||
BS.Shared.Services.Calculations calc)
|
||||
{
|
||||
var list = base.CreateInvoiceItems(serviceRecordsInPeriod, invoicePeriod, scap, calc);
|
||||
var cb2sc = scap.CostBearer2SupportConcept;
|
||||
|
||||
IList<InvoiceItem> ergebnis = new List<InvoiceItem>();
|
||||
var customer = cb2sc.SupportConcept.Customer;
|
||||
|
||||
DateTime start = invoicePeriod.StartDate;
|
||||
DateTime ende = invoicePeriod.EndDate;
|
||||
////decimal tageMonat;
|
||||
//int count = 0;
|
||||
//decimal firstDays = 0;
|
||||
|
||||
//var c = scap.CostBearer2SupportConcept.SupportConcept.Customer;
|
||||
var cbOid = scap.CostBearer2SupportConcept.CostBearer.Oid ?? 0;
|
||||
var pausch = ZuverdienstHelper.GetPauschalen(cbOid, customer, DateTime.Today);
|
||||
//var tage = ZuverdienstHelper.SetArbeitszeiten(pRO, cbOid, c);
|
||||
|
||||
var crList = MapperFactory.CostRatePeriodDC_CostRatePeriod.MapToNewDCs(scap.ServiceCategory.CostRatePeriods);
|
||||
AddCostRatePeriods(crList, pausch, scap);
|
||||
|
||||
var mot = crList.GetCostRatePeriodForDate(BS.Shared.CostRatePeriodType.AmountOfMoney, start);
|
||||
decimal? stundensatz;
|
||||
|
||||
//if (crp != null && crp.CostRateValue.HasValue)
|
||||
// monatssatz = crp.CostRateValue;
|
||||
//var tagessatz = Convert.ToInt32(monatssatz) / 30.42;
|
||||
|
||||
foreach (var at in customer.AbsenceTimes)
|
||||
{
|
||||
if (at.AbsenceReason.BillableMinutes.HasValue && at.AbsenceReason.Description.Contains("ZV"))
|
||||
{
|
||||
if (at.Start.HasValue && at.End.HasValue && (at.Start.Value >= start || at.End.Value >= ende) && at.Start.Value <= ende)
|
||||
{
|
||||
for (int i = 0; i <= (at.End.Value - at.Start.Value).Days; i++)
|
||||
{
|
||||
var tag = at.Start.Value.AddDays(i);
|
||||
var reason = at.AbsenceReason.Description.Substring(5);
|
||||
if (reason.Contains("Urlaub") || reason.Contains("Feiertag") || reason.Contains("krank"))
|
||||
{
|
||||
var std = GetFeiertagsstunden(customer.Arbeitszeiten, customer, tag);
|
||||
if (std > 0)
|
||||
{
|
||||
if (reason.Contains("Urlaub") && (pausch.urlaub != 0 || pausch.urlaubMot == true))
|
||||
{
|
||||
if (pausch.urlaub != 0)
|
||||
stundensatz = pausch.urlaub;
|
||||
else
|
||||
stundensatz = mot.CostRateValue;
|
||||
}
|
||||
else if (reason.Contains("krank") && (pausch.krank != 0 || pausch.krankMot == true))
|
||||
{
|
||||
if (pausch.krank != 0)
|
||||
stundensatz = pausch.krank;
|
||||
else
|
||||
stundensatz = mot.CostRateValue;
|
||||
}
|
||||
else if (reason.Contains("Feiertag") && (pausch.feiertag != 0 || pausch.feiertagMot == true))
|
||||
{
|
||||
if (pausch.feiertag != 0)
|
||||
stundensatz = pausch.feiertag;
|
||||
else
|
||||
stundensatz = mot.CostRateValue;
|
||||
}
|
||||
else
|
||||
stundensatz = 0;
|
||||
if (stundensatz != 0)
|
||||
{
|
||||
var ii = new InvoiceItem();
|
||||
//stundensatz = mot.CostRateValue;
|
||||
ii.AmountPerUnit = std * stundensatz;
|
||||
ii.UnitCount = 1;
|
||||
ii.AmountTotal = std * stundensatz;
|
||||
ii.GrossAmountTotal = std * stundensatz;
|
||||
ii.ItemPeriodStart = start;
|
||||
ii.ItemPeriodEnd = ende;
|
||||
ii.UnitDescription = "Tag";
|
||||
//ii.RateFactor = 1;
|
||||
//ii.AccountingInterval = bd.AccountingInterval;
|
||||
ii.ItemDescription = String.Format("bezahlte Freistellung ({0})", reason);
|
||||
|
||||
ergebnis.Add(ii);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//var aitem = CreateAbwesenheitsItem(serviceRecordsInPeriod, invoicePeriod, scap);
|
||||
|
||||
if (ergebnis != null)
|
||||
foreach (var i in ergebnis)
|
||||
{
|
||||
list.Add(i);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public override InvoiceItem CreateInvoiceItem(ServiceRecordDC iServiceRecord, SupportConceptApprovalPeriod scap, Calculations calc)
|
||||
{
|
||||
var invoiceItem = new InvoiceItem();
|
||||
@@ -176,5 +278,49 @@ namespace DomizielAnsbach.Invoicing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static decimal GetFeiertagsstunden(IList<Arbeitszeit> zeiten, Customer c, DateTime tag)
|
||||
{
|
||||
decimal std = 0;
|
||||
if (zeiten != null)
|
||||
{
|
||||
foreach (var az in zeiten)
|
||||
{
|
||||
if ((!az.GueltigVon.HasValue || az.GueltigVon <= tag) &&
|
||||
(!az.GueltigBis.HasValue || az.GueltigBis >= tag) && az.ArbeitszeitEintraege != null)
|
||||
{
|
||||
foreach (var e in az.ArbeitszeitEintraege)
|
||||
{
|
||||
if ((((int)e.Tag) + 1) == ((int)tag.DayOfWeek))
|
||||
{
|
||||
if (e.Notice != "Pause")
|
||||
std += GetZeitenFuerTag(e);
|
||||
else
|
||||
std -= GetZeitenFuerTag(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
std = Math.Round(std / 60, 2, MidpointRounding.AwayFromZero);
|
||||
return std;
|
||||
}
|
||||
|
||||
private static decimal GetZeitenFuerTag(ArbeitszeitEintrag e)
|
||||
{
|
||||
var day = DateTime.Now;
|
||||
decimal min = 0;
|
||||
|
||||
String dateStr1 = String.Format("{0:dd.MM.yyyy} {1}", day, e.UhrzeitVon);
|
||||
String dateStr2 = String.Format("{0:dd.MM.yyyy} {1}", day, e.UhrzeitBis);
|
||||
|
||||
DateTime date1;
|
||||
DateTime date2;
|
||||
|
||||
if (DateTime.TryParse(dateStr1, out date1) && DateTime.TryParse(dateStr2, out date2))
|
||||
min += (decimal)date2.Subtract(date1).TotalMinutes;
|
||||
|
||||
return min;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,7 +261,7 @@ namespace DomizielAnsbach.Service
|
||||
return count;
|
||||
}
|
||||
|
||||
private static decimal GetFeiertagsstunden(List<ArbeitszeitDC> zeiten, Customer c, DateTime tag)
|
||||
public static decimal GetFeiertagsstunden(List<ArbeitszeitDC> zeiten, Customer c, DateTime tag)
|
||||
{
|
||||
decimal std = 0;
|
||||
if (zeiten != null)
|
||||
|
||||
Reference in New Issue
Block a user