Merge branch 'Feature/InstitutionContract/set-discount' into Main

This commit is contained in:
2025-11-29 14:57:25 +03:30
8 changed files with 11436 additions and 33 deletions

View File

@@ -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,int discountPercentage, double discountAmount)
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;

View File

@@ -102,7 +102,7 @@ public class CreateInstitutionContractRequest
public double OneMonthAmount { get; set; }
public long LawId { get; set; }
public int DiscountPercentage { get; set; }
public double DiscountAmount { get; set; }

View File

@@ -271,7 +271,7 @@ public interface IInstitutionContractApplication
public class InstitutionContractResetDiscountForCreateRequest
{
public int Percentage { get; set; }
public double PaymentAmount { get; set; }
public double TotalAmount { get; set; }
public bool IsInstallment { get; set; }
public InstitutionContractDuration Duration { get; set; }
}
@@ -298,7 +298,7 @@ public class InstitutionContractSetDiscountForExtensionRequest
{
public Guid TempId { get; set; }
public int DiscountPercentage { get; set; }
public double PaymentAmount { get; set; }
public double TotalAmount { get; set; }
public bool IsInstallment { get; set; }
}
public class InstitutionContractResetDiscountForExtensionRequest
@@ -311,7 +311,7 @@ public class InstitutionContractResetDiscountForExtensionRequest
public class InstitutionContractSetDiscountRequest
{
public int DiscountPercentage { get; set; }
public double PaymentAmount { get; set; }
public double TotalAmount { get; set; }
public InstitutionContractDuration Duration { get; set; }
public bool IsInstallment { get; set; }
}

File diff suppressed because it is too large Load Diff

View File

@@ -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");
}
}
}

View File

@@ -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)");

View File

