Merge branch 'Feature/InstitutionContract/upgrade' into Main

# Conflicts:
#	Company.Domain/InstitutionContractAgg/IInstitutionContractRepository.cs
#	Company.Domain/InstitutionContractAgg/InstitutionContract.cs
This commit is contained in:
2025-10-21 11:10:06 +03:30
10 changed files with 523 additions and 57 deletions

View File

@@ -65,11 +65,13 @@ public interface IInstitutionContractRepository : IRepository<long, InstitutionC
#endregion
#region Upgrade(Amendment)
#region Upgrade(Amendment)
Task<InstitutionContractAmendmentWorkshopsResponse> GetAmendmentWorkshops(long institutionContractId);
Task<InsitutionContractAmendmentPaymentResponse> GetAmendmentPaymentDetails(InsitutionContractAmendmentPaymentRequest request);
Task<InsertAmendmentTempWorkshopResponse> InsertAmendmentTempWorkshops(InstitutionContractAmendmentTempWorkshopViewModel request);
Task RemoveAmendmentWorkshops(Guid workshopTempId);
#endregion
Task<List<InstitutionContractSelectListViewModel>> GetInstitutionContractSelectList(string search, string selected);

View File

@@ -0,0 +1,147 @@
using System;
using System.Collections.Generic;
using System.Linq;
using MongoDB.Bson.Serialization.Attributes;
namespace Company.Domain.InstitutionContractAmendmentTempAgg;
public class InstitutionContractAmendmentTemp
{
public InstitutionContractAmendmentTemp(List<InstitutionContractAmendmentTempPrevWorkshop> prevWorkshops,
long institutionContractId)
{
Id = Guid.NewGuid();
PrevWorkshops = prevWorkshops;
NewWorkshops = prevWorkshops.Select(x=> new InstitutionContractAmendmentTempNewWorkshop(
x.WorkshopName, x.CountPerson, x.ContractAndCheckout, x.ContractAndCheckoutInPerson, x.Insurance,
x.InsuranceInPerson, x.RollCall, x.RollCallInPerson, x.CustomizeCheckout, x.Price, x.WorkshopId,
x.CurrentWorkshopId, 0)).ToList();
InstitutionContractId = institutionContractId;
}
[BsonId] public Guid Id { get; private set; }
public List<InstitutionContractAmendmentTempPrevWorkshop> PrevWorkshops { get; private set; }
public List<InstitutionContractAmendmentTempNewWorkshop> NewWorkshops { get; private set; }
public long InstitutionContractId { get; private set; }
}
public class InstitutionContractAmendmentTempNewWorkshop : InstitutionContractAmendmentTempPrevWorkshop
{
public InstitutionContractAmendmentTempNewWorkshop(string workshopName, int countPerson, bool contractAndCheckout,
bool contractAndCheckoutInPerson, bool insurance, bool insuranceInPerson, bool rollCall, bool rollCallInPerson,
bool customizeCheckout, double price, long workshopId, long currentWorkshopId,double priceDifference) : base(
workshopName, countPerson, contractAndCheckout, contractAndCheckoutInPerson, insurance, insuranceInPerson,
rollCall, rollCallInPerson, customizeCheckout, price, workshopId, currentWorkshopId)
{
PriceDifference = priceDifference;
}
/// <summary>
/// مبلغ اختلاف کارگاه جدید با کارگاه قبلی(مبلغ اصلی ارتقاء)
/// </summary>
public double PriceDifference { get; private set; }
public void Edit(string workshopName, int countPerson, bool contractAndCheckout,
bool contractAndCheckoutInPerson,
bool insurance, bool insuranceInPerson, bool rollCall, bool customizeCheckout,
double price,double priceDifference)
{
base.Edit(workshopName, countPerson, contractAndCheckout, contractAndCheckoutInPerson, insurance,
insuranceInPerson, rollCall, customizeCheckout, price);
PriceDifference = priceDifference;
}
}
public class InstitutionContractAmendmentTempPrevWorkshop
{
public InstitutionContractAmendmentTempPrevWorkshop(string workshopName, int countPerson, bool contractAndCheckout,
bool contractAndCheckoutInPerson,
bool insurance, bool insuranceInPerson,
bool rollCall, bool rollCallInPerson, bool customizeCheckout, double price, long workshopId,
long currentWorkshopId)
{
Id = Guid.NewGuid();
WorkshopName = workshopName;
CountPerson = countPerson;
ContractAndCheckout = contractAndCheckout;
Insurance = insurance;
RollCall = rollCall;
CustomizeCheckout = customizeCheckout;
ContractAndCheckoutInPerson = contractAndCheckoutInPerson;
InsuranceInPerson = insuranceInPerson;
RollCallInPerson = rollCallInPerson;
Price = price;
WorkshopId = workshopId;
CurrentWorkshopId = currentWorkshopId;
}
public Guid Id { get; set; }
public long CurrentWorkshopId { get; private set; }
public long WorkshopId { get; set; }
/// <summary>
/// نام کارگاه
/// </summary>
public string WorkshopName { get; private set; }
/// <summary>
/// تعداد پرسنل
/// </summary>
public int CountPerson { get; private set; }
#region ServiceSelection
/// <summary>
/// قرارداد و تصفیه
/// </summary>
public bool ContractAndCheckout { get; private set; }
/// <summary>
/// بیمه
/// </summary>
public bool Insurance { get; private set; }
/// <summary>
/// حضورغباب
/// </summary>
public bool RollCall { get; private set; }
public bool RollCallInPerson { get; set; }
/// <summary>
/// فیش غیر رسمی
/// </summary>
public bool CustomizeCheckout { get; private set; }
/// <summary>
/// خدمات حضوری قرداد و تصفیه
/// </summary>
public bool ContractAndCheckoutInPerson { get; private set; }
/// <summary>
/// خدمات حضوری بیمه
/// </summary>
public bool InsuranceInPerson { get; private set; }
public double Price { get; private set; }
#endregion
public void Edit(string workshopName, int countPerson, bool contractAndCheckout, bool contractAndCheckoutInPerson,
bool insurance, bool insuranceInPerson, bool rollCall, bool customizeCheckout,
double price)
{
WorkshopName = workshopName;
CountPerson = countPerson;
ContractAndCheckout = contractAndCheckout;
Insurance = insurance;
RollCall = rollCall;
CustomizeCheckout = customizeCheckout;
ContractAndCheckoutInPerson = contractAndCheckoutInPerson;
InsuranceInPerson = insuranceInPerson;
Price = price;
}
}

