New Loan transactions

This commit is contained in:
Jose Alberto Hernandez
2022-08-07 23:07:56 -05:00
parent 1c8a772de6
commit e394becdcc
12 changed files with 386 additions and 110 deletions
@@ -4,6 +4,10 @@
<mifosx-foreclosure *ngIf="actions['Foreclosure']"></mifosx-foreclosure>
<mifosx-prepay-loan [dataObject]="actionButtonData" *ngIf="actions['Prepay Loan']"></mifosx-prepay-loan>
<mifosx-make-repayment [dataObject]="actionButtonData" *ngIf="actions['Make Repayment']"></mifosx-make-repayment>
<mifosx-make-repayment [dataObject]="actionButtonData" *ngIf="actions['Goodwill Credit']"></mifosx-make-repayment>
<mifosx-make-repayment [dataObject]="actionButtonData" *ngIf="actions['Payout Refund']"></mifosx-make-repayment>
<mifosx-make-repayment [dataObject]="actionButtonData" *ngIf="actions['Merchant Issued Refund']"></mifosx-make-repayment>
<mifosx-loan-credit-balance-refund [dataObject]="actionButtonData" *ngIf="actions['Credit Balance Refund']"></mifosx-loan-credit-balance-refund>
<mifosx-waive-interest [dataObject]="actionButtonData" *ngIf="actions['Waive Interest']"></mifosx-waive-interest>
<mifosx-write-off-page [dataObject]="actionButtonData" *ngIf="actions['Write Off']"></mifosx-write-off-page>
<mifosx-close-as-rescheduled [dataObject]="actionButtonData" *ngIf="actions['Close (as Rescheduled)']"></mifosx-close-as-rescheduled>
@@ -34,7 +34,12 @@ export class LoanAccountActionsComponent {
'Undo Disbursal': boolean,
'Loan Screen Reports': boolean,
'Approve': boolean,
'Add Loan Charge': boolean } = {
'Add Loan Charge': boolean,
'Goodwill Credit': boolean,
'Merchant Issued Refund': boolean,
'Payout Refund': boolean,
'Credit Balance Refund': boolean
} = {
'Close': false,
'Undo Approval': false,
'Write Off': false,
@@ -56,7 +61,12 @@ export class LoanAccountActionsComponent {
'Undo Disbursal': false,
'Loan Screen Reports': false,
'Approve': false,
'Add Loan Charge': false };
'Add Loan Charge': false,
'Goodwill Credit': false,
'Merchant Issued Refund': false,
'Payout Refund': false,
'Credit Balance Refund': false
};
actionButtonData: any;
actionName: any;
@@ -0,0 +1,54 @@
<div class="container">
<mat-card>
<form [formGroup]="creditBalanceLoanForm" (ngSubmit)="submit()">
<mat-card-content>
<div fxLayout="column">
<mat-form-field (click)="transactionDatePicker.open()">
<mat-label>Transaction Date</mat-label>
<input matInput [min]="minDate" [max]="maxDate" [matDatepicker]="transactionDatePicker" required
formControlName="transactionDate">
<mat-datepicker-toggle matSuffix [for]="transactionDatePicker"></mat-datepicker-toggle>
<mat-datepicker #transactionDatePicker></mat-datepicker>
<mat-error *ngIf="creditBalanceLoanForm.controls.transactionDate.hasError('required')">
Transaction Date <strong>is required</strong>
</mat-error>
</mat-form-field>
<mat-form-field>
<mat-label>Transaction Amount</mat-label>
<input matInput required formControlName="transactionAmount">
<mat-error *ngIf="creditBalanceLoanForm.controls.transactionAmount.hasError('required')">
Transaction Amount <strong>is required</strong>
</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>Note</mat-label>
<textarea matInput formControlName="note"></textarea>
</mat-form-field>
</div>
<mat-card-actions fxLayout="row" fxLayout.xs="column" fxLayoutAlign="center" fxLayoutGap="5px">
<button type="button" mat-raised-button [routerLink]="['../../general']">Cancel</button>
<button mat-raised-button color="primary" [disabled]="!creditBalanceLoanForm.valid"
*mifosxHasPermission="'REPAYMENT_LOAN'">Submit</button>
</mat-card-actions>
</mat-card-content>
</form>
</mat-card>
</div>
@@ -0,0 +1,7 @@
.expandcollapsebutton {
margin-top: -7px;
}
.container {
max-width: 37rem;
}
@@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { LoanCreditBalanceRefundComponent } from './loan-credit-balance-refund.component';
describe('LoanCreditBalanceRefundComponent', () => {
let component: LoanCreditBalanceRefundComponent;
let fixture: ComponentFixture<LoanCreditBalanceRefundComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ LoanCreditBalanceRefundComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(LoanCreditBalanceRefundComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,90 @@
import { Component, Input, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import { Dates } from 'app/core/utils/dates';
import { LoansService } from 'app/loans/loans.service';
import { SettingsService } from 'app/settings/settings.service';
@Component({
selector: 'mifosx-loan-credit-balance-refund',
templateUrl: './loan-credit-balance-refund.component.html',
styleUrls: ['./loan-credit-balance-refund.component.scss']
})
export class LoanCreditBalanceRefundComponent implements OnInit {
@Input() dataObject: any;
/** Loan Id */
loanId: string;
/** Minimum Date allowed. */
minDate = new Date(2000, 0, 1);
/** Maximum Date allowed. */
maxDate = new Date();
/** Credit Balance Loan Form */
creditBalanceLoanForm: FormGroup;
/**
* @param {FormBuilder} formBuilder Form Builder.
* @param {LoansService} loanService Loan Service.
* @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation.
* @param {SettingsService} settingsService Settings Service
*/
constructor(private formBuilder: FormBuilder,
private loanService: LoansService,
private route: ActivatedRoute,
private router: Router,
private dateUtils: Dates,
private settingsService: SettingsService) {
this.loanId = this.route.parent.snapshot.params['loanId'];
}
/**
* Creates the Credit Balance loan form
* and initialize with the required values
*/
ngOnInit() {
this.maxDate = this.settingsService.businessDate;
this.createCreditBalanceLoanForm();
this.setCreditBalanceLoanDetails();
}
/**
* Creates the create close form.
*/
createCreditBalanceLoanForm() {
this.creditBalanceLoanForm = this.formBuilder.group({
'transactionDate': [new Date(), Validators.required],
'transactionAmount': ['', Validators.required],
'externalId': '',
'note': ''
});
}
setCreditBalanceLoanDetails() {
this.creditBalanceLoanForm.patchValue({
transactionAmount: this.dataObject.amount
});
}
/** Submits the Credit Balance form */
submit() {
const creditBalanceLoanFormData = this.creditBalanceLoanForm.value;
const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat;
const prevTransactionDate: Date = this.creditBalanceLoanForm.value.transactionDate;
if (creditBalanceLoanFormData.transactionDate instanceof Date) {
creditBalanceLoanFormData.transactionDate = this.dateUtils.formatDate(prevTransactionDate, dateFormat);
}
const data = {
...creditBalanceLoanFormData,
dateFormat,
locale
};
const command = this.dataObject.type.code.split('.')[1];
this.loanService.submitLoanActionButton(this.loanId, data, command)
.subscribe((response: any) => {
this.router.navigate(['../../transactions'], { relativeTo: this.route });
});
}
}
@@ -111,7 +111,8 @@ export class MakeRepaymentComponent implements OnInit {
dateFormat,
locale
};
this.loanService.submitLoanActionButton(this.loanId, data, 'repayment')
const command = this.dataObject.type.code.split('.')[1];
this.loanService.submitLoanActionButton(this.loanId, data, command)
.subscribe((response: any) => {
this.router.navigate(['../../transactions'], { relativeTo: this.route });
});