From 22afdb21e1e1dd0ff96b7d91dc7ac8046676a500 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Alberto=20Hern=C3=A1ndez?= <44206706+josehernandezfintecheandomx@users.noreply.github.com> Date: Thu, 13 Jul 2023 23:34:22 -0600 Subject: [PATCH] Allow Chargeback transaction over payment transactions (#1784) Co-authored-by: Jose Alberto Hernandez --- .../loans/loans-view/loans-view.component.ts | 2 +- .../reschedule-loan-tab.component.ts | 2 +- .../view-transaction.component.ts | 14 +++++++-- ...n-status.nodel.ts => loan-status.model.ts} | 0 .../models/loan-transaction-type.model.ts | 30 +++++++++++++++++++ 5 files changed, 43 insertions(+), 5 deletions(-) rename src/app/loans/models/{loan-status.nodel.ts => loan-status.model.ts} (100%) create mode 100644 src/app/loans/models/loan-transaction-type.model.ts diff --git a/src/app/loans/loans-view/loans-view.component.ts b/src/app/loans/loans-view/loans-view.component.ts index 8a29573a6..42b1efa58 100644 --- a/src/app/loans/loans-view/loans-view.component.ts +++ b/src/app/loans/loans-view/loans-view.component.ts @@ -12,7 +12,7 @@ import { LoansAccountButtonConfiguration } from './loan-accounts-button-config'; /** Dialog Components */ import { ConfirmationDialogComponent } from '../../shared/confirmation-dialog/confirmation-dialog.component'; import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component'; -import { LoanStatus } from '../models/loan-status.nodel'; +import { LoanStatus } from '../models/loan-status.model'; @Component({ selector: 'mifosx-loans-view', diff --git a/src/app/loans/loans-view/reschedule-loan-tab/reschedule-loan-tab.component.ts b/src/app/loans/loans-view/reschedule-loan-tab/reschedule-loan-tab.component.ts index 84a230a84..4de3a5bc0 100644 --- a/src/app/loans/loans-view/reschedule-loan-tab/reschedule-loan-tab.component.ts +++ b/src/app/loans/loans-view/reschedule-loan-tab/reschedule-loan-tab.component.ts @@ -3,7 +3,7 @@ import { MatDialog } from '@angular/material/dialog'; import { ActivatedRoute, Router } from '@angular/router'; import { Dates } from 'app/core/utils/dates'; import { LoansService } from 'app/loans/loans.service'; -import { LoanStatus } from 'app/loans/models/loan-status.nodel'; +import { LoanStatus } from 'app/loans/models/loan-status.model'; import { SettingsService } from 'app/settings/settings.service'; import { ConfirmationDialogComponent } from 'app/shared/confirmation-dialog/confirmation-dialog.component'; diff --git a/src/app/loans/loans-view/transactions/view-transaction/view-transaction.component.ts b/src/app/loans/loans-view/transactions/view-transaction/view-transaction.component.ts index 133e43075..d1cb5c7a5 100644 --- a/src/app/loans/loans-view/transactions/view-transaction/view-transaction.component.ts +++ b/src/app/loans/loans-view/transactions/view-transaction/view-transaction.component.ts @@ -14,6 +14,7 @@ import { InputBase } from 'app/shared/form-dialog/formfield/model/input-base'; import { SelectBase } from 'app/shared/form-dialog/formfield/model/select-base'; import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.component'; import { MatTableDataSource } from '@angular/material/table'; +import { LoanTransactionType } from 'app/loans/models/loan-transaction-type.model'; /** Custom Dialogs */ @@ -68,9 +69,10 @@ export class ViewTransactionComponent implements OnInit { this.transactionData = data.loansAccountTransaction; this.allowEdition = !this.transactionData.manuallyReversed && !this.allowTransactionEdition(this.transactionData.type.id); this.allowUndo = !this.transactionData.manuallyReversed; - this.allowChargeback = this.transactionData.type.repayment && !this.transactionData.manuallyReversed; + console.log(this.transactionData.type); + this.allowChargeback = this.allowChargebackTransaction(this.transactionData.type) && !this.transactionData.manuallyReversed; let transactionsChargebackRelated = false; - if (this.transactionData.type.repayment) { + if (this.allowChargeback) { if (this.transactionData.transactionRelations) { this.transactionRelations.data = this.transactionData.transactionRelations; this.existTransactionRelations = (this.transactionData.transactionRelations.length > 0); @@ -83,7 +85,7 @@ export class ViewTransactionComponent implements OnInit { }); this.amountRelationsAllowed = this.transactionData.amount - amountRelations; this.isFullRelated = (this.amountRelationsAllowed === 0); - this.allowChargeback = this.transactionData.type.repayment && !this.isFullRelated; + this.allowChargeback = this.allowChargebackTransaction(this.transactionData.type) && !this.isFullRelated; } } if (!this.allowChargeback) { @@ -115,6 +117,12 @@ export class ViewTransactionComponent implements OnInit { || transactionType === 23); } + allowChargebackTransaction(transactionType: LoanTransactionType): boolean { + return (transactionType.repayment + || transactionType.goodwillCredit || transactionType.payoutRefund + || transactionType.merchantIssuedRefund); + } + /** * Undo the loans transaction */ diff --git a/src/app/loans/models/loan-status.nodel.ts b/src/app/loans/models/loan-status.model.ts similarity index 100% rename from src/app/loans/models/loan-status.nodel.ts rename to src/app/loans/models/loan-status.model.ts diff --git a/src/app/loans/models/loan-transaction-type.model.ts b/src/app/loans/models/loan-transaction-type.model.ts new file mode 100644 index 000000000..260186df3 --- /dev/null +++ b/src/app/loans/models/loan-transaction-type.model.ts @@ -0,0 +1,30 @@ +export interface LoanTransactionType { + id: number; + code: string; + value: string; + + accrual: boolean; + approveTransfer: boolean; + chargeAdjustment: boolean; + chargePayment: boolean; + chargeRefund: boolean; + chargeback: boolean; + chargeoff: boolean; + contra: boolean; + creditBalanceRefund: boolean; + disbursement: boolean; + goodwillCredit: boolean; + initiateTransfer: boolean; + merchantIssuedRefund: boolean; + payoutRefund: boolean; + recoveryRepayment: boolean; + refund: boolean; + refundForActiveLoans: boolean; + rejectTransfer: boolean; + repayment: boolean; + repaymentAtDisbursement: boolean; + waiveCharges: boolean; + waiveInterest: boolean; + withdrawTransfer: boolean; + writeOff: boolean; +}