From 98941417549d1b553a24629343bf6eef63d5951c Mon Sep 17 00:00:00 2001 From: Rinat Arsaev <11846445+A77AY@users.noreply.github.com> Date: Mon, 25 Mar 2024 15:37:00 +0700 Subject: [PATCH] IMP-193: Search by invoice and payment id (#343) --- .../sections/payments/payments.component.html | 6 ++++- .../services/fetch-payments.service.ts | 27 +++++++++++++++++-- .../utils/metadata-view-extension.ts | 2 +- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/app/sections/payments/payments.component.html b/src/app/sections/payments/payments.component.html index 4398d9d9..c4ad8966 100644 --- a/src/app/sections/payments/payments.component.html +++ b/src/app/sections/payments/payments.component.html @@ -10,7 +10,11 @@ > - + > { + const invoicePaymentIds = (params.invoice_ids || []).map((id) => splitInvoicePaymentId(id)); + const invoiceIds = [...new Set(invoicePaymentIds.map(({ invoiceId }) => invoiceId))]; return this.merchantStatisticsService .SearchPayments({ payment_params: {}, ...params, + ...clean({ invoice_ids: invoiceIds }), common_search_query_params: Object.assign({}, params.common_search_query_params, { continuation_token: continuationToken, limit: size, @@ -32,7 +47,15 @@ export class FetchPaymentsService extends FetchSuperclass ({ - result: payments, + result: params.invoice_ids?.length + ? payments.filter((p) => + invoicePaymentIds.some( + (id) => + id.invoiceId === p.invoice_id && + (isNil(id.paymentId) || id.paymentId === p.id), + ), + ) + : payments, continuationToken: continuation_token, })), catchError((err) => { diff --git a/src/app/shared/components/json-viewer/utils/metadata-view-extension.ts b/src/app/shared/components/json-viewer/utils/metadata-view-extension.ts index 80df4b35..f2bd51ba 100644 --- a/src/app/shared/components/json-viewer/utils/metadata-view-extension.ts +++ b/src/app/shared/components/json-viewer/utils/metadata-view-extension.ts @@ -7,7 +7,7 @@ import { MetadataFormData } from '../../metadata-form'; export interface MetadataViewExtensionResult { key?: string; - value?: string; + value?: unknown; hidden?: boolean; tooltip?: unknown; link?: Parameters;