mirror of
https://github.com/valitydev/control-center.git
synced 2024-11-06 02:25:17 +00:00
IMP-193: Search by invoice and payment id (#343)
This commit is contained in:
parent
a0f1a7f9e0
commit
9894141754
@ -10,7 +10,11 @@
|
||||
>
|
||||
<ng-template [formGroup]="filtersForm" vMainFilters>
|
||||
<v-date-range-field formControlName="dateRange"></v-date-range-field>
|
||||
<v-list-field formControlName="invoice_ids" label="Invoice Ids"></v-list-field>
|
||||
<v-list-field
|
||||
focusedHint="invoice_1, invoice_2.payment_2"
|
||||
formControlName="invoice_ids"
|
||||
label="Invoice and Payment Ids"
|
||||
></v-list-field>
|
||||
<cc-merchant-field formControlName="party_id"></cc-merchant-field>
|
||||
<cc-shop-field
|
||||
[partyId]="filtersForm.value.party_id"
|
||||
|
@ -1,11 +1,23 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { StatPayment, PaymentSearchQuery } from '@vality/magista-proto/magista';
|
||||
import { FetchSuperclass, FetchOptions, FetchResult, NotifyLogService } from '@vality/ng-core';
|
||||
import {
|
||||
FetchSuperclass,
|
||||
FetchOptions,
|
||||
FetchResult,
|
||||
NotifyLogService,
|
||||
clean,
|
||||
} from '@vality/ng-core';
|
||||
import isNil from 'lodash-es/isNil';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { map, catchError } from 'rxjs/operators';
|
||||
|
||||
import { MerchantStatisticsService } from '@cc/app/api/magista';
|
||||
|
||||
function splitInvoicePaymentId(invoicePaymentId: string) {
|
||||
const [invoiceId, paymentId] = invoicePaymentId.split('.');
|
||||
return { invoiceId, paymentId };
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
@ -21,10 +33,13 @@ export class FetchPaymentsService extends FetchSuperclass<StatPayment, PaymentSe
|
||||
params: PaymentSearchQuery,
|
||||
{ size, continuationToken }: FetchOptions,
|
||||
): Observable<FetchResult<StatPayment>> {
|
||||
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<StatPayment, PaymentSe
|
||||
})
|
||||
.pipe(
|
||||
map(({ payments, continuation_token }) => ({
|
||||
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) => {
|
||||
|
@ -7,7 +7,7 @@ import { MetadataFormData } from '../../metadata-form';
|
||||
|
||||
export interface MetadataViewExtensionResult {
|
||||
key?: string;
|
||||
value?: string;
|
||||
value?: unknown;
|
||||
hidden?: boolean;
|
||||
tooltip?: unknown;
|
||||
link?: Parameters<Router['navigate']>;
|
||||
|
Loading…
Reference in New Issue
Block a user