diff --git a/docs/api/administration-service.yaml b/docs/api/administration-service.yaml index a4302d81ad..db1064bc26 100644 --- a/docs/api/administration-service.yaml +++ b/docs/api/administration-service.yaml @@ -6412,8 +6412,18 @@ components: companyId: type: string format: uuid + bpn: + type: string + nullable: true name: type: string + shortName: + type: string + nullable: true + skippedDate: + type: string + format: date-time + nullable: true additionalProperties: false CompanyMissingSdDocumentDataResponse: type: object diff --git a/src/portalbackend/PortalBackend.DBAccess/Models/CompanyMissingSdDocumentData.cs b/src/portalbackend/PortalBackend.DBAccess/Models/CompanyMissingSdDocumentData.cs index 0425994549..4100d3ccdb 100644 --- a/src/portalbackend/PortalBackend.DBAccess/Models/CompanyMissingSdDocumentData.cs +++ b/src/portalbackend/PortalBackend.DBAccess/Models/CompanyMissingSdDocumentData.cs @@ -21,5 +21,8 @@ namespace Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; public record CompanyMissingSdDocumentData( Guid CompanyId, - string Name + string? Bpn, + string Name, + string? ShortName, + DateTimeOffset? SkippedDate ); diff --git a/src/portalbackend/PortalBackend.DBAccess/Repositories/CompanyRepository.cs b/src/portalbackend/PortalBackend.DBAccess/Repositories/CompanyRepository.cs index 137494b729..ecbbf25713 100644 --- a/src/portalbackend/PortalBackend.DBAccess/Repositories/CompanyRepository.cs +++ b/src/portalbackend/PortalBackend.DBAccess/Repositories/CompanyRepository.cs @@ -423,9 +423,31 @@ public void RemoveProviderCompanyDetails(Guid providerCompanyDetailId) => c => c.OrderByDescending(company => company.Name), c => new CompanyMissingSdDocumentData( c.Id, - c.Name) + c.BusinessPartnerNumber, + c.Name, + c.Shortname, + GetCompanyLastChangeDate(c) == null ? + null : + GetCompanyLastChangeDate(c)!.DateLastChanged) ).SingleOrDefaultAsync(); + private static ProcessStep? GetCompanyLastChangeDate(Company company) => company.CompanyApplications.Where(ca => + ca.ApplicationChecklistEntries.Any(a => + a.ApplicationChecklistEntryTypeId == ApplicationChecklistEntryTypeId.SELF_DESCRIPTION_LP && + a.ApplicationChecklistEntryStatusId != ApplicationChecklistEntryStatusId.SKIPPED) && + ca.ChecklistProcess!.ProcessSteps.Any(ps => + ps is + { + ProcessStepTypeId: ProcessStepTypeId.START_SELF_DESCRIPTION_LP, + ProcessStepStatusId: ProcessStepStatusId.SKIPPED + })) + .SelectMany(ca => ca.ChecklistProcess!.ProcessSteps.Where(ps => + ps is + { + ProcessStepTypeId: ProcessStepTypeId.START_SELF_DESCRIPTION_LP, + ProcessStepStatusId: ProcessStepStatusId.SKIPPED + })).FirstOrDefault(); + public IAsyncEnumerable GetCompanyIdsWithMissingSelfDescription() => context.Companies.Where(c => c.CompanyStatusId == CompanyStatusId.ACTIVE &&