/** TODO: Separate services for feature modules for cleaner accounting service. */ /** Angular Imports */ import { Injectable } from '@angular/core' ; import { HttpClient , HttpParams } from '@angular/common/http' ; /** rxjs Imports */ import { Observable } from 'rxjs' ; /**
 * Accounting service.
 */ @ Injectable ( { providedIn : 'root' } ) export class AccountingService { param { HttpClient } http constructor ( private http ) { } returns { Observable < any > } getOffices ( ) { const httpParams = new HttpParams ( ) . set ( 'orderBy' , 'id' ) ; return this . http . get ( '/offices' , { params : httpParams } ) ; } param { boolean } useHttpParams returns { Observable < any > } getAccountingRules ( useHttpParams = false ) { let httpParams = new HttpParams ( ) ; if ( useHttpParams ) { httpParams = httpParams . set ( 'associations' , 'all' ) ; } return this . http . get ( '/accountingrules' , { params : httpParams } ) ; } returns { Observable < any > } getCurrencies ( ) { return this . http . get ( '/currencies' ) ; } returns { Observable < any > } getPaymentTypes ( ) { return this . http . get ( '/paymenttypes' ) ; } param { any } journalEntry returns { Observable < any > } createJournalEntry ( journalEntry ) { return this . http . post ( '/journalentries' , journalEntry ) ; } returns { Observable < any > } getGlAccounts ( ) { const httpParams = new HttpParams ( ) . set ( 'manualEntriesAllowed' , 'true' ) . set ( 'usage' , '1' ) . set ( 'disabled' , 'false' ) ; return this . http . get ( `/glaccounts` , { params : httpParams } ) ; } param transactionId returns { Observable < any > } getJournalEntry ( transactionId ) { const httpParams = new HttpParams ( ) . set ( 'transactionId' , transactionId ) . set ( 'transactionDetails' , 'true' ) ; return this . http . get ( `/journalentries` , { params : httpParams } ) ; } param { any } filterBy param { string } orderBy param { string } sortOrder param { number } offset param { number } limit returns { Observable < any > } getJournalEntries ( filterBy , orderBy , sortOrder , offset , limit ) { let httpParams = new HttpParams ( ) . set ( 'offset' , offset . toString ( ) ) . set ( 'limit' , limit . toString ( ) ) . set ( 'sortOrder' , sortOrder ) . set ( 'orderBy' , orderBy ) ; filterBy . forEach ( function ( filter ) { if ( filter . value ) { httpParams = httpParams . set ( filter . type , filter . value ) ; } } ) ; return this . http . get ( '/journalentries' , { params : httpParams } ) ; } param { string } transactionId param { string } comments returns { Observable < any > } revertTransaction ( transactionId , comments ) { const httpParams = new HttpParams ( ) . set ( 'command' , 'reverse' ) ; let data = { } ; if ( comments ) { data = { comments : comments } ; } return this . http . post ( `/journalentries/${ transactionId }` , data , { params : httpParams } ) ; } returns { Observable < any > } getFinancialActivityAccounts ( ) { return this . http . get ( '/financialactivityaccounts' ) ; } returns { Observable < any > } getFinancialActivityAccountsTemplate ( ) { return this . http . get ( '/financialactivityaccounts/template' ) ; } param { any } financialActivityAccount returns { Observable < any > } createFinancialActivityAccount ( financialActivityAccount ) { return this . http . post ( '/financialactivityaccounts' , financialActivityAccount ) ; } param { string } financialActivityAccountId param { boolean } template returns { Observable < any > } getFinancialActivityAccount ( financialActivityAccountId , template = false ) { const httpParams = new HttpParams ( ) . set ( 'template' , template . toString ( ) ) ; return this . http . get ( `/financialactivityaccounts/${ financialActivityAccountId }` , { params : httpParams } ) ; } param { string } financialActivityAccountId param { any } financialActivityAccount returns { Observable < any > } updateFinancialActivityAccount ( financialActivityAccountId , financialActivityAccount ) { return this . http . put ( `/financialactivityaccounts/${ financialActivityAccountId }` , financialActivityAccount ) ; } param { string } financialActivityAccountId returns { Observable < any > } deleteFinancialActivityAccount ( financialActivityAccountId ) { return this . http . delete ( `/financialactivityaccounts/${ financialActivityAccountId }` ) ; } param { string } officeId returns { Observable < any > } retrieveOpeningBalances ( officeId ) { const httpParams = new HttpParams ( ) . set ( 'officeId' , officeId ) ; return this . http . get ( '/journalentries/openingbalance' , { params : httpParams } ) ; } param { any } openingBalances returns { Observable < any > } defineOpeningBalances ( openingBalances ) { const httpParams = new HttpParams ( ) . set ( 'command' , 'defineOpeningBalance' ) ; return this . http . post ( `/journalentries` , openingBalances , { params : httpParams } ) ; } returns { Observable < any > } getChartOfAccounts ( ) { return this . http . get ( '/glaccounts' ) ; } returns { Observable < any > } getChartOfAccountsTemplate ( ) { return this . http . get ( '/glaccounts/template' ) ; } param { any } glAccount returns { Observable < any > } createGlAccount ( glAccount ) { return this . http . post ( '/glaccounts' , glAccount ) ; } param { string } glAccountId param { boolean } template returns { Observable < any > } getGlAccount ( glAccountId , template = false ) { const httpParams = new HttpParams ( ) . set ( 'template' , template . toString ( ) ) ; return this . http . get ( `/glaccounts/${ glAccountId }` , { params : httpParams } ) ; } param { string } glAccountId param { any } glAccount returns { Observable < any > } updateGlAccount ( glAccountId , glAccount ) { return this . http . put ( `/glaccounts/${ glAccountId }` , glAccount ) ; } param glAccountId returns { Observable < any > } deleteGlAccount ( glAccountId ) { return this . http . delete ( `/glaccounts/${ glAccountId }` ) ; } returns { Observable < any > } getAccountingClosures ( ) { return this . http . get ( '/glclosures' ) ; } param { any } accountingClosure returns { Observable < any > } createAccountingClosure ( accountingClosure ) { return this . http . post ( '/glclosures' , accountingClosure ) ; } param { string } accountingClosureId returns { Observable < any > } getAccountingClosure ( accountingClosureId ) { return this . http . get ( `/glclosures/${ accountingClosureId }` ) ; } param { string } accountingClosureId param { any } accountingClosure returns { Observable < any > } updateAccountingClosure ( accountingClosureId , accountingClosure ) { return this . http . put ( `/glclosures/${ accountingClosureId }` , accountingClosure ) ; } param { string } accountingClosureId returns { Observable < any > } deleteAccountingClosure ( accountingClosureId ) { return this . http . delete ( `/glclosures/${ accountingClosureId }` ) ; } returns { Observable < any > } getAccountingRulesTemplate ( ) { return this . http . get ( '/accountingrules/template' ) ; } param { any } accountingRule returns { Observable < any > } createAccountingRule ( accountingRule ) { return this . http . post ( '/accountingrules' , accountingRule ) ; } param { string } accountingRuleId returns { Observable < any > } getAccountingRule ( accountingRuleId ) { return this . http . get ( `/accountingrules/${ accountingRuleId }` ) ; } param { string } accoutingRuleId param { any } accountingRule returns { Observable < any > } updateAccountingRule ( accoutingRuleId , accountingRule ) { return this . http . put ( `/accountingrules/${ accoutingRuleId }` , accountingRule ) ; } param { string } accountingRuleId returns { Observable < any > } deleteAccountingRule ( accountingRuleId ) { return this . http . delete ( `/accountingrules/${ accountingRuleId }` ) ; } param { any } periodicAccruals returns { Observable < any > } executePeriodicAccruals ( periodicAccruals ) { return this . http . post ( '/runaccruals' , periodicAccruals ) ; } returns { Observable < any > } getProvisioningEntries ( ) { return this . http . get ( '/provisioningentries' ) ; } param { any } provisioningEntry returns { Observable < any > } createProvisioningEntry ( provisioningEntry ) { return this . http . post ( '/provisioningentries' , provisioningEntry ) ; } param { string } provisioningEntryId returns { Observable < any > } getProvisioningEntry ( provisioningEntryId ) { return this . http . get ( `/provisioningentries/${ provisioningEntryId }` ) ; } returns { Observable < any > } getLoanProducts ( ) { return this . http . get ( '/loanproducts' ) ; } returns { Observable < any > } getProvisioningCategories ( ) { return this . http . get ( '/provisioningcategory' ) ; } param { string } provisioningEntryId returns { Observable < any > } getProvisioningEntryEntries ( provisioningEntryId ) { const httpParams = new HttpParams ( ) . set ( 'entryId' , provisioningEntryId ) ; return this . http . get ( '/provisioningentries/entries' , { params : httpParams } ) ; } param { string } provisioningEntryId returns { Observable < any > } getProvisioningJournalEntries ( provisioningEntryId ) { const httpParams = new HttpParams ( ) . set ( 'entryId' , provisioningEntryId ) ; return this . http . get ( '/journalentries/provisioning' , { params : httpParams } ) ; } param { string } provisioningEntryId returns { Observable < any > } createProvisioningJournalEntries ( provisioningEntryId ) { const httpParams = new HttpParams ( ) . set ( 'command' , 'createjournalentry' ) ; return this . http . post ( `/provisioningentries/${ provisioningEntryId }` , { } , { params : httpParams } ) ; } param { string } provisioningEntryId returns { Observable < any > } recreateProvisioningEntries ( provisioningEntryId ) { const httpParams = new HttpParams ( ) . set ( 'command' , 'recreateprovisioningentry' ) ; return this . http . post ( `/provisioningentries/${ provisioningEntryId }` , { } , { params : httpParams } ) ; } }