2016-06-27 01:45:38 +02:00
using System ;
using System.Collections.Generic ;
2022-10-11 16:48:36 +02:00
using System.Drawing ;
2016-06-27 01:45:38 +02:00
using System.Globalization ;
using System.Linq ;
using System.Text ;
2024-02-19 14:15:43 +01:00
using System.Web ;
2016-06-27 01:45:38 +02:00
using BeWo.Data ;
using BeWo.Data.Access ;
using BeWo.Data.Entities ;
2018-10-08 11:57:16 +02:00
using BeWo.Service.Configuration ;
2016-06-27 01:45:38 +02:00
using BeWo.Service.DCEntityMapper ;
using BeWo.Service.Plugins ;
using BS.Shared ;
using BS.Shared.Core ;
using BS.Shared.DataContracts ;
using BS.Shared.Services ;
using BS.Shared.Extensions ;
namespace BeWo.Report.ReportObjects
{
public class ServicesOverviewRO : AbstractBeWoReportObject < ServicesOverviewRO >
{
private List < ServiceDetail > _Services = new List < ServiceDetail > ( ) ;
private List < ServiceDoubleDetail > _ServicesDouble = new List < ServiceDoubleDetail > ( ) ;
2017-09-14 19:03:26 +02:00
public long CustomerOid { get ; set ; }
2016-06-27 01:45:38 +02:00
public string AbsenceTimes { get ; set ; }
public List < AbsenceTime > Abwesenheiten { get ; set ; }
2022-10-11 16:48:36 +02:00
public List < EmployeeDetail > AllEmployees { get ; set ; } = new List < EmployeeDetail > ( ) ;
2016-06-27 01:45:38 +02:00
public string ApprovedEndDate { get ; set ; }
public decimal ApprovedFLSPerMonth { get ; set ; }
public decimal ApprovedFLSPerMonthTotal { get ; set ; }
public decimal ApprovedFLSPerWeek { get ; set ; }
public decimal ApprovedFLSPerWeekTotal { get ; set ; }
public decimal ApprovedFLSTotal { get ; set ; }
public string ApprovedStartDate { get ; set ; }
public string ContactEmployee { get ; set ; }
public string Costbearer { get ; set ; }
public DateTime ? CustomerBirthday { get ; set ; }
public string CustomerCity { get ; set ; }
public string CustomerFirstName { get ; set ; }
public string CustomerLastName { get ; set ; }
public string CustomerName { get ; set ; }
public string CustomerPostalCode { get ; set ; }
public string CustomerStreet { get ; set ; }
public DateTime EndDate { get ; set ; }
public decimal? FreeMinutesThisMonth { get ; set ; }
public decimal MinutenGeleistetGesamt { get ; set ; }
public decimal MinutenSollGesamt { get ; set ; }
public string MainAttendant { get ; set ; }
public string MainAttendantCommaSeperated { get ; set ; }
public string Month { get ; set ; }
public string ReferenceNumber { get ; set ; }
public string RequestedEndDate { get ; set ; }
public string RequestedStartDate { get ; set ; }
public string Salutation { get ; set ; }
public decimal RateFactor { get ; set ; }
2018-10-08 11:57:16 +02:00
public decimal MinutenGeleistetBisVormonat { get ; set ; }
public decimal MinutenSollBisVormonat { get ; set ; }
2016-06-27 01:45:38 +02:00
public List < ServiceDetail > Services
{
get
{
return this . _Services ;
}
set
{
this . _Services = value ;
}
}
public List < ServiceDoubleDetail > ServicesDouble
{
get
{
return this . _ServicesDouble ;
}
set
{
this . _ServicesDouble = value ;
}
}
public DateTime StartDate { get ; set ; }
public SupportConceptCostBearerRelDC SupportConceptCostBearer { get ; set ; }
public string TotalFLHoursMinutesString { get ; set ; }
public double TotalFLM { get ; set ; }
public double TotalFLMBillable { get ; set ; }
2023-04-19 15:43:36 +02:00
public double TotalFLMoFehlkontakte { get ; set ; }
public double TotalFLMFehlkontakte { get ; set ; }
2016-06-27 01:45:38 +02:00
public string TotalFLMPerCostBearer { get ; set ; }
public double TotalFLMQualified { get ; set ; }
public string TotalFLMQualifiedString { get ; set ; }
public string TotalFLMString { get ; set ; }
public double TotalFLMUnqualified { get ; set ; }
public string TotalFLMUnqualifiedString { get ; set ; }
public double TotalFLS { get ; set ; }
2023-04-19 15:43:36 +02:00
public double TotalFLSoFehlkontakte { get ; set ; }
public double TotalFLSFehlkontakte { get ; set ; }
2016-06-27 01:45:38 +02:00
public string TotalFLSPerCostBearer { get ; set ; }
public double TotalFLSQualified { get ; set ; }
public string TotalFLSQualifiedString { get ; set ; }
public string TotalFLSString { get ; set ; }
public double TotalFLSUnqualified { get ; set ; }
public string TotalFLSUnqualifiedString { get ; set ; }
public double TotalGefahreneKilometer { get ; set ; }
public string TotalGefahreneKilometerString { get ; set ; }
2022-10-11 16:48:36 +02:00
public Bitmap EmployeeSignature { get ; set ; }
2021-02-17 16:59:26 +01:00
public DateTime ? EmployeeSignatureDate { get ; set ; }
2023-01-11 17:26:38 +01:00
public Bitmap CustomerSignature { get ; set ; }
2021-02-17 16:59:26 +01:00
public DateTime ? CustomerSignatureDate { get ; set ; }
2016-06-27 01:45:38 +02:00
public int Year { get ; set ; }
public IList < CostBearer2SupportConcept > CostBearer2SupportConceptList { get ; set ; }
2018-10-08 11:57:16 +02:00
public MandatorDC Mandator { get ; set ; }
public long? FilteredEmployeeOid { get ; set ; }
2016-06-27 01:45:38 +02:00
// private CostBearer2SupportConceptData CostBearer2SupportConceptData { get; set; }
2024-11-12 18:37:23 +01:00
public static List < ServicesOverviewRO > CreateAlt ( int pMonth , int pYear , long orgaOid , long empOid , int startDay , int endDay , long? serviceCategoryOid = null , bool disableEmptySupportConcepts = true )
2020-11-25 11:40:05 +01:00
{
2024-11-12 18:37:23 +01:00
return Create ( pMonth , pYear , orgaOid , empOid , startDay , endDay , false , serviceCategoryOid , disableEmptySupportConcepts ) ;
2020-11-25 11:40:05 +01:00
}
2024-11-12 18:37:23 +01:00
public static List < ServicesOverviewRO > Create ( int pMonth , int pYear , long orgaOid , long empOid , int startDay , int endDay , long? serviceCategoryOid = null , bool disableEmptySupportConcepts = true , bool checkQbStatus = false )
2017-06-28 09:00:09 +02:00
{
2024-11-12 18:37:23 +01:00
return Create ( pMonth , pYear , orgaOid , empOid , startDay , endDay , false , serviceCategoryOid , disableEmptySupportConcepts , false , checkQbStatus ) ;
2017-06-28 09:00:09 +02:00
}
2024-11-12 18:37:23 +01:00
2020-10-19 17:22:40 +02:00
public static List < ServicesOverviewRO > Create ( int pMonth , int pYear , long orgaOid , long empOid , int startDay , int endDay , bool searchServiceRecordsByEndDate , long? serviceCategoryOid = null , bool disableEmptySupportConcepts = true , bool checkTeamCustomerRights = false , bool checkQbStatus = false )
2016-06-27 01:45:38 +02:00
{
var roList = new List < ServicesOverviewRO > ( ) ;
List < Customer > customers = null ;
2024-11-12 18:37:23 +01:00
var loggedInUser = LoggedInUserOperationContextExt . Current ? . User ? ? SessionFacade . LoggedInUser ;
2016-06-27 01:45:38 +02:00
2024-11-12 18:37:23 +01:00
if ( loggedInUser ? . Employee ! = null )
2016-06-27 01:45:38 +02:00
{
2024-11-12 18:37:23 +01:00
if ( ! HasRight ( loggedInUser , UserRightType . CustomerView_View ) )
2016-06-27 01:45:38 +02:00
{
2018-03-02 16:24:55 +01:00
customers = new List < Customer > ( ) ;
2024-11-12 18:37:23 +01:00
if ( checkTeamCustomerRights & & HasRight ( loggedInUser , UserRightType . Customer_ViewMyTeams ) )
2018-03-02 16:24:55 +01:00
{
2024-11-12 18:37:23 +01:00
var teamCustomers = DAOFactory . SearchDAO . FindCustomersOfTeams ( loggedInUser . Employee . LeadingTeams . Select ( team = > team . Oid . Value ) ) ;
customers . AddRangeIfElementsNotIn ( teamCustomers ) ;
2018-03-02 16:24:55 +01:00
}
else
{
2024-11-12 18:37:23 +01:00
foreach ( var employee2Customer in loggedInUser . Employee . Employee2CustomerList )
2018-03-02 16:24:55 +01:00
{
2024-11-12 18:37:23 +01:00
customers . Add ( employee2Customer . Customer ) ;
2018-03-02 16:24:55 +01:00
}
}
2016-06-27 01:45:38 +02:00
}
}
2024-11-12 18:37:23 +01:00
if ( customers is null )
2016-06-27 01:45:38 +02:00
{
customers = DAOFactory . GenericDAO . GetAllActive < Customer > ( ) . OrderBy ( ob = > ob . Person . LastName + ", " + ob . Person . FirstName ) . ToList ( ) ;
}
2024-11-12 18:37:23 +01:00
if ( startDay > endDay )
2016-06-27 01:45:38 +02:00
{
2024-11-12 18:37:23 +01:00
( startDay , endDay ) = ( endDay , startDay ) ;
2016-06-27 01:45:38 +02:00
}
2024-11-12 18:37:23 +01:00
var pSpan = new DateTimeSpan
{
StartDateTime = new DateTime ( pYear , pMonth , startDay )
} ;
2016-06-27 01:45:38 +02:00
pSpan . EndDateTime = pSpan . StartDateTime . AddDays ( endDay - startDay + 1 ) . AddTicks ( - 1 ) ;
2024-11-12 18:37:23 +01:00
foreach ( var customer in customers )
2016-06-27 01:45:38 +02:00
{
2024-11-12 18:37:23 +01:00
var servicesOverviewRO = Create ( customer , pSpan , disableEmptySupportConcepts , orgaOid , empOid , searchServiceRecordsByEndDate , serviceCategoryOid , checkQbStatus ) ;
if ( servicesOverviewRO ! = null )
2016-06-27 01:45:38 +02:00
{
2024-11-12 18:37:23 +01:00
roList . Add ( servicesOverviewRO ) ;
2016-06-27 01:45:38 +02:00
}
}
2024-02-19 14:15:43 +01:00
2024-11-12 18:37:23 +01:00
var sortOrder = QBSortOrderEnum . NachKlient ;
2024-02-19 14:15:43 +01:00
2024-11-12 18:37:23 +01:00
if ( HttpContext . Current ! = null )
2024-02-19 14:15:43 +01:00
{
var so = HttpContext . Current . Request . Params [ "sortorder" ] ;
2024-11-12 18:37:23 +01:00
if ( ! string . IsNullOrWhiteSpace ( so ) )
2024-02-19 14:15:43 +01:00
{
2024-11-12 18:37:23 +01:00
sortOrder = ( QBSortOrderEnum ) int . Parse ( so ) ;
2024-02-19 14:15:43 +01:00
}
}
2024-11-12 18:37:23 +01:00
return sortOrder = = QBSortOrderEnum . NachHauptbetreuung ? roList . OrderBy ( r = > r . MainAttendant ) . ToList ( ) : roList ;
2016-06-27 01:45:38 +02:00
}
2017-06-28 09:00:09 +02:00
private static bool HasRight ( ApplicationUser user , UserRightType right )
2016-06-27 01:45:38 +02:00
{
return GetGrantedRights ( user ) . Contains ( right ) ;
}
public static List < UserRightType > GetGrantedRights ( ApplicationUser user )
{
var rights = new List < UserRightType > ( ) ;
foreach ( var ug in user . UserGroups )
{
foreach ( var rr in ug . Rights )
{
rights . Add ( rr . RightType ) ;
}
}
return rights ;
}
2020-11-25 11:40:05 +01:00
public static ServicesOverviewRO CreateAlt ( long pCustomerOid , int pMonth , int pYear , bool disableEmptySupportConcepts , long orgaOid , long empOid , int start , int end , long? serviceCategoryOid = null )
{
return Create ( pCustomerOid , pMonth , pYear , disableEmptySupportConcepts , orgaOid , empOid , start , end , false ,
serviceCategoryOid ) ;
}
2020-10-19 17:22:40 +02:00
public static ServicesOverviewRO Create ( long pCustomerOid , int pMonth , int pYear , bool disableEmptySupportConcepts , long orgaOid , long empOid , int start , int end , long? serviceCategoryOid = null , bool checkQbStatus = false )
2017-06-28 09:00:09 +02:00
{
2020-10-19 17:22:40 +02:00
return Create ( pCustomerOid , pMonth , pYear , disableEmptySupportConcepts , orgaOid , empOid , start , end , false , serviceCategoryOid , checkQbStatus ) ;
2017-06-28 09:00:09 +02:00
}
2020-11-10 02:25:15 +01:00
2020-10-19 17:22:40 +02:00
public static ServicesOverviewRO Create ( long pCustomerOid , int pMonth , int pYear , bool disableEmptySupportConcepts , long orgaOid , long empOid , int start , int end , bool searchServiceRecordsByEndDate , long? serviceCategoryOid = null , bool checkQbStatus = false )
2016-06-27 01:45:38 +02:00
{
var pSpan = new DateTimeSpan ( ) ;
if ( start > end )
{
int temp = start ;
start = end ;
end = temp ;
}
pSpan . StartDateTime = new DateTime ( pYear , pMonth , start ) ;
pSpan . EndDateTime = pSpan . StartDateTime . AddDays ( end - start + 1 ) . AddTicks ( - 1 ) ;
var lCustomer = DAOFactory . GenericDAO . LoadByID < Customer > ( pCustomerOid ) ;
2020-10-19 17:22:40 +02:00
return Create ( lCustomer , pSpan , disableEmptySupportConcepts , orgaOid , empOid , searchServiceRecordsByEndDate , serviceCategoryOid , checkQbStatus ) ;
2016-06-27 01:45:38 +02:00
}
2024-11-12 18:37:23 +01:00
public static List < ServicesOverviewRO > CreatePaginated ( int firstResult , int maxResults , long [ ] customerOids , int month , int year , bool disableEmptySupportConcepts , long organizationOid , long employeeOid , int start , int end , out int rowCount , long? serviceCategoryOid = null , bool checkQbStatus = false )
{
var reportObjects = new List < ServicesOverviewRO > ( ) ;
var dateTimeSpan = new DateTimeSpan ( ) ;
if ( start > end )
{
( start , end ) = ( end , start ) ;
}
dateTimeSpan . StartDateTime = new DateTime ( year , month , start ) ;
dateTimeSpan . EndDateTime = new DateTime ( year , month , end ) ;
var customers = DAOFactory . SearchDAO . FindCustomersForPaginatedQbByOids ( firstResult , maxResults , customerOids , dateTimeSpan . StartDate , dateTimeSpan . EndDate , out rowCount ) ;
foreach ( var customer in customers )
{
var servicesOverviewRO = Create ( customer , dateTimeSpan , disableEmptySupportConcepts , organizationOid , employeeOid , false , serviceCategoryOid , checkQbStatus ) ;
if ( servicesOverviewRO is null )
{
continue ;
}
reportObjects . Add ( servicesOverviewRO ) ;
}
return reportObjects ;
}
public static List < ServicesOverviewRO > CreatePaginated ( int firstResult , int maxCount , int month , int year , long organizationOid , long employeeOid , int startDay , int endDay , out int rowCount , long? serviceCategoryOid = null , bool disableEmptySupportConcepts = true , bool checkQbStatus = false )
{
var reportObjects = new List < ServicesOverviewRO > ( ) ;
if ( startDay > endDay )
{
( startDay , endDay ) = ( endDay , startDay ) ;
}
var dateTimeSpan = new DateTimeSpan
{
StartDateTime = new DateTime ( year , month , startDay )
} ;
dateTimeSpan . EndDateTime = dateTimeSpan . StartDateTime . AddDays ( endDay - startDay + 1 ) . AddTicks ( - 1 ) ;
var customers = DAOFactory . SearchDAO . FindCustomersForPaginatedQb ( firstResult , maxCount , false , dateTimeSpan . StartDate , dateTimeSpan . EndDate , out rowCount ) ;
foreach ( var customer in customers )
{
var servicesOverviewRO = Create ( customer , dateTimeSpan , disableEmptySupportConcepts , organizationOid , employeeOid , false , serviceCategoryOid , checkQbStatus ) ;
if ( servicesOverviewRO ! = null )
{
reportObjects . Add ( servicesOverviewRO ) ;
}
}
var sortOrder = QBSortOrderEnum . NachKlient ;
if ( HttpContext . Current ! = null )
{
var so = HttpContext . Current . Request . Params [ "sortorder" ] ;
if ( ! string . IsNullOrWhiteSpace ( so ) )
{
sortOrder = ( QBSortOrderEnum ) int . Parse ( so ) ;
}
}
return sortOrder = = QBSortOrderEnum . NachHauptbetreuung ? reportObjects . OrderBy ( r = > r . MainAttendant ) . ToList ( ) : reportObjects ;
}
2016-06-27 01:45:38 +02:00
public void CalculateFLSSollIst ( )
{
if ( this . SupportConceptCostBearer ! = null & & this . SupportConceptCostBearer . CostBearer2SupportConceptOid ! = null )
{
if ( this . SupportConceptCostBearer . StartDate ! = null )
{
CostBearer2SupportConcept c2s = DAOFactory . GenericDAO . LoadByID < CostBearer2SupportConcept > ( this . SupportConceptCostBearer . CostBearer2SupportConceptOid . Value ) ;
IList < ServiceRecord > allServiceRecords = c2s . ServiceRecords ;
decimal flmSoll = 0 ;
int daysPassed = 0 ;
TimeSpan ts = this . EndDate . Subtract ( this . SupportConceptCostBearer . StartDate . Value ) ;
daysPassed = ts . Days + 1 ;
var calc = PluginLoader . FindClass < Calculations > ( c2s . CostBearer . ID ) ? ? Calculations . GetInstance ( c2s . CostBearer . ID ) ;
decimal? flsnullable = calc . GetApprovedHoursPerWeekAverage ( this . SupportConceptCostBearer , false ) ;
//decimal? flsnullable = calc.GetApprovedHoursPerWeek(this.SupportConceptCostBearer, span.StartDateTime, false);
decimal fls = 0 ;
if ( flsnullable . HasValue )
fls = flsnullable . Value ;
// decimal fls = CostRateCalculationService.GetApprovedFLSPerWeek(this.CostBearer2SupportConceptData);
flmSoll = ( ( daysPassed / 7 m ) * fls ) * 60 ;
decimal minutenIst = 0 ;
DateTime end = this . EndDate . Date . AddDays ( 1 ) ;
Dictionary < long , bool > groupBookingDict = new Dictionary < long , bool > ( ) ;
foreach ( var item in allServiceRecords )
{
if ( ! item . GroupOid . HasValue | | ! groupBookingDict . ContainsKey ( item . GroupOid . Value ) )
{
if ( item . Start ! = null )
{
if ( item . Start > = this . SupportConceptCostBearer . StartDate . Value & & item . Start . Value < end )
{
if ( item . ServiceDescription ! = null & & item . ServiceDescription . ServiceCategory ! = null & & item . ServiceDescription . ServiceCategory . IsBillable )
{
2023-06-20 00:33:56 +02:00
decimal prozent = item . ServiceDescription . ServiceCategory . ProzentBudget ? ? 100 ;
if ( item . ServiceDescription . ProzentBudget . HasValue )
2022-12-15 23:16:04 +01:00
{
2023-06-20 00:33:56 +02:00
prozent = item . ServiceDescription . ProzentBudget . Value ;
2022-12-15 23:16:04 +01:00
}
2023-01-12 12:12:27 +01:00
minutenIst + = ( item . RoundedDuration * prozent ) / 100 ;
2016-06-27 01:45:38 +02:00
if ( item . GroupOid . HasValue )
groupBookingDict . Add ( item . GroupOid . Value , true ) ;
}
}
}
}
}
this . MinutenGeleistetGesamt = minutenIst ;
this . MinutenSollGesamt = flmSoll ;
this . FreeMinutesThisMonth = flmSoll - minutenIst ;
}
}
}
2018-10-08 11:57:16 +02:00
public void CalculateFLSSollIst2 ( )
{
if ( this . SupportConceptCostBearer ! = null & &
this . SupportConceptCostBearer . CostBearer2SupportConceptOid ! = null )
{
2019-02-12 19:13:34 +01:00
var c2s = DAOFactory . GenericDAO . LoadByID < CostBearer2SupportConcept > ( this . SupportConceptCostBearer . CostBearer2SupportConceptOid . Value ) ;
var calc = PluginLoader . FindClass < Calculations > ( c2s . CostBearer . ID ) ? ? Calculations . GetInstance ( c2s . CostBearer . ID ) ;
var costRatePeriods = MapperFactory . CostRatePeriodDC_CostRatePeriod . MapToNewDCs ( c2s . CostBearer . CostRatePeriods ) ;
2018-10-08 11:57:16 +02:00
2019-02-12 19:13:34 +01:00
decimal sollGesamt = 0 ;
DateTime start = c2s . StartDate ? ? this . StartDate ;
DateTime ende = this . StartDate . AddTicks ( - 1 ) ; // Ein Tag vor aktuellem Monat, da ja das Soll der Vergangenheit berechnet werden soll
// Erstelle Soll
while ( start < ende )
{
DateTime monatsEnde = new DateTime ( start . Year , start . Month , 1 ) . AddMonths ( 1 ) . AddDays ( - 1 ) ;
2018-10-08 11:57:16 +02:00
2019-02-12 19:13:34 +01:00
foreach ( var scap in c2s . ApprovalPeriodList )
{
if ( scap . StartDate . HasValue & & scap . StartDate < = monatsEnde & & scap . EndDate . HasValue & & scap . EndDate > = start )
{
var scapdc = MapperFactory . SupportConceptApprovalPeriodDC_SupportConceptApprovalPeriod . MapToNewDC ( scap ) ;
2018-10-08 11:57:16 +02:00
2019-02-12 19:13:34 +01:00
decimal soll = calc . GetApprovedHoursForPeriod ( scapdc , costRatePeriods , start , monatsEnde ) ? ? 0 ;
sollGesamt + = Math . Round ( soll , 2 , MidpointRounding . AwayFromZero ) ;
}
}
2018-10-08 11:57:16 +02:00
2019-02-12 19:13:34 +01:00
start = monatsEnde . AddDays ( 1 ) ;
}
2018-10-08 11:57:16 +02:00
2019-02-12 19:13:34 +01:00
start = c2s . StartDate ? ? this . StartDate ;
//Berechne Ist bis Ende des Vormonats
decimal minutenIst = 0 ;
2018-10-08 11:57:16 +02:00
2019-02-12 19:13:34 +01:00
IList < ServiceRecord > allServiceRecords = c2s . ServiceRecords ;
Dictionary < long , bool > groupBookingDict = new Dictionary < long , bool > ( ) ;
foreach ( var item in allServiceRecords )
{
if ( ! item . GroupOid . HasValue | | ! groupBookingDict . ContainsKey ( item . GroupOid . Value ) )
{
if ( item . Start ! = null )
2018-10-08 11:57:16 +02:00
{
2019-02-12 19:13:34 +01:00
if ( item . Start > = start & & item . Start . Value < = ende )
2018-10-08 11:57:16 +02:00
{
2019-02-12 19:13:34 +01:00
if ( item . ServiceDescription ! = null & &
item . ServiceDescription . ServiceCategory ! = null & &
item . ServiceDescription . ServiceCategory . IsBillable )
2018-10-08 11:57:16 +02:00
{
2023-06-20 00:33:56 +02:00
decimal prozent = item . ServiceDescription . ServiceCategory . ProzentBudget ? ? 100 ;
if ( item . ServiceDescription . ProzentBudget . HasValue )
2022-12-15 23:16:04 +01:00
{
2023-06-20 00:33:56 +02:00
prozent = item . ServiceDescription . ProzentBudget . Value ;
2022-12-15 23:16:04 +01:00
}
2023-01-12 12:12:27 +01:00
minutenIst + = ( item . RoundedDuration * prozent ) / 100 ;
2022-12-15 23:16:04 +01:00
2019-02-12 19:13:34 +01:00
if ( item . GroupOid . HasValue )
groupBookingDict . Add ( item . GroupOid . Value , true ) ;
2018-10-08 11:57:16 +02:00
}
}
}
}
}
2019-02-12 19:13:34 +01:00
this . MinutenGeleistetBisVormonat = minutenIst ;
this . MinutenSollBisVormonat = sollGesamt * 60 ;
2018-10-08 11:57:16 +02:00
}
}
2020-04-08 14:12:45 +02:00
public ApprovalDetail BerechneJugendamtSollIst ( )
{
ApprovalDetail ad = new ApprovalDetail ( ) ;
ad . TimeSpanStartDate = this . StartDate ;
ad . TimeSpanEndDate = this . EndDate ;
if ( this . SupportConceptCostBearer ! = null & & this . SupportConceptCostBearer . CostBearer2SupportConceptOid ! = null )
{
if ( this . SupportConceptCostBearer . StartDate ! = null )
{
CostBearer2SupportConcept c2s = DAOFactory . GenericDAO . LoadByID < CostBearer2SupportConcept > ( this . SupportConceptCostBearer . CostBearer2SupportConceptOid . Value ) ;
ad . TotalStartDate = c2s . StartDate ;
ad . TotalEndDate = c2s . EndDate ;
if ( ad . TotalStartDate . HasValue & & ad . TotalStartDate > this . StartDate )
{
this . StartDate = ad . TotalStartDate . Value ;
}
if ( ad . TotalEndDate . HasValue & & ad . TotalEndDate < this . EndDate )
{
this . EndDate = ad . TotalEndDate . Value ;
}
ad . TimeSpanStartDate = this . StartDate ;
ad . TimeSpanEndDate = this . EndDate ;
IList < ServiceRecord > allServiceRecords = c2s . ServiceRecords ;
TimeSpan ts = this . EndDate . Subtract ( ad . TotalStartDate . Value ) ;
int daysPassed = ts . Days + 1 ;
2020-08-17 15:50:00 +02:00
var endeVormonat = new DateTime ( this . StartDate . Year , this . StartDate . Month , 1 ) . AddDays ( - 1 ) ;
2020-04-08 14:12:45 +02:00
int daysVormonat = 0 ;
if ( endeVormonat > = ad . TotalStartDate . Value )
{
ts = endeVormonat . Subtract ( ad . TotalStartDate . Value ) ;
daysVormonat = ts . Days + 1 ;
}
var calc = PluginLoader . FindClass < Calculations > ( c2s . CostBearer . ID ) ? ? Calculations . GetInstance ( c2s . CostBearer . ID ) ;
ad . ApprovedHoursPerWeek = calc . GetApprovedHoursPerWeekAverage ( this . SupportConceptCostBearer , false ) ? ? 0 ;
ad . ApprovedHoursInTimeSpan = ad . DaysInTimeSpan * ( ad . ApprovedHoursPerWeek / 7 m ) ;
ad . ApprovedHoursTotal = ad . DaysTotal * ( ad . ApprovedHoursPerWeek / 7 m ) ;
var flmSoll = ( ( daysPassed / 7 m ) * ad . ApprovedHoursPerWeek ) * 60 ;
decimal minutenIstBisEndeBeleg = 0 ;
decimal minutenIstVormonat = 0 ;
DateTime end = this . EndDate . Date . AddDays ( 1 ) ;
Dictionary < long , bool > groupBookingDict = new Dictionary < long , bool > ( ) ;
foreach ( var item in allServiceRecords )
{
if ( ! item . GroupOid . HasValue | | ! groupBookingDict . ContainsKey ( item . GroupOid . Value ) )
{
if ( item . GroupOid . HasValue )
groupBookingDict . Add ( item . GroupOid . Value , true ) ;
if ( item . Start ! = null & & item . Start > = ad . TotalStartDate )
{
if ( item . ServiceDescription ! = null & & item . ServiceDescription . ServiceCategory ! = null & & item . ServiceDescription . ServiceCategory . IsBillable )
{
2023-06-20 00:33:56 +02:00
decimal prozent = item . ServiceDescription . ServiceCategory . ProzentBudget ? ? 100 ;
if ( item . ServiceDescription . ProzentBudget . HasValue )
2022-12-15 23:16:04 +01:00
{
2023-06-20 00:33:56 +02:00
prozent = item . ServiceDescription . ProzentBudget . Value ;
2022-12-15 23:16:04 +01:00
}
2020-04-08 14:12:45 +02:00
if ( item . Start . Value < end )
{
2022-12-15 23:16:04 +01:00
minutenIstBisEndeBeleg + = ( item . RoundedDuration * prozent ) / 100 ;
2020-04-08 14:12:45 +02:00
if ( item . Start . Value < endeVormonat . AddDays ( 1 ) )
{
2022-12-15 23:16:04 +01:00
minutenIstVormonat + = ( item . RoundedDuration * prozent ) / 100 ;
2020-04-08 14:12:45 +02:00
}
}
}
}
}
}
this . MinutenGeleistetGesamt = minutenIstBisEndeBeleg ;
this . MinutenSollGesamt = flmSoll ;
this . FreeMinutesThisMonth = flmSoll - minutenIstBisEndeBeleg ;
ad . UsedHoursPreviousMonths = minutenIstVormonat / 60 ;
}
}
return ad ;
}
2020-10-19 17:22:40 +02:00
private static ServicesOverviewRO Create ( Customer customer , DateTimeSpan span , bool disableEmptySupportConcepts , long orgaOid , long empOid , bool searchServiceRecordsByEndDate , long? serviceCategoryOid = null , bool checkQbStatus = true )
2016-06-27 01:45:38 +02:00
{
// IList<ServiceRecord> lServiceRecords = pServiceRecords;
// if (lServiceRecords == null)
2017-06-28 09:00:09 +02:00
IList < ServiceRecord > lServiceRecords = DAOFactory . SearchDAO . FindCustomerServiceRecords ( customer . Oid . Value , span , null , null , searchServiceRecordsByEndDate ) ;
2016-06-27 01:45:38 +02:00
2023-12-07 14:54:26 +01:00
var serviceRecordSignatures = DAOFactory . GenericDAO . LoadByIDs < Signature > ( lServiceRecords . Where ( sr = > sr . SignatureOid . HasValue ) . Select ( sr = > sr . SignatureOid . Value ) ) ;
2016-06-27 01:45:38 +02:00
var lResult = new ServicesOverviewRO ( ) ;
2020-10-19 17:22:40 +02:00
if ( checkQbStatus )
{
//gibt es für den customer schon einen QBStatus mit gleichen Werten für span, orga, emp, serviceCategory?
var alle = DAOFactory . SearchDAO . GetAllQuittierungsbelegStatusForMonth ( span . StartDate , span . EndDate ) ;
Customer richtigerKlient = null ;
long? orga , emp ;
if ( orgaOid = = 0 )
orga = null ;
else
orga = orgaOid ;
if ( empOid = = 0 )
emp = null ;
else
emp = empOid ;
foreach ( var qbs in alle )
{
if ( qbs . CustomerOid = = customer . Oid & & qbs . Startdatum = = span . StartDate & & qbs . Enddatum = = span . EndDate & & qbs . OrganisationOid = = orga & &
qbs . EmployeeOid = = emp & & qbs . ServiceCategoryOid = = serviceCategoryOid & & qbs . Erstellt )
{
richtigerKlient = customer ;
}
}
if ( richtigerKlient ! = null )
{
//Was tun, um nichts zu erstellen?
//Methode weiter ausführen, wenn ein QB für einen einzelnen Klienten erstellt werden soll
//Methode abbrechen, wenn für alle erstellt wird. (Warum geht Fenster so oft auf?)
return null ;
}
}
2018-10-08 11:57:16 +02:00
if ( empOid > 0 )
{
lResult . FilteredEmployeeOid = empOid ;
}
2017-09-14 19:03:26 +02:00
lResult . CustomerOid = customer . Oid . Value ;
2016-06-27 01:45:38 +02:00
lResult . Abwesenheiten = new List < AbsenceTime > ( ) ;
lResult . CostBearer2SupportConceptList = new List < CostBearer2SupportConcept > ( ) ;
lResult . Month = ReportHelper . GetMonthName ( span . StartDateTime . Month ) ;
lResult . Year = span . StartDateTime . Year ;
lResult . StartDate = span . StartDate ;
lResult . EndDate = span . EndDate ;
lResult . CustomerFirstName = customer . Person . FirstName ;
lResult . CustomerLastName = customer . Person . LastName ;
lResult . CustomerBirthday = customer . Person . DateOfBirth ;
lResult . CustomerName = customer . Person . FirstName + " " + customer . Person . LastName ;
if ( customer . Person . Address ! = null )
{
lResult . CustomerStreet = customer . Person . Address . Street ;
lResult . CustomerPostalCode = customer . Person . Address . PostalCode ;
lResult . CustomerCity = customer . Person . Address . Town ;
}
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 ( lResult . MainAttendantCommaSeperated ) )
{
lResult . MainAttendantCommaSeperated = empName2 ;
}
else if ( ! lResult . MainAttendantCommaSeperated . Contains ( empName2 ) )
{
2021-06-20 23:11:01 +02:00
if ( lResult . MainAttendantCommaSeperated . Length > 0 )
{
lResult . MainAttendantCommaSeperated + = ", " ;
}
2016-06-27 01:45:38 +02:00
lResult . MainAttendantCommaSeperated + = empName2 ;
}
if ( String . IsNullOrEmpty ( lResult . MainAttendant ) )
{
lResult . MainAttendant = empName ;
}
else
{
if ( ! lResult . MainAttendant . Contains ( empName ) )
{
lResult . MainAttendant + = ", " + empName ;
}
}
}
}
}
var flmBillablePerCostBearer = new Dictionary < string , double > ( ) ;
var flmNotBillableServiceDescAbbr = new Dictionary < string , double > ( ) ;
var flmPerEmployee = new Dictionary < Person , double > ( ) ;
Dictionary < Person , Employee > personPerEmployee = new Dictionary < Person , Employee > ( ) ;
double flmNotBillable = 0 ;
double flmBillable = 0 ;
double flmQualified = 0 ;
double flmUnqualified = 0 ;
var allServices = new List < ServiceDetail > ( ) ;
var cb2scOid2Count = new Dictionary < long , int > ( ) ;
var cb2scOid2FLSApprovedPerWeek = new Dictionary < long , decimal > ( ) ;
var cb2scOid2FLSApprovedTotal = new Dictionary < long , decimal > ( ) ;
var cb2scOid2RefNumber = new Dictionary < long , string > ( ) ;
// Dictionary<long, CostBearer2SupportConceptData> cb2scOid2Data = new Dictionary<long, CostBearer2SupportConceptData>();
var cb2scs = new Dictionary < long , SupportConceptCostBearerRelDC > ( ) ;
var groupBookingDict = new Dictionary < long , ServiceRecord > ( ) ;
foreach ( var iSr in lServiceRecords )
{
2018-05-21 16:39:24 +02:00
lResult . TotalGefahreneKilometer + = Convert . ToDouble ( iSr . DistanceInMeter ) ;
2016-06-27 01:45:38 +02:00
bool cont = ! ( empOid ! = 0 & & iSr . EmployeeOid ! = null & & iSr . EmployeeOid ! = empOid ) ;
CostBearer2SupportConcept cb2sc = null ;
if ( cont )
{
cb2sc = iSr . CostBearer2SupportConcept ;
}
if ( cb2sc = = null )
{
cont = false ;
}
else if ( cont & & orgaOid ! = 0 & & cb2sc . CostBearer . Organisation ! = null & & cb2sc . CostBearer . Organisation . Oid . Value ! = orgaOid )
{
cont = false ;
}
if ( cont )
{
if ( cb2sc . SupportConcept . IsActive = = ActivationTypeId . Deleted )
{
cont = false ;
}
}
if ( cont & & iSr . GroupOid ! = null & & groupBookingDict . ContainsKey ( iSr . GroupOid . Value ) )
{
cont = false ;
}
if ( cont & & serviceCategoryOid . HasValue & &
iSr . ServiceDescription . ServiceCategory . Oid ! = serviceCategoryOid )
cont = false ;
if ( cont )
{
lResult . ApprovedStartDate = cb2sc . ApprovedStartDate ! = null
? String . Format ( "{0:dd.MM.yyyy}" , cb2sc . ApprovedStartDate . Value )
: string . Empty ;
lResult . ApprovedEndDate = cb2sc . ApprovedEndDate ! = null
? String . Format ( "{0:dd.MM.yyyy}" , cb2sc . ApprovedEndDate . Value )
: string . Empty ;
lResult . RequestedStartDate = cb2sc . RequestedStartDate ! = null
? String . Format ( "{0:dd.MM.yyyy}" , cb2sc . RequestedStartDate . Value )
: string . Empty ;
lResult . RequestedEndDate = cb2sc . RequestedEndDate ! = null
? String . Format ( "{0:dd.MM.yyyy}" , cb2sc . RequestedEndDate . Value )
: string . Empty ;
int count = 0 ;
if ( cb2scOid2Count . ContainsKey ( cb2sc . Oid . Value ) )
{
count = cb2scOid2Count [ cb2sc . Oid . Value ] ;
cb2scOid2Count . Remove ( cb2sc . Oid . Value ) ;
}
else
{
lResult . CostBearer2SupportConceptList . Add ( cb2sc ) ;
}
count + + ;
cb2scOid2Count . Add ( cb2sc . Oid . Value , count ) ;
if ( ! cb2scOid2FLSApprovedPerWeek . ContainsKey ( cb2sc . Oid . Value ) )
{
var cb2scDC = cb2sc . MapToNewDC ( ) ;
if ( cb2sc . CostBearer ! = null )
{
if ( String . IsNullOrEmpty ( lResult . Costbearer ) )
lResult . Costbearer = cb2sc . CostBearer . Organisation . Name ;
DateTime ? start = cb2sc . ApprovedStartDate ;
if ( ! start . HasValue )
start = cb2sc . RequestedStartDate ;
DateTime ? end = cb2sc . ApprovedEndDate ;
if ( ! end . HasValue )
end = cb2sc . RequestedEndDate ;
if ( start . HasValue & & end . HasValue )
{
var relDC = cb2sc . MapToNewDC ( ) ;
var rateFactorsInSpanList = relDC . CostBearer . CostRatePeriods . GetSpans ( CostRatePeriodType . RateFactor ,
2018-10-08 11:57:16 +02:00
lResult . StartDate , lResult . EndDate ) . ToList ( ) ;
2016-06-27 01:45:38 +02:00
if ( rateFactorsInSpanList . Count > 0 )
{
var crv = rateFactorsInSpanList . Last ( ) . Key ;
if ( crv ! = null & & crv . CostRateValue . HasValue )
{
lResult . RateFactor = crv . CostRateValue . Value ;
lResult . RateFactor = ( lResult . RateFactor + 100 ) / 100 ;
}
}
}
}
var calc = PluginLoader . FindClass < Calculations > ( cb2sc . CostBearer . ID ) ? ? Calculations . GetInstance ( cb2sc . CostBearer . ID ) ;
DateTime sdt = span . StartDateTime ;
if ( sdt < cb2scDC . StartDate )
sdt = cb2scDC . StartDate . Value ;
decimal? fls = calc . GetApprovedHoursPerWeek ( cb2scDC , sdt , false ) ;
//decimal? fls = calc.GetApprovedHoursPerWeekAverage(cb2scDC, false);
decimal? flsTotal = calc . GetApprovedHoursTotal ( cb2scDC , false ) ;
if ( ! fls . HasValue )
fls = 0 ;
if ( ! flsTotal . HasValue )
flsTotal = 0 ;
// decimal fls = CostRateCalculationService.GetApprovedFLSPerWeek(data);
// decimal flsTotal = CostRateCalculationService.GetApprovedFLSTotal(data);
if ( cb2scDC . GetApprovedDuration ( ) . HasValue )
{
foreach ( var scap in cb2scDC . ApprovalPeriodList )
{
if ( sdt . InBetween ( scap . Span , true ) )
{
lResult . ApprovedFLSPerWeekTotal + =
calc . GetApprovedHoursPerWeek ( scap , cb2scDC . CostBearer . CostRatePeriods ) ? ? 0 ;
}
}
}
cb2scOid2FLSApprovedPerWeek . Add ( cb2sc . Oid . Value , fls . Value ) ;
cb2scOid2FLSApprovedTotal . Add ( cb2sc . Oid . Value , flsTotal . Value ) ;
// cb2scOid2Data.Add(cb2sc.Oid.Value, data);
cb2scs . Add ( cb2sc . Oid . Value , cb2scDC ) ;
}
if ( ! cb2scOid2RefNumber . ContainsKey ( cb2sc . Oid . Value ) & & ! String . IsNullOrEmpty ( cb2sc . CustomerReferenceNumber ) )
{
cb2scOid2RefNumber . Add ( cb2sc . Oid . Value , cb2sc . CustomerReferenceNumber ) ;
}
ServiceDetail sd = new ServiceDetail
{
CostBearer = iSr . CostBearer2SupportConcept ! = null & & iSr . CostBearer2SupportConcept . CostBearer . Organisation ! = null
? iSr . CostBearer2SupportConcept . CostBearer . Organisation . Name
: string . Empty ,
StartDate = iSr . Start . Value
} ;
sd . ServiceRecordOid = iSr . Oid . Value ;
2018-05-21 16:39:24 +02:00
sd . SignatureOid = iSr . SignatureOid ;
2023-12-07 14:54:26 +01:00
if ( iSr . SignatureOid . HasValue )
{
var signature = serviceRecordSignatures . FirstOrDefault ( s = > s . Oid . HasValue & & s . Oid . Value . Equals ( iSr . SignatureOid ) ) ;
if ( signature ! = null )
{
sd . SignatureImage = ImageUtils . ConvertBase64StringToBitmap ( signature . DataBild ) ;
}
}
sd . GefahreneKilometer = iSr . DistanceInMeter . HasValue ? ( Convert . ToDouble ( iSr . DistanceInMeter ) ) . ToString ( "0.##" ) : string . Empty ;
2016-06-27 01:45:38 +02:00
decimal roundedDur = iSr . RoundedDuration ;
2023-01-12 12:12:27 +01:00
decimal prozent = iSr . ServiceDescription . ServiceCategory . ProzentAbrechnung ;
2023-06-20 00:33:56 +02:00
if ( iSr . ServiceDescription . Name . ToLower ( ) . Contains ( "fehlkontakt" ) | | ( iSr . ServiceDescription . ProzentAbrechnung . HasValue & & iSr . ServiceDescription . ProzentAbrechnung . Value < 100 ) )
{
prozent = 100 ; // Keine
}
2023-01-26 00:31:27 +01:00
//if (iSr.ServiceDescription.ProzentAbrechnung.HasValue)
//{
// prozent = iSr.ServiceDescription.ProzentAbrechnung.Value;
2023-06-20 00:33:56 +02:00
2023-01-26 00:31:27 +01:00
//}
2022-12-15 23:16:04 +01:00
roundedDur * = ( prozent / 100 ) ;
2016-06-27 01:45:38 +02:00
if ( iSr . Employee . IsQualified = = null | | iSr . Employee . IsQualified . Value )
{
sd . MinutesQualified = Convert . ToDouble ( roundedDur ) ;
sd . Minutes = sd . MinutesQualified ;
}
else
{
sd . MinutesUnqualified = Convert . ToDouble ( roundedDur ) ;
sd . Minutes = sd . MinutesUnqualified ;
}
if ( iSr . GroupEmployeeCount ! = null )
{
sd . EmployeeCount = iSr . GroupEmployeeCount . Value ;
}
else
{
sd . EmployeeCount = 1 ;
}
if ( iSr . GroupPersonCount ! = null )
{
sd . CustomerCount = iSr . GroupPersonCount . Value ;
}
else
{
sd . CustomerCount = 1 ;
}
sd . GroupRoundedDuration = iSr . GroupRoundedDuration ;
if ( iSr . GroupRoundedDuration ! = null )
{
sd . GroupMinutes = ( double ) iSr . GroupRoundedDuration . Value ;
}
else
{
sd . GroupMinutes = sd . Minutes ;
}
if ( iSr . GroupOid ! = null )
{
sd . IsGroup = true ;
groupBookingDict . Add ( iSr . GroupOid . Value , iSr ) ;
2019-11-24 16:41:36 +01:00
if ( ( ! iSr . GroupEmployeeCount . HasValue | | iSr . GroupEmployeeCount . Value < 2 ) & &
( ! iSr . GroupPersonCount . HasValue | | iSr . GroupPersonCount . Value < 2 ) )
{
sd . IsGroup = false ;
}
2016-06-27 01:45:38 +02:00
}
sd . MinutesDateTime = DateTime . Now . Date . AddMinutes ( sd . Minutes ) ;
sd . EndDate = sd . StartDate . AddMinutes ( sd . GroupMinutes ) ;
sd . EndDateNotRounded = iSr . End . Value ;
if ( sd . StartDate . Second = = 0 )
{
sd . TimeRangeString = String . Format ( "{0} - {1}" , sd . StartDate . ToShortTimeString ( ) , sd . EndDate . ToShortTimeString ( ) ) ;
sd . StartDateMinutes = sd . StartDate ;
sd . EndDateMinutes = sd . EndDate ;
}
sd . StartDateString = iSr . Start . Value . ToShortDateString ( ) ;
sd . KW = GetKW ( sd . StartDate ) ;
flmQualified + = sd . MinutesQualified ;
flmUnqualified + = sd . MinutesUnqualified ;
sd . FLSQualified = sd . MinutesQualified / 60 ;
sd . FLSUnqualified = sd . MinutesUnqualified / 60 ;
sd . FLSQualifiedString = String . Format ( "{0:0.##}" , sd . FLSQualified ) ;
sd . FLSQualifiedString = sd . FLSQualifiedString . Replace ( "." , "," ) ;
sd . FLSUnqualifiedString = String . Format ( "{0:0.##}" , sd . FLSUnqualified ) ;
sd . FLSUnqualifiedString = sd . FLSUnqualifiedString . Replace ( "." , "," ) ;
2018-10-08 11:57:16 +02:00
sd . EmployeeOid = iSr . Employee . Oid . Value ;
2016-06-27 01:45:38 +02:00
string employeeAbbr = iSr . Employee . Person . Abbreviation ;
string employeeFullName = iSr . Employee . Person . FirstName + " " + iSr . Employee . Person . LastName ;
if ( employeeAbbr = = null | | employeeAbbr . Length = = 0 )
{
employeeAbbr = iSr . Employee . Person . FirstName . Substring ( 0 , 1 ) + ". " + iSr . Employee . Person . LastName ;
}
sd . EmployeeAbbr = employeeAbbr ;
sd . EmployeeFullname = employeeFullName ;
2018-05-21 16:39:24 +02:00
sd . EmployeeFirstName = iSr . Employee . Person . FirstName ;
sd . EmployeeLastName = iSr . Employee . Person . LastName ;
2016-06-27 01:45:38 +02:00
sd . EmployeeNameCommaSeparated = string . Format ( "{0}, {1}" , iSr . Employee . Person . LastName , iSr . Employee . Person . FirstName ) ;
sd . Notice = iSr . Notice ;
2017-02-01 13:53:59 +01:00
sd . Notice2 = iSr . Notice2 ;
sd . Notice3 = iSr . Notice3 ;
sd . Notice4 = iSr . Notice4 ;
sd . Notice5 = iSr . Notice5 ;
2016-06-27 01:45:38 +02:00
if ( iSr . ServiceDescription ! = null )
{
sd . ServiceDescription = iSr . ServiceDescription . Name ;
sd . ServiceCategory = iSr . ServiceDescription . ServiceCategory . Name ;
sd . ServiceCategoryAbbr = iSr . ServiceDescription . ServiceCategory . Abbreviation ;
if ( sd . ServiceCategoryAbbr = = null | | sd . ServiceCategoryAbbr . Length = = 0 )
{
sd . ServiceCategoryAbbr = iSr . ServiceDescription . ServiceCategory . Name ;
}
}
double flm = 0 ;
2023-04-19 15:43:36 +02:00
decimal flmOFehlkontakte = 0 ;
decimal flmFehlkontakte = 0 ;
2023-12-07 10:12:07 +01:00
sd . ProzentAbrechenbar = iSr . ServiceDescription . ServiceCategory . ProzentAbrechnung ;
if ( iSr . ServiceDescription . ProzentAbrechnung . HasValue )
{
sd . ProzentAbrechenbar = iSr . ServiceDescription . ProzentAbrechnung . Value ;
}
2016-06-27 01:45:38 +02:00
if ( iSr . ServiceDescription . ServiceCategory . IsBillable )
{
2023-04-19 15:43:36 +02:00
if ( iSr . ServiceDescription . Name . ToLower ( ) . Contains ( "fehlkontakt" ) | | ( iSr . ServiceDescription . ProzentAbrechnung . HasValue & & iSr . ServiceDescription . ProzentAbrechnung . Value < 100 ) )
{
flmFehlkontakte + = iSr . RoundedDuration ;
}
else
{
flmOFehlkontakte + = iSr . RoundedDuration ;
}
2016-06-27 01:45:38 +02:00
if ( flmBillablePerCostBearer . ContainsKey ( sd . CostBearer ) )
{
flm = flmBillablePerCostBearer [ sd . CostBearer ] ;
}
flm + = sd . MinutesQualified + sd . MinutesUnqualified ;
flmBillablePerCostBearer [ sd . CostBearer ] = flm ;
flmBillable + = sd . MinutesQualified + sd . MinutesUnqualified ;
sd . IsBillable = true ;
}
else
{
sd . CostBearer = string . Empty ;
if ( flmNotBillableServiceDescAbbr . ContainsKey ( sd . ServiceCategoryAbbr ) )
{
flm = flmNotBillableServiceDescAbbr [ sd . ServiceCategoryAbbr ] ;
}
flm + = sd . MinutesQualified + sd . MinutesUnqualified ;
flmNotBillableServiceDescAbbr [ sd . ServiceCategoryAbbr ] = flm ;
flmNotBillable + = sd . MinutesQualified + sd . MinutesUnqualified ;
sd . IsBillable = false ;
}
flm = 0 ;
if ( iSr . ServiceDescription . ServiceCategory . Name . IndexOf ( "Negativ" ) < 0 )
{
if ( flmPerEmployee . ContainsKey ( iSr . Employee . Person ) )
{
flm = flmPerEmployee [ iSr . Employee . Person ] ;
}
else
{
personPerEmployee [ iSr . Employee . Person ] = iSr . Employee ;
}
flm + = sd . MinutesQualified + sd . MinutesUnqualified ;
flmPerEmployee [ iSr . Employee . Person ] = flm ;
}
allServices . Add ( sd ) ;
2023-04-19 15:43:36 +02:00
lResult . TotalFLMFehlkontakte + = ( double ) flmFehlkontakte ;
lResult . TotalFLMoFehlkontakte + = ( double ) flmOFehlkontakte ;
2016-06-27 01:45:38 +02:00
}
}
if ( disableEmptySupportConcepts & & allServices . Count = = 0 )
{
return null ;
}
int max = 0 ;
long oidWithMaxCount = 0 ;
foreach ( var key in cb2scOid2Count . Keys )
{
int count = cb2scOid2Count [ key ] ;
if ( count > max )
{
oidWithMaxCount = key ;
max = count ;
}
}
if ( oidWithMaxCount ! = 0 )
{
if ( cb2scOid2FLSApprovedPerWeek . ContainsKey ( oidWithMaxCount ) )
{
lResult . ApprovedFLSPerWeek = cb2scOid2FLSApprovedPerWeek [ oidWithMaxCount ] ;
}
if ( cb2scOid2FLSApprovedTotal . ContainsKey ( oidWithMaxCount ) )
{
lResult . ApprovedFLSTotal = cb2scOid2FLSApprovedTotal [ oidWithMaxCount ] ;
}
if ( cb2scOid2RefNumber . ContainsKey ( oidWithMaxCount ) )
{
lResult . ReferenceNumber = cb2scOid2RefNumber [ oidWithMaxCount ] ;
}
}
if ( cb2scOid2Count . Count = = 0 )
{
foreach ( var sc in customer . SupportConcepts . Where ( s = > s . IsActive = = ActivationTypeId . Active ) )
{
foreach ( var c2s in sc . CostBearer2SupportConceptList )
{
if ( orgaOid = = 0 | |
( c2s . CostBearer . Organisation ! = null & & c2s . CostBearer . Organisation . Oid . Value = = orgaOid ) )
{
if ( c2s . StartDate < span . EndDate & & c2s . EndDate > = span . StartDate )
{
lResult . ApprovedStartDate = c2s . ApprovedStartDate ! = null
? String . Format ( "{0:dd.MM.yyyy}" , c2s . ApprovedStartDate . Value )
: string . Empty ;
lResult . ApprovedEndDate = c2s . ApprovedEndDate ! = null
? String . Format ( "{0:dd.MM.yyyy}" , c2s . ApprovedEndDate . Value )
: string . Empty ;
lResult . RequestedStartDate = c2s . RequestedStartDate ! = null
? String . Format ( "{0:dd.MM.yyyy}" , c2s . RequestedStartDate . Value )
: string . Empty ;
lResult . RequestedEndDate = c2s . RequestedEndDate ! = null
? String . Format ( "{0:dd.MM.yyyy}" , c2s . RequestedEndDate . Value )
: string . Empty ;
var cb2scDC = c2s . MapToNewDC ( ) ;
var calc = PluginLoader . FindClass < Calculations > ( c2s . CostBearer . ID ) ? ? Calculations . GetInstance ( c2s . CostBearer . ID ) ;
DateTime sdt = span . StartDateTime ;
if ( sdt < cb2scDC . StartDate )
sdt = cb2scDC . StartDate . Value ;
lResult . ApprovedFLSPerWeek = calc . GetApprovedHoursPerWeek ( cb2scDC , sdt , false ) ? ? 0 ;
lResult . ApprovedFLSTotal = calc . GetApprovedHoursTotal ( cb2scDC , false ) ? ? 0 ;
lResult . ReferenceNumber = c2s . CustomerReferenceNumber ;
}
}
}
}
}
int days = DateTime . DaysInMonth ( span . StartDateTime . Year , span . StartDateTime . Month ) ;
lResult . ApprovedFLSPerMonth = ( lResult . ApprovedFLSPerWeek / 7 ) * days ;
lResult . ApprovedFLSPerMonthTotal = ( lResult . ApprovedFLSPerWeekTotal / 7 ) * days ;
lResult . AbsenceTimes = string . Empty ;
if ( lResult . RateFactor < 1 )
lResult . RateFactor = 1 ;
if ( customer . AbsenceTimes ! = null )
{
StringBuilder sb = new StringBuilder ( ) ;
2023-02-28 17:16:54 +01:00
foreach ( AbsenceTime atDb in customer . AbsenceTimes . OrderBy ( a = > a . Start ) )
2016-06-27 01:45:38 +02:00
{
2022-10-10 12:57:34 +02:00
if ( atDb . AbsenceSpan ! = null )
2016-06-27 01:45:38 +02:00
{
2022-10-10 12:57:34 +02:00
//Erzeuge neue Abwesenheiten, da die original Entities nicht geändert werden dürfen, falls eine nachfolgende Methode ein übergeordnetes Objekt speichert, werden die Änderungen hier sonst mitgespeichert
AbsenceTime atTemp = new AbsenceTime ( ) ;
AbsenceReason reasonTemp = new AbsenceReason ( ) ;
reasonTemp . BillableMinutes = atDb . AbsenceReason . BillableMinutes ;
reasonTemp . Description = atDb . AbsenceReason . Description ;
atTemp . Start = atDb . Start ;
atTemp . End = atDb . End ;
atTemp . AbsenceReason = reasonTemp ;
2024-09-04 18:46:37 +02:00
bool addToList = (
! atTemp . AbsenceReason . Description . ToLower ( ) . Contains ( "urlaub" ) & &
atTemp . AbsenceReason . BillableMinutes . HasValue & & atTemp . AbsenceReason . BillableMinutes . Value > 0 ) ;
2022-10-10 12:57:34 +02:00
2024-09-04 18:46:37 +02:00
if ( atTemp . Start . HasValue )
2016-06-27 01:45:38 +02:00
{
2024-09-04 18:46:37 +02:00
atTemp . Start = atTemp . Start . Value . AddDays ( 1 ) ;
2016-06-27 01:45:38 +02:00
}
2024-09-04 18:46:37 +02:00
if ( atTemp . End . HasValue )
2019-10-10 22:07:42 +02:00
{
2024-09-04 18:46:37 +02:00
atTemp . End = atTemp . End . Value . AddDays ( - 1 ) ;
2019-10-10 22:07:42 +02:00
}
2020-02-06 18:56:40 +01:00
2024-09-04 18:46:37 +02:00
// Prüfe ob Datum der Abwesenheit innerhalb des ausgewählten Belegzeitraums liegt
if ( addToList & & ( ( atTemp . End . HasValue & & atTemp . End < span . StartDateTime ) | | ( atTemp . Start . HasValue & & atTemp . Start > span . EndDateTime ) ) )
2020-02-06 18:56:40 +01:00
{
2024-09-04 18:46:37 +02:00
addToList = false ;
2020-02-06 18:56:40 +01:00
}
2024-09-04 18:46:37 +02:00
if ( addToList )
2020-02-06 18:56:40 +01:00
{
2022-10-10 12:57:34 +02:00
if ( atTemp . Start . HasValue & & atTemp . End . HasValue )
2020-02-06 18:56:40 +01:00
{
2022-10-10 12:57:34 +02:00
var td = atTemp . End . Value . Subtract ( atTemp . Start . Value ) . TotalDays ;
2020-02-06 18:56:40 +01:00
if ( td < 0 )
{
2024-09-04 18:46:37 +02:00
addToList = false ;
2020-02-06 18:56:40 +01:00
}
}
}
2024-09-04 18:46:37 +02:00
if ( addToList )
2016-06-27 01:45:38 +02:00
{
2022-10-10 12:57:34 +02:00
lResult . Abwesenheiten . Add ( atTemp ) ;
2016-06-27 01:45:38 +02:00
if ( sb . Length > 0 )
{
sb . Append ( "; " ) ;
}
2022-10-10 12:57:34 +02:00
sb . Append ( atTemp . AbsenceReason . Description ) ;
2016-06-27 01:45:38 +02:00
sb . Append ( ": " ) ;
2022-10-10 12:57:34 +02:00
if ( atTemp . Start . HasValue )
2016-06-27 01:45:38 +02:00
{
2022-10-10 12:57:34 +02:00
sb . Append ( string . Format ( "{0:00}" , atTemp . Start . Value . Day ) ) ;
2016-06-27 01:45:38 +02:00
sb . Append ( "." ) ;
2022-10-10 12:57:34 +02:00
sb . Append ( string . Format ( "{0:00}" , atTemp . Start . Value . Month ) ) ;
2016-06-27 01:45:38 +02:00
sb . Append ( "." ) ;
2022-10-10 12:57:34 +02:00
sb . Append ( atTemp . Start . Value . Year . ToString ( ) . Substring ( 2 ) ) ;
2016-06-27 01:45:38 +02:00
sb . Append ( " - " ) ;
2022-10-10 12:57:34 +02:00
if ( atTemp . End . HasValue )
2016-06-27 01:45:38 +02:00
{
2022-10-10 12:57:34 +02:00
sb . Append ( string . Format ( "{0:00}" , atTemp . End . Value . Day ) ) ;
2016-06-27 01:45:38 +02:00
sb . Append ( "." ) ;
2022-10-10 12:57:34 +02:00
sb . Append ( string . Format ( "{0:00}" , atTemp . End . Value . Month ) ) ;
2016-06-27 01:45:38 +02:00
sb . Append ( "." ) ;
2022-10-10 12:57:34 +02:00
sb . Append ( atTemp . End . Value . Year . ToString ( ) . Substring ( 2 ) ) ;
2016-06-27 01:45:38 +02:00
}
else
{
sb . Append ( "..." ) ;
}
}
}
}
}
if ( sb . Length > 0 )
{
lResult . AbsenceTimes = sb . ToString ( ) ;
}
2020-10-19 17:22:40 +02:00
2016-06-27 01:45:38 +02:00
}
lResult . TotalFLSPerCostBearer = string . Empty ;
lResult . TotalFLMPerCostBearer = string . Empty ;
foreach ( string cb in flmBillablePerCostBearer . Keys )
{
if ( lResult . TotalFLSPerCostBearer . Length > 0 )
{
lResult . TotalFLSPerCostBearer + = ", " ;
}
lResult . TotalFLSPerCostBearer + = cb + ": " + String . Format ( "{0:0.##}" , flmBillablePerCostBearer [ cb ] / 60 ) . Replace ( "." , "," ) + " FLS" ;
if ( lResult . TotalFLMPerCostBearer . Length > 0 )
{
lResult . TotalFLMPerCostBearer + = ", " ;
}
lResult . TotalFLMPerCostBearer + = cb + ": " + String . Format ( "{0:0.##}" , flmBillablePerCostBearer [ cb ] ) . Replace ( "." , "," ) + " FLM" ;
}
foreach ( string abbr in flmNotBillableServiceDescAbbr . Keys )
{
if ( lResult . TotalFLSPerCostBearer . Length > 0 )
{
lResult . TotalFLSPerCostBearer + = ", " ;
}
lResult . TotalFLSPerCostBearer + = abbr + ": " + String . Format ( "{0:0.##}" , flmNotBillableServiceDescAbbr [ abbr ] / 60 ) . Replace ( "." , "," ) + " FLS" ;
if ( lResult . TotalFLMPerCostBearer . Length > 0 )
{
lResult . TotalFLMPerCostBearer + = ", " ;
}
lResult . TotalFLMPerCostBearer + = abbr + ": " + String . Format ( "{0:0.##}" , flmNotBillableServiceDescAbbr [ abbr ] ) . Replace ( "." , "," ) + " FLM" ;
}
lResult . TotalFLSPerCostBearer = "Gesamt: " + lResult . TotalFLSPerCostBearer ;
lResult . TotalFLMPerCostBearer = "Gesamt: " + lResult . TotalFLMPerCostBearer ;
foreach ( Person p in flmPerEmployee . Keys )
{
EmployeeDetail detail = new EmployeeDetail ( ) ;
detail . EmployeeName = p . FirstName . Substring ( 0 , 1 ) + ". " + p . LastName ;
detail . TotalFLM = flmPerEmployee [ p ] ;
detail . TotalFLS = detail . TotalFLM / 60 ;
detail . TotalFLSString = String . Format ( "{0:0.##}" , detail . TotalFLS ) . Replace ( "." , "," ) ;
if ( personPerEmployee . ContainsKey ( p ) )
{
detail . Employee = personPerEmployee [ p ] ;
}
2022-10-11 16:48:36 +02:00
lResult . AllEmployees . Add ( detail ) ;
2016-06-27 01:45:38 +02:00
}
allServices . Sort ( ( x , y ) = >
{
var c = x . StartDate . CompareTo ( y . StartDate ) ;
if ( c ! = 0 )
{
return c ;
}
return x . ServiceRecordOid . CompareTo ( y . ServiceRecordOid ) ;
} ) ;
int i = 0 ;
foreach ( var iSD in allServices )
{
lResult . _Services . Add ( iSD ) ;
ServiceDoubleDetail sdd = new ServiceDoubleDetail ( ) ;
sdd . CostBearer = iSD . CostBearer ;
sdd . EmployeeName = iSD . EmployeeAbbr ;
sdd . Minutes = iSD . MinutesQualified + iSD . MinutesUnqualified ;
sdd . CustomerCount = iSD . CustomerCount ;
sdd . FLS = sdd . Minutes / 60 ;
sdd . FLSString = String . Format ( "{0:0.##}" , sdd . FLS ) ;
sdd . FLSString = sdd . FLSString . Replace ( "." , "," ) ;
sdd . ServiceCategoryAbbr = iSD . ServiceCategoryAbbr ;
sdd . ServiceCategory = iSD . ServiceCategory ;
sdd . ServiceDescription = iSD . ServiceDescription ;
sdd . StartDate = iSD . StartDate ;
sdd . IsBillable = iSD . IsBillable ;
if ( i < ( allServices . Count / ( float ) 2 ) )
{
lResult . _ServicesDouble . Add ( sdd ) ;
}
else
{
sdd = lResult . _ServicesDouble [ i - lResult . _ServicesDouble . Count ] ;
sdd . CostBearer2 = iSD . CostBearer ;
sdd . EmployeeName2 = iSD . EmployeeAbbr ;
sdd . Minutes2 = iSD . MinutesQualified + iSD . MinutesUnqualified ;
sdd . CustomerCount2 = iSD . CustomerCount ;
sdd . FLS2 = sdd . Minutes2 / 60 ;
sdd . FLSString2 = String . Format ( "{0:0.##}" , sdd . FLS2 ) ;
sdd . FLSString2 = sdd . FLSString2 . Replace ( "." , "," ) ;
sdd . ServiceCategoryAbbr2 = iSD . ServiceCategoryAbbr ;
sdd . ServiceCategory2 = iSD . ServiceCategory ;
sdd . ServiceDescription2 = iSD . ServiceDescription ;
sdd . StartDate2 = iSD . StartDate ;
sdd . IsBillable2 = iSD . IsBillable ;
}
i + + ;
}
lResult . TotalFLMQualified = flmQualified ;
lResult . TotalFLMUnqualified = flmUnqualified ;
lResult . TotalFLSQualified = flmQualified / 60 ;
lResult . TotalFLSUnqualified = flmUnqualified / 60 ;
lResult . TotalFLM = flmQualified + flmUnqualified ;
lResult . TotalFLS = lResult . TotalFLM / 60 ;
2023-04-19 15:43:36 +02:00
lResult . TotalFLSFehlkontakte = lResult . TotalFLMFehlkontakte / 60 ;
lResult . TotalFLSoFehlkontakte = lResult . TotalFLMoFehlkontakte / 60 ;
2016-06-27 01:45:38 +02:00
lResult . TotalFLMBillable = flmBillable ;
DateTime dt = DateTime . Now . Date . AddMinutes ( lResult . TotalFLMBillable ) ;
TimeSpan tspan = dt . Subtract ( DateTime . Now . Date ) ;
double d = tspan . TotalHours ;
d = Math . Floor ( d ) ;
lResult . TotalFLHoursMinutesString = String . Format ( "{0}:{1:00}" , d , tspan . Minutes ) ;
lResult . TotalFLMQualifiedString = String . Format ( "{0:0.##}" , flmQualified ) . Replace ( "." , "," ) ;
lResult . TotalFLMUnqualifiedString = String . Format ( "{0:0.##}" , flmUnqualified ) . Replace ( "." , "," ) ;
lResult . TotalFLSQualifiedString = String . Format ( "{0:0.##}" , lResult . TotalFLSQualified ) . Replace ( "." , "," ) ;
lResult . TotalFLSUnqualifiedString = String . Format ( "{0:0.##}" , lResult . TotalFLSUnqualified ) . Replace ( "." , "," ) ;
lResult . TotalFLMString = String . Format ( "{0:0.##}" , lResult . TotalFLM ) . Replace ( "." , "," ) ;
lResult . TotalFLSString = String . Format ( "{0:0.##}" , lResult . TotalFLS ) . Replace ( "." , "," ) ;
2023-04-19 15:43:36 +02:00
lResult . TotalGefahreneKilometerString = String . Format ( "{0:0.##}" , lResult . TotalGefahreneKilometer ) ;
2016-06-27 01:45:38 +02:00
2018-10-08 11:57:16 +02:00
lResult . Mandator = MapperFactory . MandatorDC_Mandator . MapToNewDC ( AppSettings . GetMandatorEntity ( ) ) ;
2016-06-27 01:45:38 +02:00
// if (cb2scOid2Data.Count == 1)
// {
// lResult.CostBearer2SupportConceptData = cb2scOid2Data.Values.First();
// }
if ( cb2scs . Count = = 1 )
{
lResult . SupportConceptCostBearer = cb2scs . Values . First ( ) ;
}
2021-02-17 16:59:26 +01:00
var mandatorSettings = lResult . Mandator ? . Settings ;
2023-03-30 12:06:05 +02:00
var serviceRecordOids = lResult . Services . Select ( service = > service . ServiceRecordOid ) . ToList ( ) ;
var employeeSignature = DAOFactory . SearchDAO . GetConfirmationReceiptSignatureForServiceRecords ( serviceRecordOids , SignatureType . Employee ) ;
2022-10-11 16:48:36 +02:00
2023-03-30 12:06:05 +02:00
if ( ! ( employeeSignature ? . SignatureImage is null ) )
{
lResult . EmployeeSignature = ImageUtils . ConvertBase64StringToBitmap ( employeeSignature ? . SignatureImage ) ;
lResult . EmployeeSignatureDate = employeeSignature ? . InsTs ;
}
2021-02-17 16:59:26 +01:00
2023-03-30 12:06:05 +02:00
var customerSignature = DAOFactory . SearchDAO . GetConfirmationReceiptSignatureForServiceRecords ( serviceRecordOids , SignatureType . Customer ) ;
2021-02-17 16:59:26 +01:00
2023-03-30 12:06:05 +02:00
if ( ! ( customerSignature ? . SignatureImage is null ) )
{
lResult . CustomerSignature = ImageUtils . ConvertBase64StringToBitmap ( customerSignature . SignatureImage ) ;
lResult . CustomerSignatureDate = customerSignature . InsTs ;
2021-02-17 16:59:26 +01:00
}
2023-03-30 12:06:05 +02:00
2021-02-17 16:59:26 +01:00
2016-06-27 01:45:38 +02:00
return lResult ;
}
public static void CreateGoalList ( ServiceDetail sd )
{
var serviceRecord = DAOFactory . GenericDAO . LoadByID < ServiceRecord > ( sd . ServiceRecordOid ) ;
var srDc = MapperFactory . ServiceRecordDC_ServiceRecord . MapToNewDC ( serviceRecord ) ;
sd . GoalList = String . Empty ;
if ( srDc . Goals ! = null & & srDc . Goals . Count > 0 )
{
foreach ( var goal in srDc . Goals )
{
2024-04-10 15:29:37 +02:00
// Ohne diese Abfrage wird das selbe Ziel so oft eingefügt wie die Anzahl der Gruppenmitglieder ist
if ( sd . CustomerCount > 1 & & ! string . IsNullOrEmpty ( goal . TypeDescription ) & & sd . GoalList . Contains ( goal . TypeDescription ) )
continue ;
2016-06-27 01:45:38 +02:00
if ( sd . GoalList . Length > 0 )
2023-07-11 16:33:48 +02:00
{
sd . GoalList + = ", " ;
}
if ( ! string . IsNullOrEmpty ( goal . TypeDescription ) )
{
sd . GoalList + = goal . TypeDescription ;
}
else
{
sd . GoalList + = goal . Abbreviation ;
}
}
2016-06-27 01:45:38 +02:00
}
}
2018-05-21 16:39:24 +02:00
public static void CreateSignatureString ( ServiceDetail sd )
{
if ( sd . SignatureOid . HasValue & & String . IsNullOrEmpty ( sd . Signature ) )
{
var sig = DAOFactory . GenericDAO . GetByID < Signature > ( sd . SignatureOid . Value ) ;
if ( sig ! = null )
{
sd . Signature = sig . DataBild ;
2018-10-08 11:57:16 +02:00
if ( sig . Zeitstempel > DateTime . MinValue )
{
sd . SignatureDate = sig . Zeitstempel ;
}
2018-05-21 16:39:24 +02:00
}
}
}
2016-06-27 01:45:38 +02:00
private static int GetKW ( DateTime actualDate )
{
Calendar objCal = CultureInfo . CurrentCulture . Calendar ;
int weekofyear = objCal . GetWeekOfYear ( actualDate , CalendarWeekRule . FirstFourDayWeek , DayOfWeek . Monday ) ;
return weekofyear ;
}
2018-05-21 16:39:24 +02:00
public static ServicesOverviewRO CopyFromRO ( ServicesOverviewRO ro )
{
ServicesOverviewRO newRo = new ServicesOverviewRO ( ) ;
newRo . StartDate = ro . StartDate ;
2019-09-17 17:44:57 +02:00
newRo . Abwesenheiten = ro . Abwesenheiten ;
2018-05-21 16:39:24 +02:00
newRo . AbsenceTimes = ro . AbsenceTimes ;
newRo . ApprovedEndDate = ro . ApprovedEndDate ;
newRo . ApprovedFLSPerMonth = ro . ApprovedFLSPerMonth ;
newRo . ApprovedFLSPerMonthTotal = ro . ApprovedFLSPerMonthTotal ;
newRo . ApprovedFLSPerWeek = ro . ApprovedFLSPerWeek ;
newRo . ApprovedFLSPerWeekTotal = ro . ApprovedFLSPerWeekTotal ;
newRo . ApprovedFLSTotal = ro . ApprovedFLSTotal ;
newRo . ApprovedStartDate = ro . ApprovedStartDate ;
newRo . ContactEmployee = ro . ContactEmployee ;
newRo . CostBearer2SupportConceptList = ro . CostBearer2SupportConceptList ;
newRo . Costbearer = ro . Costbearer ;
newRo . CustomerBirthday = ro . CustomerBirthday ;
newRo . CustomerLastName = ro . CustomerLastName ;
newRo . CustomerCity = ro . CustomerCity ;
newRo . CustomerFirstName = ro . CustomerFirstName ;
newRo . CustomerName = ro . CustomerName ;
newRo . CustomerPostalCode = ro . CustomerPostalCode ;
newRo . CustomerStreet = ro . CustomerStreet ;
newRo . EndDate = ro . EndDate ;
newRo . FreeMinutesThisMonth = ro . FreeMinutesThisMonth ;
newRo . Month = ro . Month ;
newRo . Year = ro . Year ;
newRo . MainAttendant = ro . MainAttendant ;
newRo . MainAttendantCommaSeperated = ro . MainAttendantCommaSeperated ;
newRo . ReferenceNumber = ro . ReferenceNumber ;
2018-06-13 14:38:35 +02:00
newRo . TotalFLMBillable = ro . TotalFLMBillable ;
newRo . TotalFLM = ro . TotalFLM ;
2023-05-15 10:03:50 +02:00
newRo . TotalFLMFehlkontakte = ro . TotalFLMFehlkontakte ;
newRo . TotalFLMoFehlkontakte = ro . TotalFLMoFehlkontakte ;
2018-06-13 14:38:35 +02:00
newRo . TotalFLMQualified = ro . TotalFLMQualified ;
newRo . TotalFLMUnqualified = ro . TotalFLMUnqualified ;
2022-02-08 09:51:16 +01:00
newRo . TotalFLMQualifiedString = ro . TotalFLMQualifiedString ;
newRo . TotalFLMUnqualifiedString = ro . TotalFLMUnqualifiedString ;
2018-06-13 14:38:35 +02:00
newRo . TotalFLS = ro . TotalFLS ;
2023-05-15 10:03:50 +02:00
newRo . TotalFLSFehlkontakte = ro . TotalFLSFehlkontakte ;
newRo . TotalFLSoFehlkontakte = ro . TotalFLSoFehlkontakte ;
2018-06-13 14:38:35 +02:00
newRo . TotalFLSQualified = ro . TotalFLSQualified ;
newRo . TotalFLSUnqualified = ro . TotalFLSUnqualified ;
newRo . TotalFLSPerCostBearer = ro . TotalFLSPerCostBearer ;
2021-08-24 14:52:23 +02:00
newRo . TotalFLMPerCostBearer = ro . TotalFLMPerCostBearer ;
2018-06-13 14:38:35 +02:00
newRo . TotalGefahreneKilometer = ro . TotalGefahreneKilometer ;
2018-10-08 11:57:16 +02:00
newRo . SupportConceptCostBearer = ro . SupportConceptCostBearer ;
newRo . Mandator = ro . Mandator ;
2019-12-09 11:38:52 +01:00
newRo . CustomerOid = ro . CustomerOid ;
2020-04-08 14:12:45 +02:00
newRo . AllEmployees = ro . AllEmployees ;
2022-10-11 16:48:36 +02:00
newRo . EmployeeSignature = ro . EmployeeSignature ;
newRo . EmployeeSignatureDate = ro . EmployeeSignatureDate ;
2023-03-09 17:25:43 +01:00
newRo . CustomerSignature = ro . CustomerSignature ;
newRo . CustomerSignatureDate = ro . CustomerSignatureDate ;
2021-08-24 14:52:23 +02:00
2018-05-21 16:39:24 +02:00
return newRo ;
}
2016-06-27 01:45:38 +02:00
public class EmployeeDetail
{
public string EmployeeName { get ; set ; }
public double TotalFLM { get ; set ; }
public double TotalFLS { get ; set ; }
public string TotalFLSString { get ; set ; }
public Employee Employee { get ; set ; }
2020-11-09 17:55:01 +01:00
// Unterschriftenobjekt hinzufügen
// Nur, wenn die Unterschrift mit allen Einträgen im RO verknüpft ist?
// Was ist mit Einträgen von anderen Mitarbeitern im Quittierungsbeleg?
// Wer ist der verantwortliche Mitarbeiter?
2016-06-27 01:45:38 +02:00
}
public class ServiceDetail
{
public long ServiceRecordOid { get ; set ; }
public string CostBearer { get ; set ; }
public int CustomerCount { get ; set ; }
public string EmployeeAbbr { get ; set ; }
2018-10-08 11:57:16 +02:00
public long EmployeeOid { get ; set ; }
2016-06-27 01:45:38 +02:00
public int EmployeeCount { get ; set ; }
public string EmployeeFullname { get ; set ; }
public string EmployeeNameCommaSeparated { get ; set ; }
public DateTime EndDate { get ; set ; }
public DateTime ? EndDateMinutes { get ; set ; }
public double FLSQualified { get ; set ; }
public string FLSQualifiedString { get ; set ; }
public double FLSUnqualified { get ; set ; }
public string FLSUnqualifiedString { get ; set ; }
public double GroupMinutes { get ; set ; }
public decimal? GroupRoundedDuration { get ; set ; }
public bool IsBillable { get ; set ; }
public bool IsGroup { get ; set ; }
public int KW { get ; set ; }
public double Minutes { get ; set ; }
public DateTime MinutesDateTime { get ; set ; }
public double MinutesQualified { get ; set ; }
public double MinutesUnqualified { get ; set ; }
2023-12-07 10:12:07 +01:00
public decimal ProzentAbrechenbar { get ; set ; }
2016-06-27 01:45:38 +02:00
public string Notice { get ; set ; }
2017-02-01 13:53:59 +01:00
public string Notice2 { get ; set ; }
public string Notice3 { get ; set ; }
public string Notice4 { get ; set ; }
public string Notice5 { get ; set ; }
2016-06-27 01:45:38 +02:00
public string ServiceCategory { get ; set ; }
public string ServiceCategoryAbbr { get ; set ; }
public string ServiceDescription { get ; set ; }
public DateTime StartDate { get ; set ; }
public DateTime ? StartDateMinutes { get ; set ; }
public string StartDateString { get ; set ; }
public string TimeRangeString { get ; set ; }
public DateTime EndDateNotRounded { get ; set ; }
public string GefahreneKilometer { get ; set ; }
//Wird aus Performancegründen nicht automatisch gesetzt. Kann bei Bedarf in den Kundenreports erstellt werden
public string GoalList { get ; set ; }
2017-05-18 21:47:09 +02:00
public bool IstFeiertag { get ; set ; }
public bool IstFerien { get ; set ; }
public bool IstSamstag { get ; set ; }
public bool IstSonntag { get ; set ; }
2018-05-21 16:39:24 +02:00
public long? SignatureOid { get ; set ; }
public String Signature { get ; set ; }
2018-10-08 11:57:16 +02:00
public DateTime ? SignatureDate { get ; set ; }
2018-05-21 16:39:24 +02:00
public string EmployeeFirstName { get ; set ; }
public string EmployeeLastName { get ; set ; }
2023-12-07 14:54:26 +01:00
public Bitmap SignatureImage { get ; set ; }
2016-06-27 01:45:38 +02:00
}
public class ServiceDoubleDetail
{
public string CostBearer { get ; set ; }
public string CostBearer2 { get ; set ; }
public string EmployeeName { get ; set ; }
public string EmployeeName2 { get ; set ; }
public double FLS { get ; set ; }
public double FLS2 { get ; set ; }
public string FLSString { get ; set ; }
public string FLSString2 { get ; set ; }
public bool IsBillable { get ; set ; }
public bool IsBillable2 { get ; set ; }
public double Minutes { get ; set ; }
public double Minutes2 { get ; set ; }
public string ServiceCategory { get ; set ; }
public string ServiceCategory2 { get ; set ; }
public string ServiceCategoryAbbr { get ; set ; }
public string ServiceCategoryAbbr2 { get ; set ; }
public string ServiceDescription { get ; set ; }
public string ServiceDescription2 { get ; set ; }
public DateTime StartDate { get ; set ; }
public DateTime StartDate2 { get ; set ; }
public int CustomerCount { get ; set ; }
public int CustomerCount2 { get ; set ; }
}
2020-04-08 14:12:45 +02:00
public class ApprovalDetail
{
public DateTime TimeSpanStartDate { get ; set ; }
public DateTime TimeSpanEndDate { get ; set ; }
public DateTime ? TotalStartDate { get ; set ; }
public DateTime ? TotalEndDate { get ; set ; }
public int DaysInTimeSpan
{
get { return ( int ) TimeSpanEndDate . Subtract ( TimeSpanStartDate ) . TotalDays + 1 ; }
}
public int DaysTotal
{
get
{
if ( ! TotalStartDate . HasValue | | ! TotalEndDate . HasValue )
return 0 ;
return ( int ) TotalEndDate . Value . Subtract ( TotalStartDate . Value ) . TotalDays + 1 ;
}
}
public decimal ApprovedHoursPerWeek { get ; set ; }
public decimal ApprovedHoursInTimeSpan { get ; set ; }
public decimal ApprovedHoursTotal { get ; set ; }
public decimal UsedHoursInTimeSpan { get ; set ; }
public decimal UsedHoursPreviousMonths { get ; set ; }
public decimal RemainingHoursInTimeSpan
{
get { return ApprovedHoursInTimeSpan - UsedHoursInTimeSpan ; }
}
public decimal RemainingHoursTotal
{
get { return ApprovedHoursTotal - UsedHoursPreviousMonths ; }
}
}
}
2016-06-27 01:45:38 +02:00
}