feat: enhance institution plan calculator with in-person contract handling and tax calculations
This commit is contained in:
@@ -68,11 +68,12 @@ public interface ITemporaryClientRegistrationApplication
|
||||
/// </summary>
|
||||
/// <param name="totalPaymentMonth"></param>
|
||||
/// <param name="duration"></param>
|
||||
/// <param name="hasInPersonContract"></param>
|
||||
/// <param name="contractingPartyTempId"></param>
|
||||
/// <param name="paymentModel"></param>
|
||||
/// <returns></returns>
|
||||
Task<ReviewAndPaymentViewModel> GetTotalPaymentAndWorkshopList( double totalPaymentMonth,
|
||||
InstitutionContractDuration duration = InstitutionContractDuration.TwelveMonths);
|
||||
Task<ReviewAndPaymentViewModel> GetTotalPaymentAndWorkshopList(double totalPaymentMonth,
|
||||
InstitutionContractDuration duration , bool hasInPersonContract);
|
||||
|
||||
/// <summary>
|
||||
/// ایجاد یا ویرایش قرارداد موقت
|
||||
|
||||
@@ -13,13 +13,10 @@ public class ReviewAndPaymentViewModel
|
||||
/// </summary>
|
||||
public string Discount { get; set; }
|
||||
|
||||
public string SumOfWorkshopsPayment { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// مبلغ پرداخت بدون مالیات
|
||||
/// Double
|
||||
/// مقدار جمع مبلغ کارگاه ها
|
||||
/// </summary>
|
||||
public double OneTimeWithoutTaxPaymentDouble { get; set; }
|
||||
public string SumOfWorkshopsPayment { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// مبلغ پرداخت بدون مالیات
|
||||
@@ -27,65 +24,30 @@ public class ReviewAndPaymentViewModel
|
||||
/// </summary>
|
||||
public string OneTimeWithoutTaxPaymentStr { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// مبلغ پرداخت کامل
|
||||
/// Double
|
||||
/// </summary>
|
||||
public double OneTimeTotalPaymentDouble { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// مبلغ پرداخت کامل
|
||||
/// string
|
||||
/// </summary>
|
||||
public string OneTimeTotalPaymentStr { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// مبلغ پرداخت بدون مالیات
|
||||
/// Double
|
||||
/// </summary>
|
||||
public double MonthlyWithoutTaxPaymentDouble { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// مبلغ پرداخت بدون مالیات
|
||||
/// مبلغ پرداخت بدون مالیات ماهانه
|
||||
/// string
|
||||
/// </summary>
|
||||
public string MonthlyWithoutTaxPaymentStr { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// مبلغ پرداخت کامل
|
||||
/// Double
|
||||
/// </summary>
|
||||
public double MonthlyTotalPaymentDouble { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// مبلغ پرداخت کامل
|
||||
/// string
|
||||
/// مبلغ پرداخت کامل ماهانه
|
||||
/// string
|
||||
/// </summary>
|
||||
public string MonthlyTotalPaymentStr { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// مالیات بر ارزش افزوده
|
||||
/// Double
|
||||
/// </summary>
|
||||
public double ValueAddedTaxDouble { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// مالیات بر ارزش افزوده
|
||||
/// string
|
||||
/// </summary>
|
||||
public string ValueAddedTaxStr { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// بازه قرداد
|
||||
/// با عدد مشخص میشود
|
||||
/// مثلا یک ماه عدد 1
|
||||
/// </summary>
|
||||
public InstitutionContractDuration Duration { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// لیست اقساط ماهیانه
|
||||
/// </summary>
|
||||
|
||||
@@ -363,7 +363,6 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// بررسی و پرداخت
|
||||
/// اطلاعات کامل مبالغ
|
||||
@@ -371,7 +370,8 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati
|
||||
/// <param name="contractingPartyTempId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<ReviewAndPaymentViewModel> GetTotalPaymentAndWorkshopList(long contractingPartyTempId,
|
||||
InstitutionContractDuration duration = InstitutionContractDuration.TwelveMonths, string paymentModel = "OneTime", string contractStartType = "currentMonth")
|
||||
InstitutionContractDuration duration = InstitutionContractDuration.TwelveMonths,
|
||||
string paymentModel = "OneTime", string contractStartType = "currentMonth")
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
// //دریافت کارگاه ها
|
||||
@@ -514,10 +514,10 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati
|
||||
//
|
||||
// return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public async Task<ReviewAndPaymentViewModel> GetTotalPaymentAndWorkshopList(double totalPaymentMonth,
|
||||
InstitutionContractDuration duration = InstitutionContractDuration.TwelveMonths)
|
||||
InstitutionContractDuration duration, bool hasInPersonContract)
|
||||
{
|
||||
//دریافت کارگاه ها
|
||||
|
||||
@@ -543,81 +543,85 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati
|
||||
//بدست آوردن جمع کل مبالغ کارگاه بر اساس مدت قراداد
|
||||
var sumOfWorkshopsPaymentDouble = months * roundAmount2;
|
||||
result.SumOfWorkshopsPayment = sumOfWorkshopsPaymentDouble.ToMoney();
|
||||
|
||||
|
||||
result.Duration = duration;
|
||||
|
||||
|
||||
var tenPercent = sumOfWorkshopsPaymentDouble * 10 / 100;
|
||||
//مالیات
|
||||
result.ValueAddedTaxDouble = tenPercent;
|
||||
result.ValueAddedTaxStr = tenPercent.ToMoney();
|
||||
//پرداخت یکجا
|
||||
|
||||
#region OneTimePaymentResult
|
||||
|
||||
double discountOneTimePeyment = sumOfWorkshopsPaymentDouble - tenPercent;
|
||||
|
||||
|
||||
//مبلغ بدون مالیات و با تخفیف
|
||||
result.OneTimeWithoutTaxPaymentDouble = discountOneTimePeyment;
|
||||
result.OneTimeWithoutTaxPaymentStr = discountOneTimePeyment.ToMoney();
|
||||
|
||||
//مبلغ با مالیات
|
||||
result.OneTimeTotalPaymentDouble = discountOneTimePeyment + tenPercent;
|
||||
result.OneTimeTotalPaymentStr = result.OneTimeTotalPaymentDouble.ToMoney();
|
||||
|
||||
#endregion
|
||||
|
||||
//پرداخت ماهیانه
|
||||
|
||||
#region MonthlyPaymentResult
|
||||
|
||||
//مبلغ بدون مالیات
|
||||
result.MonthlyWithoutTaxPaymentDouble = sumOfWorkshopsPaymentDouble;
|
||||
result.MonthlyWithoutTaxPaymentStr = sumOfWorkshopsPaymentDouble.ToMoney();
|
||||
|
||||
// مبلغ با مالیات
|
||||
result.MonthlyTotalPaymentDouble = sumOfWorkshopsPaymentDouble + tenPercent;
|
||||
result.MonthlyTotalPaymentStr = result.MonthlyTotalPaymentDouble.ToMoney();
|
||||
var installmentList = new List<MonthlyInstallment>();
|
||||
|
||||
var installmentstart = (DateTime.Now).ToFarsi();
|
||||
installmentstart = "1404/02/30";
|
||||
result.ContractStartFa = installmentstart;
|
||||
result.ContractStartGr = result.ContractStartFa.ToGeorgianDateTime();
|
||||
|
||||
var findeEnd = Tools.FindEndOfContract(installmentstart, ((int)duration).ToString());
|
||||
var contractEndDate = findeEnd.endDateGr;
|
||||
result.ContractEndGr = contractEndDate;
|
||||
result.ContractEndFa = contractEndDate.ToFarsi();
|
||||
|
||||
if (duration == InstitutionContractDuration.OneMonth)
|
||||
{
|
||||
installmentList.Add(new MonthlyInstallment()
|
||||
{
|
||||
InstallmentAmountStr = result.MonthlyTotalPaymentStr,
|
||||
InstallmentCounter = "سررسید پرداخت اول",
|
||||
InstalmentDate = (DateTime.Now).ToFarsi()
|
||||
});
|
||||
result.MonthlyInstallments = installmentList;
|
||||
}
|
||||
else
|
||||
|
||||
if (hasInPersonContract)
|
||||
{
|
||||
var tenPercent = sumOfWorkshopsPaymentDouble * 10 / 100;
|
||||
//مالیات
|
||||
result.ValueAddedTaxStr = tenPercent.ToMoney();
|
||||
//پرداخت یکجا
|
||||
|
||||
#region OneTimePaymentResult
|
||||
|
||||
double discountOneTimePeyment = sumOfWorkshopsPaymentDouble - tenPercent;
|
||||
|
||||
result.Discount = tenPercent.ToMoney();
|
||||
|
||||
//مبلغ بدون مالیات و با تخفیف
|
||||
result.OneTimeWithoutTaxPaymentStr = discountOneTimePeyment.ToMoney();
|
||||
|
||||
//مبلغ با مالیات
|
||||
var oneTimePayment = discountOneTimePeyment + tenPercent;
|
||||
result.OneTimeTotalPaymentStr = oneTimePayment.ToMoney();
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
//پرداخت ماهیانه
|
||||
|
||||
#region MonthlyPaymentResult
|
||||
|
||||
//مبلغ بدون مالیات
|
||||
|
||||
result.MonthlyWithoutTaxPaymentStr = sumOfWorkshopsPaymentDouble.ToMoney();
|
||||
|
||||
// مبلغ با مالیات
|
||||
var monthlyTotalPaymentDouble = sumOfWorkshopsPaymentDouble + tenPercent;
|
||||
result.MonthlyTotalPaymentStr = monthlyTotalPaymentDouble.ToMoney();
|
||||
var installmentList = new List<MonthlyInstallment>();
|
||||
|
||||
var installmentstart = (DateTime.Now).ToFarsi();
|
||||
installmentstart = "1404/06/30";
|
||||
|
||||
result.ContractStartFa = installmentstart;
|
||||
result.ContractStartGr = result.ContractStartFa.ToGeorgianDateTime();
|
||||
|
||||
var findeEnd = Tools.FindEndOfContract(installmentstart, ((int)duration).ToString());
|
||||
var contractEndDate = findeEnd.endDateGr;
|
||||
result.ContractEndGr = contractEndDate;
|
||||
result.ContractEndFa = contractEndDate.ToFarsi();
|
||||
|
||||
int instalmentCount = (int)duration;
|
||||
var instalmentAmount = result.MonthlyTotalPaymentDouble / instalmentCount;
|
||||
var findEndOfMonth = installmentstart.FindeEndOfMonth();
|
||||
int currentInstallmentStartday = int.Parse(installmentstart.Substring(8, 2));
|
||||
var instalmentAmount = monthlyTotalPaymentDouble / instalmentCount;
|
||||
int currentInstallmentStartDay = int.Parse(installmentstart.Substring(8, 2));
|
||||
bool endOfMonth = currentInstallmentStartDay == 31;
|
||||
|
||||
// Loop through each installment period
|
||||
for (int i = 1; i <= instalmentCount; i++)
|
||||
{
|
||||
// Adjust the day for months with fewer days
|
||||
int endDayOfMonth = int.Parse(findEndOfMonth.Substring(8, 2));
|
||||
if (currentInstallmentStartday > endDayOfMonth)
|
||||
string installmentDate;
|
||||
// For first installment, use the initial date
|
||||
if (i == 1)
|
||||
{
|
||||
installmentstart = installmentstart.Substring(0, 8) + endDayOfMonth.ToString("D2");
|
||||
installmentDate = installmentstart;
|
||||
}
|
||||
else
|
||||
{
|
||||
var currentDay = int.Parse(installmentstart.Substring(8, 2));
|
||||
var currentMonth = int.Parse(installmentstart.Substring(5, 2));
|
||||
var currentYear = int.Parse(installmentstart.Substring(0, 4));
|
||||
|
||||
// Get next month's date
|
||||
var nextMonthFa = installmentstart.ToGeorgianDateTime().AddMonthsFa(1, out var nextMonth);
|
||||
var maxDayInNextMonth = int.Parse(nextMonthFa.FindeEndOfMonth().Substring(8, 2));
|
||||
|
||||
// Use original day if possible, otherwise use last day of month
|
||||
var dayToUse = Math.Min(int.Parse(installmentstart.Substring(8, 2)), maxDayInNextMonth);
|
||||
installmentDate = nextMonthFa.Substring(0, 8) + dayToUse.ToString("D2");
|
||||
|
||||
// Update installmentstart for next iteration
|
||||
installmentstart = installmentDate;
|
||||
}
|
||||
|
||||
|
||||
installmentList.Add(new MonthlyInstallment()
|
||||
{
|
||||
@@ -638,16 +642,33 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati
|
||||
12 => "سررسید پرداخت دوازدهم",
|
||||
_ => "سررسید پرداخت دوازدهم",
|
||||
},
|
||||
InstalmentDate = installmentstart
|
||||
InstalmentDate = installmentDate
|
||||
});
|
||||
installmentstart = installmentstart.ToGeorgianDateTime().AddMonthsFa(1,out _).Substring(0,8) + installmentstart.Substring(8,2);
|
||||
findEndOfMonth = installmentstart.FindeEndOfMonth();
|
||||
}
|
||||
#endregion
|
||||
|
||||
result.MonthlyInstallments = installmentList;
|
||||
}
|
||||
else
|
||||
{
|
||||
var discount = duration switch
|
||||
{
|
||||
InstitutionContractDuration.OneMonth => 0,
|
||||
InstitutionContractDuration.ThreeMonths => 5,
|
||||
InstitutionContractDuration.SixMonths => 10,
|
||||
InstitutionContractDuration.TwelveMonths => 15,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(duration), duration, null)
|
||||
};
|
||||
|
||||
var discountAmount = (sumOfWorkshopsPaymentDouble * discount) / 100;
|
||||
var discountedPayment = sumOfWorkshopsPaymentDouble - discountAmount;
|
||||
result.Discount = discountAmount.ToMoney();
|
||||
var taxDouble = (discountedPayment * 10)/100;
|
||||
result.ValueAddedTaxStr =taxDouble.ToMoney();
|
||||
result.OneTimeWithoutTaxPaymentStr = discountedPayment.ToMoney();
|
||||
result.OneTimeTotalPaymentStr =( discountedPayment + taxDouble).ToMoney();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
result.MonthlyInstallments = installmentList;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -609,7 +609,7 @@ public class institutionContractController : AdminBaseController
|
||||
public async Task<ActionResult<InstitutionPlanCalculatorResponse>> InstitutionPlanCalculator(
|
||||
[FromBody] InstitutionPlanCalculatorRequest request)
|
||||
{
|
||||
var res = await _temporaryClientRegistration.GetTotalPaymentAndWorkshopList(request.TotalAmountMonth,duration: request.Duration);
|
||||
var res = await _temporaryClientRegistration.GetTotalPaymentAndWorkshopList(request.TotalAmountMonth,duration: request.Duration,request.HasInPersonContract);
|
||||
var response = new InstitutionPlanCalculatorResponse
|
||||
{
|
||||
Installments = res.MonthlyInstallments,
|
||||
@@ -621,7 +621,8 @@ public class institutionContractController : AdminBaseController
|
||||
ContractStart = res.ContractStartFa,
|
||||
ContractEnd = res.ContractEndFa,
|
||||
Discount = res.Discount??"0",
|
||||
|
||||
ValueAddedTax = res.ValueAddedTaxStr,
|
||||
TotalAmountWithTax = res.OneTimeTotalPaymentStr
|
||||
};
|
||||
return response;
|
||||
}
|
||||
@@ -679,6 +680,7 @@ public class InstitutionPlanCalculatorResponse
|
||||
public string ContractStart { get; set; }
|
||||
public string ContractEnd { get; set; }
|
||||
public string Discount { get; set; }
|
||||
public string ValueAddedTax { get; set; }
|
||||
}
|
||||
|
||||
public class WorkshopServiceCalculatorResponse
|
||||
@@ -686,7 +688,7 @@ public class WorkshopServiceCalculatorResponse
|
||||
public string TotalAmount { get; set; }
|
||||
}
|
||||
|
||||
public record InstitutionPlanCalculatorRequest(double TotalAmountMonth,
|
||||
public record InstitutionPlanCalculatorRequest(double TotalAmountMonth,bool HasInPersonContract,
|
||||
InstitutionContractDuration Duration = InstitutionContractDuration.TwelveMonths);
|
||||
|
||||
public class CreateInquiryRequest
|
||||
|
||||
Reference in New Issue
Block a user