Compare commits

...

28 Commits

Author SHA1 Message Date
595b2c8a2d feat: update verification date and time properties in institution contract model 2025-10-28 13:15:46 +03:30
6b6b0767e3 Merge branch 'master' into Feature/InstitutionContract/print-api 2025-10-23 16:44:36 +03:30
3d86ba401f fix: update IsOldContract logic to handle null and empty workshop groups 2025-10-23 16:44:19 +03:30
6a6e2e532a feat: add print API for institution contracts and include verifier details 2025-10-23 14:13:55 +03:30
ca6638d6a3 feat: enhance workshop query with additional filtering options and improved mapping 2025-10-22 19:26:10 +03:30
608fb824dc refactor: remove unnecessary console logging in workshop selection 2025-10-22 17:23:17 +03:30
4686151bbb Merge branch 'Main'
# Conflicts:
#	CompanyManagment.EFCore/Repository/InstitutionContractRepository.cs
2025-10-22 17:04:59 +03:30
d7fae42e4f Merge remote-tracking branch 'origin/master' 2025-10-22 17:01:12 +03:30
2cfe480733 fix: correct workshop ID reference in employee count calculation 2025-10-22 17:00:33 +03:30
syntax24
c574ce534d Insurance Exept include = 0, Employee 1496 2025-10-22 16:55:11 +03:30
174edbf87d Merge branch 'Feature/InstitutionContract/add-old-edit-api' into Main
# Conflicts:
#	ServiceHost/Areas/Admin/Controllers/institutionContractController.cs
2025-10-22 15:29:43 +03:30
a827470831 feat: add API for editing old institution contracts with new properties 2025-10-22 15:19:17 +03:30
c9b61c3fc6 fix: validate Georgian date conversion in financial statement application 2025-10-22 12:07:26 +03:30
0bacb24aa2 Merge branch 'Feature/InstitutionContract/upgrade' into Main 2025-10-21 21:58:25 +03:30
7fd8851f71 refactor: optimize employee count calculation in InstitutionContractRepository 2025-10-21 21:57:04 +03:30
bc6ae854f8 Merge branch 'Feature/InstitutionContract/upgrade' into Main
# Conflicts:
#	Company.Domain/InstitutionContractAgg/IInstitutionContractRepository.cs
#	Company.Domain/InstitutionContractAgg/InstitutionContract.cs
2025-10-21 15:07:16 +03:30
68f1f81b53 feat: add BSON representation for Id property in InstitutionContractAmendmentTemp 2025-10-21 15:05:48 +03:30
d4c2ab939e fix: correct workshop ID reference in employee count calculation 2025-10-21 14:55:23 +03:30
5822005b68 Merge branch 'master' into Feature/InstitutionContract/upgrade
# Conflicts:
#	Company.Domain/InstitutionContractAgg/IInstitutionContractRepository.cs
#	Company.Domain/InstitutionContractAgg/InstitutionContract.cs
#	ServiceHost/Areas/Admin/Controllers/institutionContractController.cs
2025-10-21 14:45:22 +03:30
53aeb60861 Merge branch 'Feature/InstitutionContract/upgrade' into Main 2025-10-21 14:37:41 +03:30
c2a08d9c33 feat: add BsonRepresentation attribute to Id property for string representation in MongoDB 2025-10-21 14:37:11 +03:30
b711e803a9 Merge branch 'master' into Main
# Conflicts:
#	ServiceHost/Areas/Admin/Controllers/institutionContractController.cs
2025-10-21 11:50:45 +03:30
55f7b4f7c0 Merge branch 'Feature/InstitutionContract/upgrade' into Main
# Conflicts:
#	Company.Domain/InstitutionContractAgg/IInstitutionContractRepository.cs
#	Company.Domain/InstitutionContractAgg/InstitutionContract.cs
2025-10-21 11:10:06 +03:30
c5b521bc50 feat: add endpoints for inserting, removing, and retrieving amendment workshops and payment details 2025-10-21 11:04:46 +03:30
acdd7de4f6 feat: update InsertAmendmentTempWorkshops method to return detailed response and refactor related classes 2025-10-21 11:02:10 +03:30
fde58a7c75 feat: add temporary workshop management for institution contract amendments 2025-10-20 13:13:43 +03:30
7d6b57affd feat: make Workshops property public and update CalculateInstallment method visibility 2025-10-18 16:50:40 +03:30
c8018948c2 feat: add validation to prevent upgrading institution contracts with zero-priced workshops 2025-10-16 11:56:45 +03:30
20 changed files with 12174 additions and 88 deletions

View File

