From 8da6c5ab0413efbf2613af392ec5b52dcf2e87e9 Mon Sep 17 00:00:00 2001 From: Rinat Arsaev <11846445+A77AY@users.noreply.github.com> Date: Fri, 20 Sep 2024 13:15:45 +0500 Subject: [PATCH] IMP-310,IMP-312: Payment adjustment domain revision autocomplete, hide used routing rules shops/wallets. Table fixes (#391) --- package-lock.json | 16 +- package.json | 4 +- .../components/toolbar/toolbar.component.ts | 12 +- .../create-payment-adjustment.component.html | 30 --- .../create-payment-adjustment.component.ts | 76 ------- .../payments-table.component.html | 15 -- .../payments-table.component.ts | 104 ---------- src/app/sections/old-payments/index.ts | 1 - .../old-payments/payments-routing.module.ts | 22 --- .../old-payments/payments.component.html | 65 ------ .../old-payments/payments.component.ts | 187 ------------------ .../sections/old-payments/payments.module.ts | 46 ----- .../sections/old-payments/routing-config.ts | 5 - .../services/fetch-payments.service.ts | 67 ------- .../payments-table.component.ts | 5 +- ...d-party-routing-rule-dialog.component.html | 33 ++-- ...add-party-routing-rule-dialog.component.ts | 19 +- .../add-party-routing-rule-dialog.module.ts | 3 +- .../party-routing-ruleset.component.ts | 33 +++- .../party-routing-ruleset.service.ts | 1 + src/app/sections/sections-routing.module.ts | 4 - .../shops-terms/shops-terms.component.ts | 25 ++- .../terminals-terms.component.ts | 4 +- .../wallets-terms/wallets-terms.component.ts | 25 ++- .../withdrawals/withdrawals.component.html | 13 +- .../withdrawals/withdrawals.component.ts | 70 +++---- ...domain-metadata-form-extensions.service.ts | 9 + .../utils/table/create-failure-column.ts | 43 +--- 28 files changed, 152 insertions(+), 785 deletions(-) delete mode 100644 src/app/sections/old-payments/components/create-payment-adjustment/create-payment-adjustment.component.html delete mode 100644 src/app/sections/old-payments/components/create-payment-adjustment/create-payment-adjustment.component.ts delete mode 100644 src/app/sections/old-payments/components/payments-table/payments-table.component.html delete mode 100644 src/app/sections/old-payments/components/payments-table/payments-table.component.ts delete mode 100644 src/app/sections/old-payments/index.ts delete mode 100644 src/app/sections/old-payments/payments-routing.module.ts delete mode 100644 src/app/sections/old-payments/payments.component.html delete mode 100644 src/app/sections/old-payments/payments.component.ts delete mode 100644 src/app/sections/old-payments/payments.module.ts delete mode 100644 src/app/sections/old-payments/routing-config.ts delete mode 100644 src/app/sections/old-payments/services/fetch-payments.service.ts diff --git a/package-lock.json b/package-lock.json index b0aee448..98e96087 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,9 +24,9 @@ "@vality/domain-proto": "2.0.1-7762f6c.0", "@vality/dominator-proto": "1.0.1-41bee97.0", "@vality/fistful-proto": "2.0.1-88e69a5.0", - "@vality/machinegun-proto": "1.0.0", + "@vality/machinegun-proto": "1.0.1-3decc8f.0", "@vality/magista-proto": "2.0.2-ec1bdb9.0", - "@vality/ng-core": "18.3.1-pr-68-2c4891d.0", + "@vality/ng-core": "18.3.1-pr-68-5283c21.0", "@vality/ng-thrift": "18.0.1-pr-13-bdb6d51.0", "@vality/repairer-proto": "2.0.2-07b73e9.0", "@vality/scrooge-proto": "0.1.1-9ce7fc6.0", @@ -5959,9 +5959,9 @@ "integrity": "sha512-fsMqJbOZa2GesbP2OEmPlyPfV236VN+JRxke7HO79ujC4i8TwHeejV55DTfUbrFO7Q/d2Wwj8BtMcQF/c4KYGA==" }, "node_modules/@vality/machinegun-proto": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@vality/machinegun-proto/-/machinegun-proto-1.0.0.tgz", - "integrity": "sha512-HSK9WXE+cT+1skU5w3xI++GM/RO7YXaNDFL8mGMiE5Mga8hVUlb+yLBvvNM+zCslqiI+dENFQjviZeFROWH3Kw==" + "version": "1.0.1-3decc8f.0", + "resolved": "https://registry.npmjs.org/@vality/machinegun-proto/-/machinegun-proto-1.0.1-3decc8f.0.tgz", + "integrity": "sha512-ZGNyl/ZI2QsVs2Opw+eo6fKlopPF6NmTMCO5oTG1ZYKnDG74VfcmnMIvhLuHapPW7jgvg9K9WT7O9x0iSsUXOQ==" }, "node_modules/@vality/magista-proto": { "version": "2.0.2-ec1bdb9.0", @@ -5969,9 +5969,9 @@ "integrity": "sha512-XWF7qM/CARRAey0scGVhfGU6jNq+UdlGE2mg3jn4eIFDuIWQJqsT+Bah300RBUrl+XgFsmj95C6HWRfeA5Q8kw==" }, "node_modules/@vality/ng-core": { - "version": "18.3.1-pr-68-2c4891d.0", - "resolved": "https://registry.npmjs.org/@vality/ng-core/-/ng-core-18.3.1-pr-68-2c4891d.0.tgz", - "integrity": "sha512-1oDGn1YooeI/2EeWLbPIG0YyhbtyxITAwDXRk52eWWAHdFyvMcDmALZg89/EM3ATn+WQbV7jN/iNZGBhgmaAKw==", + "version": "18.3.1-pr-68-5283c21.0", + "resolved": "https://registry.npmjs.org/@vality/ng-core/-/ng-core-18.3.1-pr-68-5283c21.0.tgz", + "integrity": "sha512-RDD7xCe2Q+DI70J8ph2QB19U9DnAlpqW83XG9kLtLiqRDWTLfvm2yO0TxZ7AwgMUmRrwf6TJjdkgJGPk9+06RA==", "dependencies": { "@angular/material-date-fns-adapter": "^18.2.2", "@ng-matero/extensions": "^18.2.0", diff --git a/package.json b/package.json index 679d5fb4..b79d0a1f 100644 --- a/package.json +++ b/package.json @@ -33,9 +33,9 @@ "@vality/domain-proto": "2.0.1-7762f6c.0", "@vality/dominator-proto": "1.0.1-41bee97.0", "@vality/fistful-proto": "2.0.1-88e69a5.0", - "@vality/machinegun-proto": "1.0.0", + "@vality/machinegun-proto": "1.0.1-3decc8f.0", "@vality/magista-proto": "2.0.2-ec1bdb9.0", - "@vality/ng-core": "18.3.1-pr-68-2c4891d.0", + "@vality/ng-core": "18.3.1-pr-68-5283c21.0", "@vality/ng-thrift": "18.0.1-pr-13-bdb6d51.0", "@vality/repairer-proto": "2.0.2-07b73e9.0", "@vality/scrooge-proto": "0.1.1-9ce7fc6.0", diff --git a/src/app/core/components/toolbar/toolbar.component.ts b/src/app/core/components/toolbar/toolbar.component.ts index 50714f26..132582d2 100644 --- a/src/app/core/components/toolbar/toolbar.component.ts +++ b/src/app/core/components/toolbar/toolbar.component.ts @@ -53,7 +53,7 @@ export class ToolbarComponent implements OnInit { this.partyIdControl.valueChanges .pipe(distinctUntilChanged(), takeUntilDestroyed(this.destroyRef)) .subscribe((partyId) => { - const currentPartyId = this.getPartyId(); + const currentPartyId = this.getPartyId() || null; if (partyId) { if (currentPartyId !== partyId) { void this.router.navigate([`/party/${partyId}`]); @@ -63,13 +63,9 @@ export class ToolbarComponent implements OnInit { } }); this.urlService.path$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((path) => { - const partyId = this.getPartyId(path); - if (partyId) { - if (partyId !== this.partyIdControl.value) { - this.partyIdControl.setValue(partyId, { emitEvent: false }); - } - } else if (this.partyIdControl.value) { - this.partyIdControl.setValue(null, { emitEvent: false }); + const partyId = this.getPartyId(path) || null; + if (partyId !== this.partyIdControl.value) { + this.partyIdControl.setValue(partyId); } }); } diff --git a/src/app/sections/old-payments/components/create-payment-adjustment/create-payment-adjustment.component.html b/src/app/sections/old-payments/components/create-payment-adjustment/create-payment-adjustment.component.html deleted file mode 100644 index e99f19f1..00000000 --- a/src/app/sections/old-payments/components/create-payment-adjustment/create-payment-adjustment.component.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - diff --git a/src/app/sections/old-payments/components/create-payment-adjustment/create-payment-adjustment.component.ts b/src/app/sections/old-payments/components/create-payment-adjustment/create-payment-adjustment.component.ts deleted file mode 100644 index 81dd1101..00000000 --- a/src/app/sections/old-payments/components/create-payment-adjustment/create-payment-adjustment.component.ts +++ /dev/null @@ -1,76 +0,0 @@ -import { Component, DestroyRef } from '@angular/core'; -import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; -import { FormControl } from '@angular/forms'; -import { InvoicePaymentAdjustmentParams } from '@vality/domain-proto/payment_processing'; -import { StatPayment } from '@vality/magista-proto/magista'; -import { - DialogSuperclass, - NotifyLogService, - forkJoinToResult, - splitResultsErrors, - ForkJoinErrorResult, -} from '@vality/ng-core'; -import { BehaviorSubject, from } from 'rxjs'; - -import { DomainMetadataFormExtensionsService } from '@cc/app/shared/services'; - -import { InvoicingService } from '../../../../api/payment-processing'; - -@Component({ - selector: 'cc-create-payment-adjustment', - templateUrl: './create-payment-adjustment.component.html', -}) -export class CreatePaymentAdjustmentComponent extends DialogSuperclass< - CreatePaymentAdjustmentComponent, - { payments: StatPayment[] }, - { errors?: ForkJoinErrorResult[] } -> { - control = new FormControl(null); - progress$ = new BehaviorSubject(0); - metadata$ = from(import('@vality/domain-proto/metadata.json').then((m) => m.default)); - extensions$ = this.domainMetadataFormExtensionsService.extensions$; - errors: ForkJoinErrorResult[] = []; - - constructor( - private invoicingService: InvoicingService, - private log: NotifyLogService, - private domainMetadataFormExtensionsService: DomainMetadataFormExtensionsService, - private destroyRef: DestroyRef, - ) { - super(); - } - - create() { - const payments = this.errors.length - ? this.errors.map(({ data }) => data) - : this.dialogData.payments; - this.errors = []; - forkJoinToResult( - payments.map((p) => - this.invoicingService.CreatePaymentAdjustment( - p.invoice_id, - p.id, - this.control.value, - ), - ), - this.progress$, - payments, - 2, - ) - .pipe(takeUntilDestroyed(this.destroyRef)) - .subscribe((res) => { - const [result, errors] = splitResultsErrors(res); - if (errors.length) { - this.errors = errors; - this.log.error(this.errors.map((e) => e.error)); - } else { - this.log.success(`${result.length} created successfully`); - this.closeWithSuccess(); - } - }); - } - - closeAndSelectWithAnError() { - this.closeWithError({ errors: this.errors }); - } -} diff --git a/src/app/sections/old-payments/components/payments-table/payments-table.component.html b/src/app/sections/old-payments/components/payments-table/payments-table.component.html deleted file mode 100644 index 3f6f87f5..00000000 --- a/src/app/sections/old-payments/components/payments-table/payments-table.component.html +++ /dev/null @@ -1,15 +0,0 @@ - - - - - diff --git a/src/app/sections/old-payments/components/payments-table/payments-table.component.ts b/src/app/sections/old-payments/components/payments-table/payments-table.component.ts deleted file mode 100644 index 9957258a..00000000 --- a/src/app/sections/old-payments/components/payments-table/payments-table.component.ts +++ /dev/null @@ -1,104 +0,0 @@ -import { Component, Input, Output, EventEmitter } from '@angular/core'; -import { Router } from '@angular/router'; -import { InvoicePaymentStatus } from '@vality/domain-proto/domain'; -import { StatPayment } from '@vality/magista-proto/magista'; -import { Column, TagColumn, LoadOptions, createOperationColumn } from '@vality/ng-core'; -import { getUnionKey } from '@vality/ng-thrift'; -import startCase from 'lodash-es/startCase'; - -import { AmountCurrencyService } from '@cc/app/shared/services'; - -import { createFailureColumn, createPartyColumn, createShopColumn } from '../../../../shared'; -import { createProviderColumn } from '../../../../shared/utils/table/create-provider-column'; -import { createTerminalColumn } from '../../../../shared/utils/table/create-terminal-column'; - -@Component({ - selector: 'cc-payments-table', - templateUrl: './payments-table.component.html', -}) -export class PaymentsTableComponent { - @Input() data!: StatPayment[]; - @Input() isLoading?: boolean | null; - @Input() hasMore?: boolean | null; - @Input() selected?: StatPayment[]; - - @Output() selectedChange = new EventEmitter(); - @Output() update = new EventEmitter(); - @Output() more = new EventEmitter(); - - columns: Column[] = [ - { field: 'id', click: (d) => this.toDetails(d), pinned: 'left' }, - { field: 'invoice_id', pinned: 'left' }, - { - field: 'amount', - type: 'currency', - formatter: (data) => - this.amountCurrencyService.toMajor(data.amount, data.currency_symbolic_code), - typeParameters: { - currencyCode: 'currency_symbolic_code', - }, - }, - { - field: 'fee', - type: 'currency', - formatter: (data) => - this.amountCurrencyService.toMajor(data.fee, data.currency_symbolic_code), - typeParameters: { - currencyCode: 'currency_symbolic_code', - }, - }, - { - field: 'status', - type: 'tag', - formatter: (data) => getUnionKey(data.status), - typeParameters: { - label: (data) => startCase(getUnionKey(data.status)), - tags: { - captured: { color: 'success' }, - refunded: { color: 'success' }, - charged_back: { color: 'success' }, - pending: { color: 'pending' }, - processed: { color: 'pending' }, - failed: { color: 'warn' }, - cancelled: { color: 'neutral' }, - }, - }, - } as TagColumn, - { field: 'created_at', type: 'datetime' }, - createPartyColumn('owner_id'), - createShopColumn('shop_id', (d) => d.owner_id), - 'domain_revision', - createTerminalColumn((d) => d.terminal_id.id), - createProviderColumn((d) => d.provider_id.id), - 'external_id', - createFailureColumn( - (d) => d.status?.failed?.failure?.failure, - (d) => - getUnionKey(d.status?.failed?.failure) === 'failure' - ? '' - : startCase(getUnionKey(d.status?.failed?.failure)), - ), - createOperationColumn([ - { - label: 'Details', - click: (data) => this.toDetails(data), - }, - ]), - ]; - - constructor( - private amountCurrencyService: AmountCurrencyService, - private router: Router, - ) {} - - private toDetails(data: StatPayment) { - return void this.router.navigate([ - 'party', - data.owner_id, - 'invoice', - data.invoice_id, - 'payment', - data.id, - ]); - } -} diff --git a/src/app/sections/old-payments/index.ts b/src/app/sections/old-payments/index.ts deleted file mode 100644 index a3eef2ad..00000000 --- a/src/app/sections/old-payments/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './payments.module'; diff --git a/src/app/sections/old-payments/payments-routing.module.ts b/src/app/sections/old-payments/payments-routing.module.ts deleted file mode 100644 index a879b677..00000000 --- a/src/app/sections/old-payments/payments-routing.module.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { NgModule } from '@angular/core'; -import { RouterModule } from '@angular/router'; - -import { AppAuthGuardService } from '@cc/app/shared/services'; - -import { PaymentsComponent } from './payments.component'; -import { ROUTING_CONFIG } from './routing-config'; - -@NgModule({ - imports: [ - RouterModule.forChild([ - { - path: '', - component: PaymentsComponent, - canActivate: [AppAuthGuardService], - data: ROUTING_CONFIG, - }, - ]), - ], - exports: [RouterModule], -}) -export class PaymentsRoutingModule {} diff --git a/src/app/sections/old-payments/payments.component.html b/src/app/sections/old-payments/payments.component.html deleted file mode 100644 index ed928d1d..00000000 --- a/src/app/sections/old-payments/payments.component.html +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/app/sections/old-payments/payments.component.ts b/src/app/sections/old-payments/payments.component.ts deleted file mode 100644 index 504e276f..00000000 --- a/src/app/sections/old-payments/payments.component.ts +++ /dev/null @@ -1,187 +0,0 @@ -import { Component, OnInit, Inject, DestroyRef } from '@angular/core'; -import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; -import { NonNullableFormBuilder } from '@angular/forms'; -import { StatPayment } from '@vality/magista-proto/magista'; -import { - DialogService, - DialogResponseStatus, - LoadOptions, - getNoTimeZoneIsoString, - clean, - DateRange, - QueryParamsService, - createDateRangeToToday, - isEqualDateRange, - debounceTimeWithFirst, - getValueChanges, - countChanged, -} from '@vality/ng-core'; -import { isTypeWithAliases } from '@vality/ng-thrift'; -import { endOfDay } from 'date-fns'; -import { uniq } from 'lodash-es'; -import isEqual from 'lodash-es/isEqual'; -import { BehaviorSubject, of, merge } from 'rxjs'; -import { startWith, map, distinctUntilChanged, shareReplay } from 'rxjs/operators'; - -import { FailMachinesDialogComponent, Type } from '../../shared/components/fail-machines-dialog'; -import { MetadataFormExtension } from '../../shared/components/metadata-form'; -import { DATE_RANGE_DAYS, DEBOUNCE_TIME_MS } from '../../tokens'; - -import { CreatePaymentAdjustmentComponent } from './components/create-payment-adjustment/create-payment-adjustment.component'; -import { FetchPaymentsService } from './services/fetch-payments.service'; - -interface Filters { - filters: PaymentsComponent['filtersForm']['value']; - otherFilters: PaymentsComponent['otherFiltersControl']['value']; - dateRange: DateRange; -} - -@Component({ - templateUrl: 'payments.component.html', -}) -export class PaymentsComponent implements OnInit { - isLoading$ = this.fetchPaymentsService.isLoading$; - payments$ = this.fetchPaymentsService.result$; - hasMore$ = this.fetchPaymentsService.hasMore$; - selected$ = new BehaviorSubject([]); - filtersForm = this.fb.group({ - dateRange: createDateRangeToToday(this.dateRangeDays), - invoice_ids: [undefined as string[]], - party_id: undefined as string, - shop_ids: [undefined as string[]], - payment_first6: undefined as string, - payment_last4: undefined as string, - payment_rrn: undefined as string, - payment_email: undefined as string, - error_message: undefined as string, - external_id: undefined as string, - }); - otherFiltersControl = this.fb.control({ - common_search_query_params: {}, - payment_params: {}, - }); - extensions: MetadataFormExtension[] = [ - { - determinant: (data) => - of( - isTypeWithAliases(data, 'CommonSearchQueryParams', 'magista') || - [ - 'invoice_ids', - 'payment_email', - 'payment_first6', - 'payment_last4', - 'payment_rrn', - 'error_message', - 'external_id', - ].includes(data?.field?.name), - ), - extension: () => of({ hidden: true }), - }, - ]; - active$ = getValueChanges(this.filtersForm).pipe( - map((filters) => - countChanged(this.initFiltersValue, filters, { dateRange: isEqualDateRange }), - ), - shareReplay({ refCount: true, bufferSize: 1 }), - ); - - private initFiltersValue = this.filtersForm.value; - - constructor( - private qp: QueryParamsService, - private fetchPaymentsService: FetchPaymentsService, - private dialogService: DialogService, - private fb: NonNullableFormBuilder, - @Inject(DATE_RANGE_DAYS) private dateRangeDays: number, - private dr: DestroyRef, - @Inject(DEBOUNCE_TIME_MS) private debounceTimeMs: number, - ) {} - - ngOnInit() { - this.filtersForm.patchValue( - Object.assign( - {}, - this.qp.params.filters, - clean({ dateRange: this.qp.params.dateRange }), - ), - ); - this.otherFiltersControl.patchValue(Object.assign({}, this.qp.params.otherFilters)); - merge(this.filtersForm.valueChanges, this.otherFiltersControl.valueChanges) - .pipe( - startWith(null), - debounceTimeWithFirst(this.debounceTimeMs), - map(() => { - const { dateRange, ...filters } = clean(this.filtersForm.value); - const otherFilters = clean(this.otherFiltersControl.value); - return { filters, dateRange, otherFilters }; - }), - distinctUntilChanged(isEqual), - takeUntilDestroyed(this.dr), - ) - .subscribe((filters) => { - void this.qp.set(filters); - this.load(filters); - }); - } - - more() { - this.fetchPaymentsService.more(); - } - - load({ filters, otherFilters, dateRange }: Filters, options?: LoadOptions) { - const { invoice_ids, party_id, shop_ids, external_id, ...paymentParams } = filters; - const searchParams = clean({ - ...otherFilters, - common_search_query_params: { - ...(otherFilters.common_search_query_params || {}), - party_id, - shop_ids, - from_time: getNoTimeZoneIsoString(dateRange.start), - to_time: getNoTimeZoneIsoString(endOfDay(dateRange.end)), - }, - payment_params: { ...(otherFilters.payment_params || {}), ...paymentParams }, - external_id, - invoice_ids, - }); - this.fetchPaymentsService.load(searchParams, options); - } - - reload(options?: LoadOptions) { - this.fetchPaymentsService.reload(options); - } - - createPaymentAdjustment() { - this.dialogService - .open(CreatePaymentAdjustmentComponent, { - payments: this.selected$.value, - }) - .afterClosed() - .subscribe((res) => { - if (res.status === DialogResponseStatus.Success) { - this.reload(); - this.selected$.next([]); - } else if (res.data?.errors?.length) { - this.selected$.next(res.data.errors.map(({ data }) => data)); - } - }); - } - - failMachines() { - this.dialogService - .open(FailMachinesDialogComponent, { - ids: uniq(this.selected$.value.map((s) => s.invoice_id)), - type: Type.Invoice, - }) - .afterClosed() - .subscribe((res) => { - if (res.status === DialogResponseStatus.Success) { - this.reload(); - this.selected$.next([]); - } else if (res.data?.errors?.length) { - this.selected$.next( - res.data.errors.map(({ index }) => this.selected$.value[index]), - ); - } - }); - } -} diff --git a/src/app/sections/old-payments/payments.module.ts b/src/app/sections/old-payments/payments.module.ts deleted file mode 100644 index 8eb1f67f..00000000 --- a/src/app/sections/old-payments/payments.module.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { CommonModule } from '@angular/common'; -import { NgModule } from '@angular/core'; -import { ReactiveFormsModule, FormsModule } from '@angular/forms'; -import { MatButtonModule } from '@angular/material/button'; -import { - FiltersModule, - DateRangeFieldModule, - ListFieldModule, - TableModule, - DialogModule, - InputFieldModule, -} from '@vality/ng-core'; - -import { PageLayoutModule, ShopFieldModule } from '@cc/app/shared'; -import { MerchantFieldModule } from '@cc/app/shared/components/merchant-field'; -import { ThriftFormModule } from '@cc/app/shared/components/metadata-form'; - -import { MagistaThriftFormComponent } from '../../shared/components/thrift-api-crud'; - -import { CreatePaymentAdjustmentComponent } from './components/create-payment-adjustment/create-payment-adjustment.component'; -import { PaymentsTableComponent } from './components/payments-table/payments-table.component'; -import { PaymentsRoutingModule } from './payments-routing.module'; -import { PaymentsComponent } from './payments.component'; - -@NgModule({ - imports: [ - CommonModule, - PaymentsRoutingModule, - PageLayoutModule, - FiltersModule, - DateRangeFieldModule, - ListFieldModule, - MerchantFieldModule, - ReactiveFormsModule, - TableModule, - DialogModule, - ThriftFormModule, - MatButtonModule, - ShopFieldModule, - InputFieldModule, - FormsModule, - MagistaThriftFormComponent, - ], - declarations: [PaymentsComponent, CreatePaymentAdjustmentComponent, PaymentsTableComponent], -}) -export class PaymentsModule {} diff --git a/src/app/sections/old-payments/routing-config.ts b/src/app/sections/old-payments/routing-config.ts deleted file mode 100644 index 626c3c37..00000000 --- a/src/app/sections/old-payments/routing-config.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { Services, RoutingConfig } from '@cc/app/shared/services'; - -export const ROUTING_CONFIG: RoutingConfig = { - services: [Services.MerchantStatistics], -}; diff --git a/src/app/sections/old-payments/services/fetch-payments.service.ts b/src/app/sections/old-payments/services/fetch-payments.service.ts deleted file mode 100644 index 7e7da601..00000000 --- a/src/app/sections/old-payments/services/fetch-payments.service.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { Injectable } from '@angular/core'; -import { StatPayment, PaymentSearchQuery } from '@vality/magista-proto/magista'; -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', -}) -export class FetchPaymentsService extends FetchSuperclass { - constructor( - private merchantStatisticsService: MerchantStatisticsService, - private log: NotifyLogService, - ) { - super(); - } - - protected fetch( - params: PaymentSearchQuery, - { size, continuationToken }: FetchOptions, - ): Observable> { - 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, - }), - }) - .pipe( - map(({ payments, continuation_token }) => ({ - 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) => { - this.log.errorOperation(err, 'receive', 'payments'); - return of({ result: [] }); - }), - ); - } -} diff --git a/src/app/sections/payments/components/payments-table/payments-table.component.ts b/src/app/sections/payments/components/payments-table/payments-table.component.ts index bb316ac6..6c1e44e1 100644 --- a/src/app/sections/payments/components/payments-table/payments-table.component.ts +++ b/src/app/sections/payments/components/payments-table/payments-table.component.ts @@ -7,7 +7,7 @@ import startCase from 'lodash-es/startCase'; import { AmountCurrencyService } from '@cc/app/shared/services'; -import { createFailureColumn2 } from '../../../../shared'; +import { createFailureColumn } from '../../../../shared'; import { createPartyColumn, createShopColumn, @@ -36,6 +36,7 @@ export class PaymentsTableComponent { cell: (d) => ({ click: () => this.toDetails(d), }), + sticky: 'start', }, { field: 'invoice_id', sticky: 'start' }, { field: 'external_id' }, @@ -72,7 +73,7 @@ export class PaymentsTableComponent { createDomainObjectColumn((d) => ({ ref: { provider: d.provider_id } }), { header: 'Provider', }), - createFailureColumn2((d) => ({ + createFailureColumn((d) => ({ failure: d.status?.failed?.failure?.failure, noFailureMessage: getUnionKey(d.status?.failed?.failure) === 'failure' diff --git a/src/app/sections/routing-rules/party-routing-ruleset/add-party-routing-rule-dialog/add-party-routing-rule-dialog.component.html b/src/app/sections/routing-rules/party-routing-ruleset/add-party-routing-rule-dialog/add-party-routing-rule-dialog.component.html index 847cf360..beebdf6b 100644 --- a/src/app/sections/routing-rules/party-routing-ruleset/add-party-routing-rule-dialog/add-party-routing-rule-dialog.component.html +++ b/src/app/sections/routing-rules/party-routing-ruleset/add-party-routing-rule-dialog/add-party-routing-rule-dialog.component.html @@ -1,21 +1,22 @@
- - Shop - - - {{ shop.details.name }} - - - - - Wallet - - - {{ wallet.name }} - - - + @if (dialogData.type === 'payment') { + + } + @if (dialogData.type === 'withdrawal') { + + }
Routing ruleset
diff --git a/src/app/sections/routing-rules/party-routing-ruleset/add-party-routing-rule-dialog/add-party-routing-rule-dialog.component.ts b/src/app/sections/routing-rules/party-routing-ruleset/add-party-routing-rule-dialog/add-party-routing-rule-dialog.component.ts index ded0d956..c482e6c6 100644 --- a/src/app/sections/routing-rules/party-routing-ruleset/add-party-routing-rule-dialog/add-party-routing-rule-dialog.component.ts +++ b/src/app/sections/routing-rules/party-routing-ruleset/add-party-routing-rule-dialog/add-party-routing-rule-dialog.component.ts @@ -2,8 +2,9 @@ import { Component, DestroyRef } from '@angular/core'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { FormBuilder } from '@angular/forms'; import { Shop } from '@vality/domain-proto/domain'; +import { ShopID, WalletID } from '@vality/domain-proto/internal/domain'; import { StatWallet } from '@vality/fistful-proto/fistful_stat'; -import { DialogResponseStatus, DialogSuperclass, NotifyLogService } from '@vality/ng-core'; +import { DialogResponseStatus, DialogSuperclass, NotifyLogService, Option } from '@vality/ng-core'; import { RoutingRulesService } from '../../services/routing-rules'; import { RoutingRulesType } from '../../types/routing-rules-type'; @@ -16,12 +17,24 @@ export class AddPartyRoutingRuleDialogComponent extends DialogSuperclass< { refID: number; partyID: string; shops: Shop[]; wallets: StatWallet[]; type: RoutingRulesType } > { form = this.fb.group<{ shopID: string; walletID: string; name: string; description: string }>({ - shopID: '', - walletID: '', + shopID: null, + walletID: null, name: 'Ruleset[candidates]', description: '', }); + shopsOptions: Option[] = this.dialogData.shops.map((s) => ({ + value: s.id, + label: s.details.name, + description: s.id, + })); + + walletsOptions: Option[] = this.dialogData.wallets.map((s) => ({ + value: s.id, + label: s.name, + description: s.id, + })); + constructor( private fb: FormBuilder, private routingRulesService: RoutingRulesService, diff --git a/src/app/sections/routing-rules/party-routing-ruleset/add-party-routing-rule-dialog/add-party-routing-rule-dialog.module.ts b/src/app/sections/routing-rules/party-routing-ruleset/add-party-routing-rule-dialog/add-party-routing-rule-dialog.module.ts index 778ed6b3..89824e65 100644 --- a/src/app/sections/routing-rules/party-routing-ruleset/add-party-routing-rule-dialog/add-party-routing-rule-dialog.module.ts +++ b/src/app/sections/routing-rules/party-routing-ruleset/add-party-routing-rule-dialog/add-party-routing-rule-dialog.module.ts @@ -10,7 +10,7 @@ import { MatIconModule } from '@angular/material/icon'; import { MatInputModule } from '@angular/material/input'; import { MatRadioModule } from '@angular/material/radio'; import { MatSelectModule } from '@angular/material/select'; -import { DialogModule } from '@vality/ng-core'; +import { DialogModule, SelectFieldModule } from '@vality/ng-core'; import { AddPartyRoutingRuleDialogComponent } from './add-party-routing-rule-dialog.component'; @@ -28,6 +28,7 @@ import { AddPartyRoutingRuleDialogComponent } from './add-party-routing-rule-dia MatRadioModule, MatAutocompleteModule, DialogModule, + SelectFieldModule, ], declarations: [AddPartyRoutingRuleDialogComponent], exports: [AddPartyRoutingRuleDialogComponent], diff --git a/src/app/sections/routing-rules/party-routing-ruleset/party-routing-ruleset.component.ts b/src/app/sections/routing-rules/party-routing-ruleset/party-routing-ruleset.component.ts index ae0eac99..533e7bfc 100644 --- a/src/app/sections/routing-rules/party-routing-ruleset/party-routing-ruleset.component.ts +++ b/src/app/sections/routing-rules/party-routing-ruleset/party-routing-ruleset.component.ts @@ -1,7 +1,7 @@ import { Component, DestroyRef } from '@angular/core'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { ActivatedRoute, Router } from '@angular/router'; -import { DialogService, DialogResponseStatus } from '@vality/ng-core'; +import { DialogService, DialogResponseStatus, compareDifferentTypes } from '@vality/ng-core'; import { combineLatest } from 'rxjs'; import { filter, map, shareReplay, startWith, switchMap, take } from 'rxjs/operators'; @@ -165,20 +165,39 @@ export class PartyRoutingRulesetComponent { this.partyRoutingRulesetService.wallets$, this.routingRulesTypeService.routingRulesType$, this.partyRoutingRulesetService.partyID$, + this.partyRuleset$, ]) .pipe( take(1), - switchMap(([refID, shops, wallets, type, partyID]) => - this.dialogService + switchMap(([refID, shops, wallets, type, partyID, ruleset]) => { + return this.dialogService .open(AddPartyRoutingRuleDialogComponent, { refID, - shops, - wallets, + shops: shops + .filter((s) => + ruleset.data.decisions.delegates.every( + (d) => + d?.allowed?.condition?.party?.definition?.shop_is !== + s.id, + ), + ) + .sort((a, b) => + compareDifferentTypes(a.details.name, b.details.name), + ), + wallets: wallets + .filter((w) => + ruleset.data.decisions.delegates.every( + (d) => + d?.allowed?.condition?.party?.definition?.wallet_is !== + w.id, + ), + ) + .sort((a, b) => compareDifferentTypes(a.name, b.name)), type, partyID, }) - .afterClosed(), - ), + .afterClosed(); + }), takeUntilDestroyed(this.destroyRef), ) .subscribe({ diff --git a/src/app/sections/routing-rules/party-routing-ruleset/party-routing-ruleset.service.ts b/src/app/sections/routing-rules/party-routing-ruleset/party-routing-ruleset.service.ts index ab1f693f..aa960c04 100644 --- a/src/app/sections/routing-rules/party-routing-ruleset/party-routing-ruleset.service.ts +++ b/src/app/sections/routing-rules/party-routing-ruleset/party-routing-ruleset.service.ts @@ -43,6 +43,7 @@ export class PartyRoutingRulesetService { shops$ = defer(() => this.party$).pipe( map((p) => p.shops), map((shops) => Array.from(shops.values())), + shareReplay({ refCount: true, bufferSize: 1 }), ); wallets$ = defer(() => this.partyID$).pipe( switchMap((partyID) => diff --git a/src/app/sections/sections-routing.module.ts b/src/app/sections/sections-routing.module.ts index e099f3a9..30b6c866 100644 --- a/src/app/sections/sections-routing.module.ts +++ b/src/app/sections/sections-routing.module.ts @@ -40,10 +40,6 @@ const ROUTES: Routes = [ path: 'payments', loadChildren: () => import('./payments/payments.module').then((m) => m.PaymentsModule), }, - { - path: 'old-payments', - loadChildren: () => import('./old-payments/payments.module').then((m) => m.PaymentsModule), - }, { path: 'deposits', loadChildren: () => import('./deposits/deposits.module').then((m) => m.DepositsModule), diff --git a/src/app/sections/terms/components/shops-terms/shops-terms.component.ts b/src/app/sections/terms/components/shops-terms/shops-terms.component.ts index 860ab95e..db90a62f 100644 --- a/src/app/sections/terms/components/shops-terms/shops-terms.component.ts +++ b/src/app/sections/terms/components/shops-terms/shops-terms.component.ts @@ -24,6 +24,7 @@ import { UpdateOptions, VSelectPipe, Column2, + cachedHeadMap, } from '@vality/ng-core'; import { map, shareReplay } from 'rxjs/operators'; import { Overwrite } from 'utility-types'; @@ -86,19 +87,17 @@ export class ShopsTermsComponent implements OnInit { }), ); terms$ = this.shopsTermsService.result$.pipe( - map((terms) => - terms.map((t) => ({ - value: t, - children: getFlatDecisions(getShopCashFlowSelectors(t.current_term_set)).filter( - (v) => - isShopTermSetDecision(v, { - partyId: t.owner_id, - shopId: t.shop_id, - currency: t.currency, - }), - ), - })), - ), + cachedHeadMap((t) => ({ + value: t, + children: getFlatDecisions(getShopCashFlowSelectors(t.current_term_set)).filter((v) => + isShopTermSetDecision(v, { + partyId: t.owner_id, + shopId: t.shop_id, + currency: t.currency, + }), + ), + })), + shareReplay({ refCount: true, bufferSize: 1 }), ); hasMore$ = this.shopsTermsService.hasMore$; isLoading$ = this.shopsTermsService.isLoading$; diff --git a/src/app/sections/terms/components/terminals-terms/terminals-terms.component.ts b/src/app/sections/terms/components/terminals-terms/terminals-terms.component.ts index 22a2ab1c..c2f8ac8a 100644 --- a/src/app/sections/terms/components/terminals-terms/terminals-terms.component.ts +++ b/src/app/sections/terms/components/terminals-terms/terminals-terms.component.ts @@ -23,6 +23,7 @@ import { TableModule, UpdateOptions, VSelectPipe, + cachedHeadMap, } from '@vality/ng-core'; import { map, shareReplay } from 'rxjs/operators'; import { Overwrite } from 'utility-types'; @@ -74,7 +75,8 @@ export class TerminalsTermsComponent implements OnInit { }), ); terms$ = this.terminalsTermsService.result$.pipe( - map((terms) => terms.map(getTerminalTreeDataItem((d) => d.current_term_set))), + cachedHeadMap(getTerminalTreeDataItem((d) => d.current_term_set)), + shareReplay({ refCount: true, bufferSize: 1 }), ); hasMore$ = this.terminalsTermsService.hasMore$; isLoading$ = this.terminalsTermsService.isLoading$; diff --git a/src/app/sections/terms/components/wallets-terms/wallets-terms.component.ts b/src/app/sections/terms/components/wallets-terms/wallets-terms.component.ts index 5ac260ee..d4b4df59 100644 --- a/src/app/sections/terms/components/wallets-terms/wallets-terms.component.ts +++ b/src/app/sections/terms/components/wallets-terms/wallets-terms.component.ts @@ -27,6 +27,7 @@ import { UpdateOptions, VSelectPipe, Column2, + cachedHeadMap, } from '@vality/ng-core'; import { map, shareReplay } from 'rxjs/operators'; import { Overwrite } from 'utility-types'; @@ -89,19 +90,17 @@ export class WalletsTermsComponent implements OnInit { }), ); terms$ = this.walletsTermsService.result$.pipe( - map((terms) => - terms.map((t) => ({ - value: t, - children: getFlatDecisions(getWalletCashFlowSelectors(t.current_term_set)).filter( - (v) => - isWalletTermSetDecision(v, { - partyId: t.owner_id, - walletId: t.wallet_id, - currency: t.currency, - }), - ), - })), - ), + cachedHeadMap((t) => ({ + value: t, + children: getFlatDecisions(getWalletCashFlowSelectors(t.current_term_set)).filter((v) => + isWalletTermSetDecision(v, { + partyId: t.owner_id, + walletId: t.wallet_id, + currency: t.currency, + }), + ), + })), + shareReplay({ refCount: true, bufferSize: 1 }), ); hasMore$ = this.walletsTermsService.hasMore$; isLoading$ = this.walletsTermsService.isLoading$; diff --git a/src/app/sections/withdrawals/withdrawals.component.html b/src/app/sections/withdrawals/withdrawals.component.html index ed0f2943..06b72c0a 100644 --- a/src/app/sections/withdrawals/withdrawals.component.html +++ b/src/app/sections/withdrawals/withdrawals.component.html @@ -1,4 +1,4 @@ - + @@ -24,7 +24,7 @@ - -