/** Angular Imports */ import { Injectable } from '@angular/core' ; import { HttpClient , HttpParams } from '@angular/common/http' ; /** rxjs Imports */ import { Observable } from 'rxjs' ; /**
 * Loans service.
 */ @ Injectable ( { providedIn : 'root' } ) export class LoansService { constructor ( private http ) { } param { string } loanId returns { Observable < any > } getLoanChargeTemplateResource ( loanId ) { return this . http . get ( `/loans/${ loanId }/charges/template` ) ; } getLoanActionTemplate ( loanId , command ) { const httpParams = new HttpParams ( ) . set ( 'command' , command ) ; return this . http . get ( `/loans/${ loanId }/transactions/template` , { params : httpParams } ) ; } getLoanAccountResource ( loanId , associations ) { const httpParams = new HttpParams ( ) . set ( 'associations' , associations ) ; return this . http . get ( `/loans/${ loanId }` , { params : httpParams } ) ; } getGuarantorTemplate ( loanId ) { return this . http . get ( `/loans/${ loanId }/guarantors/template` ) ; } createNewGuarantor ( loanId , data ) { return this . http . post ( `/loans/${ loanId }/guarantors` , data ) ; } deleteGuarantor ( loanId , guarantorId ) { return this . http . delete ( `/loans/${ loanId }/guarantors/${ guarantorId }` ) ; } deleteLoanAccount ( loanId ) { return this . http . delete ( `/loans/${ loanId }` ) ; } param loanId getLoanTemplate ( loanId ) { const httpParams = new HttpParams ( ) . set ( 'fields' , 'id,loanOfficerId,loanOfficerOptions' ) . set ( 'staffInSelectedOfficeOnly' , 'true' ) . set ( 'template' , 'true' ) ; return this . http . get ( `/loans/${ loanId }` , { params : httpParams } ) ; } param { any } loanCharge returns { Observable < any > } createLoanCharge ( loanId , resourceType , loanCharge ) { return this . http . post ( `/loans/${ loanId }/${ resourceType }` , loanCharge ) ; } param loanId getLoanAccountDetails ( loanId ) { return this . http . get ( `/loans/${ loanId }` ) ; } param { string } loanId returns { Observable < any > } getLoanCollateralTemplate ( loanId ) { return this . http . get ( `/loans/${ loanId }/collaterals/template` ) ; } param { string } loanId param { any } collateralData returns { Observable < any > } createLoanCollateral ( loanId , collateralData ) { return this . http . post ( `/loans/${ loanId }/collaterals` , collateralData ) ; } param loanId getLoanAccountAssociationDetails ( loanId ) { const httpParams = new HttpParams ( ) . set ( 'associations' , 'all' ) . set ( 'exclude' , 'guarantors,futureSchedule' ) ; return this . http . get ( `/loans/${ loanId }` , { params : httpParams } ) ; } getApproveAssociationsDetails ( loanId ) { const httpParams = new HttpParams ( ) . set ( 'associations' , 'multiDisburseDetails' ) ; return this . http . get ( `/loans/${ loanId }` , { params : httpParams } ) ; } param loanId returns getLoanNotes ( loanId ) { return this . http . get ( `/loans/${ loanId }/notes` ) ; } param loanId param noteData returns { Observable < any > } createLoanNote ( loanId , noteData ) { return this . http . post ( `/loans/${ loanId }/notes` , noteData ) ; } param loanId param noteId param noteData editLoanNote ( loanId , noteId , noteData ) { return this . http . put ( `/loans/${ loanId }/notes/${ noteId }` , noteData ) ; } param loanId param noteId deleteLoanNote ( loanId , noteId ) { return this . http . delete ( `/loans/${ loanId }/notes/${ noteId }` ) ; } param loanId param data param command submitLoanActionButton ( loanId , data , command ) { const httpParams = new HttpParams ( ) . set ( 'command' , command ) ; return this . http . post ( `/loans/${ loanId }/transactions` , data , { params : httpParams } ) ; } getLoanScreenReportsData ( ) { const httpParams = new HttpParams ( ) . set ( 'entityId' , '1' ) . set ( 'typeId' , '0' ) ; return this . http . get ( `/templates` , { params : httpParams } ) ; } /**
     * Get Loan Datatables
     */ getLoanDataTables ( ) { const httpParams = new HttpParams ( ) . set ( 'apptable' , 'm_loan' ) ; return this . http . get ( `/datatables` , { params : httpParams } ) ; } param loanId param datatableName getLoanDatatable ( loanId , datatableName ) { const httpParams = new HttpParams ( ) . set ( 'genericResultSet' , 'true' ) ; return this . http . get ( `/datatables/${ datatableName }/${ loanId }` , { params : httpParams } ) ; } param loanId param datatableName param data returns { Observable < any > } addLoanDatatableEntry ( loanId , datatableName , data ) { const httpParams = new HttpParams ( ) . set ( 'genericResultSet' , 'true' ) ; return this . http . post ( `/datatables/${ datatableName }/${ loanId }` , data , { params : httpParams } ) ; } param loanId param datatableName param data returns { Observable < any > } editLoanDatatableEntry ( loanId , datatableName , data ) { const httpParams = new HttpParams ( ) . set ( 'genericResultSet' , 'true' ) ; return this . http . put ( `/datatables/${ datatableName }/${ loanId }` , data , { params : httpParams } ) ; } param loanId param datatableName returns { Observable < any > } deleteDatatableContent ( loanId , datatableName ) { const httpParams = new HttpParams ( ) . set ( 'genericResultSet' , 'true' ) ; return this . http . delete ( `/datatables/${ datatableName }/${ loanId }` , { params : httpParams } ) ; } param { string } loanId param { any } data returns { Observable < any > } loanActionButtons ( loanId , command , data ? ) { const httpParams = new HttpParams ( ) . set ( 'command' , command ) ; return this . http . post ( `/loans/${ loanId }` , data , { params : httpParams } ) ; } param { string | number } loanId param { any } foreclosuredata getForeclosureData ( loanId , foreclosuredata ) { const httpParams = new HttpParams ( ) . set ( 'command' , foreclosuredata . command ) . set ( 'dateFormat' , foreclosuredata . dateFormat ) . set ( 'locale' , foreclosuredata . locale ) . set ( 'transactionDate' , foreclosuredata . transactionDate ) ; return this . http . get ( `/loans/${ loanId }/transactions/template` , { params : httpParams } ) ; } param { string | number } loanId param { any } data loanForclosureData ( loanId , data ) { const httpParams = new HttpParams ( ) . set ( 'command' , 'foreclosure' ) ; return this . http . post ( `/loans/${ loanId }/transactions` , data , { params : httpParams } ) ; } /**
     * Returns the Reschedule Loans Template
     */ rescheduleLoanTemplate ( ) { return this . http . get ( '/rescheduleloans/template' ) ; } param { any } data submitRescheduleData ( data ) { const httpParams = new HttpParams ( ) . set ( 'command' , 'reschedule' ) ; return this . http . post ( '/rescheduleloans' , data , { params : httpParams } ) ; } param { any } clientId param { any } productId getLoansAccountTemplateResource ( clientId , productId ? ) { let httpParams = new HttpParams ( ) . set ( 'activeOnly' , 'true' ) . set ( 'clientId' , clientId ) . set ( 'staffInSelectedOfficeOnly' , 'true' ) . set ( 'templateType' , 'individual' ) ; httpParams = productId ? httpParams . set ( 'productId' , productId ) : httpParams ; return this . http . get ( '/loans/template' , { params : httpParams } ) ; } getLoansAccountAndTemplateResource ( loanId ) { const httpParams = new HttpParams ( ) . set ( 'associations' , 'charges,collateral,meeting,multiDisburseDetails' ) . set ( 'staffInSelectedOfficeOnly' , 'true' ) . set ( 'template' , 'true' ) ; return this . http . get ( `/loans/${ loanId }` , { params : httpParams } ) ; } param { any } productId getLoansCollateralTemplateResource ( productId ) { const httpParams = new HttpParams ( ) . set ( 'fields' , 'id, loanCollateralOptions' ) . set ( 'productId' , productId ) . set ( 'templateType' , 'collateral' ) ; return this . http . get ( '/loans/template' , { params : httpParams } ) ; } param { any } loanAccount createLoansAccount ( loanAccount ) { return this . http . post ( '/loans' , loanAccount ) ; } getLoanDocuments ( loanId ) { return this . http . get ( `/loans/${ loanId }/documents` ) ; } deleteLoanDocument ( loanId , documentId ) { return this . http . delete ( `/loans/${ loanId }/documents/${ documentId }` ) ; } loadLoanDocument ( loanId , data ) { return this . http . post ( `/loans/${ loanId }/documents` , data ) ; } param clientId param clientName param fromAccountId param locale param dateFormat returns { Observable < any > } getStandingInstructions ( clientId , clientName , fromAccountId , locale , dateFormat ) { const httpParams = new HttpParams ( ) . set ( 'clientId' , clientId ) . set ( 'clientName' , clientName ) . set ( 'fromAccountId' , fromAccountId ) . set ( 'fromAccountType' , '1' ) . set ( 'locale' , locale ) . set ( 'dateFormat' , dateFormat ) . set ( 'limit' , '14' ) . set ( 'offset' , '0' ) ; return this . http . get ( `/standinginstructions` , { params : httpParams } ) ; } updateLoansAccount ( loanId , loanData ) { return this . http . put ( `/loans/${ loanId }` , loanData ) ; } getTemplateData ( templateId , loanId ) { const httpParams = new HttpParams ( ) . set ( 'loanId' , loanId ) ; return this . http . post ( `/templates/${ templateId }` , { } , { params : httpParams , responseType : 'text' } ) ; } param { string } loanId returns { Observable < any > } getLoanApprovalTemplate ( loanId ) { const httpParams = new HttpParams ( ) . set ( 'templateType' , 'approval' ) ; return this . http . get ( `/loans/${ loanId }/template` , { params : httpParams } ) ; } guarantorAccountResource ( loanId , clientId ) { const httpParams = new HttpParams ( ) . set ( 'clientId' , clientId ) ; return this . http . get ( `/loans/${ loanId }/guarantors/accounts/template` , { params : httpParams } ) ; } param { string } accountId param { string } chargeId returns { Observable < any > } getLoansAccountCharge ( accountId , chargeId ) { return this . http . get ( `/loans/${ accountId }/charges/${ chargeId }` ) ; } param { string } accountId param { string } command param { any } data param { string } chargeId returns { Observable < any > } executeLoansAccountChargesCommand ( accountId , command , data , chargeId ) { const httpParams = new HttpParams ( ) . set ( 'command' , command ) ; return this . http . post ( `/loans/${ accountId }/charges/${ chargeId }` , data , { params : httpParams } ) ; } param { string } accountId param { any } data param { any } chargeId returns { Observable < any > } editLoansAccountCharge ( accountId , data , chargeId ) { return this . http . put ( `/loans/${ accountId }/charges/${ chargeId }` , data ) ; } param { string } accountId param { any } chargeId returns { Observable < any > } deleteLoansAccountCharge ( accountId , chargeId ) { return this . http . delete ( `/loans/${ accountId }/charges/${ chargeId }` ) ; } param { string } accountId param { string } transactionId returns { Observable < any > } getLoansAccountTransaction ( accountId , transactionId ) { return this . http . get ( `/loans/${ accountId }/transactions/${ transactionId }` ) ; } param { string } accountId param { string } transactionId returns { Observable < any > } getLoansAccountTransactionTemplate ( accountId , transactionId ) { const httpParams = new HttpParams ( ) . set ( 'template' , 'true' ) ; return this . http . get ( `/loans/${ accountId }/transactions/${ transactionId }` , { params : httpParams } ) ; } param { string } accountId param { string } command param { any } data param { string } transactionId returns { Observable < any > } executeLoansAccountTransactionsCommand ( accountId , command , data , transactionId ? ) { const httpParams = new HttpParams ( ) . set ( 'command' , command ) ; if ( transactionId ) { return this . http . post ( `/loans/${ accountId }/transactions/${ transactionId }` , data , { params : httpParams } ) ; } return this . http . post ( `/loans/${ accountId }/transactions` , data , { params : httpParams } ) ; } }