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
label Сумма возврата:
input.form-control(formControlName="amount")
span.helpBlock(*ngIf="account") Баланс основного счета: {{account.availableAmount / 100}}
span.helpBlock(*ngIf="account") Баланс основного счета: {{account.availableAmount / 100}} {{account.currency | kofCurrency}}
.form-group
label Причина совершения операции:
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 form: FormGroup;
public account: Account;
public inProcess: boolean = false;
private modalElement: any;
private refundedAmount: number = 0;
private account: Account;
private settlementID: number;
constructor(private eventPollerService: EventPollerService,

View File

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