Allow Chargeback transaction over payment transactions (#1784)

Co-authored-by: Jose Alberto Hernandez <alberto@blue-daemon.local>
This commit is contained in:
José Alberto Hernández
2023-07-13 23:34:22 -06:00
committed by GitHub
co-authored by Jose Alberto Hernandez
parent e1e3429b66
commit 22afdb21e1
5 changed files with 43 additions and 5 deletions
@@ -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',
@@ -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';
@@ -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
*/
@@ -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;
}