Compare commits
27 Commits
Feature/In
...
Feature/cu
| Author | SHA1 | Date | |
|---|---|---|---|
| a178fcd202 | |||
| 9e92d2215f | |||
| c63eb23b22 | |||
| 238926118f | |||
| c874164ca2 | |||
| d2f0ed46ae | |||
| 40dd90074b | |||
| 452b0b6277 | |||
| 720e998a54 | |||
| 626722e805 | |||
| 5e5910e0fd | |||
| 5d81731512 | |||
| 511932fa58 | |||
| 95891d5bae | |||
| f3fa76c292 | |||
| ac6bbc3587 | |||
| 947d7590f4 | |||
| 91403a52a3 | |||
| 7e80342f80 | |||
| 5e92207778 | |||
|
|
29484e9565 | ||
| ba640494d2 | |||
| 6974a505b4 | |||
| 6d3d599449 | |||
| 2d28bd1f98 | |||
| 75ae3efb65 | |||
| eb53fd67ef |
@@ -27,4 +27,3 @@ public class NullFaceEmbeddingNotificationService : IFaceEmbeddingNotificationSe
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -56,6 +56,9 @@ public interface IInstitutionContractRepository : IRepository<long, InstitutionC
|
||||
void UpdateStatusIfNeeded(long institutionContractId);
|
||||
Task<GetInstitutionVerificationDetailsViewModel> GetVerificationDetails(Guid id);
|
||||
Task<InstitutionContract> GetByPublicIdAsync(Guid id);
|
||||
InstitutionContractDiscountResponse CalculateDiscount(InstitutionContractSetDiscountRequest request);
|
||||
InstitutionContractDiscountResponse ResetDiscountCreate(InstitutionContractResetDiscountForCreateRequest request);
|
||||
|
||||
|
||||
#region Extension
|
||||
|
||||
@@ -63,9 +66,13 @@ public interface IInstitutionContractRepository : IRepository<long, InstitutionC
|
||||
Task<InstitutionContractExtensionWorkshopsResponse> GetExtensionWorkshops(InstitutionContractExtensionWorkshopsRequest request);
|
||||
Task<InstitutionContractExtensionPlanResponse> GetExtensionInstitutionPlan(InstitutionContractExtensionPlanRequest request);
|
||||
Task<InstitutionContractExtensionPaymentResponse> GetExtensionPaymentMethod(InstitutionContractExtensionPaymentRequest request);
|
||||
Task<InstitutionContractDiscountResponse> SetDiscountForExtension(
|
||||
InstitutionContractSetDiscountForExtensionRequest request);
|
||||
Task<InstitutionContractDiscountResponse> ResetDiscountForExtension(InstitutionContractResetDiscountForExtensionRequest request);
|
||||
|
||||
Task<OperationResult> ExtensionComplete(InstitutionContractExtensionCompleteRequest request);
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Upgrade(Amendment)
|
||||
|
||||
@@ -145,4 +152,6 @@ public interface IInstitutionContractRepository : IRepository<long, InstitutionC
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
Task<long> GetIdByInstallmentId(long installmentId);
|
||||
}
|
||||
@@ -19,7 +19,8 @@ public class InstitutionContract : EntityBase
|
||||
string contractEndFa, double contractAmount, double dailyCompenseation, double obligation,
|
||||
double totalAmount, int extensionNo, string workshopManualCount, string employeeManualCount, string description,
|
||||
string officialCompany, string typeOfcontract, string hasValueAddedTax, double valueAddedTax,
|
||||
List<InstitutionContractWorkshopInitial> workshopDetails, long lawId)
|
||||
List<InstitutionContractWorkshopInitial> workshopDetails, long lawId,
|
||||
int discountPercentage, double discountAmount)
|
||||
{
|
||||
ContractNo = contractNo;
|
||||
RepresentativeId = representativeId;
|
||||
@@ -57,8 +58,12 @@ public class InstitutionContract : EntityBase
|
||||
WorkshopGroup = new InstitutionContractWorkshopGroup(id, workshopDetails);
|
||||
PublicId = Guid.NewGuid();
|
||||
LawId = lawId;
|
||||
DiscountPercentage = discountPercentage;
|
||||
DiscountAmount = discountAmount;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public long LawId { get; private set; }
|
||||
|
||||
public string ContractNo { get; private set; }
|
||||
@@ -128,6 +133,10 @@ public class InstitutionContract : EntityBase
|
||||
public DateTime VerifyCodeCreation { get; private set; }
|
||||
public string VerifierFullName { get; private set; }
|
||||
public string VerifierPhoneNumber { get; private set; }
|
||||
|
||||
public double DiscountAmount { get; private set; }
|
||||
|
||||
public int DiscountPercentage { get; private set; }
|
||||
|
||||
[NotMapped] public bool VerifyCodeExpired => VerifyCodeCreation.Add(ExpireTime) <= DateTime.Now;
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@ public class InstitutionContractExtensionTemp
|
||||
MonthlyPayment = monthly;
|
||||
OneTimePayment = oneTime;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ public class CreateInstitutionContractRequest
|
||||
/// <summary>
|
||||
/// مبلغ کل قرارداد
|
||||
/// </summary>
|
||||
public double TotalAmount { get; set; }
|
||||
public double PaymentAmount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// آیا قرارداد اقساطی است؟
|
||||
@@ -102,6 +102,10 @@ public class CreateInstitutionContractRequest
|
||||
public double OneMonthAmount { get; set; }
|
||||
|
||||
public long LawId { get; set; }
|
||||
|
||||
public int DiscountPercentage { get; set; }
|
||||
|
||||
public double DiscountAmount { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// مدت زمان قرارداد نهاد
|
||||
|
||||
@@ -215,7 +215,9 @@ public interface IInstitutionContractApplication
|
||||
Task<OperationResult<OtpResultViewModel>> SendVerifyOtp(Guid id);
|
||||
Task<OperationResult<string>> VerifyOtpAndMakeGateway(Guid publicId, string code, string callbackUrl);
|
||||
Task<InstitutionContractWorkshopDetailViewModel> GetWorkshopInitialDetails(long workshopDetailsId);
|
||||
|
||||
InstitutionContractDiscountResponse CalculateDiscount(InstitutionContractSetDiscountRequest request);
|
||||
InstitutionContractDiscountResponse ResetDiscountCreate(InstitutionContractResetDiscountForCreateRequest request);
|
||||
|
||||
#region Extension
|
||||
|
||||
Task<InstitutionContractExtensionInquiryResult> GetExtensionInquiry(long previousContractId);
|
||||
@@ -228,6 +230,12 @@ public interface IInstitutionContractApplication
|
||||
|
||||
Task<InstitutionContractExtensionPaymentResponse> GetExtensionPaymentMethod(
|
||||
InstitutionContractExtensionPaymentRequest request);
|
||||
|
||||
Task<InstitutionContractDiscountResponse> SetDiscountForExtension(
|
||||
InstitutionContractSetDiscountForExtensionRequest request);
|
||||
Task<InstitutionContractDiscountResponse> ResetDiscountForExtension(
|
||||
InstitutionContractResetDiscountForExtensionRequest request);
|
||||
|
||||
|
||||
Task<OperationResult> ExtensionComplete(InstitutionContractExtensionCompleteRequest request);
|
||||
Task<List<InstitutionContractSelectListViewModel>> GetInstitutionContractSelectList(string search,string selected);
|
||||
@@ -253,6 +261,75 @@ public interface IInstitutionContractApplication
|
||||
Task<InstitutionContractPrintViewModel> PrintOneAsync(long id);
|
||||
|
||||
Task<OperationResult> SetPendingWorkflow(long entityId);
|
||||
Task<long> GetIdByInstallmentId(long installmentId);
|
||||
|
||||
}
|
||||
|
||||
public class InstitutionContractDiscountResponse
|
||||
{
|
||||
public InstitutionContractDiscountOneTimeViewModel OneTime { get; set; }
|
||||
public InstitutionContractDiscountMonthlyViewModel Monthly { get; set; }
|
||||
}
|
||||
|
||||
public class InstitutionContractDiscountMonthlyViewModel:InstitutionContractDiscountOneTimeViewModel
|
||||
{
|
||||
public List<MonthlyInstallment> Installments { get; set; }
|
||||
}
|
||||
|
||||
public class InstitutionContractDiscountOneTimeViewModel
|
||||
{
|
||||
/// <summary>
|
||||
/// مجموع مبالغ
|
||||
/// </summary>
|
||||
public string TotalAmount { get; set; }
|
||||
/// <summary>
|
||||
/// ارزش افزوده
|
||||
/// </summary>
|
||||
public string Tax { get; set; }
|
||||
/// <summary>
|
||||
/// مبلغ قابل پرداخت
|
||||
/// </summary>
|
||||
public string PaymentAmount { get; set; }
|
||||
|
||||
public string DiscountedAmount { get; set; }
|
||||
|
||||
public int DiscountPercetage { get; set; }
|
||||
|
||||
public string Obligation { get; set; }
|
||||
|
||||
public string OneMonthAmount { get; set; }
|
||||
}
|
||||
|
||||
public class InstitutionContractResetDiscountForCreateRequest
|
||||
{
|
||||
public int DiscountPercentage { get; set; }
|
||||
public double TotalAmount { get; set; }
|
||||
public bool IsInstallment { get; set; }
|
||||
public InstitutionContractDuration Duration { get; set; }
|
||||
public double OneMonthAmount { get; set; }
|
||||
}
|
||||
|
||||
public class InstitutionContractSetDiscountForExtensionRequest
|
||||
{
|
||||
public Guid TempId { get; set; }
|
||||
public int DiscountPercentage { get; set; }
|
||||
public double TotalAmount { get; set; }
|
||||
public bool IsInstallment { get; set; }
|
||||
}
|
||||
public class InstitutionContractResetDiscountForExtensionRequest
|
||||
{
|
||||
public Guid TempId { get; set; }
|
||||
public bool IsInstallment { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class InstitutionContractSetDiscountRequest
|
||||
{
|
||||
public int DiscountPercentage { get; set; }
|
||||
public double TotalAmount { get; set; }
|
||||
public InstitutionContractDuration Duration { get; set; }
|
||||
public double OneMonthAmount { get; set; }
|
||||
public bool IsInstallment { get; set; }
|
||||
}
|
||||
|
||||
public class InstitutionContractPrintViewModel
|
||||
|
||||
@@ -17,6 +17,9 @@ public class InstitutionContractPaymentOneTimeViewModel
|
||||
/// مبلغ قابل پرداخت
|
||||
/// </summary>
|
||||
public string PaymentAmount { get; set; }
|
||||
|
||||
public string DiscountedAmount { get; set; }
|
||||
public int DiscountPercetage { get; set; }
|
||||
}
|
||||
public class InstitutionContractPaymentMonthlyViewModel:InstitutionContractPaymentOneTimeViewModel
|
||||
{
|
||||
|
||||
@@ -1585,7 +1585,12 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
|
||||
if (employee.IsAuthorized == false)
|
||||
{
|
||||
var apiResult = await _uidService.GetPersonalInfo(nationalCode, birthDate);
|
||||
if (apiResult.ResponseContext.Status.Code == 14)
|
||||
|
||||
if (apiResult == null)
|
||||
{
|
||||
return op.Failed("این پرسنل در بانک اطلاعات موجود میباشد");
|
||||
}
|
||||
if (apiResult.ResponseContext.Status.Code is 14 or 3)
|
||||
{
|
||||
return op.Failed("این پرسنل در بانک اطلاعات موجود میباشد");
|
||||
|
||||
@@ -1644,8 +1649,13 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
|
||||
};
|
||||
return op.Succcedded(data);
|
||||
}
|
||||
|
||||
var apiResult = await _uidService.GetPersonalInfo(nationalCode, birthDate);
|
||||
if (apiResult.ResponseContext.Status.Code == 14)
|
||||
if (apiResult == null)
|
||||
{
|
||||
return op.Failed("سامانه احراز هویت در دسترس نمیباشد لطفا اطلاعات پرسنل را به صورت دستی وارد کنید", new EmployeeDataFromApiViewModel() { AuthorizedCanceled = true });
|
||||
}
|
||||
if (apiResult.ResponseContext.Status.Code is 14 or 3)
|
||||
{
|
||||
return op.Failed("سامانه احراز هویت در دسترس نمیباشد لطفا اطلاعات پرسنل را به صورت دستی وارد کنید", new EmployeeDataFromApiViewModel() { AuthorizedCanceled = true });
|
||||
|
||||
|
||||
@@ -1485,12 +1485,12 @@ public class EmployerApplication : IEmployerApplication
|
||||
return opration.Failed("نام شرکت وارد شده تکراری است");
|
||||
}
|
||||
|
||||
if (_EmployerRepository.Exists(x =>
|
||||
x.RegisterId == command.RegisterId && !string.IsNullOrWhiteSpace(command.RegisterId) &&
|
||||
x.RegisterId != null))
|
||||
{
|
||||
return opration.Failed(" شماره ثبت وارد شده تکراری است");
|
||||
}
|
||||
// if (_EmployerRepository.Exists(x =>
|
||||
// x.RegisterId == command.RegisterId && !string.IsNullOrWhiteSpace(command.RegisterId) &&
|
||||
// x.RegisterId != null))
|
||||
// {
|
||||
// return opration.Failed(" شماره ثبت وارد شده تکراری است");
|
||||
// }
|
||||
|
||||
if (!string.IsNullOrEmpty(command.NationalId) && command.NationalId.Length != 11)
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -119,14 +119,6 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati
|
||||
|
||||
//دریافت اطلاعات احراز هویت
|
||||
var apiResponsParty = await _uidService.GetPersonalInfo(nationalCode, dateOfBirth);
|
||||
|
||||
//چک کردن مطابقت شماره همراه و کد ملی
|
||||
var isMachMobilAndNationalCode = await _uidService.IsMachPhoneWithNationalCode(nationalCode, mobile);
|
||||
if (isMachMobilAndNationalCode == null)
|
||||
return op.Failed("خطا در سرویس احراز هویت");
|
||||
if (!isMachMobilAndNationalCode.IsMatched)
|
||||
return op.Failed("شماره همراه وارد شده با کد ملی مطابقت ندارد");
|
||||
|
||||
if (apiResponsParty == null)
|
||||
throw new InternalServerException("خطا در سرویس احراز هویت");
|
||||
|
||||
@@ -136,10 +128,20 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati
|
||||
if (apiResponsParty.ResponseContext.Status.Code != 0)
|
||||
return op.Failed($"{apiResponsParty.ResponseContext.Status.Message}");
|
||||
|
||||
idNumberParty = apiResponsParty.IdentificationInformation.ShenasnamehNumber == "0"
|
||||
idNumberParty = apiResponsParty.IdentificationInformation.ShenasnamehNumber == "0"
|
||||
? apiResponsParty.IdentificationInformation.NationalId
|
||||
: apiResponsParty.IdentificationInformation.ShenasnamehNumber;
|
||||
|
||||
|
||||
|
||||
//چک کردن مطابقت شماره همراه و کد ملی
|
||||
var isMachMobilAndNationalCode = await _uidService.IsMachPhoneWithNationalCode(nationalCode, mobile);
|
||||
|
||||
if (isMachMobilAndNationalCode == null)
|
||||
throw new InternalServerException("خطا در سرویس تطابق کد ملی و شماره همراه");
|
||||
if (!isMachMobilAndNationalCode.IsMatched)
|
||||
return op.Failed("شماره همراه وارد شده با کد ملی مطابقت ندارد");
|
||||
|
||||
contractingParty.Authentication(apiResponsParty.BasicInformation.FirstName, apiResponsParty.BasicInformation.LastName,
|
||||
apiResponsParty.BasicInformation.FatherName,idNumberParty,apiResponsParty.IdentificationInformation.ShenasnameSeri,
|
||||
apiResponsParty.IdentificationInformation.ShenasnameSerial,dateOfBirth,apiResponsParty.BasicInformation.GenderEnum,
|
||||
@@ -147,12 +149,11 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati
|
||||
|
||||
|
||||
await _contractingPartyTempRepository.SaveChangesAsync();
|
||||
|
||||
|
||||
}
|
||||
if (contractingParty.Phone != mobile)
|
||||
return op.Failed("شما قبلا با شماره همراه دیگری احراز هویت شده اید");
|
||||
|
||||
|
||||
result.Id = contractingParty.id;
|
||||
result.FName = contractingParty.FName;
|
||||
result.LName = contractingParty.LName;
|
||||
|
||||
11347
CompanyManagment.EFCore/Migrations/20251129103132_add discount to institutioncontract.Designer.cs
generated
Normal file
11347
CompanyManagment.EFCore/Migrations/20251129103132_add discount to institutioncontract.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,40 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace CompanyManagment.EFCore.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class adddiscounttoinstitutioncontract : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<double>(
|
||||
name: "DiscountAmount",
|
||||
table: "InstitutionContracts",
|
||||
type: "float",
|
||||
nullable: false,
|
||||
defaultValue: 0.0);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "DiscountPercentage",
|
||||
table: "InstitutionContracts",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "DiscountAmount",
|
||||
table: "InstitutionContracts");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "DiscountPercentage",
|
||||
table: "InstitutionContracts");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3265,6 +3265,12 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
.HasMaxLength(10000)
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("DiscountAmount")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<int>("DiscountPercentage")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("EmployeeManualCount")
|
||||
.HasMaxLength(10)
|
||||
.HasColumnType("nvarchar(10)");
|
||||
|
||||
@@ -1101,7 +1101,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
? (int)InstitutionContractListStatus.DeactiveWithDebt
|
||||
: x.contract.ContractEndGr < now
|
||||
? (int)InstitutionContractListStatus.Deactive
|
||||
: (x.contract.ContractEndGr >= now && x.contract.ContractEndGr <= endThisMontGr)
|
||||
: (x.contract.ContractEndGr >= now && x.contract.ContractEndGr <= endThisMontGr && !_context.InstitutionContractSet.Any(i=>i.ContractingPartyId == x.contract.ContractingPartyId && x.contract.ExtensionNo+1 <= i.ExtensionNo && i.IsActiveString == "true"))
|
||||
? (int)InstitutionContractListStatus.PendingForRenewal
|
||||
: x.contractingParty.IsBlock == "true"
|
||||
? (int)InstitutionContractListStatus.Block
|
||||
@@ -1726,6 +1726,9 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
{
|
||||
return await _context.InstitutionContractSet
|
||||
.Include(x => x.WorkshopGroup)
|
||||
.ThenInclude(x=> x.InitialWorkshops)
|
||||
.Include(x=>x.WorkshopGroup)
|
||||
.ThenInclude(x=>x.CurrentWorkshops)
|
||||
.FirstOrDefaultAsync(x => x.id == institutionContractId);
|
||||
}
|
||||
|
||||
@@ -1867,6 +1870,109 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
.FirstOrDefaultAsync(x => x.PublicId == id);
|
||||
}
|
||||
|
||||
public InstitutionContractDiscountResponse CalculateDiscount(InstitutionContractSetDiscountRequest request)
|
||||
{
|
||||
var baseAmount = request.TotalAmount;
|
||||
var discountAmount = (baseAmount * request.DiscountPercentage) / 100;
|
||||
var discountOneMonthAmount = (request.OneMonthAmount * request.DiscountPercentage) / 100;
|
||||
var discountedOneMonthAmount = request.OneMonthAmount - discountOneMonthAmount;
|
||||
var totalAmount = baseAmount - discountAmount;
|
||||
var taxAmount = totalAmount * 0.10;
|
||||
var paymentAmount = totalAmount + taxAmount;
|
||||
InstitutionContractDiscountMonthlyViewModel monthlyPayment = null;
|
||||
InstitutionContractDiscountOneTimeViewModel oneTimePayment = null;
|
||||
|
||||
if (request.IsInstallment)
|
||||
{
|
||||
monthlyPayment = new InstitutionContractDiscountMonthlyViewModel()
|
||||
{
|
||||
TotalAmount = totalAmount.ToMoney(),
|
||||
PaymentAmount = paymentAmount.ToMoney(),
|
||||
Tax = taxAmount.ToMoney(),
|
||||
DiscountedAmount = discountAmount.ToMoney(),
|
||||
DiscountPercetage = request.DiscountPercentage,
|
||||
Installments = InstitutionMonthlyInstallmentCaculation((int)request.Duration,
|
||||
totalAmount, DateTime.Now.ToFarsi()),
|
||||
OneMonthAmount = discountedOneMonthAmount.ToMoney(),
|
||||
Obligation = totalAmount.ToMoney()
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
oneTimePayment = new InstitutionContractDiscountOneTimeViewModel()
|
||||
{
|
||||
TotalAmount = totalAmount.ToMoney(),
|
||||
PaymentAmount = paymentAmount.ToMoney(),
|
||||
Tax = taxAmount.ToMoney(),
|
||||
DiscountedAmount = discountAmount.ToMoney(),
|
||||
DiscountPercetage = request.DiscountPercentage,
|
||||
OneMonthAmount = discountedOneMonthAmount.ToMoney(),
|
||||
Obligation = totalAmount.ToMoney()
|
||||
};
|
||||
}
|
||||
|
||||
if (discountAmount > baseAmount)
|
||||
throw new BadRequestException("مقدار تخفیف نمیتواند بیشتر از مبلغ کل باشد");
|
||||
|
||||
return new InstitutionContractDiscountResponse()
|
||||
{
|
||||
Monthly = monthlyPayment,
|
||||
OneTime = oneTimePayment
|
||||
};
|
||||
}
|
||||
|
||||
public InstitutionContractDiscountResponse ResetDiscountCreate(
|
||||
InstitutionContractResetDiscountForCreateRequest request)
|
||||
{
|
||||
InstitutionContractDiscountMonthlyViewModel monthlyPayment = null;
|
||||
InstitutionContractDiscountOneTimeViewModel oneTimePayment = null;
|
||||
|
||||
if (request.IsInstallment)
|
||||
{
|
||||
var newTotalAmount = request.TotalAmount / (1 - (request.DiscountPercentage / 100.0));
|
||||
var taxAmount = (newTotalAmount * 0.10);
|
||||
var paymentAmount = (newTotalAmount + taxAmount);
|
||||
var newOneMonthAmount = request.OneMonthAmount / (1 - (request.DiscountPercentage / 100.0));
|
||||
|
||||
monthlyPayment = new InstitutionContractDiscountMonthlyViewModel()
|
||||
{
|
||||
TotalAmount = newTotalAmount.ToMoney(),
|
||||
Tax = taxAmount.ToMoney(),
|
||||
DiscountedAmount = "0",
|
||||
DiscountPercetage = 0,
|
||||
PaymentAmount = paymentAmount.ToMoney(),
|
||||
Installments = InstitutionMonthlyInstallmentCaculation((int)request.Duration,
|
||||
paymentAmount, DateTime.Now.ToFarsi()),
|
||||
Obligation = newTotalAmount.ToMoney(),
|
||||
OneMonthAmount = newOneMonthAmount.ToMoney()
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
var newTotalAmount = request.TotalAmount / (1 - ((double)request.DiscountPercentage / 100));
|
||||
var taxAmount = (newTotalAmount * 0.10);
|
||||
var paymentAmount = (newTotalAmount + taxAmount);
|
||||
var newOneMonthAmount = request.OneMonthAmount / (1 - ((double)request.DiscountPercentage / 100));
|
||||
|
||||
oneTimePayment = new InstitutionContractDiscountOneTimeViewModel()
|
||||
{
|
||||
TotalAmount = newTotalAmount.ToMoney(),
|
||||
Tax = taxAmount.ToMoney(),
|
||||
PaymentAmount = paymentAmount.ToMoney(),
|
||||
DiscountedAmount = "0",
|
||||
DiscountPercetage = 0,
|
||||
Obligation = newTotalAmount.ToMoney(),
|
||||
OneMonthAmount = newOneMonthAmount.ToMoney()
|
||||
};
|
||||
}
|
||||
|
||||
return new InstitutionContractDiscountResponse()
|
||||
{
|
||||
Monthly = monthlyPayment,
|
||||
OneTime = oneTimePayment
|
||||
};
|
||||
}
|
||||
|
||||
#region Extension
|
||||
|
||||
public async Task<InstitutionContractExtensionInquiryResult> GetExtensionInquiry(long previousContractId)
|
||||
@@ -2174,6 +2280,264 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
return res;
|
||||
}
|
||||
|
||||
public async Task<InstitutionContractDiscountResponse> SetDiscountForExtension(InstitutionContractSetDiscountForExtensionRequest request)
|
||||
{
|
||||
|
||||
if (request.DiscountPercentage <= 0)
|
||||
throw new BadRequestException("مقدار تخفیف نمیتواند برابر یا کمتر از صفر باشد");
|
||||
var institutionTemp = await _institutionExtensionTemp.Find(x => x.Id == request.TempId)
|
||||
.FirstOrDefaultAsync();
|
||||
if (institutionTemp == null)
|
||||
{
|
||||
throw new BadRequestException("اطلاعات وارد شده نامعتبر است");
|
||||
}
|
||||
|
||||
if (request.IsInstallment)
|
||||
{
|
||||
if(institutionTemp.MonthlyPayment.DiscountPercetage>0)
|
||||
throw new BadRequestException("تخفیف قبلا برای این قرارداد اعمال شده است");
|
||||
}
|
||||
else
|
||||
{
|
||||
if(institutionTemp.OneTimePayment.DiscountPercetage>0)
|
||||
throw new BadRequestException("تخفیف قبلا برای این قرارداد اعمال شده است");
|
||||
}
|
||||
var selectedPlan = institutionTemp.Duration switch
|
||||
{
|
||||
InstitutionContractDuration.OneMonth => institutionTemp.OneMonth,
|
||||
InstitutionContractDuration.ThreeMonths => institutionTemp.ThreeMonths,
|
||||
InstitutionContractDuration.SixMonths => institutionTemp.SixMonths,
|
||||
InstitutionContractDuration.TwelveMonths => institutionTemp.TwelveMonths,
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
};
|
||||
var calculateRequest = new InstitutionContractSetDiscountRequest()
|
||||
{
|
||||
Duration = institutionTemp.Duration.Value,
|
||||
TotalAmount = request.TotalAmount,
|
||||
DiscountPercentage = request.DiscountPercentage,
|
||||
IsInstallment = request.IsInstallment,
|
||||
OneMonthAmount = selectedPlan.OneMonthPaymentDiscounted.MoneyToDouble()
|
||||
|
||||
};
|
||||
var res = CalculateDiscount(calculateRequest);
|
||||
|
||||
//این به این دلیل هست که متد caclulate discount یکی از مقادیر رو پر میکنه و ما نیاز داریم هر دو مقدار رو داشته باشیم
|
||||
if (request.IsInstallment)
|
||||
{
|
||||
var onetime = institutionTemp.OneTimePayment;
|
||||
res.OneTime = new()
|
||||
{
|
||||
PaymentAmount = onetime.PaymentAmount,
|
||||
Tax = onetime.Tax,
|
||||
TotalAmount = onetime.TotalAmount,
|
||||
DiscountedAmount = onetime.DiscountedAmount,
|
||||
DiscountPercetage = onetime.DiscountPercetage,
|
||||
};
|
||||
institutionTemp.MonthlyPayment = new()
|
||||
{
|
||||
Installments = res.Monthly.Installments,
|
||||
PaymentAmount = res.Monthly.PaymentAmount,
|
||||
Tax = res.Monthly.Tax,
|
||||
TotalAmount = res.Monthly.TotalAmount,
|
||||
DiscountedAmount = res.Monthly.DiscountedAmount,
|
||||
DiscountPercetage = res.Monthly.DiscountPercetage,
|
||||
};
|
||||
|
||||
selectedPlan.TotalPayment = res.Monthly.TotalAmount;
|
||||
selectedPlan.Obligation = res.Monthly.Obligation;
|
||||
selectedPlan.OneMonthPaymentDiscounted = res.Monthly.PaymentAmount;
|
||||
selectedPlan.DailyCompenseation = (res.Monthly.OneMonthAmount.MoneyToDouble() * 0.10).ToMoney();
|
||||
}
|
||||
else
|
||||
{
|
||||
var monthly = institutionTemp.MonthlyPayment;
|
||||
res.Monthly = new()
|
||||
{
|
||||
PaymentAmount = monthly.PaymentAmount,
|
||||
Tax = monthly.Tax,
|
||||
TotalAmount = monthly.TotalAmount,
|
||||
DiscountedAmount = monthly.DiscountedAmount,
|
||||
DiscountPercetage = monthly.DiscountPercetage,
|
||||
Installments = monthly.Installments,
|
||||
};
|
||||
institutionTemp.OneTimePayment = new()
|
||||
{
|
||||
PaymentAmount = res.OneTime.PaymentAmount,
|
||||
Tax = res.OneTime.Tax,
|
||||
TotalAmount = res.OneTime.TotalAmount,
|
||||
DiscountedAmount = res.OneTime.DiscountedAmount,
|
||||
DiscountPercetage = res.OneTime.DiscountPercetage,
|
||||
};
|
||||
selectedPlan.TotalPayment = res.OneTime.TotalAmount;
|
||||
selectedPlan.Obligation = res.OneTime.Obligation;
|
||||
selectedPlan.OneMonthPaymentDiscounted = res.OneTime.PaymentAmount;
|
||||
selectedPlan.DailyCompenseation = (res.OneTime.OneMonthAmount.MoneyToDouble() * 0.10).ToMoney();
|
||||
}
|
||||
|
||||
switch (institutionTemp.Duration)
|
||||
{
|
||||
case InstitutionContractDuration.OneMonth:
|
||||
institutionTemp.OneMonth = selectedPlan;
|
||||
break;
|
||||
case InstitutionContractDuration.ThreeMonths:
|
||||
institutionTemp.ThreeMonths = selectedPlan;
|
||||
break;
|
||||
case InstitutionContractDuration.SixMonths:
|
||||
institutionTemp.SixMonths = selectedPlan;
|
||||
break;
|
||||
case InstitutionContractDuration.TwelveMonths:
|
||||
institutionTemp.TwelveMonths = selectedPlan;
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
|
||||
}
|
||||
await _institutionExtensionTemp.ReplaceOneAsync(x => x.Id == institutionTemp.Id,
|
||||
institutionTemp);
|
||||
|
||||
return new()
|
||||
{
|
||||
OneTime = res.OneTime,
|
||||
Monthly = res.Monthly
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<InstitutionContractDiscountResponse> ResetDiscountForExtension
|
||||
(InstitutionContractResetDiscountForExtensionRequest request)
|
||||
{
|
||||
var institutionTemp = await _institutionExtensionTemp.Find(x => x.Id == request.TempId)
|
||||
.FirstOrDefaultAsync();
|
||||
if (institutionTemp == null)
|
||||
{
|
||||
throw new BadRequestException("اطلاعات وارد شده نامعتبر است");
|
||||
}
|
||||
|
||||
InstitutionContractDiscountMonthlyViewModel monthlyPayment = null;
|
||||
InstitutionContractDiscountOneTimeViewModel oneTimePayment = null;
|
||||
var selectedPlan = institutionTemp.Duration switch
|
||||
{
|
||||
InstitutionContractDuration.OneMonth => institutionTemp.OneMonth,
|
||||
InstitutionContractDuration.ThreeMonths => institutionTemp.ThreeMonths,
|
||||
InstitutionContractDuration.SixMonths => institutionTemp.SixMonths,
|
||||
InstitutionContractDuration.TwelveMonths => institutionTemp.TwelveMonths,
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
};
|
||||
if (request.IsInstallment)
|
||||
{
|
||||
var prevMonthlyPayment = institutionTemp.MonthlyPayment;
|
||||
var resetTotalAmount = prevMonthlyPayment.TotalAmount.MoneyToDouble() /
|
||||
(1 - (prevMonthlyPayment.DiscountPercetage / 100.0));
|
||||
var resetTax = (resetTotalAmount * 0.10);
|
||||
var paymentAmount = (resetTotalAmount + resetTax);
|
||||
var newOneMonthAmount = selectedPlan.OneMonthPaymentDiscounted.MoneyToDouble() / (1 - (prevMonthlyPayment.DiscountPercetage / 100));
|
||||
monthlyPayment = new InstitutionContractDiscountMonthlyViewModel()
|
||||
{
|
||||
DiscountPercetage = 0,
|
||||
DiscountedAmount = "0",
|
||||
PaymentAmount = paymentAmount.ToMoney(),
|
||||
Tax = resetTax.ToMoney(),
|
||||
TotalAmount = resetTotalAmount.ToMoney(),
|
||||
Installments = InstitutionMonthlyInstallmentCaculation((int)institutionTemp.Duration.Value,
|
||||
paymentAmount, DateTime.Now.ToFarsi()),
|
||||
OneMonthAmount = newOneMonthAmount.ToMoney(),
|
||||
Obligation = resetTotalAmount.ToMoney()
|
||||
|
||||
};
|
||||
institutionTemp.MonthlyPayment = new InstitutionContractPaymentMonthlyViewModel()
|
||||
{
|
||||
Installments = monthlyPayment.Installments,
|
||||
PaymentAmount = monthlyPayment.PaymentAmount,
|
||||
Tax = monthlyPayment.Tax,
|
||||
TotalAmount = monthlyPayment.TotalAmount,
|
||||
DiscountedAmount = monthlyPayment.DiscountedAmount,
|
||||
DiscountPercetage = monthlyPayment.DiscountPercetage,
|
||||
};
|
||||
selectedPlan.TotalPayment = monthlyPayment.TotalAmount;
|
||||
selectedPlan.Obligation = monthlyPayment.Obligation;
|
||||
selectedPlan.OneMonthPaymentDiscounted = monthlyPayment.OneMonthAmount;
|
||||
selectedPlan.DailyCompenseation = (monthlyPayment.OneMonthAmount.MoneyToDouble() * 0.10).ToMoney();
|
||||
|
||||
switch (institutionTemp.Duration)
|
||||
{
|
||||
case InstitutionContractDuration.OneMonth:
|
||||
institutionTemp.OneMonth = selectedPlan;
|
||||
break;
|
||||
case InstitutionContractDuration.ThreeMonths:
|
||||
institutionTemp.ThreeMonths = selectedPlan;
|
||||
break;
|
||||
case InstitutionContractDuration.SixMonths:
|
||||
institutionTemp.SixMonths = selectedPlan;
|
||||
break;
|
||||
case InstitutionContractDuration.TwelveMonths:
|
||||
institutionTemp.TwelveMonths = selectedPlan;
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
await _institutionExtensionTemp.ReplaceOneAsync(x=>x.Id == institutionTemp.Id,
|
||||
institutionTemp);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
var prevOneTimePayment = institutionTemp.OneTimePayment;
|
||||
var resetTotalAmount = prevOneTimePayment.TotalAmount.MoneyToDouble() /
|
||||
(1 - (prevOneTimePayment.DiscountPercetage / 100.0));
|
||||
var resetTax = (resetTotalAmount * 0.10);
|
||||
var newOneMonthAmount = selectedPlan.OneMonthPaymentDiscounted.MoneyToDouble() / (1 - (prevOneTimePayment.DiscountPercetage / 100));
|
||||
|
||||
oneTimePayment = new InstitutionContractDiscountOneTimeViewModel()
|
||||
{
|
||||
DiscountPercetage = 0,
|
||||
DiscountedAmount = "0",
|
||||
TotalAmount = resetTotalAmount.ToMoney(),
|
||||
Tax = resetTax.ToMoney(),
|
||||
PaymentAmount = (resetTotalAmount + resetTax).ToMoney(),
|
||||
OneMonthAmount = newOneMonthAmount.ToMoney(),
|
||||
Obligation = resetTotalAmount.ToMoney()
|
||||
};
|
||||
institutionTemp.OneTimePayment = new InstitutionContractPaymentOneTimeViewModel()
|
||||
{
|
||||
PaymentAmount = oneTimePayment.PaymentAmount,
|
||||
Tax = oneTimePayment.Tax,
|
||||
TotalAmount = oneTimePayment.TotalAmount,
|
||||
DiscountedAmount = oneTimePayment.DiscountedAmount,
|
||||
DiscountPercetage = oneTimePayment.DiscountPercetage,
|
||||
};
|
||||
selectedPlan.TotalPayment = oneTimePayment.TotalAmount;
|
||||
selectedPlan.Obligation = oneTimePayment.Obligation;
|
||||
selectedPlan.OneMonthPaymentDiscounted = oneTimePayment.OneMonthAmount;
|
||||
selectedPlan.DailyCompenseation = (oneTimePayment.OneMonthAmount.MoneyToDouble() * 0.10).ToMoney();
|
||||
|
||||
switch (institutionTemp.Duration)
|
||||
{
|
||||
case InstitutionContractDuration.OneMonth:
|
||||
institutionTemp.OneMonth = selectedPlan;
|
||||
break;
|
||||
case InstitutionContractDuration.ThreeMonths:
|
||||
institutionTemp.ThreeMonths = selectedPlan;
|
||||
break;
|
||||
case InstitutionContractDuration.SixMonths:
|
||||
institutionTemp.SixMonths = selectedPlan;
|
||||
break;
|
||||
case InstitutionContractDuration.TwelveMonths:
|
||||
institutionTemp.TwelveMonths = selectedPlan;
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
await _institutionExtensionTemp.ReplaceOneAsync(x=>x.Id == institutionTemp.Id,
|
||||
institutionTemp);
|
||||
}
|
||||
|
||||
return new InstitutionContractDiscountResponse()
|
||||
{
|
||||
OneTime = oneTimePayment,
|
||||
Monthly = monthlyPayment
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
public async Task<OperationResult> ExtensionComplete(InstitutionContractExtensionCompleteRequest request)
|
||||
{
|
||||
var institutionContractTemp = await _institutionExtensionTemp.Find(x => x.Id == request.TemporaryId)
|
||||
@@ -2318,7 +2682,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
previousInstitutionContract.Description,
|
||||
"NotOfficial", "JobRelation", hasValueAddedTax,
|
||||
payment.Tax.MoneyToDouble(), [],
|
||||
request.LawId);
|
||||
request.LawId,payment.DiscountPercetage,payment.DiscountedAmount.MoneyToDouble());
|
||||
|
||||
await CreateAsync(entity);
|
||||
await SaveChangesAsync();
|
||||
@@ -2358,11 +2722,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
await _context.AddAsync(financialStatement);
|
||||
}
|
||||
|
||||
var today = DateTime.Today;
|
||||
double invoiceAmount;
|
||||
string invoiceItemDescription;
|
||||
FinancialInvoiceItemType invoiceItemType;
|
||||
long invoiceItemEntityId;
|
||||
|
||||
if (request.IsInstallment && payment is InstitutionContractPaymentMonthlyViewModel monthly)
|
||||
{
|
||||
var installments = monthly.Installments.Select(x =>
|
||||
@@ -2386,32 +2746,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
|
||||
entity.SetInstallments(installments);
|
||||
await SaveChangesAsync();
|
||||
|
||||
var financialTransaction = new FinancialTransaction(0, today, today.ToFarsi(),
|
||||
"قسط اول سرویس", "debt", "بابت خدمات", firstInstallmentAmount, 0, 0);
|
||||
|
||||
financialStatement.AddFinancialTransaction(financialTransaction);
|
||||
invoiceAmount = firstInstallmentAmount;
|
||||
invoiceItemDescription = $"پرداخت قسط اول قرارداد شماره {entity.ContractNo}";
|
||||
invoiceItemType = FinancialInvoiceItemType.BuyInstitutionContractInstallment;
|
||||
invoiceItemEntityId = todayInstallment.Id;
|
||||
}
|
||||
else
|
||||
{
|
||||
var financialTransaction = new FinancialTransaction(0, today, today.ToFarsi(),
|
||||
"پرداخت کل سرویس", "debt", "بابت خدمات", totalAmount, 0, 0);
|
||||
financialStatement.AddFinancialTransaction(financialTransaction);
|
||||
invoiceAmount = totalAmount;
|
||||
invoiceItemDescription = $"پرداخت کل قرارداد شماره {entity.ContractNo}";
|
||||
invoiceItemType = FinancialInvoiceItemType.BuyInstitutionContract;
|
||||
invoiceItemEntityId = entity.id;
|
||||
}
|
||||
var financialInvoice = new FinancialInvoice(invoiceAmount, contractingParty.id, $"خرید قرارداد مالی شماره {entity.ContractNo}");
|
||||
var financialInvoiceItem = new FinancialInvoiceItem(invoiceItemDescription, invoiceAmount, 0,invoiceItemType, invoiceItemEntityId);
|
||||
financialInvoice.AddItem(financialInvoiceItem);
|
||||
|
||||
await _context.AddAsync(financialInvoice);
|
||||
await SaveChangesAsync();
|
||||
|
||||
foreach (var contactInfo in institutionContractTemp.ContactInfos)
|
||||
{
|
||||
@@ -2867,7 +3202,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
{
|
||||
OneTime = new()
|
||||
{
|
||||
TotalAmount = selectedPlan.TotalPayment,
|
||||
TotalAmount = oneTimeBase.ToMoney(),
|
||||
Tax = oneTimeTax.ToMoney(),
|
||||
PaymentAmount = oneTimeTotal.ToMoney()
|
||||
}
|
||||
@@ -4230,7 +4565,12 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
|
||||
}
|
||||
|
||||
|
||||
public async Task<long> GetIdByInstallmentId(long installmentId)
|
||||
{
|
||||
return await _context.InstitutionContractSet.Include(x=>x.Installments)
|
||||
.Where(x=>x.Installments.Any(i=>i.Id==installmentId))
|
||||
.Select(x=>x.id).FirstOrDefaultAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -4723,6 +4723,8 @@ public class RollCallMandatoryRepository : RepositoryBase<long, RollCall>, IRoll
|
||||
#endregion
|
||||
|
||||
#region KebabMahdiAbsentsCaclculation
|
||||
|
||||
|
||||
|
||||
var rollCallDays = groupedRollCall.Count > mandatoryDays ? mandatoryDays : groupedRollCall.Count;
|
||||
|
||||
@@ -5108,6 +5110,45 @@ public class RollCallMandatoryRepository : RepositoryBase<long, RollCall>, IRoll
|
||||
});
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region اگر که پرسنل در روز های جمعه یا پنجشنبه غیبت داشت یک روز به غیبت اضافه شود
|
||||
//این منطق زمانی برقرار هست که مرخصی در اون روز نداشته باشه
|
||||
|
||||
// ساخت لیست روزهای بین شروع و پایان قرارداد
|
||||
var contractDaysList = Enumerable.Range(0, (contractEnd - contractStart).Days + 1)
|
||||
.Select(offset => contractStart.AddDays(offset))
|
||||
.ToList();
|
||||
|
||||
// کم کردن روزهایی که حضور دارند
|
||||
var absentDaysList = contractDaysList
|
||||
.Where(date => !groupedRollCall.Any(g => g.ShiftDate.Date == date.Date))
|
||||
.ToList();
|
||||
|
||||
var absentFridaysOrThursdays = absentDaysList
|
||||
.Where(date => date.DayOfWeek is DayOfWeek.Friday or DayOfWeek.Thursday)
|
||||
.ToList();
|
||||
|
||||
var leaveList = _context.LeaveList
|
||||
.Where(x => x.EmployeeId == employeeId
|
||||
&& x.WorkshopId == workshopId
|
||||
&& x.IsAccepted == true
|
||||
&& x.StartLeave <= contractEnd
|
||||
&& x.EndLeave >= contractStart
|
||||
&& x.LeaveType == "استحقاقی"
|
||||
&& x.PaidLeaveType =="روزانه")
|
||||
.Select(x => new { x.StartLeave, x.EndLeave })
|
||||
.ToList();
|
||||
|
||||
// بررسی کدام روزهای غایب جمعه/پنجشنبه در بازه مرخصی قرار ندارند
|
||||
var absentFridaysOrThursdaysWithoutLeave = absentFridaysOrThursdays
|
||||
.Where(date => !leaveList.Any(leave => date.Date >= leave.StartLeave.Date && date.Date <= leave.EndLeave.Date))
|
||||
.ToList();
|
||||
|
||||
// تعداد روزهای غایب جمعه/پنجشنبه بدون مرخصی
|
||||
int absentFridaysOrThursdaysWithoutLeaveCount = absentFridaysOrThursdaysWithoutLeave.Count;
|
||||
|
||||
absentsDeductionAmount += absentFridaysOrThursdaysWithoutLeaveCount * dailyWage;
|
||||
#endregion
|
||||
|
||||
|
||||
return new CustomizeCheckoutMandatoryViewModel
|
||||
|
||||
@@ -15,268 +15,282 @@ namespace CompanyManagment.EFCore.Services;
|
||||
|
||||
public class UidService : IUidService
|
||||
{
|
||||
private readonly HttpClient _httpClient;
|
||||
private readonly IAuthorizedPersonApplication _authorizedPersonApplication;
|
||||
private readonly IAuthorizedBankDetailsApplication _authorizedBankDetailsApplication;
|
||||
private const string BaseUrl = "https://json-api.uid.ir/api/";
|
||||
|
||||
public const string BusinessToken = "5e03dd4e-999d-466f-92d8-7c0b1f66a8e9";
|
||||
private readonly HttpClient _httpClient;
|
||||
private readonly IAuthorizedPersonApplication _authorizedPersonApplication;
|
||||
private readonly IAuthorizedBankDetailsApplication _authorizedBankDetailsApplication;
|
||||
private const string BaseUrl = "https://json-api.uid.ir/api/";
|
||||
|
||||
public const string BusinessToken = "5e03dd4e-999d-466f-92d8-7c0b1f66a8e9";
|
||||
public const string BusinessId = "98ed67ca-d441-4978-a748-e8bebce010eb";
|
||||
|
||||
|
||||
public UidService(IAuthorizedPersonApplication authorizedPersonApplication, IAuthorizedBankDetailsApplication authorizedBankDetailsApplication)
|
||||
{
|
||||
_httpClient = new HttpClient()
|
||||
{
|
||||
BaseAddress = new Uri(BaseUrl),
|
||||
Timeout = new TimeSpan(0, 0, 12)
|
||||
};
|
||||
_authorizedPersonApplication = authorizedPersonApplication;
|
||||
_authorizedBankDetailsApplication = authorizedBankDetailsApplication;
|
||||
}
|
||||
|
||||
public async Task<PersonalInfoResponse> GetPersonalInfo(string nationalCode, string birthDate)
|
||||
{
|
||||
// First check if person exists in database
|
||||
var existingPerson = _authorizedPersonApplication.GetByNationalCode(nationalCode);
|
||||
if (existingPerson != null)
|
||||
{
|
||||
if (birthDate !=existingPerson.BirthDate )
|
||||
{
|
||||
return new PersonalInfoResponse(new UidBasicInformation(),
|
||||
new IdentificationInformation(default, default, default, default, default), new RegistrationStatus(),
|
||||
new ResponseContext(new UidStatus(13, "تاریخ تولد وارد با کد ملی تطابق ندارد")));
|
||||
}
|
||||
// Return data from database instead of calling API
|
||||
return CreatePersonalInfoResponseFromDatabase(existingPerson);
|
||||
}
|
||||
public UidService(IAuthorizedPersonApplication authorizedPersonApplication,
|
||||
IAuthorizedBankDetailsApplication authorizedBankDetailsApplication)
|
||||
{
|
||||
_httpClient = new HttpClient()
|
||||
{
|
||||
BaseAddress = new Uri(BaseUrl),
|
||||
Timeout = new TimeSpan(0, 0, 20)
|
||||
};
|
||||
_authorizedPersonApplication = authorizedPersonApplication;
|
||||
_authorizedBankDetailsApplication = authorizedBankDetailsApplication;
|
||||
}
|
||||
|
||||
// If not found in database, call UID API
|
||||
var request = new PersonalInfoRequest
|
||||
{
|
||||
BirthDate = birthDate,
|
||||
NationalId = nationalCode,
|
||||
RequestContext = new UidRequestContext()
|
||||
};
|
||||
var json = JsonConvert.SerializeObject(request);
|
||||
var contentType = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
public async Task<PersonalInfoResponse> GetPersonalInfo(string nationalCode, string birthDate)
|
||||
{
|
||||
// First check if person exists in database
|
||||
var existingPerson = _authorizedPersonApplication.GetByNationalCode(nationalCode);
|
||||
if (existingPerson != null)
|
||||
{
|
||||
if (birthDate != existingPerson.BirthDate)
|
||||
{
|
||||
return new PersonalInfoResponse(new UidBasicInformation(),
|
||||
new IdentificationInformation(default, default, default, default, default),
|
||||
new RegistrationStatus(),
|
||||
new ResponseContext(new UidStatus(13, "تاریخ تولد وارد با کد ملی تطابق ندارد")));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var requestResult = await _httpClient.PostAsync("inquiry/person/v2", contentType);
|
||||
|
||||
if (!requestResult.IsSuccessStatusCode)
|
||||
return null;
|
||||
var responseResult = await requestResult.Content.ReadFromJsonAsync<PersonalInfoResponse>();
|
||||
if (responseResult.BasicInformation != null)
|
||||
{
|
||||
responseResult.BasicInformation.FirstName = responseResult.BasicInformation.FirstName?.ToPersian();
|
||||
responseResult.BasicInformation.LastName = responseResult.BasicInformation.LastName?.ToPersian();
|
||||
responseResult.BasicInformation.FatherName = responseResult.BasicInformation.FatherName?.ToPersian();
|
||||
}
|
||||
// Return data from database instead of calling API
|
||||
return CreatePersonalInfoResponseFromDatabase(existingPerson);
|
||||
}
|
||||
|
||||
// ذخیره اطلاعات در جدول AuthorizedPerson
|
||||
await SaveAuthorizedPersonData(responseResult, nationalCode, birthDate);
|
||||
// If not found in database, call UID API
|
||||
var request = new PersonalInfoRequest
|
||||
{
|
||||
BirthDate = birthDate,
|
||||
NationalId = nationalCode,
|
||||
RequestContext = new UidRequestContext()
|
||||
};
|
||||
var json = JsonConvert.SerializeObject(request);
|
||||
var contentType = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
|
||||
return responseResult;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return new PersonalInfoResponse(new UidBasicInformation(),
|
||||
new IdentificationInformation(default, default, default, default, default), new RegistrationStatus(),
|
||||
new ResponseContext(new UidStatus(14, "")));
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
var requestResult = await _httpClient.PostAsync("inquiry/person/v2", contentType);
|
||||
|
||||
private PersonalInfoResponse CreatePersonalInfoResponseFromDatabase(AuthorizedPersonViewModel person)
|
||||
{
|
||||
var basicInfo = new UidBasicInformation
|
||||
{
|
||||
FirstName = person.FirstName,
|
||||
LastName = person.LastName,
|
||||
FatherName = person.FatherName,
|
||||
Gender = person.Gender
|
||||
};
|
||||
if (!requestResult.IsSuccessStatusCode)
|
||||
return null;
|
||||
|
||||
var responseResult = await requestResult.Content.ReadFromJsonAsync<PersonalInfoResponse>();
|
||||
|
||||
if (responseResult.BasicInformation != null)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(responseResult.BasicInformation.FirstName))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
responseResult.BasicInformation.FirstName = responseResult.BasicInformation.FirstName?.ToPersian();
|
||||
responseResult.BasicInformation.LastName = responseResult.BasicInformation.LastName?.ToPersian();
|
||||
responseResult.BasicInformation.FatherName = responseResult.BasicInformation.FatherName?.ToPersian();
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var identificationInfo = new IdentificationInformation(
|
||||
person.NationalCode,
|
||||
person.BirthDate,
|
||||
person.ShenasnameSeri,
|
||||
person.ShenasnameSerial,
|
||||
person.ShenasnamehNumber
|
||||
);
|
||||
// ذخیره اطلاعات در جدول AuthorizedPerson
|
||||
await SaveAuthorizedPersonData(responseResult, nationalCode, birthDate);
|
||||
|
||||
var registrationStatus = new RegistrationStatus
|
||||
{
|
||||
DeathStatus = person.DeathStatus
|
||||
};
|
||||
return responseResult;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return new PersonalInfoResponse(new UidBasicInformation(),
|
||||
new IdentificationInformation(default, default, default, default, default), new RegistrationStatus(),
|
||||
new ResponseContext(new UidStatus(14, "")));
|
||||
}
|
||||
}
|
||||
|
||||
var responseContext = new ResponseContext(new UidStatus(0, "Success - از دیتابیس"));
|
||||
private PersonalInfoResponse CreatePersonalInfoResponseFromDatabase(AuthorizedPersonViewModel person)
|
||||
{
|
||||
var basicInfo = new UidBasicInformation
|
||||
{
|
||||
FirstName = person.FirstName,
|
||||
LastName = person.LastName,
|
||||
FatherName = person.FatherName,
|
||||
Gender = person.Gender
|
||||
};
|
||||
|
||||
return new PersonalInfoResponse(basicInfo, identificationInfo, registrationStatus, responseContext);
|
||||
}
|
||||
var identificationInfo = new IdentificationInformation(
|
||||
person.NationalCode,
|
||||
person.BirthDate,
|
||||
person.ShenasnameSeri,
|
||||
person.ShenasnameSerial,
|
||||
person.ShenasnamehNumber
|
||||
);
|
||||
|
||||
private async Task SaveAuthorizedPersonData(PersonalInfoResponse response, string nationalCode, string birthDate)
|
||||
{
|
||||
if (response?.BasicInformation == null || response.ResponseContext?.Status?.Code != 0)
|
||||
return;
|
||||
var registrationStatus = new RegistrationStatus
|
||||
{
|
||||
DeathStatus = person.DeathStatus
|
||||
};
|
||||
|
||||
var command = new CreateAuthorizedPerson
|
||||
{
|
||||
NationalCode = nationalCode,
|
||||
FirstName = response.BasicInformation.FirstName ?? "",
|
||||
LastName = response.BasicInformation.LastName ?? "",
|
||||
FatherName = response.BasicInformation.FatherName ?? "",
|
||||
BirthDate = birthDate,
|
||||
Gender = response.BasicInformation.Gender ?? "",
|
||||
DeathStatus = response.RegistrationStatus?.DeathStatus ?? "",
|
||||
ShenasnameSeri = response.IdentificationInformation?.ShenasnameSeri ?? "",
|
||||
ShenasnameSerial = response.IdentificationInformation?.ShenasnameSerial ?? "",
|
||||
ShenasnamehNumber = response.IdentificationInformation?.ShenasnamehNumber ?? ""
|
||||
};
|
||||
var responseContext = new ResponseContext(new UidStatus(0, "Success - از دیتابیس"));
|
||||
|
||||
_authorizedPersonApplication.CreateFromUidResponse(command);
|
||||
}
|
||||
return new PersonalInfoResponse(basicInfo, identificationInfo, registrationStatus, responseContext);
|
||||
}
|
||||
|
||||
public async Task<MatchMobileWithNationalCodeResponse> IsMachPhoneWithNationalCode(string nationalCode, string phoneNumber)
|
||||
{
|
||||
var request = new PersonalInfoRequest
|
||||
{
|
||||
MobileNumber = phoneNumber,
|
||||
NationalId = nationalCode,
|
||||
RequestContext = new UidRequestContext()
|
||||
};
|
||||
var json = JsonConvert.SerializeObject(request);
|
||||
var contentType = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
private async Task SaveAuthorizedPersonData(PersonalInfoResponse response, string nationalCode, string birthDate)
|
||||
{
|
||||
if (response?.BasicInformation == null || response.ResponseContext?.Status?.Code != 0)
|
||||
return;
|
||||
|
||||
var requestResult = await _httpClient.PostAsync("inquiry/mobile/owner/v2", contentType);
|
||||
if (!requestResult.IsSuccessStatusCode)
|
||||
return null;
|
||||
var command = new CreateAuthorizedPerson
|
||||
{
|
||||
NationalCode = nationalCode,
|
||||
FirstName = response.BasicInformation.FirstName ?? "",
|
||||
LastName = response.BasicInformation.LastName ?? "",
|
||||
FatherName = response.BasicInformation.FatherName ?? "",
|
||||
BirthDate = birthDate,
|
||||
Gender = response.BasicInformation.Gender ?? "",
|
||||
DeathStatus = response.RegistrationStatus?.DeathStatus ?? "",
|
||||
ShenasnameSeri = response.IdentificationInformation?.ShenasnameSeri ?? "",
|
||||
ShenasnameSerial = response.IdentificationInformation?.ShenasnameSerial ?? "",
|
||||
ShenasnamehNumber = response.IdentificationInformation?.ShenasnamehNumber ?? ""
|
||||
};
|
||||
|
||||
var responseResult = await requestResult.Content.ReadFromJsonAsync<MatchMobileWithNationalCodeResponse>();
|
||||
return responseResult;
|
||||
}
|
||||
_authorizedPersonApplication.CreateFromUidResponse(command);
|
||||
}
|
||||
|
||||
public async Task<IbanInquiryResponse> IbanInquiry(string iban)
|
||||
{
|
||||
// First check if bank details exist in database
|
||||
var existingBankDetails = _authorizedBankDetailsApplication.GetByIban(iban);
|
||||
if (existingBankDetails != null)
|
||||
{
|
||||
// Return data from database instead of calling API
|
||||
return CreateIbanInquiryResponseFromDatabase(existingBankDetails);
|
||||
}
|
||||
public async Task<MatchMobileWithNationalCodeResponse> IsMachPhoneWithNationalCode(string nationalCode,
|
||||
string phoneNumber)
|
||||
{
|
||||
var request = new PersonalInfoRequest
|
||||
{
|
||||
MobileNumber = phoneNumber,
|
||||
NationalId = nationalCode,
|
||||
RequestContext = new UidRequestContext()
|
||||
};
|
||||
var json = JsonConvert.SerializeObject(request);
|
||||
var contentType = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
|
||||
// If not found in database, call UID API
|
||||
var request = new
|
||||
{
|
||||
iban,
|
||||
requestContext = new UidRequestContext()
|
||||
};
|
||||
var json = JsonConvert.SerializeObject(request);
|
||||
var contentType = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
|
||||
try
|
||||
{
|
||||
var requestResult = await _httpClient.PostAsync("inquiry/iban/v2", contentType);
|
||||
requestResult.EnsureSuccessStatusCode();
|
||||
var responseResult = await requestResult.Content.ReadFromJsonAsync<IbanInquiryResponse>();
|
||||
|
||||
if (responseResult.ResponseContext.Status.Code == 0)
|
||||
{
|
||||
var entity = new CreateAuthorizedBankDetails
|
||||
{
|
||||
IBan = iban,
|
||||
AccountNumber = responseResult?.AccountBasicInformation?.AccountNumber ?? "",
|
||||
BankName = responseResult?.AccountBasicInformation?.BankInformation?.BankName ?? "",
|
||||
OwnersList = responseResult?.Owners.Select(x=> new CreateAuthorizedBankDetailsOwner()
|
||||
{
|
||||
FName = x.FirstName,
|
||||
LName = x.LastName,
|
||||
NationalIdentifier = x.NationalIdentifier,
|
||||
CustomerType = x.CustomerType
|
||||
}).ToList() ?? []
|
||||
};
|
||||
_authorizedBankDetailsApplication.Create(entity);
|
||||
}
|
||||
|
||||
return responseResult;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return new IbanInquiryResponse
|
||||
{
|
||||
ResponseContext = new ResponseContext(new UidStatus(14, "خطا در دریافت اطلاعات از سرویس"))
|
||||
};
|
||||
}
|
||||
}
|
||||
var requestResult = await _httpClient.PostAsync("inquiry/mobile/owner/v2", contentType);
|
||||
if (!requestResult.IsSuccessStatusCode)
|
||||
return null;
|
||||
|
||||
private IbanInquiryResponse CreateIbanInquiryResponseFromDatabase(AuthorizedBankDetailsViewModel bankDetails)
|
||||
{
|
||||
var accountBasicInfo = new IbanInquiryAccountBasicInformation
|
||||
{
|
||||
Iban = bankDetails.IBan,
|
||||
AccountNumber = bankDetails.AccountNumber,
|
||||
BankInformation = new IbanInquiryBankInformation
|
||||
{
|
||||
BankName = bankDetails.BankName
|
||||
},
|
||||
AccountStatus = "Active"
|
||||
};
|
||||
var responseResult = await requestResult.Content.ReadFromJsonAsync<MatchMobileWithNationalCodeResponse>();
|
||||
return responseResult;
|
||||
}
|
||||
|
||||
var owners = new List<IbanInquiryOwner>();
|
||||
|
||||
// Add owner information if available
|
||||
if (bankDetails.Owners.Any())
|
||||
{
|
||||
var owner = bankDetails.Owners.First();
|
||||
owners.Add(new IbanInquiryOwner
|
||||
{
|
||||
NationalIdentifier = owner.NationalIdentifier,
|
||||
FirstName = owner.FName,
|
||||
LastName = owner.LName,
|
||||
CustomerType = owner.CustomerType
|
||||
});
|
||||
}
|
||||
public async Task<IbanInquiryResponse> IbanInquiry(string iban)
|
||||
{
|
||||
// First check if bank details exist in database
|
||||
var existingBankDetails = _authorizedBankDetailsApplication.GetByIban(iban);
|
||||
if (existingBankDetails != null)
|
||||
{
|
||||
// Return data from database instead of calling API
|
||||
return CreateIbanInquiryResponseFromDatabase(existingBankDetails);
|
||||
}
|
||||
|
||||
var responseContext = new ResponseContext(new UidStatus(0, "Success - از دیتابیس"));
|
||||
// If not found in database, call UID API
|
||||
var request = new
|
||||
{
|
||||
iban,
|
||||
requestContext = new UidRequestContext()
|
||||
};
|
||||
var json = JsonConvert.SerializeObject(request);
|
||||
var contentType = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
|
||||
return new IbanInquiryResponse
|
||||
{
|
||||
AccountBasicInformation = accountBasicInfo,
|
||||
Owners = owners,
|
||||
ResponseContext = responseContext
|
||||
};
|
||||
}
|
||||
try
|
||||
{
|
||||
var requestResult = await _httpClient.PostAsync("inquiry/iban/v2", contentType);
|
||||
requestResult.EnsureSuccessStatusCode();
|
||||
var responseResult = await requestResult.Content.ReadFromJsonAsync<IbanInquiryResponse>();
|
||||
|
||||
public async Task<AccountToIbanResponse> AccountToIban(string accountNumber, UidBanks bank)
|
||||
{
|
||||
var request = new
|
||||
{
|
||||
accountNumber,
|
||||
bank,
|
||||
requestContext = new UidRequestContext()
|
||||
};
|
||||
var json = JsonConvert.SerializeObject(request);
|
||||
var contentType = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
var requestResult = await _httpClient.PostAsync("account-to-iban", contentType);
|
||||
requestResult.EnsureSuccessStatusCode();
|
||||
var responseResult = await requestResult.Content.ReadFromJsonAsync<AccountToIbanResponse>();
|
||||
return responseResult;
|
||||
}
|
||||
if (responseResult.ResponseContext.Status.Code == 0)
|
||||
{
|
||||
var entity = new CreateAuthorizedBankDetails
|
||||
{
|
||||
IBan = iban,
|
||||
AccountNumber = responseResult?.AccountBasicInformation?.AccountNumber ?? "",
|
||||
BankName = responseResult?.AccountBasicInformation?.BankInformation?.BankName ?? "",
|
||||
OwnersList = responseResult?.Owners.Select(x => new CreateAuthorizedBankDetailsOwner()
|
||||
{
|
||||
FName = x.FirstName,
|
||||
LName = x.LastName,
|
||||
NationalIdentifier = x.NationalIdentifier,
|
||||
CustomerType = x.CustomerType
|
||||
}).ToList() ?? []
|
||||
};
|
||||
_authorizedBankDetailsApplication.Create(entity);
|
||||
}
|
||||
|
||||
public async Task<CardToNumberResponse> CardToIban(string cardNumber)
|
||||
{
|
||||
var request = new
|
||||
{
|
||||
cardNumber,
|
||||
requestContext = new UidRequestContext()
|
||||
};
|
||||
var json = JsonConvert.SerializeObject(request);
|
||||
var contentType = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
var requestResult = await _httpClient.PostAsync("inquiry/card", contentType);
|
||||
requestResult.EnsureSuccessStatusCode();
|
||||
var responseResult = await requestResult.Content.ReadFromJsonAsync<CardToNumberResponse>();
|
||||
return responseResult;
|
||||
}
|
||||
}
|
||||
return responseResult;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return new IbanInquiryResponse
|
||||
{
|
||||
ResponseContext = new ResponseContext(new UidStatus(14, "خطا در دریافت اطلاعات از سرویس"))
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private IbanInquiryResponse CreateIbanInquiryResponseFromDatabase(AuthorizedBankDetailsViewModel bankDetails)
|
||||
{
|
||||
var accountBasicInfo = new IbanInquiryAccountBasicInformation
|
||||
{
|
||||
Iban = bankDetails.IBan,
|
||||
AccountNumber = bankDetails.AccountNumber,
|
||||
BankInformation = new IbanInquiryBankInformation
|
||||
{
|
||||
BankName = bankDetails.BankName
|
||||
},
|
||||
AccountStatus = "Active"
|
||||
};
|
||||
|
||||
var owners = new List<IbanInquiryOwner>();
|
||||
|
||||
// Add owner information if available
|
||||
if (bankDetails.Owners.Any())
|
||||
{
|
||||
var owner = bankDetails.Owners.First();
|
||||
owners.Add(new IbanInquiryOwner
|
||||
{
|
||||
NationalIdentifier = owner.NationalIdentifier,
|
||||
FirstName = owner.FName,
|
||||
LastName = owner.LName,
|
||||
CustomerType = owner.CustomerType
|
||||
});
|
||||
}
|
||||
|
||||
var responseContext = new ResponseContext(new UidStatus(0, "Success - از دیتابیس"));
|
||||
|
||||
return new IbanInquiryResponse
|
||||
{
|
||||
AccountBasicInformation = accountBasicInfo,
|
||||
Owners = owners,
|
||||
ResponseContext = responseContext
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<AccountToIbanResponse> AccountToIban(string accountNumber, UidBanks bank)
|
||||
{
|
||||
var request = new
|
||||
{
|
||||
accountNumber,
|
||||
bank,
|
||||
requestContext = new UidRequestContext()
|
||||
};
|
||||
var json = JsonConvert.SerializeObject(request);
|
||||
var contentType = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
var requestResult = await _httpClient.PostAsync("account-to-iban", contentType);
|
||||
requestResult.EnsureSuccessStatusCode();
|
||||
var responseResult = await requestResult.Content.ReadFromJsonAsync<AccountToIbanResponse>();
|
||||
return responseResult;
|
||||
}
|
||||
|
||||
public async Task<CardToNumberResponse> CardToIban(string cardNumber)
|
||||
{
|
||||
var request = new
|
||||
{
|
||||
cardNumber,
|
||||
requestContext = new UidRequestContext()
|
||||
};
|
||||
var json = JsonConvert.SerializeObject(request);
|
||||
var contentType = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
var requestResult = await _httpClient.PostAsync("inquiry/card", contentType);
|
||||
requestResult.EnsureSuccessStatusCode();
|
||||
var responseResult = await requestResult.Content.ReadFromJsonAsync<CardToNumberResponse>();
|
||||
return responseResult;
|
||||
}
|
||||
}
|
||||
@@ -451,8 +451,19 @@ public class institutionContractController : AdminBaseController
|
||||
|
||||
return operationResult;
|
||||
}
|
||||
|
||||
|
||||
[HttpPost("create/set-discount")]
|
||||
public ActionResult<InstitutionContractDiscountResponse> SetDiscountForInstitutionContract([FromBody]InstitutionContractSetDiscountRequest request)
|
||||
{
|
||||
var res = _institutionContractApplication.CalculateDiscount(request);
|
||||
return res;
|
||||
}
|
||||
|
||||
[HttpPost("create/reset-discount")]
|
||||
public ActionResult<InstitutionContractDiscountResponse> ResetDiscountForCreate([FromBody]InstitutionContractResetDiscountForCreateRequest request)
|
||||
{
|
||||
var res = _institutionContractApplication.ResetDiscountCreate(request);
|
||||
return res;
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
@@ -545,7 +556,21 @@ public class institutionContractController : AdminBaseController
|
||||
var res =await _institutionContractApplication.GetExtensionPaymentMethod(request);
|
||||
return res;
|
||||
}
|
||||
|
||||
[HttpPost("extension/set-discount")]
|
||||
public async Task<ActionResult<InstitutionContractDiscountResponse>> SetDiscountForExtension([FromBody]InstitutionContractSetDiscountForExtensionRequest request)
|
||||
{
|
||||
var res =await _institutionContractApplication.SetDiscountForExtension(request);
|
||||
return res;
|
||||
}
|
||||
|
||||
[HttpPost("extension/reset-discount")]
|
||||
public async Task<ActionResult<InstitutionContractDiscountResponse>> ResetDiscountForExtension([FromBody]InstitutionContractResetDiscountForExtensionRequest request)
|
||||
{
|
||||
var res =await _institutionContractApplication.ResetDiscountForExtension(request);
|
||||
return res;
|
||||
}
|
||||
|
||||
[HttpPost("extenstion/complete")]
|
||||
public async Task<ActionResult<OperationResult>> ExtensionComplete([FromBody]InstitutionContractExtensionCompleteRequest request)
|
||||
{
|
||||
|
||||
@@ -28,6 +28,7 @@ using Parbad;
|
||||
using Parbad.AspNetCore;
|
||||
using Parbad.Gateway.Sepehr;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using _0_Framework.Application.Enums;
|
||||
using CompanyManagement.Infrastructure.Excel.WorkshopsRollCall;
|
||||
using static ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk.IndexModel2;
|
||||
|
||||
@@ -46,18 +47,18 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk
|
||||
private readonly IOnlinePayment _onlinePayment;
|
||||
|
||||
|
||||
|
||||
[BindProperty] public IFormFile File { get; set; }
|
||||
|
||||
|
||||
[BindProperty]
|
||||
[Required(ErrorMessage = "لطفا نام ورژن را وارد کنید")]
|
||||
[Display(Name = "نام ورژن")]
|
||||
public string VersionName { get; set; }
|
||||
|
||||
|
||||
[BindProperty]
|
||||
[Required(ErrorMessage = "لطفا کد ورژن را وارد کنید")]
|
||||
[Display(Name = "کد ورژن")]
|
||||
public string VersionCode { get; set; }
|
||||
|
||||
[BindProperty] public ApkType SelectedApkType { get; set; }
|
||||
[BindProperty] public bool IsForce { get; set; }
|
||||
|
||||
@@ -82,7 +83,7 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk
|
||||
|
||||
public async Task<IActionResult> OnPostUpload()
|
||||
{
|
||||
var result = await _application.CreateAndActive(File,SelectedApkType, VersionName, VersionCode, IsForce);
|
||||
var result = await _application.CreateAndActive(File, SelectedApkType, VersionName, VersionCode, IsForce);
|
||||
ViewData["message"] = result.Message;
|
||||
return Page();
|
||||
}
|
||||
@@ -103,50 +104,39 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk
|
||||
|
||||
|
||||
var amount = 10000;
|
||||
var transaction = new PaymentTransaction(30427, amount, "سید حسن مصباح", "https://client.gozareshgir.ir", PaymentTransactionGateWay.SepehrPay);
|
||||
var transaction = new PaymentTransaction(30427, amount, "سید حسن مصباح", "https://client.gozareshgir.ir",
|
||||
PaymentTransactionGateWay.SepehrPay);
|
||||
|
||||
_context.PaymentTransactions.Add(transaction);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
var command = new CreatePaymentGatewayRequest()
|
||||
var command = new CreatePaymentGatewayRequest()
|
||||
{
|
||||
TransactionId = transaction.id.ToString(),
|
||||
Amount = amount,
|
||||
CallBackUrl = callBack
|
||||
};
|
||||
};
|
||||
|
||||
var createRes = await _paymentGateway.Create(command);
|
||||
|
||||
if (createRes.IsSuccess)
|
||||
{
|
||||
transaction.SetTransactionId(createRes.Token);
|
||||
await _context.SaveChangesAsync();
|
||||
transaction.SetTransactionId(createRes.Token);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
var payUrl = _paymentGateway.GetStartPayUrl(createRes.Token);
|
||||
return Redirect(payUrl);
|
||||
var payUrl = _paymentGateway.GetStartPayUrl(createRes.Token);
|
||||
return Redirect(payUrl);
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest(createRes.Status + "خطا در ارسال به درگاه پرداخت");
|
||||
return BadRequest(createRes.Status + "خطا در ارسال به درگاه پرداخت");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public IActionResult OnPostShiftDateNew()
|
||||
public async Task<IActionResult> OnPostShiftDateNew()
|
||||
{
|
||||
var startRollCall = new DateTime(2025, 4, 21);
|
||||
//var employees = _context.CustomizeWorkshopEmployeeSettings
|
||||
// .Where(x => x.WorkshopShiftStatus == WorkshopShiftStatus.Rotating).Select(x => x.EmployeeId).ToList();
|
||||
|
||||
var rollCalls = _context.RollCalls.Where(x => x.ShiftDate >= startRollCall && x.EndDate != null).ToList();
|
||||
var r1 = rollCalls.ToList();
|
||||
|
||||
Console.ForegroundColor = ConsoleColor.DarkRed;
|
||||
Console.WriteLine("endStep 1 ============");
|
||||
SetBreakTime(r1);
|
||||
|
||||
|
||||
await UpdateInstitutionContract();
|
||||
ViewData["message"] = "تومام یک";
|
||||
return Page();
|
||||
}
|
||||
@@ -169,21 +159,22 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk
|
||||
.ThenInclude(x => x.LeftWorks)
|
||||
.Include(x => x.Workshop)
|
||||
.ThenInclude(x => x.WorkshopEmployers)
|
||||
.ThenInclude(x=>x.Employer)
|
||||
.ThenInclude(x => x.Employer)
|
||||
.Select(x => new WorkshopRollCallExcelViewModel()
|
||||
{
|
||||
EmployerName = x.Workshop.WorkshopEmployers.First().Employer.FullName,
|
||||
IsActive = x.IsActiveString == "true",
|
||||
PersonnelCount = x.Workshop.LeftWorks.Count(l => l.StartWorkDate <= now && l.LeftWorkDate >= now),
|
||||
WorkshopName = x.Workshop.WorkshopFullName
|
||||
}).OrderByDescending(x=>x.IsActive).ToList();
|
||||
}).OrderByDescending(x => x.IsActive).ToList();
|
||||
var dataBytes = WorkshopRollCallExcelExporter.Export(data);
|
||||
return File(dataBytes, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
"RollCallServices.xlsx");
|
||||
ViewData["message"] = "تومام دو";
|
||||
return Page();
|
||||
}
|
||||
private async System.Threading.Tasks.Task CreateDadmehrWorkshopFaceEmbedding()
|
||||
|
||||
private async System.Threading.Tasks.Task CreateDadmehrWorkshopFaceEmbedding()
|
||||
{
|
||||
var basePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "faces");
|
||||
|
||||
@@ -264,7 +255,7 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public async Task<IActionResult> OnPostPaymentGateWay(CancellationToken cancellationToken)
|
||||
{
|
||||
var command = new CreatePaymentGatewayRequest()
|
||||
@@ -820,7 +811,10 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk
|
||||
{
|
||||
var today = DateTime.Today;
|
||||
var transaction = await _context.Database.BeginTransactionAsync();
|
||||
|
||||
var query = _context.InstitutionContractSet
|
||||
.Where(a => a.VerifyCode == null
|
||||
&& a.PublicId == Guid.Empty)
|
||||
.Include(x => x.WorkshopGroup)
|
||||
.Join(_context.PersonalContractingParties
|
||||
.Include(x => x.Employers)
|
||||
@@ -830,8 +824,8 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk
|
||||
contract => contract.ContractingPartyId,
|
||||
contractingParty => contractingParty.id,
|
||||
(contract, contractingParty) => new { contract, contractingParty });
|
||||
|
||||
|
||||
|
||||
|
||||
var remoteContractsQuery = query
|
||||
.Where(x => x.contractingParty.Employers
|
||||
.Any(e => e.WorkshopEmployers
|
||||
@@ -854,13 +848,17 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk
|
||||
var personnelCount =
|
||||
w.LeftWorks.Count(lw => lw.StartWorkDate <= today && lw.LeftWorkDate >= today);
|
||||
|
||||
var rollCallService = _context.RollCallServices
|
||||
.Where(x => x.WorkshopId == w.id)
|
||||
.ToList().MaxBy(x => x.StartService);
|
||||
|
||||
var calculation = _clientRegistrationApplication
|
||||
.GetInstitutionPlanForWorkshop(new WorkshopTempViewModel()
|
||||
{
|
||||
CustomizeCheckout = false,
|
||||
Insurance = true,
|
||||
InsuranceInPerson = false,
|
||||
RollCall = true,
|
||||
RollCall = rollCallService != null,
|
||||
WorkshopName = "",
|
||||
ContractAndCheckout = true,
|
||||
ContractAndCheckoutInPerson = false,
|
||||
@@ -915,14 +913,19 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk
|
||||
.SelectMany(e => e.WorkshopEmployers.Select(we => we.Workshop)).ToList()
|
||||
.DistinctBy(x => x.id).ToList();
|
||||
|
||||
|
||||
var initialWorkshop = workshops
|
||||
.Select(w =>
|
||||
{
|
||||
var personnelCount =
|
||||
w.LeftWorks.Count(lw => lw.StartWorkDate <= today && lw.LeftWorkDate >= today);
|
||||
|
||||
bool hasRollCallPlan = true;
|
||||
bool hasRollCallPlanInPerson = false;
|
||||
var rollCallService = _context.RollCallServices
|
||||
.Where(x => x.WorkshopId == w.id)
|
||||
.ToList().MaxBy(x => x.StartService);
|
||||
|
||||
bool hasRollCallPlan = rollCallService != null;
|
||||
bool hasRollCallPlanInPerson = rollCallService != null;
|
||||
bool hasCustomizeCheckoutPlan = w.id == 170;
|
||||
bool hasContractPlan = true;
|
||||
bool hasContractPlanInPerson = true;
|
||||
|
||||
@@ -136,6 +136,9 @@
|
||||
<div class="card-title">قرارداد های مالی</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="countNumber" id="InstitutionContractCount">
|
||||
<span></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="spinner-loading loading" style="display: none;">
|
||||
<span class="spinner-border spinner-border-sm loading text-white" role="status" aria-hidden="true"></span>
|
||||
@@ -192,6 +195,7 @@
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
workFlowStartAndLeftWorkCountMenu();
|
||||
getInstitutionContractCount();
|
||||
|
||||
$('.loadingButton').on('click', function (e) {
|
||||
if (e.ctrlKey || e.metaKey) {
|
||||
@@ -235,5 +239,29 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getInstitutionContractCount() {
|
||||
$.ajax({
|
||||
async: true,
|
||||
dataType: 'json',
|
||||
url: `@Url.Page("./Index", "InstitutionContractCount")`,
|
||||
headers: { "RequestVerificationToken": antiForgeryTokenLayout },
|
||||
type: 'GET',
|
||||
success: function (response) {
|
||||
if (response.success) {
|
||||
if (response.dataInstitutionContractCount === 0) {
|
||||
$('#InstitutionContractCount').hide();
|
||||
} else {
|
||||
$('#InstitutionContractCount').show();
|
||||
var contractCount = response.dataInstitutionContractCount > 99 ? "+99" : response.dataInstitutionContractCount;
|
||||
$('#InstitutionContractCount span').text(contractCount);
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using _0_Framework.Application;
|
||||
using Company.Domain.WorkshopAccountAgg;
|
||||
using CompanyManagment.App.Contracts.InstitutionContract;
|
||||
using CompanyManagment.App.Contracts.RollCallService;
|
||||
using CompanyManagment.App.Contracts.Workshop;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@@ -18,13 +19,15 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.WorkFlow
|
||||
private readonly IAuthHelper _authHelper;
|
||||
private readonly IWorkshopAccountRepository _workshopAccountRepository;
|
||||
public int EmployeeDocumentsAwaitingSubmitCount;
|
||||
private readonly IInstitutionContractApplication _institutionContractApplication;
|
||||
private readonly long _roleId;
|
||||
|
||||
public IndexModel(IAdminWorkFlowApplication adminWorkFlowApplication, IAuthHelper authHelper, IWorkshopAccountRepository workshopAccountRepository)
|
||||
public IndexModel(IAdminWorkFlowApplication adminWorkFlowApplication, IAuthHelper authHelper, IWorkshopAccountRepository workshopAccountRepository, IInstitutionContractApplication institutionContractApplication)
|
||||
{
|
||||
_adminWorkFlowApplication = adminWorkFlowApplication;
|
||||
_authHelper = authHelper;
|
||||
_workshopAccountRepository = workshopAccountRepository;
|
||||
_institutionContractApplication = institutionContractApplication;
|
||||
_roleId = authHelper.CurrentAccountInfo().RoleId;
|
||||
|
||||
}
|
||||
@@ -49,5 +52,27 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.WorkFlow
|
||||
dataLeftWorkCount = resultLeftWorkCount,
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnGetInstitutionContractCount()
|
||||
{
|
||||
try
|
||||
{
|
||||
var institutionContractCount = (await _institutionContractApplication.RegistrationWorkflowMainList()).Count;
|
||||
|
||||
return new JsonResult(new
|
||||
{
|
||||
success = true,
|
||||
dataInstitutionContractCount = institutionContractCount
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new JsonResult(new
|
||||
{
|
||||
success = false,
|
||||
message = ex.Message
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +99,9 @@ namespace ServiceHost.Areas.AdminNew.Pages
|
||||
{
|
||||
var currentAccountId = _authHelper.CurrentAccountId();
|
||||
var accountWorkshops = _workshopAccountRepository.GetList(currentAccountId).Select(x => x.WorkshopId).ToList();
|
||||
int workFlowCount = await _adminWorkFlowApplication.GetWorkFlowCountsForAdmin(accountWorkshops,currentAccountId, _roleId);
|
||||
var permissions = _authHelper.GetPermissions();
|
||||
|
||||
int workFlowCount = await _adminWorkFlowApplication.GetWorkFlowCountsForAdmin(accountWorkshops,currentAccountId, _roleId,permissions);
|
||||
|
||||
|
||||
return new JsonResult(new
|
||||
|
||||
56
ServiceHost/Areas/Client/Controllers/DashboardController.cs
Normal file
56
ServiceHost/Areas/Client/Controllers/DashboardController.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using _0_Framework.Application;
|
||||
using CompanyManagment.App.Contracts.ClientDashboard;
|
||||
using CompanyManagment.App.Contracts.Holiday;
|
||||
using CompanyManagment.App.Contracts.HolidayItem;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using PersianTools.Core;
|
||||
using ServiceHost.BaseControllers;
|
||||
|
||||
namespace ServiceHost.Areas.Client.Controllers;
|
||||
public record ClientDashboardViewModel(List<CalenderViewModel> Calender, int Year,string Month,int Day,string DayOfWeek);
|
||||
|
||||
public class DashboardController:ClientBaseController
|
||||
{
|
||||
private readonly IHolidayItemApplication _holidayItemApplication;
|
||||
|
||||
public DashboardController(IHolidayItemApplication holidayItemApplication)
|
||||
{
|
||||
_holidayItemApplication = holidayItemApplication;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public ActionResult<ClientDashboardViewModel> Index()
|
||||
{
|
||||
var calenderList = new List<CalenderViewModel>();
|
||||
|
||||
var todayGr = DateTime.Today;
|
||||
var todayFa = todayGr.ToFarsi();
|
||||
|
||||
var todayPersian = new PersianDateTime(
|
||||
int.Parse(todayFa.Substring(0, 4)),
|
||||
int.Parse(todayFa.Substring(5, 2)),
|
||||
int.Parse(todayFa.Substring(8, 2))
|
||||
);
|
||||
|
||||
var startDate =new PersianDateTime(todayGr.AddDays(-3));
|
||||
var endDate =new PersianDateTime(todayGr.AddDays(3));
|
||||
|
||||
|
||||
for (var day = startDate; day <= endDate; day = day.AddDays(1))
|
||||
{
|
||||
var calenderNewItem = new CalenderViewModel
|
||||
{
|
||||
DayNumber = day.ToString("dd"),
|
||||
IsToday = day.DateTime == todayGr,
|
||||
DayOfWeek = day.DayOfWeek,
|
||||
Holiday = _holidayItemApplication.IsHoliday(day.ToGregorianDateTime()) || day.DayOfWeek== "جمعه"
|
||||
};
|
||||
calenderList.Add(calenderNewItem);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return new ClientDashboardViewModel(calenderList, todayPersian.Year,todayPersian.MonthOfYear,todayPersian.Day,todayPersian.DayOfWeek);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ public class GeneralController : GeneralBaseController
|
||||
payResponse.cardnumber, payResponse.issuerbank, payResponse.rrn.ToString(),
|
||||
payResponse.digitalreceipt);
|
||||
|
||||
if (financialInvoice.Items?.Any(x => x.Type == FinancialInvoiceItemType.BuyInstitutionContract) ?? false)
|
||||
if (financialInvoice.Items?.Any(x => x.Type is FinancialInvoiceItemType.BuyInstitutionContract or FinancialInvoiceItemType.BuyInstitutionContractInstallment) ?? false)
|
||||
{
|
||||
var financialItems = financialInvoice.Items
|
||||
.Where(x => x.Type == FinancialInvoiceItemType.BuyInstitutionContract);
|
||||
@@ -158,6 +158,16 @@ public class GeneralController : GeneralBaseController
|
||||
{
|
||||
await _institutionContractApplication.SetPendingWorkflow(editFinancialInvoiceItem.EntityId);
|
||||
}
|
||||
var financialInstallmentItems = financialInvoice.Items
|
||||
.Where(x => x.Type == FinancialInvoiceItemType.BuyInstitutionContractInstallment);
|
||||
|
||||
foreach (var editFinancialInvoiceItem in financialInstallmentItems)
|
||||
{
|
||||
var institutionContractId =
|
||||
await _institutionContractApplication.GetIdByInstallmentId(
|
||||
editFinancialInvoiceItem.Id);
|
||||
await _institutionContractApplication.SetPendingWorkflow(institutionContractId);
|
||||
}
|
||||
}
|
||||
|
||||
if (!setSuccessResult.IsSuccedded)
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
"sqlDebugging": true,
|
||||
"dotnetRunMessages": "true",
|
||||
"nativeDebugging": true,
|
||||
"applicationUrl": "https://localhost:5004;http://localhost:5003;",
|
||||
"applicationUrl": "https://localhost:5004;http://localhost:5003;https://192.168.0.117:5005",
|
||||
"jsWebView2Debugging": false,
|
||||
"hotReloadEnabled": true
|
||||
},
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
|
||||
//local
|
||||
"MesbahDb": "Data Source=.;Initial Catalog=mesbah_db;Integrated Security=True;TrustServerCertificate=true;",
|
||||
|
||||
//server
|
||||
//"MesbahDb": "Data Source=185.208.175.186;Initial Catalog=mesbah_db;Persist Security Info=False;User ID=ir_db;Password=R2rNp[170]18[3019]#@ATt;TrustServerCertificate=true;",
|
||||
|
||||
//dad-mehr
|
||||
//"MesbahDb": "Data Source=.;Initial Catalog=teamWork;Integrated Security=True;TrustServerCertificate=true;",
|
||||
|
||||
@@ -67,7 +67,7 @@ public interface IAdminWorkFlowApplication
|
||||
#endregion
|
||||
|
||||
Task<int> GetEmployeeDocumentWorkFlowCountsForAdmin(List<long> workshopIds, long roleId);
|
||||
Task<int> GetWorkFlowCountsForAdmin(List<long> workshopIds, long accountId, long roleId);
|
||||
Task<int> GetWorkFlowCountsForAdmin(List<long> workshopIds, long accountId, long roleId, List<int> permissions);
|
||||
Task<int> GetWorkFlowCountForChecker();
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ public interface IAdminWorkFlowApplication
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
Task<int> GetInstitutionContractWorkflowCount();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -3,6 +3,7 @@ using CompanyManagment.App.Contracts.Employee;
|
||||
using WorkFlow.Application.Contracts.AdminWorkFlow;
|
||||
using WorkFlow.Infrastructure.ACL.Employee;
|
||||
using WorkFlow.Infrastructure.ACL.EmployeeDocuments;
|
||||
using WorkFlow.Infrastructure.ACL.InstitutionContract;
|
||||
using WorkFlow.Infrastructure.ACL.Workshop;
|
||||
|
||||
namespace WorkFlow.Application
|
||||
@@ -12,65 +13,76 @@ namespace WorkFlow.Application
|
||||
private readonly IWorkFlowEmployeeDocumentsACL _workFlowEmployeeDocumentsACL;
|
||||
private readonly IWorkFlowWorkshopACL _workFlowWorkshopACL;
|
||||
private readonly IWorkFlowEmployeeACL _workFlowEmployeeACL;
|
||||
private readonly IWorkFlowInstitutionContractACL _workFlowInstitutionContractACL;
|
||||
|
||||
|
||||
public AdminWorkFlowApplication(IWorkFlowEmployeeDocumentsACL workFlowEmployeeDocumentsACL, IWorkFlowWorkshopACL workFlowWorkshopACL, IWorkFlowEmployeeACL workFlowEmployeeACL)
|
||||
public AdminWorkFlowApplication(IWorkFlowEmployeeDocumentsACL workFlowEmployeeDocumentsACL,
|
||||
IWorkFlowWorkshopACL workFlowWorkshopACL, IWorkFlowEmployeeACL workFlowEmployeeACL,
|
||||
IWorkFlowInstitutionContractACL workFlowInstitutionContractACL)
|
||||
{
|
||||
_workFlowEmployeeDocumentsACL = workFlowEmployeeDocumentsACL;
|
||||
_workFlowWorkshopACL = workFlowWorkshopACL;
|
||||
_workFlowEmployeeACL = workFlowEmployeeACL;
|
||||
_workFlowInstitutionContractACL = workFlowInstitutionContractACL;
|
||||
}
|
||||
|
||||
#region Pooya
|
||||
|
||||
public List<WorkshopWithDocumentsViewModelForWorkFlow> GetWorkshopDocumentsAwaitingReviewForChecker(List<long> workshops)
|
||||
public List<WorkshopWithDocumentsViewModelForWorkFlow> GetWorkshopDocumentsAwaitingReviewForChecker(
|
||||
List<long> workshops)
|
||||
{
|
||||
return _workFlowEmployeeDocumentsACL.GetWorkshopDocumentsAwaitingReviewForChecker(workshops);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<int> GetEmployeeDocumentWorkFlowCountsForAdmin(List<long> workshopIds,long roleId)
|
||||
public async Task<int> GetEmployeeDocumentWorkFlowCountsForAdmin(List<long> workshopIds, long roleId)
|
||||
{
|
||||
var count = 0;
|
||||
count += await _workFlowEmployeeDocumentsACL.GetWorkshopDocumentRejectedForAdmin(workshopIds,roleId);
|
||||
count += await _workFlowEmployeeDocumentsACL.GetWorkshopDocumentRejectedForAdmin(workshopIds, roleId);
|
||||
|
||||
count+= await _workFlowEmployeeDocumentsACL.GetCreatedEmployeesWorkshopDocumentForAdmin(workshopIds,roleId);
|
||||
count += await _workFlowEmployeeDocumentsACL.GetCreatedEmployeesWorkshopDocumentForAdmin(workshopIds,
|
||||
roleId);
|
||||
|
||||
//count+= await _workFlowEmployeeDocumentsACL.GetClientRejectedDocumentWorkshopsForAdmin(workshopIds, roleId);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
public async Task<int> GetWorkFlowCountsForAdmin(List<long> workshopIds, long accountId,long roleId)
|
||||
public async Task<int> GetWorkFlowCountsForAdmin(List<long> workshopIds, long accountId, long roleId,
|
||||
List<int> permissions)
|
||||
{
|
||||
var employeeDocumentWorkFlowCounts = await GetEmployeeDocumentWorkFlowCountsForAdmin(workshopIds, roleId);
|
||||
var startWork = await GetWorkshopsForEmployeeStartWorkCount(accountId);
|
||||
var leftWork = await GetWorkshopsForLeftWorkTempCount(accountId);
|
||||
int institutionContract = 0;
|
||||
if (permissions.Any(x => x == 1004))
|
||||
{
|
||||
institutionContract = await GetInstitutionContractWorkflowCount();
|
||||
}
|
||||
|
||||
return employeeDocumentWorkFlowCounts + startWork + leftWork;
|
||||
return employeeDocumentWorkFlowCounts + startWork + leftWork +institutionContract;
|
||||
}
|
||||
|
||||
public async Task<int> GetWorkFlowCountForChecker()
|
||||
{
|
||||
return await _workFlowEmployeeDocumentsACL.GetCheckerWorkFlowCount();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<WorkshopWithDocumentsViewModelForWorkFlow> GetWorkshopsWithDocumentsAwaitingUploadForAdmin(List<long> workshops)
|
||||
public List<WorkshopWithDocumentsViewModelForWorkFlow> GetWorkshopsWithDocumentsAwaitingUploadForAdmin(
|
||||
List<long> workshops)
|
||||
{
|
||||
return _workFlowEmployeeDocumentsACL.GetWorkshopsWithDocumentsAwaitingUploadForAdmin(workshops);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Mahan
|
||||
|
||||
#region شروع به کار پرسنل افزوده شده
|
||||
public async Task<ICollection<WorkshopWithStartedWorkWorkFlowViewModel>> GetWorkshopsForEmployeeStartWork(long accountId)
|
||||
|
||||
public async Task<ICollection<WorkshopWithStartedWorkWorkFlowViewModel>> GetWorkshopsForEmployeeStartWork(
|
||||
long accountId)
|
||||
{
|
||||
return await _workFlowWorkshopACL.GetWorkshopsForEmployeeStartWork(accountId);
|
||||
}
|
||||
@@ -81,14 +93,14 @@ namespace WorkFlow.Application
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public async Task<ICollection<ClientStartedWorkEmployeesWorkFlowViewModel>> GetClientEmployeesStartWork(long workshopId)
|
||||
public async Task<ICollection<ClientStartedWorkEmployeesWorkFlowViewModel>> GetClientEmployeesStartWork(
|
||||
long workshopId)
|
||||
{
|
||||
return await _workFlowEmployeeACL.GetClientEmployeesStartWork(workshopId);
|
||||
}
|
||||
|
||||
public async Task<GetEditEmployeeInEmployeeDocumentViewModel> GetEmployeeEditInEmployeeDocumentWorkFlow(long employeeId, long workshopId)
|
||||
public async Task<GetEditEmployeeInEmployeeDocumentViewModel> GetEmployeeEditInEmployeeDocumentWorkFlow(
|
||||
long employeeId, long workshopId)
|
||||
{
|
||||
return await _workFlowEmployeeACL.GetEmployeeEditInEmployeeDocumentWorkFlow(employeeId, workshopId);
|
||||
}
|
||||
@@ -103,16 +115,24 @@ namespace WorkFlow.Application
|
||||
|
||||
#region ترک کار موقت
|
||||
|
||||
public async Task<ICollection<WorkshopWithLeftWorkWorkFlowViewModel>> GetWorkshopsForLeftWorkTemp(long accountId)
|
||||
public async Task<ICollection<WorkshopWithLeftWorkWorkFlowViewModel>> GetWorkshopsForLeftWorkTemp(
|
||||
long accountId)
|
||||
{
|
||||
return await _workFlowWorkshopACL.GetWorkshopsForLeftWorkTemp(accountId);
|
||||
}
|
||||
|
||||
public async Task<int> GetWorkshopsForLeftWorkTempCount(long accountId)
|
||||
{
|
||||
return await _workFlowWorkshopACL.GetWorkshopsForLeftWorkTempCount(accountId);
|
||||
}
|
||||
|
||||
public async Task<ICollection<ClientLeftWorkEmployeesWorkFlowViewModel>> GetEmployeesForLeftWorkTemp(long workshopId)
|
||||
public async Task<int> GetInstitutionContractWorkflowCount()
|
||||
{
|
||||
return await _workFlowInstitutionContractACL.GetInstitutionContractWorkflowCount();
|
||||
}
|
||||
|
||||
public async Task<ICollection<ClientLeftWorkEmployeesWorkFlowViewModel>> GetEmployeesForLeftWorkTemp(
|
||||
long workshopId)
|
||||
{
|
||||
return await _workFlowEmployeeACL.GetEmployeesForLeftWorkTemp(workshopId);
|
||||
}
|
||||
@@ -121,7 +141,8 @@ namespace WorkFlow.Application
|
||||
|
||||
#region آپلود مدارک پرسنل
|
||||
|
||||
public async Task<ICollection<WorkshopWithDocumentsViewModelForWorkFlow>> GetWorkshopDocumentCreatedEmployeeForAdmin(List<long> workshops, long roleId)
|
||||
public async Task<ICollection<WorkshopWithDocumentsViewModelForWorkFlow>>
|
||||
GetWorkshopDocumentCreatedEmployeeForAdmin(List<long> workshops, long roleId)
|
||||
{
|
||||
return await _workFlowEmployeeDocumentsACL.GetWorkshopDocumentCreatedEmployeeForAdmin(workshops, roleId);
|
||||
}
|
||||
@@ -130,6 +151,4 @@ namespace WorkFlow.Application
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -58,4 +58,5 @@ public class WorkFlowEmployeeACL : IWorkFlowEmployeeACL
|
||||
{
|
||||
return await _employeeApplication.EditEmployeeInEmployeeDocumentWorkFlow(command);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using CompanyManagment.App.Contracts.InstitutionContract;
|
||||
|
||||
namespace WorkFlow.Infrastructure.ACL.InstitutionContract;
|
||||
|
||||
public interface IWorkFlowInstitutionContractACL
|
||||
{
|
||||
Task<int> GetInstitutionContractWorkflowCount();
|
||||
}
|
||||
|
||||
public class WorkFlowInstitutionContractACL : IWorkFlowInstitutionContractACL
|
||||
{
|
||||
private readonly IInstitutionContractApplication _institutionContractApplication;
|
||||
public WorkFlowInstitutionContractACL(IInstitutionContractApplication institutionContractApplication)
|
||||
{
|
||||
_institutionContractApplication = institutionContractApplication;
|
||||
}
|
||||
|
||||
public async Task<int> GetInstitutionContractWorkflowCount()
|
||||
{
|
||||
var list = await _institutionContractApplication.RegistrationWorkflowMainList();
|
||||
return list.Count;
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ using WorkFlow.Infrastructure.ACL.Checkout;
|
||||
using WorkFlow.Infrastructure.ACL.CustomizedWorkshopSettings;
|
||||
using WorkFlow.Infrastructure.ACL.Employee;
|
||||
using WorkFlow.Infrastructure.ACL.EmployeeDocuments;
|
||||
using WorkFlow.Infrastructure.ACL.InstitutionContract;
|
||||
using WorkFlow.Infrastructure.ACL.RollCall;
|
||||
using WorkFlow.Infrastructure.ACL.Workshop;
|
||||
using WorkFlow.Infrastructure.EfCore;
|
||||
@@ -33,8 +34,7 @@ namespace WorkFlow.Infrastructure.Config
|
||||
services.AddTransient<IWorkFlowRollCallACL, WorkFlowRollCallACL>();
|
||||
services.AddTransient<IWorkFlowCustomizedWorkshopSettingsACL, WorkFlowCustomizedWorkshopSettingsACL>();
|
||||
services.AddTransient<IWorkFlowEmployeeACL, WorkFlowEmployeeACL>();
|
||||
|
||||
|
||||
services.AddTransient<IWorkFlowInstitutionContractACL, WorkFlowInstitutionContractACL>();
|
||||
services.AddTransient<IWorkFlowWorkshopACL, WorkFlowWorkshopACL>();
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user