Merge branch 'master' into Api

This commit is contained in:
MahanCh
2025-07-24 11:26:29 +03:30
12 changed files with 328 additions and 44 deletions

View File

@@ -18,7 +18,7 @@ public interface ICheckoutRepository : IRepository<long, Checkout>
/// <param name="سال به صورت رشته عددی"></param>
/// <param name="ماه بصورت رشته عددی"></param>
/// <returns></returns>
(bool hasChekout, double FamilyAlloance, double OverTimePay) HasCheckout(long workshopId, long employeId,
(bool hasChekout, double FamilyAlloance, double OverTimePay, double RotatingShift, double Nightwork, double Fridaywork, double YraesPay) HasCheckout(long workshopId, long employeId,
string year, string month);
EditCheckout GetDetails(long id);

View File

@@ -33,4 +33,14 @@ public interface IInstitutionContractRepository : IRepository<long, InstitutionC
int ArchiveCodeFinder(List<WorkshopViewModel> workshopViewModels);
InstitutionContract InstitutionContractByEmployerId(long employerId);
/// <summary>
/// ایجاد سند مالی حضور غیاب
/// </summary>
/// <param name="now"></param>
/// <param name="endOfMonthGr"></param>
/// <param name="endOfMonth"></param>
/// <param name="description"></param>
void RollcallServiceCreateTransaction();
}

View File

@@ -15,6 +15,14 @@ public interface IInstitutionContractApplication
List<InstitutionContractViewModel> Search(InstitutionContractSearchModel searchModel);
List<InstitutionContractViewModel> NewSearch(InstitutionContractSearchModel searchModel);
/// <summary>
/// دریافت اطلاعات قزداد های مالی فعال
///دارای کارگاه
/// جهت ست کردن سرویس ها از طریق اکسل
/// </summary>
/// <returns></returns>
List<InstitutionContractViewModel> GetInstitutionContractToSetServicesExcelImport();
List<InstitutionContractViewModel> PrintAll(List<long> id);
InstitutionContractViewModel PrintOne(long id);
OperationResult Active(long id);

View File

