From e394becdcc142b133c1035aea54509c04413c97f Mon Sep 17 00:00:00 2001 From: Jose Alberto Hernandez Date: Thu, 4 Aug 2022 13:31:12 -0500 Subject: [PATCH] New Loan transactions --- .../loan-action-button.resolver.ts | 10 +- src/app/loans/loans-routing.module.ts | 2 +- .../loan-account-actions.component.html | 4 + .../loan-account-actions.component.ts | 14 +- .../loan-credit-balance-refund.component.html | 54 ++++ .../loan-credit-balance-refund.component.scss | 7 + ...an-credit-balance-refund.component.spec.ts | 25 ++ .../loan-credit-balance-refund.component.ts | 90 +++++++ .../make-repayment.component.ts | 3 +- .../loans-view/loan-accounts-button-config.ts | 52 +++- .../loans-view/loans-view.component.html | 231 ++++++++++-------- src/app/loans/loans.module.ts | 4 +- 12 files changed, 386 insertions(+), 110 deletions(-) create mode 100644 src/app/loans/loans-view/loan-account-actions/loan-credit-balance-refund/loan-credit-balance-refund.component.html create mode 100644 src/app/loans/loans-view/loan-account-actions/loan-credit-balance-refund/loan-credit-balance-refund.component.scss create mode 100644 src/app/loans/loans-view/loan-account-actions/loan-credit-balance-refund/loan-credit-balance-refund.component.spec.ts create mode 100644 src/app/loans/loans-view/loan-account-actions/loan-credit-balance-refund/loan-credit-balance-refund.component.ts diff --git a/src/app/loans/common-resolvers/loan-action-button.resolver.ts b/src/app/loans/common-resolvers/loan-action-button.resolver.ts index 48c306823..6bbd992da 100644 --- a/src/app/loans/common-resolvers/loan-action-button.resolver.ts +++ b/src/app/loans/common-resolvers/loan-action-button.resolver.ts @@ -30,8 +30,16 @@ export class LoanActionButtonResolver implements Resolve { return this.loansService.getLoanTemplate(loanId); } else if (loanActionButton === 'Make Repayment') { return this.loansService.getLoanActionTemplate(loanId, 'repayment'); + } else if (loanActionButton === 'Goodwill Credit') { + return this.loansService.getLoanActionTemplate(loanId, 'goodwillCredit'); + } else if (loanActionButton === 'Payout Refund') { + return this.loansService.getLoanActionTemplate(loanId, 'payoutRefund'); + } else if (loanActionButton === 'Merchant Issued Refund') { + return this.loansService.getLoanActionTemplate(loanId, 'merchantIssuedRefund'); + } else if (loanActionButton === 'Credit Balance Refund') { + return this.loansService.getLoanActionTemplate(loanId, 'creditBalanceRefund'); } else if (loanActionButton === 'Waive Interest') { - return this.loansService.getLoanActionTemplate(loanId, 'waiveinterest'); + return this.loansService.getLoanActionTemplate(loanId, 'waiveinterest'); } else if (loanActionButton === 'Write Off') { return this.loansService.getLoanActionTemplate(loanId, 'writeoff'); } else if (loanActionButton === 'Close') { diff --git a/src/app/loans/loans-routing.module.ts b/src/app/loans/loans-routing.module.ts index a4475c517..097d0220b 100644 --- a/src/app/loans/loans-routing.module.ts +++ b/src/app/loans/loans-routing.module.ts @@ -231,7 +231,7 @@ const routes: Routes = [ { path: 'actions/:action', component: LoanAccountActionsComponent, - data: { title: extract('Loan Account Actions'), routeParamBreadcrumb: 'action' }, + data: { title: extract('Loan Account Actions'), breadcrumb: 'action', routeParamBreadcrumb: 'action' }, resolve: { actionButtonData: LoanActionButtonResolver } diff --git a/src/app/loans/loans-view/loan-account-actions/loan-account-actions.component.html b/src/app/loans/loans-view/loan-account-actions/loan-account-actions.component.html index 0e4268b5a..8dba79e65 100644 --- a/src/app/loans/loans-view/loan-account-actions/loan-account-actions.component.html +++ b/src/app/loans/loans-view/loan-account-actions/loan-account-actions.component.html @@ -4,6 +4,10 @@ + + + + diff --git a/src/app/loans/loans-view/loan-account-actions/loan-account-actions.component.ts b/src/app/loans/loans-view/loan-account-actions/loan-account-actions.component.ts index 728cbe6e0..ae14af85e 100644 --- a/src/app/loans/loans-view/loan-account-actions/loan-account-actions.component.ts +++ b/src/app/loans/loans-view/loan-account-actions/loan-account-actions.component.ts @@ -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; diff --git a/src/app/loans/loans-view/loan-account-actions/loan-credit-balance-refund/loan-credit-balance-refund.component.html b/src/app/loans/loans-view/loan-account-actions/loan-credit-balance-refund/loan-credit-balance-refund.component.html new file mode 100644 index 000000000..8aaa17bcf --- /dev/null +++ b/src/app/loans/loans-view/loan-account-actions/loan-credit-balance-refund/loan-credit-balance-refund.component.html @@ -0,0 +1,54 @@ +
+ + + +
+ + + +
+ + + Transaction Date + + + + + Transaction Date is required + + + + + Transaction Amount + + + Transaction Amount is required + + + + + External Id + + + + + Note + + + +
+ + + + + + +
+ +
+ +
+ +
diff --git a/src/app/loans/loans-view/loan-account-actions/loan-credit-balance-refund/loan-credit-balance-refund.component.scss b/src/app/loans/loans-view/loan-account-actions/loan-credit-balance-refund/loan-credit-balance-refund.component.scss new file mode 100644 index 000000000..f6b89f7e9 --- /dev/null +++ b/src/app/loans/loans-view/loan-account-actions/loan-credit-balance-refund/loan-credit-balance-refund.component.scss @@ -0,0 +1,7 @@ +.expandcollapsebutton { + margin-top: -7px; +} + +.container { + max-width: 37rem; +} diff --git a/src/app/loans/loans-view/loan-account-actions/loan-credit-balance-refund/loan-credit-balance-refund.component.spec.ts b/src/app/loans/loans-view/loan-account-actions/loan-credit-balance-refund/loan-credit-balance-refund.component.spec.ts new file mode 100644 index 000000000..44594f072 --- /dev/null +++ b/src/app/loans/loans-view/loan-account-actions/loan-credit-balance-refund/loan-credit-balance-refund.component.spec.ts @@ -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; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ LoanCreditBalanceRefundComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(LoanCreditBalanceRefundComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/loans/loans-view/loan-account-actions/loan-credit-balance-refund/loan-credit-balance-refund.component.ts b/src/app/loans/loans-view/loan-account-actions/loan-credit-balance-refund/loan-credit-balance-refund.component.ts new file mode 100644 index 000000000..399d5fff9 --- /dev/null +++ b/src/app/loans/loans-view/loan-account-actions/loan-credit-balance-refund/loan-credit-balance-refund.component.ts @@ -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 }); + }); + } + +} diff --git a/src/app/loans/loans-view/loan-account-actions/make-repayment/make-repayment.component.ts b/src/app/loans/loans-view/loan-account-actions/make-repayment/make-repayment.component.ts index 0b2baabc0..c3fec8ffc 100644 --- a/src/app/loans/loans-view/loan-account-actions/make-repayment/make-repayment.component.ts +++ b/src/app/loans/loans-view/loan-account-actions/make-repayment/make-repayment.component.ts @@ -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 }); }); diff --git a/src/app/loans/loans-view/loan-accounts-button-config.ts b/src/app/loans/loans-view/loan-accounts-button-config.ts index 2c8e49fe0..81e7aa075 100644 --- a/src/app/loans/loans-view/loan-accounts-button-config.ts +++ b/src/app/loans/loans-view/loan-accounts-button-config.ts @@ -6,6 +6,11 @@ export class LoansAccountButtonConfiguration { taskPermissionName?: string, }[]; + optionPaymentArray: { + name: string, + taskPermissionName?: string, + }[]; + buttonsArray: { name: string, icon: string, @@ -25,6 +30,10 @@ export class LoansAccountButtonConfiguration { return this.optionArray; } + get optionsPayment() { + return this.optionPaymentArray; + } + setButtons(status: string) { switch (status) { case 'Active': @@ -48,7 +57,7 @@ export class LoansAccountButtonConfiguration { name: 'Undo Disbursal', icon: 'fa fa-undo', taskPermissionName: 'DISBURSALUNDO_LOAN', - }, + } ]; break; case 'Submitted and pending approval': @@ -101,6 +110,11 @@ export class LoansAccountButtonConfiguration { icon: 'fa fa-exchange', taskPermissionName: 'CREATE_ACCOUNTTRANSFER', }, + { + name: 'Credit Balance Refund', + icon: 'fa fa-dollar', + taskPermissionName: 'CREATE_CREDIT_BALANCE_REFUND', + } ]; break; case 'Closed (written off)': @@ -112,6 +126,25 @@ export class LoansAccountButtonConfiguration { }, ]; break; + case 'Closed (obligations met)': + this.buttonsArray = [ + { + name: 'Goodwill Credit', + icon: 'fa fa-dollar', + taskPermissionName: 'CREATE_GOODWILL_TRANSACTION', + }, + { + name: 'Payout Refund', + icon: 'fa fa-dollar', + taskPermissionName: 'CREATE_PAYOUT_REFUND', + }, + { + name: 'Merchant Issued Refund', + icon: 'fa fa-dollar', + taskPermissionName: 'CREATE_MERCHANT_ISSUED_REFUND', + } + ]; + break; default: this.buttonsArray = []; } @@ -158,6 +191,20 @@ export class LoansAccountButtonConfiguration { taskPermissionName: 'RECOVERGUARANTEES_LOAN', }, ]; + this.optionPaymentArray = [ + { + name: 'Goodwill Credit', + taskPermissionName: 'CREATE_GOODWILL_TRANSACTION', + }, + { + name: 'Payout Refund', + taskPermissionName: 'CREATE_PAYOUT_REFUND', + }, + { + name: 'Merchant Issued Refund', + taskPermissionName: 'CREATE_MERCHANT_ISSUED_REFUND', + } + ]; break; case 'Submitted and pending approval': this.optionArray = [ @@ -186,6 +233,7 @@ export class LoansAccountButtonConfiguration { taskPermissionName: 'READ_LOAN', }, ]; + this.optionPaymentArray = []; break; case 'Approved': this.optionArray = [ @@ -206,9 +254,11 @@ export class LoansAccountButtonConfiguration { taskPermissionName: 'READ_LOAN', }, ]; + this.optionPaymentArray = []; break; default: this.optionArray = []; + this.optionPaymentArray = []; } } diff --git a/src/app/loans/loans-view/loans-view.component.html b/src/app/loans/loans-view/loans-view.component.html index b96230451..3af5c9613 100644 --- a/src/app/loans/loans-view/loans-view.component.html +++ b/src/app/loans/loans-view/loans-view.component.html @@ -2,124 +2,149 @@ - + -
-
- -
-
+
+
+ +
+
-
- -
+
+ +
-
-

- - Loan Product: {{loanDetailsData.loanProductName}}(#{{loanDetailsData.accountNo}}) -
- Client Name: {{loanDetailsData.clientName}}
- Group Name: {{loanDetailsData.group.name}} -

-
+
+

+ + Loan Product: {{loanDetailsData.loanProductName}}(#{{loanDetailsData.accountNo}}) +
+ Client Name: {{loanDetailsData.clientName}}
+ Group Name: {{loanDetailsData.group.name}} +

+
-
-

Loan Account OverView

- Current Balance: {{loanDetailsData.currency.displaySymbol}} {{loanDetailsData.summary.totalOutstanding | number}}
- Arrears By: {{loanDetailsData.summary.totalOverdue | number}} - Not Provided -
-
+
+

Loan Account OverView

+ Current Balance: {{loanDetailsData.currency.displaySymbol}} + {{loanDetailsData.summary.totalOutstanding | number}}
+ Arrears By: {{loanDetailsData.summary.totalOverdue | number}} + Not Provided +
+
-
-
-
- +
+
+
+
- + - - - + + + - - - - - - - - + + + + + + + + - + + + + + + + + + +