mirror of
https://github.com/valitydev/control-center.git
synced 2024-11-06 02:25:17 +00:00
IMP-188, IMP-213: Always generate withdrawal adjustment id. Move external id to payments main filters (#347)
This commit is contained in:
parent
d571485f31
commit
b185890065
8
package-lock.json
generated
8
package-lock.json
generated
@ -25,7 +25,7 @@
|
||||
"@vality/fistful-proto": "2.0.1-6600be9.0",
|
||||
"@vality/machinegun-proto": "1.0.0",
|
||||
"@vality/magista-proto": "2.0.2-28d11b9.0",
|
||||
"@vality/ng-core": "17.2.1-pr-57-1a93ecb.0",
|
||||
"@vality/ng-core": "17.2.1-pr-60-8d151ad.0",
|
||||
"@vality/payout-manager-proto": "2.0.1-eb4091a.0",
|
||||
"@vality/repairer-proto": "2.0.2-07b73e9.0",
|
||||
"@vality/thrift-ts": "2.4.1-8ad5123.0",
|
||||
@ -6454,9 +6454,9 @@
|
||||
"integrity": "sha512-BsDy5ejotfTtUlwuoX3kz+PYJ5NSTW6m5ZRGv+p5HaKXSjR7tserPdv0q133Wp4T+sg0ED0Qr9Peqsrn+9XlDQ=="
|
||||
},
|
||||
"node_modules/@vality/ng-core": {
|
||||
"version": "17.2.1-pr-57-1a93ecb.0",
|
||||
"resolved": "https://registry.npmjs.org/@vality/ng-core/-/ng-core-17.2.1-pr-57-1a93ecb.0.tgz",
|
||||
"integrity": "sha512-X3PXwqZu6Wej0ETv7mqI6VIZrLJ72GnTszkpbmJkEo+MZSdgzFfgyqMglNz8QKZ0ORclszjlG41J4jtBKspvVQ==",
|
||||
"version": "17.2.1-pr-60-8d151ad.0",
|
||||
"resolved": "https://registry.npmjs.org/@vality/ng-core/-/ng-core-17.2.1-pr-60-8d151ad.0.tgz",
|
||||
"integrity": "sha512-CTPRbj/W7hNBd4yYKM4u5BJK00Q93F8xrc4xJ8QusNlaJM0FGF0eqtZMAOJ4r9ViPeAbwU0c8B6gkvgwrXrvJw==",
|
||||
"dependencies": {
|
||||
"@angular/material-date-fns-adapter": "^17.2.0",
|
||||
"@ng-matero/extensions": "^17.1.0",
|
||||
|
@ -33,7 +33,7 @@
|
||||
"@vality/fistful-proto": "2.0.1-6600be9.0",
|
||||
"@vality/machinegun-proto": "1.0.0",
|
||||
"@vality/magista-proto": "2.0.2-28d11b9.0",
|
||||
"@vality/ng-core": "17.2.1-pr-57-1a93ecb.0",
|
||||
"@vality/ng-core": "17.2.1-pr-60-8d151ad.0",
|
||||
"@vality/payout-manager-proto": "2.0.1-eb4091a.0",
|
||||
"@vality/repairer-proto": "2.0.2-07b73e9.0",
|
||||
"@vality/thrift-ts": "2.4.1-8ad5123.0",
|
||||
|
@ -15,6 +15,7 @@
|
||||
formControlName="invoice_ids"
|
||||
label="Invoice and Payment Ids"
|
||||
></v-list-field>
|
||||
<v-input-field formControlName="external_id" label="External Id"></v-input-field>
|
||||
<cc-merchant-field formControlName="party_id"></cc-merchant-field>
|
||||
<cc-shop-field
|
||||
[partyId]="filtersForm.value.party_id"
|
||||
@ -44,11 +45,10 @@
|
||||
[selected]="selected$ | async"
|
||||
(more)="more()"
|
||||
(selectedChange)="selected$.next($event)"
|
||||
(update)="load($event ?? {})"
|
||||
(update)="update($event ?? {})"
|
||||
>
|
||||
<button
|
||||
[disabled]="!(selected$ | async)?.length"
|
||||
color="primary"
|
||||
mat-raised-button
|
||||
(click)="failMachines()"
|
||||
>
|
||||
|
@ -54,6 +54,7 @@ export class PaymentsComponent implements OnInit {
|
||||
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: {},
|
||||
@ -74,6 +75,7 @@ export class PaymentsComponent implements OnInit {
|
||||
'payment_last4',
|
||||
'payment_rrn',
|
||||
'error_message',
|
||||
'external_id',
|
||||
].includes(data?.field?.name),
|
||||
),
|
||||
extension: () => of({ hidden: true }),
|
||||
@ -120,7 +122,7 @@ export class PaymentsComponent implements OnInit {
|
||||
|
||||
load({ filters, otherFilters, dateRange }: Filters, options?: LoadOptions) {
|
||||
void this.qp.set({ filters, otherFilters, dateRange });
|
||||
const { invoice_ids, party_id, shop_ids, ...paymentParams } = filters;
|
||||
const { invoice_ids, party_id, shop_ids, external_id, ...paymentParams } = filters;
|
||||
const searchParams = clean({
|
||||
...otherFilters,
|
||||
common_search_query_params: {
|
||||
@ -131,6 +133,7 @@ export class PaymentsComponent implements OnInit {
|
||||
to_time: getNoTimeZoneIsoString(endOfDay(dateRange.end)),
|
||||
},
|
||||
payment_params: { ...(otherFilters.payment_params || {}), ...paymentParams },
|
||||
external_id,
|
||||
invoice_ids,
|
||||
});
|
||||
this.fetchPaymentsService.load(searchParams, options);
|
||||
@ -142,6 +145,10 @@ export class PaymentsComponent implements OnInit {
|
||||
) + +!isEqualDateRange(dateRange, createDateRangeToToday(this.dateRangeDays));
|
||||
}
|
||||
|
||||
update(options?: LoadOptions) {
|
||||
this.fetchPaymentsService.reload(options);
|
||||
}
|
||||
|
||||
createPaymentAdjustment() {
|
||||
this.dialogService
|
||||
.open(CreatePaymentAdjustmentComponent, {
|
||||
@ -150,7 +157,7 @@ export class PaymentsComponent implements OnInit {
|
||||
.afterClosed()
|
||||
.subscribe((res) => {
|
||||
if (res.status === DialogResponseStatus.Success) {
|
||||
this.fetchPaymentsService.reload();
|
||||
this.update();
|
||||
this.selected$.next([]);
|
||||
} else if (res.data?.errors?.length) {
|
||||
this.selected$.next(res.data.errors.map(({ data }) => data));
|
||||
@ -167,7 +174,7 @@ export class PaymentsComponent implements OnInit {
|
||||
.afterClosed()
|
||||
.subscribe((res) => {
|
||||
if (res.status === DialogResponseStatus.Success) {
|
||||
this.fetchPaymentsService.reload();
|
||||
this.update();
|
||||
this.selected$.next([]);
|
||||
} else if (res.data?.errors?.length) {
|
||||
this.selected$.next(
|
||||
|
@ -1,29 +1,14 @@
|
||||
<v-dialog [progress]="progress$ | async" title="Create Adjustment">
|
||||
<div style="display: grid; grid-template-columns: 1fr; gap: 16px">
|
||||
<mat-radio-group
|
||||
[formControl]="typeControl"
|
||||
style="display: grid; grid-template-columns: 1fr 1fr; gap: 8px"
|
||||
>
|
||||
<mat-radio-button [value]="0">Use ID from withdrawal</mat-radio-button>
|
||||
<mat-radio-button [value]="1">Generate ID</mat-radio-button>
|
||||
</mat-radio-group>
|
||||
<cc-metadata-form
|
||||
[formControl]="control"
|
||||
[metadata]="metadata$ | async"
|
||||
namespace="withdrawal_adjustment"
|
||||
type="ChangeRequest"
|
||||
></cc-metadata-form>
|
||||
<cc-metadata-form
|
||||
[extensions]="externalIdExtensions"
|
||||
[formControl]="externalIdControl"
|
||||
[metadata]="metadata$ | async"
|
||||
namespace="base"
|
||||
type="ExternalID"
|
||||
></cc-metadata-form>
|
||||
</div>
|
||||
<cc-fistful-thrift-form
|
||||
[extensions]="extensions"
|
||||
[formControl]="control"
|
||||
namespace="withdrawal_adjustment"
|
||||
noToolbar
|
||||
type="AdjustmentParams"
|
||||
></cc-fistful-thrift-form>
|
||||
<v-dialog-actions>
|
||||
<button
|
||||
[disabled]="control.invalid"
|
||||
[disabled]="control.invalid || (progress$ | async)"
|
||||
color="primary"
|
||||
mat-button
|
||||
(click)="createAdjustment()"
|
||||
|
@ -1,15 +1,18 @@
|
||||
import { Component, DestroyRef } from '@angular/core';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { Validators, FormControl } from '@angular/forms';
|
||||
import { ChangeRequest } from '@vality/fistful-proto/deposit_adjustment';
|
||||
import { StatWithdrawal } from '@vality/fistful-proto/fistful_stat';
|
||||
import { ExternalID } from '@vality/fistful-proto/withdrawal_adjustment';
|
||||
import { AdjustmentParams } from '@vality/fistful-proto/withdrawal_adjustment';
|
||||
import { DialogSuperclass, forkJoinToResult, NotifyLogService } from '@vality/ng-core';
|
||||
import { from, of, BehaviorSubject } from 'rxjs';
|
||||
import { BehaviorSubject, of } from 'rxjs';
|
||||
import * as short from 'short-uuid';
|
||||
|
||||
import { ManagementService } from '@cc/app/api/withdrawal';
|
||||
import { MetadataFormExtension } from '@cc/app/shared/components/metadata-form';
|
||||
|
||||
import {
|
||||
MetadataFormExtension,
|
||||
isTypeWithAliases,
|
||||
} from '../../../../shared/components/metadata-form';
|
||||
|
||||
@Component({
|
||||
templateUrl: './create-adjustment-dialog.component.html',
|
||||
@ -18,23 +21,23 @@ export class CreateAdjustmentDialogComponent extends DialogSuperclass<
|
||||
CreateAdjustmentDialogComponent,
|
||||
{ withdrawals: StatWithdrawal[] }
|
||||
> {
|
||||
control = new FormControl<ChangeRequest>(
|
||||
control = new FormControl<Partial<AdjustmentParams>>(
|
||||
{
|
||||
change_status: {
|
||||
new_status: { failed: { failure: { code: 'account_limit_exceeded:unknown' } } },
|
||||
id: '-',
|
||||
change: {
|
||||
change_status: {
|
||||
new_status: { failed: { failure: { code: 'account_limit_exceeded:unknown' } } },
|
||||
},
|
||||
},
|
||||
},
|
||||
[Validators.required],
|
||||
);
|
||||
externalIdControl = new FormControl() as FormControl<ExternalID>;
|
||||
externalIdExtensions: MetadataFormExtension[] = [
|
||||
extensions: MetadataFormExtension[] = [
|
||||
{
|
||||
determinant: () => of(true),
|
||||
extension: () => of({ label: 'External ID' }),
|
||||
determinant: (d) => of(isTypeWithAliases(d, 'AdjustmentID', 'withdrawal_adjustment')),
|
||||
extension: () => of({ hidden: true }),
|
||||
},
|
||||
];
|
||||
typeControl = new FormControl<number>(1);
|
||||
metadata$ = from(import('@vality/fistful-proto/metadata.json').then((m) => m.default));
|
||||
progress$ = new BehaviorSubject(0);
|
||||
|
||||
constructor(
|
||||
@ -49,10 +52,9 @@ export class CreateAdjustmentDialogComponent extends DialogSuperclass<
|
||||
forkJoinToResult(
|
||||
this.dialogData.withdrawals.map((w) =>
|
||||
this.managementService.CreateAdjustment(w.id, {
|
||||
id: this.typeControl.value === 0 ? w.id : short().uuid(),
|
||||
change: this.control.value,
|
||||
external_id: this.externalIdControl.value,
|
||||
}),
|
||||
...this.control.value,
|
||||
id: short().uuid(),
|
||||
} as AdjustmentParams),
|
||||
),
|
||||
this.progress$,
|
||||
)
|
||||
|
@ -21,6 +21,7 @@ import {
|
||||
} from '@vality/ng-core';
|
||||
|
||||
import { PageLayoutModule } from '../../shared';
|
||||
import { FistfulThriftFormComponent } from '../../shared/components/fistful-thrift-form';
|
||||
import { MerchantFieldModule } from '../../shared/components/merchant-field';
|
||||
import { MetadataFormModule } from '../../shared/components/metadata-form';
|
||||
import { ThriftPipesModule } from '../../shared/pipes/thrift';
|
||||
@ -55,6 +56,7 @@ import { WithdrawalsComponent } from './withdrawals.component';
|
||||
DateRangeFieldModule,
|
||||
InputFieldModule,
|
||||
NumberRangeFieldModule,
|
||||
FistfulThriftFormComponent,
|
||||
],
|
||||
declarations: [WithdrawalsComponent, CreateAdjustmentDialogComponent],
|
||||
})
|
||||
|
@ -5,5 +5,6 @@
|
||||
[metadata]="metadata$ | async"
|
||||
[namespace]="namespace ?? defaultNamespace"
|
||||
[noChangeKind]="noChangeKind"
|
||||
[noToolbar]="noToolbar"
|
||||
[type]="type"
|
||||
></cc-thrift-editor>
|
||||
|
@ -2,6 +2,7 @@ import { inject } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { PossiblyAsync, ColumnObject, getPossiblyAsyncObservable } from '@vality/ng-core';
|
||||
import get from 'lodash-es/get';
|
||||
import { of } from 'rxjs';
|
||||
import { switchMap, map, take } from 'rxjs/operators';
|
||||
|
||||
import { PartiesStoreService } from '../../../api/payment-processing';
|
||||
@ -20,7 +21,11 @@ export function createPartyColumn<T extends object>(
|
||||
if (!selectPartyEmail) {
|
||||
selectPartyEmail = (d: T) =>
|
||||
getPossiblyAsyncObservable(selectPartyId(d)).pipe(
|
||||
switchMap((partyId) => partiesStoreService.get(partyId)),
|
||||
switchMap((partyId) =>
|
||||
partyId
|
||||
? partiesStoreService.get(partyId)
|
||||
: of({ contact_info: { email: '' } }),
|
||||
),
|
||||
map((p) => p.contact_info.email),
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user