Compare commits

...

18 Commits

Author SHA1 Message Date
87d47fa0d9 feat: remove temporary institution amendment record after saving changes 2025-11-06 12:53:00 +03:30
c7d4481a6d Merge branch 'master' into Feature/InstitutionContract/upgrade
# Conflicts:
#	0_Framework/Application/Sms/ISmsService.cs
#	CompanyManagment.EFCore/Services/SmsService.cs
2025-11-06 12:38:57 +03:30
4b52d144e0 feat: add LawId column to InstitutionContractAmendments migration 2025-11-06 11:57:17 +03:30
90a1683047 feat: add WorkshopName property to institution contract amendment payment workshop response 2025-11-05 18:55:00 +03:30
d078feccf9 feat: sort institution contract responses by price in descending order 2025-11-02 11:28:29 +03:30
c6a7e0a0bd feat: add workshop response handling to institution contract amendment payment response 2025-10-29 15:08:14 +03:30
fcf2b38457 feat: add previous ID handling and price difference validation to institution contract amendment workshops 2025-10-28 13:13:55 +03:30
7b71bd36b1 feat: add verification status and amendment tracking to institution contract models 2025-10-27 15:22:45 +03:30
62900a22a1 feat: add amendment verification details retrieval methods and update related classes 2025-10-27 11:30:56 +03:30
e6977b29fc feat: add methods for creating institution contract amendment changes and enhance personnel count handling 2025-10-26 14:00:03 +03:30
6e902011ca feat: enhance institution contract verification process and update SMS service methods 2025-10-26 12:21:14 +03:30
7cce903f6e Merge branch 'Feature/InstitutionContract/print-api' into Feature/InstitutionContract/upgrade
# Conflicts:
#	Company.Domain/InstitutionContractAgg/IInstitutionContractRepository.cs
#	CompanyManagment.App.Contracts/InstitutionContract/IInstitutionContractApplication.cs
#	CompanyManagment.Application/InstitutionContractApplication.cs
#	CompanyManagment.EFCore/Repository/InstitutionContractRepository.cs
2025-10-26 12:03:39 +03:30
4d6077c93d Merge branch 'refs/heads/master' into Feature/InstitutionContract/upgrade 2025-10-26 11:50:48 +03:30
c36e81e263 feat: update InstitutionContractRepository to enhance workshop change tracking and improve data handling 2025-10-25 15:23:48 +03:30
818d88d859 feat: update InstitutionContractAmendmentChange to include roll call options and current workshop ID 2025-10-23 16:32:45 +03:30
1a70569a36 feat: implement amendment completion functionality with payment details 2025-10-23 11:44:12 +03:30
8d24339f04 Merge branch 'master' into Feature/InstitutionContract/upgrade
# Conflicts:
#	ServiceHost/Areas/Admin/Controllers/institutionContractController.cs
2025-10-23 09:29:05 +03:30
bea858d4e7 feat: add AmendmentComplete method and request class to InstitutionContractApplication 2025-10-22 13:33:30 +03:30
25 changed files with 44958 additions and 34 deletions

View File

@@ -28,6 +28,7 @@ public interface ISmsService
Task<double> GetCreditAmount();
public Task<bool> SendInstitutionCreationVerificationLink(string number, string fullName, Guid institutionId, long contractingPartyId, long institutionContractId);
public Task<bool> SendInstitutionAmendmentVerificationLink(string number, string fullName, Guid institutionId, long contractingPartyId, long institutionContractId);
public Task<bool> SendInstitutionVerificationCode(string number, string code, string contractingPartyFullName,
long contractingPartyId, long institutionContractId);

View File

@@ -6,7 +6,6 @@ using _0_Framework.Application;
using _0_Framework.Domain;
using CompanyManagment.App.Contracts.InstitutionContract;
using CompanyManagment.App.Contracts.Workshop;
using Microsoft.AspNetCore.Mvc;
namespace Company.Domain.InstitutionContractAgg;
@@ -77,4 +76,6 @@ public interface IInstitutionContractRepository : IRepository<long, InstitutionC
Task<List<InstitutionContractSelectListViewModel>> GetInstitutionContractSelectList(string search, string selected);
Task<List<InstitutionContractPrintViewModel>> PrintAllAsync(List<long> ids);
Task AmendmentComplete(InstitutionContractAmendmentCompleteRequest request);
Task<GetInstitutionAmendmentVerificationDetailsViewModel> GetAmendmentVerificationDetails(Guid id, long amendmentId);
}

View File

