BaseYearPay bug Fixed YearlySalery

This commit is contained in:
SamSys
2025-04-13 22:49:43 +03:30
parent 4f673f22d5
commit bcd6447509

View File

@@ -18,6 +18,7 @@ using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using PersianTools.Core;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace CompanyManagment.EFCore.Repository;
@@ -602,19 +603,31 @@ public class YearlySalaryRepository : RepositoryBase<long, YearlySalary>, IYearl
var DayliSalaryStep1 = salary.FirstOrDefault(x => x.Year == "1370")!
.YearlySalaryItemsList.Where(x => x.ItemName == "مزد روزانه").Select(x => x.ItemValue).FirstOrDefault();
var DayliSalaryStep1Fa = DayliSalaryStep1.ToMoney();
double firstDayliSalary = DayliSalaryStep1;
double firstDayliSalary = DayliSalaryStep1Fa.MoneyToDouble();
string firstYear = "1370";
int counter = 0;
foreach (var item in salary)
{
var currentDayliFee = salary.FirstOrDefault(x => x.Year == item.Year)!
Console.WriteLine($"{item.Year} - {item.ConnectionId}");
var currentDayliFee = item!
.YearlySalaryItemsList.Where(x => x.ItemName == "مزد روزانه").Select(x => x.ItemValue).FirstOrDefault();
var fixFeePercentage = salary.FirstOrDefault(x => x.Year == item.Year)!
var fixFeePercentage = item!
.YearlySalaryItemsList.Where(x => x.ItemName == "درصد مزد ثابت").Select(x => x.ItemValue).FirstOrDefault();
// مبلغ مزد ثابت سال جاری
var fixFeePrice = salary.FirstOrDefault(x => x.Year == item.Year)!.YearlySalaryItemsList
var fixFeePrice = item!.YearlySalaryItemsList
.Where(x => x.ItemName == "مبلغ مزد ثابت").Select(x => x.ItemValue).FirstOrDefault();
if (counter > 0)
{
if (firstYear == item.Year)
{
int currentYear = Convert.ToInt32(item.Year);
string lastYear = $"{currentYear - 1}";
firstDayliSalary = salary.Where(x => x.Year == lastYear).MaxBy(x=>x.StartDate)!
.YearlySalaryItemsList.Where(x => x.ItemName == "مزد روزانه").Select(x => x.ItemValue).FirstOrDefault();
}
// مزد روزانه سال قبل ضربدر درصد مزد ثابت تقسیم بر صد
var percntSumDaylifee = (firstDayliSalary * fixFeePercentage) / 100;
// نتیجه عملیات بالا بعلاوه مزد سال قبل
@@ -623,20 +636,23 @@ public class YearlySalaryRepository : RepositoryBase<long, YearlySalary>, IYearl
//مزد پایه
var BaseResult = Sum + fixFeePrice;
var baseResultFa = BaseResult.ToMoney();
var res = BaseResult;
var res = GetCurrectFirstDailyFee(BaseResult,item.Year);
if (currentDayliFee != res)
{
Console.BackgroundColor = ConsoleColor.DarkRed;
Console.WriteLine($"{item.Year} original : {currentDayliFee} Computed : {res} ");
Console.WriteLine($" lastYear : {firstDayliSalary} thisYearOriginal : {currentDayliFee} GetCurrect : {res} falseResut : {BaseResult} ");
Console.ResetColor();
}
else
{
Console.WriteLine($"{item.Year} original : {currentDayliFee} Computed : {res} ");
Console.WriteLine($" lastYear : {firstDayliSalary} thisYearOriginal : {currentDayliFee} GetCurrect : {res} falseResut : {BaseResult} ");
}
//Console.WriteLine($"{item.Year} defualtFa : {currentDayliFee.ToMoney()} dailFeeFa : {BaseResult.ToMoney()} ");
firstDayliSalary = currentDayliFee;
firstDayliSalary = res;
firstYear = item.Year;
}
@@ -647,32 +663,121 @@ public class YearlySalaryRepository : RepositoryBase<long, YearlySalary>, IYearl
}
private double CurrectFirstDailyFee(double value,string year)
private double GetCurrectFirstDailyFee(double value,string year)
{
double currcted = 0;
double currected = 0;
switch (year)
{
case "1370": currcted = value;
case "1370": currected = value;
break;
case "1371": currcted = value;
case "1371": currected = value;
break;
case "1372":
currcted = Math.Round(value, MidpointRounding.ToPositiveInfinity);
currected = Math.Round(value, MidpointRounding.ToPositiveInfinity);
break;
case "1373":
currcted = value;
currected = Math.Round(value, MidpointRounding.ToPositiveInfinity);
break;
case "1374":
currcted = value;
currected = Math.Round(value, MidpointRounding.ToNegativeInfinity);
break;
case "1375":
currcted = value;
currected = Math.Round(value, MidpointRounding.ToPositiveInfinity);
break;
case "1376":
currected = Math.Round(value, MidpointRounding.ToPositiveInfinity);
break;
case "1377":
currected = Math.Round(value, MidpointRounding.ToNegativeInfinity);
break;
case "1378":
currected = Math.Round(value, MidpointRounding.ToNegativeInfinity);
break;
case "1379":
currected = Math.Round(value, MidpointRounding.ToNegativeInfinity);
break;
case "1380":
currected = Math.Round(value, MidpointRounding.ToNegativeInfinity);
break;
case "1381":
currected = Math.Round(value, MidpointRounding.ToPositiveInfinity);
break;
case "1382":
currected = Math.Round(value, MidpointRounding.ToNegativeInfinity);
break;
case "1383":
currected = Math.Round(value, MidpointRounding.ToNegativeInfinity);
break;
case "1384":
currected = Math.Round(value, MidpointRounding.ToNegativeInfinity);
break;
case "1385":
currected = value == 49950.4 ? 50000 : value;
break;
case "1386":
currected = value < 61000 ? 61000 : value;
break;
case "1387":
currected = Math.Round(value, MidpointRounding.ToNegativeInfinity);
break;
case "1388":
currected = Math.Round(value, MidpointRounding.ToNegativeInfinity);
break;
case "1389":
currected = Math.Round(value, MidpointRounding.ToPositiveInfinity);
break;
case "1390":
currected = Math.Round(value, MidpointRounding.ToNegativeInfinity);
break;
case "1391":
currected = Math.Round(value, MidpointRounding.ToNegativeInfinity);
break;
case "1392":
currected = Math.Round(value, MidpointRounding.ToNegativeInfinity);
break;
case "1393":
currected = Math.Round(value, MidpointRounding.ToNegativeInfinity);
break;
case "1394":
currected = Math.Round(value, MidpointRounding.ToPositiveInfinity);
break;
case "1395":
currected = Math.Round(value, MidpointRounding.ToPositiveInfinity);
break;
case "1396":
currected = Math.Round(value, MidpointRounding.ToPositiveInfinity);
break;
case "1397":
currected = Math.Round(value, MidpointRounding.ToPositiveInfinity);
break;
case "1398":
currected = Math.Round(value, MidpointRounding.ToPositiveInfinity);
break;
case "1399":
currected = Math.Round(value, MidpointRounding.ToNegativeInfinity);
break;
case "1400":
currected = Math.Round(value, MidpointRounding.ToPositiveInfinity);
break;
case "1401":
currected = Math.Round(value, MidpointRounding.ToPositiveInfinity);
break;
case "1402":
currected = Math.Round(value, MidpointRounding.ToNegativeInfinity);
break;
case "1403":
currected = Math.Round(value, MidpointRounding.ToNegativeInfinity);
break;
case "1404":
currected = Math.Round(value, MidpointRounding.ToPositiveInfinity);
break;
default: currected = value;
break;
}
return currcted;
return currected;
}
//محاسبه حقوق روزانه
@@ -731,8 +836,9 @@ public class YearlySalaryRepository : RepositoryBase<long, YearlySalary>, IYearl
.YearlySalaryItemsList.Where(x => x.ItemName == "مزد روزانه").Select(x => x.ItemValue).FirstOrDefault();
//مقدار اولیه مزد روزانه
double firstDayliSalary = DayliSalaryStep1;
var DayliSalaryStep1Fa = DayliSalaryStep1.ToMoney();
double firstDayliSalary = DayliSalaryStep1Fa.MoneyToDouble();
for (DateTime LoopDate = getWork; LoopDate <= endDateW; LoopDate = LoopDate.AddDays(1))
{
var loopdateFa = LoopDate.ToFarsi();
@@ -767,9 +873,10 @@ public class YearlySalaryRepository : RepositoryBase<long, YearlySalary>, IYearl
//اگر شمارنده روزها صفر بود
if (DayCounter == 0)
{
//var date = LoopDate.ToString();
// ذهیر تعداد روز های سال جاری بر اساس کبیسه یودن یا نبودن
Max365 = 365;
Max365 = loopdateFa.YearTotalDays();
}
// یک روز به شمارنده روزها اضافه کن
DayCounter += 1;
@@ -809,6 +916,7 @@ public class YearlySalaryRepository : RepositoryBase<long, YearlySalary>, IYearl
//مزد پایه
BaseResult = Sum + fixFeePrice;
BaseResult = GetCurrectFirstDailyFee(BaseResult, test);
//var rondUp = Convert.ToInt32(BaseResult);
Console.WriteLine($"{test} - mozdeSaleGhabl[{firstDayliSalary}] - mozdeSaleJari[{BaseResult}] - fixFeePercentage[{fixFeePercentage}] - fixFeePrice[{fixFeePrice}]");
@@ -823,8 +931,11 @@ public class YearlySalaryRepository : RepositoryBase<long, YearlySalary>, IYearl
if (BaseResult == 0)
{
var oldYearString = oldYear.ToString();
BaseResult = salary.FirstOrDefault(x => x.Year == oldYearString)
var resDouble = salary.FirstOrDefault(x => x.Year == oldYearString)
.YearlySalaryItemsList.Where(x => x.ItemName == "مزد روزانه").Select(x => x.ItemValue).FirstOrDefault();
var resFa = resDouble.ToMoney();
BaseResult = resFa.MoneyToDouble();
}
}
@@ -847,7 +958,7 @@ public class YearlySalaryRepository : RepositoryBase<long, YearlySalary>, IYearl
//مزد پایه
BaseResult = Sum + fixFeePrice;
//var rondUp = Convert.ToInt32(BaseResult);
BaseResult = GetCurrectFirstDailyFee(BaseResult, test);
Console.WriteLine($"{test} - mozdeSaleGhabl[{firstDayliSalary}] - mozdeSaleJari[{BaseResult}] - fixFeePercentage[{fixFeePercentage}] - fixFeePrice[{fixFeePrice}]");
//آی دی سال جاری
@@ -874,6 +985,7 @@ public class YearlySalaryRepository : RepositoryBase<long, YearlySalary>, IYearl
//مزد پایه
BaseResult = Sum + fixFeePrice;
BaseResult = GetCurrectFirstDailyFee(BaseResult, test);
//var rondUp = Convert.ToInt32(BaseResult);
Console.WriteLine($"{test} - mozdeSaleGhabl[{firstDayliSalary}] - mozdeSaleJari[{BaseResult}] - fixFeePercentage[{fixFeePercentage}] - fixFeePrice[{fixFeePrice}]");