feat: add installment management to InstitutionContract and related classes
This commit is contained in:
@@ -37,4 +37,12 @@ public class FinancialStatment : EntityBase
|
|||||||
{
|
{
|
||||||
PublicId = Guid.NewGuid();
|
PublicId = Guid.NewGuid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AddFinancialTransaction(FinancialTransaction financialTransaction)
|
||||||
|
{
|
||||||
|
if (financialTransaction == null)
|
||||||
|
throw new ArgumentNullException(nameof(financialTransaction));
|
||||||
|
FinancialTransactionList.Add(financialTransaction);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
|
using _0_Framework.Application;
|
||||||
using _0_Framework.Domain;
|
using _0_Framework.Domain;
|
||||||
using Company.Domain.InstitutionContractContactInfoAgg;
|
using Company.Domain.InstitutionContractContactInfoAgg;
|
||||||
using CompanyManagment.App.Contracts.InstitutionContract;
|
using CompanyManagment.App.Contracts.InstitutionContract;
|
||||||
@@ -50,6 +51,7 @@ public class InstitutionContract : EntityBase
|
|||||||
Status = InstitutionContractStatus.Incomplete;
|
Status = InstitutionContractStatus.Incomplete;
|
||||||
ContactInfoList = [];
|
ContactInfoList = [];
|
||||||
WorkshopDetails = [];
|
WorkshopDetails = [];
|
||||||
|
Installments = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public string ContractNo { get; private set; }
|
public string ContractNo { get; private set; }
|
||||||
@@ -98,10 +100,13 @@ public class InstitutionContract : EntityBase
|
|||||||
|
|
||||||
public List<InstitutionContractContactInfo> ContactInfoList { get; set; }
|
public List<InstitutionContractContactInfo> ContactInfoList { get; set; }
|
||||||
|
|
||||||
|
public List<InstitutionContractInstallment> Installments { get; set; }
|
||||||
|
|
||||||
public InstitutionContract()
|
public InstitutionContract()
|
||||||
{
|
{
|
||||||
ContactInfoList = new List<InstitutionContractContactInfo>();
|
ContactInfoList = [];
|
||||||
WorkshopDetails = new List<InstitutionContractWorkshopDetail>();
|
WorkshopDetails = [];
|
||||||
|
Installments = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Edit(DateTime contractDateGr, string contractDateFa, string state, string city, string address,
|
public void Edit(DateTime contractDateGr, string contractDateFa, string state, string city, string address,
|
||||||
@@ -168,6 +173,11 @@ public class InstitutionContract : EntityBase
|
|||||||
{
|
{
|
||||||
WorkshopDetails = commandWorkshops;
|
WorkshopDetails = commandWorkshops;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetInstallments(List<InstitutionContractInstallment> installments)
|
||||||
|
{
|
||||||
|
Installments = installments;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class InstitutionContractWorkshopDetail:EntityBase
|
public class InstitutionContractWorkshopDetail:EntityBase
|
||||||
@@ -242,4 +252,26 @@ public enum InstitutionContractStatus
|
|||||||
/// تکمیل شده - قرارداد به طور کامل انجام شده و نهایی شده است
|
/// تکمیل شده - قرارداد به طور کامل انجام شده و نهایی شده است
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Completed = 1
|
Completed = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
public class InstitutionContractInstallment
|
||||||
|
{
|
||||||
|
public InstitutionContractInstallment(DateTime installmentDateGr, double amount,
|
||||||
|
string description)
|
||||||
|
{
|
||||||
|
InstallmentDateGr = installmentDateGr;
|
||||||
|
InstallmentDateFa = installmentDateGr.ToFarsi();
|
||||||
|
Amount = amount;
|
||||||
|
Description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long Id { get; private set; }
|
||||||
|
public DateTime InstallmentDateGr { get; private set; }
|
||||||
|
public string InstallmentDateFa { get; private set; }
|
||||||
|
public double Amount { get; private set; }
|
||||||
|
public string Description { get; private set; }
|
||||||
|
|
||||||
|
public long InstitutionContractId { get; private set; }
|
||||||
|
|
||||||
|
public InstitutionContract InstitutionContract { get; private set; }
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -10,53 +11,149 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
|
|
||||||
namespace CompanyManagment.App.Contracts.InstitutionContract;
|
namespace CompanyManagment.App.Contracts.InstitutionContract;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// رابط اپلیکیشن قراردادهای مؤسسه
|
||||||
|
/// مدیریت عملیات مربوط به قراردادهای مالی مؤسسات
|
||||||
|
/// </summary>
|
||||||
public interface IInstitutionContractApplication
|
public interface IInstitutionContractApplication
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// ایجاد قرارداد جدید
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="command">اطلاعات قرارداد جدید</param>
|
||||||
|
/// <returns>نتیجه عملیات</returns>
|
||||||
OperationResult Create(CreateInstitutionContract command);
|
OperationResult Create(CreateInstitutionContract command);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// تمدید قرارداد موجود
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="command">اطلاعات قرارداد برای تمدید</param>
|
||||||
|
/// <returns>نتیجه عملیات</returns>
|
||||||
OperationResult Extension(CreateInstitutionContract command);
|
OperationResult Extension(CreateInstitutionContract command);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ویرایش قرارداد موجود
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="command">اطلاعات جدید قرارداد</param>
|
||||||
|
/// <returns>نتیجه عملیات</returns>
|
||||||
OperationResult Edit(EditInstitutionContract command);
|
OperationResult Edit(EditInstitutionContract command);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// دریافت جزئیات قرارداد برای ویرایش
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">شناسه قرارداد</param>
|
||||||
|
/// <returns>اطلاعات قرارداد</returns>
|
||||||
EditInstitutionContract GetDetails(long id);
|
EditInstitutionContract GetDetails(long id);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// جستجو در قراردادها
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="searchModel">مدل جستجو</param>
|
||||||
|
/// <returns>لیست قراردادها</returns>
|
||||||
List<InstitutionContractViewModel> Search(InstitutionContractSearchModel searchModel);
|
List<InstitutionContractViewModel> Search(InstitutionContractSearchModel searchModel);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// جستجوی جدید در قراردادها
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="searchModel">مدل جستجو</param>
|
||||||
|
/// <returns>لیست قراردادها</returns>
|
||||||
List<InstitutionContractViewModel> NewSearch(InstitutionContractSearchModel searchModel);
|
List<InstitutionContractViewModel> NewSearch(InstitutionContractSearchModel searchModel);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// دریافت اطلاعات قزداد های مالی فعال
|
/// دریافت اطلاعات قرارداد های مالی فعال
|
||||||
///دارای کارگاه
|
///دارای کارگاه
|
||||||
/// جهت ست کردن سرویس ها از طریق اکسل
|
/// جهت ست کردن سرویس ها از طریق اکسل
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
List<InstitutionContractViewModel> GetInstitutionContractToSetServicesExcelImport();
|
List<InstitutionContractViewModel> GetInstitutionContractToSetServicesExcelImport();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// چاپ مجموعه قراردادها
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">لیست شناسه قراردادها</param>
|
||||||
|
/// <returns>لیست قراردادها برای چاپ</returns>
|
||||||
List<InstitutionContractViewModel> PrintAll(List<long> id);
|
List<InstitutionContractViewModel> PrintAll(List<long> id);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// چاپ یک قرارداد
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">شناسه قرارداد</param>
|
||||||
|
/// <returns>اطلاعات قرارداد برای چاپ</returns>
|
||||||
InstitutionContractViewModel PrintOne(long id);
|
InstitutionContractViewModel PrintOne(long id);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// فعال کردن قرارداد
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">شناسه قرارداد</param>
|
||||||
|
/// <returns>نتیجه عملیات</returns>
|
||||||
OperationResult Active(long id);
|
OperationResult Active(long id);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// غیرفعال کردن قرارداد
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">شناسه قرارداد</param>
|
||||||
|
/// <returns>نتیجه عملیات</returns>
|
||||||
OperationResult DeActive(long id);
|
OperationResult DeActive(long id);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// غیرفعال کردن قرارداد (حالت آبی)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">شناسه قرارداد</param>
|
||||||
|
/// <returns>نتیجه عملیات</returns>
|
||||||
OperationResult DeActiveBlue(long id);
|
OperationResult DeActiveBlue(long id);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// غیرفعال کردن تمام اتصالات قرارداد
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">شناسه قرارداد</param>
|
||||||
|
/// <returns>نتیجه عملیات</returns>
|
||||||
OperationResult DeActiveAllConnections(long id);
|
OperationResult DeActiveAllConnections(long id);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// فعال کردن مجدد تمام اتصالات قرارداد
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">شناسه قرارداد</param>
|
||||||
|
/// <returns>نتیجه عملیات</returns>
|
||||||
OperationResult ReActiveAllConnections(long id);
|
OperationResult ReActiveAllConnections(long id);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// فعال کردن مجدد تمام قراردادها بعد از ایجاد قرارداد جدید
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="contractingPartyId">شناسه طرف قرارداد</param>
|
||||||
void ReActiveAllAfterCreateNew(long contractingPartyId);
|
void ReActiveAllAfterCreateNew(long contractingPartyId);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// حذف قرارداد
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">شناسه قرارداد</param>
|
||||||
void RemoveContract(long id);
|
void RemoveContract(long id);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// امضای قرارداد
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">شناسه قرارداد</param>
|
||||||
|
/// <returns>نتیجه عملیات</returns>
|
||||||
OperationResult Sign(long id);
|
OperationResult Sign(long id);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// لغو امضای قرارداد
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">شناسه قرارداد</param>
|
||||||
|
/// <returns>نتیجه عملیات</returns>
|
||||||
OperationResult UnSign(long id);
|
OperationResult UnSign(long id);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ایجاد حساب کاربری برای طرف قرارداد
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="contractingPartyid">شناسه طرف قرارداد</param>
|
||||||
|
/// <param name="accountId">شناسه حساب کاربری</param>
|
||||||
void CreateContractingPartyAccount(long contractingPartyid, long accountId);
|
void CreateContractingPartyAccount(long contractingPartyid, long accountId);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// محاسبه مبلغ قرارداد بر اساس تعداد افراد
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="countPerson">تعداد افراد</param>
|
||||||
|
/// <returns>مبلغ قرارداد</returns>
|
||||||
double GetcontractAmount(int countPerson);
|
double GetcontractAmount(int countPerson);
|
||||||
|
|
||||||
#region Api
|
#region Api
|
||||||
@@ -82,53 +179,110 @@ public interface IInstitutionContractApplication
|
|||||||
/// <param name="command"></param>
|
/// <param name="command"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<OperationResult> CreateAsync(CreateInstitutionContractRequest command);
|
Task<OperationResult> CreateAsync(CreateInstitutionContractRequest command);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ویرایش
|
/// ویرایش
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="command"></param>
|
/// <param name="command"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<OperationResult> EditAsync(EditInstitutionContractRequest command);
|
Task<OperationResult> EditAsync(EditInstitutionContractRequest command);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// تمدید قرارداد
|
/// تمدید قرارداد
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="command"></param>
|
/// <param name="command"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<OperationResult> ExtensionَAsync(CreateInstitutionContractRequest command);
|
Task<OperationResult> ExtensionَAsync(CreateInstitutionContractRequest command);
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GetInstitutionContractListStatsViewModel
|
public class GetInstitutionContractListStatsViewModel
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents the total outstanding debt of institution contracts.
|
/// مجموع بدهی قراردادهای مؤسسه
|
||||||
/// This property aggregates the liabilities of the respective contracts and provides
|
/// این ویژگی بدهیهای قراردادهای مربوطه را تجمیع میکند و
|
||||||
/// a single metric to measure financial obligations.
|
/// یک معیار واحد برای اندازهگیری تعهدات مالی ارائه میدهد
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double TotalDebt { get; set; }
|
public double TotalDebt { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents the total monetary value associated with institution contracts.
|
/// مجموع ارزش پولی مرتبط با قراردادهای مؤسسه
|
||||||
/// This property consolidates the aggregate amount from relevant contracts
|
/// این ویژگی مبلغ کل قراردادهای مربوطه را برای
|
||||||
/// for financial reporting and analysis.
|
/// گزارشگیری و تجزیه و تحلیل مالی تجمیع میکند
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double TotalAmount { get; set; }
|
public double TotalAmount { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a collection of counts for institution contracts categorized by their status.
|
/// مجموعهای از تعداد قراردادهای مؤسسه دستهبندی شده بر اساس وضعیت
|
||||||
/// This property provides the count of contracts for each status defined in the
|
/// این ویژگی تعداد قراردادها را برای هر وضعیت تعریف شده در
|
||||||
/// InstitutionContractStatus enumeration, enabling analysis and monitoring of contract distribution.
|
/// شمارش InstitutionContractStatus ارائه میدهد که امکان تجزیه و تحلیل و نظارت بر توزیع قراردادها را فراهم میکند
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<InstitutionContractStatusCount> Counts { get; set; }
|
public List<InstitutionContractStatusCount> Counts { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// شمارش وضعیت قراردادهای مؤسسه
|
||||||
|
/// نمایش تعداد قراردادها برای هر وضعیت خاص
|
||||||
|
/// </summary>
|
||||||
public class InstitutionContractStatusCount
|
public class InstitutionContractStatusCount
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// وضعیت لیست قرارداد
|
||||||
|
/// </summary>
|
||||||
public InstitutionContractListStatus ListStatus { get; set; }
|
public InstitutionContractListStatus ListStatus { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// تعداد قراردادها در این وضعیت
|
||||||
|
/// </summary>
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
}
|
}
|
||||||
public class ExtenstionInstitutionContractRequest:EditInstitutionContractRequest
|
|
||||||
|
/// <summary>
|
||||||
|
/// درخواست تمدید قرارداد مؤسسه
|
||||||
|
/// شامل اطلاعات قرارداد قبلی برای فرآیند تمدید
|
||||||
|
/// </summary>
|
||||||
|
public class ExtenstionInstitutionContractRequest : EditInstitutionContractRequest
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// شناسه قرارداد قبلی که قرار است تمدید شود
|
||||||
|
/// </summary>
|
||||||
public long PreviousContractId { get; set; }
|
public long PreviousContractId { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// مدل نمایش اقساط قرارداد مؤسسه
|
||||||
|
/// شامل اطلاعات مربوط به هر قسط از قرارداد
|
||||||
|
/// </summary>
|
||||||
|
public class InstitutionContractInstallmentViewModel
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// شناسه یکتای قسط
|
||||||
|
/// </summary>
|
||||||
|
public long Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// تاریخ میلادی قسط
|
||||||
|
/// </summary>
|
||||||
|
public DateTime InstallmentDateGr { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// تاریخ فارسی قسط
|
||||||
|
/// </summary>
|
||||||
|
public string InstallmentDateFa { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// مبلغ قسط
|
||||||
|
/// </summary>
|
||||||
|
public double Amount { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// توضیحات قسط
|
||||||
|
/// </summary>
|
||||||
|
public string Description { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// شناسه قرارداد مؤسسه مربوط به این قسط
|
||||||
|
/// </summary>
|
||||||
|
public long InstitutionContractId { get; set; }
|
||||||
}
|
}
|
||||||
@@ -9,6 +9,8 @@ using _0_Framework.Exceptions;
|
|||||||
using Company.Domain.ContarctingPartyAgg;
|
using Company.Domain.ContarctingPartyAgg;
|
||||||
using Company.Domain.EmployeeAgg;
|
using Company.Domain.EmployeeAgg;
|
||||||
using Company.Domain.empolyerAgg;
|
using Company.Domain.empolyerAgg;
|
||||||
|
using Company.Domain.FinancialStatmentAgg;
|
||||||
|
using Company.Domain.FinancialTransactionAgg;
|
||||||
using Company.Domain.InstitutionContractAgg;
|
using Company.Domain.InstitutionContractAgg;
|
||||||
using Company.Domain.LeftWorkAgg;
|
using Company.Domain.LeftWorkAgg;
|
||||||
using Company.Domain.RepresentativeAgg;
|
using Company.Domain.RepresentativeAgg;
|
||||||
@@ -21,6 +23,7 @@ using CompanyManagment.App.Contracts.Workshop;
|
|||||||
using CompanyManagment.EFCore.Migrations;
|
using CompanyManagment.EFCore.Migrations;
|
||||||
using PersianTools.Core;
|
using PersianTools.Core;
|
||||||
using ConnectedPersonnelViewModel = CompanyManagment.App.Contracts.Workshop.ConnectedPersonnelViewModel;
|
using ConnectedPersonnelViewModel = CompanyManagment.App.Contracts.Workshop.ConnectedPersonnelViewModel;
|
||||||
|
using FinancialStatment = Company.Domain.FinancialStatmentAgg.FinancialStatment;
|
||||||
|
|
||||||
namespace CompanyManagment.Application;
|
namespace CompanyManagment.Application;
|
||||||
|
|
||||||
@@ -35,6 +38,7 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
|||||||
private readonly ILeftWorkRepository _leftWorkRepository;
|
private readonly ILeftWorkRepository _leftWorkRepository;
|
||||||
private readonly IWorkshopApplication _workshopApplication;
|
private readonly IWorkshopApplication _workshopApplication;
|
||||||
private readonly IContractingPartyTempRepository _contractingPartyTempRepository;
|
private readonly IContractingPartyTempRepository _contractingPartyTempRepository;
|
||||||
|
private readonly IFinancialStatmentRepository _financialStatmentRepository;
|
||||||
|
|
||||||
|
|
||||||
public InstitutionContractApplication(IInstitutionContractRepository institutionContractRepository,
|
public InstitutionContractApplication(IInstitutionContractRepository institutionContractRepository,
|
||||||
@@ -42,7 +46,7 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
|||||||
IRepresentativeRepository representativeRepository, IEmployerRepository employerRepository,
|
IRepresentativeRepository representativeRepository, IEmployerRepository employerRepository,
|
||||||
IWorkshopRepository workshopRepository, ILeftWorkRepository leftWorkRepository,
|
IWorkshopRepository workshopRepository, ILeftWorkRepository leftWorkRepository,
|
||||||
IFinancialStatmentApplication financialStatmentApplication, IWorkshopApplication workshopApplication,
|
IFinancialStatmentApplication financialStatmentApplication, IWorkshopApplication workshopApplication,
|
||||||
IContractingPartyTempRepository contractingPartyTempRepository)
|
IContractingPartyTempRepository contractingPartyTempRepository, IFinancialStatmentRepository financialStatmentRepository)
|
||||||
{
|
{
|
||||||
_institutionContractRepository = institutionContractRepository;
|
_institutionContractRepository = institutionContractRepository;
|
||||||
_contractingPartyRepository = contractingPartyRepository;
|
_contractingPartyRepository = contractingPartyRepository;
|
||||||
@@ -53,6 +57,7 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
|||||||
_financialStatmentApplication = financialStatmentApplication;
|
_financialStatmentApplication = financialStatmentApplication;
|
||||||
_workshopApplication = workshopApplication;
|
_workshopApplication = workshopApplication;
|
||||||
_contractingPartyTempRepository = contractingPartyTempRepository;
|
_contractingPartyTempRepository = contractingPartyTempRepository;
|
||||||
|
_financialStatmentRepository = financialStatmentRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OperationResult Create(CreateInstitutionContract command)
|
public OperationResult Create(CreateInstitutionContract command)
|
||||||
@@ -937,42 +942,72 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
|||||||
|
|
||||||
contractStartGr.AddMonthsFa((int)command.Duration, out var contractEndGr);
|
contractStartGr.AddMonthsFa((int)command.Duration, out var contractEndGr);
|
||||||
contractEndGr = contractEndGr.ToFarsi().FindeEndOfMonth().ToGeorgianDateTime();
|
contractEndGr = contractEndGr.ToFarsi().FindeEndOfMonth().ToGeorgianDateTime();
|
||||||
var contractDateGr = DateTime.Today;
|
|
||||||
|
var today = DateTime.Today;
|
||||||
|
|
||||||
|
var contractDateGr = today;
|
||||||
var contractDateFa = contractDateGr.ToFarsi();
|
var contractDateFa = contractDateGr.ToFarsi();
|
||||||
|
|
||||||
|
|
||||||
//Todo: Calculate Amount.
|
//Todo: Calculate Amount.
|
||||||
double contractAmount = 0;
|
|
||||||
|
|
||||||
if (command.IsInstallment)
|
var hasValueAddedTax = command.TaxAmount > 0 ? "true" : "false";
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
var hasValueAddedTax = command.TaxAmount> 0 ? "true" : "false";
|
|
||||||
|
|
||||||
var contractingPartyFullName = contractingParty.FName + " " + contractingParty.LName;
|
var contractingPartyFullName = contractingParty.FName + " " + contractingParty.LName;
|
||||||
|
|
||||||
var entity = new InstitutionContract(contractNo, command.RepresentativeId, representative.FullName,
|
var entity = new InstitutionContract(contractNo, command.RepresentativeId, representative.FullName,
|
||||||
contractingParty.id,
|
contractingParty.id,
|
||||||
contractingPartyFullName, contractDateGr, contractDateFa, command.Province, command.City, command.Address,
|
contractingPartyFullName, contractDateGr, contractDateFa, command.Province, command.City, command.Address,
|
||||||
contractStartGr,
|
contractStartGr,
|
||||||
contractStartGr.ToFarsi(), contractEndGr, contractEndGr.ToFarsi(),contractAmount, command.DailyCompensation,
|
contractStartGr.ToFarsi(), contractEndGr, contractEndGr.ToFarsi(), 0, command.DailyCompensation,
|
||||||
command.Obligation,command.TotalAmount, 0,
|
command.Obligation, command.TotalAmount, 0,
|
||||||
command.Workshops.Count.ToString(),
|
command.Workshops.Count.ToString(),
|
||||||
command.Workshops.Sum(x => x.PersonnelCount).ToString(), command.Description,
|
command.Workshops.Sum(x => x.PersonnelCount).ToString(), command.Description,
|
||||||
"Official", "JobRelation",hasValueAddedTax
|
"NotOfficial", "JobRelation", hasValueAddedTax
|
||||||
, command.TaxAmount);
|
, command.TaxAmount);
|
||||||
|
|
||||||
|
|
||||||
var workshopDetails = command.Workshops.Select(x =>
|
var workshopDetails = command.Workshops.Select(x =>
|
||||||
new InstitutionContractWorkshopDetail(x.WorkshopName, x.HasRollCallPlan, x.HasCustomizeCheckoutPlan,
|
new InstitutionContractWorkshopDetail(x.WorkshopName, x.HasRollCallPlan, x.HasCustomizeCheckoutPlan,
|
||||||
x.HasContractPlan, x.PersonnelCount)).ToList();
|
x.HasContractPlan, x.PersonnelCount)).ToList();
|
||||||
|
|
||||||
|
var financialStatement = new FinancialStatment(contractingParty.id,contractingPartyFullName);
|
||||||
|
|
||||||
|
if (command.IsInstallment)
|
||||||
|
{
|
||||||
|
var installments =
|
||||||
|
CalculateInstallment(command.TotalAmount, (int)command.Duration, command.ContractStartFa, true);
|
||||||
|
|
||||||
|
// دریافت مبلغ اولین قسط
|
||||||
|
//این کار برای این هست که اولین قسط باید با تاریخ امروز باشد و باید به وضعیت مالی بدهی ایجاد شود که یوزر اولین بدهی را وارد کند
|
||||||
|
var firstInstallmentAmount = installments.First().Amount;
|
||||||
|
|
||||||
|
// حذف اولین قسط
|
||||||
|
installments.RemoveAt(0);
|
||||||
|
|
||||||
|
// ایجاد قسط جدید با تاریخ امروز
|
||||||
|
var todayInstallment = new InstitutionContractInstallment(DateTime.Today, firstInstallmentAmount, "");
|
||||||
|
|
||||||
|
var financialTransaction = new FinancialTransaction(0,today,today.ToFarsi(),
|
||||||
|
"قسط اول سرویس", "debt","بابت خدمات",firstInstallmentAmount,0,0);
|
||||||
|
|
||||||
|
financialStatement.AddFinancialTransaction(financialTransaction);
|
||||||
|
|
||||||
|
// اضافه کردن قسط جدید به ابتدای لیست
|
||||||
|
installments.Insert(0, todayInstallment);
|
||||||
|
|
||||||
|
entity.SetInstallments(installments);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var financialTransaction = new FinancialTransaction(0, today, today.ToFarsi(),
|
||||||
|
"پرداخت کل سرویس", "debt", "بابت خدمات", command.TotalAmount, 0, 0);
|
||||||
|
financialStatement.AddFinancialTransaction(financialTransaction);
|
||||||
|
}
|
||||||
|
|
||||||
entity.SetWorkshopDetails(workshopDetails);
|
entity.SetWorkshopDetails(workshopDetails);
|
||||||
|
await _financialStatmentRepository.CreateAsync(financialStatement);
|
||||||
await _institutionContractRepository.CreateAsync(entity);
|
await _institutionContractRepository.CreateAsync(entity);
|
||||||
await _institutionContractRepository.SaveChangesAsync();
|
await _institutionContractRepository.SaveChangesAsync();
|
||||||
await transaction.CommitAsync();
|
await transaction.CommitAsync();
|
||||||
@@ -1025,7 +1060,7 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
|||||||
"*", "*", request.RegisterId, request.NationalId,
|
"*", "*", request.RegisterId, request.NationalId,
|
||||||
"حقوقی",
|
"حقوقی",
|
||||||
request.PhoneNumber, request.PhoneNumber, null, representativeId, representative.FullName,
|
request.PhoneNumber, request.PhoneNumber, null, representativeId, representative.FullName,
|
||||||
archiveCode, null, null, null, null,request.Position);
|
archiveCode, null, null, null, null, request.Position);
|
||||||
|
|
||||||
|
|
||||||
await _contractingPartyRepository.CreateAsync(legalContractingParty);
|
await _contractingPartyRepository.CreateAsync(legalContractingParty);
|
||||||
@@ -1075,6 +1110,97 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
|||||||
|
|
||||||
return operation.Succcedded(personalContractingParty);
|
return operation.Succcedded(personalContractingParty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<InstitutionContractInstallment> CalculateInstallment(double amount, int installmentCount,
|
||||||
|
string loanStartDate, bool getRounded)
|
||||||
|
{
|
||||||
|
int day = Convert.ToInt32(loanStartDate.Substring(8, 2));
|
||||||
|
int month = Convert.ToInt32(loanStartDate.Substring(5, 2));
|
||||||
|
int year = Convert.ToInt32(loanStartDate.Substring(0, 4));
|
||||||
|
|
||||||
|
var installments = new List<InstitutionContractInstallment>();
|
||||||
|
|
||||||
|
|
||||||
|
bool endOfMonth = day == 31;
|
||||||
|
|
||||||
|
|
||||||
|
var dividedAmount = amount / installmentCount;
|
||||||
|
|
||||||
|
double moneyPerMonth = 0;
|
||||||
|
|
||||||
|
if (getRounded)
|
||||||
|
moneyPerMonth = Math.Floor(dividedAmount / 1000) * 1000;
|
||||||
|
else
|
||||||
|
moneyPerMonth = Math.Floor(dividedAmount);
|
||||||
|
|
||||||
|
double lastLoan = amount - (moneyPerMonth * (installmentCount - 1));
|
||||||
|
|
||||||
|
if (endOfMonth)
|
||||||
|
{
|
||||||
|
for (int i = 1; i < installmentCount; i++)
|
||||||
|
{
|
||||||
|
var installment =
|
||||||
|
new InstitutionContractInstallment(loanStartDate.ToGeorgianDateTime(), moneyPerMonth, "");
|
||||||
|
|
||||||
|
installments.Add(installment);
|
||||||
|
|
||||||
|
if (month == 12)
|
||||||
|
{
|
||||||
|
year++;
|
||||||
|
month = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
month++;
|
||||||
|
}
|
||||||
|
|
||||||
|
loanStartDate = $"{year:0000}/{month:00}/01".FindeEndOfMonth();
|
||||||
|
}
|
||||||
|
|
||||||
|
var lastInstallment = new InstitutionContractInstallment(loanStartDate.ToGeorgianDateTime(), lastLoan, "");
|
||||||
|
|
||||||
|
installments.Add(lastInstallment);
|
||||||
|
return installments;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int i = 1; i < installmentCount; i++)
|
||||||
|
{
|
||||||
|
var installment =
|
||||||
|
new InstitutionContractInstallment(loanStartDate.ToGeorgianDateTime(), moneyPerMonth, "");
|
||||||
|
|
||||||
|
installments.Add(installment);
|
||||||
|
var endDay = 0;
|
||||||
|
|
||||||
|
if (month == 12)
|
||||||
|
{
|
||||||
|
year++;
|
||||||
|
month = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
month++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (day == 30)
|
||||||
|
{
|
||||||
|
if (month == 12)
|
||||||
|
{
|
||||||
|
var lastYearDay =
|
||||||
|
Convert.ToInt32($"{year:0000}/{month:00}/1".FindeEndOfMonth().Substring(8, 2));
|
||||||
|
endDay = lastYearDay == 30 ? lastYearDay : 29;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
loanStartDate =
|
||||||
|
endDay == 0 ? $"{year:0000}/{month:00}/{day:00}" : $"{year:0000}/{month:00}/{endDay:00}";
|
||||||
|
}
|
||||||
|
|
||||||
|
var lastInstallment = new InstitutionContractInstallment(loanStartDate.ToGeorgianDateTime(), lastLoan, "");
|
||||||
|
installments.Add(lastInstallment);
|
||||||
|
return installments;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#region CustomViewModels
|
#region CustomViewModels
|
||||||
|
|||||||
@@ -200,7 +200,8 @@ public class LoanApplication : ILoanApplication
|
|||||||
DateGr = loanStartDate.ToGeorgianDateTime(),
|
DateGr = loanStartDate.ToGeorgianDateTime(),
|
||||||
Month = loanStartDate.Substring(5, 2),
|
Month = loanStartDate.Substring(5, 2),
|
||||||
Year = loanStartDate.Substring(0, 4),
|
Year = loanStartDate.Substring(0, 4),
|
||||||
Day = loanStartDate.Substring(8, 2)
|
Day = loanStartDate.Substring(8, 2),
|
||||||
|
AmountDouble = moneyPerMonth
|
||||||
};
|
};
|
||||||
|
|
||||||
installments.Add(installment);
|
installments.Add(installment);
|
||||||
@@ -225,7 +226,8 @@ public class LoanApplication : ILoanApplication
|
|||||||
DateGr = loanStartDate.ToGeorgianDateTime(),
|
DateGr = loanStartDate.ToGeorgianDateTime(),
|
||||||
Month = loanStartDate.Substring(5, 2),
|
Month = loanStartDate.Substring(5, 2),
|
||||||
Year = loanStartDate.Substring(0, 4),
|
Year = loanStartDate.Substring(0, 4),
|
||||||
Day = loanStartDate.Substring(8, 2)
|
Day = loanStartDate.Substring(8, 2),
|
||||||
|
AmountDouble = lastLoan
|
||||||
|
|
||||||
};
|
};
|
||||||
installments.Add(lastInstallment);
|
installments.Add(lastInstallment);
|
||||||
@@ -243,7 +245,8 @@ public class LoanApplication : ILoanApplication
|
|||||||
DateGr = loanStartDate.ToGeorgianDateTime(),
|
DateGr = loanStartDate.ToGeorgianDateTime(),
|
||||||
Month = loanStartDate.Substring(5, 2),
|
Month = loanStartDate.Substring(5, 2),
|
||||||
Year = loanStartDate.Substring(0, 4),
|
Year = loanStartDate.Substring(0, 4),
|
||||||
Day = loanStartDate.Substring(8, 2)
|
Day = loanStartDate.Substring(8, 2),
|
||||||
|
AmountDouble = moneyPerMonth
|
||||||
};
|
};
|
||||||
|
|
||||||
installments.Add(installment);
|
installments.Add(installment);
|
||||||
@@ -278,7 +281,8 @@ public class LoanApplication : ILoanApplication
|
|||||||
DateGr = loanStartDate.ToGeorgianDateTime(),
|
DateGr = loanStartDate.ToGeorgianDateTime(),
|
||||||
Month = loanStartDate.Substring(5, 2),
|
Month = loanStartDate.Substring(5, 2),
|
||||||
Year = loanStartDate.Substring(0, 4),
|
Year = loanStartDate.Substring(0, 4),
|
||||||
Day = loanStartDate.Substring(8, 2)
|
Day = loanStartDate.Substring(8, 2),
|
||||||
|
AmountDouble = lastLoan
|
||||||
|
|
||||||
};
|
};
|
||||||
installments.Add(lastInstallment);
|
installments.Add(lastInstallment);
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
using Company.Domain.InstitutionContractAgg;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||||
|
|
||||||
|
namespace CompanyManagment.EFCore.Mapping;
|
||||||
|
|
||||||
|
public class InstitutionContractInstallmentMapping : IEntityTypeConfiguration<InstitutionContractInstallment>
|
||||||
|
{
|
||||||
|
public void Configure(EntityTypeBuilder<InstitutionContractInstallment> builder)
|
||||||
|
{
|
||||||
|
builder.ToTable("InstitutionContractInstallments");
|
||||||
|
builder.HasKey(x => x.Id);
|
||||||
|
|
||||||
|
builder.Property(x => x.InstallmentDateFa).HasMaxLength(10).IsRequired();
|
||||||
|
builder.Property(x => x.Description).HasMaxLength(1000);
|
||||||
|
builder.Property(x => x.Amount).IsRequired();
|
||||||
|
|
||||||
|
builder.HasOne(x => x.InstitutionContract)
|
||||||
|
.WithMany(x => x.Installments)
|
||||||
|
.HasForeignKey(x => x.InstitutionContractId)
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -37,7 +37,9 @@ public class InstitutionContractMapping : IEntityTypeConfiguration<InstitutionCo
|
|||||||
workshopDetail.Property(x => x.WorkshopId).IsRequired(false);
|
workshopDetail.Property(x => x.WorkshopId).IsRequired(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
builder.HasMany(x => x.Installments)
|
||||||
|
.WithOne(x => x.InstitutionContract)
|
||||||
|
.HasForeignKey(x => x.InstitutionContractId);
|
||||||
|
|
||||||
builder.HasMany(x => x.ContactInfoList)
|
builder.HasMany(x => x.ContactInfoList)
|
||||||
.WithOne(x => x.InstitutionContracts)
|
.WithOne(x => x.InstitutionContracts)
|
||||||
|
|||||||
@@ -2,5 +2,6 @@
|
|||||||
<s:Boolean x:Key="/Default/CodeEditing/SuppressNullableWarningFix/Enabled/@EntryValue">False</s:Boolean>
|
<s:Boolean x:Key="/Default/CodeEditing/SuppressNullableWarningFix/Enabled/@EntryValue">False</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Aqaye/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Aqaye/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Govermentlist/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Govermentlist/@EntryIndexedValue">True</s:Boolean>
|
||||||
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=managment/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Mcls/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Mcls/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Pardakht/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Pardakht/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
||||||
Reference in New Issue
Block a user