Compare commits
16 Commits
Feature/fi
...
Feature/sa
| Author | SHA1 | Date | |
|---|---|---|---|
| c844867cab | |||
| 779514f5c0 | |||
| bc491eec18 | |||
| 67910d2fa5 | |||
| db32b1e6ea | |||
| 79a9d72b86 | |||
| a8cb226d20 | |||
| ffe8fa67e2 | |||
| a0d2023a6c | |||
| b22aa86aea | |||
| f0feac9601 | |||
|
|
8ec13ffae1 | ||
|
|
5508d4e88f | ||
| 43abb74c61 | |||
| 73e6681baa | |||
| 90b2fd2eab |
@@ -8,7 +8,6 @@ public class CreateSalaryAidViewModel
|
|||||||
public long WorkshopId { get; set; }
|
public long WorkshopId { get; set; }
|
||||||
public string Amount { get; set; }
|
public string Amount { get; set; }
|
||||||
public string SalaryDateTime { get; set; }
|
public string SalaryDateTime { get; set; }
|
||||||
public string CalculationDateTime { get; set; }
|
|
||||||
public string NationalCode { get; set; }
|
public string NationalCode { get; set; }
|
||||||
public int CalculationMonth { get; set; }
|
public int CalculationMonth { get; set; }
|
||||||
public int CalculationYear { get; set; }
|
public int CalculationYear { get; set; }
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ public class SalaryAidGroupedByDateViewModel
|
|||||||
public string YearFa { get; set; }
|
public string YearFa { get; set; }
|
||||||
public int Month { get; set; }
|
public int Month { get; set; }
|
||||||
public int Year { get; set; }
|
public int Year { get; set; }
|
||||||
public List<SalaryAidGroupedByDateViewModelItems> SalaryAidViewModels { get; set; }
|
public List<SalaryAidGroupedByDateViewModelItems> Items { get; set; }
|
||||||
public string TotalAmount { get; set; }
|
public string TotalAmount { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ public class SalaryAidGroupedByEmployeeViewModel
|
|||||||
{
|
{
|
||||||
public string EmployeeName { get; set; }
|
public string EmployeeName { get; set; }
|
||||||
public long EmployeeId { get; set; }
|
public long EmployeeId { get; set; }
|
||||||
public List<SalaryAidGroupedByEmployeeViewModelItems> SalaryAidViewModels { get; set; }
|
public List<SalaryAidGroupedByEmployeeViewModelItems> Items { get; set; }
|
||||||
public string TotalAmount { get; set; }
|
public string TotalAmount { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,15 +3,15 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using _0_Framework.Application;
|
||||||
|
|
||||||
namespace CompanyManagment.App.Contracts.SalaryAid;
|
namespace CompanyManagment.App.Contracts.SalaryAid;
|
||||||
public class SalaryAidSearchViewModel
|
public class SalaryAidSearchViewModel:PaginationRequest
|
||||||
{
|
{
|
||||||
public string StartDate { get; set; }
|
public string StartDate { get; set; }
|
||||||
public string EndDate { get; set; }
|
public string EndDate { get; set; }
|
||||||
public long EmployeeId { get; set; }
|
public long EmployeeId { get; set; }
|
||||||
public long WorkshopId { get; set; }
|
public long WorkshopId { get; set; }
|
||||||
public int PageIndex { get; set; }
|
|
||||||
public bool ShowAsGrouped { get; set; }
|
public bool ShowAsGrouped { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
|
using _0_Framework.Application;
|
||||||
|
|
||||||
namespace CompanyManagment.App.Contracts.SalaryAid;
|
namespace CompanyManagment.App.Contracts.SalaryAid;
|
||||||
|
|
||||||
@@ -7,7 +8,7 @@ public class SalaryAidsGroupedViewModel
|
|||||||
{
|
{
|
||||||
public List<SalaryAidGroupedByEmployeeViewModel> GroupedByEmployee { get; set; }
|
public List<SalaryAidGroupedByEmployeeViewModel> GroupedByEmployee { get; set; }
|
||||||
public List<SalaryAidGroupedByDateViewModel> GroupedByDate { get; set; }
|
public List<SalaryAidGroupedByDateViewModel> GroupedByDate { get; set; }
|
||||||
public List<SalaryAidViewModel> SalaryAidListViewModels { get; set; }
|
public PagedResult<SalaryAidViewModel> List { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ public class SalaryAidRepository : RepositoryBase<long, SalaryAid>, ISalaryAidRe
|
|||||||
{
|
{
|
||||||
YearFa = x.Key.YearFa,
|
YearFa = x.Key.YearFa,
|
||||||
MonthFa = x.Key.MonthFa,
|
MonthFa = x.Key.MonthFa,
|
||||||
SalaryAidViewModels = x.Select(s => new SalaryAidGroupedByDateViewModelItems()
|
Items = x.Select(s => new SalaryAidGroupedByDateViewModelItems()
|
||||||
{
|
{
|
||||||
Amount = s.Amount,
|
Amount = s.Amount,
|
||||||
EmployeeName = s.EmployeeFullName,
|
EmployeeName = s.EmployeeFullName,
|
||||||
@@ -175,7 +175,7 @@ public class SalaryAidRepository : RepositoryBase<long, SalaryAid>, ISalaryAidRe
|
|||||||
EmployeeId = x.Key,
|
EmployeeId = x.Key,
|
||||||
TotalAmount = x.Sum(s => s.Amount).ToMoney(),
|
TotalAmount = x.Sum(s => s.Amount).ToMoney(),
|
||||||
EmployeeName = employees.FirstOrDefault(e => e.id == x.Key).FullName,
|
EmployeeName = employees.FirstOrDefault(e => e.id == x.Key).FullName,
|
||||||
SalaryAidViewModels = x.Select(s => new SalaryAidGroupedByEmployeeViewModelItems()
|
Items = x.Select(s => new SalaryAidGroupedByEmployeeViewModelItems()
|
||||||
{
|
{
|
||||||
Amount = s.Amount.ToMoney(),
|
Amount = s.Amount.ToMoney(),
|
||||||
Id = s.id,
|
Id = s.id,
|
||||||
@@ -197,8 +197,11 @@ public class SalaryAidRepository : RepositoryBase<long, SalaryAid>, ISalaryAidRe
|
|||||||
query = query.Where(x => x.SalaryAidDateTime >= startDate && x.SalaryAidDateTime <= endDate);
|
query = query.Where(x => x.SalaryAidDateTime >= startDate && x.SalaryAidDateTime <= endDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
result.SalaryAidListViewModels = query.OrderByDescending(x => x.SalaryAidDateTime).Skip(searchModel.PageIndex).Take(30).ToList().Select(
|
result.List = new PagedResult<SalaryAidViewModel>()
|
||||||
x => new SalaryAidViewModel()
|
{
|
||||||
|
TotalCount = query.Count(),
|
||||||
|
List = query.OrderByDescending(x => x.SalaryAidDateTime).ApplyPagination(searchModel.PageIndex,searchModel.PageSize).ToList()
|
||||||
|
.Select(x => new SalaryAidViewModel()
|
||||||
{
|
{
|
||||||
Amount = x.Amount.ToMoney(),
|
Amount = x.Amount.ToMoney(),
|
||||||
CreationDate = x.CreationDate.ToFarsi(),
|
CreationDate = x.CreationDate.ToFarsi(),
|
||||||
@@ -209,10 +212,12 @@ public class SalaryAidRepository : RepositoryBase<long, SalaryAid>, ISalaryAidRe
|
|||||||
WorkshopId = x.WorkshopId,
|
WorkshopId = x.WorkshopId,
|
||||||
YearFa = x.SalaryAidDateTime.ToFarsi().Substring(0, 4),
|
YearFa = x.SalaryAidDateTime.ToFarsi().Substring(0, 4),
|
||||||
MonthFa = x.SalaryAidDateTime.ToFarsi().Substring(5, 2),
|
MonthFa = x.SalaryAidDateTime.ToFarsi().Substring(5, 2),
|
||||||
PersonnelCode = personnelCodes.FirstOrDefault(p => p.EmployeeId == x.EmployeeId).PersonnelCode.ToString(),
|
PersonnelCode = personnelCodes.FirstOrDefault(p => p.EmployeeId == x.EmployeeId).PersonnelCode
|
||||||
|
.ToString(),
|
||||||
EmployeeFullName = employees.FirstOrDefault(e => e.id == x.EmployeeId).FullName,
|
EmployeeFullName = employees.FirstOrDefault(e => e.id == x.EmployeeId).FullName,
|
||||||
AmountDouble = x.Amount,
|
AmountDouble = x.Amount,
|
||||||
}).ToList();
|
}).ToList()
|
||||||
|
};
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -209,22 +209,38 @@ public class CreateOrEditCheckoutCommandHandler : IBaseCommandHandler<CreateOrEd
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
//حقوق نهایی
|
////حقوق نهایی
|
||||||
var monthlySalaryPay = (totalHoursWorked * monthlySalaryDefined) / mandatoryHours;
|
//var monthlySalaryPay = (totalHoursWorked * monthlySalaryDefined) / mandatoryHours;
|
||||||
// اگر اضافه کار داشت حقوق تعین شده به عنوان حقوق نهایی در نظر گرفته میشود
|
//// اگر اضافه کار داشت حقوق تعین شده به عنوان حقوق نهایی در نظر گرفته میشود
|
||||||
monthlySalaryPay = monthlySalaryPay > monthlySalaryDefined ? monthlySalaryDefined : monthlySalaryPay;
|
//monthlySalaryPay = monthlySalaryPay > monthlySalaryDefined ? monthlySalaryDefined : monthlySalaryPay;
|
||||||
|
|
||||||
//حقوق کسر شده
|
////حقوق کسر شده
|
||||||
var deductionFromSalary = monthlySalaryDefined - monthlySalaryPay;
|
//var deductionFromSalary = monthlySalaryDefined - monthlySalaryPay;
|
||||||
|
|
||||||
|
//new chang salary compute
|
||||||
|
var monthlySalaryPay = totalHoursWorked * monthlySalaryDefined;
|
||||||
|
|
||||||
//زمان باقی مانده
|
//زمان باقی مانده
|
||||||
var remainingTime = totalHoursWorked - mandatoryHours;
|
var remainingTime = totalHoursWorked - mandatoryHours;
|
||||||
|
|
||||||
|
|
||||||
|
//تناسب به دقیقه
|
||||||
|
#region MyRegion
|
||||||
|
|
||||||
|
//var monthlySalaryDefinedTest = monthlySalaryDefined * mandatoryHours;
|
||||||
|
//var monthlySalaryPayTest = totalHoursWorked * monthlySalaryDefined;
|
||||||
|
////// اگر اضافه کار داشت حقوق تعین شده به عنوان حقوق نهایی در نظر گرفته میشود
|
||||||
|
//monthlySalaryPayTest = monthlySalaryPayTest > monthlySalaryDefinedTest ? monthlySalaryDefinedTest : monthlySalaryPayTest;
|
||||||
|
//////حقوق کسر شده
|
||||||
|
//var deductionFromSalaryTest = monthlySalaryDefinedTest - monthlySalaryPayTest;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
var computeResult = new ComputeResultDto
|
var computeResult = new ComputeResultDto
|
||||||
{
|
{
|
||||||
MandatoryHours = mandatoryHours,
|
MandatoryHours = mandatoryHours,
|
||||||
MonthlySalaryPay = monthlySalaryPay,
|
MonthlySalaryPay = monthlySalaryPay,
|
||||||
DeductionFromSalary = deductionFromSalary,
|
DeductionFromSalary = 0 /*deductionFromSalary*/,
|
||||||
RemainingHours = remainingTime
|
RemainingHours = remainingTime
|
||||||
};
|
};
|
||||||
Console.WriteLine(mandatoryHours);
|
Console.WriteLine(mandatoryHours);
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
using DNTPersianUtils.Core;
|
||||||
|
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||||
using GozareshgirProgramManager.Application._Common.Models;
|
using GozareshgirProgramManager.Application._Common.Models;
|
||||||
using GozareshgirProgramManager.Application.Modules.SalaryPaymentSettings.Queries.GetUserListWhoHaveSettings;
|
using GozareshgirProgramManager.Application.Modules.SalaryPaymentSettings.Queries.GetUserListWhoHaveSettings;
|
||||||
using GozareshgirProgramManager.Domain._Common;
|
using GozareshgirProgramManager.Domain._Common;
|
||||||
using GozareshgirProgramManager.Domain.CheckoutAgg.Enums;
|
using GozareshgirProgramManager.Domain.CheckoutAgg.Enums;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using PersianTools.Core;
|
using PersianDateTime = PersianTools.Core.PersianDateTime;
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Application.Modules.Checkouts.Queries.GetUserToGropCreate;
|
namespace GozareshgirProgramManager.Application.Modules.Checkouts.Queries.GetUserToGropCreate;
|
||||||
|
|
||||||
@@ -45,8 +46,8 @@ public class GetUserToGroupCreatingQueryHandler : IBaseQueryHandler<GetUserToGro
|
|||||||
"ایجاد فیش فقط برای ماه های گذشته امکان پذیر است");
|
"ایجاد فیش فقط برای ماه های گذشته امکان پذیر است");
|
||||||
|
|
||||||
|
|
||||||
var lastMonthStart = lastMonth;
|
//var lastMonthStart = lastMonth;
|
||||||
var lastMonthEnd = lastMonth;
|
var lastMonthEnd = ((selectedDate.ToFarsi().FindeEndOfMonth())).ToGeorgianDateTime();
|
||||||
|
|
||||||
var query =
|
var query =
|
||||||
await (from u in _context.Users
|
await (from u in _context.Users
|
||||||
@@ -60,8 +61,8 @@ public class GetUserToGroupCreatingQueryHandler : IBaseQueryHandler<GetUserToGro
|
|||||||
// LEFT JOIN
|
// LEFT JOIN
|
||||||
//فیش
|
//فیش
|
||||||
join ch in _context.Checkouts
|
join ch in _context.Checkouts
|
||||||
.Where(x => x.CheckoutStartDate < lastMonthStart
|
.Where(x => x.CheckoutStartDate < lastMonthEnd
|
||||||
&& x.CheckoutEndDate >= lastMonthStart)
|
&& x.CheckoutEndDate > selectedDate)
|
||||||
on u.Id equals ch.UserId into chJoin
|
on u.Id equals ch.UserId into chJoin
|
||||||
from ch in chJoin.DefaultIfEmpty()
|
from ch in chJoin.DefaultIfEmpty()
|
||||||
|
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ public class ProjectSetTimeDetailsQueryHandler
|
|||||||
|
|
||||||
var skills = await _context.Skills
|
var skills = await _context.Skills
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
|
.OrderBy(x=>x.CreationDate)
|
||||||
.ToListAsync(cancellationToken);
|
.ToListAsync(cancellationToken);
|
||||||
|
|
||||||
var res = new ProjectSetTimeResponse(
|
var res = new ProjectSetTimeResponse(
|
||||||
@@ -84,7 +85,7 @@ public class ProjectSetTimeDetailsQueryHandler
|
|||||||
UserId = section?.OriginalAssignedUserId ?? 0,
|
UserId = section?.OriginalAssignedUserId ?? 0,
|
||||||
SkillId = skill.Id,
|
SkillId = skill.Id,
|
||||||
};
|
};
|
||||||
}).OrderBy(x => x.SkillId).ToList(),
|
}).ToList(),
|
||||||
task.Id,
|
task.Id,
|
||||||
level);
|
level);
|
||||||
|
|
||||||
@@ -114,6 +115,7 @@ public class ProjectSetTimeDetailsQueryHandler
|
|||||||
|
|
||||||
var skills = await _context.Skills
|
var skills = await _context.Skills
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
|
.OrderBy(x=>x.CreationDate)
|
||||||
.ToListAsync(cancellationToken);
|
.ToListAsync(cancellationToken);
|
||||||
|
|
||||||
var res = new ProjectSetTimeResponse(
|
var res = new ProjectSetTimeResponse(
|
||||||
@@ -135,7 +137,7 @@ public class ProjectSetTimeDetailsQueryHandler
|
|||||||
UserId = section?.UserId ?? 0,
|
UserId = section?.UserId ?? 0,
|
||||||
SkillId = skill.Id,
|
SkillId = skill.Id,
|
||||||
};
|
};
|
||||||
}).OrderBy(x => x.SkillId).ToList(),
|
}).ToList(),
|
||||||
phase.Id,
|
phase.Id,
|
||||||
level);
|
level);
|
||||||
|
|
||||||
@@ -165,6 +167,7 @@ public class ProjectSetTimeDetailsQueryHandler
|
|||||||
|
|
||||||
var skills = await _context.Skills
|
var skills = await _context.Skills
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
|
.OrderBy(x=>x.CreationDate)
|
||||||
.ToListAsync(cancellationToken);
|
.ToListAsync(cancellationToken);
|
||||||
|
|
||||||
var res = new ProjectSetTimeResponse(
|
var res = new ProjectSetTimeResponse(
|
||||||
@@ -186,7 +189,7 @@ public class ProjectSetTimeDetailsQueryHandler
|
|||||||
UserId = section?.UserId ?? 0,
|
UserId = section?.UserId ?? 0,
|
||||||
SkillId = skill.Id,
|
SkillId = skill.Id,
|
||||||
};
|
};
|
||||||
}).OrderBy(x => x.SkillId).ToList(),
|
}).ToList(),
|
||||||
project.Id,
|
project.Id,
|
||||||
level);
|
level);
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
using GozareshgirProgramManager.Application._Common.Interfaces;
|
using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||||
using GozareshgirProgramManager.Application._Common.Models;
|
using GozareshgirProgramManager.Application._Common.Models;
|
||||||
using GozareshgirProgramManager.Application.Modules.TaskChat.DTOs;
|
using GozareshgirProgramManager.Application.Modules.TaskChat.DTOs;
|
||||||
|
using GozareshgirProgramManager.Domain.TaskChatAgg.Enums;
|
||||||
|
using MediatR;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace GozareshgirProgramManager.Application.Modules.TaskChat.Queries.GetMessages;
|
namespace GozareshgirProgramManager.Application.Modules.TaskChat.Queries.GetMessages;
|
||||||
|
|
||||||
public record GetMessagesQuery(
|
public record GetMessagesQuery(
|
||||||
Guid TaskId,
|
Guid TaskId,
|
||||||
|
MessageType? MessageType,
|
||||||
int Page = 1,
|
int Page = 1,
|
||||||
int PageSize = 50
|
int PageSize = 50
|
||||||
) : IBaseQuery<PaginationResult<MessageDto>>;
|
) : IBaseQuery<PaginationResult<MessageDto>>;
|
||||||
@@ -66,7 +69,12 @@ public class GetMessagesQueryHandler : IBaseQueryHandler<GetMessagesQuery, Pagin
|
|||||||
var query = _context.TaskChatMessages
|
var query = _context.TaskChatMessages
|
||||||
.Where(m => m.TaskId == request.TaskId && !m.IsDeleted)
|
.Where(m => m.TaskId == request.TaskId && !m.IsDeleted)
|
||||||
.Include(m => m.ReplyToMessage)
|
.Include(m => m.ReplyToMessage)
|
||||||
.OrderBy(m => m.CreationDate);
|
.OrderBy(m => m.CreationDate).AsQueryable();
|
||||||
|
|
||||||
|
if (request.MessageType.HasValue)
|
||||||
|
{
|
||||||
|
query = query.Where(m => m.MessageType == request.MessageType.Value);
|
||||||
|
}
|
||||||
|
|
||||||
var totalCount = await query.CountAsync(cancellationToken);
|
var totalCount = await query.CountAsync(cancellationToken);
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ using GozareshgirProgramManager.Application.Modules.TaskChat.DTOs;
|
|||||||
using GozareshgirProgramManager.Application.Modules.TaskChat.Queries.GetMessages;
|
using GozareshgirProgramManager.Application.Modules.TaskChat.Queries.GetMessages;
|
||||||
using GozareshgirProgramManager.Application.Modules.TaskChat.Queries.GetPinnedMessages;
|
using GozareshgirProgramManager.Application.Modules.TaskChat.Queries.GetPinnedMessages;
|
||||||
using GozareshgirProgramManager.Application.Modules.TaskChat.Queries.SearchMessages;
|
using GozareshgirProgramManager.Application.Modules.TaskChat.Queries.SearchMessages;
|
||||||
|
using GozareshgirProgramManager.Domain.TaskChatAgg.Enums;
|
||||||
using MediatR;
|
using MediatR;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using ServiceHost.BaseControllers;
|
using ServiceHost.BaseControllers;
|
||||||
@@ -30,15 +31,17 @@ public class TaskChatController : ProgramManagerBaseController
|
|||||||
/// دریافت لیست پیامهای یک تسک
|
/// دریافت لیست پیامهای یک تسک
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="taskId">شناسه تسک</param>
|
/// <param name="taskId">شناسه تسک</param>
|
||||||
|
/// <param name="messageType">نوع پیام</param>
|
||||||
/// <param name="page">صفحه (پیشفرض: 1)</param>
|
/// <param name="page">صفحه (پیشفرض: 1)</param>
|
||||||
/// <param name="pageSize">تعداد در هر صفحه (پیشفرض: 50)</param>
|
/// <param name="pageSize">تعداد در هر صفحه (پیشفرض: 50)</param>
|
||||||
[HttpGet("{taskId:guid}/messages")]
|
[HttpGet("{taskId:guid}/messages")]
|
||||||
public async Task<ActionResult<OperationResult<PaginationResult<MessageDto>>>> GetMessages(
|
public async Task<ActionResult<OperationResult<PaginationResult<MessageDto>>>> GetMessages(
|
||||||
Guid taskId,
|
Guid taskId,
|
||||||
|
[FromQuery] MessageType? messageType,
|
||||||
[FromQuery] int page = 1,
|
[FromQuery] int page = 1,
|
||||||
[FromQuery] int pageSize = 50)
|
[FromQuery] int pageSize = 50)
|
||||||
{
|
{
|
||||||
var query = new GetMessagesQuery(taskId, page, pageSize);
|
var query = new GetMessagesQuery(taskId,messageType, page, pageSize);
|
||||||
var result = await _mediator.Send(query);
|
var result = await _mediator.Send(query);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
138
ServiceHost/Areas/Client/Controllers/SalaryAidController.cs
Normal file
138
ServiceHost/Areas/Client/Controllers/SalaryAidController.cs
Normal file
@@ -0,0 +1,138 @@
|
|||||||
|
using _0_Framework.Application;
|
||||||
|
using CompanyManagement.Infrastructure.Excel.SalaryAid;
|
||||||
|
using CompanyManagment.App.Contracts.SalaryAid;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.Build.Evaluation;
|
||||||
|
using ServiceHost.BaseControllers;
|
||||||
|
|
||||||
|
namespace ServiceHost.Areas.Client.Controllers;
|
||||||
|
|
||||||
|
public class SalaryAidController:ClientBaseController
|
||||||
|
{
|
||||||
|
private readonly ISalaryAidApplication _salaryAidApplication;
|
||||||
|
private readonly long _workshopId;
|
||||||
|
private readonly SalaryAidImportExcel _salaryAidImportExcel;
|
||||||
|
|
||||||
|
public SalaryAidController(ISalaryAidApplication salaryAidApplication,IAuthHelper authHelper, SalaryAidImportExcel salaryAidImportExcel)
|
||||||
|
{
|
||||||
|
_salaryAidApplication = salaryAidApplication;
|
||||||
|
_salaryAidImportExcel = salaryAidImportExcel;
|
||||||
|
_workshopId = authHelper.GetWorkshopId();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public ActionResult<SalaryAidsGroupedViewModel> GetList([FromQuery]SalaryAidSearchViewModel searchModel)
|
||||||
|
{
|
||||||
|
searchModel.WorkshopId = _workshopId;
|
||||||
|
var result = _salaryAidApplication.GetSearchListAsGrouped(searchModel);
|
||||||
|
return Ok(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public ActionResult<OperationResult> Create([FromBody]CreateSalaryAidRequest request)
|
||||||
|
{
|
||||||
|
var command = new CreateSalaryAidViewModel()
|
||||||
|
{
|
||||||
|
Amount = request.Amount.ToMoney(),
|
||||||
|
CalculationMonth = request.CalculationMonth,
|
||||||
|
CalculationYear = request.CalculationYear,
|
||||||
|
EmployeeIds = request.EmployeeIds,
|
||||||
|
WorkshopId = _workshopId,
|
||||||
|
SalaryDateTime = request.SalaryDateTime,
|
||||||
|
|
||||||
|
};
|
||||||
|
var result = _salaryAidApplication.Create(command);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPut]
|
||||||
|
public ActionResult<OperationResult> Edit([FromBody]EditSalaryAidRequest request)
|
||||||
|
{
|
||||||
|
var command = new EditSalaryAidViewModel()
|
||||||
|
{
|
||||||
|
Id = request.Id,
|
||||||
|
Amount = request.Amount.ToMoney(),
|
||||||
|
CalculationMonth = request.CalculationMonth,
|
||||||
|
CalculationYear = request.CalculationYear,
|
||||||
|
SalaryDateTime = request.SalaryDateTime,
|
||||||
|
WorkshopId = _workshopId,
|
||||||
|
};
|
||||||
|
var result = _salaryAidApplication.Edit(command);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("{id}")]
|
||||||
|
public ActionResult<EditSalaryAidRequest> EditDetails(long id)
|
||||||
|
{
|
||||||
|
var data = _salaryAidApplication.GetDetails(id);
|
||||||
|
var res = new EditSalaryAidRequest()
|
||||||
|
{
|
||||||
|
Id = data.Id,
|
||||||
|
Amount = data.Amount.MoneyToDouble(),
|
||||||
|
CalculationMonth = data.CalculationMonth,
|
||||||
|
CalculationYear = data.CalculationYear,
|
||||||
|
SalaryDateTime = data.SalaryDateTime,
|
||||||
|
};
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpDelete("{id:long}")]
|
||||||
|
public ActionResult<OperationResult> Delete(long id)
|
||||||
|
{
|
||||||
|
var result = _salaryAidApplication.Remove(id);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
[HttpPost("validate-excel")]
|
||||||
|
public ActionResult<ExcelValidation<SalaryAidImportData>> ValidateExcel([FromForm]ValidateExcelRequest request)
|
||||||
|
{
|
||||||
|
var validation = _salaryAidImportExcel.ReadAndValidateExcel(request.Excel, _workshopId);
|
||||||
|
|
||||||
|
return validation;
|
||||||
|
}
|
||||||
|
[HttpPost("create-from-excel")]
|
||||||
|
public async Task<ActionResult<OperationResult>> OnPostCreateFromExcelData(List<SalaryAidImportData> data)
|
||||||
|
{
|
||||||
|
var commands = data.Select(x => new CreateSalaryAidViewModel()
|
||||||
|
{
|
||||||
|
WorkshopId = x.WorkshopId,
|
||||||
|
Amount = x.Amount.ToMoney(),
|
||||||
|
EmployeeIds = [x.EmployeeId],
|
||||||
|
SalaryDateTime = x.SalaryAidDateTime,
|
||||||
|
NationalCode = x.NationalCode,
|
||||||
|
CalculationMonth = x.calculationMonth,
|
||||||
|
CalculationYear = x.calculationYear
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
OperationResult result = await _salaryAidApplication.CreateRangeAsync(commands);
|
||||||
|
|
||||||
|
return new JsonResult(new
|
||||||
|
{
|
||||||
|
result.IsSuccedded,
|
||||||
|
result.Message
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ValidateExcelRequest
|
||||||
|
{
|
||||||
|
public IFormFile Excel { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class EditSalaryAidRequest
|
||||||
|
{
|
||||||
|
public long Id { get; set; }
|
||||||
|
public long EmployeeId { get; set; }
|
||||||
|
public double Amount { get; set; }
|
||||||
|
public string SalaryDateTime { get; set; }
|
||||||
|
public int CalculationMonth { get; set; }
|
||||||
|
public int CalculationYear { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class CreateSalaryAidRequest
|
||||||
|
{
|
||||||
|
public List<long> EmployeeIds { get; set; }
|
||||||
|
public double Amount { get; set; }
|
||||||
|
public string SalaryDateTime { get; set; }
|
||||||
|
public int CalculationMonth { get; set; }
|
||||||
|
public int CalculationYear { get; set; }
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user