diff --git a/Data/Data.csproj b/Data/Data.csproj index 5d3b39fad..68f25c758 100644 --- a/Data/Data.csproj +++ b/Data/Data.csproj @@ -234,6 +234,7 @@ + @@ -857,6 +858,9 @@ Designer + + Designer + Designer diff --git a/Data/Entities/OvertimeHistory.cs b/Data/Entities/OvertimeHistory.cs new file mode 100644 index 000000000..74bbcd69a --- /dev/null +++ b/Data/Entities/OvertimeHistory.cs @@ -0,0 +1,28 @@ +using System; + +using BS.Shared; +using BS.Shared.Core; + +namespace BeWo.Data.Entities +{ + public class OvertimeHistory : BeWoEntityBase + { + + public OvertimeHistory() + { + this._Tid = TableID.OvertimeHistory; + } + + public virtual StatementType ChangeType { get; set; } + + public virtual long OvertimeOid { get; set; } + + public virtual long? OvertimeEmployeeOid { get; set; } + + public virtual DateTime? OvertimeDatum { get; set; } + + public virtual decimal? OvertimeBetrag { get; set; } + + public virtual long? OvertimeAuszahlungsartOid { get; set; } + } +} \ No newline at end of file diff --git a/Data/Mappings/OvertimeHistory.hbm.xml b/Data/Mappings/OvertimeHistory.hbm.xml new file mode 100644 index 000000000..c1da38130 --- /dev/null +++ b/Data/Mappings/OvertimeHistory.hbm.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Model/Changes_2025-12-01 OvertimeHistory.txt b/Model/Changes_2025-12-01 OvertimeHistory.txt new file mode 100644 index 000000000..0793e0c0d --- /dev/null +++ b/Model/Changes_2025-12-01 OvertimeHistory.txt @@ -0,0 +1,20 @@ + +CREATE TABLE IF NOT EXISTS `OvertimeHistory` ( + `Oid` bigint NOT NULL AUTO_INCREMENT, + `Tid` int NOT NULL, + `Notice` varchar(1024) DEFAULT NULL, + `InsTs` datetime DEFAULT NULL, + `InsUser` varchar(256) DEFAULT NULL, + `Version` bigint DEFAULT NULL, + `UdpUser` varchar(256) DEFAULT NULL, + `UpdTs` datetime DEFAULT NULL, + `IsActive` tinyint DEFAULT NULL, + `SystemEntryID` int DEFAULT NULL, + `ChangeType` tinyint NULL DEFAULT NULL, + `OvertimeOid` bigint NULL DEFAULT NULL, + `OvertimeEmployeeOid` bigint DEFAULT NULL, + `OvertimeDatum` datetime DEFAULT NULL, + `OvertimeBetrag` decimal(18,10) DEFAULT NULL, + `OvertimeAuszahlungsartOid` bigint DEFAULT NULL, + PRIMARY KEY (`Oid`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; diff --git a/Model/Changes_alle_fuer_neue_db.txt b/Model/Changes_alle_fuer_neue_db.txt index f5babe40c..56c69f30f 100644 --- a/Model/Changes_alle_fuer_neue_db.txt +++ b/Model/Changes_alle_fuer_neue_db.txt @@ -1738,3 +1738,24 @@ ALTER TABLE `team` ADD CONSTRAINT `FK_TEAM_LEADER_EMPLOYEE` FOREIGN KEY (`EmployeeOid`) REFERENCES `employee` (`Oid`); + + +CREATE TABLE IF NOT EXISTS `OvertimeHistory` ( + `Oid` bigint NOT NULL AUTO_INCREMENT, + `Tid` int NOT NULL, + `Notice` varchar(1024) DEFAULT NULL, + `InsTs` datetime DEFAULT NULL, + `InsUser` varchar(256) DEFAULT NULL, + `Version` bigint DEFAULT NULL, + `UdpUser` varchar(256) DEFAULT NULL, + `UpdTs` datetime DEFAULT NULL, + `IsActive` tinyint DEFAULT NULL, + `SystemEntryID` int DEFAULT NULL, + `ChangeType` tinyint NULL DEFAULT NULL, + `OvertimeOid` bigint NULL DEFAULT NULL, + `OvertimeEmployeeOid` bigint DEFAULT NULL, + `OvertimeDatum` datetime DEFAULT NULL, + `OvertimeBetrag` decimal(18,10) DEFAULT NULL, + `OvertimeAuszahlungsartOid` bigint DEFAULT NULL, + PRIMARY KEY (`Oid`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; diff --git a/Service/ServiceUtils/History/HistoryCreator.cs b/Service/ServiceUtils/History/HistoryCreator.cs index 882c40feb..d4892d027 100644 --- a/Service/ServiceUtils/History/HistoryCreator.cs +++ b/Service/ServiceUtils/History/HistoryCreator.cs @@ -74,10 +74,11 @@ namespace BeWo.ServiceUtils.History } } CreateAbsenceTimeHistoryEntry(originalEmployee.AbsenceTimes, newEmployee.AbsenceTimes); - - - - DAOFactory.GenericDAO.Insert(employeeHistory); + CreateOvertimeHistoryEntry(originalEmployee.Overtimes, newEmployee.Overtimes); + + + + DAOFactory.GenericDAO.Insert(employeeHistory); } @@ -209,6 +210,61 @@ namespace BeWo.ServiceUtils.History } + public static void CreateOvertimeHistoryEntry(IList originalOvertimes, IList newOvertimes) + { + if (newOvertimes != null) + { + foreach (var na in newOvertimes) + { + if (!na.OvertimeOid.HasValue) + { + CreateOvertimeHistoryEntry(na, StatementType.Insert); + } + else + { + var oldAt = originalOvertimes.Where(a => a.Oid == na.OvertimeOid).FirstOrDefault(); + + if (oldAt != null) + { + CreateOvertimeHistoryEntry(na, StatementType.Update); + } + else + { + //Wurde gelöscht? + } + } + } + } + foreach (var oat in originalOvertimes) + { + //wenn es eine Abwesenheit gibt, der nicht mehr in der neuen Liste enthalten ist, wurde er gelöscht + + var na = newOvertimes.Where(a => a.OvertimeOid == oat.Oid).FirstOrDefault(); + + if (na == null) + { + CreateOvertimeHistoryEntry(MapperFactory.OvertimeDC_Overtime.MapToNewDC(oat), StatementType.Delete); + } + } + } + + public static void CreateOvertimeHistoryEntry(OvertimeDC newOvertime, StatementType statementType) + { + + var historyEntry = new OvertimeHistory() + { + OvertimeOid = newOvertime.OvertimeOid ?? 0, + OvertimeAuszahlungsartOid = newOvertime.Auszahlungsart?.AuszahlungsartOid, + OvertimeDatum = newOvertime.Date, + OvertimeBetrag = newOvertime.Betrag, + OvertimeEmployeeOid = newOvertime.EmployeeOid, + Notice = newOvertime.Notice, + ChangeType = statementType + }; + DAOFactory.GenericDAO.Insert(historyEntry); + + } + public static void MakeCustomerHistoryEntry(Customer lOriginal, CustomerDC newCustomer, long? Oid, StatementType statementType, List originalCustomer2PersonList, List originalC2OList, List originale2CList, List originaleAbsenceTimeList) { var lCustomerHistory = new CustomerHistory @@ -754,6 +810,13 @@ namespace BeWo.ServiceUtils.History atDc.CustomerOid = customerOid; CreateAbsenceTimeHistoryEntry(atDc, sType); } + else if (entityObj is Overtime) + { + var ent = entityObj as Overtime; + var dc = MapperFactory.OvertimeDC_Overtime.MapToNewDC(ent); + + CreateOvertimeHistoryEntry(dc, sType); + } } } } diff --git a/Shared/BeWoEntityEnums.cs b/Shared/BeWoEntityEnums.cs index 6d6c3cfbc..5f3742fe1 100644 --- a/Shared/BeWoEntityEnums.cs +++ b/Shared/BeWoEntityEnums.cs @@ -191,8 +191,9 @@ namespace BS.Shared AiContext2BeWoObject = 181, AiConfig = 182, StoredFile = 183, - Person2Team = 184 - } + Person2Team = 184, + OvertimeHistory = 185 + } public enum SystemEntryID {