@@ -252,6 +252,11 @@ public class InstitutionContract : EntityBase
{
WorkshopGroup = null;
}
public void AddAmendment(InstitutionContractAmendment amendment)
{
Amendments.Add(amendment);
}
}
public class InstitutionContractAmendment : EntityBase
@@ -259,14 +264,15 @@ public class InstitutionContractAmendment : EntityBase
private InstitutionContractAmendment(){}
public InstitutionContractAmendment(long institutionContractId,
List<InstitutionContractInstallment> installments, double amount, bool hasInstallment,
InstitutionContractAmendmentChange amendmentChange, long lawId)
List<InstitutionContractAmendmentChange> amendmentChanges, long lawId)
{
InstitutionContractId = institutionContractId;
Installments = installments is { Count: > 0} ? installments : [];
Amount = amount;
HasInstallment = hasInstallment;
AmendmentChanges = [amendmentChange];
AmendmentChanges = amendmentChanges;
LawId = lawId;
VerificationStatus = InstitutionContractVerificationStatus.PendingForVerify;
}
public long InstitutionContractId { get; set; }
@@ -280,6 +286,15 @@ public class InstitutionContractAmendment : EntityBase
public long LawId { get; set; }
public string VerifierPhoneNumber { get; private set; }
public string VerifierFullName { get; private set; }
public InstitutionContractVerificationStatus VerificationStatus { get; set; }
public DateTime VerifyCodeCreation { get; set; }
public void SetVerifyCode(string code,string verifierFullName, string verifierPhoneNumber)
{
VerifyCode = code;
@@ -287,25 +302,22 @@ public class InstitutionContractAmendment : EntityBase
VerifierFullName = verifierFullName;
VerifierPhoneNumber = verifierPhoneNumber;
}
public string VerifierPhoneNumber { get; private set; }
public string VerifierFullName { get; private set; }
public DateTime VerifyCodeCreation { get; set; }
public void Verified()
{
VerificationStatus = InstitutionContractVerificationStatus.Verified;
}
}
public class InstitutionContractAmendmentChange : EntityBase
{
private InstitutionContractAmendmentChange() { }
private InstitutionContractAmendmentChange(long institutionContractAmendmentId,
InstitutionContractAmendment institutionContractAmendment, InstitutionContractAmendmentChangeType changeType,
DateTime changeDateGr, bool? hasRollCallPlan, bool? hasCustomizeCheckoutPlan, bool? hasContractPlan,
private InstitutionContractAmendmentChange(InstitutionContractAmendmentChangeType changeType,
DateTime changeDateGr, bool? hasCustomizeCheckoutPlan, bool? hasContractPlan,
bool? hasContractPlanInPerson, bool? hasInsurancePlan, bool? hasInsurancePlanInPerson, int? personnelCount,
long? workshopDetailsId)
bool? hasRollCallPlan, bool? hasRollCallInPerson,
long? currentWorkshopId, int personnelCountDifference)
{
InstitutionContractAmendmentId = institutionContractAmendmentId;
InstitutionContractAmendment = institutionContractAmendment;
ChangeType = changeType;
ChangeDateGr = changeDateGr;
HasRollCallPlan = hasRollCallPlan;
@@ -315,9 +327,80 @@ public class InstitutionContractAmendmentChange : EntityBase
HasInsurancePlan = hasInsurancePlan;
HasInsurancePlanInPerson = hasInsurancePlanInPerson;
PersonnelCount = personnelCount;
WorkshopDetailsId = workshopDetailsId;
PersonnelCountDifference = personnelCountDifference;
CurrentWorkshopId = currentWorkshopId;
HasRollCallInPerson = hasRollCallInPerson;
}
/// <summary>
/// تغییر تعداد پرسنل
/// </summary>
public static InstitutionContractAmendmentChange CreatePersonCountChange(
DateTime changeDateGr, int personnelCount, int personnelCountDifference,
long currentWorkshopId)
{
return new InstitutionContractAmendmentChange(
changeType: InstitutionContractAmendmentChangeType.PersonCount,
changeDateGr: changeDateGr,
hasCustomizeCheckoutPlan: null,
hasContractPlan: null,
hasContractPlanInPerson: null,
hasInsurancePlan: null,
hasInsurancePlanInPerson: null,
personnelCount: personnelCount,
hasRollCallPlan: null,
hasRollCallInPerson: null,
currentWorkshopId: currentWorkshopId,
personnelCountDifference: personnelCountDifference);
}
/// <summary>
/// تغییر خدمات
/// </summary>
public static InstitutionContractAmendmentChange CreateServicesChange(
DateTime changeDateGr, long currentWorkshopId, bool hasRollCallPlan, bool hasRollCallInPerson,
bool hasCustomizeCheckoutPlan, bool hasContractPlan, bool hasContractPlanInPerson,
bool hasInsurancePlan, bool hasInsurancePlanInPerson)
{
return new InstitutionContractAmendmentChange(
changeType: InstitutionContractAmendmentChangeType.Services,
changeDateGr: changeDateGr,
hasCustomizeCheckoutPlan: hasCustomizeCheckoutPlan,
hasContractPlan: hasContractPlan,
hasContractPlanInPerson: hasContractPlanInPerson,
hasInsurancePlan: hasInsurancePlan,
hasInsurancePlanInPerson: hasInsurancePlanInPerson,
personnelCount: null,
hasRollCallPlan: hasRollCallPlan,
hasRollCallInPerson: hasRollCallInPerson,
currentWorkshopId: currentWorkshopId,
personnelCountDifference: 0);
}
/// <summary>
/// ایجاد کارگاه جدید
/// </summary>
public static InstitutionContractAmendmentChange CreateWorkshopCreatedChange(
DateTime changeDateGr, bool hasRollCallPlan, bool hasRollCallInPerson,
bool hasCustomizeCheckoutPlan, bool hasContractPlan, bool hasContractPlanInPerson,
bool hasInsurancePlan, bool hasInsurancePlanInPerson,int personnelCount)
{
return new InstitutionContractAmendmentChange(
changeType: InstitutionContractAmendmentChangeType.WorkshopCreated,
changeDateGr: changeDateGr,
hasCustomizeCheckoutPlan: hasCustomizeCheckoutPlan,
hasContractPlan: hasContractPlan,
hasContractPlanInPerson: hasContractPlanInPerson,
hasInsurancePlan: hasInsurancePlan,
hasInsurancePlanInPerson: hasInsurancePlanInPerson,
personnelCount: personnelCount,
hasRollCallPlan: hasRollCallPlan,
hasRollCallInPerson: hasRollCallInPerson,
currentWorkshopId: null,
personnelCountDifference: 0);
}
public long InstitutionContractAmendmentId { get; private set; }
public InstitutionContractAmendment InstitutionContractAmendment { get; private set; }
public InstitutionContractAmendmentChangeType ChangeType { get; private set; }
@@ -328,6 +411,8 @@ public class InstitutionContractAmendmentChange : EntityBase
/// </summary>
public bool? HasRollCallPlan { get; private set; }
public bool? HasRollCallInPerson { get; set; }
/// <summary>
/// پلن فیش غیر رسمی
/// </summary>
@@ -357,11 +442,17 @@ public class InstitutionContractAmendmentChange : EntityBase
/// تعداد پرسنل
/// </summary>
public int? PersonnelCount { get; private set; }
/// <summary>
/// مقدار تغییرات تعداد پرسنل
/// </summary>
public int PersonnelCountDifference { get; set; }
/// <summary>
/// تعداد کارگاه
/// </summary>
public long? WorkshopDetailsId { get; private set; }
public long? CurrentWorkshopId { get; private set; }
}
public enum InstitutionContractAmendmentChangeType

