Compare commits
11 Commits
AdminCheck
...
Feature/sa
| Author | SHA1 | Date | |
|---|---|---|---|
| c844867cab | |||
| 779514f5c0 | |||
| bc491eec18 | |||
| 67910d2fa5 | |||
| db32b1e6ea | |||
| 79a9d72b86 | |||
| a8cb226d20 | |||
| ffe8fa67e2 | |||
| a0d2023a6c | |||
| b22aa86aea | |||
| f0feac9601 |
@@ -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; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -433,7 +433,7 @@ public class SalaryAidApplication : ISalaryAidApplication
|
|||||||
var checkouts = _checkoutRepository.GetByWorkshopIdEmployeeIdInDate(
|
var checkouts = _checkoutRepository.GetByWorkshopIdEmployeeIdInDate(
|
||||||
command.WorkshopId, employeeId, calculationDateGr).GetAwaiter().GetResult();
|
command.WorkshopId, employeeId, calculationDateGr).GetAwaiter().GetResult();
|
||||||
|
|
||||||
checkouts?.SetAmountConflict(true);
|
checkouts?.SetAmountConflict(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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,23 +197,28 @@ 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(),
|
||||||
Amount = x.Amount.ToMoney(),
|
List = query.OrderByDescending(x => x.SalaryAidDateTime).ApplyPagination(searchModel.PageIndex,searchModel.PageSize).ToList()
|
||||||
CreationDate = x.CreationDate.ToFarsi(),
|
.Select(x => new SalaryAidViewModel()
|
||||||
Id = x.id,
|
{
|
||||||
EmployeeId = x.EmployeeId,
|
Amount = x.Amount.ToMoney(),
|
||||||
SalaryAidDateTimeFa = x.SalaryAidDateTime.ToFarsi(),
|
CreationDate = x.CreationDate.ToFarsi(),
|
||||||
SalaryAidDateTimeGe = x.SalaryAidDateTime,
|
Id = x.id,
|
||||||
WorkshopId = x.WorkshopId,
|
EmployeeId = x.EmployeeId,
|
||||||
YearFa = x.SalaryAidDateTime.ToFarsi().Substring(0, 4),
|
SalaryAidDateTimeFa = x.SalaryAidDateTime.ToFarsi(),
|
||||||
MonthFa = x.SalaryAidDateTime.ToFarsi().Substring(5, 2),
|
SalaryAidDateTimeGe = x.SalaryAidDateTime,
|
||||||
PersonnelCode = personnelCodes.FirstOrDefault(p => p.EmployeeId == x.EmployeeId).PersonnelCode.ToString(),
|
WorkshopId = x.WorkshopId,
|
||||||
EmployeeFullName = employees.FirstOrDefault(e => e.id == x.EmployeeId).FullName,
|
YearFa = x.SalaryAidDateTime.ToFarsi().Substring(0, 4),
|
||||||
AmountDouble = x.Amount,
|
MonthFa = x.SalaryAidDateTime.ToFarsi().Substring(5, 2),
|
||||||
}).ToList();
|
PersonnelCode = personnelCodes.FirstOrDefault(p => p.EmployeeId == x.EmployeeId).PersonnelCode
|
||||||
|
.ToString(),
|
||||||
|
EmployeeFullName = employees.FirstOrDefault(e => e.id == x.EmployeeId).FullName,
|
||||||
|
AmountDouble = x.Amount,
|
||||||
|
}).ToList()
|
||||||
|
};
|
||||||
|
|
||||||
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