@@ -6,6 +6,7 @@ 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;
@@ -65,12 +66,15 @@ 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);
Task<List<InstitutionContractPrintViewModel>> PrintAllAsync(List<long> ids);
}

View File

@@ -6,7 +6,6 @@ using System.Security.Cryptography;
using _0_Framework.Domain;
using Company.Domain.InstitutionContractContactInfoAgg;
using CompanyManagment.App.Contracts.InstitutionContract;
using OfficeOpenXml.Table.PivotTable;
namespace Company.Domain.InstitutionContractAgg;
@@ -126,6 +125,8 @@ public class InstitutionContract : EntityBase
public string VerifyCode { get; private set; }
public DateTime VerifyCodeCreation { get; private set; }
public string VerifierFullName { get; private set; }
public string VerifierPhoneNumber { get; private set; }
[NotMapped] public bool VerifyCodeExpired => VerifyCodeCreation.Add(ExpireTime) <= DateTime.Now;
@@ -226,10 +227,12 @@ public class InstitutionContract : EntityBase
}
public void SetVerifyCode(string code)
public void SetVerifyCode(string code,string verifierFullName, string verifierPhoneNumber)
{
VerifyCode = code;
VerifyCodeCreation = DateTime.Now;
VerifierFullName = verifierFullName;
VerifierPhoneNumber = verifierPhoneNumber;
}
public void SetWorkshopGroup(InstitutionContractWorkshopGroup workshopGroup)
@@ -277,11 +280,19 @@ public class InstitutionContractAmendment : EntityBase
public long LawId { get; set; }
public void SetVerifyCode(string code)
public void SetVerifyCode(string code,string verifierFullName, string verifierPhoneNumber)
{
VerifyCode = code;
VerificationCreation = DateTime.Now;
VerifyCodeCreation = DateTime.Now;
VerifierFullName = verifierFullName;
VerifierPhoneNumber = verifierPhoneNumber;
}
public string VerifierPhoneNumber { get; private set; }
public string VerifierFullName { get; private set; }
public DateTime VerifyCodeCreation { get; set; }
}
public class InstitutionContractAmendmentChange : EntityBase

View File

@@ -0,0 +1,151 @@
using System;
using System.Collections.Generic;
using System.Linq;
using MongoDB.Bson;
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]
[BsonRepresentation(BsonType.String)]
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;
}
[BsonRepresentation(BsonType.String)]
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

@@ -87,6 +87,10 @@ public class GetInstitutionContractListItemsViewModel
public long ContractingPartyId { get; set; }
public List<InstitutionContractListWorkshop> Workshops { get; set; }
public bool IsInPersonContract { get; set; }
public bool IsOldContract { get; set; }
}
public class InstitutionContractListWorkshop

View File

@@ -7,6 +7,7 @@ using System.Threading.Tasks;
using _0_Framework.Application;
using _0_Framework.Application.Sms;
using CompanyManagment.App.Contracts.Checkout;
using CompanyManagment.App.Contracts.Law;
using CompanyManagment.App.Contracts.TemporaryClientRegistration;
using CompanyManagment.App.Contracts.Workshop;
using CompanyManagment.App.Contracts.WorkshopPlan;
@@ -77,6 +78,8 @@ public interface IInstitutionContractApplication
/// <returns>لیست قراردادها برای چاپ</returns>
List<InstitutionContractViewModel> PrintAll(List<long> id);
[Obsolete("استفاده نشود، از متد غیرهمزمان استفاده شود")]
/// <summary>
/// چاپ یک قرارداد
/// </summary>
@@ -234,28 +237,47 @@ 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
Task<OperationResult> ResendVerifyLink(long institutionContractId);
/// <summary>
/// دیتای پرینت قرارداد مالی
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
Task<InstitutionContractPrintViewModel> PrintOneAsync(long id);
}
public class InsitutionContractAmendmentPaymentRequest
public class InstitutionContractPrintViewModel
{
List<WorkshopTempViewModel> Workshops { get; set; }
public long InstitutionContractId { get; set; }
}
public class InsitutionContractAmendmentPaymentResponse
{
public InstitutionContractPaymentOneTimeViewModel OneTime { get; set; }
public InstitutionContractPaymentMonthlyViewModel Monthly { get; set; }
public InstitutionContratVerificationParty FirstParty { get; set; }
public InstitutionContratVerificationParty SecondParty { get; set; }
public string ContractNo { get; set; }
public string CreationDate { get; set; }
public string ContractStart { get; set; }
public string ContractEnd { get; set; }
public string OneMonthAmount { get; set; }
public string TotalAmount { get; set; }
public List<GetInstitutionVerificationDetailsWorkshopsViewModel> Workshops { get; set; }
public string TotalPrice { get; set; }
public string TaxPrice { get; set; }
public string PaymentPrice { get; set; }
public string VerifyCode { get; set; }
public string VerifyDate { get; set; }
public string VerifyTime { get; set; }
public string VerifierFullName { get; set; }
public string VerifierPhoneNumber { get; set; }
public LawViewModel LawViewModel { get; set; }
public string Obligation { get; set; }
}
public class InsertAmendmentTempWorkshopResponse
{
public Guid WorkshopTempId { get; set; }
public string Amount { get; set; }
}
public class InstitutionContractAmendmentWorkshopsResponse
@@ -263,7 +285,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

