瀏覽代碼

HR invoices and next salary date

zinab_elgendy 2 月之前
父節點
當前提交
4dbd51027d
共有 25 個文件被更改,包括 14168 次插入16 次删除
  1. 1 1
      MTWorkHR.API/Controllers/HRController.cs
  2. 113 0
      MTWorkHR.API/Properties/ServiceDependencies/mtwork - FTP1/profile.arm.json
  3. 2 0
      MTWorkHR.Application/Dtos/Attendance/OrderRequestDto.cs
  4. 76 0
      MTWorkHR.Application/Dtos/Contract/ContractHRDto.cs
  5. 23 0
      MTWorkHR.Application/Dtos/Payment/InvoiceDto.cs
  6. 3 1
      MTWorkHR.Application/Mapper/MappingProfile.cs
  7. 31 6
      MTWorkHR.Application/Services/Contract/ContractService.cs
  8. 1 1
      MTWorkHR.Application/Services/Interfaces/IContractService.cs
  9. 3 3
      MTWorkHR.Application/Services/User/OrderRequestService.cs
  10. 2 1
      MTWorkHR.Core/Entities/Attendance/OrderRequest.cs
  11. 24 0
      MTWorkHR.Core/Entities/Payment/Invoice.cs
  12. 0 0
      MTWorkHR.Core/Entities/Payment/SubscriptionConfiguration.cs
  13. 15 0
      MTWorkHR.Core/IRepositories/Payment/IInvoiceRepository.cs
  14. 1 1
      MTWorkHR.Core/IRepositories/User/IOrderRequestRepository.cs
  15. 1 0
      MTWorkHR.Core/IUnitOfWork/IUnitOfWork.cs
  16. 1 0
      MTWorkHR.Infrastructure/DBContext/HRDataContext.cs
  17. 1 0
      MTWorkHR.Infrastructure/InfrastructureServiceRegistration.cs
  18. 6850 0
      MTWorkHR.Infrastructure/Migrations/20250204112713_addInvoice.Designer.cs
  19. 46 0
      MTWorkHR.Infrastructure/Migrations/20250204112713_addInvoice.cs
  20. 6853 0
      MTWorkHR.Infrastructure/Migrations/20250204145927_altrOrderRequest2.Designer.cs
  21. 28 0
      MTWorkHR.Infrastructure/Migrations/20250204145927_altrOrderRequest2.cs
  22. 62 0
      MTWorkHR.Infrastructure/Migrations/HRDataContextModelSnapshot.cs
  23. 26 0
      MTWorkHR.Infrastructure/Repositories/Payment/InvoiceRepository.cs
  24. 2 2
      MTWorkHR.Infrastructure/Repositories/User/OrderRequestRepository.cs
  25. 3 0
      MTWorkHR.Infrastructure/UnitOfWork/UnitOfWork.cs

+ 1 - 1
MTWorkHR.API/Controllers/HRController.cs

@@ -30,7 +30,7 @@ namespace MTWorkHR.API.Controllers
 
 
         [HttpGet("GetByIdHRDetails")]
         [HttpGet("GetByIdHRDetails")]
         [ProducesResponseType(StatusCodes.Status200OK)]
         [ProducesResponseType(StatusCodes.Status200OK)]
-        public async Task<ActionResult<ContractDto>> GetByIdHRDetails([FromQuery] long contractId)
+        public async Task<ActionResult<ContractHRDto>> GetByIdHRDetails([FromQuery] long contractId)
         {
         {
             return Ok(await _ContractService.GetByIdHRDetails(contractId));
             return Ok(await _ContractService.GetByIdHRDetails(contractId));
         }
         }

+ 113 - 0
MTWorkHR.API/Properties/ServiceDependencies/mtwork - FTP1/profile.arm.json