View File

@@ -234,26 +234,17 @@ public interface IInstitutionContractApplication
#region Upgrade (Amendment)
Task<InstitutionContractAmendmentWorkshopsResponse> GetAmendmentWorkshops(long institutionContractId);
Task<InsertAmendmentTempWorkshopResponse> InsertAmendmentTempWorkshops(InstitutionContractAmendmentTempWorkshopViewModel request);
Task RemoveAmendmentWorkshops(Guid workshopTempId);
Task<InsitutionContractAmendmentPaymentResponse> GetAmendmentPaymentDetails(InsitutionContractAmendmentPaymentRequest request);
#endregion
}
public class InsitutionContractAmendmentPaymentRequest
public class InsertAmendmentTempWorkshopResponse
{
List<WorkshopTempViewModel> Workshops { get; set; }
public long InstitutionContractId { get; set; }
}
public class InsitutionContractAmendmentPaymentResponse
{
public InstitutionContractPaymentOneTimeViewModel OneTime { get; set; }
public InstitutionContractPaymentMonthlyViewModel Monthly { get; set; }
public string ContractStart { get; set; }
public string ContractEnd { get; set; }
public string OneMonthAmount { get; set; }
public string TotalAmount { get; set; }
public Guid WorkshopTempId { get; set; }
public string Amount { get; set; }
}
public class InstitutionContractAmendmentWorkshopsResponse
@@ -261,7 +252,9 @@ public class InstitutionContractAmendmentWorkshopsResponse
/// <summary>
///
/// </summary>
public List<WorkshopTempViewModel> Workshops { get; set; }
public List<InstitutionContractAmendmentTempWorkshopViewModel> Workshops { get; set; }
public Guid TempId { get; set; }
}

View File