@@ -106,8 +106,11 @@ public class FinancialStatmentApplication : IFinancialStatmentApplication
debtor = command.DeptorString.MoneyToDouble();
}
var tDateGr = command.TdateFa.ToGeorgianDateTime();
if (!command.TdateFa.TryToGeorgianDateTime(out var tDateGr))
{
return op.Failed("تاریخ وارد شده صحیح نمی باشد");
}
if (_financialStatmentRepository.Exists(x => x.ContractingPartyId == command.ContractingPartyId))
{
var financialStatment = _financialStatmentRepository.GetDetailsByContractingPartyId(command.ContractingPartyId);

View File

@@ -1203,7 +1203,12 @@ public class InstitutionContractApplication : IInstitutionContractApplication
throw new NotFoundException("طرف قرارداد یافت نشد");
var code = new Random().Next(1000, 9999).ToString();
institutionContract.SetVerifyCode(code);
var contractingPartyFullName = contractingParty.IsLegal == "حقیقی"
? contractingParty.FName + " " + contractingParty.LName
: contractingParty.CeoFName + " " + contractingParty.CeoLName;
institutionContract.SetVerifyCode(code,contractingPartyFullName ,contractingParty.Phone);
var transaction = await _institutionContractRepository.BeginTransactionAsync();
try
@@ -1340,6 +1345,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);
@@ -1367,6 +1382,11 @@ public class InstitutionContractApplication : IInstitutionContractApplication
return new OperationResult().Succcedded();
}
public async Task<InstitutionContractPrintViewModel> PrintOneAsync(long id)
{
return (await _institutionContractRepository.PrintAllAsync([id])).FirstOrDefault();
}
private async Task<OperationResult<PersonalContractingParty>> CreateLegalContractingPartyEntity(
CreateInstitutionContractLegalPartyRequest request, long representativeId, string address, string city,
@@ -1462,7 +1482,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

@@ -1869,6 +1869,11 @@ public class InsuranceListApplication : IInsuranceListApplication
bool isManager = jobId is 10 or 16 or 17 or 18 or 3498;
if (isManager && !includeStatus)
return 0;
//پرسنل استثناء سیدعسکر موسوی زاده - فروشگاه ولی عصر
if (employeeId == 1496)
return 0;
//پرسنل استثناء
if (employeeId == 42783)
return 53082855;

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

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

View File

@@ -30,6 +30,8 @@ public class InstitutionContractMapping : IEntityTypeConfiguration<InstitutionCo
builder.Property(x => x.HasValueAddedTax).HasMaxLength(10);
builder.Property(x => x.VerifyCode).HasMaxLength(20);
builder.Property(x => x.VerifierFullName).HasMaxLength(100);
builder.Property(x => x.VerifierPhoneNumber).HasMaxLength(20);
builder.Property(x => x.VerificationStatus).HasConversion<string>().HasMaxLength(122);

View File

@@ -0,0 +1,74 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CompanyManagment.EFCore.Migrations
{
/// <inheritdoc />
public partial class AddVerifierdetailsininstituioncontractandamendment : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "VerifierFullName",
table: "InstitutionContracts",
type: "nvarchar(100)",
maxLength: 100,
nullable: true);
migrationBuilder.AddColumn<string>(
name: "VerifierPhoneNumber",
table: "InstitutionContracts",
type: "nvarchar(20)",
maxLength: 20,
nullable: true);
migrationBuilder.AddColumn<string>(
name: "VerifierFullName",
table: "InstitutionContractAmendments",
type: "nvarchar(100)",
maxLength: 100,
nullable: true);
migrationBuilder.AddColumn<string>(
name: "VerifierPhoneNumber",
table: "InstitutionContractAmendments",
type: "nvarchar(20)",
maxLength: 20,
nullable: true);
migrationBuilder.AddColumn<DateTime>(
name: "VerifyCodeCreation",
table: "InstitutionContractAmendments",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "VerifierFullName",
table: "InstitutionContracts");
migrationBuilder.DropColumn(
name: "VerifierPhoneNumber",
table: "InstitutionContracts");
migrationBuilder.DropColumn(
name: "VerifierFullName",
table: "InstitutionContractAmendments");
migrationBuilder.DropColumn(
name: "VerifierPhoneNumber",
table: "InstitutionContractAmendments");
migrationBuilder.DropColumn(
name: "VerifyCodeCreation",
table: "InstitutionContractAmendments");
}
}
}

