InsuranceJobItems Start End Added - merged
This commit is contained in:
@@ -6,6 +6,7 @@ using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Domain;
|
||||
using CompanyManagment.App.Contracts.InsuranceJob;
|
||||
using CompanyManagment.App.Contracts.InsuranceJobItem;
|
||||
|
||||
namespace Company.Domain.InsurancJobAgg;
|
||||
|
||||
@@ -13,10 +14,16 @@ public interface IInsuranceJobRepositpry:IRepository<long, InsuranceJob>
|
||||
{
|
||||
//OperationResult Create(CreateInsurancJob command);
|
||||
// OperationResult Edit(EditInsurancJob command);
|
||||
EditInsuranceJob GetDetails(long id);
|
||||
EditInsuranceJob GetDetails(long id, string year, string month);
|
||||
List<InsuranceJobViewModel> GetInsurancJob();
|
||||
List<InsuranceJobViewModel> Search(InsuranceJobSearchModel searchModel);
|
||||
OperationResult CreateInsuranceJob(CreateInsuranceJob command);
|
||||
List<(long id, string date)> GetOldYersInsuranceItemIds();
|
||||
OperationResult CopyFromLastYear(CopyFromLastYearViewModel command);
|
||||
OperationResult RecoveryOldData1403();
|
||||
OperationResult Remove(long id);
|
||||
OperationResult EditInsuranceJob(EditInsuranceJob command);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -14,8 +14,11 @@ public interface IInsuranceJobItemRepositpry : IRepository<long, InsuranceJobIte
|
||||
{
|
||||
void CreateInsuranceJobItem(InsuranceJobItemViewModel model);
|
||||
DetailsInsuranceJobItem GetDetails(long id);
|
||||
List<InsuranceJobItemViewModel> GetInsuranceJobItemByInsuranceJobId(long Id);
|
||||
List<InsuranceJobItemViewModel> GetInsuranceJobItemByInsuranceJobId(long Id, string year, string month);
|
||||
List<InsuranceJobItemViewModel> Search(InsuranceJobItemSearchModel searchModel);
|
||||
InsuranceJobItemViewModel GetInsuranceJobItemByInsuranceJobIdForFixedSalary(long insuranceJobId, long jobId);
|
||||
InsuranceJobItemViewModel GetInsuranceJobItemByInsuranceJobIdForFixedSalary(long insuranceJobId, long jobId,
|
||||
string year, string month);
|
||||
|
||||
(List<string> workshopList, bool hasAnyWorkshop) GetWorkshopUsedThisInsuranceJob(long insuranceJobId);
|
||||
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using _0_Framework.Domain;
|
||||
using Company.Domain.InsuranceJobAndJobsAgg;
|
||||
using Company.Domain.InsurancJobAgg;
|
||||
@@ -8,13 +9,15 @@ namespace Company.Domain.InsuranceJobItemAgg;
|
||||
|
||||
public class InsuranceJobItem : EntityBase
|
||||
{
|
||||
public InsuranceJobItem(double percentageLessThan, double salaeyLessThan, double percentageMoreThan, double salaryMoreThan, long insuranceJobId)
|
||||
public InsuranceJobItem(double percentageLessThan, double salaeyLessThan, double percentageMoreThan, double salaryMoreThan, long insuranceJobId, DateTime? startDate, DateTime? endDate)
|
||||
{
|
||||
PercentageLessThan = percentageLessThan;
|
||||
SalaeyLessThan = salaeyLessThan;
|
||||
PercentageMoreThan = percentageMoreThan;
|
||||
SalaryMoreThan = salaryMoreThan;
|
||||
InsuranceJobId = insuranceJobId;
|
||||
StartDate = startDate;
|
||||
EndDate = endDate;
|
||||
}
|
||||
|
||||
public double PercentageLessThan { get; private set; }
|
||||
@@ -22,6 +25,9 @@ public class InsuranceJobItem : EntityBase
|
||||
public double PercentageMoreThan { get; private set; }
|
||||
public double SalaryMoreThan { get; private set; }
|
||||
|
||||
public DateTime? StartDate { get; private set; }
|
||||
public DateTime? EndDate { get; private set; }
|
||||
|
||||
public long InsuranceJobId { get; private set; }
|
||||
public InsuranceJob InsuranceJob { get; set; }
|
||||
public List<InsuranceJobAndJobs> InsuranceJobAndJobs { get; set; }
|
||||
@@ -31,12 +37,14 @@ public class InsuranceJobItem : EntityBase
|
||||
InsuranceJobAndJobs = new List<InsuranceJobAndJobs>();
|
||||
}
|
||||
|
||||
public void Edit(double percentageLessThan, double salaeyLessThan, double percentageMoreThan, double salaryMoreThan, long insuranceJobId)
|
||||
public void Edit(double percentageLessThan, double salaeyLessThan, double percentageMoreThan, double salaryMoreThan, long insuranceJobId, DateTime? startDate, DateTime? endDate)
|
||||
{
|
||||
PercentageLessThan = percentageLessThan;
|
||||
SalaeyLessThan = salaeyLessThan;
|
||||
PercentageMoreThan = percentageMoreThan;
|
||||
SalaryMoreThan = salaryMoreThan;
|
||||
InsuranceJobId = insuranceJobId;
|
||||
StartDate = startDate;
|
||||
EndDate = endDate;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System.Collections.Generic;
|
||||
using CompanyManagment.App.Contracts.InsuranceJobItem;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.InsuranceJob;
|
||||
|
||||
public class CopyFromLastYearViewModel
|
||||
{
|
||||
public string StartDate { get; set; }
|
||||
public string EndDate { get; set; }
|
||||
|
||||
public long InsuranceJobItemId { get; set; }
|
||||
|
||||
public SelectList InsuranceJobItemViewModels { get; set; }
|
||||
}
|
||||
@@ -5,6 +5,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CompanyManagment.App.Contracts.InsuranceJobItem;
|
||||
using CompanyManagment.App.Contracts.Job;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.InsuranceJob;
|
||||
|
||||
@@ -14,7 +15,20 @@ public class CreateInsuranceJob
|
||||
public long YearlySalaryId { get; set; }
|
||||
public string EconomicCode { get; set; }
|
||||
public string Year { get; set; }
|
||||
public string Month { get; set; }
|
||||
public long JobId { get; set; }
|
||||
|
||||
public string StartDateFa { get; set; }
|
||||
public string EndDateFa { get; set; }
|
||||
public List<JobViewModel> Jobs { get; set; }
|
||||
public List<InsuranceJobItemViewModel> InsuranceJobItems { get; set; }
|
||||
|
||||
public List<string> WorkshopList { get; set; }
|
||||
public bool HasAnyWorkshop { get; set; }
|
||||
|
||||
public long InsuranceJobItemId { get; set; }
|
||||
|
||||
public SelectList InsuranceJobItemViewModels { get; set; }
|
||||
|
||||
|
||||
}
|
||||
@@ -10,9 +10,12 @@ namespace CompanyManagment.App.Contracts.InsuranceJob;
|
||||
|
||||
public interface IInsuranceJobApplication
|
||||
{
|
||||
List<(long id, string date)> GetOldYersInsuranceItemIds();
|
||||
OperationResult CopyFromLastYear(CopyFromLastYearViewModel command);
|
||||
OperationResult RecoveryOldData1403();
|
||||
OperationResult Create(CreateInsuranceJob command);
|
||||
OperationResult Edit(EditInsuranceJob command);
|
||||
EditInsuranceJob GetDetails(long id);
|
||||
EditInsuranceJob GetDetails(long id,string year, string month);
|
||||
List<InsuranceJobViewModel> GetInsurancJob();
|
||||
|
||||
List<InsuranceJobViewModel> Search(InsuranceJobSearchModel searchModel);
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CompanyManagment.App.Contracts.InsuranceJobItem;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.InsuranceJob;
|
||||
|
||||
@@ -13,4 +14,7 @@ public class InsuranceJobViewModel
|
||||
//public long YearlySalaryId { get; set; }
|
||||
public string EconomicCode { get; set; }
|
||||
public string Year { get; set; }
|
||||
public string Month { get; set; }
|
||||
public List<InsuranceJobItemViewModel> InsuranceJobItemViewModels { get; set; }
|
||||
|
||||
}
|
||||
@@ -11,14 +11,32 @@ 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; }
|
||||
public string SalaryMoreThanString { get; set; }
|
||||
public long InsuranceJobId { get; set; }
|
||||
|
||||
public DateTime? StartDate { get; set; }
|
||||
public DateTime? EndDate { get; set; }
|
||||
|
||||
public List<long> JobIds { get; set; }
|
||||
public List<JobViewModel> JobList { get; set; }
|
||||
}
|
||||
@@ -19,6 +19,21 @@ public class InsuranceJobApplication: IInsuranceJobApplication
|
||||
_insuranceJobItemRepositpry = insuranceJobItemRepositpry;
|
||||
}
|
||||
|
||||
public List<(long id, string date)> GetOldYersInsuranceItemIds()
|
||||
{
|
||||
return _insuranceJobRepositpry.GetOldYersInsuranceItemIds();
|
||||
}
|
||||
|
||||
public OperationResult CopyFromLastYear(CopyFromLastYearViewModel command)
|
||||
{
|
||||
return _insuranceJobRepositpry.CopyFromLastYear(command);
|
||||
}
|
||||
|
||||
public OperationResult RecoveryOldData1403()
|
||||
{
|
||||
return _insuranceJobRepositpry.RecoveryOldData1403();
|
||||
}
|
||||
|
||||
public OperationResult Create(CreateInsuranceJob command)
|
||||
{
|
||||
var opration = new OperationResult();
|
||||
@@ -32,6 +47,10 @@ public class InsuranceJobApplication: IInsuranceJobApplication
|
||||
if (_insuranceJobRepositpry.Exists(x => x.InsuranceJobTitle == command.InsuranceJobTitle))
|
||||
return opration.Failed("عنوان صنف و درجه تکراری است");
|
||||
|
||||
|
||||
if (command.InsuranceJobItemId == 0)
|
||||
return opration.Failed("بازه را انتخاب کنید");
|
||||
|
||||
//if (_insuranceJobRepositpry.Exists(x => x.EconomicCode == command.EconomicCode))
|
||||
// return opration.Failed("کد اقتصادی تکراری است");
|
||||
|
||||
@@ -116,9 +135,9 @@ public class InsuranceJobApplication: IInsuranceJobApplication
|
||||
return opration.Failed("ویرایش با خطا مواجه شد.");
|
||||
}
|
||||
}
|
||||
public EditInsuranceJob GetDetails(long id)
|
||||
public EditInsuranceJob GetDetails(long id, string year, string month)
|
||||
{
|
||||
return _insuranceJobRepositpry.GetDetails(id);
|
||||
return _insuranceJobRepositpry.GetDetails(id, year,month);
|
||||
}
|
||||
|
||||
public List<InsuranceJobViewModel> GetInsurancJob()
|
||||
|
||||
@@ -1680,6 +1680,7 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
{
|
||||
|
||||
double? result = 0;
|
||||
string month = $"{startDateGr.ToFarsi()}".Substring(5, 2);
|
||||
//اگر مشاغل مقطوع بود و شغلش کارفرما بود
|
||||
// در جدول لیست بیمه قبلی چک شود
|
||||
try
|
||||
@@ -1726,7 +1727,7 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
|
||||
{
|
||||
var inJob = _insuranceJobItemRepository
|
||||
.GetInsuranceJobItemByInsuranceJobId((long)workshop.InsuranceJobId);
|
||||
.GetInsuranceJobItemByInsuranceJobId((long)workshop.InsuranceJobId,year, month);
|
||||
if (workshop.Population == "MoreThan500")
|
||||
{
|
||||
var max = inJob.MaxBy(x => x.PercentageMoreThan);
|
||||
@@ -1775,9 +1776,9 @@ public class InsuranceListApplication: IInsuranceListApplication
|
||||
else
|
||||
{
|
||||
|
||||
var searchModel = new InsuranceJobItemSearchModel();
|
||||
searchModel.InsuranceJobId = (long)insuranceJobId;
|
||||
var JobItem = _insuranceJobItemRepository.GetInsuranceJobItemByInsuranceJobIdForFixedSalary((long)insuranceJobId, jobId);
|
||||
var searchModel = new InsuranceJobItemSearchModel();
|
||||
searchModel.InsuranceJobId = (long)insuranceJobId;
|
||||
var JobItem = _insuranceJobItemRepository.GetInsuranceJobItemByInsuranceJobIdForFixedSalary((long)insuranceJobId, jobId, year, month);
|
||||
|
||||
if (JobItem != null && JobItem.Id != 0)
|
||||
{
|
||||
|
||||
@@ -11,6 +11,9 @@ public class InsuranceJobeItemMapping : IEntityTypeConfiguration<InsuranceJobIte
|
||||
builder.ToTable("InsuranceJobItems");
|
||||
builder.HasKey(x => x.id);
|
||||
|
||||
builder.Property(x => x.StartDate).IsRequired(false);
|
||||
builder.Property(x => x.EndDate).IsRequired(false);
|
||||
|
||||
builder.HasOne(x => x.InsuranceJob)
|
||||
.WithMany(x => x.InsuranceJobItemList)
|
||||
.HasForeignKey(x => x.InsuranceJobId);
|
||||
|
||||
9539
CompanyManagment.EFCore/Migrations/20250517165553_add startEndToInsuranceJobItems.Designer.cs
generated
Normal file
9539
CompanyManagment.EFCore/Migrations/20250517165553_add startEndToInsuranceJobItems.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace CompanyManagment.EFCore.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class addstartEndToInsuranceJobItems : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "EndDate",
|
||||
table: "InsuranceJobItems",
|
||||
type: "datetime2",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "StartDate",
|
||||
table: "InsuranceJobItems",
|
||||
type: "datetime2",
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "EndDate",
|
||||
table: "InsuranceJobItems");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "StartDate",
|
||||
table: "InsuranceJobItems");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3219,6 +3219,9 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
b.Property<DateTime>("CreationDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime?>("EndDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<long>("InsuranceJobId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
@@ -3234,6 +3237,9 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
b.Property<double>("SalaryMoreThan")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<DateTime?>("StartDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.HasKey("id");
|
||||
|
||||
b.HasIndex("InsuranceJobId");
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -23,7 +25,7 @@ public class InsuranceJobItemRepository : RepositoryBase<long, InsuranceJobItem>
|
||||
{
|
||||
|
||||
InsuranceJobItem incuranceJobItemObj = new InsuranceJobItem(model.PercentageLessThan, model.SalaeyLessThan,
|
||||
model.PercentageMoreThan, model.SalaryMoreThan, model.InsuranceJobId);
|
||||
model.PercentageMoreThan, model.SalaryMoreThan, model.InsuranceJobId, model.StartDate,model.EndDate);
|
||||
_context.InsuranceJobItems.Add(incuranceJobItemObj);
|
||||
_context.SaveChanges();
|
||||
List<InsuranceJobAndJobs> insuranceJobAndJobsList = new List<InsuranceJobAndJobs>();
|
||||
@@ -44,7 +46,7 @@ public class InsuranceJobItemRepository : RepositoryBase<long, InsuranceJobItem>
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public List<InsuranceJobItemViewModel> GetInsuranceJobItemByInsuranceJobId(long Id)
|
||||
public List<InsuranceJobItemViewModel> GetInsuranceJobItemByInsuranceJobId(long Id, string year, string month)
|
||||
{
|
||||
|
||||
//var list = _context.InsuranceJobItems.Where(x => x.InsuranceJobId == Id).ToList().Select(x=>new InsuranceJobItemViewModel()
|
||||
@@ -91,21 +93,37 @@ public class InsuranceJobItemRepository : RepositoryBase<long, InsuranceJobItem>
|
||||
|
||||
// list.Add(obj);
|
||||
//}
|
||||
|
||||
var insuranceJobItems = _context.InsuranceJobItems.Where(x => x.InsuranceJobId == Id).ToList();
|
||||
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;
|
||||
obj.JobIds = _context.InsuranceJobAndJobsSet.Where(p => p.InsuranceJobItemId == item.id)
|
||||
.Select(p => p.JobId).ToList();
|
||||
obj.JobList = _context.Jobs.Where(x => obj.JobIds.Contains(x.id)).ToList().Select(x =>
|
||||
@@ -122,10 +140,11 @@ public class InsuranceJobItemRepository : RepositoryBase<long, InsuranceJobItem>
|
||||
}
|
||||
|
||||
|
||||
public InsuranceJobItemViewModel GetInsuranceJobItemByInsuranceJobIdForFixedSalary(long insuranceJobId, long jobId)
|
||||
public InsuranceJobItemViewModel GetInsuranceJobItemByInsuranceJobIdForFixedSalary(long insuranceJobId, long jobId, string year, string month)
|
||||
{
|
||||
var searcheDate = ($"{year}/{month}/01").ToGeorgianDateTime();
|
||||
var insuranceJobItemViewModel = new InsuranceJobItemViewModel();
|
||||
var insuranceJobItems = _context.InsuranceJobItems.Where(x => x.InsuranceJobId == insuranceJobId).ToList();
|
||||
var insuranceJobItems = _context.InsuranceJobItems.Where(i => i.InsuranceJobId == insuranceJobId && i.StartDate <= searcheDate && i.EndDate >= searcheDate).ToList();
|
||||
var insuranceJobItemIds = insuranceJobItems.Select(x => x.id).ToList();
|
||||
var jobAndJob = _context.InsuranceJobAndJobsSet
|
||||
.Where(x => insuranceJobItemIds.Contains(x.InsuranceJobItemId) && x.JobId == jobId).FirstOrDefault();
|
||||
@@ -146,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();
|
||||
|
||||
@@ -3,11 +3,17 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.InfraStructure;
|
||||
using Company.Domain.DateSalaryAgg;
|
||||
using Company.Domain.DateSalaryItemAgg;
|
||||
using Company.Domain.InsuranceJobAndJobsAgg;
|
||||
using Company.Domain.InsuranceJobItemAgg;
|
||||
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;
|
||||
|
||||
|
||||
namespace CompanyManagment.EFCore.Repository;
|
||||
@@ -15,16 +21,21 @@ namespace CompanyManagment.EFCore.Repository;
|
||||
public class InsuranceJobRepository : RepositoryBase<long, InsuranceJob>, IInsuranceJobRepositpry
|
||||
{
|
||||
private readonly CompanyContext _context;
|
||||
private readonly TestDbContext _testDbContext;
|
||||
private readonly IInsuranceJobItemRepositpry _insuranceJobItemRepositpry;
|
||||
private readonly IPercentageRepository _percentageRepository;
|
||||
public InsuranceJobRepository(CompanyContext context, IInsuranceJobItemRepositpry insuranceJobItemRepositpry , IPercentageRepository percentageRepository) : 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)
|
||||
public EditInsuranceJob GetDetails(long id, string year, string month)
|
||||
{
|
||||
var insuranceJob = new EditInsuranceJob();
|
||||
var details = Get(id);
|
||||
@@ -32,7 +43,13 @@ public class InsuranceJobRepository : RepositoryBase<long, InsuranceJob>, IInsur
|
||||
insuranceJob.Year = details.Year;
|
||||
insuranceJob.EconomicCode = details.EconomicCode;
|
||||
insuranceJob.InsuranceJobTitle = details.InsuranceJobTitle;
|
||||
insuranceJob.InsuranceJobItems = _insuranceJobItemRepositpry.GetInsuranceJobItemByInsuranceJobId(id);
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -49,16 +66,33 @@ public class InsuranceJobRepository : RepositoryBase<long, InsuranceJob>, IInsur
|
||||
|
||||
public List<InsuranceJobViewModel> Search(InsuranceJobSearchModel searchModel)
|
||||
{
|
||||
var query = _context.InsuranceJobs.Select(x => new InsuranceJobViewModel
|
||||
{
|
||||
Id = x.id,
|
||||
InsuranceJobTitle = x.InsuranceJobTitle,
|
||||
EconomicCode = x.EconomicCode
|
||||
});
|
||||
|
||||
string now = Tools.ToFarsi(DateTime.Now);
|
||||
string year = now.Substring(0, 4);
|
||||
string month = now.Substring(5, 2);
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.Year))
|
||||
year = searchModel.Year;
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.Month))
|
||||
month = searchModel.Month;
|
||||
|
||||
|
||||
var searcheDate = ($"{year}/{month}/01").ToGeorgianDateTime();
|
||||
var query = _context.InsuranceJobs
|
||||
.Include(x => x.InsuranceJobItemList).Where(x => x.InsuranceJobItemList.Any(i => i.StartDate <= searcheDate && i.EndDate >= searcheDate))
|
||||
.Select(x => new InsuranceJobViewModel
|
||||
{
|
||||
Id = x.id,
|
||||
InsuranceJobTitle = x.InsuranceJobTitle,
|
||||
EconomicCode = x.EconomicCode,
|
||||
Year = year,
|
||||
Month = month,
|
||||
|
||||
|
||||
});
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.EconomicCode))
|
||||
query = query.Where(x => x.EconomicCode.Contains(searchModel.EconomicCode));
|
||||
|
||||
query = query.Where(x => x.EconomicCode.Contains(searchModel.EconomicCode));
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.InsuranceJobTitle))
|
||||
query = query.Where(x => x.InsuranceJobTitle.Contains(searchModel.InsuranceJobTitle));
|
||||
|
||||
@@ -67,7 +101,21 @@ public class InsuranceJobRepository : RepositoryBase<long, InsuranceJob>, IInsur
|
||||
|
||||
public OperationResult CreateInsuranceJob(CreateInsuranceJob command)
|
||||
{
|
||||
OperationResult result = new OperationResult();
|
||||
OperationResult result = new OperationResult();
|
||||
var insuranceJobItemObj = _insuranceJobItemRepositpry.Get(command.InsuranceJobItemId);
|
||||
if (insuranceJobItemObj == null)
|
||||
return result.Failed("آیتم شغلی انتخاب شده وجود ندارد");
|
||||
|
||||
List<double> percentaegJoin = new List<double>();
|
||||
var percentageLessThan = command.InsuranceJobItems.Select(x => x.PercentageLessThan).ToList();
|
||||
var percentageMoreThan = command.InsuranceJobItems.Select(x => x.PercentageMoreThan).ToList();
|
||||
if (percentageMoreThan != null)
|
||||
{
|
||||
percentaegJoin = percentageLessThan
|
||||
.Concat(percentageMoreThan)
|
||||
.Distinct()
|
||||
.ToList();
|
||||
}
|
||||
using (var transaction = _context.Database.BeginTransaction())
|
||||
{
|
||||
try
|
||||
@@ -80,6 +128,8 @@ public class InsuranceJobRepository : RepositoryBase<long, InsuranceJob>, IInsur
|
||||
item.PercentageLessThan = item.PercentageLessThan;
|
||||
item.PercentageMoreThan = item.PercentageMoreThan;
|
||||
item.InsuranceJobId = insuranceJobObj.id;
|
||||
item.StartDate = insuranceJobItemObj.StartDate;
|
||||
item.EndDate = insuranceJobItemObj.EndDate;
|
||||
_insuranceJobItemRepositpry.CreateInsuranceJobItem(item);
|
||||
|
||||
if (!_percentageRepository.Exists(x => x.Percent == item.PercentageLessThan))
|
||||
@@ -93,16 +143,39 @@ public class InsuranceJobRepository : RepositoryBase<long, InsuranceJob>, IInsur
|
||||
var percentage2 = new Percentage(item.PercentageMoreThan);
|
||||
_percentageRepository.Create(percentage2);
|
||||
}
|
||||
|
||||
|
||||
_percentageRepository.SaveChanges();
|
||||
}
|
||||
|
||||
var dateSalary = _context.DateSalaries.FirstOrDefault(x =>
|
||||
x.StartDateGr == insuranceJobItemObj.StartDate && x.EndDateGr == insuranceJobItemObj.EndDate);
|
||||
var percentages = _context.Percentages.Select(x => new { x.id, x.Percent }).ToList();
|
||||
var dateSalaryItemList = new List<DateSalaryItem>();
|
||||
foreach (var percent in percentaegJoin)
|
||||
{
|
||||
var percentageId = percentages.FirstOrDefault(x => x.Percent == percent);
|
||||
if (percentageId != null)
|
||||
{
|
||||
|
||||
var dateSalaryItem = new DateSalaryItem(percent, percentageId.id, 0, dateSalary.id);
|
||||
dateSalaryItemList.Add(dateSalaryItem);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (dateSalaryItemList.Count > 0)
|
||||
{
|
||||
_context.DateSalaryItems.AddRange(dateSalaryItemList);
|
||||
_context.SaveChanges();
|
||||
}
|
||||
// SaveChanges();
|
||||
transaction.Commit();
|
||||
result.IsSuccedded = true;
|
||||
result.Message = "ثبت اطلاعات با موفقیت انجام شد";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
{
|
||||
transaction.Rollback();
|
||||
result.Failed("ثبت اطلاعات با خطا مواجه شد");
|
||||
}
|
||||
@@ -110,14 +183,224 @@ public class InsuranceJobRepository : RepositoryBase<long, InsuranceJob>, IInsur
|
||||
return result;
|
||||
}
|
||||
|
||||
public OperationResult Remove(long id)
|
||||
public List<(long id, string date)> GetOldYersInsuranceItemIds()
|
||||
{
|
||||
var res = _context.InsuranceJobItems.Where(x=>x.StartDate != null && x.EndDate != null)
|
||||
.GroupBy(x => x.StartDate)
|
||||
.Select(g => g.First())
|
||||
.ToList().Select(x => new InsuranceJobItemViewModel()
|
||||
{
|
||||
Id = x.id,
|
||||
StartDate = x.StartDate,
|
||||
EndDate = x.EndDate,
|
||||
|
||||
|
||||
});
|
||||
|
||||
return res.Select(x => (x.Id, $"{(x.StartDate.HasValue ? x.StartDate.Value.ToFarsi() : "نامشخص")} - {(x.EndDate.HasValue ? x.EndDate.Value.ToFarsi() : "نامشخص")}")).ToList();
|
||||
|
||||
}
|
||||
|
||||
public OperationResult CopyFromLastYear(CopyFromLastYearViewModel command)
|
||||
{
|
||||
var op = new OperationResult();
|
||||
if (command.InsuranceJobItemId == 0)
|
||||
return op.Failed("بازه را انتخاب کنید");
|
||||
DateTime startDateGr = new DateTime();
|
||||
DateTime endDateGr = new DateTime();
|
||||
try
|
||||
{
|
||||
startDateGr = command.StartDate.ToGeorgianDateTime();
|
||||
endDateGr = command.EndDate.ToGeorgianDateTime();
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return op.Failed("تاریخ به درستی وارد نشده است");
|
||||
|
||||
}
|
||||
|
||||
|
||||
var chekExist = _insuranceJobItemRepositpry.Exists(x => x.StartDate < endDateGr && x.EndDate > startDateGr);
|
||||
if (chekExist)
|
||||
return op.Failed("بازه تاریخ وارد شده با بازه های قبلی تداخل دارد");
|
||||
|
||||
var insuranceJobItemObj = _insuranceJobItemRepositpry.Get(command.InsuranceJobItemId);
|
||||
if (insuranceJobItemObj == null)
|
||||
return op.Failed("آیتم شغلی انتخاب شده وجود ندارد");
|
||||
var insuranceJobItemList = _context.InsuranceJobItems
|
||||
.Include(jobs => jobs.InsuranceJobAndJobs)
|
||||
.Where(x => x.StartDate == insuranceJobItemObj.StartDate).Select(x => new InsuranceJobItemViewModel()
|
||||
{
|
||||
PercentageLessThan = x.PercentageLessThan,
|
||||
PercentageMoreThan = x.PercentageMoreThan,
|
||||
InsuranceJobId = x.InsuranceJobId,
|
||||
StartDate = startDateGr,
|
||||
EndDate = endDateGr,
|
||||
JobIds = x.InsuranceJobAndJobs.Select(j => j.JobId).ToList()
|
||||
}).ToList();
|
||||
|
||||
if (!insuranceJobItemList.Any())
|
||||
return op.Failed("خطا");
|
||||
List<double> percentaegJoin = new List<double>();
|
||||
var percentageLessThan = insuranceJobItemList.Select(x => x.PercentageLessThan).ToList();
|
||||
var percentageMoreThan = insuranceJobItemList.Select(x => x.PercentageMoreThan).ToList();
|
||||
if (percentageMoreThan != null)
|
||||
{
|
||||
percentaegJoin = percentageLessThan
|
||||
.Concat(percentageMoreThan)
|
||||
.Distinct()
|
||||
.ToList();
|
||||
}
|
||||
|
||||
using (var transaction = _context.Database.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
foreach (var item in insuranceJobItemList)
|
||||
{
|
||||
|
||||
_insuranceJobItemRepositpry.CreateInsuranceJobItem(item);
|
||||
|
||||
|
||||
if (!_percentageRepository.Exists(x => x.Percent == item.PercentageLessThan))
|
||||
{
|
||||
var percentage = new Percentage(item.PercentageLessThan);
|
||||
_percentageRepository.Create(percentage);
|
||||
}
|
||||
|
||||
if (!_percentageRepository.Exists(x => x.Percent == item.PercentageMoreThan))
|
||||
{
|
||||
var percentage2 = new Percentage(item.PercentageMoreThan);
|
||||
_percentageRepository.Create(percentage2);
|
||||
}
|
||||
|
||||
_percentageRepository.SaveChanges();
|
||||
}
|
||||
|
||||
var dateSalary = new DateSalary(command.StartDate, command.EndDate);
|
||||
_context.DateSalaries.Add(dateSalary);
|
||||
_context.SaveChanges();
|
||||
var percentages = _context.Percentages.Select(x=> new{x.id, x.Percent}).ToList();
|
||||
var dateSalaryItemList = new List<DateSalaryItem>();
|
||||
foreach (var percent in percentaegJoin)
|
||||
{
|
||||
var percentageId = percentages.FirstOrDefault(x => x.Percent == percent);
|
||||
if (percentageId != null)
|
||||
{
|
||||
|
||||
var dateSalaryItem = new DateSalaryItem(percent, percentageId.id, 0, dateSalary.id);
|
||||
dateSalaryItemList.Add(dateSalaryItem);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (dateSalaryItemList.Count > 0)
|
||||
{
|
||||
_context.DateSalaryItems.AddRange(dateSalaryItemList);
|
||||
_context.SaveChanges();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// SaveChanges();
|
||||
transaction.Commit();
|
||||
op.IsSuccedded = true;
|
||||
op.Message = "ثبت اطلاعات با موفقیت انجام شد";
|
||||
return op;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
transaction.Rollback();
|
||||
return op.Failed("ثبت اطلاعات با خطا مواجه شد");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public OperationResult RecoveryOldData1403()
|
||||
{
|
||||
|
||||
OperationResult result = new OperationResult();
|
||||
using (var transaction = _context.Database.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
var insuranceJobItems = _context.InsuranceJobItems.Where(x=>x.InsuranceJobId==id).ToList();
|
||||
var res = _testDbContext.InsuranceJobItems.Include(x => x.InsuranceJobAndJobs).ToList();
|
||||
foreach (var item in res)
|
||||
{
|
||||
var createItem = new InsuranceJobItem(item.PercentageLessThan, 0, item.PercentageMoreThan, 0,
|
||||
item.InsuranceJobId, item.StartDate, item.EndDate);
|
||||
_context.InsuranceJobItems.Add(createItem);
|
||||
_context.SaveChanges();
|
||||
|
||||
List<InsuranceJobAndJobs> insuranceJobAndJobsList = new List<InsuranceJobAndJobs>();
|
||||
foreach (var jobItem in item.InsuranceJobAndJobs)
|
||||
{
|
||||
var insuranceJobAndJobsObj = new InsuranceJobAndJobs();
|
||||
insuranceJobAndJobsObj.JobId = jobItem.JobId;
|
||||
insuranceJobAndJobsObj.InsuranceJobItemId = createItem.id;
|
||||
insuranceJobAndJobsList.Add(insuranceJobAndJobsObj);
|
||||
}
|
||||
_context.InsuranceJobAndJobsSet.AddRange(insuranceJobAndJobsList);
|
||||
_context.SaveChanges();
|
||||
|
||||
|
||||
if (!_percentageRepository.Exists(x => x.Percent == item.PercentageLessThan))
|
||||
{
|
||||
var percentage = new Percentage(item.PercentageLessThan);
|
||||
_percentageRepository.Create(percentage);
|
||||
}
|
||||
|
||||
if (!_percentageRepository.Exists(x => x.Percent == item.PercentageMoreThan))
|
||||
{
|
||||
var percentage2 = new Percentage(item.PercentageMoreThan);
|
||||
_percentageRepository.Create(percentage2);
|
||||
}
|
||||
|
||||
_percentageRepository.SaveChanges();
|
||||
|
||||
}
|
||||
|
||||
transaction.Commit();
|
||||
result.IsSuccedded = true;
|
||||
result.Message = "حذف اطلاعات با موفقیت انجام شد";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
transaction.Rollback();
|
||||
result.Failed("ثبت اطلاعات با خطا مواجه شد");
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
|
||||
}
|
||||
public OperationResult Remove(long id)
|
||||
{
|
||||
OperationResult result = new OperationResult();
|
||||
var insuranceJobItems = _context.InsuranceJobItems.Where(x => x.InsuranceJobId == id).ToList();
|
||||
var start = insuranceJobItems.FirstOrDefault()!.StartDate;
|
||||
var end = insuranceJobItems.FirstOrDefault()!.StartDate;
|
||||
var usedParcentsInDateSalaryItems = _context.DateSalaries
|
||||
.Where(x => x.StartDateGr == start && x.EndDateGr >= end)
|
||||
.Include(x => x.DateSalaryItemList)
|
||||
.SelectMany(x => x.DateSalaryItemList)
|
||||
.ToList();
|
||||
var itemsLessThan = insuranceJobItems.Select(x => x.PercentageLessThan).ToList();
|
||||
var itemsMoreThan = insuranceJobItems.Select(x => x.PercentageMoreThan).ToList();
|
||||
bool lessThan = usedParcentsInDateSalaryItems.Any(x => itemsLessThan.Contains(x.Percent) && x.Salary > 0);
|
||||
bool moreThan = usedParcentsInDateSalaryItems.Any(x => itemsMoreThan.Contains(x.Percent) && x.Salary > 0);
|
||||
if (lessThan || moreThan)
|
||||
return result.Failed("درصد های این صنف دارای مبلغ می باشند");
|
||||
using (var transaction = _context.Database.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
_context.InsuranceJobItems.RemoveRange(insuranceJobItems);
|
||||
|
||||
var insuranceJobObj = Get(id);
|
||||
@@ -147,33 +430,54 @@ public class InsuranceJobRepository : RepositoryBase<long, InsuranceJob>, IInsur
|
||||
{
|
||||
var insuranceJob = Get(command.Id);
|
||||
insuranceJob.Edit(command.InsuranceJobTitle, command.YearlySalaryId, command.EconomicCode, command.Year);
|
||||
|
||||
var insuranceJobItemsIds = _context.InsuranceJobItems.Where(x => x.InsuranceJobId == command.Id).Select(x=>x.id).ToList();
|
||||
//List<long> deleteIds = new List<long>();
|
||||
var searcheDate = ($"{command.Year}/{command.Month}/01").ToGeorgianDateTime();
|
||||
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);}
|
||||
long deleteId = insuranceJobItemsIds.Where(x => x == item.Id).FirstOrDefault();
|
||||
if (deleteId != 0)
|
||||
{
|
||||
insuranceJobItemsIds.Remove(deleteId);
|
||||
}
|
||||
|
||||
if (item.Id == 0)
|
||||
{
|
||||
item.PercentageLessThan = item.PercentageLessThan;
|
||||
item.PercentageMoreThan = item.PercentageMoreThan;
|
||||
item.InsuranceJobId = command.Id;
|
||||
item.StartDate = startDate;
|
||||
item.EndDate = endDate;
|
||||
_insuranceJobItemRepositpry.CreateInsuranceJobItem(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
var insuranceJobItem = _insuranceJobItemRepositpry.Get(item.Id);
|
||||
insuranceJobItem.Edit(item.PercentageLessThan, item.SalaeyLessThan, item.PercentageMoreThan, item.SalaryMoreThan, command.Id);
|
||||
insuranceJobItem.Edit(item.PercentageLessThan, item.SalaeyLessThan, item.PercentageMoreThan, item.SalaryMoreThan, command.Id, startDate, endDate);
|
||||
|
||||
#region JobAndJob
|
||||
|
||||
var jobAndJobList = _context.InsuranceJobAndJobsSet .Where(x => x.InsuranceJobItemId == item.Id).ToList();
|
||||
var jobAndJobList = _context.InsuranceJobAndJobsSet.Where(x => x.InsuranceJobItemId == item.Id).ToList();
|
||||
_context.InsuranceJobAndJobsSet.RemoveRange(jobAndJobList);
|
||||
List <InsuranceJobAndJobs> insuranceJobAndJobsList = new List<InsuranceJobAndJobs>();
|
||||
List<InsuranceJobAndJobs> insuranceJobAndJobsList = new List<InsuranceJobAndJobs>();
|
||||
foreach (var item2 in item.JobIds)
|
||||
{
|
||||
var insuranceJobAndJobsObj = new InsuranceJobAndJobs();
|
||||
@@ -186,25 +490,59 @@ 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();
|
||||
_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
|
||||
var deleteList = _context.InsuranceJobItems.Where(x => insuranceJobItemsIds.Contains(x.id)).ToList();
|
||||
_context.InsuranceJobItems.RemoveRange(deleteList);
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
_context.SaveChanges();
|
||||
transaction.Commit();
|
||||
|
||||
39
CompanyManagment.EFCore/TestDbContext.cs
Normal file
39
CompanyManagment.EFCore/TestDbContext.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using Company.Domain.InsuranceJobItemAgg;
|
||||
using Company.Domain.InsurancJobAgg;
|
||||
using Company.Domain.RollCallAgg;
|
||||
using CompanyManagment.EFCore.Mapping;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CompanyManagment.EFCore
|
||||
{
|
||||
public class TestDbContext : DbContext
|
||||
{
|
||||
public DbSet<InsuranceJobItem> InsuranceJobItems { get; set; }
|
||||
public DbSet<InsuranceJob> InsuranceJobs { get; set; }
|
||||
|
||||
public TestDbContext(DbContextOptions<TestDbContext> options) : base(options)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
public TestDbContext()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
var assembly = typeof(PersonalContractingpartyMapping).Assembly;
|
||||
modelBuilder.ApplyConfigurationsFromAssembly(assembly);
|
||||
base.OnModelCreating(modelBuilder);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
21
PersonalContractingParty.Config/TestDbBootStrapper.cs
Normal file
21
PersonalContractingParty.Config/TestDbBootStrapper.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using Company.Domain.InsuranceJobItemAgg;
|
||||
using Company.Domain.InsurancJobAgg;
|
||||
using CompanyManagment.App.Contracts.InsuranceJob;
|
||||
using CompanyManagment.Application;
|
||||
using CompanyManagment.EFCore;
|
||||
using CompanyManagment.EFCore.Repository;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace PersonalContractingParty.Config;
|
||||
|
||||
public class TestDbBootStrapper
|
||||
{
|
||||
public static void Configure(IServiceCollection services, string connectionString)
|
||||
{
|
||||
services.AddTransient<IInsuranceJobApplication, InsuranceJobApplication>();
|
||||
services.AddTransient<IInsuranceJobRepositpry, InsuranceJobRepository>();
|
||||
services.AddTransient<IInsuranceJobItemRepositpry, InsuranceJobItemRepository>();
|
||||
services.AddDbContext<TestDbContext>(x => x.UseSqlServer(connectionString));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
@model CompanyManagment.App.Contracts.InsuranceJob.CopyFromLastYearViewModel
|
||||
@{
|
||||
<style>
|
||||
.input {
|
||||
border: 1px solid #0000004a;
|
||||
border-radius: 7px;
|
||||
padding: 7px;
|
||||
width: 100%;
|
||||
background: whitesmoke;
|
||||
}
|
||||
|
||||
.input:focus {
|
||||
box-shadow: 0 2px 5px 0 rgb(136 137 141), 0 2px 10px 0 rgba(0, 0, 0, 0.12);
|
||||
}
|
||||
</style>
|
||||
}
|
||||
|
||||
<div class="modal-header" id="createContractingParty">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
</div>
|
||||
<form asp-page="./Index" asp-page-handler="CopyFromLastYear" autocomplete="off"
|
||||
method="post"
|
||||
data-ajax="true"
|
||||
data-callback=""
|
||||
data-action="Refresh"
|
||||
enctype="multipart/form-data">
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
<fieldset style="border: 1px solid #999797; border-radius: 10px; padding: revert;padding-bottom: 30px">
|
||||
<legend style="margin-bottom: 5px; font-size: large; border-bottom: 0px; color: #505458; width: 394px; text-align: center;"> ساخت لیست اصناف با استفاده از داده های قبلی</legend>
|
||||
|
||||
<div class="flexible-wrap">
|
||||
<div class="row">
|
||||
<div class="col-md-12 col-xs-12">
|
||||
<div class="form-group">
|
||||
|
||||
<select class="form-control select-city" asp-for="InsuranceJobItemId" asp-items='@Model.InsuranceJobItemViewModels'>
|
||||
<option value="0">انتخاب بازه زمانی</option>
|
||||
</select>
|
||||
<span asp-validation-for="InsuranceJobItemId" class="error"></span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6 inputs">
|
||||
<input type="text" style="text-align: center" id="fromDate" placeholder="تاریخ شروع" asp-for="StartDate" class="input upper-in date">
|
||||
</div>
|
||||
<div class="col-md-6 inputs">
|
||||
<input type="text" style="text-align: center" id="toDate" placeholder="تاریخ پایان" asp-for="EndDate" class="input upper-in date" style="direction: rtl;">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
@*<input type="hidden" asp-for="id" value="id"/>*@
|
||||
|
||||
<div class="modal-footer">
|
||||
@*<button type="button" class="btn btn-default waves-effect" data-dismiss="modal">بستن</button>*@
|
||||
<button type="submit" class="btn btn-success btn-rounded waves-effect waves-light" id="save"> ذخیره </button>
|
||||
<button type="button" class="btn btn-default btn-rounded waves-effect waves-light m-b-5" data-dismiss="modal">بستن </button>
|
||||
</div>
|
||||
</form>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$(".select-city").select2({
|
||||
language: "fa",
|
||||
dir: "rtl"
|
||||
});
|
||||
});
|
||||
|
||||
$(document).ready(function() {
|
||||
$(".date").mask("0000/00/00");
|
||||
});
|
||||
|
||||
|
||||
$(".date").keyup(function() {
|
||||
const value = $(this).val();
|
||||
const lengthValue = value.length;
|
||||
|
||||
if (lengthValue == 10) {
|
||||
if (!dateValidCheck(this)) {
|
||||
$(this).addClass("errored");
|
||||
} else {
|
||||
$(this).removeClass("errored");
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
</script>
|
||||
@@ -25,12 +25,31 @@
|
||||
<label>عنوان صنف و درجه</label>
|
||||
<input type="text" placeholder="" class="input" id="insuranceJobTitle" asp-for="InsuranceJobTitle" tabindex="1">
|
||||
</div>
|
||||
<div class="col-md-12 inputs" style="display: flex;">
|
||||
<label> کد اقتصادی </label>
|
||||
<input type="text" placeholder="" class="input" style="direction: rtl;" id="economicCode" asp-for="EconomicCode" tabindex="2">
|
||||
</div>
|
||||
<div class="col-md-12 inputs" style="display: flex;">
|
||||
<label> کد اقتصادی </label>
|
||||
<input type="text" placeholder="" class="input" style="direction: rtl;" id="economicCode" asp-for="EconomicCode" tabindex="2">
|
||||
</div>
|
||||
|
||||
@* <div class="col-md-6 inputs">
|
||||
<input type="text" style="text-align: center" id="fromDate" placeholder="تاریخ شروع" asp-for="StartDateFa" class="input upper-in date">
|
||||
</div>
|
||||
<div class="col-md-6 inputs">
|
||||
<input type="text" style="text-align: center" id="toDate" placeholder="تاریخ پایان" asp-for="EndDateFa" class="input upper-in date" style="direction: rtl;">
|
||||
</div> *@
|
||||
<div class="row">
|
||||
<div class="col-md-12 col-xs-12">
|
||||
<div class="form-group">
|
||||
|
||||
<div class="col-md-12 inputs" id="table-container">
|
||||
<select class="form-control select-city" id="insuranceJobItemIdselected" asp-for="InsuranceJobItemId" asp-items='@Model.InsuranceJobItemViewModels'>
|
||||
<option value="0">انتخاب بازه زمانی</option>
|
||||
</select>
|
||||
<span asp-validation-for="InsuranceJobItemId" class="error"></span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-12 inputs" id="table-container">
|
||||
<table id="worksTable" class="table table-bordered table-striped">
|
||||
<thead style="background-color: #a9fcff">
|
||||
<tr>
|
||||
@@ -97,7 +116,8 @@
|
||||
<script src="~/lib/select2/js/select2.js"></script>
|
||||
<script src="~/lib/select2/js/i18n/fa.js"></script>
|
||||
<link href="~/AdminTheme/assets/datatables/jquery.dataTables.min.css" rel="stylesheet" type="text/css"/>
|
||||
<link href="~/lib/select2/css/select2.css" rel="stylesheet"/>
|
||||
<link href="~/lib/select2/css/select2.css" rel="stylesheet"/>
|
||||
<script src="~/AdminTheme/js/numeral.min.js"></script>
|
||||
//<script src="~/AdminTheme/js/numeral.min.js"></script>
|
||||
}
|
||||
<script>
|
||||
@@ -155,14 +175,43 @@
|
||||
|
||||
});
|
||||
|
||||
$(document).ready(function() {
|
||||
$(".date").mask("0000/00/00");
|
||||
});
|
||||
|
||||
|
||||
$(".date").keyup(function() {
|
||||
const value = $(this).val();
|
||||
const lengthValue = value.length;
|
||||
|
||||
if (lengthValue == 10) {
|
||||
if (!dateValidCheck(this)) {
|
||||
$(this).addClass("errored");
|
||||
} else {
|
||||
$(this).removeClass("errored");
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function sendData() {
|
||||
if (!$('#save').is('[disabled=disabled]')) {
|
||||
const fromDate = $("#fromDate").val();
|
||||
const toDate = $("#toDate").val();
|
||||
console.log(fromDate);
|
||||
console.log(toDate);
|
||||
|
||||
|
||||
var allInputsFilled = true;
|
||||
$('.ratioLess, .ratioMore , #EconomicCode , #InsuranceJobTitle').each(function() {
|
||||
if ($(this).val() === '' || $(this).val() === 0) {
|
||||
allInputsFilled = false;
|
||||
$(this).addClass('errored');
|
||||
|
||||
} else {
|
||||
$(this).removeClass('errored');
|
||||
}
|
||||
@@ -177,13 +226,19 @@
|
||||
$(this).removeClass('errored');
|
||||
}
|
||||
});
|
||||
|
||||
if (!allInputsFilled) {
|
||||
$.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', "لطفا تمام فیلد ها را تکمیل کنید");
|
||||
} else {
|
||||
$.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', "لطفا خطاها را برطرف کنید");
|
||||
|
||||
}
|
||||
else {
|
||||
var itemId = Number($("#insuranceJobItemIdselected").val());
|
||||
$('#divData').html('');
|
||||
$("#save").prop("disabled", true);
|
||||
$('#divData').append(`<input type="hidden" name="EconomicCode" id="EconomicCode" value="${$("#economicCode").val()}" />`);
|
||||
$('#divData').append(`<input type="hidden" name="InsuranceJobTitle" id="InsuranceJobTitle" value="${$("#insuranceJobTitle").val()}" />`);
|
||||
$('#divData').append(`<input type="hidden" name="insuranceJobItemId" id="insuranceJobItemId" value="${itemId}" />`);
|
||||
|
||||
|
||||
$("#worksTable tbody").find('tr').each(function(i) {
|
||||
const ratioLess = $(this).find("input.ratioLess").val();
|
||||
@@ -208,14 +263,122 @@
|
||||
|
||||
|
||||
});
|
||||
// $('#send').click();
|
||||
$('#createForm').submit();
|
||||
if (allInputsFilled) {
|
||||
$('#createForm').submit();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function checkLength(value, maxLength) {
|
||||
var lengthValue = value.length;
|
||||
if (maxLength == lengthValue)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
|
||||
}
|
||||
function dateValidCheckByValue(value) {
|
||||
let persianNumbers = [/۰/g, /۱/g, /۲/g, /۳/g, /۴/g, /۵/g, /۶/g, /۷/g, /۸/g, /۹/g],
|
||||
arabicNumbers = [/٠/g, /١/g, /٢/g, /٣/g, /٤/g, /٥/g, /٦/g, /٧/g, /٨/g, /٩/g],
|
||||
fixNumbers = function (str) {
|
||||
if (typeof str === 'string') {
|
||||
for (var i = 0; i < 10; i++) {
|
||||
str = str.replace(persianNumbers[i], i).replace(arabicNumbers[i], i);
|
||||
}
|
||||
}
|
||||
return str;
|
||||
};
|
||||
let getdate = value;
|
||||
|
||||
//console.log(getdate);
|
||||
//console.log(getdate.length);
|
||||
|
||||
let m1, m2;
|
||||
let y1, y2, y3, y4;
|
||||
let d1, d2;
|
||||
let s1, s2;
|
||||
for (var i = 0; i < getdate.length; i++) {
|
||||
if (i === 0) {
|
||||
y1 = fixNumbers(getdate[i]);
|
||||
}
|
||||
if (i === 1) {
|
||||
y2 = fixNumbers(getdate[i]);
|
||||
}
|
||||
if (i === 2) {
|
||||
y3 = fixNumbers(getdate[i]);
|
||||
}
|
||||
if (i === 3) {
|
||||
y4 = fixNumbers(getdate[i]);
|
||||
}
|
||||
if (i === 4) {
|
||||
s1 = fixNumbers(getdate[i]);
|
||||
}
|
||||
if (i === 5) {
|
||||
m1 = fixNumbers(getdate[i]);
|
||||
}
|
||||
if (i === 6) {
|
||||
m2 = fixNumbers(getdate[i]);
|
||||
}
|
||||
if (i === 7) {
|
||||
s2 = fixNumbers(getdate[i]);
|
||||
}
|
||||
if (i === 8) {
|
||||
d1 = fixNumbers(getdate[i]);
|
||||
}
|
||||
if (i === 9) {
|
||||
d2 = fixNumbers(getdate[i]);
|
||||
}
|
||||
|
||||
}
|
||||
let yRes = y1 + y2 + y3 + y4;
|
||||
let year = parseInt(yRes);
|
||||
let mRes = m1 + m2;
|
||||
let month = parseInt(mRes);
|
||||
let dRes = d1 + d2;
|
||||
let day = parseInt(dRes);
|
||||
let fixResult = yRes + s1 + mRes + s2 + dRes;
|
||||
let test1 = checkEnValid(value);
|
||||
|
||||
let isValid = /^([1][3-4][0-9][0-9][/])([0][1-9]|[1][0-2])([/])([0][1-9]|[1-2][0-9]|[3][0-1])$/.test(fixResult);
|
||||
|
||||
|
||||
if (isValid && test1) {
|
||||
//element.style.backgroundColor = '#a6e9a6';
|
||||
start1valid = true;
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
if (value != "") {
|
||||
//element.style.backgroundColor = '#f94c4c';
|
||||
//$.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', "لطفا تاریخ را بصورت صحیح وارد کنید");
|
||||
start1valid = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
return start1valid;
|
||||
|
||||
}
|
||||
function getNumberValue(value) {
|
||||
|
||||
var result = '';
|
||||
for (var i = 0; i < value.length; i++) {
|
||||
var x = value.charAt(i);
|
||||
if (x != '٬' && x != ',')
|
||||
result = result + x;
|
||||
}
|
||||
return Number(result);
|
||||
}
|
||||
|
||||
|
||||
$('#createForm').submit(function(e) {
|
||||
e.preventDefault();
|
||||
e.stopImmediatePropagation();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -5,11 +5,26 @@
|
||||
<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">
|
||||
<a href="#showmodal=@Url.Page("/Company/InsuranceJob/Index", "Create")" class="btn btn-rounded waves-effect waves-light m-b-5 btn-show-modal"><i class="fa fa-user-plus"></i> مشاغل مقطوع </a>
|
||||
@*<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>
|
||||
</div>
|
||||
<p class="pull-right">
|
||||
<a href="#showmodal=@Url.Page("/Company/InsuranceJob/Index", "Create")" class="btn btn-rounded waves-effect waves-light m-b-5 btn-show-modal"><i class="fa fa-user-plus"></i> ایجاد صنف جدید </a>
|
||||
@*<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 class="pull-right">
|
||||
|
||||
<a href="#showmodal=@Url.Page("/Company/InsuranceJob/Index", "CopyFromLastYear")" class="btn btn-rounded waves-effect waves-light m-b-5 btn-show-modal"><i class="fa fa-user-plus"></i> کپی از اصناف سال قبل </a>
|
||||
@*<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 class="pull-right">
|
||||
|
||||
<a asp-page="/Company/InsuranceJob/Index" asp-page-handler="OldDataRecovery1403" class="btn btn-rounded waves-effect waves-light m-b-5 btn-show-modal"><i class="fa fa-user-plus"></i> ریکاوری دیتای سال 1403 </a>
|
||||
@*<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>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<div class="col-sm-12">
|
||||
<div class="panel-group panel-group-joined" id="accordion-test">
|
||||
<div class="panel panel-default">
|
||||
@@ -96,9 +111,11 @@
|
||||
<table id="datatable" class="table table-striped table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 5px;">#</th>
|
||||
<th style="width: 5px;">#</th>
|
||||
<th style="width: 20px;"> سال</th>
|
||||
<th style="width: 300px;">عنوان صنف و درجه </th>
|
||||
<th style="width: 200px;"> کد اقتصادی </th>
|
||||
<th style="width: 180px;"> کد اقتصادی </th>
|
||||
|
||||
<th style="width: 300px;">عملیات</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -109,19 +126,26 @@
|
||||
@foreach (var item in Model.InsuranceJobList)
|
||||
{
|
||||
<tr>
|
||||
<td style="width: 5px;"> @index</td>
|
||||
<td style="width: 5px;"> @index</td>
|
||||
<td style="width: 20px;">
|
||||
|
||||
|
||||
<span> @item.Year</span>
|
||||
|
||||
</td>
|
||||
<td style="width: 300px;">
|
||||
<div class="tooltipfull-container">
|
||||
<p class="text-ellipsis-name">@item.InsuranceJobTitle</p>
|
||||
<span class="tooltipfull"> @item.InsuranceJobTitle</span>
|
||||
</div>
|
||||
</td>
|
||||
<td style="width: 200px;">
|
||||
<div class="tooltipfull-container">
|
||||
<p class="text-ellipsis-code">@item.EconomicCode</p>
|
||||
<span class="tooltipfull"> @item.EconomicCode</span>
|
||||
</div>
|
||||
</td>
|
||||
<td style="width: 180px;">
|
||||
<div class="tooltipfull-container">
|
||||
<p class="text-ellipsis-code">@item.EconomicCode</p>
|
||||
<span class="tooltipfull"> @item.EconomicCode</span>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td style="width: 300px;">
|
||||
<a class="btn btn-danger ionRad pull-left op-btn rad" onclick="removeInsuranceJob(@item.Id)">
|
||||
<i class="fa fa-trash faSize"></i>
|
||||
@@ -131,7 +155,7 @@
|
||||
<i class="fa fa-file-text ionSize"></i>
|
||||
</a>
|
||||
<a class="btn btn-warning pull-left op-btn rad"
|
||||
href="#showmodal=@Url.Page("./Index", "Edit", new { item.Id })">
|
||||
href="#showmodal=@Url.Page("./Index", "Edit", new { item.Id, item.Year, item.Month })">
|
||||
<i class="fa fa-edit faSize"></i>
|
||||
</a>
|
||||
</td>
|
||||
@@ -175,8 +199,13 @@
|
||||
headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() },
|
||||
data: { "id": id },
|
||||
success: function(response) {
|
||||
$.Notification.autoHideNotify('success', 'top center', 'پیام سیستم ', response.message);
|
||||
$('.btn-success').click();
|
||||
if(response.isSuccedded){
|
||||
$.Notification.autoHideNotify('success', 'top center', 'پیام سیستم ', response.message);
|
||||
window.location.reload();
|
||||
}else{
|
||||
$.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', response.message);
|
||||
}
|
||||
|
||||
},
|
||||
failure: function(response) {
|
||||
$.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', response.message);
|
||||
|
||||
@@ -6,6 +6,7 @@ using CompanyManagment.App.Contracts.YearlySalary;
|
||||
using MD.PersianDateTime.Standard;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
|
||||
namespace ServiceHost.Areas.Admin.Pages.Company.InsuranceJob;
|
||||
|
||||
@@ -36,7 +37,11 @@ public class IndexModel : PageModel
|
||||
|
||||
public void OnGet(InsuranceJobSearchModel searchModel)
|
||||
{
|
||||
YearlyList = _yearlySalaryApplication.GetYears();
|
||||
if(!string.IsNullOrWhiteSpace(searchModel.Year))
|
||||
Console.WriteLine(searchModel.Year);
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.Month))
|
||||
Console.WriteLine(searchModel.Month);
|
||||
YearlyList = _yearlySalaryApplication.GetYears();
|
||||
|
||||
var insuranceJobs = _insuranceJobApplication.Search(searchModel);
|
||||
InsuranceJobList = insuranceJobs;
|
||||
@@ -44,10 +49,14 @@ public class IndexModel : PageModel
|
||||
|
||||
public IActionResult OnGetCreate()
|
||||
{
|
||||
var model = new CreateInsuranceJob
|
||||
var dats = _insuranceJobApplication.GetOldYersInsuranceItemIds()
|
||||
.Select(x => new { Id = x.id, Date = x.date })
|
||||
.ToList();
|
||||
var model = new CreateInsuranceJob
|
||||
{
|
||||
// Jobs = _jobApplication.GetJob()
|
||||
};
|
||||
model.InsuranceJobItemViewModels = new SelectList(dats, "Id", "Date");
|
||||
return Partial("./Create", model);
|
||||
}
|
||||
|
||||
@@ -57,17 +66,43 @@ public class IndexModel : PageModel
|
||||
return new JsonResult(result);
|
||||
}
|
||||
|
||||
//public async Task<IActionResult> OnPostJobListByText(string textSearch)
|
||||
//{
|
||||
// var jobs = _jobApplication.GetJobListByText(textSearch);
|
||||
// return new JsonResult(new
|
||||
// {
|
||||
// IsSuccedded = true,
|
||||
// mylist = jobs,
|
||||
// });
|
||||
//}
|
||||
public IActionResult OnGetCopyFromLastYear()
|
||||
{
|
||||
var dats = _insuranceJobApplication.GetOldYersInsuranceItemIds()
|
||||
.Select(x => new { Id = x.id, Date = x.date })
|
||||
.ToList();
|
||||
var model = new CopyFromLastYearViewModel()
|
||||
{
|
||||
InsuranceJobItemId = 0,
|
||||
StartDate = "",
|
||||
EndDate = "",
|
||||
InsuranceJobItemViewModels = new SelectList(dats,"Id", "Date"),
|
||||
};
|
||||
return Partial("./CopyFromLastYear", model);
|
||||
}
|
||||
public IActionResult OnPostCopyFromLastYear(CopyFromLastYearViewModel commnad)
|
||||
{
|
||||
var res = _insuranceJobApplication.CopyFromLastYear(commnad);
|
||||
return new JsonResult(res);
|
||||
}
|
||||
|
||||
public IActionResult OnPostJobListByText(string textSearch)
|
||||
public IActionResult OnGetOldDataRecovery1403()
|
||||
{
|
||||
var res = _insuranceJobApplication.RecoveryOldData1403();
|
||||
|
||||
return new JsonResult(res);
|
||||
}
|
||||
//public async Task<IActionResult> OnPostJobListByText(string textSearch)
|
||||
//{
|
||||
// var jobs = _jobApplication.GetJobListByText(textSearch);
|
||||
// return new JsonResult(new
|
||||
// {
|
||||
// IsSuccedded = true,
|
||||
// mylist = jobs,
|
||||
// });
|
||||
//}
|
||||
|
||||
public IActionResult OnPostJobListByText(string textSearch)
|
||||
{
|
||||
var jobs = _jobApplication.GetJobListByText(textSearch);
|
||||
|
||||
@@ -99,9 +134,9 @@ public class IndexModel : PageModel
|
||||
});
|
||||
}
|
||||
|
||||
public IActionResult OnGetDetails(long id)
|
||||
public IActionResult OnGetDetails(long id, string year, string month)
|
||||
{
|
||||
var details = _insuranceJobApplication.GetDetails(id);
|
||||
var details = _insuranceJobApplication.GetDetails(id, year, month);
|
||||
return Partial("Details", details);
|
||||
}
|
||||
|
||||
@@ -157,15 +192,18 @@ public class IndexModel : PageModel
|
||||
return new JsonResult(result);
|
||||
}
|
||||
|
||||
public IActionResult OnGetEdit(long id)
|
||||
public IActionResult OnGetEdit(long id,string year, string month)
|
||||
{
|
||||
var model = new EditInsuranceJob();
|
||||
model = _insuranceJobApplication.GetDetails(id);
|
||||
model = _insuranceJobApplication.GetDetails(id, year, month);
|
||||
model.Year = year;
|
||||
model.Month = month;
|
||||
return Partial("./Edit", model);
|
||||
}
|
||||
|
||||
public IActionResult OnPostEdit(EditInsuranceJob command)
|
||||
{
|
||||
|
||||
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">
|
||||
|
||||
@@ -65,20 +65,20 @@ public class IndexModel : PageModel
|
||||
|
||||
var searchModelPercentage = new PercentageSearchModel();
|
||||
var percentageList = _percentageApplication.Search(searchModelPercentage);
|
||||
var percentagIds = dateSalaryItems.Select(x => x.PercentageId).ToList();
|
||||
var percentages = percentageList.Where(x => !percentagIds.Contains(x.Id)).ToList();
|
||||
//var percentagIds = dateSalaryItems.Select(x => x.PercentageId).ToList();
|
||||
//var percentages = percentageList.Where(x => !percentagIds.Contains(x.Id)).ToList();
|
||||
|
||||
foreach (var item in percentages)
|
||||
{
|
||||
var obj = new DateSalaryItemViewModel();
|
||||
obj.Percent = item.Percent;
|
||||
obj.PercentageId = item.Id;
|
||||
obj.Salary = null;
|
||||
obj.DateSalaryId = id;
|
||||
obj.Id = 0;
|
||||
obj.StrSalary = "";
|
||||
dateSalaryItems.Add(obj);
|
||||
}
|
||||
//foreach (var item in percentages)
|
||||
//{
|
||||
// var obj = new DateSalaryItemViewModel();
|
||||
// obj.Percent = item.Percent;
|
||||
// obj.PercentageId = item.Id;
|
||||
// obj.Salary = null;
|
||||
// obj.DateSalaryId = id;
|
||||
// obj.Id = 0;
|
||||
// obj.StrSalary = "";
|
||||
// dateSalaryItems.Add(obj);
|
||||
//}
|
||||
|
||||
var list = new CreateDateSalaryForInsuranceJob();
|
||||
list.EndDateFa = dateSalary.EndDateFa;
|
||||
|
||||
@@ -34,7 +34,9 @@ builder.Services.AddRazorPages()
|
||||
builder.Services.AddHttpContextAccessor();
|
||||
builder.Services.AddHttpClient("holidayApi", c => c.BaseAddress = new System.Uri("https://api.github.com"));
|
||||
var connectionString = builder.Configuration.GetConnectionString("MesbahDb");
|
||||
var connectionStringTestDb = builder.Configuration.GetConnectionString("TestDb");
|
||||
PersonalBootstrapper.Configure(builder.Services, connectionString);
|
||||
TestDbBootStrapper.Configure(builder.Services, connectionStringTestDb);
|
||||
AccountManagementBootstrapper.Configure(builder.Services, connectionString);
|
||||
WorkFlowBootstrapper.Configure(builder.Services, connectionString);
|
||||
QueryBootstrapper.Configure(builder.Services);
|
||||
|
||||
@@ -15,11 +15,14 @@
|
||||
//"MesbahDb": "Data Source=171.22.24.15;Initial Catalog=mesbah_db;Persist Security Info=False;User ID=ir_db;Password=R2rNp[170]is[3019]#@ATt;TrustServerCertificate=true;"
|
||||
|
||||
//local
|
||||
"MesbahDb": "Data Source=.;Initial Catalog=mesbah_db;Integrated Security=True;TrustServerCertificate=true;"
|
||||
"MesbahDb": "Data Source=.;Initial Catalog=mesbah_db;Integrated Security=True;TrustServerCertificate=true;",
|
||||
|
||||
"TestDb": "Data Source=.;Initial Catalog=TestDb;Integrated Security=True;TrustServerCertificate=true;"
|
||||
|
||||
//mahan Docker
|
||||
//"MesbahDb": "Data Source=localhost,5069;Initial Catalog=mesbah_db;User ID=sa;Password=YourPassword123;TrustServerCertificate=True;"
|
||||
},
|
||||
|
||||
"GoogleRecaptchaV3": {
|
||||
"SiteKey": "6Lfhp_AnAAAAAB79WkrMoHd1k8ir4m8VvfjE7FTH",
|
||||
"SecretKey": "6Lfhp_AnAAAAANjDDY6DPrbbUQS7k6ZCRmrVP5Lb"
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
|
||||
.main-title {
|
||||
position: absolute;
|
||||
width: 434px;
|
||||
width: 469px;
|
||||
font-size: 20px;
|
||||
background-color: inherit;
|
||||
left: 50%;
|
||||
@@ -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