changes
This commit is contained in:
@@ -19,4 +19,6 @@ public interface IInsuranceJobItemRepositpry : IRepository<long, InsuranceJobIte
|
||||
InsuranceJobItemViewModel GetInsuranceJobItemByInsuranceJobIdForFixedSalary(long insuranceJobId, long jobId,
|
||||
string year, string month);
|
||||
|
||||
(List<string> workshopList, bool hasAnyWorkshop) GetWorkshopUsedThisInsuranceJob(long insuranceJobId);
|
||||
|
||||
}
|
||||
@@ -22,5 +22,8 @@ public class CreateInsuranceJob
|
||||
public List<JobViewModel> Jobs { get; set; }
|
||||
public List<InsuranceJobItemViewModel> InsuranceJobItems { get; set; }
|
||||
|
||||
public List<string> WorkshopList { get; set; }
|
||||
public bool HasAnyWorkshop { get; set; }
|
||||
|
||||
|
||||
}
|
||||
@@ -11,8 +11,23 @@ namespace CompanyManagment.App.Contracts.InsuranceJobItem;
|
||||
public class InsuranceJobItemViewModel
|
||||
{
|
||||
public long Id { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// آیای این درصد در لیست مبالغ مبلغ پر شده دارد
|
||||
/// </summary>
|
||||
public bool IsPercentageLessThanUse { get; set; }
|
||||
public double PercentageLessThan { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// آیای این درصد در لیست مبالغ مبلغ پر شده دارد
|
||||
/// </summary>
|
||||
public bool IsPercentageMoreThanUse { get; set; }
|
||||
public double PercentageMoreThan { get; set; }
|
||||
|
||||
public double SalaeyLessThan { get; set; }
|
||||
public double SalaryMoreThan { get; set; }
|
||||
public string SalaeyLessThanString { get; set; }
|
||||
|
||||
@@ -106,7 +106,7 @@ public class DateSalaryRepository : RepositoryBase<long, DateSalary>, IDateSalar
|
||||
var dateSalary = Get(command.Id);
|
||||
dateSalary.Edit(command.StartDateFa, command.EndDateFa);
|
||||
SaveChanges();
|
||||
command.DateSalaryItems = command.DateSalaryItems.Where(x => x.Salary > 0).ToList();
|
||||
//command.DateSalaryItems = command.DateSalaryItems.Where(x => x.Salary > 0).ToList();
|
||||
foreach (var item in command.DateSalaryItems)
|
||||
{
|
||||
if (item.Id == 0)
|
||||
|
||||
@@ -6,8 +6,10 @@ using _0_Framework.InfraStructure;
|
||||
|
||||
using Company.Domain.InsuranceJobAndJobsAgg;
|
||||
using Company.Domain.InsuranceJobItemAgg;
|
||||
using CompanyManagment.App.Contracts.DateSalaryItem;
|
||||
using CompanyManagment.App.Contracts.InsuranceJobItem;
|
||||
using CompanyManagment.App.Contracts.Job;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace CompanyManagment.EFCore.Repository;
|
||||
|
||||
@@ -94,17 +96,31 @@ public class InsuranceJobItemRepository : RepositoryBase<long, InsuranceJobItem>
|
||||
var searcheDate = ($"{year}/{month}/01").ToGeorgianDateTime();
|
||||
var insuranceJobItems = _context.InsuranceJobItems.Where(i => i.InsuranceJobId == Id && i.StartDate <= searcheDate && i.EndDate >= searcheDate).ToList();
|
||||
var list = new List<InsuranceJobItemViewModel>();
|
||||
var usedParcentsInDateSalaryItems = _context.DateSalaries
|
||||
.Where(x => x.StartDateGr <= searcheDate && x.EndDateGr >= searcheDate)
|
||||
.Include(x => x.DateSalaryItemList)
|
||||
.SelectMany(x => x.DateSalaryItemList)
|
||||
.ToList();
|
||||
|
||||
foreach (var item in insuranceJobItems)
|
||||
{
|
||||
double lessThan = usedParcentsInDateSalaryItems.Any(x => x.Percent == item.PercentageLessThan && x.Salary > 0)
|
||||
? usedParcentsInDateSalaryItems.FirstOrDefault(x => x.Percent == item.PercentageLessThan).Salary
|
||||
: 0;
|
||||
|
||||
double moreThan = usedParcentsInDateSalaryItems.Any(x => x.Percent == item.PercentageMoreThan && x.Salary > 0)
|
||||
? usedParcentsInDateSalaryItems.FirstOrDefault(x => x.Percent == item.PercentageMoreThan).Salary
|
||||
: 0;
|
||||
var obj = new InsuranceJobItemViewModel();
|
||||
obj.Id = item.id;
|
||||
obj.PercentageLessThan = item.PercentageLessThan;
|
||||
obj.IsPercentageLessThanUse = lessThan > 0 ;
|
||||
obj.PercentageMoreThan = item.PercentageMoreThan;
|
||||
obj.IsPercentageMoreThanUse = moreThan > 0;
|
||||
obj.SalaeyLessThan = item.SalaeyLessThan;
|
||||
obj.SalaryMoreThan = item.SalaryMoreThan;
|
||||
obj.SalaeyLessThanString = item.SalaryMoreThan.ToMoney();
|
||||
obj.SalaryMoreThanString = item.SalaryMoreThan.ToMoney();
|
||||
obj.SalaeyLessThanString = lessThan > 0 ? lessThan.ToMoney() : "0";
|
||||
obj.SalaryMoreThanString = moreThan > 0 ? moreThan.ToMoney() : "0";
|
||||
obj.InsuranceJobId = item.InsuranceJobId;
|
||||
obj.StartDate = item.StartDate;
|
||||
obj.EndDate = item.EndDate;
|
||||
@@ -149,6 +165,17 @@ public class InsuranceJobItemRepository : RepositoryBase<long, InsuranceJobItem>
|
||||
return insuranceJobItemViewModel;
|
||||
}
|
||||
|
||||
public (List<string> workshopList, bool hasAnyWorkshop) GetWorkshopUsedThisInsuranceJob(long insuranceJobId)
|
||||
{
|
||||
var workshops = _context.Workshops.Where(x => x.InsuranceJobId == insuranceJobId);
|
||||
if (!workshops.Any())
|
||||
{
|
||||
return (new List<string>(), false);
|
||||
}
|
||||
|
||||
return (workshops.Select(x => x.WorkshopFullName).ToList(), true);
|
||||
}
|
||||
|
||||
public List<InsuranceJobItemViewModel> Search(InsuranceJobItemSearchModel searchModel)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
@@ -11,6 +11,7 @@ using Company.Domain.InsurancJobAgg;
|
||||
using Company.Domain.PercentageAgg;
|
||||
using CompanyManagment.App.Contracts.InsuranceJob;
|
||||
using CompanyManagment.App.Contracts.InsuranceJobItem;
|
||||
using CompanyManagment.App.Contracts.Percentage;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;
|
||||
|
||||
@@ -23,12 +24,15 @@ public class InsuranceJobRepository : RepositoryBase<long, InsuranceJob>, IInsur
|
||||
private readonly TestDbContext _testDbContext;
|
||||
private readonly IInsuranceJobItemRepositpry _insuranceJobItemRepositpry;
|
||||
private readonly IPercentageRepository _percentageRepository;
|
||||
public InsuranceJobRepository(CompanyContext context, IInsuranceJobItemRepositpry insuranceJobItemRepositpry, IPercentageRepository percentageRepository, TestDbContext testDbContext) : base(context)
|
||||
private readonly IDateSalaryItemRepository _dateSalaryItemRepository;
|
||||
|
||||
public InsuranceJobRepository(CompanyContext context, IInsuranceJobItemRepositpry insuranceJobItemRepositpry, IPercentageRepository percentageRepository, TestDbContext testDbContext, IDateSalaryItemRepository dateSalaryItemRepository) : base(context)
|
||||
{
|
||||
_context = context;
|
||||
_insuranceJobItemRepositpry = insuranceJobItemRepositpry;
|
||||
_percentageRepository = percentageRepository;
|
||||
_testDbContext = testDbContext;
|
||||
_dateSalaryItemRepository = dateSalaryItemRepository;
|
||||
}
|
||||
|
||||
public EditInsuranceJob GetDetails(long id, string year, string month)
|
||||
@@ -40,9 +44,12 @@ public class InsuranceJobRepository : RepositoryBase<long, InsuranceJob>, IInsur
|
||||
insuranceJob.EconomicCode = details.EconomicCode;
|
||||
insuranceJob.InsuranceJobTitle = details.InsuranceJobTitle;
|
||||
insuranceJob.InsuranceJobItems = _insuranceJobItemRepositpry.GetInsuranceJobItemByInsuranceJobId(id, year, month);
|
||||
var workshopsUsedThis = _insuranceJobItemRepositpry.GetWorkshopUsedThisInsuranceJob(id);
|
||||
var item = insuranceJob.InsuranceJobItems.FirstOrDefault();
|
||||
insuranceJob.StartDateFa = item != null ? $"{item.StartDate.ToFarsi()}" : "-";
|
||||
insuranceJob.EndDateFa = item != null ? $"{item.EndDate.ToFarsi()}" : "-";
|
||||
insuranceJob.WorkshopList = workshopsUsedThis.workshopList;
|
||||
insuranceJob.HasAnyWorkshop = workshopsUsedThis.hasAnyWorkshop;
|
||||
return insuranceJob;
|
||||
}
|
||||
|
||||
@@ -373,16 +380,33 @@ public class InsuranceJobRepository : RepositoryBase<long, InsuranceJob>, IInsur
|
||||
var insuranceJob = Get(command.Id);
|
||||
insuranceJob.Edit(command.InsuranceJobTitle, command.YearlySalaryId, command.EconomicCode, command.Year);
|
||||
var searcheDate = ($"{command.Year}/{command.Month}/01").ToGeorgianDateTime();
|
||||
var insuranceJobItems = _context.InsuranceJobItems.Where(i => i.InsuranceJobId == command.Id && i.StartDate <= searcheDate && i.EndDate >= searcheDate);
|
||||
//List<long> deleteIds = new List<long>();
|
||||
var insuranceJobItems = _context.InsuranceJobItems
|
||||
.Include(x=>x.InsuranceJobAndJobs)
|
||||
.Where(i => i.InsuranceJobId == command.Id && i.StartDate <= searcheDate && i.EndDate >= searcheDate);
|
||||
|
||||
DateTime? startDate = insuranceJobItems.Select(x => x.StartDate).FirstOrDefault();
|
||||
DateTime? endDate = insuranceJobItems.Select(x => x.EndDate).FirstOrDefault();
|
||||
var insuranceJobItemsIds = insuranceJobItems.Select(x => x.id).ToList();
|
||||
|
||||
var usedParcentsInDateSalaryItems = _context.DateSalaries
|
||||
.Where(x => x.StartDateGr <= searcheDate && x.EndDateGr >= searcheDate)
|
||||
.Include(x => x.DateSalaryItemList)
|
||||
.SelectMany(x => x.DateSalaryItemList)
|
||||
.ToList();
|
||||
//var editedJobItems = command.InsuranceJobItems.Where(x => x.Id != 0).ToList();
|
||||
//var newAdedJobItems = command.InsuranceJobItems.Where(x => x.Id == 0).ToList();
|
||||
|
||||
//foreach (var item in insuranceJobItems)
|
||||
//{
|
||||
|
||||
//}
|
||||
foreach (var item in command.InsuranceJobItems)
|
||||
{
|
||||
long deleteId = insuranceJobItemsIds.Where(x => x == item.Id).FirstOrDefault();
|
||||
if (deleteId != 0)
|
||||
{ insuranceJobItemsIds.Remove(deleteId); }
|
||||
{
|
||||
insuranceJobItemsIds.Remove(deleteId);
|
||||
}
|
||||
|
||||
if (item.Id == 0)
|
||||
{
|
||||
@@ -415,18 +439,52 @@ public class InsuranceJobRepository : RepositoryBase<long, InsuranceJob>, IInsur
|
||||
}
|
||||
|
||||
#region Percentage
|
||||
var percentage = new Percentage(item.PercentageLessThan);
|
||||
if (!_percentageRepository.Exists(x => x.Percent == item.PercentageLessThan))
|
||||
{
|
||||
var percentage = new Percentage(item.PercentageLessThan);
|
||||
|
||||
_percentageRepository.Create(percentage);
|
||||
}
|
||||
var percentage2 = new Percentage(item.PercentageMoreThan);
|
||||
if (!_percentageRepository.Exists(x => x.Percent == item.PercentageMoreThan))
|
||||
{
|
||||
var percentage2 = new Percentage(item.PercentageMoreThan);
|
||||
|
||||
_percentageRepository.Create(percentage2);
|
||||
}
|
||||
_percentageRepository.SaveChanges();
|
||||
#endregion
|
||||
|
||||
|
||||
#region DateSalaryItems
|
||||
|
||||
var checkExitLeesThan = usedParcentsInDateSalaryItems.Any(x => x.Percent == item.PercentageLessThan);
|
||||
if (!checkExitLeesThan && usedParcentsInDateSalaryItems.Any())
|
||||
{
|
||||
|
||||
if(percentage.id == 0)
|
||||
percentage.id = _percentageRepository.Search(new PercentageSearchModel(){Percent = item.PercentageLessThan }).FirstOrDefault()!.Id;
|
||||
|
||||
var dateSalaryId =usedParcentsInDateSalaryItems.FirstOrDefault()!.DateSalaryId;
|
||||
var dateSalaryItem = new DateSalaryItem(item.PercentageLessThan, percentage.id, 0, dateSalaryId);
|
||||
_dateSalaryItemRepository.Create(dateSalaryItem);
|
||||
|
||||
}
|
||||
|
||||
var checkExitMoreThan = usedParcentsInDateSalaryItems.Any(x => x.Percent == item.PercentageMoreThan);
|
||||
if (!checkExitMoreThan && usedParcentsInDateSalaryItems.Any())
|
||||
{
|
||||
if (percentage2.id == 0)
|
||||
percentage2.id = _percentageRepository.Search(new PercentageSearchModel() { Percent = item.PercentageMoreThan }).FirstOrDefault()!.Id;
|
||||
|
||||
var dateSalaryId = usedParcentsInDateSalaryItems.FirstOrDefault()!.DateSalaryId;
|
||||
var dateSalaryItem = new DateSalaryItem(item.PercentageMoreThan, percentage2.id, 0, dateSalaryId);
|
||||
_dateSalaryItemRepository.Create(dateSalaryItem);
|
||||
|
||||
}
|
||||
|
||||
_dateSalaryItemRepository.SaveChanges();
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region removeJobItems
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -199,7 +199,7 @@ public class IndexModel : PageModel
|
||||
|
||||
public IActionResult OnPostEdit(EditInsuranceJob command)
|
||||
{
|
||||
Console.WriteLine(command.Year);
|
||||
|
||||
var result = _insuranceJobApplication.Edit(command);
|
||||
return new JsonResult(result);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
@model CompanyManagment.App.Contracts.DateSalary.CreateDateSalaryForInsuranceJob
|
||||
|
||||
@{
|
||||
<style>
|
||||
.disabled {
|
||||
pointer-events: none;
|
||||
cursor: default;
|
||||
background-color: #b2b2b2 !important;
|
||||
border-color: grey !important;
|
||||
}
|
||||
</style>
|
||||
}
|
||||
<link href="@Href("~/admintheme/css/information-insurance-jobs.css")" rel="stylesheet"/>
|
||||
@Html.AntiForgeryToken()
|
||||
<div class="container">
|
||||
@@ -9,10 +18,10 @@
|
||||
<form>
|
||||
<div class="form">
|
||||
<div class="col-md-6 inputs">
|
||||
<input type="text" id="fromDate" placeholder="تاریخ شروع" class="input upper-in date" value="@Model.StartDateFa">
|
||||
<input type="text" id="fromDate" placeholder="تاریخ شروع" class="input upper-in date disabled" value="@Model.StartDateFa">
|
||||
</div>
|
||||
<div class="col-md-6 inputs">
|
||||
<input type="text" id="toDate" placeholder="تاریخ پایان" class="input upper-in date" style="direction: rtl;" value="@Model.EndDateFa">
|
||||
<input type="text" id="toDate" placeholder="تاریخ پایان" class="input upper-in date disabled" style="direction: rtl;" value="@Model.EndDateFa">
|
||||
</div>
|
||||
<div class="col-md-12 inputs" id="table-container">
|
||||
<table id="table" class="table edit-table table-bordered table-striped">
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
<link href="@Href("~/admintheme/css/index.css")" rel="stylesheet"/>
|
||||
<div id="index" class="row">
|
||||
<div class="col-sm-12 m-r-10">
|
||||
<p class="pull-right">
|
||||
@* <p class="pull-right">
|
||||
<a href="#showmodal=@Url.Page("/Company/InsuranceJob/Index", "CreateInformation")" class="btn btn-rounded waves-effect waves-light m-b-5 btn-show-modal"><i class="fa fa-user-plus"></i> ثبت مبالغ مشاغل مقطوع </a>
|
||||
</p>
|
||||
</p> *@
|
||||
</div>
|
||||
<div class="col-sm-12">
|
||||
<div class="panel-group panel-group-joined" id="accordion-test">
|
||||
|
||||
@@ -180,9 +180,9 @@ input.no-spinner {
|
||||
border: 1px solid #9393938a;
|
||||
}
|
||||
#worksTable th {
|
||||
background-color: #aaecf9;
|
||||
text-align: center;
|
||||
color: #010838;
|
||||
background-color: #a5cfd7 !important;
|
||||
text-align: center;
|
||||
color: #010838;
|
||||
}
|
||||
|
||||
#worksTable thead {
|
||||
|
||||
Reference in New Issue
Block a user