@@ -0,0 +1,113 @@
+{
+  "$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
+  "contentVersion": "1.0.0.0",
+  "metadata": {
+    "_dependencyType": "compute.appService.windows"
+  },
+  "parameters": {
+    "resourceGroupName": {
+      "type": "string",
+      "defaultValue": "WepResourceGrp",
+      "metadata": {
+        "description": "Name of the resource group for the resource. It is recommended to put resources under same resource group for better tracking."
+      }
+    },
+    "resourceGroupLocation": {
+      "type": "string",
+      "defaultValue": "",
+      "metadata": {
+        "description": "Location of the resource group. Resource groups could have different location than resources, however by default we use API versions from latest hybrid profile which support all locations for resource types we support."
+      }
+    },
+    "resourceName": {
+      "type": "string",
+      "defaultValue": "mtwork",
+      "metadata": {
+        "description": "Name of the main resource to be created by this template."
+      }
+    },
+    "resourceLocation": {
+      "type": "string",
+      "defaultValue": "[parameters('resourceGroupLocation')]",
+      "metadata": {
+        "description": "Location of the resource. By default use resource group's location, unless the resource provider is not supported there."
+      }
+    }
+  },
+  "variables": {
+    "appServicePlan_name": "[concat('Plan', uniqueString(concat(parameters('resourceName'), subscription().subscriptionId)))]",
+    "appServicePlan_ResourceId": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', parameters('resourceGroupName'), '/providers/Microsoft.Web/serverFarms/', variables('appServicePlan_name'))]"
+  },
+  "resources": [
+    {
+      "type": "Microsoft.Resources/resourceGroups",
+      "name": "[parameters('resourceGroupName')]",
+      "location": "[parameters('resourceGroupLocation')]",
+      "apiVersion": "2019-10-01"
+    },
+    {
+      "type": "Microsoft.Resources/deployments",
+      "name": "[concat(parameters('resourceGroupName'), 'Deployment', uniqueString(concat(parameters('resourceName'), subscription().subscriptionId)))]",
+      "resourceGroup": "[parameters('resourceGroupName')]",
+      "apiVersion": "2019-10-01",
+      "dependsOn": [
+        "[parameters('resourceGroupName')]"
+      ],
+      "properties": {
+        "mode": "Incremental",
+        "template": {
+          "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
+          "contentVersion": "1.0.0.0",
+          "resources": [
+            {
+              "location": "[parameters('resourceLocation')]",
+              "name": "[parameters('resourceName')]",
+              "type": "Microsoft.Web/sites",
+              "apiVersion": "2015-08-01",
+              "tags": {
+                "[concat('hidden-related:', variables('appServicePlan_ResourceId'))]": "empty"
+              },
+              "dependsOn": [
+                "[variables('appServicePlan_ResourceId')]"
+              ],
+              "kind": "app",
+              "properties": {
+                "name": "[parameters('resourceName')]",
+                "kind": "app",
+                "httpsOnly": true,
+                "reserved": false,
+                "serverFarmId": "[variables('appServicePlan_ResourceId')]",
+                "siteConfig": {
+                  "metadata": [
+                    {
+                      "name": "CURRENT_STACK",
+                      "value": "dotnetcore"
+                    }
+                  ]
+                }
+              },
+              "identity": {
+                "type": "SystemAssigned"
+              }
+            },
+            {
+              "location": "[parameters('resourceLocation')]",
+              "name": "[variables('appServicePlan_name')]",
+              "type": "Microsoft.Web/serverFarms",
+              "apiVersion": "2015-08-01",
+              "sku": {
+                "name": "S1",
+                "tier": "Standard",
+                "family": "S",
+                "size": "S1"
+              },
+              "properties": {
+                "name": "[variables('appServicePlan_name')]"
+              }
+            }
+          ]
+        }
+      }
+    }
+  ]
+}

+ 2 - 0
MTWorkHR.Application/Dtos/Attendance/OrderRequestDto.cs

@@ -27,5 +27,7 @@ namespace MTWorkHR.Application.Models
         public UserDto? Employee { get; set; }
         public UserDto? Employee { get; set; }
         public string? StartTime { get; set; }
         public string? StartTime { get; set; }
         public string? EndTime { get; set; }
         public string? EndTime { get; set; }
+        public long ContractId { get; set; }
+
     }
     }
 }
 }

+ 76 - 0
MTWorkHR.Application/Dtos/Contract/ContractHRDto.cs