@@ -579,6 +579,14 @@ public class InstitutionContractApplication : IInstitutionContractApplication
return _institutionContractRepository.NewSearch(searchModel);
}
public List<InstitutionContractViewModel> GetInstitutionContractToSetServicesExcelImport()
{
var result = _institutionContractRepository.NewSearch(new InstitutionContractSearchModel());
return result.Where(x => x.IsActiveString == "true" && x.IsContractingPartyBlock !="true" && x.WorkshopCount != "0" && x.ContractStartGr <= DateTime.Now && x.ContractEndGr >= DateTime.Now).ToList();
}
public string ExpCheckColor(DateTime now, DateTime ContractEndGr, DateTime endThisMontGr, string ContractAmount, string isActiveString)
{
string result = "";

View File

@@ -440,6 +440,12 @@ public class InsuranceListApplication : IInsuranceListApplication
bool employeeHasCheckout = true;
double familyAllowance = 0;
double overTimePay = 0;
double rotatingShift = 0;
double nightWork = 0;
double fridayWork = 0;
double yearsPay = 0;
if (hasWorkshopOverTimeOrFamilyAllowance && (leftDate >= startDateGr || employee.LeftWorkDateGr == null))
{
var checkout = _checkoutRepository.HasCheckout(workshopId, employee.EmployeeId,
@@ -450,6 +456,11 @@ public class InsuranceListApplication : IInsuranceListApplication
familyAllowance = checkout.FamilyAlloance;
overTimePay = checkout.OverTimePay;
rotatingShift = checkout.RotatingShift;
nightWork = checkout.Nightwork;
fridayWork = checkout.Fridaywork;
yearsPay = checkout.YraesPay;
}
else
{
@@ -537,12 +548,21 @@ public class InsuranceListApplication : IInsuranceListApplication
var employeeListData = employeeInsurancDataPreviusList
.FirstOrDefault(e => e.EmployeeId == employee.EmployeeId);
//مزیای عیر مشمول لیست قبل
var benefitsIncludedNonContinuous =
employeeListData != null ? employeeListData.BenefitsIncludedNonContinuous : 0;
//var benefitsIncludedNonContinuous =
// employeeListData != null ? employeeListData.BenefitsIncludedNonContinuous : 0;
double benefitsIncludedNonContinuous = 0;
if (workshop.InsuranceCheckoutFamilyAllowance && employeeHasCheckout && !isManager)
{
{
double addOptionsfromCheckout = familyAllowance;
benefitsIncludedNonContinuous = GetRoundValue(benefitsIncludedNonContinuous + familyAllowance);
//استثنا کارگته بازرگانی سیم آهن مهراکو
//if (workshopId == 666)
//{
// addOptionsfromCheckout = familyAllowance + rotatingShift + nightWork + fridayWork + yearsPay;
//}
benefitsIncludedNonContinuous = GetRoundValue(benefitsIncludedNonContinuous + addOptionsfromCheckout);
}

View File

@@ -71,7 +71,7 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
/// <param name="سال به صورت رشته عددی"></param>
/// <param name="ماه بصورت رشته عددی"></param>
/// <returns></returns>
public (bool hasChekout, double FamilyAlloance, double OverTimePay) HasCheckout(long workshopId, long employeId, string year, string month)
public (bool hasChekout, double FamilyAlloance, double OverTimePay, double RotatingShift, double Nightwork, double Fridaywork, double YraesPay) HasCheckout(long workshopId, long employeId, string year, string month)
{
var farisMonthName = Tools.ToFarsiMonthByNumber(month);
@@ -79,9 +79,9 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
x.WorkshopId == workshopId && x.EmployeeId == employeId && x.Year == year && x.Month == farisMonthName &&
x.IsActiveString == "true");
if (res == null)
return (false, 0, 0);
return (false, 0, 0,0,0,0,0);
return (true, res.FamilyAllowance, res.OvertimePay);
return (true, res.FamilyAllowance, res.OvertimePay, res.ShiftPay, res.NightworkPay, res.FridayPay,res.YearsPay);
}
public EditCheckout GetDetails(long id)
@@ -240,6 +240,7 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
var now = DateTime.Now;
DateTime currentStart = ($"{DateTime.Now.ToFarsi().Substring(0, 8)}01").ToGeorgianDateTime();
DateTime currentEnd = ($"{DateTime.Now.ToFarsi().FindeEndOfMonth()}").ToGeorgianDateTime();
var chekoutCreated = result.checkout.FirstOrDefault(x => x.ContractStart < endSearch && x.ContractEnd > startSreach && x.IsActiveString == "true");
if (chekoutCreated != null)
@@ -265,13 +266,20 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
}
var employeeJoin = result.contractWorkshopEmployeeleftWorkPersonnelCode.contractWorkshopEmployeeleftWork
.contractWorkshopEmployee.employee.id;
bool hasRollCall =
_rollCallEmployeeRepository.HasRollCallRecord(employeeJoin, workshopId, startSreach, endSearch);
var leftWork = result.contractWorkshopEmployeeleftWorkPersonnelCode.contractWorkshopEmployeeleftWork
.leftwork;
var startStatusSearch = leftWork.StartWorkDate > startSreach && leftWork.StartWorkDate <= endSearch
? leftWork.StartWorkDate
: startSreach;
var endStatusSearch = leftWork.HasLeft && leftWork.LeftWorkDate > startSreach && leftWork.LeftWorkDate <= endSearch
? leftWork.LeftWorkDate.AddDays(-1)
: startSreach;
bool hasRollCall =
_rollCallEmployeeRepository.HasRollCallRecord(employeeJoin, workshopId, startStatusSearch, endStatusSearch);
bool extension = true;
bool laterThanEnd = false;
string description = "";
@@ -2221,40 +2229,41 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
if (!hasSearch && !hasEmployeeOrWorkshpSearch)
{
return checkouts.Select(x => new CheckoutViewModel()
{
{
Id = x.ch.id,
EmployeeFullName = x.ch.EmployeeFullName,
ContractStart = x.ch.ContractStart.ToFarsi(),
ContractEnd = x.ch.ContractEnd.ToFarsi(),
ContractStartGr = x.ch.ContractStart,
ContractEndGr = x.ch.ContractEnd,
PersonnelCode = x.ch.PersonnelCode,
PersonnelCodeInt = Convert.ToInt32(x.ch.PersonnelCode),
ArchiveCode = x.workshop.ArchiveCode,
SumOfWorkingDays = x.ch.SumOfWorkingDays,
WorkshopName = x.workshop.WorkshopName,
Month = x.ch.Month,
Year = x.ch.Year,
ContractNo = x.ch.ContractNo,
ContractId = x.ch.ContractId,
WorkshopId = x.ch.WorkshopId,
EmployeeId = x.ch.EmployeeId,
EmployerId = x.workshopEmployer.EmployerId,
IsActiveString = x.ch.IsActiveString,
Signature = x.ch.Signature,
CreationDate = x.ch.CreationDate,
EmployerName = $"{x.workshopEmployer.Employer.FName} {x.workshopEmployer.Employer.LName}",
IsBlockCantracingParty = x.contractingParty.IsBlock,
HasSignCheckout = x.option != null ? x.option.SignCheckout : x.workshop.SignCheckout
Id = x.ch.id,
EmployeeFullName = x.ch.EmployeeFullName,
ContractStart = x.ch.ContractStart.ToFarsi(),
ContractEnd = x.ch.ContractEnd.ToFarsi(),
ContractStartGr = x.ch.ContractStart,
ContractEndGr = x.ch.ContractEnd,
PersonnelCode = x.ch.PersonnelCode,
PersonnelCodeInt = Convert.ToInt32(x.ch.PersonnelCode),
ArchiveCode = x.workshop.ArchiveCode,
SumOfWorkingDays = x.ch.SumOfWorkingDays,
WorkshopName = x.workshop.WorkshopName,
Month = x.ch.Month,
Year = x.ch.Year,
ContractNo = x.ch.ContractNo,
ContractId = x.ch.ContractId,
WorkshopId = x.ch.WorkshopId,
EmployeeId = x.ch.EmployeeId,
EmployerId = x.workshopEmployer.EmployerId,
IsActiveString = x.ch.IsActiveString,
Signature = x.ch.Signature,
CreationDate = x.ch.CreationDate,
EmployerName = $"{x.workshopEmployer.Employer.FName} {x.workshopEmployer.Employer.LName}",
IsBlockCantracingParty = x.contractingParty.IsBlock,
HasSignCheckout = x.option != null ? x.option.SignCheckout : x.workshop.SignCheckout
}).OrderByDescending(x => x.Id).ThenByDescending(x => x.Year).ThenBy(x => x.PersonnelCodeInt).Take(200)
.GroupBy(x => x.Id)
.Select(x => x.First()).ToList()
.OrderByDescending(x => x.Id).ThenByDescending(x => x.Year).ThenBy(x => x.PersonnelCodeInt).Take(50).ToList();
}).OrderByDescending(x=>x.Id).Take(3000).ToList().DistinctBy(x => x.Id)
.OrderByDescending(x => x.Id).ThenByDescending(x => x.Year)
.ThenBy(x => x.PersonnelCodeInt)
.Take(50).ToList();
}
else if (hasSearch && !hasEmployeeOrWorkshpSearch)
{

View File

@@ -7,14 +7,18 @@ using _0_Framework.Application;
using _0_Framework.InfraStructure;
using Company.Domain.ContractingPartyAccountAgg;
using Company.Domain.empolyerAgg;
using Company.Domain.FinancialStatmentAgg;
using Company.Domain.FinancialTransactionAgg;
using Company.Domain.InstitutionContractAgg;
using Company.Domain.WorkshopAgg;
using CompanyManagment.App.Contracts.Employer;
using CompanyManagment.App.Contracts.InstitutionContract;
using CompanyManagment.App.Contracts.Workshop;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using PersianTools.Core;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;
namespace CompanyManagment.EFCore.Repository;
@@ -759,6 +763,226 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
}
/// <summary>
/// ایجاد سند مالی حضور غیاب
/// </summary>
/// <param name="now"></param>
/// <param name="endOfMonthGr"></param>
/// <param name="endOfMonth"></param>
/// <param name="description"></param>
#region RollcallServicCreateTransaction
public void RollcallServiceCreateTransaction()
{
DateTime now = DateTime.Now;
var nowFa = now.ToFarsi();
var endOfMonth = nowFa.FindeEndOfMonth();
DateTime endOfMonthGr = endOfMonth.ToGeorgianDateTime();
#region FindeNextMonth 1th
var year = Convert.ToInt32(endOfMonth.Substring(0, 4));
var month = Convert.ToInt32(endOfMonth.Substring(5, 2));
var nextM = new PersianDateTime(year, month, 1).AddMonths(1);
var nextMonthGr = ($"{nextM}").ToGeorgianDateTime();
var endOfCurrentMonth = (($"{endOfMonth.Substring(0, 8)}/01").FindeEndOfMonth()).ToGeorgianDateTime();
#endregion
#region GetAvtiveContracts
var institutionContracts = _context.InstitutionContractSet.Where(x => x.IsActiveString == "true").Select(x => new InstitutionContractViewModel
{
Id = x.id,
ContractingPartyId = x.ContractingPartyId,
ContractingPartyName = x.ContractingPartyName,
ContractStartGr = x.ContractStartGr,
ContractStartFa = x.ContractStartFa,
ContractEndGr = x.ContractEndGr,
ContractEndFa = x.ContractEndFa,
IsActiveString = x.IsActiveString,
SearchAmount = x.ContractAmount,
TypeOfContract = x.TypeOfContract
}).Where(x =>
x.ContractStartGr < endOfMonthGr && x.ContractEndGr >= endOfMonthGr && x.SearchAmount > 0)
.ToList();
#endregion
#region GetFutureContracts
List<InstitutionContractViewModel> futureContracts = _context.InstitutionContractSet
.Where(x => x.IsActiveString == "true" &&
x.ContractStartGr == nextMonthGr && x.ContractAmount > 0)
.Select(x => new InstitutionContractViewModel
{
Id = x.id,
ContractingPartyId = x.ContractingPartyId,
ContractingPartyName = x.ContractingPartyName,
ContractStartGr = x.ContractStartGr,
ContractStartFa = x.ContractStartFa,
ContractEndGr = x.ContractEndGr,
ContractEndFa = x.ContractEndFa,
IsActiveString = x.IsActiveString,
TypeOfContract = x.TypeOfContract,
ExtensionNo = x.ExtensionNo,
}).ToList();
#endregion
#region GetDectivedContractOnCurrentMonth
if (futureContracts.Any())
{
List<long> futureContractIds = futureContracts.Select(x => x.ContractingPartyId).ToList();
List<InstitutionContractViewModel> deatcivedContract = _context.InstitutionContractSet
.Where(x => x.IsActiveString == "false" && futureContractIds.Contains(x.ContractingPartyId) &&
x.ContractEndGr == endOfCurrentMonth && x.ContractAmount > 0)
.Select(x => new InstitutionContractViewModel
{
Id = x.id,
ContractingPartyId = x.ContractingPartyId,
ContractingPartyName = x.ContractingPartyName,
ContractStartGr = x.ContractStartGr,
ContractStartFa = x.ContractStartFa,
ContractEndGr = x.ContractEndGr,
ContractEndFa = x.ContractEndFa,
IsActiveString = x.IsActiveString,
SearchAmount = x.ContractAmount,
TypeOfContract = x.TypeOfContract
}).ToList();
if (deatcivedContract.Any())
institutionContracts.AddRange(deatcivedContract);
}
List<long> exceptionContractingPartyIds = [30520, 30739];
institutionContracts = institutionContracts
.Where(x => !exceptionContractingPartyIds.Contains(x.ContractingPartyId)).ToList();
int counter = 0;
var rollcallServiceList =
_context.RollCallServices.Where(x => x.IsActiveString == "true").ToList();
var activeStatusDate = new DateTime(2121, 03, 21);
foreach (var item in institutionContracts)
{
//var isblock = contractingParty.IsBlock == "true" ? true : false;
var employers = _context.Employers.Where(x => x.ContractingPartyId == item.ContractingPartyId).Select(x => x.id);
var workshops = _context.WorkshopEmployers.Where(x => employers.Contains(x.EmployerId)).Select(x => x.WorkshopId).Distinct().ToList();
var srvices =
rollcallServiceList.Where(x => workshops.Contains(x.WorkshopId)).ToList();
if (rollcallServiceList.Count > 0)
{
foreach (var rollCallService in srvices)
{
//var spaning = (int)(endOfMonthGr - rollCallService.StartService).TotalDays + 1;
int monthCounter = 0;
var currentMonthStart = ($"{(endOfMonthGr.ToFarsi()).Substring(0, 8)}01").ToGeorgianDateTime();
var prevMonthEnd = currentMonthStart.AddDays(-1);
var prevMonthStart = ($"{(prevMonthEnd.ToFarsi()).Substring(0, 8)}01").ToGeorgianDateTime();
var monthCurrent = endOfMonth.Substring(5, 2);
var yearCurrent = endOfMonth.Substring(0, 4);
var currentMonthName = monthCurrent.ToFarsiMonthByNumber();
var workshop = _context.Workshops.FirstOrDefault(x => x.id == rollCallService.WorkshopId);
string description = "";
if (rollCallService.StartService <= prevMonthStart)
{
var monthPrev = prevMonthEnd.ToFarsi().Substring(5, 2);
var yearPrev = prevMonthEnd.ToFarsi().Substring(0, 4);
var prevMonthName = monthPrev.ToFarsiMonthByNumber();
description = $"{prevMonthName} و {currentMonthName} {yearCurrent} - {workshop.WorkshopFullName}";
monthCounter = 2;
}else if (rollCallService.StartService <= currentMonthStart &&
rollCallService.StartService > prevMonthStart)
{
monthCounter = 1;
description = $"{currentMonthName} {yearCurrent} - {workshop.WorkshopFullName}";
}
var employees =
_context.RollCallEmployees.Where(x => x.WorkshopId == rollCallService.WorkshopId).Select(x=>x.id);
var employeeCount = _context.RollCallEmployeesStatus.Where(x => employees.Contains(x.RollCallEmployeeId))
.Count(x => x.EndDate.Date == activeStatusDate.Date);
if (employeeCount > 0 && monthCounter > 0)
{
counter++;
var dailyWageYearlySalery = _context.YearlySalaries.Include(i => i.YearlySalaryItemsList).FirstOrDefault(x =>
x.StartDate.Date <= DateTime.Now.Date && x.EndDate >= DateTime.Now.Date);
var dailyWage = dailyWageYearlySalery.YearlySalaryItemsList.Where(x => x.ItemName == "مزد روزانه")
.Select(x => x.ItemValue).FirstOrDefault();
var planPercentage = _context.PlanPercentages.FirstOrDefault();
var countPersonnel = employeeCount;
var planByCountPerson = _context.InstitutionPlans
.FirstOrDefault(x => x.CountPerson == countPersonnel);
var amountForOneMonth =(((dailyWage * planPercentage.RollCallPercent) / 100) * planByCountPerson.CountPerson *
planByCountPerson.IncreasePercentage);
var amountWithoutTax = amountForOneMonth * monthCounter;
var tenPercent = amountWithoutTax * 10 / 100;
var totalAmonut = amountWithoutTax + tenPercent;
Console.WriteLine( counter + " - " + rollCallService.StartService.ToFarsi() + " - " + rollCallService.WorkshopId + " - " + monthCounter + " - " + employeeCount + $" - {amountWithoutTax}");
var financialStatment =
_context.FinancialStatments.FirstOrDefault(x =>
x.ContractingPartyId == item.ContractingPartyId);
long financialStatementId = 0;
if (financialStatment != null)
{
financialStatementId = financialStatment.id;
}
else
{
var statement = new FinancialStatment(item.ContractingPartyId, item.ContractingPartyName);
_context.FinancialStatments.Add(statement);
_context.SaveChanges();
financialStatementId = statement.id;
}
var transaction = new FinancialTransaction(financialStatementId, endOfMonthGr, endOfMonth,
description,
"debt", "بابت سرویس حضور غیاب", totalAmonut, 0, 0);
_context.FinancialTransactions.Add(transaction);
_context.SaveChanges();
//Console.WriteLine(" number : " + counter + " - " + rollCallService.StartService.ToFarsi() + " - WorkshopId : " + rollCallService.WorkshopId + " - monthCount : " + monthCounter + " - employeeCount : " + employeeCount + $" - Amount : {amountWithoutTax.ToMoney()}" + $" - ten : {tenPercent.ToMoney()} total : {totalAmonut.ToMoney()}");
}
}
}
}
#endregion
}
#endregion
#region CustomViewModels

View File

@@ -466,7 +466,7 @@
</a>
</li>
<li permission="500">
<a href="https://admin@(AppSetting.Value.Domain)/admin/monthly-overview" class="waves-effect btnWorkFlow" style="display: flex;align-items: center;justify-content: space-between;">
<a href="https://admin@(AppSetting.Value.Domain)/monthly-overview" class="waves-effect btnWorkFlow" style="display: flex;align-items: center;justify-content: space-between;">
<div class="menuTitle">
<i class="md md-home"></i>
<span> بررسی امور ماهانه </span>

View File

@@ -1,7 +1,9 @@
@using AccountManagement.Domain.TicketAccessAccountAgg
@using Microsoft.AspNetCore.Mvc.TagHelpers
@using Microsoft.Extensions.Options
@inject ITicketAccessAccountRepository TicketAccessAccount;
@inject _0_Framework.Application.IAuthHelper AuthHelper;
@inject IOptions<AppSettingConfiguration> AppSetting
@{
var accountId = AuthHelper.CurrentAccountId();
<style>
@@ -611,7 +613,7 @@
</a>
</li>
<li permission="500">
<a href="https://admin.dad-mehr.ir/admin/monthly-overview" class="waves-effect btnWorkFlow">
<a href="https://admin@(AppSetting.Value.Domain)/monthly-overview" class="waves-effect btnWorkFlow">
<div class="menuTitle">
<i class="md md-home"></i>
<span> بررسی امور ماهانه </span>

View File

@@ -32,7 +32,7 @@
"ApiKey": "Og5M562igmzJRhQPnq0GdtieYdLgtfikjzxOmeQBPxJjZtyge5Klc046Lfw1mxSa",
"SecretKey": "dadmehr"
},
"Domain": ".dad-mehr.ir"
"Domain": ".gozareshgir.ir"
}

