FE-578: refund btn (#196)

This commit is contained in:
Alexandra Usacheva 2018-03-22 19:33:32 +03:00 committed by GitHub
parent fa4f5a9efe
commit c968e73a99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 8 deletions

View File

@ -14,7 +14,7 @@ button.btn.btn-default.btn-sm(data-toggle="modal", [attr.data-target]="'#' + pay
.form-group .form-group
label Сумма возврата: label Сумма возврата:
input.form-control(formControlName="amount") input.form-control(formControlName="amount")
span.helpBlock(*ngIf="account") Баланс основного счета: {{account.availableAmount / 100}} span.helpBlock(*ngIf="account") Баланс основного счета: {{account.availableAmount / 100}} {{account.currency | kofCurrency}}
.form-group .form-group
label Причина совершения операции: label Причина совершения операции:
textarea.form-control(formControlName="reason", rows="5") textarea.form-control(formControlName="reason", rows="5")

View File

@ -32,11 +32,11 @@ export class PaymentRefundComponent implements OnInit, OnChanges, AfterViewInit
public onRefund: EventEmitter<void> = new EventEmitter(); public onRefund: EventEmitter<void> = new EventEmitter();
public form: FormGroup; public form: FormGroup;
public account: Account;
public inProcess: boolean = false; public inProcess: boolean = false;
private modalElement: any; private modalElement: any;
private refundedAmount: number = 0; private refundedAmount: number = 0;
private account: Account;
private settlementID: number; private settlementID: number;
constructor(private eventPollerService: EventPollerService, constructor(private eventPollerService: EventPollerService,

View File

@ -36,12 +36,16 @@ export class PaymentRefundsComponent implements OnInit {
} }
public isRefundActionAvailable(): boolean { public isRefundActionAvailable(): boolean {
if (this.refunds) { let result: boolean = false;
const totalRefunded = this.refunds.reduce((acc, current) => current.status === 'succeeded' ? acc + current.amount : acc, 0); if (this.payment.status === 'captured') {
return totalRefunded < this.payment.amount - 1000; if (this.refunds) {
} else { const totalRefunded = this.refunds.reduce((acc, current) => current.status === 'succeeded' ? acc + current.amount : acc, 0);
return true; result = totalRefunded < this.payment.amount - 1000;
} else {
result = true;
}
} }
return result;
} }
private getRefunds() { private getRefunds() {