@@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;
using CompanyManagment.App.Contracts.TemporaryClientRegistration;
namespace CompanyManagment.App.Contracts.InstitutionContract;
public class InsitutionContractAmendmentPaymentRequest
{
public Guid TempId { get; set; }
}

View File

@@ -0,0 +1,11 @@
namespace CompanyManagment.App.Contracts.InstitutionContract;
public class InsitutionContractAmendmentPaymentResponse
{
public InstitutionContractPaymentOneTimeViewModel OneTime { get; set; }
public InstitutionContractPaymentMonthlyViewModel Monthly { get; set; }
public string ContractStart { get; set; }
public string ContractEnd { get; set; }
public string OneMonthAmount { get; set; }
public string TotalAmount { get; set; }
}

View File

@@ -0,0 +1,64 @@
using System;
namespace CompanyManagment.App.Contracts.InstitutionContract;
public class InstitutionContractAmendmentTempWorkshopViewModel
{
public Guid TempId { get; set; }
public Guid WorkshopTempId { get; set; }
public long CurrentWorkshopId { get; set; }
public long WorkshopId { get; set; }
/// <summary>
/// نام کارگاه
/// </summary>
public string WorkshopName { get; set; }
/// <summary>
/// تعداد پرسنل
/// </summary>
public int CountPerson { get; set; }
#region ServiceSelection
/// <summary>
/// قرارداد و تصفیه
/// </summary>
public bool ContractAndCheckout { get; set; }
/// <summary>
/// بیمه
/// </summary>
public bool Insurance { get; set; }
/// <summary>
/// حضورغباب
/// </summary>
public bool RollCall { get; set; }
public bool RollCallInPerson { get; set; }
/// <summary>
/// فیش غیر رسمی
/// </summary>
public bool CustomizeCheckout { get; set; }
/// <summary>
/// خدمات حضوری قرداد و تصفیه
/// </summary>
public bool ContractAndCheckoutInPerson { get; set; }
/// <summary>
/// خدمات حضوری بیمه
/// </summary>
public bool InsuranceInPerson { get; set; }
public double Price{ get; set; }
public string PriceStr{ get; set; }
#endregion
}

View File