View File

@@ -3205,6 +3205,14 @@ namespace CompanyManagment.EFCore.Migrations
.HasMaxLength(122)
.HasColumnType("nvarchar(122)");
b.Property<string>("VerifierFullName")
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.Property<string>("VerifierPhoneNumber")
.HasMaxLength(20)
.HasColumnType("nvarchar(20)");
b.Property<string>("VerifyCode")
.HasMaxLength(20)
.HasColumnType("nvarchar(20)");
@@ -3247,10 +3255,21 @@ namespace CompanyManagment.EFCore.Migrations
b.Property<DateTime>("VerificationCreation")
.HasColumnType("datetime2");
b.Property<string>("VerifierFullName")
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.Property<string>("VerifierPhoneNumber")
.HasMaxLength(20)
.HasColumnType("nvarchar(20)");
b.Property<string>("VerifyCode")
.HasMaxLength(10)
.HasColumnType("nvarchar(10)");
b.Property<DateTime>("VerifyCodeCreation")
.HasColumnType("datetime2");
b.HasKey("id");
b.HasIndex("InstitutionContractId");

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;
@@ -23,9 +25,11 @@ using Company.Domain.WorkshopAgg;
using CompanyManagment.App.Contracts.Employer;
using CompanyManagment.App.Contracts.InstitutionContract;
using CompanyManagment.App.Contracts.InstitutionContractContactinfo;
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;
@@ -42,9 +46,20 @@ 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;
private readonly InstitutionContratVerificationParty _firstParty = new()
{
Address = "رشت - خیابان حاجی آیاد - کوچه سپهدار - ساختمان داماش - واحد 17",
PhoneNumber = "09111485044",
CeoName = "سید حسن مصباح",
CompanyNameOrFullName = "نور داد مهر گستر کاسپین",
NationalCodeOrNationalId = "14009970584",
LegalType = LegalType.Legal
};
public InstitutionContractRepository(CompanyContext context, IEmployerRepository employerRepository,
IWorkshopRepository workshopRepository, IMongoDatabase database,
IPlanPercentageRepository planPercentageRepository, ISmsService smsService) : base(context)
@@ -56,6 +71,8 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
_smsService = smsService;
_institutionExtensionTemp =
database.GetCollection<InstitutionContractExtensionTemp>("InstitutionContractExtensionTemp");
_institutionAmendmentTemp =
database.GetCollection<InstitutionContractAmendmentTemp>("InstitutionContractAmendmentTemp");
}
public EditInstitutionContract GetDetails(long id)
@@ -1240,7 +1257,6 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
TotalCount = await joinedQuery.CountAsync(),
List = list.Select(x =>
{
Console.WriteLine(x.contractingParty.id);
var workshops = x.contractingParty.Employers
.SelectMany(e => e.WorkshopEmployers.Select(we => we.Workshop)).DistinctBy(w => w.id).ToList();
@@ -1267,7 +1283,6 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
var workshopDetails = currentStateWorkshops?.Select(w =>
{
Workshop workshopSelected = null;
Console.WriteLine(w.WorkshopId);
if (w.WorkshopId != null && workshops.Select(ww => ww.id).Contains(w.WorkshopId.Value))
{
workshopSelected = workshops.First(ww => ww.id == w.WorkshopId.Value);
@@ -1289,6 +1304,10 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
}
};
}).ToList() ?? [];
var employeesCount = _context.LeftWorkList
.Where(l => workshops.Select(w => w.id).Contains(l.WorkshopId))
.Count(l => l.StartWorkDate <= DateTime.Now && l.LeftWorkDate >= DateTime.Now);
return new GetInstitutionContractListItemsViewModel()
{
ContractAmount = x.contract.ContractAmount,
@@ -1303,14 +1322,17 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
Id = x.contract.id,
ContractNo = x.contract.ContractNo,
ArchiveNo = archiveCode.ToString(),
EmployeesCount = _context.LeftWorkList
.Where(l => workshops.Select(w => w.id).Contains(l.id))
.Count(l => l.StartWorkDate <= DateTime.Now && l.LeftWorkDate >= DateTime.Now),
EmployeesCount = employeesCount,
EmployerNames = employers.Select(e => e.FullName).ToList(),
ListStatus = status,
IsExpired = x.contract.ContractEndGr <= endThisMontGr,
ContractingPartyId = x.contractingParty.id,
Workshops = workshopDetails
Workshops = workshopDetails,
IsInPersonContract = x.contract.WorkshopGroup?.CurrentWorkshops
.Any(y=>y.Services.ContractInPerson)??true,
IsOldContract = x.contract.WorkshopGroup?.CurrentWorkshops == null
|| x.contract.WorkshopGroup.CurrentWorkshops.Count == 0
|| x.contract.WorkshopGroup.CurrentWorkshops.Any(y => y.Price == 0)
};
}).ToList()
};
@@ -1789,15 +1811,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
query.party.IsLegal == "حقیقی" ? query.party.Nationalcode : query.party.NationalId,
LegalType = query.party.IsLegal == "حقیقی" ? LegalType.Real : LegalType.Legal,
},
FirstParty = new InstitutionContratVerificationParty()
{
Address = "رشت - خیابان حاجی آیاد - کوچه سپهدار - ساختمان داماش - واحد 17",
PhoneNumber = "09111111111",
CeoName = "سید حسن مصباح",
CompanyNameOrFullName = "نور داد مهر گستر کاسپین",
NationalCodeOrNationalId = "1111111111",
LegalType = LegalType.Legal
}
FirstParty =_firstParty
};
return res;
@@ -2239,7 +2253,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 +2263,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 +2359,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)
@@ -2441,6 +2659,113 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
}
public async Task<List<InstitutionContractPrintViewModel>> PrintAllAsync(List<long> ids)
{
var query =_context.InstitutionContractSet
.Include(x=>x.WorkshopGroup)
.ThenInclude(x=>x.InitialWorkshops)
.Include(x=>x.WorkshopGroup)
.ThenInclude(x=>x.CurrentWorkshops)
.Where(x=>ids.Contains(x.id));
var contractingPartyIds = query.Select(x => x.ContractingPartyId).ToList();
var contractingParties = await _context.PersonalContractingParties
.Where(x => contractingPartyIds.Contains(x.id))
.ToListAsync();
var list = query.ToList();
if (list.Count == 0)
throw new NotFoundException("قرارداد مؤسسه یافت نشد");
var res = new List<InstitutionContractPrintViewModel>();
foreach (var institution in list)
{
var contractingParty = contractingParties.FirstOrDefault(x => x.id == institution.ContractingPartyId);
if (contractingParty == null)
{
throw new NotFoundException("طرف حساب یافت نشد");
}
var law = await _context.Laws
.FirstOrDefaultAsync(x => x.id == institution.LawId);
var secondParty = new InstitutionContratVerificationParty()
{
Address = contractingParty.Address,
PhoneNumber = contractingParty.Phone,
CeoName = contractingParty.IsLegal == "حقیقی"
? $"{contractingParty.FName} {contractingParty.LName}"
: $"{contractingParty.CeoFName} {contractingParty.CeoLName}",
CompanyNameOrFullName = contractingParty.IsLegal == "حقیقی"
? $"{contractingParty.FName} {contractingParty.LName}"
: contractingParty.LName,
NationalCodeOrNationalId =
contractingParty.IsLegal == "حقیقی" ? contractingParty.Nationalcode : contractingParty.NationalId,
LegalType = contractingParty.IsLegal == "حقیقی" ? LegalType.Real : LegalType.Legal,
};
var lawViewModel = new LawViewModel()
{
Id = law.id,
CreatedAt = law.CreationDate,
HeadTitle = law.HeadTitle,
IsActive = law.IsActive,
Items = law.Items.Select(x => new LawItemViewModel()
{
Details = x.Details,
Header = x.Header
}).ToList(),
Notifications = law.Notifications,
Title = law.Title,
Type = law.Type,
Version = law.Version
};
var item = new InstitutionContractPrintViewModel()
{
ContractStart = institution.ContractStartFa,
ContractEnd = institution.ContractEndFa,
ContractNo = institution.ContractNo,
CreationDate = institution.CreationDate.ToFarsi(),
FirstParty = _firstParty,
SecondParty = secondParty,
LawViewModel = lawViewModel,
Obligation = institution.Obligation.ToMoney(),
PaymentPrice = institution.TotalAmount.ToMoney(),
TotalPrice = (institution.TotalAmount - institution.ValueAddedTax).ToMoney(),
TaxPrice = institution.ValueAddedTax.ToMoney(),
VerifierFullName = institution.VerifierFullName,
VerifierPhoneNumber = institution.VerifierPhoneNumber,
VerifyCode = institution.VerifyCode,
VerifyDate = institution.VerifyCodeCreation.ToFarsi(),
VerifyTime = institution.VerifyCodeCreation.ToString("HH:mm:ss"),
Workshops = institution.WorkshopGroup.CurrentWorkshops
.Select(x => new GetInstitutionVerificationDetailsWorkshopsViewModel()
{
Name = x.WorkshopName,
PersonnelCount = x.PersonnelCount,
Services = new WorkshopServicesViewModel()
{
Contract = x.Services.Contract,
ContractInPerson = x.Services.ContractInPerson,
CustomizeCheckout = x.Services.CustomizeCheckout,
Insurance = x.Services.Insurance,
InsuranceInPerson = x.Services.InsuranceInPerson,
RollCall = x.Services.RollCall,
RollCallInPerson = x.Services.RollCallInPerson
},
Price = x.Price.ToMoney()
}).ToList()
};
res.Add(item);
}
return res;
}
private InstitutionContractExtensionPaymentResponse CalculateInPersonPayment(
InstitutionContractExtensionPlanDetail selectedPlan, double baseAmount, double tenPercent,
@@ -2464,7 +2789,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 +2871,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 +2879,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 +2939,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
#endregion
#region CustomViewModels

View File

@@ -1724,9 +1724,86 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
.Include(x => x.LeftWorkInsurances)
.Where(x => x.LeftWorkInsurances.Any(l => l.StartWorkDate <= firstDayOfMonth &&
(l.LeftWorkDate == null || l.LeftWorkDate >= firstDayOfMonth)));
var query = notCreatedWorkshop.Select(result=>new InsuranceListViewModel
{
Year = searchModel.Year,
Month = searchModel.Month,
WorkShopId = result.id,
WorkShopCode = result.InsuranceWorkshopInfo != null
? result.InsuranceWorkshopInfo.InsuranceCode
: result.InsuranceCode,
WorkShopName = result.InsuranceWorkshopInfo != null
? result.InsuranceWorkshopInfo.WorkshopName
: result.WorkshopFullName,
TypeOfInsuranceSend = result.TypeOfInsuranceSend == "NormalList" ? "عادی" :
result.TypeOfInsuranceSend == "Govermentlist" ? "کمک دولت" :
result.TypeOfInsuranceSend == "Familylist" ? "خانوادگی" : "",
FixedSalary = result.FixedSalary,
StrFixedSalary = result.FixedSalary ? "دارد" : "ندارد",
EmployerName = result.InsuranceWorkshopInfo != null
? result.InsuranceWorkshopInfo.EmployerName
: result.WorkshopFullName,
Branch = "",
City = "",
ArchiveCode = result.ArchiveCode,
});
if (!string.IsNullOrEmpty(searchModel.Month) && searchModel.Month != "0")
query = query.Where(x => x.Month == searchModel.Month).OrderByDescending(x => x.WorkShopName)
.ThenByDescending(x => x.EmployerName).ThenByDescending(x => x.Year);
var workshopList = await notCreatedWorkshop.Skip(searchModel.PageIndex).Take(30).ToListAsync();
var workshopIds = workshopList.Select(x=>x.id);
if (!string.IsNullOrEmpty(searchModel.Year) && searchModel.Year != "0")
query = query.Where(x => x.Year == searchModel.Year).OrderByDescending(x => x.EmployerName)
.ThenByDescending(x => x.WorkShopName).ThenByDescending(x => x.Month);
if (!string.IsNullOrEmpty(searchModel.WorkShopCode))
query = query.Where(x => x.WorkShopCode == searchModel.WorkShopCode).OrderByDescending(x => x.Year)
.ThenByDescending(x => x.Month).ThenByDescending(x => x.EmployerName);
if (!string.IsNullOrEmpty(searchModel.WorkShopName))
query = query.Where(x => x.WorkShopName.Contains(searchModel.WorkShopName))
.OrderByDescending(x => x.EmployerName).ThenByDescending(x => x.Year).OrderByDescending(x => x.Month);
if (searchModel.WorkshopId > 0)
{
var workshopName = query.FirstOrDefault(u => u.WorkShopId == searchModel.WorkshopId)?.WorkShopName;
query = query.Where(x => x.WorkShopName.Contains(workshopName)).OrderByDescending(x => x.EmployerName)
.ThenByDescending(x => x.Year).ThenByDescending(x => x.Month);
}
if (searchModel.EmployerId > 0)
{
var employerName = query.FirstOrDefault(u => u.EmployerId == searchModel.EmployerId)?.EmployerName;
query = query.Where(x => x.EmployerName.Contains(employerName)).OrderByDescending(x => x.EmployerName)
.ThenByDescending(x => x.Year).ThenByDescending(x => x.Month);
}
if (!string.IsNullOrEmpty(searchModel.EmployerName))
query = query.Where(x => x.EmployerName.Contains(searchModel.EmployerName))
.OrderByDescending(x => x.EmployerName).ThenByDescending(x => x.Year).OrderByDescending(x => x.Month);
if (searchModel.FixedSalary != null)
query = query.Where(x => x.FixedSalary == searchModel.FixedSalary);
if (!string.IsNullOrEmpty(searchModel.TypeOfInsuranceSend) && searchModel.TypeOfInsuranceSend != "0")
query = query.Where(x => x.TypeOfInsuranceSend == searchModel.TypeOfInsuranceSend);
if (!string.IsNullOrEmpty(searchModel.City) && searchModel.City != "0")
query = query.Where(x => x.City == searchModel.City);
if (!string.IsNullOrEmpty(searchModel.Branch))
query = query.Where(x => x.Branch.Contains(searchModel.Branch));
var workshopList = await query.Skip(searchModel.PageIndex).Take(30).ToListAsync();
var workshopIds = workshopList.Select(x=>x.WorkShopId);
var employers =await _context.WorkshopEmployers
.Where(x=>workshopIds.Contains(x.WorkshopId))
@@ -1735,20 +1812,16 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
var res = workshopList.Select(x =>
{
var employer = employers.FirstOrDefault(e => e.WorkshopId ==x.id)?.Employer;
var employer = employers.FirstOrDefault(e => e.WorkshopId ==x.WorkShopId)?.Employer;
return new InsuranceListViewModel
{
WorkShopId = x.id,
WorkShopCode = x.InsuranceCode,
WorkShopName = x.InsuranceWorkshopInfo != null
? x.InsuranceWorkshopInfo.WorkshopName
: x.WorkshopFullName,
WorkShopId = x.WorkShopId,
WorkShopCode = x.WorkShopCode,
WorkShopName = x.WorkShopName,
EmployerName = employer != null
? employer.FullName
: (x.InsuranceWorkshopInfo != null
? x.InsuranceWorkshopInfo.EmployerName
: x.WorkshopFullName),
: (x.EmployerName),
Year = searchModel.Year,
Month = searchModel.Month,
TypeOfInsuranceSend = x.TypeOfInsuranceSend == "NormalList" ? "عادی" :

View File

@@ -534,6 +534,222 @@ public class institutionContractController : AdminBaseController
var res = await _institutionContractApplication.ResendVerifyLink(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;
}
[HttpGet("edit-old/{id}")]
public ActionResult<EditInstitutionContract> GetEditOldDetails(long id)
{
var representativList = new List<RepresentativeViewModel>();
var contractingPartyList = new List<PersonalContractingPartyViewModel>();
var res = _institutionContractApplication.GetDetails(id);
var representative = new RepresentativeViewModel
{
Id = res.RepresentativeId,
FullName = res.RepresentativeName
};
representativList.Add(representative);
var contractingParty = new PersonalContractingPartyViewModel
{
id = res.ContractingPartyId,
FullName = _contractingPartyApplication.GetFullName(res.ContractingPartyId)
};
contractingPartyList.Add(contractingParty);
res.RepresentativeSelectList =
new SelectList(representativList, "Id", "FullName");
res.ContractingPartiesSelectList =
new SelectList(contractingPartyList, "id", "FullName");
var employer = _employerApplication.GetEmployerByContracrtingPartyID(res.ContractingPartyId);
var emplId = employer.Select(x => x.Id).ToList();
var w = _workshopApplication.GetWorkshopsByEmployerId(emplId);
var workshopIds = w.Select(x => x.Id).ToList();
var workshopCount = Convert.ToString(w.Count);
var pCount = 0;
if (workshopIds.Count > 0)
{
foreach (var workshopId in workshopIds)
{
var p = _workshopApplication.PersonnelCount(workshopId);
pCount += p;
}
res.EmployeeCount = Convert.ToString(pCount);
}
else
{
res.EmployeeCount = "0";
}
res.WorkshopCount = workshopCount;
var contactInfo = _contactInfoApplication.GetContactInfolist(id);
if (contactInfo.Count > 0)
{
res.ContactInfoCounter = contactInfo.Count;
res.ContactInformationList = contactInfo;
}
else
{
res.ContactInfoCounter = 0;
}
if (res.HasValueAddedTax == "true")
{
res.ContractAmount -= res.ValueAddedTax;
res.ContractAmountOAlone = res.ContractAmount.ToMoney();
res.ValueAddedTaxStr = res.ValueAddedTax.ToMoney();
}
else
{
res.ContractAmountOAlone = res.ContractAmountString;
res.ValueAddedTaxStr = "0";
}
return res;
}
[HttpPost("edit-old")]
public ActionResult<OperationResult> EditOld([FromBody] EditInstitutionContract command)
{
var op = new OperationResult();
var phoneNumber = command.ContactInformationList.FirstOrDefault(x =>
x.SendSmsString == "true" && x.Position == "طرف قرارداد" && x.PhoneType == "شماره همراه");
var conractingParty = _contractingPartyApplication.GetDetails(command.ContractingPartyId);
if (conractingParty.IsLegal == "حقیقی" && string.IsNullOrWhiteSpace(conractingParty.Nationalcode))
return new JsonResult(op.Failed("کد ملی طرف حساب وجود ندارد"));
if (conractingParty.IsLegal == "حقوقی" && string.IsNullOrWhiteSpace(conractingParty.NationalId))
return new JsonResult(op.Failed("شناسه ملی طرف حساب وجود ندارد"));
if (phoneNumber == null)
return new JsonResult(op.Failed("تعیین شماره همراه با سمت طرف قرارداد اجباریست"));
//if (string.IsNullOrWhiteSpace(command.HasValueAddedTax))
// command.HasValueAddedTax = "false";
var result = _institutionContractApplication.Edit(command);
var contractingPartyId = _institutionContractApplication.GetDetails(result.SendId);
var counter = command.ContactInformationList.Count;
var getOldContarct = _institutionContractApplication.NewSearch(new InstitutionContractSearchModel()
{ ContractingPartyId = contractingPartyId.ContractingPartyId, IsActiveString = "both" }).Where(x=>x.IsActiveString == "false" || x.IsActiveString == "blue").ToList();
if (result.IsSuccedded && counter > 0)
{
if (getOldContarct.Count > 0)
{
foreach (var item in getOldContarct)
{
_contactInfoApplication.RemoveContactInfo(item.Id);
foreach (var phone in command.ContactInformationList)
{
if (phone.PhoneNumber != null)
{
var contactinfo = new CreateContactInfo
{
InstitutionContractId = item.Id,
PhoneType = phone.PhoneType,
Position = phone.Position,
PhoneNumber = phone.PhoneNumber,
FnameLname = phone.FnameLname,
SendSms = phone.SendSmsString == "true" ? true : false
};
_contactInfoApplication.Create(contactinfo);
}
Thread.Sleep(500);
}
}
}
_contactInfoApplication.RemoveContactInfo(command.Id);
foreach (var item in command.ContactInformationList)
{
if (item.PhoneNumber != null)
{
var contactinfo = new CreateContactInfo
{
InstitutionContractId = result.SendId,
PhoneType = item.PhoneType,
Position = item.Position,
PhoneNumber = item.PhoneNumber,
FnameLname = item.FnameLname,
SendSms = item.SendSmsString == "true" ? true : false
};
_contactInfoApplication.Create(contactinfo);
}
Thread.Sleep(500);
}
//ساخت اکانت کلاینت
var userPass = conractingParty.IsLegal == "حقیقی"
? conractingParty.Nationalcode
: conractingParty.NationalId;
var checkExistAccount = _accountApplication.CheckExistClientAccount(userPass);
if (!checkExistAccount)
{
var createAcc = new RegisterAccount
{
Fullname = conractingParty.LName,
Username = userPass,
Password = userPass,
Mobile = phoneNumber.PhoneNumber,
NationalCode = userPass
};
var res = _accountApplication.RegisterClient(createAcc);
if (res.IsSuccedded)
_institutionContractApplication.CreateContractingPartyAccount(command.ContractingPartyId, res.SendId);
}
}
//Thread.Sleep(500);
//for (int i = 0; i <= counter - 1; i++)
//{
// if (command.ContactInformationList[i].PhoneNumber != null)
// {
// var contactinfo = new CreateContactInfo()
// {
// InstitutionContractId = result.SendId,
// PhoneType = command.ContactInformationList[i].PhoneType,
// Position = command.ContactInformationList[i].Position,
// PhoneNumber = command.ContactInformationList[i].PhoneNumber,
// FnameLname = command.ContactInformationList[i].FnameLname,
// SendSms = command.ContactInformationList[i].SendSmsString == "true" ? true : false
// };
// _contactInfoApplication.Create(contactinfo);
// }
// Thread.Sleep(500);
//}
return result;
}
[HttpGet("print/{id}")]
public async Task<ActionResult<InstitutionContractPrintViewModel>> PrintOne(long id)
{
var res =await _institutionContractApplication.PrintOneAsync(id);
return res;
}
}