From 85e2481680e0d0a6899724a6eb407b8ee94323ea Mon Sep 17 00:00:00 2001 From: mahan Date: Tue, 21 Oct 2025 13:50:42 +0330 Subject: [PATCH 1/3] feat: enhance financial statement retrieval with contracting party validation and creation --- .../Repository/FinancialStatmentRepository.cs | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/CompanyManagment.EFCore/Repository/FinancialStatmentRepository.cs b/CompanyManagment.EFCore/Repository/FinancialStatmentRepository.cs index 6e5d0617..278bc861 100644 --- a/CompanyManagment.EFCore/Repository/FinancialStatmentRepository.cs +++ b/CompanyManagment.EFCore/Repository/FinancialStatmentRepository.cs @@ -10,6 +10,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using AccountManagement.Application.Contracts.SubAccount; +using ZstdSharp.Unsafe; using static Microsoft.EntityFrameworkCore.DbLoggerCategory; namespace CompanyManagment.EFCore.Repository; @@ -266,14 +267,26 @@ public class FinancialStatmentRepository : RepositoryBase GetDetailsByContractingParty(long contractingPartyId,FinancialStatementSearchModel searchModel) { + var contractingParty = await _context.PersonalContractingParties + .FirstOrDefaultAsync(x=>x.id == contractingPartyId); + + if (contractingParty == null) + throw new NotFoundException("طرف حساب یافت نشد"); + var financialStatement = await _context.FinancialStatments .Include(x=>x.FinancialTransactionList) .FirstOrDefaultAsync(x=>x.ContractingPartyId == contractingPartyId); - + if (financialStatement == null) { - throw new NotFoundException("وضعیت مالی مورد نظر یافت نشد"); + financialStatement = new FinancialStatment(contractingPartyId,contractingParty.FName+" "+contractingParty.LName); + + await _context.AddAsync(financialStatement); + await _context.SaveChangesAsync(); } + + + bool searched = false; #region Search @@ -383,7 +396,8 @@ public class FinancialStatmentRepository : RepositoryBase x.Creditor), TotalDebt = financialStatement.FinancialTransactionList.Sum(x => x.Deptor), ContractingPartyName = financialStatement.ContractingPartyName, - List = list.OrderByDescending(x=>x.DateTimeGr).ToList(), + List = list, }; return res; } From d4c2ab939e0faba3821abb652c751fc67d54383e Mon Sep 17 00:00:00 2001 From: mahan Date: Tue, 21 Oct 2025 14:55:23 +0330 Subject: [PATCH 2/3] fix: correct workshop ID reference in employee count calculation --- .../Repository/InstitutionContractRepository.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CompanyManagment.EFCore/Repository/InstitutionContractRepository.cs b/CompanyManagment.EFCore/Repository/InstitutionContractRepository.cs index 0d523aa8..1af2342f 100644 --- a/CompanyManagment.EFCore/Repository/InstitutionContractRepository.cs +++ b/CompanyManagment.EFCore/Repository/InstitutionContractRepository.cs @@ -1309,7 +1309,7 @@ public class InstitutionContractRepository : RepositoryBase workshops.Select(w => w.id).Contains(l.id)) + .Where(l => workshops.Select(w => w.id).Contains(l.WorkshopId)) .Count(l => l.StartWorkDate <= DateTime.Now && l.LeftWorkDate >= DateTime.Now), EmployerNames = employers.Select(e => e.FullName).ToList(), ListStatus = status, From 68f1f81b5337e5affef2b47a98fbd72554d23a52 Mon Sep 17 00:00:00 2001 From: mahan Date: Tue, 21 Oct 2025 15:05:48 +0330 Subject: [PATCH 3/3] feat: add BSON representation for Id property in InstitutionContractAmendmentTemp --- .../InstitutionContractAmendmentTemp.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Company.Domain/InstitutionContractAmendmentTempAgg/InstitutionContractAmendmentTemp.cs b/Company.Domain/InstitutionContractAmendmentTempAgg/InstitutionContractAmendmentTemp.cs index 7c13616a..bac4cd56 100644 --- a/Company.Domain/InstitutionContractAmendmentTempAgg/InstitutionContractAmendmentTemp.cs +++ b/Company.Domain/InstitutionContractAmendmentTempAgg/InstitutionContractAmendmentTemp.cs @@ -79,6 +79,7 @@ public class InstitutionContractAmendmentTempPrevWorkshop CurrentWorkshopId = currentWorkshopId; } + [BsonRepresentation(BsonType.String)] public Guid Id { get; set; } public long CurrentWorkshopId { get; private set; }