Loan transactions using external identifer

This commit is contained in:
Jose Alberto Hernandez
2022-12-07 10:07:12 -06:00
parent d7346e26e4
commit 35b9669605
17 changed files with 120 additions and 49 deletions
@@ -25,6 +25,11 @@
</mat-error>
</mat-form-field>
<mat-form-field>
<mat-label>External Id</mat-label>
<input matInput formControlName="externalId">
</mat-form-field>
<mat-form-field>
<mat-label>Payment Type</mat-label>
<mat-select formControlName="paymentTypeId">
@@ -70,6 +70,7 @@ export class EditTransactionComponent implements OnInit {
this.editTransactionForm.patchValue({
'transactionDate': this.transactionTemplateData.date && new Date(this.transactionTemplateData.date),
'transactionAmount': this.transactionTemplateData.amount,
'externalId': this.transactionTemplateData.externalId,
'paymentTypeId': this.transactionTemplateData.paymentTypeId
});
}
@@ -81,6 +82,7 @@ export class EditTransactionComponent implements OnInit {
this.editTransactionForm = this.formBuilder.group({
'transactionDate': ['', Validators.required],
'transactionAmount': ['', Validators.required],
'externalId': [''],
'paymentTypeId': [''],
});
}
@@ -76,6 +76,14 @@
{{ transactionData.amount | currency:transactionData.currency.code }} {{ transactionData.currency.code }}
</div>
<div fxFlex="50%" class="mat-body-strong" *ngIf="transactionData.externalId">
{{ 'External Id' | translate }}
</div>
<div fxFlex="50%" *ngIf="transactionData.externalId">
{{ transactionData.externalId }}
</div>
<mat-divider *ngIf="existTransactionRelations" [inset]="true"></mat-divider>
<div fxFlex="100%" class="mat-body-strong" *ngIf="existTransactionRelations">
@@ -66,17 +66,20 @@ export class ViewTransactionComponent implements OnInit {
private organizationService: OrganizationService) {
this.route.data.subscribe((data: { loansAccountTransaction: any }) => {
this.transactionData = data.loansAccountTransaction;
this.allowEdition = !this.transactionData.manuallyReversed && !(this.transactionData.type.id === 20 || this.transactionData.type.id === 21 || this.transactionData.type.id === 22
|| this.transactionData.type.id === 23);
this.allowEdition = !this.transactionData.manuallyReversed && !this.allowTransactionEdition(this.transactionData.type.id);
this.allowUndo = !this.transactionData.manuallyReversed;
this.allowChargeback = this.transactionData.type.repayment;
let transactionsChargebackRelated = false;
if (this.transactionData.type.repayment) {
if (this.transactionData.transactionRelations) {
this.transactionRelations.data = this.transactionData.transactionRelations;
this.existTransactionRelations = (this.transactionData.transactionRelations.length > 0);
let amountRelations = 0;
this.transactionData.transactionRelations.forEach((relation: any) => {
amountRelations += relation.amount;
if (relation.relationType === 'CHARGEBACK') {
amountRelations += relation.amount;
transactionsChargebackRelated = true;
}
});
this.amountRelationsAllowed = this.transactionData.amount - amountRelations;
this.isFullRelated = (this.amountRelationsAllowed === 0);
@@ -86,7 +89,7 @@ export class ViewTransactionComponent implements OnInit {
if (!this.allowChargeback) {
this.allowEdition = false;
}
if (this.existTransactionRelations) {
if (this.existTransactionRelations && transactionsChargebackRelated) {
this.allowUndo = false;
}
});
@@ -103,6 +106,15 @@ export class ViewTransactionComponent implements OnInit {
}
}
/**
* Allow edit, undo and chargeback actions
*/
allowTransactionEdition(transactionType: number): boolean {
return (transactionType === 20
|| transactionType === 21 || transactionType === 22
|| transactionType === 23);
}
/**
* Undo the loans transaction
*/