@@ -0,0 +1,76 @@
+using MTWorkHR.Application.Models;
+using MTWorkHR.Core.Entities;
+using MTWorkHR.Core.Entities.Base;
+using MTWorkHR.Core.Global;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MTWorkHR.Application.Models
+{
+    public class ContractHRDto : EntityDto
+    {
+        public ContractTypeEnum ContractTypeId { get; set; }
+        public ContractStatusEnum ContractStatusId { get; set; } 
+
+        public long CompanyId { get; set; }
+        
+        public string UserId { get; set; }
+        public string? EmployeeName { get; set; }
+        public string? EmployeeEmail { get; set; }
+      
+        public int? JobId { get; set; }
+        public int? AcademicQualificationId { get; set; }
+        public int? SpecializationId { get; set; }
+        public int WorkCountryId { get; set; }
+        public int WorkStateId { get; set; }
+        //-------------------Scope of work-----------
+        public string? JobTitleName { get; set; }
+        public string? JobDescription{ get; set; }
+        [MaxLength(150)]
+        public string? JobNumber { get; set; } //ثابت و مأخوذ من المنصة
+        //----------------Contract data -------------------------
+        public DateTime? StartDate { get; set; }
+        public DateTime? EndDate { get; set; }
+
+        public ContractDurationEnum? ContractDurationId { get; set; } //:  اختيار: شهري – ربعي – نصف سنوي – 3 ارباع – سنوي
+        public TypeOfWork? TypeOfWork { get; set; } //: :   اختيار: عقد بدوام كامل -  عقد دوام جزئي   
+
+        //------Working time---------------
+        public List<string>? WorkingDays { get; set; } //:   اختيار متعدد الأيام سبت أحد اثنين..... (بحيث الأيام الأخرى تكون إجازة) 1,2,3,4,5
+        public WorkingHours WorkingHours { get; set; } //	يومي/ اسبوعي  
+        public int? WorkingHoursNum { get; set; } // عدد الساعات
+        public DateTime? StartDailyWorkingHours { get; set; } // تحديد ساعات الدوام قائمة الساعات << التوقيت بحسب دولة صاحب العمل
+        public DateTime? EndDailyWorkingHours { get; set; } // تحديد ساعات الدوام قائمة الساعات << التوقيت بحسب دولة صاحب العمل
+
+        //----------Salary-----------------
+        [MaxLength(50)]
+        public string? Currency { get; set; }
+        public decimal? Salary{ get; set; }
+        public string? BillingCycle { get; set; }// 2 fortnightly, 4 Monthly
+        public DateTime? NextSalaryDate { get; set; }// 2 fortnightly, 4 Monthly
+        //------------------------Fixed Pay----------------
+        public DateTime? FirstPatchDateFrom { get; set; }
+        public DateTime? FirstPatchDateTo { get; set; } //
+        public decimal? FirstPatchAmount { get; set; }
+
+        public DateTime? LastPatchDateFrom { get; set; } //
+        public DateTime? LastPatchDateTo { get; set; } // 
+        public decimal? LastPatchAmount { get; set; }
+        public string? Teams{ get; set; }
+        public string? Vacations{ get; set; }
+
+        //__________________HR data_________-
+        public List<TeamDto>? TeamList { get; set; }
+        public List<OrderRequestDto>? OrderList { get; set; }
+        //-------------------------------
+        public List<ContractTaskDto>? ContractTasks { get; set; }
+        public List<ProjectStageDto>? ProjectStages { get; set; }
+        public List<InvoiceDto>? InvoiceList { get; set; }
+    }
+}

+ 23 - 0
MTWorkHR.Application/Dtos/Payment/InvoiceDto.cs

@@ -0,0 +1,23 @@
+using MTWorkHR.Core.Entities.Base;
+using MTWorkHR.Core.Global;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MTWorkHR.Core.Entities
+{
+    public class InvoiceDto : FullAuditEntity
+    {
+        public string? InvoiceNumber { get; set; }
+        public DateTime? InvoiceDate{ get; set; }
+        public decimal? Amount{ get; set; }
+        public int? Status{ get; set; }
+        public int? ContractId{ get; set; }
+        public int? UserId { get; set; }
+
+    }
+}

+ 3 - 1
MTWorkHR.Application/Mapper/MappingProfile.cs

@@ -138,7 +138,9 @@ namespace MTWorkHR.Application.Mapper
             CreateMap<ChatMessageDto, ChatMessage>().ReverseMap();
             CreateMap<ChatMessageDto, ChatMessage>().ReverseMap();
             
             
             //-----------Contract----
             //-----------Contract----
-            CreateMap<Contract, ContractDto>() .ForMember(d => d.WorkingDays, o => o.Ignore());
+            CreateMap<Invoice, InvoiceDto>().ReverseMap();
+            CreateMap<Contract, ContractDto>().ForMember(d => d.WorkingDays, o => o.Ignore());
+            CreateMap<Contract, ContractHRDto>().ForMember(d => d.WorkingDays, o => o.Ignore());
             CreateMap<ContractDto, Contract>()
             CreateMap<ContractDto, Contract>()
                 .ForMember(d => d.CreateDate, o => o.Ignore())
                 .ForMember(d => d.CreateDate, o => o.Ignore())
                 .ForMember(d => d.CreateUser, o => o.Ignore());
                 .ForMember(d => d.CreateUser, o => o.Ignore());

