Skip to content

Commit

Permalink
feat(companyData): enhance GET: /api/administration/companyData/missi…
Browse files Browse the repository at this point in the history
…ng-sd-document

Refs: #1179
  • Loading branch information
Phil91 committed Jan 16, 2025
1 parent e059fcf commit 97c5064
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
10 changes: 10 additions & 0 deletions docs/api/administration-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Original file line number Diff line number Diff line change
Expand Up @@ -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<Guid> GetCompanyIdsWithMissingSelfDescription() =>
context.Companies.Where(c =>
c.CompanyStatusId == CompanyStatusId.ACTIVE &&
Expand Down

0 comments on commit 97c5064

Please sign in to comment.