Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dh): adjustments to settlement report #3846

Merged
merged 14 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libs/dh/shared/data-access-graphql/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ export { graphQLProviders } from './lib/dh-graphql.providers';
export { parseGraphQLErrorResponse } from './lib/error-handler';
export { getActorOptions } from './lib/graphql/get-actors-by-eic-function-for-dropdowns';
export { getGridAreaOptions } from './lib/graphql/get-grid-area-options';
export { getGridAreaOptionsForPeriod } from './lib/graphql/get-grid-area-options-for-period';
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//#region License
/**
* @license
* Copyright 2020 Energinet DataHub A/S
*
* Licensed under the Apache License, Version 2.0 (the "License2");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//#endregion
import { GetRelevantGridAreasDocument } from '@energinet-datahub/dh/shared/domain/graphql';
import { WattDropdownOptions } from '@energinet-datahub/watt/dropdown';
import { WattRange } from '@energinet-datahub/watt/date';
import { query } from '@energinet-datahub/dh/shared/util-apollo';

export async function getGridAreaOptionsForPeriod(
period: WattRange<Date>,
actorId: string
): Promise<WattDropdownOptions> {
const result = await query(GetRelevantGridAreasDocument, {
variables: {
period,
actorId,
},
}).result();

return result.data.relevantGridAreas.map((gridArea) => ({
value: gridArea.code,
displayValue: gridArea.displayName,
}));
}
10 changes: 0 additions & 10 deletions libs/dh/shared/data-access-mocks/src/lib/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import {
mockGetUserRoleAuditLogsQuery,
mockGetUserRolesByEicfunctionQuery,
mockGetUserAuditLogsQuery,
mockGetGridAreasQuery,
mockGetUserRolesByActorIdQuery,
mockGetUserRoleWithPermissionsQuery,
mockUpdateUserAndRolesMutation,
Expand Down Expand Up @@ -60,7 +59,6 @@ import { adminPermissionDetailsMock } from './data/admin-get-permission-details'
import { marketParticipantUserRoles } from './data/admin-get-market-participant-user-roles';
import { getUserRolesByEicfunctionQuery } from './data/get-user-roles-by-eicfunction';
import { filteredActors } from './data/market-participant-filtered-actors';
import { getGridAreas } from './data/get-grid-areas';
import { users } from './data/admin/users';
import { userRoles } from './data/admin/user-roles';

Expand All @@ -73,7 +71,6 @@ export function adminMocks(apiBase: string) {
getAdminPermissionLogs(),
getAdminPermissionDetails(),
getKnownEmailsQuery(),
getGridAreasQuery(),
getUserDetailsQuery(),
updateUserAndRoles(),
updatePermission(),
Expand Down Expand Up @@ -534,13 +531,6 @@ function getKnownEmailsQuery() {
});
}

function getGridAreasQuery() {
return mockGetGridAreasQuery(async () => {
await delay(mswConfig.delay);
return HttpResponse.json({ data: getGridAreas });
});
}

function getUserEditQuery() {
return mockGetUserEditQuery(async ({ variables }) => {
const user = users.find((user) => user.id === variables.id);
Expand Down
10 changes: 5 additions & 5 deletions libs/dh/shared/data-access-mocks/src/lib/data/get-grid-areas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,35 @@ export const getGridAreas: GetGridAreasQuery = {
__typename: 'Query',
gridAreas: [
{
__typename: 'GridAreaDto',
id: '4ee13230-3716-468f-96ee-01b15f054530',
code: '001',
name: 'Grid area 1',
displayName: '001 • Grid area 1',
validFrom: new Date(),
validFrom: new Date('2024-12-02T23:00:00Z'),
validTo: null,
__typename: 'GridAreaDto',
includedInCalculation: true,
type: GridAreaType.Distribution,
},
{
__typename: 'GridAreaDto',
id: '89801ec1-af12-46d9-b044-05a004a0d46c',
code: '002',
name: 'Grid area 2',
displayName: '002 • Grid area 2',
validFrom: new Date(),
validFrom: new Date('2024-11-02T23:00:00Z'),
validTo: null,
__typename: 'GridAreaDto',
includedInCalculation: true,
type: GridAreaType.Distribution,
},
{
__typename: 'GridAreaDto',
id: 'd45f9498-1954-4c7d-8e9c-0d4a2aba058b',
code: '003',
name: 'Grid area 3',
displayName: '003 • Grid area 3',
validFrom: new Date(),
validTo: null,
__typename: 'GridAreaDto',
includedInCalculation: false,
type: GridAreaType.Test,
},
Expand Down
26 changes: 26 additions & 0 deletions libs/dh/shared/data-access-mocks/src/lib/market-participant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ import {
mockGetGridAreaDetailsQuery,
mockGetActorAuditLogsQuery,
mockGetActorDetailsQuery,
mockGetGridAreasQuery,
mockGetRelevantGridAreasQuery,
} from '@energinet-datahub/dh/shared/domain/graphql';

import { mswConfig } from '@energinet-datahub/gf/util-msw';
Expand All @@ -69,6 +71,7 @@ import { getGridAreaOverviewMock } from './data/get-grid-area-overview';
import { getDelegationsForActorMock } from './data/get-delegations-for-actor';
import { actors } from './data/get-actors-by-organizationId';
import { balanceResponsibleAgreements } from './data/balance-responsible-agreements';
import { getGridAreas } from './data/get-grid-areas';

export function marketParticipantMocks(apiBase: string) {
return [
Expand Down Expand Up @@ -101,6 +104,8 @@ export function marketParticipantMocks(apiBase: string) {
addTokenToDownloadUrl(),
checkDomainExists(),
mergeMarketParticipants(),
getGridAreasQuery(),
getRelevantGridAreasQuery(),
];
}

Expand Down Expand Up @@ -679,3 +684,24 @@ function mergeMarketParticipants() {
});
});
}

function getGridAreasQuery() {
return mockGetGridAreasQuery(async () => {
await delay(mswConfig.delay);

return HttpResponse.json({ data: getGridAreas });
});
}

function getRelevantGridAreasQuery() {
return mockGetRelevantGridAreasQuery(async () => {
await delay(mswConfig.delay);

return HttpResponse.json({
data: {
__typename: 'Query',
relevantGridAreas: getGridAreas.gridAreas,
},
});
});
}
11 changes: 0 additions & 11 deletions libs/dh/shared/data-access-mocks/src/lib/wholesale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import {
mockGetActorsForRequestCalculationQuery,
mockGetCalculationByIdQuery,
mockGetCalculationsQuery,
mockGetGridAreasQuery,
mockGetLatestCalculationQuery,
mockGetSelectedActorQuery,
mockGetSettlementReportsQuery,
Expand Down Expand Up @@ -61,7 +60,6 @@ export function wholesaleMocks(apiBase: string) {
getCalculations(),
downloadSettlementReportData(apiBase),
downloadSettlementReportDataV2(apiBase),
getGridAreasQuery(),
getLatestCalculation(),
getActorsForRequestCalculationQuery(),
getSelectedActorQuery(),
Expand Down Expand Up @@ -637,15 +635,6 @@ function getCalculations() {
});
}

function getGridAreasQuery() {
return mockGetGridAreasQuery(async () => {
await delay(mswConfig.delay);
return HttpResponse.json({
data: { __typename: 'Query', gridAreas: mockedGridAreas },
});
});
}

function getLatestCalculation() {
return mockGetLatestCalculationQuery(async () => {
await delay(mswConfig.delay);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,24 @@ import {
ReactiveFormsModule,
Validators,
} from '@angular/forms';
import { RxPush } from '@rx-angular/template/push';
import { TranslocoDirective } from '@ngneat/transloco';
import { Apollo } from 'apollo-angular';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';

import { getActorOptions } from '@energinet-datahub/dh/shared/data-access-graphql';
import { EicFunction, GetActorByIdDocument } from '@energinet-datahub/dh/shared/domain/graphql';
import { WattButtonComponent } from '@energinet-datahub/watt/button';
import { WattDropdownComponent } from '@energinet-datahub/watt/dropdown';
import { WattFieldErrorComponent } from '@energinet-datahub/watt/field';
import { WATT_MODAL, WattModalService, WattTypedModal } from '@energinet-datahub/watt/modal';
import { VaterStackComponent } from '@energinet-datahub/watt/vater';
import { TranslocoDirective } from '@ngneat/transloco';
import { RxPush } from '@rx-angular/template/push';

import { DhRequestSettlementReportModalComponent } from '../modal/dh-request-settlement-report-modal.component';
import { Apollo } from 'apollo-angular';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import {
DhActorStorage,
PermissionService,
} from '@energinet-datahub/dh/shared/feature-authorization';

import { DhRequestSettlementReportModalComponent } from '../modal/dh-request-settlement-report-modal.component';

type DhFormType = FormGroup<{
actorId: FormControl<string>;
}>;
Expand All @@ -58,7 +58,6 @@ type DhFormType = FormGroup<{
VaterStackComponent,
WattDropdownComponent,
WattButtonComponent,
WattFieldErrorComponent,
],
templateUrl: './dh-request-as-settlement-report-modal.component.html',
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,52 @@
>
<form id="request-settlement-report-form" [formGroup]="form" (ngSubmit)="submit()">
<vater-stack align="stretch" direction="column" gap="l">
@if (hasMoreThanOneGridAreaOption()) {
<div class="items-group">
<watt-dropdown
[multiple]="true"
sortDirection="asc"
[label]="t('gridArea')"
[formControl]="form.controls.gridAreas"
[options]="gridAreaOptions$ | push"
>
@if (multipleGridAreasSelected$ | push) {
<watt-field-hint>
{{ t("gridAreaHint", { count: form.controls.gridAreas.value?.length }) }}
</watt-field-hint>
}
</watt-dropdown>
<div class="items-group">
<watt-datepicker
[range]="true"
[label]="t('period')"
[min]="minDate"
[max]="maxDate"
[formControl]="form.controls.period"
>
@if (form.controls.period.hasError("startDateIsBeforeMinDate")) {
<watt-field-error> {{ t("startDateIsBeforeMinDate") }} </watt-field-error>
}
@if (form.controls.period.hasError("startDateAndEndDateHaveDifferentMonth")) {
<watt-field-error>
{{ t("startDateAndEndDateHaveDifferentMonth") }}
</watt-field-error>
}
</watt-datepicker>

@if (showMonthlySumCheckbox$ | push) {
<watt-checkbox [formControl]="form.controls.includeMonthlySum">
{{ t("includeMonthlySum") }}
</watt-checkbox>
}
</div>

<div class="items-group">
<watt-dropdown
[multiple]="true"
sortDirection="asc"
[label]="t('gridArea')"
[formControl]="form.controls.gridAreas"
[options]="gridAreaOptions$ | push"
>
@if (multipleGridAreasSelected$ | push) {
<watt-checkbox [formControl]="form.controls.combineResultsInOneFile">
{{ t("combineResultsInOneFile") }}
</watt-checkbox>
<watt-field-hint>
{{ t("gridAreaHint", { count: form.controls.gridAreas.value?.length }) }}
</watt-field-hint>
}
</div>
}
</watt-dropdown>

@if (multipleGridAreasSelected$ | push) {
<watt-checkbox [formControl]="form.controls.combineResultsInOneFile">
{{ t("combineResultsInOneFile") }}
</watt-checkbox>
}
</div>

@if ((showEnergySupplierDropdown$ | push) && form.controls.energySupplier) {
<div class="items-group">
Expand Down Expand Up @@ -74,31 +97,6 @@
{{ t("allowLargeTextFiles") }}
</watt-checkbox>
</div>

<div class="items-group">
<watt-datepicker
[range]="true"
[label]="t('period')"
[min]="minDate"
[max]="maxDate"
[formControl]="form.controls.period"
>
@if (form.controls.period.hasError("startDateIsBeforeMinDate")) {
<watt-field-error> {{ t("startDateIsBeforeMinDate") }} </watt-field-error>
}
@if (form.controls.period.hasError("startDateAndEndDateHaveDifferentMonth")) {
<watt-field-error>
{{ t("startDateAndEndDateHaveDifferentMonth") }}
</watt-field-error>
}
</watt-datepicker>

@if (showMonthlySumCheckbox$ | push) {
<watt-checkbox [formControl]="form.controls.includeMonthlySum">
{{ t("includeMonthlySum") }}
</watt-checkbox>
}
</div>
</vater-stack>
</form>

Expand Down
Loading
Loading