View File

@@ -9,7 +9,7 @@ public class InstitutionContractWorkshopBase:EntityBase
protected InstitutionContractWorkshopBase(){}
public InstitutionContractWorkshopBase(string workshopName, bool hasRollCallPlan,bool hasRollCallPlanInPerson,
bool hasCustomizeCheckoutPlan, bool hasContractPlan,bool hasContractPlanInPerson,bool hasInsurancePlan,bool hasInsurancePlanInPerson,
int personnelCount, double price )
int personnelCount, double price,bool isAmendment )
{
WorkshopName = workshopName;
Services = new WorkshopServices(hasInsurancePlan, hasInsurancePlanInPerson,
@@ -17,7 +17,10 @@ public class InstitutionContractWorkshopBase:EntityBase
PersonnelCount = personnelCount;
Price = price;
Employers = [];
IsAmendment = isAmendment;
}
/// <summary>
/// شناسه کارگاه
/// </summary>
@@ -42,7 +45,11 @@ public class InstitutionContractWorkshopBase:EntityBase
public double Price { get; private set; }
/// <summary>
/// جهت نمایش دادن اینکه آیا این کارگاه مربوط به ارتقا قرارداد است یا خیر
/// </summary>
public bool IsAmendment { get; set; }
public List<InstitutionContractWorkshopDetailEmployer> Employers { get; private set; } = new();

View File

@@ -10,9 +10,10 @@ public class InstitutionContractWorkshopCurrent:InstitutionContractWorkshopBase
public InstitutionContractWorkshopCurrent(string workshopName, bool hasRollCallPlan,
bool hasRollCallPlanInPerson, bool hasCustomizeCheckoutPlan, bool hasContractPlan,
bool hasContractPlanInPerson, bool hasInsurancePlan, bool hasInsurancePlanInPerson,
int personnelCount, double price,long institutionContractWorkshopGroupId,InstitutionContractWorkshopGroup workshopGroup,long workshopId) : base(workshopName, hasRollCallPlan,
int personnelCount, double price,long institutionContractWorkshopGroupId,
InstitutionContractWorkshopGroup workshopGroup,long workshopId,bool isAmendment) : base(workshopName, hasRollCallPlan,
hasRollCallPlanInPerson, hasCustomizeCheckoutPlan, hasContractPlan,
hasContractPlanInPerson, hasInsurancePlan, hasInsurancePlanInPerson, personnelCount, price)
hasContractPlanInPerson, hasInsurancePlan, hasInsurancePlanInPerson, personnelCount, price,isAmendment)
{
InstitutionContractWorkshopGroupId = institutionContractWorkshopGroupId;
WorkshopGroup = workshopGroup;

View File

@@ -31,6 +31,13 @@ public class InstitutionContractWorkshopGroup : EntityBase
InitialWorkshops = initialWorkshops.ToList();
LastModifiedDate = DateTime.Now;
}
public void AddAmendmentWorkshops(List<InstitutionContractWorkshopInitial> amendmentDetails)
{
InitialWorkshops.AddRange(amendmentDetails);
LastModifiedDate = DateTime.Now;
}
public void UpdateCurrentWorkshops(List<InstitutionContractWorkshopCurrent> updatedDetails)
{

View File

@@ -11,9 +11,9 @@ public class InstitutionContractWorkshopInitial:InstitutionContractWorkshopBase
public InstitutionContractWorkshopInitial(string workshopName, bool hasRollCallPlan,
bool hasRollCallPlanInPerson, bool hasCustomizeCheckoutPlan, bool hasContractPlan,
bool hasContractPlanInPerson, bool hasInsurancePlan, bool hasInsurancePlanInPerson,
int personnelCount, double price) : base(workshopName, hasRollCallPlan,
int personnelCount, double price,bool isAmendment =false) : base(workshopName, hasRollCallPlan,
hasRollCallPlanInPerson, hasCustomizeCheckoutPlan, hasContractPlan, hasContractPlanInPerson,
hasInsurancePlan, hasInsurancePlanInPerson, personnelCount, price)
hasInsurancePlan, hasInsurancePlanInPerson, personnelCount, price,isAmendment)
{
WorkshopCreated = false;
}
@@ -31,7 +31,8 @@ public class InstitutionContractWorkshopInitial:InstitutionContractWorkshopBase
WorkshopCreated = true;
WorkshopCurrent = new InstitutionContractWorkshopCurrent(WorkshopName,Services.RollCall,Services.RollCallInPerson,
Services.CustomizeCheckout,Services.Contract,Services.ContractInPerson,Services.Insurance,
Services.InsuranceInPerson,PersonnelCount,Price,InstitutionContractWorkshopGroupId,WorkshopGroup,workshopId);
Services.InsuranceInPerson,PersonnelCount,Price,InstitutionContractWorkshopGroupId,WorkshopGroup,workshopId,
IsAmendment);
WorkshopCurrent.SetEmployers(Employers.Select(x=>x.EmployerId).ToList());
}

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using CompanyManagment.App.Contracts.InstitutionContract;
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
@@ -16,7 +17,7 @@ public class InstitutionContractAmendmentTemp
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();
x.CurrentWorkshopId, 0,x.Id)).ToList();
InstitutionContractId = institutionContractId;
}
@@ -25,17 +26,32 @@ public class InstitutionContractAmendmentTemp
public Guid Id { get; private set; }
public List<InstitutionContractAmendmentTempPrevWorkshop> PrevWorkshops { get; private set; }
public List<InstitutionContractAmendmentTempNewWorkshop> NewWorkshops { get; private set; }
public InstitutionContractPaymentMonthlyViewModel MonthlyPayment { get; set; }
public InstitutionContractPaymentOneTimeViewModel OneTimePayment { get; set; }
public long InstitutionContractId { get; private set; }
public int MonthDifference { get; set; }
public void AddPaymentDetails(InstitutionContractPaymentMonthlyViewModel resMonthly, InstitutionContractPaymentOneTimeViewModel resOneTime, int monthDiff)
{
MonthlyPayment = resMonthly;
OneTimePayment = resOneTime;
MonthDifference = monthDiff;
}
}
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(
bool customizeCheckout, double price, long workshopId, long currentWorkshopId,double priceDifference,Guid prevId) : base(
workshopName, countPerson, contractAndCheckout, contractAndCheckoutInPerson, insurance, insuranceInPerson,
rollCall, rollCallInPerson, customizeCheckout, price, workshopId, currentWorkshopId)
{
Id = prevId;
PriceDifference = priceDifference;
}