@@ -1340,6 +1340,16 @@ public class InstitutionContractApplication : IInstitutionContractApplication
return await _institutionContractRepository.GetAmendmentWorkshops(institutionContractId);
}
public async Task<InsertAmendmentTempWorkshopResponse> InsertAmendmentTempWorkshops(InstitutionContractAmendmentTempWorkshopViewModel request)
{
return await _institutionContractRepository.InsertAmendmentTempWorkshops(request);
}
public Task RemoveAmendmentWorkshops(Guid workshopTempId)
{
return _institutionContractRepository.RemoveAmendmentWorkshops(workshopTempId);
}
public Task<InsitutionContractAmendmentPaymentResponse> GetAmendmentPaymentDetails(InsitutionContractAmendmentPaymentRequest request)
{
return _institutionContractRepository.GetAmendmentPaymentDetails(request);
@@ -1440,7 +1450,7 @@ public class InstitutionContractApplication : IInstitutionContractApplication
return operation.Succcedded(personalContractingParty);
}
private List<InstitutionContractInstallment> CalculateInstallment(double amount, int installmentCount,
public static List<InstitutionContractInstallment> CalculateInstallment(double amount, int installmentCount,
string loanStartDate, bool getRounded)
{
int day = Convert.ToInt32(loanStartDate.Substring(8, 2));

View File

@@ -674,7 +674,7 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati
result.MonthlyValueAddedTaxStr= tenPercent.ToMoney();
var monthlyTotalPaymentDouble = sumOfWorkshopsPaymentDouble + tenPercent;
result.MonthlyTotalPaymentStr = monthlyTotalPaymentDouble.ToMoney();
var installmentList = InstitutionContractRepository.InstitutionMonthlyInstallmentCaculation(duration, monthlyTotalPaymentDouble, installmentstart);
var installmentList = InstitutionContractRepository.InstitutionMonthlyInstallmentCaculation((int)duration, monthlyTotalPaymentDouble, installmentstart);
#endregion

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;
using _0_Framework.Application;
@@ -16,6 +17,7 @@ using Company.Domain.empolyerAgg;
using Company.Domain.FinancialStatmentAgg;
using Company.Domain.FinancialTransactionAgg;
using Company.Domain.InstitutionContractAgg;
using Company.Domain.InstitutionContractAmendmentTempAgg;
using Company.Domain.InstitutionContractContactInfoAgg;
using Company.Domain.InstitutionContractExtensionTempAgg;
using Company.Domain.InstitutionPlanAgg;
@@ -42,6 +44,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
private readonly IEmployerRepository _employerRepository;
private readonly IWorkshopRepository _workshopRepository;
private readonly IMongoCollection<InstitutionContractExtensionTemp> _institutionExtensionTemp;
private readonly IMongoCollection<InstitutionContractAmendmentTemp> _institutionAmendmentTemp;
private readonly IPlanPercentageRepository _planPercentageRepository;
private readonly ISmsService _smsService;
@@ -56,6 +59,8 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
_smsService = smsService;
_institutionExtensionTemp =
database.GetCollection<InstitutionContractExtensionTemp>("InstitutionContractExtensionTemp");
_institutionAmendmentTemp =
database.GetCollection<InstitutionContractAmendmentTemp>("InstitutionContractAmendmentTemp");
}
public EditInstitutionContract GetDetails(long id)
@@ -2239,7 +2244,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
extensionNo, workshopsCount, employeeCount,
previousInstitutionContract.Description,
"NotOfficial", "JobRelation", hasValueAddedTax,
payment.Tax.MoneyToDouble(),[],
payment.Tax.MoneyToDouble(), [],
request.LawId);
await CreateAsync(entity);
@@ -2249,26 +2254,25 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
var workshopDetail = new InstitutionContractWorkshopInitial(
workshop.WorkshopName, workshop.RollCall, workshop.RollCallInPerson,
workshop.CustomizeCheckout, workshop.ContractAndCheckout,
workshop.ContractAndCheckoutInPerson, workshop.Insurance,
workshop.ContractAndCheckoutInPerson, workshop.Insurance,
workshop.InsuranceInPerson, workshop.CountPerson, workshop.Price);
workshopDetail.SetWorkshopGroup(entity.WorkshopGroup);
if (workshop.WorkshopId != 0)
{
workshopDetail.SetWorkshopId(workshop.WorkshopId);
}
// Set parent reference
// Add to the parent's collection
entity.WorkshopGroup.InitialWorkshops.Add(workshopDetail);
}
// Save the changes again
await SaveChangesAsync();
FinancialStatment financialStatement;
if (_context.FinancialStatments.Any(x => x.ContractingPartyId == contractingParty.id))
{
@@ -2346,46 +2350,251 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
.Include(x => x.WorkshopGroup)
.ThenInclude(x => x.CurrentWorkshops)
.FirstOrDefaultAsync(x => x.id == institutionContractId);
var workshops = institutionContract.WorkshopGroup.CurrentWorkshops.Select(x => new WorkshopTempViewModel()
if (institutionContract.WorkshopGroup.CurrentWorkshops.Any(x => x.Price == 0))
{
Id = x.id,
ContractAndCheckout = x.Services.Contract,
ContractAndCheckoutInPerson = x.Services.ContractInPerson,
CustomizeCheckout = x.Services.CustomizeCheckout,
CountPerson = x.PersonnelCount,
Insurance = x.Services.Insurance,
InsuranceInPerson = x.Services.InsuranceInPerson,
RollCall = x.Services.RollCall,
WorkshopName = x.WorkshopName,
WorkshopServicesAmountStr = x.Price.ToMoney(),
WorkshopServicesAmount = x.Price,
WorkshopId = x.WorkshopId ?? 0,
RollCallInPerson = x.Services.RollCallInPerson,
throw new BadRequestException(
"این قرارداد قابل ارتقا به صورت ظاهری نیست لطفا به صورت دیتابیسی اقدام به ویرایش کنید");
}
}).ToList();
var workshops = institutionContract.WorkshopGroup.CurrentWorkshops
.Select(x => new InstitutionContractAmendmentTempPrevWorkshop(x.WorkshopName,x.PersonnelCount,
x.Services.Contract,x.Services.ContractInPerson,x.Services.Insurance,
x.Services.InsuranceInPerson,x.Services.RollCall,x.Services.RollCallInPerson,
x.Services.CustomizeCheckout,x.Price,
x.WorkshopId??0,x.id)).ToList();
var temp = new InstitutionContractAmendmentTemp(workshops, institutionContractId);
await _institutionAmendmentTemp.InsertOneAsync(temp);
var prevWorkshops = workshops.Select(x =>
new InstitutionContractAmendmentTempWorkshopViewModel()
{
WorkshopName = x.WorkshopName,
CountPerson = x.CountPerson,
ContractAndCheckout = x.ContractAndCheckout,
ContractAndCheckoutInPerson = x.ContractAndCheckoutInPerson,
Insurance = x.Insurance,
InsuranceInPerson = x.InsuranceInPerson,
RollCall = x.RollCall,
RollCallInPerson = x.RollCallInPerson,
CustomizeCheckout = x.CustomizeCheckout,
PriceStr = x.Price.ToMoney(),
Price = x.Price,
WorkshopId = x.WorkshopId,
WorkshopTempId = x.Id,
CurrentWorkshopId = x.CurrentWorkshopId,
TempId =temp.Id
})
.ToList();
var res = new InstitutionContractAmendmentWorkshopsResponse()
{
Workshops = workshops
Workshops = prevWorkshops,
TempId = temp.Id
};
return res;
}
public async Task<InsitutionContractAmendmentPaymentResponse> GetAmendmentPaymentDetails(InsitutionContractAmendmentPaymentRequest request)
public async Task<InsitutionContractAmendmentPaymentResponse> GetAmendmentPaymentDetails(
InsitutionContractAmendmentPaymentRequest request)
{
var institutionContract =await _context.InstitutionContractSet
.Include(x => x.WorkshopGroup)
.ThenInclude(x => x.CurrentWorkshops)
.FirstOrDefaultAsync(x => x.id == request.InstitutionContractId);
if (institutionContract == null)
throw new NotFoundException("قرارداد مالی یافت نشد");
var institutionContractAmendmentTemp = await _institutionAmendmentTemp
.Find(x=>x.Id == request.TempId)
.FirstOrDefaultAsync();
if (institutionContractAmendmentTemp == null)
throw new NotFoundException("دیتای وارد شده نامعتبر است");
var amendmentStart = DateTime.Now;
var amendmentEnd = institutionContract.ContractEndGr;
//TODO : محاسبه مبلغ بر اساس کارگاه های انتخاب شده
var res = new InsitutionContractAmendmentPaymentResponse();
return res;
var institutionContract = await _context.InstitutionContractSet
.Include(x=>x.WorkshopGroup)
.ThenInclude(x=>x.CurrentWorkshops)
.FirstOrDefaultAsync(x => x.id == institutionContractAmendmentTemp.InstitutionContractId);
if (institutionContract == null)
throw new NotFoundException("قرارداد مؤسسه یافت نشد");
var amendmentEnd = institutionContract.ContractEndGr;
var haContractInPerson = institutionContract.WorkshopGroup.CurrentWorkshops
.Any(x => x.Services.ContractInPerson);
if (!haContractInPerson)
{
if (institutionContractAmendmentTemp.NewWorkshops.Any(x => x.ContractAndCheckoutInPerson))
{
throw new BadRequestException("برای قرارداد آنلاین نمیتوان سرویس حضوری انتخاب کرد");
}
}
var pc = new PersianCalendar();
int startYear = pc.GetYear(amendmentStart);
int startMonth = pc.GetMonth(amendmentStart);
int startDay = pc.GetDayOfMonth(amendmentStart);
int endYear = pc.GetYear(amendmentEnd);
int endMonth = pc.GetMonth(amendmentEnd);
int endDay = pc.GetDayOfMonth(amendmentEnd);
// اختلاف خام ماه‌ها
int monthDiff = (endYear - startYear) * 12 + (endMonth - startMonth);
// اگر حتی چند روز از ماه بعدی هم گذشته بود → رند به بالا
if (endDay > startDay)
monthDiff++;
var sumOneMonth = institutionContractAmendmentTemp.NewWorkshops.Sum(x => x.PriceDifference);
var baseAmount = monthDiff * sumOneMonth;
var tax = baseAmount*0.10;
var totalPayment = tax+baseAmount;
var res = new InsitutionContractAmendmentPaymentResponse()
{
ContractStart = amendmentStart.ToFarsi(),
ContractEnd = amendmentEnd.ToFarsi(),
OneMonthAmount = sumOneMonth.ToMoney(),
TotalAmount = baseAmount.ToMoney(),
};
res.OneTime = new InstitutionContractPaymentOneTimeViewModel()
{
TotalAmount = baseAmount.ToMoney(),
PaymentAmount = totalPayment.ToMoney(),
Tax = tax.ToMoney()
};
if (haContractInPerson)
{
var installment = InstitutionMonthlyInstallmentCaculation(monthDiff,totalPayment, amendmentStart.ToFarsi());
var firstPrevInstallment = installment.First();
var lastPrevInstallment = installment.Last();
var firstInstallment = new MonthlyInstallment()
{
InstallmentAmountStr = firstPrevInstallment.InstallmentAmountStr,
InstallmentCounter = firstPrevInstallment.InstallmentCounter,
InstalmentDate = amendmentStart.ToFarsi()
};
var lastInstallment = new MonthlyInstallment()
{
InstallmentAmountStr = lastPrevInstallment.InstallmentAmountStr,
InstallmentCounter = lastPrevInstallment.InstallmentCounter,
InstalmentDate = lastPrevInstallment.InstalmentDate
};
installment.Remove(firstPrevInstallment);
installment.Remove(lastPrevInstallment);
installment.Insert(0, firstInstallment);
installment.Add(lastInstallment);
res.Monthly = new InstitutionContractPaymentMonthlyViewModel()
{
Installments = installment,
TotalAmount = baseAmount.ToMoney(),
PaymentAmount = totalPayment.ToMoney(),
Tax = tax.ToMoney()
};
}
return res;
}
public async Task<InsertAmendmentTempWorkshopResponse> InsertAmendmentTempWorkshops(
InstitutionContractAmendmentTempWorkshopViewModel request)
{
var amendmentTemp =await _institutionAmendmentTemp
.Find(x=> x.Id == request.TempId).FirstOrDefaultAsync();
if (amendmentTemp == null)
throw new BadRequestException("دیتای وارد شده نامعتبر است");
var workshopTemp = amendmentTemp.NewWorkshops
.FirstOrDefault(x => x.Id == request.WorkshopTempId);
var planForWorkshop = new WorkshopTempViewModel()
{
WorkshopName = request.WorkshopName,
CountPerson = request.CountPerson,
ContractAndCheckout = request.ContractAndCheckout,
ContractAndCheckoutInPerson = request.ContractAndCheckoutInPerson,
Insurance = request.Insurance,
InsuranceInPerson = request.InsuranceInPerson,
RollCall = request.RollCall,
RollCallInPerson = request.RollCallInPerson,
CustomizeCheckout = request.CustomizeCheckout
};
var price = _planPercentageRepository.GetInstitutionPlanForWorkshop(planForWorkshop)
.OnlineAndInPersonSumAmountDouble;
if (workshopTemp == null)
{
var newWorkshopTemp = new InstitutionContractAmendmentTempNewWorkshop(request.WorkshopName,
request.CountPerson,
request.ContractAndCheckout, request.ContractAndCheckoutInPerson,
request.Insurance, request.InsuranceInPerson,
request.RollCall, request.RollCallInPerson,
request.CustomizeCheckout, price,
request.WorkshopId,0,price);
workshopTemp = newWorkshopTemp;
amendmentTemp.NewWorkshops.Add(newWorkshopTemp);
await _institutionAmendmentTemp
.ReplaceOneAsync(x => x.Id == amendmentTemp.Id, amendmentTemp);
}
else
{
amendmentTemp.NewWorkshops.Remove(workshopTemp);
var differencePrice = price - workshopTemp.Price;
workshopTemp.Edit(request.WorkshopName, request.CountPerson,
request.ContractAndCheckout, request.ContractAndCheckoutInPerson,
request.Insurance, request.InsuranceInPerson,
request.RollCall,
request.CustomizeCheckout, price,differencePrice);
amendmentTemp.NewWorkshops.Add(workshopTemp);
await _institutionAmendmentTemp
.ReplaceOneAsync(x => x.Id == amendmentTemp.Id, amendmentTemp);
}
return new InsertAmendmentTempWorkshopResponse()
{
WorkshopTempId = workshopTemp.Id,
Amount = workshopTemp.PriceDifference.ToMoney()
};
}
public async Task RemoveAmendmentWorkshops(Guid workshopTempId)
{
var amendmentTemp = await _institutionAmendmentTemp.Find(x => x.NewWorkshops.Any(w => w.Id == workshopTempId))
.FirstOrDefaultAsync();
if (amendmentTemp == null)
throw new BadRequestException("دیتای وارد شده نامعتبر است");
var workshopTemp = amendmentTemp.NewWorkshops.FirstOrDefault(x => x.Id == workshopTempId);
if (workshopTemp == null)
throw new BadRequestException("دیتای وارد شده نامعتبر است");
if (workshopTemp.CurrentWorkshopId!=0)
throw new BadRequestException("شما نمی توانید این کارگاه را حذف کنید زیرا در قرارداد اصلی وجود دارد");
amendmentTemp.NewWorkshops.Remove(workshopTemp);
await _institutionAmendmentTemp.ReplaceOneAsync(x => x.Id == amendmentTemp.Id, amendmentTemp);
}
public async Task<List<InstitutionContractSelectListViewModel>> GetInstitutionContractSelectList(string search,
string selected)
@@ -2464,7 +2673,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
// حالت پرداخت اقساطی
var monthlyTax = baseAmount * 0.10;
var monthlyTotal = baseAmount + monthlyTax;
var installments = InstitutionMonthlyInstallmentCaculation(duration, monthlyTotal, selectedPlan.ContractStart);
var installments = InstitutionMonthlyInstallmentCaculation((int)duration, monthlyTotal, selectedPlan.ContractStart);
res.Monthly = new()
{
@@ -2546,7 +2755,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
return result;
}
public static List<MonthlyInstallment> InstitutionMonthlyInstallmentCaculation(InstitutionContractDuration duration,
public static List<MonthlyInstallment> InstitutionMonthlyInstallmentCaculation(int duration,
double monthlyTotalPaymentDouble,
string installmentstart)
{
@@ -2554,7 +2763,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
var installmentList = new List<MonthlyInstallment>();
int instalmentCount = (int)duration;
int instalmentCount = duration;
var instalmentAmount = monthlyTotalPaymentDouble / instalmentCount;
int currentInstallmentStartDay = int.Parse(installmentstart.Substring(8, 2));
bool endOfMonth = currentInstallmentStartDay == 31;
@@ -2614,6 +2823,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
#endregion
#region CustomViewModels

View File

@@ -527,6 +527,25 @@ public class institutionContractController : AdminBaseController
var res =await _institutionContractApplication.GetAmendmentWorkshops(institutionContractId);
return res;
}
[HttpPost("amendment/insert-temp-workshops")]
public async Task<ActionResult<InsertAmendmentTempWorkshopResponse>> InsertAmendmentTempWorkshops([FromBody]InstitutionContractAmendmentTempWorkshopViewModel request)
{
var res =await _institutionContractApplication.InsertAmendmentTempWorkshops(request);
return res;
}
[HttpDelete("amendment/remove-temp-workshops/{workshopTempId:guid}")]
public async Task<ActionResult> RemoveAmendmentWorkshops(Guid workshopTempId)
{
await _institutionContractApplication.RemoveAmendmentWorkshops(workshopTempId);
return Ok();
}
[HttpPost("amendment/payment-details")]
public async Task<ActionResult<InsitutionContractAmendmentPaymentResponse>> GetAmendmentPaymentDetails([FromBody]InsitutionContractAmendmentPaymentRequest request)
{
var res =await _institutionContractApplication.GetAmendmentPaymentDetails(request);
return res;
}
}