Compare commits
5 Commits
Feature/Ex
...
ServiceAmo
| Author | SHA1 | Date | |
|---|---|---|---|
| 223c2bde21 | |||
| f17b566957 | |||
|
|
82bf10c2d5 | ||
|
|
19a72ac78d | ||
|
|
9cb42b7cef |
@@ -1,5 +1,6 @@
|
||||
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Application.Sms;
|
||||
using Company.Domain.ContarctingPartyAgg;
|
||||
using Company.Domain.InstitutionContractAgg;
|
||||
using Hangfire;
|
||||
@@ -13,13 +14,15 @@ public class JobSchedulerRegistrator
|
||||
private readonly IInstitutionContractRepository _institutionContractRepository;
|
||||
private static DateTime? _lastRunCreateTransaction;
|
||||
private static DateTime? _lastRunSendMonthlySms;
|
||||
private readonly ISmsService _smsService;
|
||||
|
||||
|
||||
public JobSchedulerRegistrator(SmsReminder smsReminder, IBackgroundJobClient backgroundJobClient, IInstitutionContractRepository institutionContractRepository)
|
||||
public JobSchedulerRegistrator(SmsReminder smsReminder, IBackgroundJobClient backgroundJobClient, IInstitutionContractRepository institutionContractRepository, ISmsService smsService)
|
||||
{
|
||||
_smsReminder = smsReminder;
|
||||
_backgroundJobClient = backgroundJobClient;
|
||||
_institutionContractRepository = institutionContractRepository;
|
||||
_smsService = smsService;
|
||||
}
|
||||
|
||||
public void Register()
|
||||
@@ -91,8 +94,8 @@ public class JobSchedulerRegistrator
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//_smsService.Alarm("09114221321", "خطا-ایجاد سند مالی");
|
||||
|
||||
await _smsService.Alarm("09114221321", "خطا-ایجاد سند مالی");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
using GozareshgirProgramManager.Application.Interfaces;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||
|
||||
public class NullBoardNotificationPublisher:IBoardNotificationPublisher
|
||||
{
|
||||
public Task SendProjectStatusChanged(long userId, TaskSectionStatus oldStatus, TaskSectionStatus newStatus, Guid sectionId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ using BackgroundInstitutionContract.Task.Jobs;
|
||||
using CompanyManagment.App.Contracts.Hubs;
|
||||
using CompanyManagment.EFCore.Services;
|
||||
using GozareshgirProgramManager.Application._Bootstrapper;
|
||||
using GozareshgirProgramManager.Application.Interfaces;
|
||||
using GozareshgirProgramManager.Application.Modules.Users.Commands.CreateUser;
|
||||
using GozareshgirProgramManager.Infrastructure;
|
||||
using GozareshgirProgramManager.Infrastructure.Persistence.Seed;
|
||||
@@ -31,7 +32,7 @@ builder.Services.AddTransient<ISmsService, SmsService>();
|
||||
builder.Services.AddTransient<IUidService, UidService>();
|
||||
builder.Services.AddTransient<IFileUploader, FileUploader>();
|
||||
builder.Services.Configure<AppSettingConfiguration>(builder.Configuration);
|
||||
|
||||
builder.Services.AddScoped<IBoardNotificationPublisher, NullBoardNotificationPublisher>();
|
||||
#region MongoDb
|
||||
|
||||
var mongoConnectionSection = builder.Configuration.GetSection("MongoDb");
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using _0_Framework.Domain;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Domain;
|
||||
using CompanyManagment.App.Contracts.InstitutionPlan;
|
||||
using CompanyManagment.App.Contracts.TemporaryClientRegistration;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Company.Domain.InstitutionPlanAgg;
|
||||
|
||||
@@ -26,4 +28,18 @@ public interface IPlanPercentageRepository : IRepository<long, PlanPercentage>
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
InstitutionPlanViewModel GetInstitutionPlanForWorkshop(WorkshopTempViewModel command);
|
||||
|
||||
/// <summary>
|
||||
/// دریافت دیتای مودال ایجاد
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<CreateServiceAmountDto> GetCreateModalData();
|
||||
|
||||
/// <summary>
|
||||
/// دریافت لیست مبالغ سرویس ها
|
||||
/// </summary>
|
||||
/// <param name="searchModel"></param>
|
||||
/// <returns></returns>
|
||||
Task<PagedResult<InstitutionPlanListDto>> GetList(
|
||||
InstitutionPlanSearchModel searchModel);
|
||||
}
|
||||
@@ -76,5 +76,7 @@ public class InstitutionContractViewModel
|
||||
public bool IsInstallment { get; set; }
|
||||
public InstitutionContractVerificationStatus VerificationStatus { get; set; }
|
||||
|
||||
public InstitutionContractSigningType? SigningType { get; set; }
|
||||
|
||||
public List<InstitutionContractInstallmentViewModel> InstallmentList { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
namespace CompanyManagment.App.Contracts.InstitutionPlan;
|
||||
|
||||
public class CreateServiceAmountDto
|
||||
{
|
||||
/// <summary>
|
||||
/// آی دی
|
||||
/// </summary>
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// قرارداد و تصفیه
|
||||
/// درصد از مزد روزانه
|
||||
/// string
|
||||
/// </summary>
|
||||
public string ContractAndCheckoutPercentStr { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// بیمه
|
||||
/// درصد از مزد روزانه
|
||||
/// string
|
||||
/// </summary>
|
||||
public string InsurancePercentStr { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// حضورغباب
|
||||
/// درصد از مزد روزانه
|
||||
/// string
|
||||
/// </summary>
|
||||
public string RollCallPercentStr { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// فیش غیر رسمی
|
||||
/// درصد از مزد روزانه
|
||||
/// string
|
||||
/// </summary>
|
||||
public string CustomizeCheckoutPercentStr { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// خدمات حضوری قرداد و تصفیه
|
||||
/// درصد از مزد روزانه
|
||||
/// string
|
||||
/// </summary>
|
||||
public string ContractAndCheckoutInPersonPercentStr { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// خدمات حضوری بیمه
|
||||
/// درصد از مزد روزانه
|
||||
/// string
|
||||
/// </summary>
|
||||
public string InsuranceInPersonPercentStr { get; set; }
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Application;
|
||||
using CompanyManagment.App.Contracts.TemporaryClientRegistration;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.InstitutionPlan;
|
||||
|
||||
@@ -34,4 +35,27 @@ public interface IInstitutionPlanApplication
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
InstitutionPlanViewModel GetInstitutionPlanForWorkshop(WorkshopTempViewModel command);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// دریافت دیتای درصد سرویس برای مودال ایجاد
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<CreateServiceAmountDto> GetCreateModalData();
|
||||
|
||||
/// <summary>
|
||||
/// ایجاد درصد سرویس
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
Task<OperationResult> CreateInstitutionPlanPercentage(CreateServiceAmountDto command);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// دریافت لیست مبالغ سرویس ها
|
||||
/// </summary>
|
||||
/// <param name="searchModel"></param>
|
||||
/// <returns></returns>
|
||||
Task<PagedResult<InstitutionPlanListDto>> GetList(
|
||||
InstitutionPlanSearchModel searchModel);
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
namespace CompanyManagment.App.Contracts.InstitutionPlan;
|
||||
|
||||
public class InstitutionPlanListDto
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// تعداد پرسنل
|
||||
/// </summary>
|
||||
public int CountPerson { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// مبلغ قرارداد و تصفیه
|
||||
/// </summary>
|
||||
public string ContractAndCheckout { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// مبلغ بیمه
|
||||
/// </summary>
|
||||
public string Insurance { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// مبلغ حضورغباب
|
||||
/// </summary>
|
||||
public string RollCall { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// مبلغ فیش غیر رسمی
|
||||
/// </summary>
|
||||
public string CustomizeCheckout { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// مبلغ خدمات حضوری قرداد و تصفیه
|
||||
/// </summary>
|
||||
public string ContractAndCheckoutInPerson { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// مبلغ خدمات حضوری بیمه
|
||||
/// </summary>
|
||||
public string InsuranceInPerson { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
#region Total
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// مبلغ کل خدمات حضوری
|
||||
/// </summary>
|
||||
public string InPersonSumAmountStr { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// مبلغ کل خدمات آنلاین
|
||||
/// </summary>
|
||||
public string OnlineOnlySumAmountStr { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// مبلغ کل خدمات حضوری و آنلاین
|
||||
/// </summary>
|
||||
public string OnlineAndInPersonSumAmountStr { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// مبلغ کل خدمات حضوری و آنلاین
|
||||
/// double
|
||||
/// </summary>
|
||||
public double OnlineAndInPersonSumAmountDouble { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// مبلغ کل خدمات حضوری
|
||||
/// double
|
||||
/// </summary>
|
||||
public double InPersonSumAmountDouble { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// مبلغ کل خدمات آنلاین
|
||||
/// double
|
||||
/// </summary>
|
||||
public double OnlineOnlySumAmountDouble { get; set; }
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using _0_Framework.Application;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.InstitutionPlan;
|
||||
|
||||
public class InstitutionPlanSearchModel : PaginationRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// تعدلد پرسنل برای جستجو
|
||||
/// </summary>
|
||||
public int CountPeron { get; set; }
|
||||
}
|
||||
@@ -1570,9 +1570,7 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
createdWorkshop.InstitutionContractWorkshopGroupId,createdWorkshop.WorkshopGroup,
|
||||
createdWorkshop.WorkshopId!.Value, createdWorkshop.id);
|
||||
institutionContract.WorkshopGroup.AddCurrentWorkshop(currentWorkshop);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (institutionContract.WorkshopGroup.InitialWorkshops.All(x => x.WorkshopCreated && x.WorkshopId is > 0))
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using Company.Domain.InstitutionPlanAgg;
|
||||
using CompanyManagment.App.Contracts.InstitutionPlan;
|
||||
@@ -84,4 +85,73 @@ public class InstitutionPlanApplication : IInstitutionPlanApplication
|
||||
{
|
||||
return _planPercentageRepository.GetInstitutionPlanForWorkshop(command);
|
||||
}
|
||||
|
||||
|
||||
#region ForApi
|
||||
|
||||
public async Task<CreateServiceAmountDto> GetCreateModalData()
|
||||
{
|
||||
return await _planPercentageRepository.GetCreateModalData();
|
||||
}
|
||||
|
||||
|
||||
public async Task<OperationResult> CreateInstitutionPlanPercentage(CreateServiceAmountDto command)
|
||||
{
|
||||
var op = new OperationResult();
|
||||
if (string.IsNullOrWhiteSpace(command.ContractAndCheckoutInPersonPercentStr) || command.ContractAndCheckoutInPersonPercentStr == "0" ||
|
||||
string.IsNullOrWhiteSpace(command.ContractAndCheckoutPercentStr) || (command.ContractAndCheckoutPercentStr == "0" ||
|
||||
string.IsNullOrWhiteSpace(command.CustomizeCheckoutPercentStr) || command.CustomizeCheckoutPercentStr == "0" ||
|
||||
string.IsNullOrWhiteSpace(command.InsuranceInPersonPercentStr) || command.InsuranceInPersonPercentStr == "0" ||
|
||||
string.IsNullOrWhiteSpace(command.InsurancePercentStr) || command.InsurancePercentStr == "0" ||
|
||||
string.IsNullOrWhiteSpace(command.RollCallPercentStr) || command.RollCallPercentStr == "0"))
|
||||
return op.Failed("هیچ یک از فیلدها نمیتوانند صفر باشند");
|
||||
|
||||
int contractAndCheckoutInPersonPercent = 0;
|
||||
int contractAndCheckoutPercent = 0;
|
||||
int customizeCheckoutPercent = 0;
|
||||
int insuranceInPersonPercent = 0;
|
||||
int insurancePercent = 0;
|
||||
int rollCallPercent = 0;
|
||||
|
||||
try
|
||||
{
|
||||
contractAndCheckoutInPersonPercent = Convert.ToInt32(command.ContractAndCheckoutInPersonPercentStr);
|
||||
contractAndCheckoutPercent = Convert.ToInt32(command.ContractAndCheckoutPercentStr);
|
||||
customizeCheckoutPercent = Convert.ToInt32(command.CustomizeCheckoutPercentStr);
|
||||
insuranceInPersonPercent = Convert.ToInt32(command.InsuranceInPersonPercentStr);
|
||||
insurancePercent = Convert.ToInt32(command.InsurancePercentStr);
|
||||
rollCallPercent = Convert.ToInt32(command.RollCallPercentStr);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return op.Failed("لطفا عدد معتبر وارد کنید");
|
||||
|
||||
}
|
||||
|
||||
var firstPlan =await _planPercentageRepository.GetCreateModalData();
|
||||
if (firstPlan != null)
|
||||
{
|
||||
var planPercentage = _planPercentageRepository.Get(firstPlan.Id);
|
||||
planPercentage.Edit(contractAndCheckoutPercent, insurancePercent, rollCallPercent, customizeCheckoutPercent, contractAndCheckoutInPersonPercent, insuranceInPersonPercent);
|
||||
_planPercentageRepository.SaveChanges();
|
||||
}
|
||||
else
|
||||
{
|
||||
var create = new PlanPercentage(contractAndCheckoutPercent, insurancePercent, rollCallPercent,
|
||||
customizeCheckoutPercent, contractAndCheckoutInPersonPercent, insuranceInPersonPercent);
|
||||
await _planPercentageRepository.CreateAsync(create);
|
||||
await _planPercentageRepository.SaveChangesAsync();
|
||||
}
|
||||
|
||||
|
||||
|
||||
return op.Succcedded();
|
||||
}
|
||||
|
||||
public async Task<PagedResult<InstitutionPlanListDto>> GetList(InstitutionPlanSearchModel searchModel)
|
||||
{
|
||||
return await _planPercentageRepository.GetList(searchModel);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -4364,6 +4364,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
{
|
||||
var sendResult = await _smsService.SendInstitutionCreationVerificationLink(item.Number, item.FullName,
|
||||
item.InstitutionId, item.ContractingPartyId, item.InstitutionContractId, typeOfSms);
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
|
||||
Console.WriteLine("executed at : " + persianNow + " - " + hour + ":" + minute);
|
||||
@@ -4415,12 +4416,13 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
TypeOfContract = x.TypeOfContract,
|
||||
IsInstallment = x.IsInstallment,
|
||||
VerificationStatus = x.VerificationStatus,
|
||||
SigningType = x.SigningType,
|
||||
InstallmentList = x.Installments
|
||||
.Select(ins => new InstitutionContractInstallmentViewModel
|
||||
{ AmountDouble = ins.Amount, InstallmentDateGr = ins.InstallmentDateGr })
|
||||
.OrderBy(ins => ins.InstallmentDateGr).Skip(1).ToList(),
|
||||
}).Where(x =>
|
||||
x.ContractStartGr < endOfMonthGr && x.ContractEndGr >= endOfMonthGr && x.ContractAmountDouble > 0)
|
||||
x.ContractStartGr < endOfMonthGr && x.ContractEndGr >= endOfMonthGr && x.ContractAmountDouble > 0 && x.VerificationStatus != InstitutionContractVerificationStatus.PendingForVerify)
|
||||
.ToListAsync();
|
||||
|
||||
#endregion
|
||||
@@ -4438,13 +4440,13 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
|
||||
|
||||
#region GetDectivedContractOnCurrentMonth
|
||||
|
||||
|
||||
if (futureContracts.Any())
|
||||
{
|
||||
List<long> futureContractIds = futureContracts.Select(x => x.ContractingPartyId).ToList();
|
||||
List<InstitutionContractViewModel> deatcivedContract = await _context.InstitutionContractSet
|
||||
.Where(x => x.IsActiveString == "false" && futureContractIds.Contains(x.ContractingPartyId) &&
|
||||
x.ContractEndGr.Date == endOfCurrentMonth.Date && x.ContractAmount > 0)
|
||||
x.ContractEndGr.Date == endOfCurrentMonth.Date && x.ContractAmount > 0 && x.VerificationStatus != InstitutionContractVerificationStatus.PendingForVerify)
|
||||
.Select(x => new InstitutionContractViewModel
|
||||
{
|
||||
Id = x.id,
|
||||
@@ -4459,6 +4461,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
TypeOfContract = x.TypeOfContract,
|
||||
IsInstallment = x.IsInstallment,
|
||||
VerificationStatus = x.VerificationStatus,
|
||||
SigningType = x.SigningType,
|
||||
InstallmentList = x.Installments
|
||||
.Select(ins => new InstitutionContractInstallmentViewModel
|
||||
{ AmountDouble = ins.Amount, InstallmentDateGr = ins.InstallmentDateGr })
|
||||
@@ -4469,6 +4472,12 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
institutionContracts.AddRange(deatcivedContract);
|
||||
}
|
||||
|
||||
// قرارداد هایی که پطور یکجا پرداخت شده اند
|
||||
var paidInFull = institutionContracts.Where(x =>
|
||||
x.SigningType != InstitutionContractSigningType.Legacy && x.IsInstallment == false && x.SigningType != null).ToList();
|
||||
|
||||
//حذف قراداد هایی که یکجا پرداخت شده اند از لیست ایجاد سند ماهانه
|
||||
institutionContracts = institutionContracts.Except(paidInFull).ToList();
|
||||
|
||||
#region RollCallServicCompute
|
||||
|
||||
@@ -4516,8 +4525,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
|
||||
if (!alreadyCreated)
|
||||
{
|
||||
if (item.IsInstallment &&
|
||||
item.VerificationStatus == InstitutionContractVerificationStatus.Verified)
|
||||
if (item.IsInstallment)
|
||||
{
|
||||
var instalment = item.InstallmentList
|
||||
.FirstOrDefault(x =>
|
||||
@@ -4551,8 +4559,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
await _financialStatmentRepository.SaveChangesAsync();
|
||||
|
||||
|
||||
if (item.IsInstallment &&
|
||||
item.VerificationStatus == InstitutionContractVerificationStatus.Verified)
|
||||
if (item.IsInstallment)
|
||||
{
|
||||
var instalment = item.InstallmentList
|
||||
.FirstOrDefault(x =>
|
||||
@@ -4579,12 +4586,17 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
|
||||
|
||||
#region RollCallServicCompute
|
||||
|
||||
if (item.VerificationStatus != InstitutionContractVerificationStatus.Verified &&
|
||||
!item.IsInstallment && item.ContractingPartyId != 30520 && item.ContractingPartyId != 30739)
|
||||
//ایجاد سند مالی حضورغیاب
|
||||
//قرارداد هایی که جدید نیستند و اقساط ندارند
|
||||
//کارگاه های استثناء : کباب مهدی 30520 و نمونه پروتئین 30739
|
||||
if (item.SigningType != InstitutionContractSigningType.OtpBased && item.SigningType != InstitutionContractSigningType.Physical
|
||||
&& !item.IsInstallment && item.ContractingPartyId != 30520 && item.ContractingPartyId != 30739)
|
||||
{
|
||||
try
|
||||
{
|
||||
//TODO
|
||||
//@refactor Need
|
||||
|
||||
var employers = await _context.Employers
|
||||
.Where(x => x.ContractingPartyId == item.ContractingPartyId)
|
||||
.Select(x => x.id).ToListAsync();
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.InfraStructure;
|
||||
using Company.Domain.InstitutionPlanAgg;
|
||||
using CompanyManagment.App.Contracts.InstitutionContract;
|
||||
using CompanyManagment.App.Contracts.InstitutionPlan;
|
||||
using CompanyManagment.App.Contracts.TemporaryClientRegistration;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CompanyManagment.EFCore.Repository;
|
||||
|
||||
@@ -44,6 +46,7 @@ public class PlanPercentageRepository : RepositoryBase<long, PlanPercentage>, IP
|
||||
}).FirstOrDefault();
|
||||
}
|
||||
|
||||
|
||||
public List<InstitutionPlanViewModel> GetInstitutionPlanList(int pageIndex, int countPeron)
|
||||
{
|
||||
var planPercentage = _context.PlanPercentages.FirstOrDefault();
|
||||
@@ -303,4 +306,112 @@ public class PlanPercentageRepository : RepositoryBase<long, PlanPercentage>, IP
|
||||
|
||||
return new InstitutionPlanViewModel();
|
||||
}
|
||||
|
||||
|
||||
#region ForApi
|
||||
|
||||
public async Task<CreateServiceAmountDto> GetCreateModalData()
|
||||
{
|
||||
return await _context.PlanPercentages.Select(x => new CreateServiceAmountDto()
|
||||
{
|
||||
Id = x.id,
|
||||
ContractAndCheckoutInPersonPercentStr = $"{x.ContractAndCheckoutInPersonPercent}",
|
||||
CustomizeCheckoutPercentStr = $"{x.CustomizeCheckoutPercent}",
|
||||
ContractAndCheckoutPercentStr = $"{x.ContractAndCheckoutPercent}",
|
||||
InsuranceInPersonPercentStr = $"{x.InsuranceInPersonPercent}",
|
||||
InsurancePercentStr = $"{x.InsurancePercent}",
|
||||
RollCallPercentStr = $"{x.RollCallPercent}",
|
||||
}).FirstOrDefaultAsync();
|
||||
}
|
||||
|
||||
|
||||
public async Task<PagedResult<InstitutionPlanListDto>> GetList(
|
||||
InstitutionPlanSearchModel searchModel)
|
||||
{
|
||||
var planPercentage = await _context.PlanPercentages.FirstOrDefaultAsync();
|
||||
|
||||
if (planPercentage == null)
|
||||
return new PagedResult<InstitutionPlanListDto>();
|
||||
|
||||
var dailyWageYearlySalery = await _context.YearlySalaries.Include(i => i.YearlySalaryItemsList).FirstOrDefaultAsync(x =>
|
||||
x.StartDate.Date <= DateTime.Now.Date && x.EndDate >= DateTime.Now.Date);
|
||||
if (dailyWageYearlySalery == null)
|
||||
return new PagedResult<InstitutionPlanListDto>();
|
||||
|
||||
var dailyWage = dailyWageYearlySalery.YearlySalaryItemsList.Where(x => x.ItemName == "مزد روزانه")
|
||||
.Select(x => x.ItemValue).FirstOrDefault();
|
||||
|
||||
var plans = _context.InstitutionPlans.AsQueryable();
|
||||
|
||||
if (searchModel.CountPeron > 0)
|
||||
plans = plans.Where(x => x.CountPerson == searchModel.CountPeron);
|
||||
|
||||
var count = await plans.CountAsync();
|
||||
|
||||
var planQueryFilter =await plans.ApplyPagination(searchModel.PageIndex, searchModel.PageSize).ToListAsync();
|
||||
var planResult = planQueryFilter.Select(plan =>
|
||||
new InstitutionPlanViewModel
|
||||
{
|
||||
CountPerson = plan.CountPerson,
|
||||
|
||||
ContractAndCheckoutDouble =
|
||||
((dailyWage * planPercentage.ContractAndCheckoutPercent / 100) * plan.CountPerson *
|
||||
plan.IncreasePercentage),
|
||||
|
||||
InsuranceDouble = (((dailyWage * planPercentage.InsurancePercent) / 100) * plan.CountPerson *
|
||||
plan.IncreasePercentage),
|
||||
|
||||
RollCallDouble = (((dailyWage * planPercentage.RollCallPercent) / 100) * plan.CountPerson *
|
||||
plan.IncreasePercentage),
|
||||
|
||||
CustomizeCheckoutDouble = (((dailyWage * planPercentage.CustomizeCheckoutPercent) / 100) *
|
||||
plan.CountPerson *
|
||||
plan.IncreasePercentage),
|
||||
|
||||
ContractAndCheckoutInPersonDouble =
|
||||
(((dailyWage * planPercentage.ContractAndCheckoutInPersonPercent) / 100) * plan.CountPerson *
|
||||
plan.IncreasePercentage),
|
||||
|
||||
InsuranceInPersonDouble = (((dailyWage * planPercentage.InsuranceInPersonPercent) / 100) *
|
||||
plan.CountPerson *
|
||||
plan.IncreasePercentage)
|
||||
}).ToList();
|
||||
|
||||
var finalResult = planResult.Select(plan => new InstitutionPlanListDto()
|
||||
{
|
||||
CountPerson = plan.CountPerson,
|
||||
|
||||
ContractAndCheckout = plan.ContractAndCheckoutDouble.ToMoney(),
|
||||
|
||||
Insurance = plan.InsuranceDouble.ToMoney(),
|
||||
|
||||
RollCall = plan.RollCallDouble.ToMoney(),
|
||||
|
||||
CustomizeCheckout = plan.CustomizeCheckoutDouble.ToMoney(),
|
||||
|
||||
ContractAndCheckoutInPerson = plan.ContractAndCheckoutInPersonDouble.ToMoney(),
|
||||
|
||||
InsuranceInPerson = plan.InsuranceInPersonDouble.ToMoney(),
|
||||
|
||||
InPersonSumAmountStr =
|
||||
(plan.ContractAndCheckoutDouble + plan.InsuranceDouble + plan.ContractAndCheckoutInPersonDouble +
|
||||
plan.InsuranceInPersonDouble).ToMoney(),
|
||||
|
||||
OnlineAndInPersonSumAmountStr = (plan.ContractAndCheckoutDouble + plan.InsuranceDouble +
|
||||
plan.ContractAndCheckoutInPersonDouble + plan.InsuranceInPersonDouble +
|
||||
plan.RollCallDouble + plan.CustomizeCheckoutDouble).ToMoney(),
|
||||
|
||||
OnlineOnlySumAmountStr =
|
||||
(plan.ContractAndCheckoutDouble + plan.InsuranceDouble + plan.RollCallDouble +
|
||||
plan.CustomizeCheckoutDouble).ToMoney(),
|
||||
}).ToList();
|
||||
|
||||
return new PagedResult<InstitutionPlanListDto>()
|
||||
{
|
||||
TotalCount = count,
|
||||
List = finalResult
|
||||
};
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
using _0_Framework.Application;
|
||||
using AccountManagement.Application.Contracts.Ticket;
|
||||
using CompanyManagment.App.Contracts.InstitutionPlan;
|
||||
using CompanyManagment.App.Contracts.Workshop;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ServiceHost.BaseControllers;
|
||||
|
||||
namespace ServiceHost.Areas.Admin.Controllers;
|
||||
|
||||
public class ServiceAmountsManagement : AdminBaseController
|
||||
{
|
||||
private readonly IInstitutionPlanApplication _institutionPlanApplication;
|
||||
private readonly IAuthHelper _authHelper;
|
||||
|
||||
public ServiceAmountsManagement(IInstitutionPlanApplication institutionPlanApplication, IAuthHelper authHelper)
|
||||
{
|
||||
_institutionPlanApplication = institutionPlanApplication;
|
||||
_authHelper = authHelper;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// دریافت دیتای مودال ایجاد
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("GetCreateModalData")]
|
||||
public async Task<ActionResult<CreateServiceAmountDto>> GetCreateModalData()
|
||||
{
|
||||
if(!_authHelper.HasPermission(315))
|
||||
return Forbid();
|
||||
var data = await _institutionPlanApplication.GetCreateModalData();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ذخیره درصدها
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("CreateServicePercentage")]
|
||||
public async Task<ActionResult<OperationResult>> CreateServicePercentage([FromBody] CreateServiceAmountDto command)
|
||||
{
|
||||
|
||||
if (!_authHelper.HasPermission(315))
|
||||
return Forbid();
|
||||
|
||||
var result = await _institutionPlanApplication.CreateInstitutionPlanPercentage(command);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// دریافت لیست مبالغ سرویس ها
|
||||
/// </summary>
|
||||
/// <param name="searchModel"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("GetList")]
|
||||
public async Task<ActionResult<PagedResult<InstitutionPlanListDto>>> GetList(InstitutionPlanSearchModel searchModel)
|
||||
{
|
||||
return await _institutionPlanApplication.GetList(searchModel);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user