+ 31 - 6
MTWorkHR.Application/Services/Contract/ContractService.cs

@@ -195,12 +195,12 @@ namespace MTWorkHR.Application.Services
 
 
             return response;
             return response;
         }
         }
-        public async Task<ContractDto> GetByIdHRDetails(long id)
+        public async Task<ContractHRDto> GetByIdHRDetails(long contractId)
         {
         {
-            var entity = await _unitOfWork.Contract.GetByIdWithAllChildren(id);
+            var entity = await _unitOfWork.Contract.GetByIdWithAllChildren(contractId);
             if (entity != null)
             if (entity != null)
             {
             {
-                var response = MapperObject.Mapper.Map<ContractDto>(entity);
+                var response = MapperObject.Mapper.Map<ContractHRDto>(entity);
                 response.WorkingDays = entity.WorkingDays != null ? entity.WorkingDays.Split(",").ToList() : null;
                 response.WorkingDays = entity.WorkingDays != null ? entity.WorkingDays.Split(",").ToList() : null;
                 //--------------------
                 //--------------------
                 var user = await _userService.GetUserWithAttachmentById(entity.UserId);
                 var user = await _userService.GetUserWithAttachmentById(entity.UserId);
@@ -216,13 +216,38 @@ namespace MTWorkHR.Application.Services
                 var remainVacations = vacationAllocations;
                 var remainVacations = vacationAllocations;
                 response.Vacations = remainVacations == null ? "" : remainVacations.NumberOfDays + " / " + entity.VacationDays;
                 response.Vacations = remainVacations == null ? "" : remainVacations.NumberOfDays + " / " + entity.VacationDays;
                 //__-----------Order Requests----
                 //__-----------Order Requests----
-                var orderRequestsList = await _unitOfWork.OrderRequest.GetAllUserOrdersAsync(entity.UserId);
+                var orderRequestsList = await _unitOfWork.OrderRequest.GetAllUserOrdersAsync(entity.UserId, contractId);
                 var orderList = MapperObject.Mapper.Map<List<OrderRequestDto>>(orderRequestsList.Item1);
                 var orderList = MapperObject.Mapper.Map<List<OrderRequestDto>>(orderRequestsList.Item1);
-
                 response.OrderList = orderList;
                 response.OrderList = orderList;
+                /////------------------------
+                var invoiceList = await _unitOfWork.Invoice.GetAllUserInvoices(contractId);
+                var Invoices = MapperObject.Mapper.Map<List<InvoiceDto>>(invoiceList.Item1);
+
+                response.InvoiceList = Invoices;
+
+                //------------------
+                if(entity.ContractTypeId == (int)ContractTypeEnum.EmployeeContract)
+                {
+                    var lastInvoice = Invoices.LastOrDefault();
+                    var diffDate = DateTime.Now.Date - entity.StartDate.Value.Date;
+                    if(lastInvoice != null)
+                    {
+                        if (entity.BillingCycle == "Monthly")
+                            response.NextSalaryDate = lastInvoice.InvoiceDate.Value.AddMonths(1);
+                        else if (entity.BillingCycle == "Fortnightly")
+                            response.NextSalaryDate = lastInvoice.InvoiceDate.Value.AddDays(15);
+                    }
+                    else
+                    {
+                        if (entity.BillingCycle == "Monthly")
+                            response.NextSalaryDate = entity.StartDate.Value.AddMonths(1);
+                        else if(entity.BillingCycle == "Fortnightly")
+                            response.NextSalaryDate = entity.StartDate.Value.AddDays(15);
+                    }
+                }
                 return response;
                 return response;
             }
             }
-            return new ContractDto();
+            return new ContractHRDto();
         }
         }
         #endregion
         #endregion
         public async Task<bool> ChangeStatus(long contractId, int statusId)
         public async Task<bool> ChangeStatus(long contractId, int statusId)

+ 1 - 1
MTWorkHR.Application/Services/Interfaces/IContractService.cs

@@ -10,6 +10,6 @@ namespace MTWorkHR.Application.Services.Interfaces
         Task<PagingResultDto<ContractDto>> GetAll(ContractPagingInputDto PagingInputDto);
         Task<PagingResultDto<ContractDto>> GetAll(ContractPagingInputDto PagingInputDto);
         Task<PagingResultDto<ContractDto>> GetAllForHr(ContractPagingInputDto PagingInputDto);
         Task<PagingResultDto<ContractDto>> GetAllForHr(ContractPagingInputDto PagingInputDto);
         Task<bool> ChangeStatus(long contractId, int statusId);
         Task<bool> ChangeStatus(long contractId, int statusId);
