Skip to content

Commit

Permalink
Allow Chargeback transaction over payment transactions (#1784)
Browse files Browse the repository at this point in the history
Co-authored-by: Jose Alberto Hernandez <[email protected]>
  • Loading branch information
josehernandezfintecheandomx and Jose Alberto Hernandez authored Jul 14, 2023
1 parent e1e3429 commit 22afdb2
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/app/loans/loans-view/loans-view.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down Expand Up @@ -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);
Expand All @@ -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) {
Expand Down Expand Up @@ -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
*/
Expand Down
File renamed without changes.
30 changes: 30 additions & 0 deletions src/app/loans/models/loan-transaction-type.model.ts
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit 22afdb2

Please sign in to comment.