diff --git a/Company.Domain/InstitutionContractAgg/InstitutionContract.cs b/Company.Domain/InstitutionContractAgg/InstitutionContract.cs index 3984f44a..84535d30 100644 --- a/Company.Domain/InstitutionContractAgg/InstitutionContract.cs +++ b/Company.Domain/InstitutionContractAgg/InstitutionContract.cs @@ -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; 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; } 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; } 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,