-        Task<ContractDto> GetByIdHRDetails(long id);
+        Task<ContractHRDto> GetByIdHRDetails(long id);
     }
     }
 }
 }

+ 3 - 3
MTWorkHR.Application/Services/User/OrderRequestService.cs

@@ -134,7 +134,7 @@ namespace MTWorkHR.Application.Services
             {
             {
                 var contractId = await _unitOfWork.Contract.GetLatestActiveContract(input.RequestingEmployeeId);
                 var contractId = await _unitOfWork.Contract.GetLatestActiveContract(input.RequestingEmployeeId);
                 var allocation = await _unitOfWork.OrderAllocation.GetUserAllocations(input.RequestingEmployeeId, input.OrderTypeId, input.LeaveTypeId, contractId.Id, period);
                 var allocation = await _unitOfWork.OrderAllocation.GetUserAllocations(input.RequestingEmployeeId, input.OrderTypeId, input.LeaveTypeId, contractId.Id, period);
-
+                input.ContractId = contractId.Id;
                 if (allocation is null)
                 if (allocation is null)
                 {
                 {
                     throw new AppException(ExceptionEnum.NoVacationBalance, "You do not have any allocations for this leave type.");
                     throw new AppException(ExceptionEnum.NoVacationBalance, "You do not have any allocations for this leave type.");
@@ -209,8 +209,8 @@ namespace MTWorkHR.Application.Services
             orderRequest.OrderStatus = (ApprovalStatusEnum)statusId;
             orderRequest.OrderStatus = (ApprovalStatusEnum)statusId;
             if (orderRequest.OrderStatus == ApprovalStatusEnum.Approved)
             if (orderRequest.OrderStatus == ApprovalStatusEnum.Approved)
             {
             {
-                var contractId = await _unitOfWork.Contract.GetLatestActiveContract(orderRequest.RequestingEmployeeId);
-                var allocation = await _unitOfWork.OrderAllocation.GetUserAllocations(orderRequest.RequestingEmployeeId, orderRequest.OrderTypeId, orderRequest.LeaveTypeId,contractId.Id, DateTime.Now.Year);
+                var contract = await _unitOfWork.Contract.GetLatestActiveContract(orderRequest.RequestingEmployeeId);
+                var allocation = await _unitOfWork.OrderAllocation.GetUserAllocations(orderRequest.RequestingEmployeeId, orderRequest.OrderTypeId, orderRequest.LeaveTypeId, contract.Id, DateTime.Now.Year);
                 if (allocation != null)
                 if (allocation != null)
                 {
                 {
                     int daysRequested = !orderRequest.EndDate.HasValue ? 1 : (int)(orderRequest.EndDate.Value - orderRequest.StartDate).TotalDays;
                     int daysRequested = !orderRequest.EndDate.HasValue ? 1 : (int)(orderRequest.EndDate.Value - orderRequest.StartDate).TotalDays;

+ 2 - 1
MTWorkHR.Core/Entities/Attendance/OrderRequest.cs

@@ -31,7 +31,8 @@ namespace MTWorkHR.Core.Entities.User
         public string? StartTime { get; set; }
         public string? StartTime { get; set; }
         public string? EndTime { get; set; }
         public string? EndTime { get; set; }
 
 
-        public long CompanyId { get ; set ; }
+        public long CompanyId { get; set ; }
+        public long? ContractId { get; set ; }
 
 
     }
     }
 }
 }

+ 24 - 0
MTWorkHR.Core/Entities/Payment/Invoice.cs

@@ -0,0 +1,24 @@
+using MTWorkHR.Core.Entities.Base;
+using MTWorkHR.Core.Global;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MTWorkHR.Core.Entities
+{
+    public class Invoice : FullAuditEntity
+    {
+
+        public string? InvoiceNumber { get; set; }
+        public DateTime? InvoiceDate{ get; set; }
+        public decimal? Amount{ get; set; }
+        public int? Status{ get; set; }
+        public int? ContractId{ get; set; }
+        public string? UserId { get; set; }
+
+    }
+}

MTWorkHR.Core/Entities/Payment/SubscriptionConfigurationDto.cs → MTWorkHR.Core/Entities/Payment/SubscriptionConfiguration.cs


+ 15 - 0
MTWorkHR.Core/IRepositories/Payment/IInvoiceRepository.cs

@@ -0,0 +1,15 @@
+using MTWorkHR.Core.Entities;
+using MTWorkHR.Core.IRepositories.Base;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MTWorkHR.Core.IRepositories
+{
+    public interface IInvoiceRepository : IRepository<Invoice>
+    {
+        Task<Tuple<IQueryable<Invoice>, int>> GetAllUserInvoices(long contractId);
+    }
+}

+ 1 - 1
MTWorkHR.Core/IRepositories/User/IOrderRequestRepository.cs

@@ -13,7 +13,7 @@ namespace MTWorkHR.Core.IRepositories
     {
     {
        Task<OrderRequest> GetByIdWithAllChildren(long id);
        Task<OrderRequest> GetByIdWithAllChildren(long id);
         Task<Tuple<IQueryable<OrderRequest>, int>> GetAllWithChildrenAsync();
         Task<Tuple<IQueryable<OrderRequest>, int>> GetAllWithChildrenAsync();
-        Task<Tuple<IQueryable<OrderRequest>, int>> GetAllUserOrdersAsync(string userId);
+        Task<Tuple<IQueryable<OrderRequest>, int>> GetAllUserOrdersAsync(string userId, long contractId);
 
 
     }
     }
 }
 }

+ 1 - 0
MTWorkHR.Core/IUnitOfWork/IUnitOfWork.cs

@@ -42,6 +42,7 @@ namespace MTWorkHR.Core.UnitOfWork
 
 
         IHubConnectionRepository HubConnection { get; }
         IHubConnectionRepository HubConnection { get; }
         ISubscriptionConfigurationRepository SubscriptionConfiguration { get; }
         ISubscriptionConfigurationRepository SubscriptionConfiguration { get; }
+        IInvoiceRepository Invoice { get; }
         Task<int> CompleteAsync();
         Task<int> CompleteAsync();
 
 
         void BeginTran();
         void BeginTran();

+ 1 - 0
MTWorkHR.Infrastructure/DBContext/HRDataContext.cs

@@ -55,6 +55,7 @@ namespace MTWorkHR.Infrastructure.DBContext
         public DbSet<Contract> Contracts { get; set; }
         public DbSet<Contract> Contracts { get; set; }
         public DbSet<Nationality> Nationalities{ get; set; }
         public DbSet<Nationality> Nationalities{ get; set; }
         public DbSet<SubscriptionConfiguration> SubscriptionConfiguration { get; set; }
         public DbSet<SubscriptionConfiguration> SubscriptionConfiguration { get; set; }
+        public DbSet<Invoice> Invoice { get; set; }
 
 
         //------------------------Logs------------------------
         //------------------------Logs------------------------
         public DbSet<UserLog> UserLogs { get; set; }
         public DbSet<UserLog> UserLogs { get; set; }

+ 1 - 0
MTWorkHR.Infrastructure/InfrastructureServiceRegistration.cs

@@ -107,6 +107,7 @@ namespace MTWorkHR.Infrastructure
             services.AddScoped(typeof(IContractTaskAttachmentRepository), typeof(ContractTaskAttachmentRepository));
             services.AddScoped(typeof(IContractTaskAttachmentRepository), typeof(ContractTaskAttachmentRepository));
             services.AddScoped(typeof(IProjectStageAttachmentRepository), typeof(ProjectStageAttachmentRepository));
             services.AddScoped(typeof(IProjectStageAttachmentRepository), typeof(ProjectStageAttachmentRepository));
             services.AddScoped(typeof(ISubscriptionConfigurationRepository), typeof(SubscriptionConfigurationRepository));
             services.AddScoped(typeof(ISubscriptionConfigurationRepository), typeof(SubscriptionConfigurationRepository));
+            services.AddScoped(typeof(IInvoiceRepository), typeof(InvoiceRepository));
 
 
             services.AddScoped(typeof(IHubConnectionRepository), typeof(HubConnectionRepository));
             services.AddScoped(typeof(IHubConnectionRepository), typeof(HubConnectionRepository));
             
             

文件差異過大導致無法顯示
+ 6850 - 0
MTWorkHR.Infrastructure/Migrations/20250204112713_addInvoice.Designer.cs


+ 46 - 0
MTWorkHR.Infrastructure/Migrations/20250204112713_addInvoice.cs

@@ -0,0 +1,46 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace MTWorkHR.Infrastructure.Migrations
+{
+    /// <inheritdoc />
+    public partial class addInvoice : Migration
+    {
+        /// <inheritdoc />
+        protected override void Up(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.CreateTable(
+                name: "Invoice",
+                columns: table => new
+                {
+                    Id = table.Column<long>(type: "bigint", nullable: false)
+                        .Annotation("SqlServer:Identity", "1, 1"),
+                    CreateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
+                    UpdateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
+                    CreateDate = table.Column<DateTime>(type: "datetime2", nullable: false),
+                    UpdateDate = table.Column<DateTime>(type: "datetime2", nullable: true),
+                    IsDeleted = table.Column<bool>(type: "bit", nullable: false),
+                    DeleteUserId = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
+                    InvoiceNumber = table.Column<string>(type: "nvarchar(max)", nullable: true),
+                    InvoiceDate = table.Column<DateTime>(type: "datetime2", nullable: true),
+                    Amount = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
+                    Status = table.Column<int>(type: "int", nullable: true),
+                    ContractId = table.Column<int>(type: "int", nullable: true),
+                    UserId = table.Column<string>(type: "nvarchar(max)", nullable: true)
+                },
+                constraints: table =>
+                {
+                    table.PrimaryKey("PK_Invoice", x => x.Id);
+                });
+        }
+
+        /// <inheritdoc />
+        protected override void Down(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.DropTable(
+                name: "Invoice");
+        }
+    }
+}

文件差異過大導致無法顯示
+ 6853 - 0
MTWorkHR.Infrastructure/Migrations/20250204145927_altrOrderRequest2.Designer.cs


+ 28 - 0
MTWorkHR.Infrastructure/Migrations/20250204145927_altrOrderRequest2.cs

@@ -0,0 +1,28 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace MTWorkHR.Infrastructure.Migrations
+{
+    /// <inheritdoc />
+    public partial class altrOrderRequest2 : Migration
+    {
+        /// <inheritdoc />
+        protected override void Up(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.AddColumn<long>(
+                name: "ContractId",
+                table: "OrderRequests",
+                type: "bigint",
+                nullable: true);
+        }
+
+        /// <inheritdoc />
+        protected override void Down(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.DropColumn(
+                name: "ContractId",
+                table: "OrderRequests");
+        }
+    }
+}

+ 62 - 0
MTWorkHR.Infrastructure/Migrations/HRDataContextModelSnapshot.cs

@@ -1302,6 +1302,65 @@ namespace MTWorkHR.Infrastructure.Migrations
                         });
                         });
                 });
                 });
 
 