View File

@@ -4,6 +4,8 @@ public class GetInstitutionVerificationDetailsWorkshopsViewModel
{
public string Name { get; set; }
public int PersonnelCount { get; set; }
public WorkshopServicesViewModel OldServices { get; set; }
public WorkshopServicesViewModel Services { get; set; }
public string Price { get; set; }
}

View File

@@ -244,13 +244,41 @@ public interface IInstitutionContractApplication
#endregion
Task<OperationResult> ResendVerifyLink(long institutionContractId);
Task AmendmentComplete(InstitutionContractAmendmentCompleteRequest request);
/// <summary>
/// دیتای پرینت قرارداد مالی
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
Task<InstitutionContractPrintViewModel> PrintOneAsync(long id);
Task<GetInstitutionAmendmentVerificationDetailsViewModel> GetAmendmentVerificationDetails(Guid id, long amendmentId);
}
public class GetInstitutionAmendmentVerificationDetailsViewModel
{
public InstitutionContratVerificationParty FirstParty { get; set; }
public InstitutionContratVerificationParty SecondParty { get; set; }
public string ContractNo { get; set; }
public string AmendmentCreationDate { get; set; }
public string AmendmentStart { get; set; }
public string AmendmentEnd { get; set; }
public List<GetInstitutionVerificationDetailsWorkshopsViewModel> Workshops { get; set; }
public string TotalPrice { get; set; }
public string TaxPrice { get; set; }
public string PaymentPrice { get; set; }
public List<InstitutionContractInstallmentViewModel> Installments { get; set; }
public bool IsInstallment { get; set; }
}
public class InstitutionContractAmendmentCompleteRequest
{
public Guid TempId { get; set; }
public bool IsInstallment { get; set; }
public long LawId { get; set; }
}
public class InstitutionContractPrintViewModel