View File

@@ -14,6 +14,7 @@ $(document).ready(function () {
<option class="debtOption" value = "بابت بدهی از قرارداد قبل" > بابت بدهی از قرارداد قبل </option>
<option class="debtOption" value = "بابت خرید" > بابت خرید </option>
<option class="debtOption" value = "بابت خرید استند حضور غیاب" > بابت خرید استند حضور غیاب </option>
<option class="debtOption" value = "بابت سرویس حضور غیاب" > بابت سرویس حضور غیاب </option>
<option class="debtOption" value = "بابت بدهی سایر" > بابت بدهی سایر </option>
`
@@ -81,6 +82,7 @@ let debtorOptions = $(
<option class="debtOption" value = "بابت بدهی از قرارداد قبل" > بابت بدهی از قرارداد قبل </option>
<option class="debtOption" value = "بابت خرید" > بابت خرید </option>
<option class="debtOption" value = "بابت خرید استند حضور غیاب" > بابت خرید استند حضور غیاب </option>
<option class="debtOption" value = "بابت سرویس حضور غیاب" > بابت سرویس حضور غیاب </option>
<option class="debtOption" value = "بابت بدهی سایر" > بابت بدهی سایر </option>
`
);

View File

@@ -172,6 +172,7 @@ let debtorOptions = $(
<option class="debtOption" value = "بابت بدهی از قرارداد قبل" > بابت بدهی از قرارداد قبل </option>
<option class="debtOption" value = "بابت خرید" > بابت خرید </option>
<option class="debtOption" value = "بابت خرید استند حضور غیاب" > بابت خرید استند حضور غیاب </option>
<option class="debtOption" value = "بابت سرویس حضور غیاب" > بابت سرویس حضور غیاب </option>
<option class="debtOption" value = "بابت بدهی سایر" > بابت بدهی سایر </option>
`
);