@@ -1875,11 +1875,11 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
public InstitutionContractExtensionPaymentResponse CalculateDiscount(InstitutionContractSetDiscountRequest request)
{
var baseAmount = request.PaymentAmount;
var baseAmount = request.TotalAmount;
var discountAmount = (baseAmount * request.DiscountPercentage) / 100;
var paymentAmount = baseAmount - discountAmount;
var taxAmount = paymentAmount * 0.10;
var totalAmount = paymentAmount + taxAmount;
var totalAmount = baseAmount - discountAmount;
var taxAmount = totalAmount * 0.10;
var paymentAmount = totalAmount + taxAmount;
InstitutionContractPaymentMonthlyViewModel monthlyPayment = null;
InstitutionContractPaymentOneTimeViewModel oneTimePayment = null;
@@ -1926,30 +1926,30 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
if (request.IsInstallment)
{
var newPaymentAmount = request.PaymentAmount / (1 - (request.Percentage / 100));
var taxAmount = (newPaymentAmount * 0.10);
var paymentAmount = (newPaymentAmount + taxAmount);
var newTotalAmount = request.TotalAmount / (1 - (request.Percentage / 100));
var taxAmount = (newTotalAmount * 0.10);
var paymentAmount = (newTotalAmount + taxAmount);
monthlyPayment = new InstitutionContractPaymentMonthlyViewModel()
{
PaymentAmount = newPaymentAmount.ToMoney(),
TotalAmount = newTotalAmount.ToMoney(),
Tax = taxAmount.ToMoney(),
DiscountedAmount = "0",
DiscountPercetage = 0,
TotalAmount =paymentAmount.ToMoney(),
PaymentAmount = paymentAmount.ToMoney(),
Installments = InstitutionMonthlyInstallmentCaculation((int)request.Duration,
paymentAmount, DateTime.Now.ToFarsi())
};
}
else
{
var newPaymentAmount = request.PaymentAmount / (1 - (request.Percentage / 100));
var taxAmount = (newPaymentAmount * 0.10);
var paymentAmount = (newPaymentAmount + taxAmount);
var newTotalAmount = request.TotalAmount / (1 - (request.Percentage / 100));
var taxAmount = (newTotalAmount * 0.10);
var paymentAmount = (newTotalAmount + taxAmount);
oneTimePayment = new InstitutionContractPaymentOneTimeViewModel()
{
PaymentAmount = newPaymentAmount.ToMoney(),
TotalAmount = newTotalAmount.ToMoney(),
Tax = taxAmount.ToMoney(),
TotalAmount = paymentAmount.ToMoney(),
PaymentAmount = paymentAmount.ToMoney(),
DiscountedAmount = "0",
DiscountPercetage = 0
};
@@ -2295,7 +2295,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
var calculateRequest = new InstitutionContractSetDiscountRequest()
{
Duration = institutionTemp.Duration.Value,
PaymentAmount = request.PaymentAmount,
TotalAmount = request.TotalAmount,
DiscountPercentage = request.DiscountPercentage,
IsInstallment = request.IsInstallment
};
@@ -2336,18 +2336,19 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
if (request.IsInstallment)
{
var prevMonthlyPayment = institutionTemp.MonthlyPayment;
var resetPaymentAmount = prevMonthlyPayment.PaymentAmount.MoneyToDouble() / (1 - (prevMonthlyPayment.DiscountPercetage / 100.0));
var resetTax = (resetPaymentAmount * 0.10);
var totalAmount = (resetPaymentAmount + resetTax);
var resetTotalAmount = prevMonthlyPayment.TotalAmount.MoneyToDouble() /
(1 - (prevMonthlyPayment.DiscountPercetage / 100.0));
var resetTax = (resetTotalAmount * 0.10);
var paymentAmount = (resetTotalAmount + resetTax);
monthlyPayment = new InstitutionContractPaymentMonthlyViewModel()
{
DiscountPercetage = 0,
DiscountedAmount = "0",
PaymentAmount = resetPaymentAmount.ToMoney(),
PaymentAmount = paymentAmount.ToMoney(),
Tax = resetTax.ToMoney(),
TotalAmount = totalAmount.ToMoney(),
TotalAmount = resetTotalAmount.ToMoney(),
Installments = InstitutionMonthlyInstallmentCaculation((int)institutionTemp.Duration.Value,
totalAmount, DateTime.Now.ToFarsi()),
paymentAmount, DateTime.Now.ToFarsi()),
};
institutionTemp.MonthlyPayment = monthlyPayment;
await _institutionExtensionTemp.ReplaceOneAsync(x=>x.Id == institutionTemp.Id,
@@ -2357,16 +2358,16 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
else
{
var prevOneTimePayment = institutionTemp.OneTimePayment;
var resetPaymentAmount = prevOneTimePayment.PaymentAmount.MoneyToDouble() /
(1 - (prevOneTimePayment.DiscountPercetage / 100.0));
var resetTax = (resetPaymentAmount * 0.10);
var resetTotalAmount = prevOneTimePayment.TotalAmount.MoneyToDouble() /
(1 - (prevOneTimePayment.DiscountPercetage / 100.0));
var resetTax = (resetTotalAmount * 0.10);
oneTimePayment = new InstitutionContractPaymentOneTimeViewModel()
{
DiscountPercetage = 0,
DiscountedAmount = "0",
PaymentAmount = resetPaymentAmount.ToMoney(),
TotalAmount = resetTotalAmount.ToMoney(),
Tax = resetTax.ToMoney(),
TotalAmount = (resetPaymentAmount + resetTax).ToMoney(),
PaymentAmount = (resetTotalAmount + resetTax).ToMoney(),
};
institutionTemp.OneTimePayment = oneTimePayment;
await _institutionExtensionTemp.ReplaceOneAsync(x=>x.Id == institutionTemp.Id,
@@ -3301,7 +3302,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
{
OneTime = new()
{
TotalAmount = selectedPlan.TotalPayment,
TotalAmount = oneTimeBase.ToMoney(),
Tax = oneTimeTax.ToMoney(),
PaymentAmount = oneTimeTotal.ToMoney()
}

View File

@@ -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
},