View File

@@ -1,11 +1,28 @@
using System.Collections.Generic;
namespace CompanyManagment.App.Contracts.InstitutionContract;
public class InsitutionContractAmendmentPaymentResponse
{
public List<InsitutionContractAmendmentPaymentWorkshopResponse> workshops { get; set; }
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 class InsitutionContractAmendmentPaymentWorkshopResponse
{
public string WorkshopName { get; set; }
public WorkshopServicesViewModel OldServices { get; set; }
public WorkshopServicesViewModel NewServices { get; set; }
public bool IsNewWorkshop { get; set; }
public int PrevPersonnelCount { get; set; }
public int NewPersonnelCount { get; set; }
public double Price { get; set; }
}

View File

@@ -1387,6 +1387,16 @@ public class InstitutionContractApplication : IInstitutionContractApplication
return (await _institutionContractRepository.PrintAllAsync([id])).FirstOrDefault();
}
public async Task<GetInstitutionAmendmentVerificationDetailsViewModel> GetAmendmentVerificationDetails(Guid id, long amendmentId)
{
return await _institutionContractRepository.GetAmendmentVerificationDetails(id,amendmentId);
}
public async Task AmendmentComplete(InstitutionContractAmendmentCompleteRequest request)
{
await _institutionContractRepository.AmendmentComplete(request);
}
private async Task<OperationResult<PersonalContractingParty>> CreateLegalContractingPartyEntity(
CreateInstitutionContractLegalPartyRequest request, long representativeId, string address, string city,

View File

@@ -14,6 +14,8 @@ public class InstitutionContractAmendmentMapping:IEntityTypeConfiguration<Instit
builder.Property(x => x.VerifyCode).HasMaxLength(10);
builder.Property(x => x.VerifierFullName).HasMaxLength(100);
builder.Property(x => x.VerifierPhoneNumber).HasMaxLength(20);
builder.Property(x=>x.VerificationStatus).HasConversion<string>().HasMaxLength(50);
builder.HasOne(x => x.InstitutionContract)
.WithMany(x => x.Amendments)

View File

@@ -0,0 +1,83 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CompanyManagment.EFCore.Migrations
{
/// <inheritdoc />
public partial class AddIsAmendmentininstitutioncontractWorkshopDetials : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "WorkshopDetailsId",
table: "InstitutionContractAmendmentChange",
newName: "CurrentWorkshopId");
migrationBuilder.AddColumn<bool>(
name: "IsAmendment",
table: "InstitutionContractWorkshopInitials",
type: "bit",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<bool>(
name: "IsAmendment",
table: "InstitutionContractWorkshopCurrents",
type: "bit",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<string>(
name: "VerificationStatus",
table: "InstitutionContractAmendments",
type: "nvarchar(50)",
maxLength: 50,
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<bool>(
name: "HasRollCallInPerson",
table: "InstitutionContractAmendmentChange",
type: "bit",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "PersonnelCountDifference",
table: "InstitutionContractAmendmentChange",
type: "int",
nullable: false,
defaultValue: 0);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "IsAmendment",
table: "InstitutionContractWorkshopInitials");
migrationBuilder.DropColumn(
name: "IsAmendment",
table: "InstitutionContractWorkshopCurrents");
migrationBuilder.DropColumn(
name: "VerificationStatus",
table: "InstitutionContractAmendments");
migrationBuilder.DropColumn(
name: "HasRollCallInPerson",
table: "InstitutionContractAmendmentChange");
migrationBuilder.DropColumn(
name: "PersonnelCountDifference",
table: "InstitutionContractAmendmentChange");
migrationBuilder.RenameColumn(
name: "CurrentWorkshopId",
table: "InstitutionContractAmendmentChange",
newName: "WorkshopDetailsId");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CompanyManagment.EFCore.Migrations
{
/// <inheritdoc />
public partial class institutioncontractAmendmentlawid : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,30 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CompanyManagment.EFCore.Migrations
{
/// <inheritdoc />
public partial class ignorelawid : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<long>(
name: "LawId",
table: "InstitutionContractAmendments",
type: "bigint",
nullable: false,
defaultValue: 0L);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "LawId",
table: "InstitutionContractAmendments");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,20 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CompanyManagment.EFCore.Migrations
{
/// <inheritdoc />
public partial class lawIdtest : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@@ -3288,6 +3288,11 @@ namespace CompanyManagment.EFCore.Migrations
b.Property<DateTime>("VerificationCreation")
.HasColumnType("datetime2");
b.Property<string>("VerificationStatus")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("VerifierFullName")
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
@@ -3327,6 +3332,9 @@ namespace CompanyManagment.EFCore.Migrations
b.Property<DateTime>("CreationDate")
.HasColumnType("datetime2");
b.Property<long?>("CurrentWorkshopId")
.HasColumnType("bigint");
b.Property<bool?>("HasContractPlan")
.HasColumnType("bit");
@@ -3342,6 +3350,9 @@ namespace CompanyManagment.EFCore.Migrations
b.Property<bool?>("HasInsurancePlanInPerson")
.HasColumnType("bit");
b.Property<bool?>("HasRollCallInPerson")
.HasColumnType("bit");
b.Property<bool?>("HasRollCallPlan")
.HasColumnType("bit");
@@ -3351,8 +3362,8 @@ namespace CompanyManagment.EFCore.Migrations
b.Property<int?>("PersonnelCount")
.HasColumnType("int");
b.Property<long?>("WorkshopDetailsId")
.HasColumnType("bigint");
b.Property<int>("PersonnelCountDifference")
.HasColumnType("int");
b.HasKey("id");
@@ -3419,6 +3430,9 @@ namespace CompanyManagment.EFCore.Migrations
b.Property<long>("InstitutionContractWorkshopGroupId")
.HasColumnType("bigint");
b.Property<bool>("IsAmendment")
.HasColumnType("bit");
b.Property<int>("PersonnelCount")
.HasColumnType("int");
@@ -3484,6 +3498,9 @@ namespace CompanyManagment.EFCore.Migrations
b.Property<long>("InstitutionContractWorkshopGroupId")
.HasColumnType("bigint");
b.Property<bool>("IsAmendment")
.HasColumnType("bit");
b.Property<int>("PersonnelCount")
.HasColumnType("int");

View File

@@ -29,7 +29,6 @@ using CompanyManagment.App.Contracts.Law;
using CompanyManagment.App.Contracts.TemporaryClientRegistration;
using CompanyManagment.App.Contracts.Workshop;
using CompanyManagment.App.Contracts.WorkshopPlan;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
@@ -2374,6 +2373,8 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
x.WorkshopId??0,x.id)).ToList();
await _institutionAmendmentTemp
.DeleteManyAsync(x => x.InstitutionContractId == institutionContractId);;
var temp = new InstitutionContractAmendmentTemp(workshops, institutionContractId);
@@ -2456,12 +2457,14 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
if (endDay > startDay)
monthDiff++;
var sumOneMonth = institutionContractAmendmentTemp.NewWorkshops.Sum(x => x.PriceDifference);
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()
{
@@ -2469,6 +2472,41 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
ContractEnd = amendmentEnd.ToFarsi(),
OneMonthAmount = sumOneMonth.ToMoney(),
TotalAmount = baseAmount.ToMoney(),
workshops = institutionContractAmendmentTemp.NewWorkshops
.Select(x=>
{
var prevWorkshop = institutionContractAmendmentTemp.PrevWorkshops
.FirstOrDefault(w=> w.Id == x.Id);
var isNewWorkshop = prevWorkshop == null;
return new InsitutionContractAmendmentPaymentWorkshopResponse()
{
WorkshopName = x.WorkshopName,
IsNewWorkshop = isNewWorkshop,
NewPersonnelCount = x.CountPerson,
PrevPersonnelCount = prevWorkshop?.CountPerson??0,
Price = x.PriceDifference,
OldServices = prevWorkshop != null? new WorkshopServicesViewModel()
{
Contract = prevWorkshop.ContractAndCheckout,
ContractInPerson = prevWorkshop.ContractAndCheckoutInPerson,
CustomizeCheckout = prevWorkshop.CustomizeCheckout,
Insurance = prevWorkshop.Insurance,
InsuranceInPerson = prevWorkshop.InsuranceInPerson,
RollCall = prevWorkshop.RollCall,
RollCallInPerson = prevWorkshop.RollCallInPerson,
}: new WorkshopServicesViewModel(),
NewServices = new WorkshopServicesViewModel()
{
Contract = x.ContractAndCheckout,
ContractInPerson = x.ContractAndCheckoutInPerson,
CustomizeCheckout = x.CustomizeCheckout,
Insurance = x.Insurance,
InsuranceInPerson = x.InsuranceInPerson,
RollCall = x.RollCall,
RollCallInPerson = x.RollCallInPerson,
},
};
}).OrderByDescending(x=>x.Price).ToList()
};
res.OneTime = new InstitutionContractPaymentOneTimeViewModel()
@@ -2515,6 +2553,13 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
};
}
institutionContractAmendmentTemp.AddPaymentDetails(res.Monthly, res.OneTime, monthDiff);
await _institutionAmendmentTemp
.ReplaceOneAsync(x => x.Id == institutionContractAmendmentTemp.Id, institutionContractAmendmentTemp);
return res;
}
@@ -2553,7 +2598,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
request.Insurance, request.InsuranceInPerson,
request.RollCall, request.RollCallInPerson,
request.CustomizeCheckout, price,
request.WorkshopId,0,price);
request.WorkshopId,0,price,Guid.NewGuid());
workshopTemp = newWorkshopTemp;
@@ -2565,9 +2610,24 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
}
else
{
var prevWorkshop = amendmentTemp.PrevWorkshops
.FirstOrDefault(x => x.Id == workshopTemp.Id);
var differencePrice = 0d;
if (prevWorkshop != null)
{
differencePrice = price - prevWorkshop.Price;
}
else
{
differencePrice = price;
}
amendmentTemp.NewWorkshops.Remove(workshopTemp);
var differencePrice = price - workshopTemp.Price;
if (differencePrice<0)
{
differencePrice = 0;
}
workshopTemp.Edit(request.WorkshopName, request.CountPerson,
request.ContractAndCheckout, request.ContractAndCheckoutInPerson,
request.Insurance, request.InsuranceInPerson,
@@ -2768,6 +2828,146 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
return res;
}
public async Task AmendmentComplete(InstitutionContractAmendmentCompleteRequest request)
{
var amendmentTemp = await _institutionAmendmentTemp
.Find(x=>x.Id == request.TempId).FirstOrDefaultAsync();
if (amendmentTemp == null)
throw new BadRequestException("دیتای وارد شده نامعتبر است");
var institutionContract = await _context.InstitutionContractSet
.Include(x=>x.Amendments)
.Include(x=>x.WorkshopGroup)
.ThenInclude(x=>x.CurrentWorkshops)
.FirstOrDefaultAsync(x => x.id == amendmentTemp.InstitutionContractId);
List<InstitutionContractInstallment> installments = [];
double amount = 0;
if (request.IsInstallment)
{
installments = amendmentTemp.MonthlyPayment.Installments.Select(x=>
new InstitutionContractInstallment(x.InstalmentDate.ToGeorgianDateTime(),
x.InstallmentAmountStr.MoneyToDouble(), "")).ToList();
amount = amendmentTemp.MonthlyPayment.PaymentAmount.MoneyToDouble();
}
else
{
amount = amendmentTemp.OneTimePayment.PaymentAmount.MoneyToDouble();
}
var newWorkshops = amendmentTemp
.NewWorkshops.Where(x=>x.CurrentWorkshopId ==0).ToList();
var newWorkshopTempIds = newWorkshops.Select(x=>x.Id).ToList();
var changes = newWorkshops.Select(x=>
InstitutionContractAmendmentChange.CreateWorkshopCreatedChange(DateTime.Now,x.RollCall,x.RollCallInPerson,x.CustomizeCheckout,
x.ContractAndCheckout,x.ContractAndCheckoutInPerson,x.Insurance,x.InsuranceInPerson,x.CountPerson)).ToList();
var changedWorkshops = amendmentTemp.NewWorkshops
.Where(x => !newWorkshopTempIds.Contains(x.Id)).ToList();
foreach (var changedWorkshop in changedWorkshops)
{
var prev = amendmentTemp.PrevWorkshops.FirstOrDefault(x => x.Id == changedWorkshop.Id);
if (prev == null)
throw new BadRequestException("دیتای وارد شده ناقص ذخیره شده است");
// مقایسه مقادیر بولین بین prev و changedWorkshop برای تشخیص تغییرات
var changedBooleans = new Dictionary<string, (bool Previous, bool Current)>();
if (prev.CustomizeCheckout != changedWorkshop.CustomizeCheckout)
changedBooleans.Add("CustomizeCheckout", (prev.CustomizeCheckout, changedWorkshop.CustomizeCheckout));
if (prev.ContractAndCheckout != changedWorkshop.ContractAndCheckout)
changedBooleans.Add("ContractAndCheckout", (prev.ContractAndCheckout, changedWorkshop.ContractAndCheckout));
if (prev.ContractAndCheckoutInPerson != changedWorkshop.ContractAndCheckoutInPerson)
changedBooleans.Add("ContractAndCheckoutInPerson", (prev.ContractAndCheckoutInPerson, changedWorkshop.ContractAndCheckoutInPerson));
if (prev.Insurance != changedWorkshop.Insurance)
changedBooleans.Add("Insurance", (prev.Insurance, changedWorkshop.Insurance));
if (prev.InsuranceInPerson != changedWorkshop.InsuranceInPerson)
changedBooleans.Add("InsuranceInPerson", (prev.InsuranceInPerson, changedWorkshop.InsuranceInPerson));
if (prev.RollCall != changedWorkshop.RollCall)
changedBooleans.Add("RollCall", (prev.RollCall, changedWorkshop.RollCall));
if (prev.RollCallInPerson != changedWorkshop.RollCallInPerson)
changedBooleans.Add("RollCallInPerson", (prev.RollCallInPerson, changedWorkshop.RollCallInPerson));
// اگر تغییری وجود داشته باشد، آن را به لیست تغییرات اضافه کن
if (changedBooleans.Any())
{
var change = InstitutionContractAmendmentChange.CreateServicesChange(
DateTime.Now,
changedWorkshop.WorkshopId,
changedWorkshop.RollCall,
changedWorkshop.RollCallInPerson,
changedWorkshop.CustomizeCheckout,
changedWorkshop.ContractAndCheckout,
changedWorkshop.ContractAndCheckoutInPerson,
changedWorkshop.Insurance,
changedWorkshop.InsuranceInPerson);
changes.Add(change);
}
if (changedWorkshop.CountPerson != prev.CountPerson)
{
var difference = changedWorkshop.CountPerson - prev.CountPerson;
var change = InstitutionContractAmendmentChange.CreatePersonCountChange(
DateTime.Now,
changedWorkshop.CountPerson,
difference,changedWorkshop.WorkshopId);
changes.Add(change);
}
}
var amendment = new InstitutionContractAmendment(institutionContract.id,installments,amount,
request.IsInstallment,changes,request.LawId);
institutionContract.AddAmendment(amendment);
await _smsService.SendInstitutionAmendmentVerificationLink(
institutionContract.VerifierPhoneNumber,
institutionContract.ContractingPartyName,
institutionContract.PublicId,
institutionContract.ContractingPartyId,
institutionContract.id
);
await _institutionAmendmentTemp.DeleteOneAsync(x=>x.Id == amendmentTemp.Id);
await _context.SaveChangesAsync();
}
public async Task<GetInstitutionAmendmentVerificationDetailsViewModel> GetAmendmentVerificationDetails(Guid id,
long amendmentId)
{
var institutionContract = await _context.InstitutionContractSet
.Include(x => x.Amendments)
.FirstOrDefaultAsync(x => x.PublicId == id);
if (institutionContract == null)
throw new NotFoundException("قرارداد مؤسسه یافت نشد");
var amendment = institutionContract.Amendments
.FirstOrDefault(x => x.id == amendmentId);
if (amendment == null)
throw new NotFoundException("ارتقا یافت نشد");
if (amendment.VerificationStatus != InstitutionContractVerificationStatus.PendingForVerify)
throw new BadRequestException("این ارتقا قبلا تایید شده است");
throw new NotImplementedException();
}
private InstitutionContractExtensionPaymentResponse CalculateInPersonPayment(
InstitutionContractExtensionPlanDetail selectedPlan, double baseAmount, double tenPercent,

View File

@@ -541,18 +541,52 @@ public class institutionContractController : AdminBaseController
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;
}
[HttpPost("amendment/complete")]
public async Task<ActionResult> AmendmentComplete(
[FromBody] InstitutionContractAmendmentCompleteRequest request)
{
await _institutionContractApplication.AmendmentComplete(request);
return Ok();
}
/// <summary>
///
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet("/api/institutionContract/amendment-Verification/{id:guid}/{amendmentId:long}")]
[AllowAnonymous]
public async Task<GetInstitutionAmendmentVerificationDetailsViewModel> GetAmendmentVerificationDetails(Guid id,long amendmentId)
{
return await _institutionContractApplication.GetAmendmentVerificationDetails(id,amendmentId);
}
[HttpPost("/api/institutionContract/Verify-amendment")]
[AllowAnonymous]
public async Task<ActionResult<OperationResult>> VerifyAmendment([FromBody] InstitutionVerificationRequest command)
{
throw new NotImplementedException();
//var res = await _institutionContractApplication.AmendmentVerifyOtp(command.Id, command.Code);
//return res;
}
[HttpGet("edit-old/{id}")]

View File

@@ -737,7 +737,7 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk
x.PersonnelCount,
x.Price, x.InstitutionContractWorkshopGroupId,
group,
x.WorkshopId.Value);
x.WorkshopId.Value,false);
entity.SetEmployers(x.Employers.Select(e => e.EmployerId).ToList());
return entity;