Add payements table terminal ID (#217)

This commit is contained in:
Rinat Arsaev 2023-04-26 12:57:03 +04:00 committed by GitHub
parent 910baa9fd7
commit a97bfd08f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 33 additions and 12 deletions

View File

@ -14,7 +14,7 @@
"prettier-preset": "prettier \"**/*.{html,js,ts,css,scss,md,json,prettierrc,svg,huskyrc,yml,yaml}\"",
"prettier": "npm run prettier-preset -- --list-different",
"prettier-fix": "npm run prettier-preset -- --write",
"fix": "npm:lint-fix && npm run prettier-fix"
"fix": "npm run lint-fix && npm run prettier-fix"
},
"dependencies": {
"@angular/animations": "15.0.3",

View File

@ -5,7 +5,7 @@ import {
wallet_Management,
} from '@vality/fistful-proto';
import { ContextSet } from '@vality/fistful-proto/internal/context';
import { WalletParams } from '@vality/fistful-proto/internal/wallet';
import { AccountBalance, WalletParams } from '@vality/fistful-proto/internal/wallet';
import { WalletID, EventRange, WalletState } from '@vality/fistful-proto/wallet';
import { combineLatest, from, map, Observable, switchMap } from 'rxjs';
@ -46,4 +46,9 @@ export class ManagementService {
Create(params: WalletParams, context: ContextSet): Observable<WalletState> {
return this.client$.pipe(switchMap((c) => c.Create(params, context)));
}
// eslint-disable-next-line @typescript-eslint/naming-convention
GetAccountBalance(id: WalletID): Observable<AccountBalance> {
return this.client$.pipe(switchMap((c) => c.GetAccountBalance(id)));
}
}

View File

@ -42,7 +42,7 @@
</button>
<ng-template #balanceTpl>
<ng-container *ngIf="getBalance(row.id) | async as account; else spinner">
{{ account.own_amount | amountCurrency : account.currency_sym_code }}
{{ account.current | amountCurrency : account.currency.symbolic_code }}
</ng-container>
<ng-template #spinner>
<button [loading]="true" class="cell-button" mat-icon-button></button>

View File

@ -4,7 +4,7 @@ import { untilDestroyed, UntilDestroy } from '@ngneat/until-destroy';
import { StatWallet } from '@vality/fistful-proto/internal/fistful_stat';
import { clean, splitIds } from '@vality/ng-core';
import { of } from 'rxjs';
import { startWith, map, shareReplay, switchMap, catchError } from 'rxjs/operators';
import { startWith, map, shareReplay, catchError } from 'rxjs/operators';
import { Memoize } from 'typescript-memoize';
import { AccounterService } from '@cc/app/api/accounter';
@ -82,10 +82,7 @@ export class WalletsComponent implements OnInit {
@Memoize()
getBalance(walletId: string) {
return this.walletManagementService.Get(walletId, {}).pipe(
switchMap((wallet) =>
this.accounterService.GetAccountByID(Number(wallet.account.accounter_account_id))
),
return this.walletManagementService.GetAccountBalance(walletId).pipe(
catchError((err) => {
this.errorService.error(err);
return of({});

View File

@ -58,6 +58,13 @@
</td>
</ng-container>
<ng-container matColumnDef="terminal_id">
<th *matHeaderCellDef mat-header-cell>Terminal</th>
<td *matCellDef="let payment" mat-cell>
{{ payment.terminal_id.id }}
</td>
</ng-container>
<ng-container matColumnDef="actions" stickyEnd>
<th *matHeaderCellDef class="action-cell" mat-header-cell></th>
<td *matCellDef="let payment" class="action-cell" mat-cell>

View File

@ -32,6 +32,7 @@ export class PaymentsTableComponent {
'revision',
'invoice',
'party',
'terminal_id',
'actions'
);
selection = new SelectionModel<StatPayment>();

View File

@ -1,9 +1,10 @@
import { formatCurrency, getCurrencySymbol } from '@angular/common';
import { Pipe, Inject, LOCALE_ID, DEFAULT_CURRENCY_CODE, PipeTransform } from '@angular/core';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { CurrencyObject } from '@vality/domain-proto/domain';
import isNil from 'lodash-es/isNil';
import { ReplaySubject, combineLatest } from 'rxjs';
import { map } from 'rxjs/operators';
import { map, startWith } from 'rxjs/operators';
import { DomainStoreService } from '@cc/app/api/deprecated-damsel';
@ -32,13 +33,23 @@ export class AmountCurrencyPipe implements PipeTransform {
init() {
this.isInit = true;
combineLatest([this.domainStoreService.getObjects('currency'), this.params$])
combineLatest([
this.domainStoreService.getObjects('currency').pipe(startWith([] as CurrencyObject[])),
this.params$,
])
.pipe(
map(([currencies, { amount, currencyCode, format }]) => {
if (isNil(amount)) return '?';
if (!currencyCode) return String(amount);
const exponent = currencies.find((c) => c.data.symbolic_code === currencyCode)
.data.exponent;
?.data?.exponent;
if (!currencyCode || !exponent)
return formatCurrency(
toMajor(amount, exponent),
this._locale,
'',
'',
format === 'short' ? '0.0-2' : undefined
);
return formatCurrency(
toMajor(amount, exponent),
this._locale,