start new insurancelist operations
This commit is contained in:
@@ -7,7 +7,8 @@ namespace AccountManagement.Application.Contracts.Media
|
||||
public interface IMediaApplication
|
||||
{
|
||||
MediaViewModel Get(long id);
|
||||
OperationResult UploadFile(IFormFile file, string fileLabel, string relativePath, int maximumFileLength, List<string> allowedExtensions);
|
||||
OperationResult UploadFile(IFormFile file, string fileLabel, string relativePath, int maximumFileLength,
|
||||
List<string> allowedExtensions, string category);
|
||||
OperationResult MoveFile(long mediaId, string newRelativePath);
|
||||
OperationResult DeleteFile(long mediaId);
|
||||
List<MediaViewModel> GetRange(IEnumerable<long> select);
|
||||
|
||||
@@ -22,54 +22,20 @@ namespace AccountManagement.Application
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// دریافت فایل و نوشتن آن در مسیر داده شده، و ثبت مدیا
|
||||
/// </summary>
|
||||
/// <param name="file">فایل</param>
|
||||
/// <param name="fileLabel">برچسب فایل که در نام فایل ظاهر می شود</param>
|
||||
/// <param name="relativePath">مسیر فایل</param>
|
||||
/// <param name="allowedExtensions">[.png,.jpg,.jpeg] پسوند های مجاز مثلا </param>
|
||||
/// <param name="maximumFileLength">حداکثر حجم فایل به مگابایت</param>
|
||||
/// <returns></returns>
|
||||
public OperationResult UploadFile(IFormFile file, string fileLabel, string relativePath,int maximumFileLength,List<string> allowedExtensions)
|
||||
/// <summary>
|
||||
/// دریافت فایل و نوشتن آن در مسیر داده شده، و ثبت مدیا
|
||||
/// </summary>
|
||||
/// <param name="file">فایل</param>
|
||||
/// <param name="fileLabel">برچسب فایل که در نام فایل ظاهر می شود</param>
|
||||
/// <param name="relativePath">مسیر فایل</param>
|
||||
/// <param name="maximumFileLength">حداکثر حجم فایل به مگابایت</param>
|
||||
/// <param name="allowedExtensions">[.png,.jpg,.jpeg] پسوند های مجاز مثلا </param>
|
||||
/// <param name="category"></param>
|
||||
/// <returns></returns>
|
||||
public OperationResult UploadFile(IFormFile file, string fileLabel, string relativePath, int maximumFileLength,
|
||||
List<string> allowedExtensions, string category)
|
||||
{
|
||||
OperationResult op = new();
|
||||
var path = Path.Combine(_basePath, relativePath);
|
||||
var fileExtension = Path.GetExtension(file.FileName);
|
||||
|
||||
if (file == null || file.Length == 0)
|
||||
return op.Failed("خطای سیستمی");
|
||||
|
||||
if (file.Length > (maximumFileLength * 1024 * 1024))
|
||||
return op.Failed($"حجم فایل نمی تواند بیشتر از " +
|
||||
$"{maximumFileLength}" +
|
||||
$"مگابایت باشد");
|
||||
|
||||
if (!allowedExtensions.Contains(fileExtension.ToLower()))
|
||||
{
|
||||
var operationMessage = ":فرمت فایل باید یکی از موارد زیر باشد";
|
||||
operationMessage += "\n";
|
||||
operationMessage += string.Join(" ", allowedExtensions);
|
||||
return op.Failed(operationMessage);
|
||||
}
|
||||
|
||||
|
||||
Directory.CreateDirectory(path);
|
||||
|
||||
var extension = Path.GetExtension(file.FileName);
|
||||
|
||||
var uniqueFileName = $"{fileLabel}-{DateTime.Now.Ticks}{extension}";
|
||||
var filePath = Path.Combine(path, uniqueFileName);
|
||||
using (var fileStream = new FileStream(filePath, FileMode.CreateNew))
|
||||
{
|
||||
file.CopyTo(fileStream);
|
||||
}
|
||||
var mediaEntity = new Media(filePath, extension, "فایل", "EmployeeDocuments");
|
||||
_mediaRepository.Create(mediaEntity);
|
||||
_mediaRepository.SaveChanges();
|
||||
|
||||
return op.Succcedded(mediaEntity.id);
|
||||
|
||||
return _mediaRepository.UploadFile(file,fileLabel, relativePath, maximumFileLength, allowedExtensions, category);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
using System.Collections.Generic;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Domain;
|
||||
using AccountManagement.Application.Contracts.Media;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
|
||||
namespace AccountManagement.Domain.MediaAgg;
|
||||
|
||||
public interface IMediaRepository:IRepository<long,Media>
|
||||
{
|
||||
public string BasePath { get; protected set; }
|
||||
void CreateMediaWithTaskMedia(long taskId, long mediaId);
|
||||
List<MediaViewModel> GetMediaByTaskId(long taskId);
|
||||
void Remove(long id);
|
||||
@@ -23,4 +26,6 @@ public interface IMediaRepository:IRepository<long,Media>
|
||||
|
||||
#endregion
|
||||
|
||||
OperationResult UploadFile(IFormFile file, string fileLabel, string relativePath, int maximumFileLength,
|
||||
List<string> allowedExtensions, string category);
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.InfraStructure;
|
||||
using AccountManagement.Application.Contracts.Media;
|
||||
using AccountManagement.Domain.AdminResponseMediaAgg;
|
||||
@@ -7,19 +10,27 @@ using AccountManagement.Domain.ClientResponseMediaAgg;
|
||||
using AccountManagement.Domain.MediaAgg;
|
||||
using AccountManagement.Domain.TaskMediaAgg;
|
||||
using AccountManagement.Domain.TicketMediasAgg;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace AccountMangement.Infrastructure.EFCore.Repository;
|
||||
|
||||
public class MediaRepository:RepositoryBase<long,Media>,IMediaRepository
|
||||
{
|
||||
private const string _basePath = "Storage/Medias";
|
||||
public string BasePath { get; set; }
|
||||
|
||||
|
||||
private readonly AccountContext _accountContext;
|
||||
public MediaRepository( AccountContext taskManagerContext) : base(taskManagerContext)
|
||||
public MediaRepository( AccountContext taskManagerContext, IWebHostEnvironment webHostEnvironment) : base(taskManagerContext)
|
||||
{
|
||||
_accountContext = taskManagerContext;
|
||||
BasePath = webHostEnvironment.ContentRootPath+"/Storage";
|
||||
}
|
||||
//ساخت جدول واسط بین مدیا و نسک
|
||||
//نکته: این متد ذخیره انجام نمیدهد
|
||||
|
||||
public void CreateMediaWithTaskMedia(long taskId, long mediaId)
|
||||
{
|
||||
var Taskmedias = new TaskMedia(taskId,mediaId);
|
||||
@@ -77,6 +88,48 @@ public class MediaRepository:RepositoryBase<long,Media>,IMediaRepository
|
||||
{
|
||||
return _accountContext.Medias.Where(x => mediaIds.Contains(x.id)).ToList();
|
||||
}
|
||||
|
||||
public OperationResult UploadFile(IFormFile file, string fileLabel, string relativePath, int maximumFileLength,
|
||||
List<string> allowedExtensions, string category)
|
||||
{
|
||||
OperationResult op = new();
|
||||
var path = Path.Combine(_basePath, relativePath);
|
||||
var fileExtension = Path.GetExtension(file.FileName);
|
||||
|
||||
if (file == null || file.Length == 0)
|
||||
return op.Failed("خطای سیستمی");
|
||||
|
||||
if (file.Length > (maximumFileLength * 1024 * 1024))
|
||||
return op.Failed($"حجم فایل نمی تواند بیشتر از " +
|
||||
$"{maximumFileLength}" +
|
||||
$"مگابایت باشد");
|
||||
|
||||
if (!allowedExtensions.Contains(fileExtension.ToLower()))
|
||||
{
|
||||
var operationMessage = ":فرمت فایل باید یکی از موارد زیر باشد";
|
||||
operationMessage += "\n";
|
||||
operationMessage += string.Join(" ", allowedExtensions);
|
||||
return op.Failed(operationMessage);
|
||||
}
|
||||
|
||||
|
||||
Directory.CreateDirectory(path);
|
||||
|
||||
var extension = Path.GetExtension(file.FileName);
|
||||
|
||||
var uniqueFileName = $"{fileLabel}-{DateTime.Now.Ticks}{extension}";
|
||||
var filePath = Path.Combine(path, uniqueFileName);
|
||||
using (var fileStream = new FileStream(filePath, FileMode.CreateNew))
|
||||
{
|
||||
file.CopyTo(fileStream);
|
||||
}
|
||||
var mediaEntity = new Media(filePath, extension, "فایل", category);
|
||||
Create(mediaEntity);
|
||||
SaveChanges();
|
||||
|
||||
return op.Succcedded(mediaEntity.id);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Domain;
|
||||
using Company.Domain.InsuranceListAgg.ValueObjects;
|
||||
using Company.Domain.InsuranceWorkshopAgg;
|
||||
|
||||
namespace Company.Domain.InsuranceListAgg;
|
||||
@@ -166,7 +167,6 @@ public class InsuranceList : EntityBase
|
||||
public InsuranceListEmployerApproval EmployerApproval { get; set; } = new(InsuranceListEmployerApprovalStatus.None, string.Empty);
|
||||
#endregion
|
||||
|
||||
|
||||
public List<InsuranceListWorkshop> InsuranceListWorkshops { get; set; }
|
||||
|
||||
public void Edit(int sumOfEmployees, int sumOfWorkingDays, double sumOfSalaries, double sumOfBenefitsIncluded, double included,
|
||||
@@ -190,73 +190,22 @@ public class InsuranceList : EntityBase
|
||||
SumOfDailyWagePlusBaseYears = sumOfDailyWage + sumOfBaseYears;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class InsuranceListEmployerApproval
|
||||
{
|
||||
public InsuranceListEmployerApproval(InsuranceListEmployerApprovalStatus status, string description)
|
||||
public void SetDebt(InsuranceListDebt debt)
|
||||
{
|
||||
Status = status;
|
||||
Description = description;
|
||||
Debt = debt;
|
||||
}
|
||||
public void SetInspection(InsuranceListInspection inspection)
|
||||
{
|
||||
Inspection = inspection;
|
||||
}
|
||||
public void SetEmployerApproval(InsuranceListEmployerApproval employerApproval)
|
||||
{
|
||||
EmployerApproval = employerApproval;
|
||||
}
|
||||
public void SetConfirmSentlist(bool confirmSentlist)
|
||||
{
|
||||
ConfirmSentlist = confirmSentlist;
|
||||
}
|
||||
|
||||
public InsuranceListEmployerApprovalStatus Status { get; set; }
|
||||
public string Description { get; set; }
|
||||
}
|
||||
|
||||
public enum InsuranceListEmployerApprovalStatus
|
||||
{
|
||||
None,
|
||||
/// <summary>
|
||||
/// تاییدیه شفاهی (اذنی)
|
||||
/// </summary>
|
||||
VerbalApproval,
|
||||
/// <summary>
|
||||
/// تاییدیه کاغذی
|
||||
/// </summary>
|
||||
WrittenApproval
|
||||
}
|
||||
|
||||
public class InsuranceListDebt
|
||||
{
|
||||
public InsuranceListDebt(InsuranceListDebtType type, DateTime debtDate, double amount, long mediaId)
|
||||
{
|
||||
Type = type;
|
||||
DebtDate = debtDate;
|
||||
Amount = amount;
|
||||
MediaId = mediaId;
|
||||
}
|
||||
|
||||
public InsuranceListDebtType Type { get; set; }
|
||||
public DateTime DebtDate { get; set; }
|
||||
public double Amount { get; set; }
|
||||
public long MediaId { get; set; }
|
||||
}
|
||||
|
||||
public enum InsuranceListDebtType
|
||||
{
|
||||
None,
|
||||
Old,
|
||||
New
|
||||
}
|
||||
|
||||
public class InsuranceListInspection
|
||||
{
|
||||
public InsuranceListInspection(InsuraceListInspectionType type, DateTime lastInspectionDateTime, long mediaId)
|
||||
{
|
||||
Type = type;
|
||||
LastInspectionDateTime = lastInspectionDateTime;
|
||||
MediaId = mediaId;
|
||||
}
|
||||
|
||||
public InsuraceListInspectionType Type { get; set; }
|
||||
public DateTime LastInspectionDateTime { get; set; }
|
||||
public long MediaId { get; set; }
|
||||
}
|
||||
|
||||
public enum InsuraceListInspectionType
|
||||
{
|
||||
None,
|
||||
Old,
|
||||
New
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
|
||||
namespace Company.Domain.InsuranceListAgg.ValueObjects;
|
||||
|
||||
public class InsuranceListDebt
|
||||
{
|
||||
public InsuranceListDebt(InsuranceListDebtType type, DateTime debtDate, double amount, long mediaId)
|
||||
{
|
||||
Type = type;
|
||||
if (type == InsuranceListDebtType.None)
|
||||
{
|
||||
DebtDate = DateTime.MinValue;
|
||||
Amount = 0;
|
||||
MediaId = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
DebtDate = debtDate;
|
||||
Amount = amount;
|
||||
MediaId = mediaId;
|
||||
}
|
||||
}
|
||||
|
||||
public InsuranceListDebtType Type { get; set; }
|
||||
public DateTime DebtDate { get; set; }
|
||||
public double Amount { get; set; }
|
||||
public long MediaId { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace Company.Domain.InsuranceListAgg.ValueObjects;
|
||||
|
||||
public class InsuranceListEmployerApproval
|
||||
{
|
||||
public InsuranceListEmployerApproval(InsuranceListEmployerApprovalStatus status, string description)
|
||||
{
|
||||
Status = status;
|
||||
Description = status == InsuranceListEmployerApprovalStatus.None ? string.Empty : description;
|
||||
}
|
||||
|
||||
public InsuranceListEmployerApprovalStatus Status { get; set; }
|
||||
public string Description { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
|
||||
namespace Company.Domain.InsuranceListAgg.ValueObjects;
|
||||
|
||||
public class InsuranceListInspection
|
||||
{
|
||||
public InsuranceListInspection(InsuraceListInspectionType type, DateTime lastInspectionDateTime, long mediaId)
|
||||
{
|
||||
Type = type;
|
||||
if (type == InsuraceListInspectionType.None)
|
||||
{
|
||||
LastInspectionDateTime = DateTime.MinValue;
|
||||
MediaId = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
LastInspectionDateTime = lastInspectionDateTime;
|
||||
MediaId = mediaId;
|
||||
}
|
||||
}
|
||||
|
||||
public InsuraceListInspectionType Type { get; set; }
|
||||
public DateTime LastInspectionDateTime { get; set; }
|
||||
public long MediaId { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Company.Domain.InsuranceListAgg.ValueObjects;
|
||||
|
||||
public enum InsuraceListInspectionType
|
||||
{
|
||||
None,
|
||||
Old,
|
||||
New
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Company.Domain.InsuranceListAgg.ValueObjects;
|
||||
|
||||
public enum InsuranceListDebtType
|
||||
{
|
||||
None,
|
||||
Old,
|
||||
New
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace Company.Domain.InsuranceListAgg.ValueObjects;
|
||||
|
||||
public enum InsuranceListEmployerApprovalStatus
|
||||
{
|
||||
None,
|
||||
/// <summary>
|
||||
/// تاییدیه شفاهی (اذنی)
|
||||
/// </summary>
|
||||
VerbalApproval,
|
||||
/// <summary>
|
||||
/// تاییدیه کاغذی
|
||||
/// </summary>
|
||||
WrittenApproval
|
||||
}
|
||||
@@ -4,7 +4,9 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using Company.Domain.InsuranceListAgg.ValueObjects;
|
||||
using CompanyManagment.App.Contracts.InsuranceList;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.InsuranceList;
|
||||
|
||||
@@ -34,4 +36,14 @@ public interface IInsuranceListApplication
|
||||
//farokhiChanges
|
||||
(double basic, int totalYear) BasicYear(long employeeId, long worshopId, DateTime startDate);
|
||||
double GetMonthlyBaseYear(double dayliBase, int countWorkingDays);
|
||||
}
|
||||
|
||||
#region Mahan
|
||||
/// <summary>
|
||||
/// مراحل اجرایی برای تکمیل و ارسال لیست بیمه
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<OperationResult> ConfirmInsuranceOperation(InsuranceListConfirmOperation command);
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
using Company.Domain.InsuranceListAgg.ValueObjects;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.InsuranceList;
|
||||
|
||||
public class InsuranceListConfirmOperation
|
||||
{
|
||||
public long InsuranceListId { get; set; }
|
||||
public CreateInsuranceListInspection Inspection { get; set; }
|
||||
public CreateInsuranceListDebt Debt { get; set; }
|
||||
public CreateInsuranceListApproval Approval { get; set; }
|
||||
public bool ConfirmSentList { get; set; }
|
||||
}
|
||||
public class CreateInsuranceListApproval
|
||||
{
|
||||
public InsuranceListEmployerApprovalStatus ApprovalStatus { get; set; }
|
||||
public string Description { get; set; }
|
||||
}
|
||||
|
||||
public class CreateInsuranceListDebt
|
||||
{
|
||||
public InsuranceListDebtType Type { get; set; }
|
||||
public string DebtDate { get; set; }
|
||||
public string Amount { get; set; }
|
||||
public IFormFile DebtFile { get; set; }
|
||||
}
|
||||
|
||||
public class CreateInsuranceListInspection
|
||||
{
|
||||
public InsuraceListInspectionType Type { get; set; }
|
||||
public string LastInspectionDate { get; set; }
|
||||
public IFormFile InspectionFile { get; set; }
|
||||
}
|
||||
@@ -55,7 +55,7 @@ namespace CompanyManagment.Application
|
||||
if(command.BankLogoPictureFile != null && command.BankLogoPictureFile.Length >0 )
|
||||
{
|
||||
var uploadResult = _mediaApplication.UploadFile(command.BankLogoPictureFile, command.BankName,
|
||||
_basePath, 10, [".jpg", ".jpeg", ".png",".svg"]);
|
||||
_basePath, 10, [".jpg", ".jpeg", ".png",".svg"], "Bank");
|
||||
if (uploadResult.IsSuccedded == false)
|
||||
return uploadResult;
|
||||
mediaId = uploadResult.SendId;
|
||||
@@ -81,7 +81,7 @@ namespace CompanyManagment.Application
|
||||
if (command.BankLogoPictureFile != null && command.BankLogoPictureFile.Length > 0)
|
||||
{
|
||||
var uploadResult = _mediaApplication.UploadFile(command.BankLogoPictureFile, command.BankName,
|
||||
_basePath, 10, [".jpg", ".jpeg", ".png",".svg"]);
|
||||
_basePath, 10, [".jpg", ".jpeg", ".png",".svg"], "Bank");
|
||||
if (uploadResult.IsSuccedded == false)
|
||||
return uploadResult;
|
||||
_mediaApplication.DeleteFile(entity.BankLogoMediaId);
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Domain.CustomizeCheckoutShared.ValueObjects;
|
||||
using AccountManagement.Domain.MediaAgg;
|
||||
using Company.Domain.CheckoutAgg;
|
||||
using Company.Domain.DateSalaryAgg;
|
||||
using Company.Domain.DateSalaryItemAgg;
|
||||
@@ -15,6 +18,7 @@ using Company.Domain.empolyerAgg;
|
||||
using Company.Domain.InsuranceEmployeeInfoAgg;
|
||||
using Company.Domain.InsuranceJobItemAgg;
|
||||
using Company.Domain.InsuranceListAgg;
|
||||
using Company.Domain.InsuranceListAgg.ValueObjects;
|
||||
using Company.Domain.InsurancWorkshopInfoAgg;
|
||||
using Company.Domain.LeftWorkAgg;
|
||||
using Company.Domain.LeftWorkInsuranceAgg;
|
||||
@@ -32,10 +36,12 @@ using CompanyManagment.App.Contracts.YearlySalary;
|
||||
using CompanyManagment.App.Contracts.YearlySalaryItems;
|
||||
using CompanyManagment.EFCore.Migrations;
|
||||
using MD.PersianDateTime.Standard;
|
||||
using Microsoft.AspNetCore.Authorization.Infrastructure;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace CompanyManagment.Application;
|
||||
|
||||
public class InsuranceListApplication: IInsuranceListApplication
|
||||
public class InsuranceListApplication : IInsuranceListApplication
|
||||
{
|
||||
|
||||
//private readonly ITransactionManager _transactionManager;
|
||||
@@ -57,11 +63,11 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
private readonly ILeftWorkInsuranceRepository _leftWorkInsuranceRepository;
|
||||
private readonly IInsuranceYearlySalaryApplication _insuranceYearlySalaryApplication;
|
||||
private readonly ICheckoutRepository _checkoutRepository;
|
||||
|
||||
public InsuranceListApplication( IInsuranceListRepository insuranceListRepositpry, IEmployeeInsurancListDataRepository employeeInsurancListDataRepository, IInsuranceEmployeeInfoRepository insuranceEmployeeInfoRepository, IEmployeeRepository employeeRepository, IWorkshopRepository workShopRepository, ILeftWorkInsuranceApplication leftWorkInsuranceApplication, IInsuranceEmployeeInfoApplication insuranceEmployeeInfoApplication, IEmployeeInsurancListDataApplication employeeInsurancListDataApplication, IYearlySalaryApplication yearlySalaryApplication,IYearlySalaryItemApplication yearlySalaryItemApplication ,IInsuranceWorkshopInfoRepository insuranceWorkshopInfoRepository,IInsuranceJobItemRepositpry insuranceJobItemRepository, IDateSalaryRepository dateSalaryRepository, IDateSalaryItemRepository dateSalaryItemRepository, IPersonalContractingPartyApp contractingPartyApp, ILeftWorkInsuranceRepository leftWorkInsuranceRepository, IInsuranceYearlySalaryApplication insuranceYearlySalaryApplication, ICheckoutRepository checkoutRepository)
|
||||
private readonly IMediaRepository _mediaRepository;
|
||||
public InsuranceListApplication(IInsuranceListRepository insuranceListRepositpry, IEmployeeInsurancListDataRepository employeeInsurancListDataRepository, IInsuranceEmployeeInfoRepository insuranceEmployeeInfoRepository, IEmployeeRepository employeeRepository, IWorkshopRepository workShopRepository, ILeftWorkInsuranceApplication leftWorkInsuranceApplication, IInsuranceEmployeeInfoApplication insuranceEmployeeInfoApplication, IEmployeeInsurancListDataApplication employeeInsurancListDataApplication, IYearlySalaryApplication yearlySalaryApplication, IYearlySalaryItemApplication yearlySalaryItemApplication, IInsuranceWorkshopInfoRepository insuranceWorkshopInfoRepository, IInsuranceJobItemRepositpry insuranceJobItemRepository, IDateSalaryRepository dateSalaryRepository, IDateSalaryItemRepository dateSalaryItemRepository, IPersonalContractingPartyApp contractingPartyApp, ILeftWorkInsuranceRepository leftWorkInsuranceRepository, IInsuranceYearlySalaryApplication insuranceYearlySalaryApplication, ICheckoutRepository checkoutRepository, IMediaRepository mediaRepository)
|
||||
{
|
||||
// _transactionManager = transactionManager;
|
||||
|
||||
|
||||
_insuranceListRepositpry = insuranceListRepositpry;
|
||||
_employeeInsurancListDataRepository = employeeInsurancListDataRepository;
|
||||
_insuranceEmployeeInfoRepository = insuranceEmployeeInfoRepository;
|
||||
@@ -80,21 +86,22 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
_leftWorkInsuranceRepository = leftWorkInsuranceRepository;
|
||||
_insuranceYearlySalaryApplication = insuranceYearlySalaryApplication;
|
||||
_checkoutRepository = checkoutRepository;
|
||||
_mediaRepository = mediaRepository;
|
||||
}
|
||||
|
||||
public OperationResult Create(CreateInsuranceList command)
|
||||
{
|
||||
|
||||
|
||||
var operation = new OperationResult();
|
||||
if (command.WorkshopId==0 )
|
||||
if (command.WorkshopId == 0)
|
||||
{
|
||||
return operation.Failed(" انتخاب کارگاه اجباری می باشد ");
|
||||
}
|
||||
if ( command.Month == "0" )
|
||||
if (command.Month == "0")
|
||||
{
|
||||
return operation.Failed(" انتخاب ماه اجباری می باشد ");
|
||||
}
|
||||
if ( command.Year == "0")
|
||||
if (command.Year == "0")
|
||||
{
|
||||
return operation.Failed("انتخاب سال اجباری می باشد ");
|
||||
}
|
||||
@@ -171,7 +178,7 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
|
||||
public OperationResult Edit(EditInsuranceList command)
|
||||
{
|
||||
|
||||
|
||||
var operation = new OperationResult();
|
||||
if (command.WorkshopId == 0)
|
||||
{
|
||||
@@ -185,7 +192,7 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
{
|
||||
return operation.Failed("انتخاب سال اجباری می باشد ");
|
||||
}
|
||||
else if (_insuranceListRepositpry.Exists(x =>x.id!=command.Id && x.WorkshopId == command.WorkshopId && x.Month == command.Month && x.Year == command.Year))
|
||||
else if (_insuranceListRepositpry.Exists(x => x.id != command.Id && x.WorkshopId == command.WorkshopId && x.Month == command.Month && x.Year == command.Year))
|
||||
{
|
||||
return operation.Failed(" لیست بیمه برای کارگاه، سال و ماه انتخاب شده قبلا ایجاد شده است ");
|
||||
}
|
||||
@@ -211,7 +218,7 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
createInsuranceEmployeeInfo.Gender = item.Gender;
|
||||
createInsuranceEmployeeInfo.InsuranceCode = item.InsuranceCode;
|
||||
createInsuranceEmployeeInfo.DateOfBirthGr = item.DateOfBirth.ToGeorgianDateTime();
|
||||
createInsuranceEmployeeInfo.DateOfIssueGr =!string.IsNullOrEmpty(item.DateOfIssue)? item.DateOfIssue.ToGeorgianDateTime(): "1300/10/11".ToGeorgianDateTime();
|
||||
createInsuranceEmployeeInfo.DateOfIssueGr = !string.IsNullOrEmpty(item.DateOfIssue) ? item.DateOfIssue.ToGeorgianDateTime() : "1300/10/11".ToGeorgianDateTime();
|
||||
_insuranceEmployeeInfoApplication.Create(createInsuranceEmployeeInfo);
|
||||
}
|
||||
else
|
||||
@@ -266,8 +273,8 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
|
||||
return operation;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public EditInsuranceList GetDetails(long id)
|
||||
{
|
||||
@@ -302,8 +309,8 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
|
||||
foreach (var item in insuranceListDetails.EmployeeDetailsForInsuranceList)
|
||||
{
|
||||
|
||||
item.IncludeStatus = _leftWorkInsuranceApplication.GetLeftPersonelByWorkshopIdAndEmployeeId(insuranceListDetails.WorkshopId,item.EmployeeId).IncludeStatus;
|
||||
|
||||
item.IncludeStatus = _leftWorkInsuranceApplication.GetLeftPersonelByWorkshopIdAndEmployeeId(insuranceListDetails.WorkshopId, item.EmployeeId).IncludeStatus;
|
||||
if (!string.IsNullOrEmpty(item.LeftWorkDate))
|
||||
{
|
||||
var yearEndDateUser = Convert.ToInt32(item.LeftWorkDate.Substring(0, 4));
|
||||
@@ -348,7 +355,7 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
return insuranceListDetails;
|
||||
}
|
||||
|
||||
public List<InsuranceListViewModel> Search(InsuranceListSearchModel searchModel)
|
||||
public List<InsuranceListViewModel> Search(InsuranceListSearchModel searchModel)
|
||||
{
|
||||
return _insuranceListRepositpry.OptimizedSearch(searchModel);
|
||||
//var result = _insuranceListRepositpry.Search(searchModel);
|
||||
@@ -380,10 +387,10 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
/// </summary>
|
||||
/// <param name="searchModel"></param>
|
||||
/// <returns></returns>
|
||||
public MainEmployeeDetailsViewModel SearchEmployeeForCreateInsuranceList( EmployeeForCreateInsuranceListSearchModel searchModel)
|
||||
public MainEmployeeDetailsViewModel SearchEmployeeForCreateInsuranceList(EmployeeForCreateInsuranceListSearchModel searchModel)
|
||||
{
|
||||
var watch = new Stopwatch();
|
||||
|
||||
var watch = new Stopwatch();
|
||||
|
||||
var result = new MainEmployeeDetailsViewModel();
|
||||
var workshopId = searchModel.WorkshopIds.FirstOrDefault();
|
||||
var workshop = _workShopRepository.GetDetails(workshopId);
|
||||
@@ -392,30 +399,30 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
double monthlybaseYear = 0;
|
||||
// اگر در این سال و ماه برای این کارگاه لیست بیمه ایجاد نشده بود
|
||||
if (!_insuranceListRepositpry.Exists(x =>
|
||||
x.Year == searchModel.Year && x.Month == searchModel.Month &&
|
||||
searchModel.WorkshopIds.Contains(x.WorkshopId)))
|
||||
x.Year == searchModel.Year && x.Month == searchModel.Month &&
|
||||
searchModel.WorkshopIds.Contains(x.WorkshopId)))
|
||||
{
|
||||
|
||||
var startMonthFa = $"{searchModel.Year}/{searchModel.Month.PadLeft(2, '0')}/01";
|
||||
DateTime startDateGr = startMonthFa.ToGeorgianDateTime();
|
||||
DateTime endDateGr = startMonthFa.FindeEndOfMonth()
|
||||
.ToGeorgianDateTime();
|
||||
DateTime endDateGr = startMonthFa.FindeEndOfMonth()
|
||||
.ToGeorgianDateTime();
|
||||
int endOfMonth = Convert.ToInt32((startMonthFa.FindeEndOfMonth()).Substring(8, 2));
|
||||
|
||||
|
||||
//مقادیر سالانه این تاریخ
|
||||
var yearlysaleries = _yearlySalaryApplication.GetInsuranceItems(startDateGr, endDateGr, searchModel.Year);
|
||||
|
||||
//مقادیر سالانه این تاریخ
|
||||
var yearlysaleries = _yearlySalaryApplication.GetInsuranceItems(startDateGr, endDateGr, searchModel.Year);
|
||||
|
||||
|
||||
// دریافت اطلاعات هویتی و شروع و ترک کار کارکنان
|
||||
var employeesInfoAndLeftWorks =
|
||||
_leftWorkInsuranceApplication.GetEmployeeInsuranceLeftWorksAndInformation(workshopId, startDateGr,
|
||||
endDateGr);
|
||||
// دریافت اطلاعات هویتی و شروع و ترک کار کارکنان
|
||||
var employeesInfoAndLeftWorks =
|
||||
_leftWorkInsuranceApplication.GetEmployeeInsuranceLeftWorksAndInformation(workshopId, startDateGr,
|
||||
endDateGr);
|
||||
|
||||
var employeeInsurancDataPreviusList =
|
||||
_insuranceListRepositpry.GetEmployeeInsuranceDataAmonthAgo(startDateGr, workshopId);
|
||||
watch.Start();
|
||||
var computeResult = employeesInfoAndLeftWorks.Select(employee =>
|
||||
watch.Start();
|
||||
var computeResult = employeesInfoAndLeftWorks.Select(employee =>
|
||||
{
|
||||
var dateOfBirth = employee.DateOfBirthGr.ToFarsi();
|
||||
var dateOfIssue = employee.DateOfIssueGr.ToFarsi();
|
||||
@@ -426,7 +433,7 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
//آیا در کارگاه تیک محاسبه اضافه کار یا حق اولاد زده شده است؟
|
||||
bool hasWorkshopOverTimeOrFamilyAllowance =
|
||||
workshop.InsuranceCheckoutFamilyAllowance || workshop.InsuranceCheckoutOvertime;
|
||||
|
||||
|
||||
//آیا پرسنل فیش حقوق دارد
|
||||
//این مورد زمانی چک می شود که تیک محاسبه در کارگاه زده شده باشد
|
||||
// در غیر اینصورت بصورت پیشفرض دارای فیش حقوق در نظر گرفته می شود
|
||||
@@ -439,10 +446,10 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
searchModel.Year, searchModel.Month);
|
||||
if (checkout.hasChekout)
|
||||
{
|
||||
|
||||
|
||||
familyAllowance = checkout.FamilyAlloance;
|
||||
overTimePay = checkout.OverTimePay;
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -451,9 +458,9 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
}
|
||||
|
||||
|
||||
|
||||
var workingDays = Tools.GetEmployeeInsuranceWorkingDays(employee.StartWorkDateGr, leftDate, startDateGr,endDateGr, employee.EmployeeId);
|
||||
var leftWorkFa = workingDays.hasLeftWorkInMonth ? employee.LeftWorkDateGr.ToFarsi(): "";
|
||||
|
||||
var workingDays = Tools.GetEmployeeInsuranceWorkingDays(employee.StartWorkDateGr, leftDate, startDateGr, endDateGr, employee.EmployeeId);
|
||||
var leftWorkFa = workingDays.hasLeftWorkInMonth ? employee.LeftWorkDateGr.ToFarsi() : "";
|
||||
var startWorkFa = employee.StartWorkDateGr.ToFarsi();
|
||||
//به دست آوردن دستمزد روزانه با توجه به اینکه کارگاه مشاغل مقطوع است یا خیر
|
||||
|
||||
@@ -463,34 +470,34 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
var res = GetDailyWageFixedSalary(searchModel.Year, workshopId, employee.EmployeeId, startDateGr,
|
||||
endDateGr, employee.JobId, searchModel.Population, searchModel.InsuranceJobId);
|
||||
dailyWage = res ?? 0;
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
var res = ComputeDailyWage(yearlysaleries.DayliWage, employee.EmployeeId, workshopId, searchModel.Year);
|
||||
dailyWage = res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//بدست آوردن پایه سنوات
|
||||
var baseYears = _insuranceListRepositpry.GetEmployeeInsuranceBaseYear(employee.EmployeeId, workshopId,
|
||||
workingDays.countWorkingDays, startDateGr, endDateGr,workingDays.startWork, workingDays.endWork, workingDays.hasLeftWorkInMonth);
|
||||
workingDays.countWorkingDays, startDateGr, endDateGr, workingDays.startWork, workingDays.endWork, workingDays.hasLeftWorkInMonth);
|
||||
//آیا کارفرما یا مدیر عامل است؟
|
||||
|
||||
baseYears.baseYear = isManager ? 0 : baseYears.baseYear;
|
||||
Console.WriteLine(employee.JobId + " - "+ baseYears.baseYear);
|
||||
//جمع مزد روزانه و پایه سنوات
|
||||
var dailyWagePlusBaseYears = dailyWage + baseYears.baseYear;
|
||||
|
||||
|
||||
//دستمزد ماهانه با محاسبه پایه سنوات
|
||||
baseYears.baseYear = isManager ? 0 : baseYears.baseYear;
|
||||
Console.WriteLine(employee.JobId + " - " + baseYears.baseYear);
|
||||
//جمع مزد روزانه و پایه سنوات
|
||||
var dailyWagePlusBaseYears = dailyWage + baseYears.baseYear;
|
||||
|
||||
|
||||
//دستمزد ماهانه با محاسبه پایه سنوات
|
||||
var monthlySalary = GetRoundValue(dailyWagePlusBaseYears * workingDays.countWorkingDays);
|
||||
|
||||
//حق تاهل
|
||||
var marriedAllowance = employee.MaritalStatus == "متاهل" && !isManager ? yearlysaleries.MarriedAllowance : 0;
|
||||
|
||||
//محاسبه مزایای ماهانه
|
||||
var monthlyBenefits = GetMonthlyBenefits(endOfMonth, yearlysaleries.ConsumableItems, yearlysaleries.HousingAllowance, marriedAllowance, workingDays.countWorkingDays, searchModel.TypeOfInsuranceSendWorkshop, employee.JobId, employee.EmployeeId,employee.IncludeStatus);
|
||||
var monthlyBenefits = GetMonthlyBenefits(endOfMonth, yearlysaleries.ConsumableItems, yearlysaleries.HousingAllowance, marriedAllowance, workingDays.countWorkingDays, searchModel.TypeOfInsuranceSendWorkshop, employee.JobId, employee.EmployeeId, employee.IncludeStatus);
|
||||
|
||||
//if (employee.EmployeeId is 7999)// سید عباس خوشکلام سلیمان
|
||||
// monthlyBenefits = 80869389;
|
||||
@@ -501,7 +508,7 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
|
||||
monthlyBenefits = GetRoundValue(monthlyBenefits += overTimePay);
|
||||
}
|
||||
|
||||
|
||||
//سرای ملک
|
||||
// نوشین خالی
|
||||
// 39692467
|
||||
@@ -509,13 +516,13 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
// monthlyBenefits += 39692467;
|
||||
|
||||
var marriedAllowanceCompute = MarriedAllowance(employee.MaritalStatus, employee.JobId, employee.IncludeStatus,
|
||||
workingDays.countWorkingDays, yearlysaleries.MarriedAllowance, endOfMonth);
|
||||
//محاسبه جمع مزایای مشمول و دستمزد ماهانه
|
||||
var benefitsIncludedContinuous = monthlyBenefits + monthlySalary;
|
||||
workingDays.countWorkingDays, yearlysaleries.MarriedAllowance, endOfMonth);
|
||||
//محاسبه جمع مزایای مشمول و دستمزد ماهانه
|
||||
var benefitsIncludedContinuous = monthlyBenefits + monthlySalary;
|
||||
|
||||
//benefitsIncludedContinuous = employee.JobId != 16 ? benefitsIncludedContinuous : 0;
|
||||
//محاسبه حق بیمه سهم بیمه شده
|
||||
var insuranceShare = (benefitsIncludedContinuous * 7) / 100;
|
||||
//benefitsIncludedContinuous = employee.JobId != 16 ? benefitsIncludedContinuous : 0;
|
||||
//محاسبه حق بیمه سهم بیمه شده
|
||||
var insuranceShare = (benefitsIncludedContinuous * 7) / 100;
|
||||
|
||||
//محاسبه حق بیمه سهم کارفرما
|
||||
var employerShare = (benefitsIncludedContinuous * 20) / 100;
|
||||
@@ -535,30 +542,30 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
benefitsIncludedNonContinuous = GetRoundValue(benefitsIncludedNonContinuous + familyAllowance);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var includedAndNotIncluded = benefitsIncludedContinuous + benefitsIncludedNonContinuous;
|
||||
|
||||
|
||||
return new EmployeeDetailsForInsuranceListViewModel
|
||||
{
|
||||
#region EmployeeInfo
|
||||
{
|
||||
#region EmployeeInfo
|
||||
EmployeeHasCheckout = employeeHasCheckout,
|
||||
InsuranceEmployeeInformationId = employee.InsuranceEmployeeInformationId,
|
||||
EmployeeId = employee.EmployeeId,
|
||||
FName = employee.FName,
|
||||
LName = employee.LName,
|
||||
FatherName = employee.FatherName,
|
||||
DateOfBirth = dateOfBirth == "1300/10/11" ? "" : dateOfBirth,
|
||||
DateOfIssue = dateOfIssue,
|
||||
DateOfBirthGr = employee.DateOfBirthGr,
|
||||
DateOfIssueGr = employee.DateOfIssueGr,
|
||||
PlaceOfIssue = employee.PlaceOfIssue,
|
||||
IdNumber = employee.IdNumber,
|
||||
Gender = employee.Gender,
|
||||
NationalCode = employee.NationalCode,
|
||||
Nationality = employee.Nationality,
|
||||
InsuranceCode = employee.InsuranceCode,
|
||||
EmployeeId = employee.EmployeeId,
|
||||
FName = employee.FName,
|
||||
LName = employee.LName,
|
||||
FatherName = employee.FatherName,
|
||||
DateOfBirth = dateOfBirth == "1300/10/11" ? "" : dateOfBirth,
|
||||
DateOfIssue = dateOfIssue,
|
||||
DateOfBirthGr = employee.DateOfBirthGr,
|
||||
DateOfIssueGr = employee.DateOfIssueGr,
|
||||
PlaceOfIssue = employee.PlaceOfIssue,
|
||||
IdNumber = employee.IdNumber,
|
||||
Gender = employee.Gender,
|
||||
NationalCode = employee.NationalCode,
|
||||
Nationality = employee.Nationality,
|
||||
InsuranceCode = employee.InsuranceCode,
|
||||
// آیا وضعیت تاهل پرسنل ست شده است
|
||||
IsMaritalStatusSet = !string.IsNullOrWhiteSpace(employee.MaritalStatus),
|
||||
MaritalStatus = employee.MaritalStatus,
|
||||
@@ -582,7 +589,7 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
IncludeStatus = employee.IncludeStatus,
|
||||
|
||||
//دستمزد روزانه
|
||||
DailyWage = GetRoundValue(dailyWage),
|
||||
DailyWage = GetRoundValue(dailyWage),
|
||||
DailyWageStr = dailyWage.ToMoney(),
|
||||
|
||||
HasConfilictJobs = dailyWage == 0,
|
||||
@@ -598,13 +605,13 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
|
||||
//دستمزد ماهانه
|
||||
MonthlySalary = monthlySalary,
|
||||
|
||||
|
||||
|
||||
|
||||
//مزایای ماهانه
|
||||
MonthlyBenefits = monthlyBenefits,
|
||||
|
||||
//جمع مزایای مشمول و دستمزد ماهانه
|
||||
BenefitsIncludedContinuous = benefitsIncludedContinuous,
|
||||
//جمع مزایای مشمول و دستمزد ماهانه
|
||||
BenefitsIncludedContinuous = benefitsIncludedContinuous,
|
||||
|
||||
//مزایای غیر مشمول *
|
||||
BenefitsIncludedNonContinuous = benefitsIncludedNonContinuous,
|
||||
@@ -636,9 +643,9 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
|
||||
|
||||
};
|
||||
}).ToList();
|
||||
}).ToList();
|
||||
Console.WriteLine("New Compute : " + watch.Elapsed);
|
||||
watch.Stop();
|
||||
watch.Stop();
|
||||
|
||||
watch.Start();
|
||||
|
||||
@@ -951,28 +958,28 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
result.IsExist = true;
|
||||
result.IsBlock = isBolock;
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public double MarriedAllowance(string maritalStatus,long jobId, bool includedStatus,
|
||||
int countWorkingDays, double marriedAlowance,int endMonthCurrentDay)
|
||||
public double MarriedAllowance(string maritalStatus, long jobId, bool includedStatus,
|
||||
int countWorkingDays, double marriedAlowance, int endMonthCurrentDay)
|
||||
{
|
||||
bool isManager = jobId is 10 or 16 or 17 or 18 or 3498;
|
||||
if (isManager)//اگر مدیر عامل بود
|
||||
return 0;
|
||||
if (maritalStatus != "متاهل")//اگر مجرد بود
|
||||
return 0;
|
||||
|
||||
if(countWorkingDays == endMonthCurrentDay)
|
||||
return (marriedAlowance);
|
||||
bool isManager = jobId is 10 or 16 or 17 or 18 or 3498;
|
||||
if (isManager)//اگر مدیر عامل بود
|
||||
return 0;
|
||||
if (maritalStatus != "متاهل")//اگر مجرد بود
|
||||
return 0;
|
||||
|
||||
if (countWorkingDays == endMonthCurrentDay)
|
||||
return (marriedAlowance);
|
||||
|
||||
return endMonthCurrentDay switch
|
||||
{
|
||||
29 => GetRoundValue((marriedAlowance / 29) * countWorkingDays),
|
||||
30 => GetRoundValue((marriedAlowance / 30) * countWorkingDays),
|
||||
31 => GetRoundValue((marriedAlowance / 31) * countWorkingDays),
|
||||
_ => marriedAlowance
|
||||
29 => GetRoundValue((marriedAlowance / 29) * countWorkingDays),
|
||||
30 => GetRoundValue((marriedAlowance / 30) * countWorkingDays),
|
||||
31 => GetRoundValue((marriedAlowance / 31) * countWorkingDays),
|
||||
_ => marriedAlowance
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1147,9 +1154,9 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
string strValue = value.ToString();
|
||||
if (strValue.IndexOf('.') > -1)
|
||||
{
|
||||
|
||||
|
||||
string a = strValue.Substring(strValue.IndexOf('.')+1, 1);
|
||||
|
||||
string a = strValue.Substring(strValue.IndexOf('.') + 1, 1);
|
||||
if (int.Parse(a) > 5)
|
||||
{
|
||||
return (Math.Round(value, MidpointRounding.ToPositiveInfinity));
|
||||
@@ -1166,13 +1173,13 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
//محاسبه پرسنل در جدول - DSKWOR EDIT
|
||||
public MainEmployeeDetailsViewModel SearchEmployeeListForEditByInsuranceListId(EmployeeForEditInsuranceListSearchModel searchModel)
|
||||
{
|
||||
var mainEmployeeDetailsViewModel= new MainEmployeeDetailsViewModel();
|
||||
var mainEmployeeDetailsViewModel2= new MainEmployeeDetailsViewModel();
|
||||
var mainEmployeeDetailsViewModelForNewPersonel= new MainEmployeeDetailsViewModel();
|
||||
var mainEmployeeDetailsViewModel = new MainEmployeeDetailsViewModel();
|
||||
var mainEmployeeDetailsViewModel2 = new MainEmployeeDetailsViewModel();
|
||||
var mainEmployeeDetailsViewModelForNewPersonel = new MainEmployeeDetailsViewModel();
|
||||
|
||||
List<long> ids = searchModel.WorkshopIds.Where(x=>x!=searchModel.WorkshopId).ToList();
|
||||
List<long> ids = searchModel.WorkshopIds.Where(x => x != searchModel.WorkshopId).ToList();
|
||||
searchModel.Month = searchModel.Month.PadLeft(2, '0');
|
||||
if (!_insuranceListRepositpry.Exists(x => x.Year == searchModel.Year && x.Month == searchModel.Month && (ids!=null && ids.Count > 0 && ids.Contains(x.WorkshopId))))
|
||||
if (!_insuranceListRepositpry.Exists(x => x.Year == searchModel.Year && x.Month == searchModel.Month && (ids != null && ids.Count > 0 && ids.Contains(x.WorkshopId))))
|
||||
{
|
||||
|
||||
mainEmployeeDetailsViewModel = _insuranceListRepositpry.SearchEmployeeListForEditByInsuranceListId(searchModel);
|
||||
@@ -1194,11 +1201,11 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
var searchModelForCreate = new EmployeeForCreateInsuranceListSearchModel();
|
||||
searchModelForCreate.Month = searchModel.Month;
|
||||
searchModelForCreate.Year = searchModel.Year;
|
||||
searchModelForCreate.WorkshopIds=new List<long>(){ searchModel.WorkshopId };
|
||||
searchModelForCreate.WorkshopIds = new List<long>() { searchModel.WorkshopId };
|
||||
var leftWorkInsuranceViewModelList = _leftWorkInsuranceApplication.SearchForCreateInsuranceList(searchModelForCreate);
|
||||
var newEmployeeId = leftWorkInsuranceViewModelList.Select(x => x.EmployeeId).ToList();
|
||||
var oldEmployeeId = mainEmployeeDetailsViewModel.EmployeeDetailsForInsuranceList.Select(x => x.EmployeeId).ToList();
|
||||
if(!newEmployeeId.SequenceEqual(oldEmployeeId))
|
||||
if (!newEmployeeId.SequenceEqual(oldEmployeeId))
|
||||
{
|
||||
var employeeAddIds = new List<long>();
|
||||
var employeeRemoveIds = new List<long>();
|
||||
@@ -1223,14 +1230,14 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
if (employeeAddIds != null && employeeAddIds.Count > 0)
|
||||
{
|
||||
leftWorkInsuranceViewModelList = leftWorkInsuranceViewModelList.Where(x => employeeAddIds.Contains(x.EmployeeId)).ToList();
|
||||
mainEmployeeDetailsViewModelForNewPersonel = GetEmployeeForInsuranceList(leftWorkInsuranceViewModelList,searchModel);
|
||||
mainEmployeeDetailsViewModelForNewPersonel = GetEmployeeForInsuranceList(leftWorkInsuranceViewModelList, searchModel);
|
||||
if (mainEmployeeDetailsViewModelForNewPersonel.EmployeeDetailsForInsuranceList != null &&
|
||||
mainEmployeeDetailsViewModelForNewPersonel.EmployeeDetailsForInsuranceList.Count > 0)
|
||||
{
|
||||
mainEmployeeDetailsViewModel.EmployeeDetailsForInsuranceList = mainEmployeeDetailsViewModel.EmployeeDetailsForInsuranceList.Union(mainEmployeeDetailsViewModelForNewPersonel.EmployeeDetailsForInsuranceList).ToList();
|
||||
}
|
||||
}
|
||||
if (employeeRemoveIds != null && employeeRemoveIds.Count>0)
|
||||
if (employeeRemoveIds != null && employeeRemoveIds.Count > 0)
|
||||
{
|
||||
mainEmployeeDetailsViewModel.EmployeeDetailsForInsuranceList = mainEmployeeDetailsViewModel
|
||||
.EmployeeDetailsForInsuranceList.Where(x => !employeeRemoveIds.Contains(x.EmployeeId))
|
||||
@@ -1251,12 +1258,12 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
var day = 1;
|
||||
var persianCurrentStartDate = new PersianDateTime(year, month, day);
|
||||
var persianCurrentEndDate = new PersianDateTime(year, month, dayMonthCurrent);
|
||||
|
||||
|
||||
var model = new YearlySalarySearchModel();
|
||||
model.StartDateGr = startMonthCurrent.ToGeorgianDateTime();
|
||||
model.EndDateGr = endMonthCurrent.ToGeorgianDateTime();
|
||||
model.year = searchModel.Year;
|
||||
|
||||
|
||||
var yearlysalaryItem = new YearlysalaryItemViewModel();
|
||||
var housingAllowance = new YearlysalaryItemViewModel();
|
||||
var consumableItems = new YearlysalaryItemViewModel();
|
||||
@@ -1270,7 +1277,7 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
int endWork = 0;
|
||||
item.IsMaritalStatusSet = // آیا وضعیت تاهل پرسنل ست شده است
|
||||
!string.IsNullOrWhiteSpace(employeeObject.MaritalStatus);
|
||||
|
||||
|
||||
#region HasConfilictLeftWork
|
||||
|
||||
bool hasConfilict = false;
|
||||
@@ -1325,7 +1332,7 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
}
|
||||
|
||||
//ترک کارش در ماه و سال جاری بود نمایش داده شود
|
||||
if (!string.IsNullOrEmpty(item.LeftWorkDate) && !item.LeftWorkDate.Contains(searchModel.Year+"/"+searchModel.Month ) )
|
||||
if (!string.IsNullOrEmpty(item.LeftWorkDate) && !item.LeftWorkDate.Contains(searchModel.Year + "/" + searchModel.Month))
|
||||
{
|
||||
item.LeftWorkDate = string.Empty;
|
||||
item.LeftWorkDateGr = null;
|
||||
@@ -1366,8 +1373,8 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
var monthStartDateUser = Convert.ToInt32(item.StartWorkDate.Substring(5, 2));
|
||||
var dayStartDateUser = Convert.ToInt32(item.StartWorkDate.Substring(8, 2));
|
||||
var persianStartDateUser = new PersianDateTime(yearStartDateUser, monthStartDateUser, dayStartDateUser);
|
||||
|
||||
if(persianStartDateUser <= persianCurrentStartDate)
|
||||
|
||||
if (persianStartDateUser <= persianCurrentStartDate)
|
||||
{
|
||||
startWork = 1;
|
||||
}
|
||||
@@ -1376,18 +1383,18 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
startWork = dayStartDateUser;
|
||||
}
|
||||
|
||||
if(persianStartDateUser < persianCurrentStartDate)
|
||||
if (persianStartDateUser < persianCurrentStartDate)
|
||||
item.HasStartWorkInMonth = false;
|
||||
else
|
||||
item.HasStartWorkInMonth = true;
|
||||
|
||||
|
||||
|
||||
if (hasConfilict) //اگر ترک کار شخص تغییر کرده بود، دوباره محاسبه شود
|
||||
{
|
||||
item.StartMonthCurrent = startMonthCurrent;
|
||||
item.HousingAllowance = housingAllowance.ItemValue;
|
||||
item.ConsumableItems = consumableItems.ItemValue;
|
||||
item.DailyWage= ComputeDailyWage(yearlysalaryItem.ItemValue, item.EmployeeId, searchModel.WorkshopId, searchModel.Year);
|
||||
item.DailyWage = ComputeDailyWage(yearlysalaryItem.ItemValue, item.EmployeeId, searchModel.WorkshopId, searchModel.Year);
|
||||
item.DailyWageStr = item.DailyWage.ToMoney();
|
||||
}
|
||||
else
|
||||
@@ -1447,15 +1454,15 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
item.UnEmploymentInsurance = GetRoundValue(unEmploymentInsurance);
|
||||
|
||||
// item.BenefitsIncludedNonContinuous = item.BenefitsIncludedContinuous;
|
||||
item.IncludedAndNotIncluded = item.BenefitsIncludedContinuous + item.BenefitsIncludedNonContinuous;
|
||||
item.IncludedAndNotIncluded = item.BenefitsIncludedContinuous + item.BenefitsIncludedNonContinuous;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (mainEmployeeDetailsViewModel2.EmployeeDetailsForInsuranceList!=null && mainEmployeeDetailsViewModel2.EmployeeDetailsForInsuranceList.Count>0)
|
||||
if (mainEmployeeDetailsViewModel2.EmployeeDetailsForInsuranceList != null && mainEmployeeDetailsViewModel2.EmployeeDetailsForInsuranceList.Count > 0)
|
||||
mainEmployeeDetailsViewModel.EmployeeDetailsForInsuranceList = mainEmployeeDetailsViewModel.EmployeeDetailsForInsuranceList.Union(mainEmployeeDetailsViewModel2.EmployeeDetailsForInsuranceList).OrderByDescending(x => x.HasLeftWorkInMonth).ThenByDescending(x => x.HasStartWorkInMonth).ThenBy(x => x.LName).ToList();
|
||||
else
|
||||
mainEmployeeDetailsViewModel.EmployeeDetailsForInsuranceList = mainEmployeeDetailsViewModel.EmployeeDetailsForInsuranceList.OrderByDescending(x => x.HasLeftWorkInMonth).ThenByDescending(x => x.HasStartWorkInMonth).ThenBy(x => x.LName).ToList();
|
||||
|
||||
|
||||
mainEmployeeDetailsViewModel.IsExist = false;
|
||||
mainEmployeeDetailsViewModel.MaritalStatus = maritalStatus.ItemValue;
|
||||
}
|
||||
@@ -1486,7 +1493,7 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
// endDateGr);
|
||||
|
||||
var employeeInsurancDataPreviusList =
|
||||
_insuranceListRepositpry.GetEmployeeInsuranceDataForEdit(searchModel.InsuranceId,startDateGr,endDateGr);
|
||||
_insuranceListRepositpry.GetEmployeeInsuranceDataForEdit(searchModel.InsuranceId, startDateGr, endDateGr);
|
||||
|
||||
var computeResult = employeeInsurancDataPreviusList.Select(employeeData =>
|
||||
{
|
||||
@@ -1550,12 +1557,12 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
overTimePayIsSet = false;
|
||||
}
|
||||
return new EmployeeDetailsForInsuranceListViewModel
|
||||
{
|
||||
{
|
||||
#region EmployeeInfo
|
||||
EmployeeHasCheckout = employeeHasCheckout,
|
||||
EmployeeInsurancListDataId = employeeData.EmployeeInsurancListDataId,
|
||||
|
||||
InsuranceEmployeeInformationId = employeeData.InsuranceEmployeeInformationId,
|
||||
InsuranceEmployeeInformationId = employeeData.InsuranceEmployeeInformationId,
|
||||
EmployeeId = employeeData.EmployeeId,
|
||||
FName = employeeData.FName,
|
||||
LName = employeeData.LName,
|
||||
@@ -1676,9 +1683,9 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
return result;
|
||||
}
|
||||
|
||||
private double? GetDailyWageFixedSalary(string year, long workshopId,long employeeId,DateTime? startDateGr, DateTime? endDateGr, long jobId, string population, long? insuranceJobId)
|
||||
private double? GetDailyWageFixedSalary(string year, long workshopId, long employeeId, DateTime? startDateGr, DateTime? endDateGr, long jobId, string population, long? insuranceJobId)
|
||||
{
|
||||
|
||||
|
||||
double? result = 0;
|
||||
string month = $"{startDateGr.ToFarsi()}".Substring(5, 2);
|
||||
//اگر مشاغل مقطوع بود و شغلش کارفرما بود
|
||||
@@ -1727,7 +1734,7 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
|
||||
{
|
||||
var inJob = _insuranceJobItemRepository
|
||||
.GetInsuranceJobItemByInsuranceJobId((long)workshop.InsuranceJobId,year, month);
|
||||
.GetInsuranceJobItemByInsuranceJobId((long)workshop.InsuranceJobId, year, month);
|
||||
if (workshop.Population == "MoreThan500")
|
||||
{
|
||||
var max = inJob.MaxBy(x => x.PercentageMoreThan);
|
||||
@@ -1776,9 +1783,9 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
else
|
||||
{
|
||||
|
||||
var searchModel = new InsuranceJobItemSearchModel();
|
||||
searchModel.InsuranceJobId = (long)insuranceJobId;
|
||||
var JobItem = _insuranceJobItemRepository.GetInsuranceJobItemByInsuranceJobIdForFixedSalary((long)insuranceJobId, jobId, year, month);
|
||||
var searchModel = new InsuranceJobItemSearchModel();
|
||||
searchModel.InsuranceJobId = (long)insuranceJobId;
|
||||
var JobItem = _insuranceJobItemRepository.GetInsuranceJobItemByInsuranceJobIdForFixedSalary((long)insuranceJobId, jobId, year, month);
|
||||
|
||||
if (JobItem != null && JobItem.Id != 0)
|
||||
{
|
||||
@@ -1804,7 +1811,7 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
@@ -1827,28 +1834,28 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
/// <param name="jobId"></param>
|
||||
/// <param name="employeeId"></param>
|
||||
/// <returns></returns>
|
||||
private double GetMonthlyBenefits(int endMonthCurrentDay, double consumableItemsItemValue, double housingAllowanceItemValue,double maritalStatus, int countWorkingDays, string typeOfInsuranceSendWorkshop, long jobId,long employeeId,bool includeStatus)
|
||||
private double GetMonthlyBenefits(int endMonthCurrentDay, double consumableItemsItemValue, double housingAllowanceItemValue, double maritalStatus, int countWorkingDays, string typeOfInsuranceSendWorkshop, long jobId, long employeeId, bool includeStatus)
|
||||
{
|
||||
//ToDo
|
||||
//افزودن شرط مشمول مزایای
|
||||
//ToDo
|
||||
//افزودن شرط مشمول مزایای
|
||||
|
||||
//اگر پرسنل کارفرما بود و نوع لیست کارگاه کمک دولت بود مزایا محاسبه نشود
|
||||
//اگر تیک مشمول مزایا در ترک کار خاموش بود مزایا نگیرد
|
||||
//اگر پرسنل کارفرما بود و نوع لیست کارگاه کمک دولت بود مزایا محاسبه نشود
|
||||
//اگر تیک مشمول مزایا در ترک کار خاموش بود مزایا نگیرد
|
||||
|
||||
bool isManager = jobId is 10 or 16 or 17 or 18 or 3498;
|
||||
if (isManager && !includeStatus)
|
||||
bool isManager = jobId is 10 or 16 or 17 or 18 or 3498;
|
||||
if (isManager && !includeStatus)
|
||||
return 0;
|
||||
//پرسنل استثناء
|
||||
if (employeeId == 42783)
|
||||
return 53082855;
|
||||
|
||||
|
||||
//if(employeeId == 8859)
|
||||
// return GetRoundValue(((consumableItemsItemValue + housingAllowanceItemValue + maritalStatus) / 31) * countWorkingDays);
|
||||
|
||||
//مزایای ماهانه با توجه به پایان ماه که 30 یا 31 روزه است، متفاوت می باشد
|
||||
//برای ماه 29 روزه هم تقسیم بر 30 می شود.
|
||||
if (countWorkingDays == endMonthCurrentDay)
|
||||
//if(employeeId == 8859)
|
||||
// return GetRoundValue(((consumableItemsItemValue + housingAllowanceItemValue + maritalStatus) / 31) * countWorkingDays);
|
||||
|
||||
//مزایای ماهانه با توجه به پایان ماه که 30 یا 31 روزه است، متفاوت می باشد
|
||||
//برای ماه 29 روزه هم تقسیم بر 30 می شود.
|
||||
if (countWorkingDays == endMonthCurrentDay)
|
||||
return (consumableItemsItemValue + housingAllowanceItemValue + maritalStatus);
|
||||
else if (endMonthCurrentDay == 29)//farokhiChanges در خط پایین عدد 30 رو به 29 تغییر دادم
|
||||
return GetRoundValue(((consumableItemsItemValue + housingAllowanceItemValue + maritalStatus) / 29) * countWorkingDays);
|
||||
@@ -1860,31 +1867,31 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
return GetRoundValue(((consumableItemsItemValue + housingAllowanceItemValue + maritalStatus) / endMonthCurrentDay) * countWorkingDays);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private double ComputeDailyWage(double yearlysalaryItemValue, long employeeId, long workshopId, string year)
|
||||
|
||||
private double ComputeDailyWage(double yearlysalaryItemValue, long employeeId, long workshopId, string year)
|
||||
{
|
||||
double dailyWage = yearlysalaryItemValue;
|
||||
InsuranceListSearchModel searchModel = new InsuranceListSearchModel();
|
||||
InsuranceListSearchModel searchModel = new InsuranceListSearchModel();
|
||||
var insuransList = _insuranceListRepositpry.GetInsuranceListByWorkshopIdAndYear(workshopId, year);
|
||||
if (insuransList != null)
|
||||
{
|
||||
var employeeInsurancListData = _employeeInsurancListDataRepository.GetEmployeeInsurancListDataByEmployeeIdAndInsuranceListId( employeeId, insuransList.Id);
|
||||
if (employeeInsurancListData != null && employeeInsurancListData.DailyWage> dailyWage)
|
||||
var employeeInsurancListData = _employeeInsurancListDataRepository.GetEmployeeInsurancListDataByEmployeeIdAndInsuranceListId(employeeId, insuransList.Id);
|
||||
if (employeeInsurancListData != null && employeeInsurancListData.DailyWage > dailyWage)
|
||||
{
|
||||
dailyWage=employeeInsurancListData.DailyWage;
|
||||
dailyWage = employeeInsurancListData.DailyWage;
|
||||
}
|
||||
}
|
||||
|
||||
dailyWage = employeeId == 6536 ? 9399512 : dailyWage;
|
||||
return dailyWage;
|
||||
}
|
||||
public MainEmployeeDetailsViewModel GetEmployeeForInsuranceList(List<LeftWorkInsuranceViewModel> leftWorkInsuranceViewModelList, EmployeeForEditInsuranceListSearchModel searchModel)
|
||||
public MainEmployeeDetailsViewModel GetEmployeeForInsuranceList(List<LeftWorkInsuranceViewModel> leftWorkInsuranceViewModelList, EmployeeForEditInsuranceListSearchModel searchModel)
|
||||
{
|
||||
var result = new MainEmployeeDetailsViewModel();
|
||||
|
||||
List<EmployeeDetailsForInsuranceListViewModel> list = new List<EmployeeDetailsForInsuranceListViewModel>();
|
||||
int leftWorkInsuranceCount= leftWorkInsuranceViewModelList.Count();
|
||||
int leftWorkInsuranceCount = leftWorkInsuranceViewModelList.Count();
|
||||
string startMonthCurrent = searchModel.Year + "/" + searchModel.Month + "/01";
|
||||
string endMonthCurrent = startMonthCurrent.FindeEndOfMonth();
|
||||
|
||||
@@ -1893,7 +1900,7 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
model.EndDateGr = endMonthCurrent.ToGeorgianDateTime();
|
||||
model.year = searchModel.Year;
|
||||
|
||||
|
||||
|
||||
|
||||
var yearSalaryObj = _yearlySalaryApplication.GetDetailsBySearchModel(model);
|
||||
|
||||
@@ -1953,7 +1960,7 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
employeeDetailsForInsuranceObj.FName = employeeObject.FName;
|
||||
employeeDetailsForInsuranceObj.LName = employeeObject.LName;
|
||||
employeeDetailsForInsuranceObj.FatherName = employeeObject.FatherName;
|
||||
employeeDetailsForInsuranceObj.DateOfBirth = employeeObject.DateOfBirth=="1300/10/11"?"": employeeObject.DateOfBirth;
|
||||
employeeDetailsForInsuranceObj.DateOfBirth = employeeObject.DateOfBirth == "1300/10/11" ? "" : employeeObject.DateOfBirth;
|
||||
employeeDetailsForInsuranceObj.DateOfIssue = employeeObject.DateOfIssue;
|
||||
employeeDetailsForInsuranceObj.PlaceOfIssue = employeeObject.PlaceOfIssue;
|
||||
employeeDetailsForInsuranceObj.NationalCode = employeeObject.NationalCode;
|
||||
@@ -2059,8 +2066,8 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
case 40469://ثابت
|
||||
countWorkingDays = 7;
|
||||
break;
|
||||
//case 9950://ثابت
|
||||
// countWorkingDays = 15;
|
||||
//case 9950://ثابت
|
||||
// countWorkingDays = 15;
|
||||
break;
|
||||
case 9640://ثابت
|
||||
countWorkingDays = 15;
|
||||
@@ -2071,9 +2078,9 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
case 6219://ثابت
|
||||
countWorkingDays = 15;
|
||||
break;
|
||||
//case 7897://ثابت
|
||||
// countWorkingDays = 15;
|
||||
// break;
|
||||
//case 7897://ثابت
|
||||
// countWorkingDays = 15;
|
||||
// break;
|
||||
}
|
||||
;
|
||||
#endregion
|
||||
@@ -2085,17 +2092,17 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
double dailyWage = employeeDetailsForInsuranceObj.DailyWage;
|
||||
if (searchModel.FixedSalary)
|
||||
{
|
||||
dailyWage = Convert.ToDouble(GetDailyWageFixedSalary(searchModel.Year, item.WorkshopId,item.EmployeeId, model.StartDateGr, model.EndDateGr, item.JobId, searchModel.Population, searchModel.InsuranceJobId));
|
||||
dailyWage = Convert.ToDouble(GetDailyWageFixedSalary(searchModel.Year, item.WorkshopId, item.EmployeeId, model.StartDateGr, model.EndDateGr, item.JobId, searchModel.Population, searchModel.InsuranceJobId));
|
||||
employeeDetailsForInsuranceObj.HasConfilictJobs = (dailyWage == 0 ? true : false);
|
||||
}
|
||||
#endregion
|
||||
|
||||
if (yearlysalaryItem != null)
|
||||
{
|
||||
if(!searchModel.FixedSalary )
|
||||
if (!searchModel.FixedSalary)
|
||||
{
|
||||
//dailyWage= yearlysalaryItem.ItemValue;
|
||||
dailyWage = ComputeDailyWage(yearlysalaryItem.ItemValue, item.EmployeeId,item.WorkshopId, searchModel.Year) ;
|
||||
dailyWage = ComputeDailyWage(yearlysalaryItem.ItemValue, item.EmployeeId, item.WorkshopId, searchModel.Year);
|
||||
}
|
||||
employeeDetailsForInsuranceObj.DailyWage = GetRoundValue(dailyWage);
|
||||
employeeDetailsForInsuranceObj.DailyWageStr = employeeDetailsForInsuranceObj.DailyWage.ToMoney();
|
||||
@@ -2119,8 +2126,8 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
employeeDetailsForInsuranceObj.MonthlyBenefits = 0;
|
||||
}
|
||||
|
||||
employeeDetailsForInsuranceObj.BenefitsIncludedContinuous =employeeDetailsForInsuranceObj.MonthlyBenefits + employeeDetailsForInsuranceObj.MonthlySalary;
|
||||
|
||||
employeeDetailsForInsuranceObj.BenefitsIncludedContinuous = employeeDetailsForInsuranceObj.MonthlyBenefits + employeeDetailsForInsuranceObj.MonthlySalary;
|
||||
|
||||
//if ((!item.IncludeStatus &&(item.JobId == 10 || item.JobId == 17 || item.JobId == 18 || item.JobId == 16)) ||(item.IncludeStatus && item.JobId == 10)) // 10 --> karfarma
|
||||
//{
|
||||
// var insuranceShare2 =(employeeDetailsForInsuranceObj.BenefitsIncludedContinuous * 27) / 100;
|
||||
@@ -2133,14 +2140,14 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
//}
|
||||
|
||||
var employerShare = (employeeDetailsForInsuranceObj.BenefitsIncludedContinuous * 20) / 100;
|
||||
employeeDetailsForInsuranceObj.EmployerShare = GetRoundValue(employerShare); //Math.Round(employerShare, MidpointRounding.ToPositiveInfinity);
|
||||
employeeDetailsForInsuranceObj.EmployerShare = GetRoundValue(employerShare); //Math.Round(employerShare, MidpointRounding.ToPositiveInfinity);
|
||||
|
||||
|
||||
//if (searchModel.TypeOfInsuranceSendWorkshop == "Govermentlist" && item.JobId==10)//کمک دولت
|
||||
//{employeeDetailsForInsuranceObj.InsuranceShare = 0;}
|
||||
|
||||
|
||||
var unEmploymentInsurance =(employeeDetailsForInsuranceObj.BenefitsIncludedContinuous * 3) / 100;
|
||||
var unEmploymentInsurance = (employeeDetailsForInsuranceObj.BenefitsIncludedContinuous * 3) / 100;
|
||||
employeeDetailsForInsuranceObj.UnEmploymentInsurance = GetRoundValue(unEmploymentInsurance);
|
||||
|
||||
employeeDetailsForInsuranceObj.BenefitsIncludedNonContinuous = employeeDetailsForInsuranceObj.BenefitsIncludedNonContinuous;
|
||||
@@ -2195,7 +2202,119 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
|
||||
public double GetMonthlyBaseYear(double dayliBase, int countWorkingDays)
|
||||
{
|
||||
double res =GetRoundValue(dayliBase * countWorkingDays);
|
||||
double res = GetRoundValue(dayliBase * countWorkingDays);
|
||||
return res;
|
||||
}
|
||||
|
||||
#region Mahan
|
||||
|
||||
|
||||
|
||||
public async Task<OperationResult> ConfirmInsuranceOperation(InsuranceListConfirmOperation command)
|
||||
{
|
||||
// Improved version of the ConfirmInsuranceOperation method's main logic
|
||||
async Task<long> CreateMediaAsync(InsuranceList insuranceList, string insuranceType, IFormFile file)
|
||||
{
|
||||
var path = Path.Combine(_mediaRepository.BasePath, "InsuranceList", $"{insuranceList.Year}_{insuranceList.Month}", insuranceList.id.ToString());
|
||||
Directory.CreateDirectory(path);
|
||||
|
||||
string uniqueFileName = $"{insuranceType}_{Path.GetFileNameWithoutExtension(file.FileName)}_{DateTime.Now.Ticks}{Path.GetExtension(file.FileName)}";
|
||||
string filePath = Path.Combine(path, uniqueFileName);
|
||||
|
||||
await using (var stream = new FileStream(filePath, FileMode.Create))
|
||||
{
|
||||
await file.CopyToAsync(stream);
|
||||
}
|
||||
var type = Path.GetExtension(filePath);
|
||||
var media = new Media(filePath, type, "فایل", "InsuranceList");
|
||||
await _mediaRepository.CreateAsync(media);
|
||||
await _mediaRepository.SaveChangesAsync();
|
||||
return media.id;
|
||||
}
|
||||
|
||||
var op = new OperationResult();
|
||||
var insuranceList = _insuranceListRepositpry.Get(command.InsuranceListId);
|
||||
if (insuranceList == null)
|
||||
return op.Failed("لیست بیمه پیدا نشد");
|
||||
|
||||
bool completeDebt = false, completeInspection = false, completeApproval = false;
|
||||
|
||||
// Debt Section
|
||||
if (command.Debt.Type != InsuranceListDebtType.None)
|
||||
{
|
||||
var debt = command.Debt;
|
||||
if (string.IsNullOrWhiteSpace(debt.DebtDate))
|
||||
return op.Failed("لطفا تاریخ بدهی را وارد کنید");
|
||||
if (!debt.DebtDate.TryToGeorgianDateTime(out var debtDateGr))
|
||||
return op.Failed("تاریخ بدهی نامعتبر است");
|
||||
|
||||
if (debt.DebtFile is not { Length: > 0 })
|
||||
return op.Failed("لطفا فایل بدهی را وارد کنید");
|
||||
|
||||
if (debt.DebtFile.Length > 20_000_000)
|
||||
return op.Failed("حجم فایل نمیتواند از 20 مگابایت بیشتر باشد");
|
||||
|
||||
var debtAmount = debt.Amount.MoneyToDouble();
|
||||
if (debtAmount <= 0)
|
||||
return op.Failed("مبلغ بدهی نامعتبر است");
|
||||
|
||||
var mediaId = await CreateMediaAsync(insuranceList, "debt", debt.DebtFile);
|
||||
var debtEntity = new InsuranceListDebt(debt.Type, debtDateGr, debtAmount, mediaId);
|
||||
insuranceList.SetDebt(debtEntity);
|
||||
completeDebt = true;
|
||||
}
|
||||
|
||||
// Inspection Section
|
||||
if (command.Inspection.Type != InsuraceListInspectionType.None)
|
||||
{
|
||||
var inspection = command.Inspection;
|
||||
if (string.IsNullOrWhiteSpace(inspection.LastInspectionDate))
|
||||
return op.Failed("لطفا تاریخ بازرسی را وارد کنید");
|
||||
|
||||
if (!inspection.LastInspectionDate.TryToGeorgianDateTime(out var inspectionDateGr))
|
||||
return op.Failed("تاریخ بازرسی نامعتبر است");
|
||||
|
||||
if (inspection.InspectionFile is not { Length: > 0 })
|
||||
return op.Failed("لطفا فایل بازرسی را وارد کنید");
|
||||
|
||||
if (inspection.InspectionFile.Length > 20_000_000)
|
||||
return op.Failed("حجم فایل نمیتواند از 20 مگابایت بیشتر باشد");
|
||||
|
||||
var mediaId = await CreateMediaAsync(insuranceList, "inspection", inspection.InspectionFile);
|
||||
var inspectionEntity = new InsuranceListInspection(inspection.Type, inspectionDateGr, mediaId);
|
||||
insuranceList.SetInspection(inspectionEntity);
|
||||
completeInspection = true;
|
||||
}
|
||||
|
||||
// Approval Section
|
||||
if (command.Approval.ApprovalStatus != InsuranceListEmployerApprovalStatus.None)
|
||||
{
|
||||
var approval = command.Approval;
|
||||
if (approval.ApprovalStatus == InsuranceListEmployerApprovalStatus.VerbalApproval)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(approval.Description))
|
||||
return op.Failed("لطفا توضیحات را وارد کنید");
|
||||
|
||||
if (approval.Description.Length < 15)
|
||||
return op.Failed("توضیحات باید حداقل 15 کاراکتر باشد");
|
||||
}
|
||||
var approvalEntity = new InsuranceListEmployerApproval(approval.ApprovalStatus, approval.Description);
|
||||
insuranceList.SetEmployerApproval(approvalEntity);
|
||||
completeApproval = true;
|
||||
}
|
||||
|
||||
// Final Confirmation
|
||||
if (command.ConfirmSentList)
|
||||
{
|
||||
if (!(completeApproval && completeDebt && completeInspection))
|
||||
return op.Failed("تا زمانی که تمامی بخش ها پر نشده باشد نمیتوانید لیست را ارسال کنید");
|
||||
|
||||
insuranceList.SetConfirmSentlist(true);
|
||||
}
|
||||
|
||||
await _insuranceListRepositpry.SaveChangesAsync();
|
||||
return op.Succcedded();
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -16,6 +16,7 @@ public class InsuranceListMapping : IEntityTypeConfiguration<InsuranceList>
|
||||
|
||||
builder.ComplexProperty(x => x.Inspection, inspection =>
|
||||
{
|
||||
inspection.IsRequired();
|
||||
inspection.Property(x => x.Type).HasConversion<string>().HasMaxLength(50);
|
||||
inspection.Property(x => x.LastInspectionDateTime);
|
||||
inspection.Property(x => x.MediaId);
|
||||
@@ -23,6 +24,7 @@ public class InsuranceListMapping : IEntityTypeConfiguration<InsuranceList>
|
||||
|
||||
builder.ComplexProperty(x => x.Debt, debt =>
|
||||
{
|
||||
debt.IsRequired();
|
||||
debt.Property(x => x.Type).HasConversion<string>().HasMaxLength(50);
|
||||
debt.Property(x => x.DebtDate);
|
||||
debt.Property(x => x.Amount);
|
||||
@@ -31,6 +33,7 @@ public class InsuranceListMapping : IEntityTypeConfiguration<InsuranceList>
|
||||
|
||||
builder.ComplexProperty(x => x.EmployerApproval, approval =>
|
||||
{
|
||||
approval.IsRequired();
|
||||
approval.Property(x => x.Status).HasConversion<string>().HasMaxLength(50);
|
||||
approval.Property(x => x.Description).HasMaxLength(500);
|
||||
});
|
||||
|
||||
9589
CompanyManagment.EFCore/Migrations/20250521125646_add inspection-debt-approval to insurance list.Designer.cs
generated
Normal file
9589
CompanyManagment.EFCore/Migrations/20250521125646_add inspection-debt-approval to insurance list.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,121 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace CompanyManagment.EFCore.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class addinspectiondebtapprovaltoinsurancelist : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<double>(
|
||||
name: "Debt_Amount",
|
||||
table: "InsuranceLists",
|
||||
type: "float",
|
||||
nullable: false,
|
||||
defaultValue: 0.0);
|
||||
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "Debt_DebtDate",
|
||||
table: "InsuranceLists",
|
||||
type: "datetime2",
|
||||
nullable: false,
|
||||
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
|
||||
|
||||
migrationBuilder.AddColumn<long>(
|
||||
name: "Debt_MediaId",
|
||||
table: "InsuranceLists",
|
||||
type: "bigint",
|
||||
nullable: false,
|
||||
defaultValue: 0L);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "Debt_Type",
|
||||
table: "InsuranceLists",
|
||||
type: "nvarchar(50)",
|
||||
maxLength: 50,
|
||||
nullable: false,
|
||||
defaultValue: "None");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "EmployerApproval_Description",
|
||||
table: "InsuranceLists",
|
||||
type: "nvarchar(500)",
|
||||
maxLength: 500,
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "EmployerApproval_Status",
|
||||
table: "InsuranceLists",
|
||||
type: "nvarchar(50)",
|
||||
maxLength: 50,
|
||||
nullable: false,
|
||||
defaultValue: "None");
|
||||
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "Inspection_LastInspectionDateTime",
|
||||
table: "InsuranceLists",
|
||||
type: "datetime2",
|
||||
nullable: false,
|
||||
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
|
||||
|
||||
migrationBuilder.AddColumn<long>(
|
||||
name: "Inspection_MediaId",
|
||||
table: "InsuranceLists",
|
||||
type: "bigint",
|
||||
nullable: false,
|
||||
defaultValue: 0L);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "Inspection_Type",
|
||||
table: "InsuranceLists",
|
||||
type: "nvarchar(50)",
|
||||
maxLength: 50,
|
||||
nullable: false,
|
||||
defaultValue: "None");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Debt_Amount",
|
||||
table: "InsuranceLists");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Debt_DebtDate",
|
||||
table: "InsuranceLists");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Debt_MediaId",
|
||||
table: "InsuranceLists");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Debt_Type",
|
||||
table: "InsuranceLists");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "EmployerApproval_Description",
|
||||
table: "InsuranceLists");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "EmployerApproval_Status",
|
||||
table: "InsuranceLists");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Inspection_LastInspectionDateTime",
|
||||
table: "InsuranceLists");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Inspection_MediaId",
|
||||
table: "InsuranceLists");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Inspection_Type",
|
||||
table: "InsuranceLists");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using CompanyManagment.EFCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
@@ -3320,6 +3321,55 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
.HasMaxLength(4)
|
||||
.HasColumnType("nvarchar(4)");
|
||||
|
||||
b.ComplexProperty<Dictionary<string, object>>("Debt", "Company.Domain.InsuranceListAgg.InsuranceList.Debt#InsuranceListDebt", b1 =>
|
||||
{
|
||||
b1.IsRequired();
|
||||
|
||||
b1.Property<double>("Amount")
|
||||
.HasColumnType("float");
|
||||
|
||||
b1.Property<DateTime>("DebtDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b1.Property<long>("MediaId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b1.Property<string>("Type")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
});
|
||||
|
||||
b.ComplexProperty<Dictionary<string, object>>("EmployerApproval", "Company.Domain.InsuranceListAgg.InsuranceList.EmployerApproval#InsuranceListEmployerApproval", b1 =>
|
||||
{
|
||||
b1.IsRequired();
|
||||
|
||||
b1.Property<string>("Description")
|
||||
.HasMaxLength(500)
|
||||
.HasColumnType("nvarchar(500)");
|
||||
|
||||
b1.Property<string>("Status")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
});
|
||||
|
||||
b.ComplexProperty<Dictionary<string, object>>("Inspection", "Company.Domain.InsuranceListAgg.InsuranceList.Inspection#InsuranceListInspection", b1 =>
|
||||
{
|
||||
b1.IsRequired();
|
||||
|
||||
b1.Property<DateTime>("LastInspectionDateTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b1.Property<long>("MediaId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b1.Property<string>("Type")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
});
|
||||
|
||||
b.HasKey("id");
|
||||
|
||||
b.ToTable("InsuranceLists", (string)null);
|
||||
|
||||
Reference in New Issue
Block a user