+            modelBuilder.Entity("MTWorkHR.Core.Entities.Invoice", b =>
+                {
+                    b.Property<long>("Id")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("bigint")
+                        .HasColumnOrder(0);
+
+                    SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
+
+                    b.Property<decimal?>("Amount")
+                        .HasColumnType("decimal(18,2)");
+
+                    b.Property<int?>("ContractId")
+                        .HasColumnType("int");
+
+                    b.Property<DateTime>("CreateDate")
+                        .HasColumnType("datetime2")
+                        .HasColumnOrder(3);
+
+                    b.Property<string>("CreateUser")
+                        .HasMaxLength(450)
+                        .HasColumnType("nvarchar(450)")
+                        .HasColumnOrder(1);
+
+                    b.Property<string>("DeleteUserId")
+                        .HasMaxLength(450)
+                        .HasColumnType("nvarchar(450)")
+                        .HasColumnOrder(8);
+
+                    b.Property<DateTime?>("InvoiceDate")
+                        .HasColumnType("datetime2");
+
+                    b.Property<string>("InvoiceNumber")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<bool>("IsDeleted")
+                        .HasColumnType("bit")
+                        .HasColumnOrder(7);
+
+                    b.Property<int?>("Status")
+                        .HasColumnType("int");
+
+                    b.Property<DateTime?>("UpdateDate")
+                        .HasColumnType("datetime2")
+                        .HasColumnOrder(4);
+
+                    b.Property<string>("UpdateUser")
+                        .HasMaxLength(450)
+                        .HasColumnType("nvarchar(450)")
+                        .HasColumnOrder(2);
+
+                    b.Property<string>("UserId")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.HasKey("Id");
+
+                    b.ToTable("Invoice");
+                });
+
             modelBuilder.Entity("MTWorkHR.Core.Entities.JobTitle", b =>
             modelBuilder.Entity("MTWorkHR.Core.Entities.JobTitle", b =>
                 {
                 {
                     b.Property<long>("Id")
                     b.Property<long>("Id")
@@ -4466,6 +4525,9 @@ namespace MTWorkHR.Infrastructure.Migrations
                     b.Property<long>("CompanyId")
                     b.Property<long>("CompanyId")
                         .HasColumnType("bigint");
                         .HasColumnType("bigint");
 
 
+                    b.Property<long?>("ContractId")
+                        .HasColumnType("bigint");
+
                     b.Property<int?>("CountryId")
                     b.Property<int?>("CountryId")
                         .HasColumnType("int");
                         .HasColumnType("int");
 
 

+ 26 - 0
MTWorkHR.Infrastructure/Repositories/Payment/InvoiceRepository.cs

@@ -0,0 +1,26 @@
+using Microsoft.EntityFrameworkCore;
+using MTWorkHR.Core.Entities;
+using MTWorkHR.Core.IRepositories;
+using MTWorkHR.Infrastructure.DBContext;
+
+namespace MTWorkHR.Infrastructure.Repositories
+{
+    public class InvoiceRepository : Repository<Invoice>, IInvoiceRepository
+    {
+        private readonly DbSet<Invoice> dbSet;
+
+        public InvoiceRepository(HRDataContext context) : base(context)
+        {
+            dbSet = context.Set<Invoice>();
+
+        }
+
+        public async Task<Tuple<IQueryable<Invoice>, int>> GetAllUserInvoices(long contractId)
+        {
+            var query = dbSet.Where(a => a.ContractId == contractId).AsQueryable();
+            var total = await query.CountAsync();
+
+            return new Tuple<IQueryable<Invoice>, int>(query, total);
+        }
+    }
+}

+ 2 - 2
MTWorkHR.Infrastructure/Repositories/User/OrderRequestRepository.cs

@@ -31,9 +31,9 @@ namespace MTWorkHR.Infrastructure.Repositories
             return new Tuple<IQueryable<OrderRequest>, int>(query, total);
             return new Tuple<IQueryable<OrderRequest>, int>(query, total);
         }
         }
 
 
-        public async Task<Tuple<IQueryable<OrderRequest>, int>> GetAllUserOrdersAsync(string userId)
+        public async Task<Tuple<IQueryable<OrderRequest>, int>> GetAllUserOrdersAsync(string userId, long contractId)
         {
         {
-            var query = dbSet.Include(x => x.OrderType).Include(x => x.LeaveType).Where(a=> a.RequestingEmployeeId == userId).AsQueryable();
+            var query = dbSet.Include(x => x.OrderType).Include(x => x.LeaveType).Where(a=> a.RequestingEmployeeId == userId && a.ContractId == contractId).AsQueryable();
             var total = await query.CountAsync();
             var total = await query.CountAsync();
 
 
             return new Tuple<IQueryable<OrderRequest>, int>(query, total);
             return new Tuple<IQueryable<OrderRequest>, int>(query, total);

+ 3 - 0
MTWorkHR.Infrastructure/UnitOfWork/UnitOfWork.cs

@@ -44,6 +44,7 @@ namespace MTWorkHR.Infrastructure.UnitOfWorks
         public IContractTaskAttachmentRepository ContractTaskAttachment { get; }
         public IContractTaskAttachmentRepository ContractTaskAttachment { get; }
         public IProjectStageAttachmentRepository ProjectStageAttachment { get; }
         public IProjectStageAttachmentRepository ProjectStageAttachment { get; }
         public ISubscriptionConfigurationRepository SubscriptionConfiguration { get; }
         public ISubscriptionConfigurationRepository SubscriptionConfiguration { get; }
+        public IInvoiceRepository Invoice { get; }
 
 
         public UnitOfWork(HRDataContext _context
         public UnitOfWork(HRDataContext _context
             , IPermissionRepository permission
             , IPermissionRepository permission
@@ -76,6 +77,7 @@ namespace MTWorkHR.Infrastructure.UnitOfWorks
             , IProjectStageAttachmentRepository projectStageAttachment
             , IProjectStageAttachmentRepository projectStageAttachment
             , IHubConnectionRepository connection
             , IHubConnectionRepository connection
             , ISubscriptionConfigurationRepository subscriptionConfiguration
             , ISubscriptionConfigurationRepository subscriptionConfiguration
+            , IInvoiceRepository invoice
 
 
             )
             )
         {
         {
@@ -110,6 +112,7 @@ namespace MTWorkHR.Infrastructure.UnitOfWorks
             ContractTaskAttachment = contractTaskAttachment;
             ContractTaskAttachment = contractTaskAttachment;
             ProjectStageAttachment = projectStageAttachment;
             ProjectStageAttachment = projectStageAttachment;
             SubscriptionConfiguration = subscriptionConfiguration;
             SubscriptionConfiguration = subscriptionConfiguration;
+            Invoice = invoice;
         }
         }
 
 
         public async Task<int> CompleteAsync()
         public async Task<int> CompleteAsync()