diff --git a/src/app/customApis.service.ts b/src/app/customApis.service.ts index 19da5188a9..f408365b14 100644 --- a/src/app/customApis.service.ts +++ b/src/app/customApis.service.ts @@ -231,3 +231,20 @@ export class OrganizationService { }); } } +/** + * Savings Service + */ +@Injectable({ + providedIn: 'root' +}) +export class SavingsService { + constructor(private http: HttpClient) {} + + /** + * @param {any} savingsAccount Savings Account + * @returns {Observable} + */ + createSavingsAccount(savingsAccount: any): Observable { + return this.http.post('/savingsaccounts', savingsAccount); + } +} diff --git a/src/app/deposits/fixed-deposits/common-resolvers/fixed-deposit-account-actions.resolver.ts b/src/app/deposits/fixed-deposits/common-resolvers/fixed-deposit-account-actions.resolver.ts index 6a0606eceb..ba07afb544 100644 --- a/src/app/deposits/fixed-deposits/common-resolvers/fixed-deposit-account-actions.resolver.ts +++ b/src/app/deposits/fixed-deposits/common-resolvers/fixed-deposit-account-actions.resolver.ts @@ -6,7 +6,7 @@ import { ActivatedRouteSnapshot } from '@angular/router'; import { Observable } from 'rxjs'; /** Custom Services */ -import { SavingsService } from 'app/savings/savings.service'; +import { SavingsChargesService } from '@fineract/client'; import { FixedDepositsService } from '../fixed-deposits.service'; /** @@ -15,11 +15,11 @@ import { FixedDepositsService } from '../fixed-deposits.service'; @Injectable() export class FixedDepositsAccountActionsResolver { /** - * @param {SavingsService} SavingsService Savings service. + * @param {SavingsChargesService} SavingsChargesService Savings charges service. * @param {FixedDepositsService} fixedDepositsService Fixed Deposits Service. */ constructor( - private savingsService: SavingsService, + private savingsChargesService: SavingsChargesService, private fixedDepositsService: FixedDepositsService ) {} @@ -34,7 +34,7 @@ export class FixedDepositsAccountActionsResolver { route.paramMap.get('fixedDepositAccountId') || route.parent.parent.paramMap.get('fixedDepositAccountId'); switch (actionName) { case 'Add Charge': - return this.savingsService.getSavingsChargeTemplateResource(fixedDepositAccountId); + return this.savingsChargesService.retrieveTemplate18({ savingsAccountId: Number(fixedDepositAccountId) }); case 'Close': return this.fixedDepositsService.getFixedDepositsAccountClosureTemplate(fixedDepositAccountId); case 'Withdrawal': diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/charges-tab/charges-tab.component.ts b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/charges-tab/charges-tab.component.ts index 1ef8e2297d..b8cdea0ce0 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/charges-tab/charges-tab.component.ts +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/charges-tab/charges-tab.component.ts @@ -17,7 +17,7 @@ import { } from '@angular/material/table'; /** Custom Services */ -import { SavingsService } from 'app/savings/savings.service'; +import { SavingsAccountService } from '@fineract/client'; import { SettingsService } from 'app/settings/settings.service'; /** Custom Dialogs */ @@ -90,7 +90,7 @@ export class ChargesTabComponent implements OnInit { /** * Retrieves the Fixed Deposits account data from `resolve`. - * @param {SavingsService} savingsService Savings Service + * @param {SavingsAccountService} savingsAccountService Savings Account Service * @param {ActivatedRoute} route Activated Route. * @param {Router} router Router for navigation. * @param {MatDialog} dialog Dialog reference. @@ -98,7 +98,7 @@ export class ChargesTabComponent implements OnInit { * @param {SettingsService} settingsService Settings Service. */ constructor( - private savingsService: SavingsService, + private savingsAccountService: SavingsAccountService, private route: ActivatedRoute, private dateUtils: Dates, private router: Router, @@ -169,8 +169,12 @@ export class ChargesTabComponent implements OnInit { dateFormat, locale }; - this.savingsService - .executeSavingsAccountChargesCommand(this.fixedDepositsAccountData.id, 'paycharge', dataObject, chargeId) + this.savingsAccountService + .handleCommands6({ + accountId: this.fixedDepositsAccountData.id, + postSavingsAccountsAccountIdRequest: dataObject, + command: 'paycharge' + }) .subscribe(() => { this.reload(); }); @@ -186,8 +190,18 @@ export class ChargesTabComponent implements OnInit { const waiveChargeDialogRef = this.dialog.open(WaiveChargeDialogComponent, { data: { id: chargeId } }); waiveChargeDialogRef.afterClosed().subscribe((response: any) => { if (response.confirm) { - this.savingsService - .executeSavingsAccountChargesCommand(this.fixedDepositsAccountData.id, 'waive', {}, chargeId) + const locale = this.settingsService.language.code; + const dateFormat = this.settingsService.dateFormat; + const dataObject = { + dateFormat, + locale + }; + this.savingsAccountService + .handleCommands6({ + accountId: this.fixedDepositsAccountData.id, + postSavingsAccountsAccountIdRequest: dataObject, + command: 'waive' + }) .subscribe(() => { this.reload(); }); @@ -203,8 +217,18 @@ export class ChargesTabComponent implements OnInit { const inactivateChargeDialogRef = this.dialog.open(InactivateChargeDialogComponent, { data: { id: chargeId } }); inactivateChargeDialogRef.afterClosed().subscribe((response: any) => { if (response.confirm) { - this.savingsService - .executeSavingsAccountChargesCommand(this.fixedDepositsAccountData.id, 'inactivate', {}, chargeId) + const locale = this.settingsService.language.code; + const dateFormat = this.settingsService.dateFormat; + const dataObject = { + dateFormat, + locale + }; + this.savingsAccountService + .handleCommands6({ + accountId: this.fixedDepositsAccountData.id, + postSavingsAccountsAccountIdRequest: dataObject, + command: 'inactivate' + }) .subscribe(() => { this.reload(); }); @@ -242,8 +266,8 @@ export class ChargesTabComponent implements OnInit { dateFormat, locale }; - this.savingsService - .editSavingsAccountCharge(this.fixedDepositsAccountData.id, dataObject, charge.id) + this.savingsAccountService + .handleCommands6(this.fixedDepositsAccountData.id, dataObject, charge.id) .subscribe(() => { this.reload(); }); @@ -261,7 +285,7 @@ export class ChargesTabComponent implements OnInit { }); deleteChargeDialogRef.afterClosed().subscribe((response: any) => { if (response.delete) { - this.savingsService.deleteSavingsAccountCharge(this.fixedDepositsAccountData.id, chargeId).subscribe(() => { + this.savingsAccountService.delete18(this.fixedDepositsAccountData.id, chargeId).subscribe(() => { this.reload(); }); } diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/fixed-deposit-account-view.component.ts b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/fixed-deposit-account-view.component.ts index efa82b7e00..f8b8a9da3e 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/fixed-deposit-account-view.component.ts +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/fixed-deposit-account-view.component.ts @@ -14,7 +14,7 @@ import { FixedDepositsButtonsConfiguration } from './fixed-deposits-buttons.conf /** Custom Services */ import { FixedDepositsService } from '../fixed-deposits.service'; -import { SavingsService } from 'app/savings/savings.service'; +import { SavingsAccountService } from '@fineract/client'; import { Currency } from 'app/shared/models/general.model'; import { MatCard, @@ -83,14 +83,14 @@ export class FixedDepositAccountViewComponent implements OnInit { * @param {ActivatedRoute} route Activated Route * @param {Router} router Router * @param {FixedDepositsService} fixedDepositsService Fixed Deposits Service - * @param {SavingsService} savingsService Savings Service + * @param {SavingsAccountService} savingsAccountService Savings Account Service * @param {MatDialog} dialog Mat Dialog */ constructor( private route: ActivatedRoute, private router: Router, private fixedDepositsService: FixedDepositsService, - private savingsService: SavingsService, + private savingsAccountService: SavingsAccountService, public dialog: MatDialog ) { this.route.data.subscribe((data: { fixedDepositsAccountData: any; savingsDatatables: any }) => { @@ -240,9 +240,13 @@ export class FixedDepositAccountViewComponent implements OnInit { }); deleteSavingsAccountDialogRef.afterClosed().subscribe((response: any) => { if (response.confirm) { - this.savingsService - .executeSavingsAccountUpdateCommand(this.fixedDepositsAccountData.id, 'updateWithHoldTax', { - withHoldTax: true + this.savingsAccountService + .update20({ + accountId: this.fixedDepositsAccountData.id, + command: 'updateWithHoldTax', + putSavingsAccountsAccountIdRequest: { + withHoldTax: true + } as any }) .subscribe(() => { this.reload(); @@ -261,9 +265,13 @@ export class FixedDepositAccountViewComponent implements OnInit { }); disableWithHoldTaxDialogRef.afterClosed().subscribe((response: any) => { if (response.confirm) { - this.savingsService - .executeSavingsAccountUpdateCommand(this.fixedDepositsAccountData.id, 'updateWithHoldTax', { - withHoldTax: false + this.savingsAccountService + .update20({ + accountId: this.fixedDepositsAccountData.id, + command: 'updateWithHoldTax', + putSavingsAccountsAccountIdRequest: { + withHoldTax: false + } as any }) .subscribe(() => { this.reload(); diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/view-transaction/view-transaction.component.ts b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/view-transaction/view-transaction.component.ts index 3dbb293e50..53426e74b5 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/view-transaction/view-transaction.component.ts +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/view-transaction/view-transaction.component.ts @@ -4,7 +4,7 @@ import { ActivatedRoute, Router, RouterLink } from '@angular/router'; import { MatDialog } from '@angular/material/dialog'; import { UndoTransactionDialogComponent } from 'app/savings/savings-account-view/custom-dialogs/undo-transaction-dialog/undo-transaction-dialog.component'; import { Dates } from 'app/core/utils/dates'; -import { SavingsService } from 'app/savings/savings.service'; +import { SavingsAccountTransactionsService } from '@fineract/client'; import { SettingsService } from 'app/settings/settings.service'; import { NgIf, NgClass, CurrencyPipe } from '@angular/common'; import { FaIconComponent } from '@fortawesome/angular-fontawesome'; @@ -37,7 +37,7 @@ export class ViewTransactionComponent { /** */ constructor( - private savingsService: SavingsService, + private savingsAccountTransactionsService: SavingsAccountTransactionsService, private route: ActivatedRoute, private dateUtils: Dates, private router: Router, @@ -76,8 +76,13 @@ export class ViewTransactionComponent { dateFormat, locale }; - this.savingsService - .executeSavingsAccountTransactionsCommand(this.accountId, 'undo', data, this.transactionData.id) + this.savingsAccountTransactionsService + .adjustTransaction1({ + savingsId: Number(this.accountId), + transactionId: this.transactionData.id, + command: 'undo', + postSavingsAccountBulkReversalTransactionsRequest: data as any + }) .subscribe(() => { this.router.navigate(['../'], { relativeTo: this.route }); }); diff --git a/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/activate-fixed-deposits-account/activate-fixed-deposits-account.component.ts b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/activate-fixed-deposits-account/activate-fixed-deposits-account.component.ts index 058ec6b950..28a5ad03a7 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/activate-fixed-deposits-account/activate-fixed-deposits-account.component.ts +++ b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/activate-fixed-deposits-account/activate-fixed-deposits-account.component.ts @@ -5,7 +5,7 @@ import { ActivatedRoute, Router, RouterLink } from '@angular/router'; import { Dates } from 'app/core/utils/dates'; /** Custom Services */ -import { SavingsService } from 'app/savings/savings.service'; +import { SavingsAccountService } from '@fineract/client'; import { SettingsService } from 'app/settings/settings.service'; import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module'; @@ -33,7 +33,7 @@ export class ActivateFixedDepositsAccountComponent implements OnInit { /** * Fixed deposits endpoint is not supported so using Savings endpoint. * @param {FormBuilder} formBuilder Form Builder - * @param {SavingsService} savingsService Savings Service + * @param {SavingsAccountService} savingsAccountService Savings Account Service * @param {Dates} dateUtils Date Utils * @param {ActivatedRoute} route Activated Route * @param {Router} router Router @@ -41,7 +41,7 @@ export class ActivateFixedDepositsAccountComponent implements OnInit { */ constructor( private formBuilder: UntypedFormBuilder, - private savingsService: SavingsService, + private savingsAccountService: SavingsAccountService, private dateUtils: Dates, private route: ActivatedRoute, private router: Router, @@ -87,8 +87,14 @@ export class ActivateFixedDepositsAccountComponent implements OnInit { dateFormat, locale }; - this.savingsService.executeSavingsAccountCommand(this.accountId, 'activate', data).subscribe(() => { - this.router.navigate(['../../'], { relativeTo: this.route }); - }); + this.savingsAccountService + .handleCommands6({ + accountId: this.accountId, + command: 'activate', + postSavingsAccountsAccountIdRequest: data + }) + .subscribe(() => { + this.router.navigate(['../../'], { relativeTo: this.route }); + }); } } diff --git a/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/add-charge-fixed-deposits-account/add-charge-fixed-deposits-account.component.ts b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/add-charge-fixed-deposits-account/add-charge-fixed-deposits-account.component.ts index bcba746fc0..b6192f20e6 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/add-charge-fixed-deposits-account/add-charge-fixed-deposits-account.component.ts +++ b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/add-charge-fixed-deposits-account/add-charge-fixed-deposits-account.component.ts @@ -11,7 +11,7 @@ import { Router, ActivatedRoute, RouterLink } from '@angular/router'; import { Dates } from 'app/core/utils/dates'; /** Custom Services */ -import { SavingsService } from 'app/savings/savings.service'; +import { ChargesService, SavingsAccountService } from '@fineract/client'; import { SettingsService } from 'app/settings/settings.service'; import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module'; @@ -47,7 +47,8 @@ export class AddChargeFixedDepositsAccountComponent implements OnInit { * @param {ActivatedRoute} route Activated Route * @param {Router} router Router * @param {Dates} dateUtils Date Utils - * @param {SavingsService} savingsService Savings Service + * @param {ChargesService} chargesService Charges Service + * @param {SavingsAccountService} savingsAccountService Savings Account Service * @param {SettingsService} settingsService Settings Service */ constructor( @@ -55,7 +56,8 @@ export class AddChargeFixedDepositsAccountComponent implements OnInit { private route: ActivatedRoute, private router: Router, private dateUtils: Dates, - private savingsService: SavingsService, + private chargesService: ChargesService, + private savingsAccountService: SavingsAccountService, private settingsService: SettingsService ) { this.route.data.subscribe((data: { fixedDepositsAccountActionData: any }) => { @@ -75,7 +77,7 @@ export class AddChargeFixedDepositsAccountComponent implements OnInit { buildDependencies() { this.fixedDepositsChargeForm.controls.chargeId.valueChanges.subscribe((chargeId) => { - this.savingsService.getChargeTemplate(chargeId).subscribe((data: any) => { + this.chargesService.retrieveCharge(chargeId).subscribe((data: any) => { this.chargeDetails = data; const chargeTimeType = data.chargeTimeType.id; if (data.chargeTimeType.value === 'Withdrawal Fee' || data.chargeTimeType.value === 'Saving No Activity Fee') { @@ -155,8 +157,14 @@ export class AddChargeFixedDepositsAccountComponent implements OnInit { } } } - this.savingsService.createSavingsCharge(this.fixedDepositAccountId, 'charges', savingsCharge).subscribe(() => { - this.router.navigate(['../../'], { relativeTo: this.route }); - }); + this.savingsAccountService + .handleCommands6({ + accountId: Number(this.fixedDepositAccountId), + command: 'charges', + postSavingsAccountsAccountIdRequest: savingsCharge + }) + .subscribe(() => { + this.router.navigate(['../../'], { relativeTo: this.route }); + }); } } diff --git a/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/undo-approval-fixed-deposits-account/undo-approval-fixed-deposits-account.component.ts b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/undo-approval-fixed-deposits-account/undo-approval-fixed-deposits-account.component.ts index f83943b2ba..b42c322921 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/undo-approval-fixed-deposits-account/undo-approval-fixed-deposits-account.component.ts +++ b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/undo-approval-fixed-deposits-account/undo-approval-fixed-deposits-account.component.ts @@ -4,7 +4,7 @@ import { UntypedFormGroup, UntypedFormBuilder, ReactiveFormsModule } from '@angu import { ActivatedRoute, Router, RouterLink } from '@angular/router'; /** Custom Services */ -import { SavingsService } from 'app/savings/savings.service'; +import { SavingsAccountService } from '@fineract/client'; import { FixedDepositsService } from '../../fixed-deposits.service'; import { CdkTextareaAutosize } from '@angular/cdk/text-field'; import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module'; @@ -33,13 +33,13 @@ export class UndoApprovalFixedDepositsAccountComponent implements OnInit { /** * Fixed deposits endpoint is not supported so using Savings endpoint. * @param {FormBuilder} formBuilder Form Builder - * @param {SavingsService} savingsService Savings Service + * @param {SavingsAccountService } savingsAccountService Savings Account Service * @param {ActivatedRoute} route Activated Route * @param {Router} router Router */ constructor( private formBuilder: UntypedFormBuilder, - private savingsService: SavingsService, + private savingsAccountService: SavingsAccountService, private fixedDepositsService: FixedDepositsService, private route: ActivatedRoute, private router: Router @@ -83,9 +83,15 @@ export class UndoApprovalFixedDepositsAccountComponent implements OnInit { this.router.navigate(['../../'], { relativeTo: this.route }); }); } else { - this.savingsService.executeSavingsAccountCommand(this.accountId, this.undoCommand, data).subscribe(() => { - this.router.navigate(['../../'], { relativeTo: this.route }); - }); + this.savingsAccountService + .handleCommands6({ + accountId: this.accountId, + command: this.undoCommand, + postSavingsAccountsAccountIdRequest: data + }) + .subscribe(() => { + this.router.navigate(['../../'], { relativeTo: this.route }); + }); } } } diff --git a/src/app/deposits/recurring-deposits/common-resolvers/recurring-deposit-account-actions.resolver.ts b/src/app/deposits/recurring-deposits/common-resolvers/recurring-deposit-account-actions.resolver.ts index 2c293f358e..15bde41799 100644 --- a/src/app/deposits/recurring-deposits/common-resolvers/recurring-deposit-account-actions.resolver.ts +++ b/src/app/deposits/recurring-deposits/common-resolvers/recurring-deposit-account-actions.resolver.ts @@ -6,7 +6,7 @@ import { ActivatedRouteSnapshot } from '@angular/router'; import { Observable } from 'rxjs'; /** Custom Services */ -import { SavingsService } from 'app/savings/savings.service'; +import { SavingsChargesService } from '@fineract/client'; import { RecurringDepositsService } from '../recurring-deposits.service'; /** @@ -15,11 +15,11 @@ import { RecurringDepositsService } from '../recurring-deposits.service'; @Injectable() export class RecurringDepositsAccountActionsResolver { /** - * @param {SavingsService} SavingsService Savings service. + * @param {SavingsChargesService} SavingsChargesService Savings charges service. * @param {RecurringDepositsService} recurringDepositsService Recurring Deposits Service. */ constructor( - private savingsService: SavingsService, + private savingsChargesService: SavingsChargesService, private recurringDepositsService: RecurringDepositsService ) {} @@ -34,7 +34,7 @@ export class RecurringDepositsAccountActionsResolver { route.paramMap.get('recurringDepositAccountId') || route.parent.parent.paramMap.get('recurringDepositAccountId'); switch (actionName) { case 'Add Charge': - return this.savingsService.getSavingsChargeTemplateResource(recurringDepositAccountId); + return this.savingsChargesService.retrieveTemplate18({ savingsAccountId: Number(recurringDepositAccountId) }); case 'Close': return this.recurringDepositsService.getRecurringDepositAccountActionResource( recurringDepositAccountId, diff --git a/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/add-charge-recurring-deposits-account/add-charge-recurring-deposits-account.component.ts b/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/add-charge-recurring-deposits-account/add-charge-recurring-deposits-account.component.ts index 96dc55c282..f69ca4c643 100644 --- a/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/add-charge-recurring-deposits-account/add-charge-recurring-deposits-account.component.ts +++ b/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/add-charge-recurring-deposits-account/add-charge-recurring-deposits-account.component.ts @@ -11,7 +11,7 @@ import { Router, ActivatedRoute, RouterLink } from '@angular/router'; import { Dates } from 'app/core/utils/dates'; /** Custom Services */ -import { SavingsService } from 'app/savings/savings.service'; +import { ChargesService, SavingsAccountService } from '@fineract/client'; import { SettingsService } from 'app/settings/settings.service'; import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module'; @@ -47,14 +47,17 @@ export class AddChargeRecurringDepositsAccountComponent implements OnInit { * @param {ActivatedRoute} route Activated Route * @param {Router} router Router * @param {Dates} dateUtils Date Utils - * @param {SavingsService} savingsService Savings Service + * @param {ChargesService} chargesService Charges Service + * @param {SavingsAccountService} SavingsAccountService Saving acccount service + * */ constructor( private formBuilder: UntypedFormBuilder, private route: ActivatedRoute, private router: Router, private dateUtils: Dates, - private savingsService: SavingsService, + private chargesService: ChargesService, + private savingAccountService: SavingsAccountService, private settingsService: SettingsService ) { this.route.data.subscribe((data: { recurringDepositsAccountActionData: any }) => { @@ -74,7 +77,7 @@ export class AddChargeRecurringDepositsAccountComponent implements OnInit { buildDependencies() { this.recurringDepositsChargeForm.controls.chargeId.valueChanges.subscribe((chargeId) => { - this.savingsService.getChargeTemplate(chargeId).subscribe((data: any) => { + this.chargesService.retrieveCharge(chargeId).subscribe((data: any) => { this.chargeDetails = data; const chargeTimeType = data.chargeTimeType.id; if (data.chargeTimeType.value === 'Withdrawal Fee' || data.chargeTimeType.value === 'Saving No Activity Fee') { @@ -154,8 +157,14 @@ export class AddChargeRecurringDepositsAccountComponent implements OnInit { } } } - this.savingsService.createSavingsCharge(this.recurringDepositAccountId, 'charges', savingsCharge).subscribe(() => { - this.router.navigate(['../../'], { relativeTo: this.route }); - }); + this.savingAccountService + .handleCommands6({ + accountId: Number(this.recurringDepositAccountId), + postSavingsAccountsAccountIdRequest: savingsCharge, + command: 'charges' + }) + .subscribe(() => { + this.router.navigate(['../../'], { relativeTo: this.route }); + }); } } diff --git a/src/app/deposits/recurring-deposits/recurring-deposits-account-view/charges-tab/charges-tab.component.ts b/src/app/deposits/recurring-deposits/recurring-deposits-account-view/charges-tab/charges-tab.component.ts index b0f0c2890f..838a6da1bc 100644 --- a/src/app/deposits/recurring-deposits/recurring-deposits-account-view/charges-tab/charges-tab.component.ts +++ b/src/app/deposits/recurring-deposits/recurring-deposits-account-view/charges-tab/charges-tab.component.ts @@ -17,7 +17,7 @@ import { } from '@angular/material/table'; /** Custom Services */ -import { SavingsService } from 'app/savings/savings.service'; +import { SavingsAccountService, SavingsChargesService } from '@fineract/client'; import { SettingsService } from 'app/settings/settings.service'; /** Custom Dialogs */ @@ -88,10 +88,12 @@ export class ChargesTabComponent implements OnInit { /** * Retrieves Recurring Deposits Account Data from `resolve`. * @param {ActivatedRoute} route Activated Route. + * @param {SavingsAccountService} savingsAccountService Savings Account Service */ constructor( private route: ActivatedRoute, - private savingsService: SavingsService, + private savingsAccountService: SavingsAccountService, + private savingsChargesService: SavingsChargesService, private dateUtils: Dates, private router: Router, public dialog: MatDialog, @@ -147,8 +149,15 @@ export class ChargesTabComponent implements OnInit { dateFormat, locale }; - this.savingsService - .executeSavingsAccountChargesCommand(this.recurringDepositsAccountData.id, 'paycharge', dataObject, chargeId) + this.savingsAccountService + .handleCommands6({ + accountId: this.recurringDepositsAccountData.id, + command: 'paycharge', + postSavingsAccountsAccountIdRequest: { + ...dataObject, + chargeId: chargeId + } + }) .subscribe(() => { this.reload(); }); @@ -164,15 +173,18 @@ export class ChargesTabComponent implements OnInit { const waiveChargeDialogRef = this.dialog.open(RecurringDepositConfirmationDialogComponent, { data: { heading: this.translateService.instant('labels.heading.Waive Charge'), - dialogContext: - this.translateService.instant('labels.dialogContext.Are you sure you want to waive charge with id: ') + - `${chargeId} ?` + dialogContext: this.translateService.instant('labels.text.Are you sure you want to waive this charge?') } }); waiveChargeDialogRef.afterClosed().subscribe((response: any) => { if (response.confirm) { - this.savingsService - .executeSavingsAccountChargesCommand(this.recurringDepositsAccountData.id, 'waive', {}, chargeId) + this.savingsChargesService + .payOrWaiveSavingsAccountCharge({ + savingsAccountId: this.recurringDepositsAccountData.id, + savingsAccountChargeId: chargeId, + command: 'waive', + postSavingsAccountsSavingsAccountIdChargesSavingsAccountChargeIdRequest: {} + }) .subscribe(() => { this.reload(); }); @@ -210,8 +222,8 @@ export class ChargesTabComponent implements OnInit { dateFormat, locale }; - this.savingsService - .editSavingsAccountCharge(this.recurringDepositsAccountData.id, dataObject, charge.id) + this.savingsAccountService + .update20(this.recurringDepositsAccountData.id, dataObject, charge.id) .subscribe(() => { this.reload(); }); @@ -229,7 +241,7 @@ export class ChargesTabComponent implements OnInit { }); deleteChargeDialogRef.afterClosed().subscribe((response: any) => { if (response.delete) { - this.savingsService.deleteSavingsAccountCharge(this.recurringDepositsAccountData.id, chargeId).subscribe(() => { + this.savingsAccountService.delete18(this.recurringDepositsAccountData.id, chargeId).subscribe(() => { this.reload(); }); } diff --git a/src/app/deposits/recurring-deposits/recurring-deposits-account-view/recurring-deposits-account-view.component.ts b/src/app/deposits/recurring-deposits/recurring-deposits-account-view/recurring-deposits-account-view.component.ts index 376662e623..540998051d 100644 --- a/src/app/deposits/recurring-deposits/recurring-deposits-account-view/recurring-deposits-account-view.component.ts +++ b/src/app/deposits/recurring-deposits/recurring-deposits-account-view/recurring-deposits-account-view.component.ts @@ -5,7 +5,7 @@ import { MatDialog } from '@angular/material/dialog'; /** Custom Services */ import { RecurringDepositsService } from '../recurring-deposits.service'; -import { SavingsService } from 'app/savings/savings.service'; +import { SavingsAccountService } from '@fineract/client'; /** Custom Buttons Configuration */ import { RecurringDepositsButtonsConfiguration } from './recurring-deposits-buttons.config'; @@ -84,13 +84,15 @@ export class RecurringDepositsAccountViewComponent implements OnInit { * Fetches recurringDeposits account data from `resolve` * @param {ActivatedRoute} route Activated Route * @param {Router} router Router - * @param {RecurringDepositsService} recurringDepositsService RecurringDeposits Service + * @param {RecurringDepositsService} recurringDepositsService + * @param {SavingsAccountService} savingsAccountService + * RecurringDeposits Service */ constructor( private route: ActivatedRoute, private router: Router, private recurringDepositsService: RecurringDepositsService, - private savingsService: SavingsService, + private savingsAccountService: SavingsAccountService, public dialog: MatDialog, private translateService: TranslateService ) { @@ -309,9 +311,13 @@ export class RecurringDepositsAccountViewComponent implements OnInit { }); deleteSavingsAccountDialogRef.afterClosed().subscribe((response: any) => { if (response.confirm) { - this.savingsService - .executeSavingsAccountUpdateCommand(this.recurringDepositsAccountData.id, 'updateWithHoldTax', { - withHoldTax: true + this.savingsAccountService + .update20({ + accountId: this.recurringDepositsAccountData.id, + putSavingsAccountsAccountIdRequest: { + changes: { withHoldTax: true } + } as any, + command: 'updateWithHoldTax' }) .subscribe(() => { this.reload(); @@ -333,9 +339,13 @@ export class RecurringDepositsAccountViewComponent implements OnInit { }); disableWithHoldTaxDialogRef.afterClosed().subscribe((response: any) => { if (response.confirm) { - this.savingsService - .executeSavingsAccountUpdateCommand(this.recurringDepositsAccountData.id, 'updateWithHoldTax', { - withHoldTax: false + this.savingsAccountService + .update20({ + accountId: this.recurringDepositsAccountData.id, + putSavingsAccountsAccountIdRequest: { + changes: { withHoldTax: false } + } as any, + command: 'updateWithHoldTax' }) .subscribe(() => { this.reload(); diff --git a/src/app/savings/common-resolvers/saving-documents.resolver.ts b/src/app/savings/common-resolvers/saving-documents.resolver.ts index 3cc0ad858c..3d8d84a576 100644 --- a/src/app/savings/common-resolvers/saving-documents.resolver.ts +++ b/src/app/savings/common-resolvers/saving-documents.resolver.ts @@ -1,16 +1,16 @@ import { Injectable } from '@angular/core'; import { ActivatedRouteSnapshot } from '@angular/router'; import { Observable } from 'rxjs'; -import { SavingsService } from '../savings.service'; +import { DocumentsService } from '@fineract/client'; @Injectable({ providedIn: 'root' }) export class SavingDocumentsResolver { /** - * @param {SavingsService} savingsService Savings service. + * @param {DocumentsService} documentsService Documents service. */ - constructor(private savingsService: SavingsService) {} + constructor(private documentsService: DocumentsService) {} /** * Returns the Savings data. @@ -18,6 +18,9 @@ export class SavingDocumentsResolver { */ resolve(route: ActivatedRouteSnapshot): Observable { const savingAccountId = route.parent.paramMap.get('savingAccountId'); - return this.savingsService.getSavingsDocuments(savingAccountId); + return this.documentsService.retrieveAllDocuments({ + entityId: Number(savingAccountId), + entityType: 'savings' + }); } } diff --git a/src/app/savings/common-resolvers/saving-notes.resolver.ts b/src/app/savings/common-resolvers/saving-notes.resolver.ts index 7bcddb1ed8..af8e5382d2 100644 --- a/src/app/savings/common-resolvers/saving-notes.resolver.ts +++ b/src/app/savings/common-resolvers/saving-notes.resolver.ts @@ -1,16 +1,16 @@ import { Injectable } from '@angular/core'; import { ActivatedRouteSnapshot } from '@angular/router'; import { Observable } from 'rxjs'; -import { SavingsService } from '../savings.service'; +import { NotesService } from '@fineract/client'; @Injectable({ providedIn: 'root' }) export class SavingNotesResolver { /** - * @param {SavingsService} savingsService Savings service. + * @param {NotesService} notesService Notes service. */ - constructor(private savingsService: SavingsService) {} + constructor(private notesService: NotesService) {} /** * Returns the Savings data. @@ -18,6 +18,9 @@ export class SavingNotesResolver { */ resolve(route: ActivatedRouteSnapshot): Observable { const savingAccountId = route.parent.paramMap.get('savingAccountId'); - return this.savingsService.getSavingsNotes(savingAccountId); + return this.notesService.retrieveNotesByResource({ + resourceType: 'savings', + resourceId: Number(savingAccountId) + }); } } diff --git a/src/app/savings/common-resolvers/savings-account-actions.resolver.ts b/src/app/savings/common-resolvers/savings-account-actions.resolver.ts index cabbc7a740..3e837518d9 100644 --- a/src/app/savings/common-resolvers/savings-account-actions.resolver.ts +++ b/src/app/savings/common-resolvers/savings-account-actions.resolver.ts @@ -6,7 +6,7 @@ import { ActivatedRouteSnapshot } from '@angular/router'; import { Observable, forkJoin } from 'rxjs'; /** Custom Services */ -import { SavingsService } from '../savings.service'; +import { SavingsAccountService, SavingsChargesService, SavingsAccountTransactionsService } from '@fineract/client'; /** * Savings Account Actions data resolver. @@ -14,9 +14,15 @@ import { SavingsService } from '../savings.service'; @Injectable() export class SavingsAccountActionsResolver { /** - * @param {SavingsService} SavingsService Savings service. + * @param {SavingsAccountService} SavingsAccountService Savings account service. + * @param {SavingsChargesService} savingsChargesService Savings charges service. + * @param {SavingsAccountTransactionsService} savingsService Savings account transactions service. */ - constructor(private savingsService: SavingsService) {} + constructor( + private savingsAccountService: SavingsAccountService, + private savingsChargesService: SavingsChargesService, + private savingsAccountTransactionsService: SavingsAccountTransactionsService + ) {} /** * Returns the Savings account actions data. @@ -29,19 +35,34 @@ export class SavingsAccountActionsResolver { route.paramMap.get('savingAccountId') || route.parent.parent.paramMap.get('savingAccountId'); switch (actionName) { case 'Assign Staff': - return this.savingsService.getSavingsAccountAndTemplate(savingAccountId, true); + return this.savingsAccountService.retrieveOne25({ + accountId: parseInt(savingAccountId as string, 10), + staffInSelectedOfficeOnly: true + }); case 'Add Charge': - return this.savingsService.getSavingsChargeTemplateResource(savingAccountId); + return this.savingsChargesService.retrieveTemplate18({ + savingsAccountId: parseInt(savingAccountId as string, 10) + }); case 'Withdrawal': case 'Deposit': case 'Hold Amount': - return this.savingsService.getSavingsTransactionTemplateResource(savingAccountId); + return this.savingsAccountTransactionsService.retrieveTemplate19({ + savingsId: parseInt(savingAccountId as string, 10) + }); case 'Close': return forkJoin([ - this.savingsService.getSavingsTransactionTemplateResource(savingAccountId), - this.savingsService.getSavingsAccountData(savingAccountId)]); + this.savingsAccountTransactionsService.retrieveTemplate19({ + savingsId: parseInt(savingAccountId as string, 10) + }), + this.savingsAccountService.retrieveOne25({ + accountId: parseInt(savingAccountId as string, 10) + }) + + ]); case 'Apply Annual Fees': - return this.savingsService.getSavingsAccountData(savingAccountId); + return this.savingsAccountService.retrieveOne25({ + accountId: parseInt(savingAccountId as string, 10) + }); default: return undefined; } diff --git a/src/app/savings/common-resolvers/savings-account-and-template.resolver.ts b/src/app/savings/common-resolvers/savings-account-and-template.resolver.ts index 2e76f3b834..f92b1eacff 100644 --- a/src/app/savings/common-resolvers/savings-account-and-template.resolver.ts +++ b/src/app/savings/common-resolvers/savings-account-and-template.resolver.ts @@ -6,7 +6,7 @@ import { ActivatedRouteSnapshot } from '@angular/router'; import { Observable } from 'rxjs'; /** Custom Services */ -import { SavingsService } from '../savings.service'; +import { SavingsAccountService } from '@fineract/client'; /** * Savings Account data and template resolver. @@ -14,9 +14,9 @@ import { SavingsService } from '../savings.service'; @Injectable() export class SavingsAccountAndTemplateResolver { /** - * @param {SavingsService} SavingsService Savings service. + * @param {SavingsAccountService} savingsAccountService Savings Account Service */ - constructor(private savingsService: SavingsService) {} + constructor(private savingsAccountService: SavingsAccountService) {} /** * Returns the Savings Account data and template. @@ -25,6 +25,9 @@ export class SavingsAccountAndTemplateResolver { */ resolve(route: ActivatedRouteSnapshot): Observable { const savingAccountId = route.paramMap.get('savingAccountId'); - return this.savingsService.getSavingsAccountAndTemplate(savingAccountId, true); + return this.savingsAccountService.retrieveOne25({ + accountId: savingAccountId ? parseInt(savingAccountId, 10) : 0, + staffInSelectedOfficeOnly: true + }); } } diff --git a/src/app/savings/common-resolvers/savings-account-charge.resolver.ts b/src/app/savings/common-resolvers/savings-account-charge.resolver.ts index 0fef92e1e3..fca694d6cd 100644 --- a/src/app/savings/common-resolvers/savings-account-charge.resolver.ts +++ b/src/app/savings/common-resolvers/savings-account-charge.resolver.ts @@ -6,7 +6,7 @@ import { ActivatedRouteSnapshot } from '@angular/router'; import { Observable } from 'rxjs'; /** Custom Services */ -import { SavingsService } from '../savings.service'; +import { SavingsAccountService } from '@fineract/client'; /** * Savings Account Charge data resolver. @@ -14,9 +14,9 @@ import { SavingsService } from '../savings.service'; @Injectable() export class SavingsAccountChargeResolver { /** - * @param {SavingsService} SavingsService Savings service. + * @param {SavingsAccountService} savingsAccountService Savings Account service. */ - constructor(private savingsService: SavingsService) {} + constructor(private savingsAccountService: SavingsAccountService) {} /** * Returns the Savings Account Charge data. @@ -26,6 +26,9 @@ export class SavingsAccountChargeResolver { resolve(route: ActivatedRouteSnapshot): Observable { const savingAccountId = route.parent.paramMap.get('savingAccountId'); const chargeId = route.paramMap.get('id'); - return this.savingsService.getSavingsAccountCharge(savingAccountId, chargeId); + return this.savingsAccountService.retrieveOne25({ + accountId: Number(savingAccountId), + chargeStatus: 'all' + }); } } diff --git a/src/app/savings/common-resolvers/savings-account-template.resolver.ts b/src/app/savings/common-resolvers/savings-account-template.resolver.ts index 6ad4c31175..1a5f443e92 100644 --- a/src/app/savings/common-resolvers/savings-account-template.resolver.ts +++ b/src/app/savings/common-resolvers/savings-account-template.resolver.ts @@ -6,7 +6,7 @@ import { ActivatedRouteSnapshot } from '@angular/router'; import { Observable } from 'rxjs'; /** Custom Services */ -import { SavingsService } from '../savings.service'; +import { SavingsAccountService } from '@fineract/client'; /** * Savings Account Template resolver. @@ -14,9 +14,9 @@ import { SavingsService } from '../savings.service'; @Injectable() export class SavingsAccountTemplateResolver { /** - * @param {savingsService} SavingsService Savings service. + * @param {SavingsAccountService} savingsAccountService Savings Account service. */ - constructor(private savingsService: SavingsService) {} + constructor(private savingsAccountService: SavingsAccountService) {} /** * Returns the Shares Account Template. @@ -26,6 +26,14 @@ export class SavingsAccountTemplateResolver { resolve(route: ActivatedRouteSnapshot): Observable { const entityId = route.paramMap.get('clientId') || route.paramMap.get('groupId') || route.paramMap.get('centerId'); const isGroup = route.paramMap.get('groupId') || route.paramMap.get('centerId') ? true : false; - return this.savingsService.getSavingsAccountTemplate(entityId, undefined, isGroup); + + const clientId = route.paramMap.get('clientId'); + const groupId = route.paramMap.get('groupId') || route.paramMap.get('centerId'); + + return this.savingsAccountService.template14({ + clientId: clientId ? Number(clientId) : undefined, + groupId: groupId ? Number(groupId) : undefined, + staffInSelectedOfficeOnly: undefined + }); } } diff --git a/src/app/savings/common-resolvers/savings-account-transaction-template.resolver.ts b/src/app/savings/common-resolvers/savings-account-transaction-template.resolver.ts index e21566a8e3..57b2b7e133 100644 --- a/src/app/savings/common-resolvers/savings-account-transaction-template.resolver.ts +++ b/src/app/savings/common-resolvers/savings-account-transaction-template.resolver.ts @@ -6,7 +6,7 @@ import { ActivatedRouteSnapshot } from '@angular/router'; import { Observable } from 'rxjs'; /** Custom Services */ -import { SavingsService } from '../savings.service'; +import { SavingsAccountTransactionsService } from '@fineract/client'; /** * Savings Account Transaction Template data resolver. @@ -14,9 +14,9 @@ import { SavingsService } from '../savings.service'; @Injectable() export class SavingsAccountTransactionTemplateResolver { /** - * @param {SavingsService} SavingsService Savings service. + * @param SavingsAccountTransactionsService savingsAccountTransactionsService Savings Account Transactions Service */ - constructor(private savingsService: SavingsService) {} + constructor(private savingsAccountTransactionsService: SavingsAccountTransactionsService) {} /** * Returns the Savings Account Transaction Template data. @@ -26,6 +26,9 @@ export class SavingsAccountTransactionTemplateResolver { resolve(route: ActivatedRouteSnapshot): Observable { const savingAccountId = route.parent.paramMap.get('savingAccountId'); const transactionId = route.paramMap.get('id'); - return this.savingsService.getSavingsAccountTransactionTemplate(savingAccountId, transactionId); + return this.savingsAccountTransactionsService.retrieveOne24({ + savingsId: Number(savingAccountId), + transactionId: Number(transactionId) + }); } } diff --git a/src/app/savings/common-resolvers/savings-account-transaction.resolver.ts b/src/app/savings/common-resolvers/savings-account-transaction.resolver.ts index 538be0d02d..0fb113b8e6 100644 --- a/src/app/savings/common-resolvers/savings-account-transaction.resolver.ts +++ b/src/app/savings/common-resolvers/savings-account-transaction.resolver.ts @@ -6,7 +6,7 @@ import { ActivatedRouteSnapshot } from '@angular/router'; import { Observable } from 'rxjs'; /** Custom Services */ -import { SavingsService } from '../savings.service'; +import { SavingsAccountTransactionsService } from '@fineract/client'; /** * Savings Account Transaction data resolver. @@ -14,9 +14,9 @@ import { SavingsService } from '../savings.service'; @Injectable() export class SavingsAccountTransactionResolver { /** - * @param {SavingsService} SavingsService Savings service. + * @param {SavingsAccountTransactionsService} SavingsAccountTransactionsService Savings Account Transactions Service. */ - constructor(private savingsService: SavingsService) {} + constructor(private savingsAccountTransactionsService: SavingsAccountTransactionsService) {} /** * Returns the Savings Account Transaction data. @@ -26,6 +26,12 @@ export class SavingsAccountTransactionResolver { resolve(route: ActivatedRouteSnapshot): Observable { const savingAccountId = route.parent.paramMap.get('savingAccountId'); const transactionId = route.parent.paramMap.get('id'); - return this.savingsService.getSavingsAccountTransaction(savingAccountId, transactionId); + if (savingAccountId && transactionId) { + return this.savingsAccountTransactionsService.retrieveOne24({ + savingsId: Number(savingAccountId), + transactionId: Number(transactionId) + }); + } + throw new Error('Required parameters missing'); } } diff --git a/src/app/savings/common-resolvers/savings-account-view.resolver.ts b/src/app/savings/common-resolvers/savings-account-view.resolver.ts index b95cadcbac..967b04b178 100644 --- a/src/app/savings/common-resolvers/savings-account-view.resolver.ts +++ b/src/app/savings/common-resolvers/savings-account-view.resolver.ts @@ -6,7 +6,7 @@ import { ActivatedRouteSnapshot } from '@angular/router'; import { Observable } from 'rxjs'; /** Custom Services */ -import { SavingsService } from '../savings.service'; +import { SavingsAccountService } from '@fineract/client'; /** * Savings Account data resolver. @@ -14,9 +14,9 @@ import { SavingsService } from '../savings.service'; @Injectable() export class SavingsAccountViewResolver { /** - * @param {SavingsService} SavingsService Savings service. + * @param {SavingsAccountService} savingsAccountService Savings Account service. */ - constructor(private savingsService: SavingsService) {} + constructor(private savingsAccountService: SavingsAccountService) {} /** * Returns the Savings Account data. @@ -25,6 +25,8 @@ export class SavingsAccountViewResolver { */ resolve(route: ActivatedRouteSnapshot): Observable { const savingAccountId = route.paramMap.get('savingAccountId'); - return this.savingsService.getSavingsAccountData(savingAccountId); + return this.savingsAccountService.retrieveOne25({ + accountId: Number(savingAccountId) + }); } } diff --git a/src/app/savings/common-resolvers/savings-datatable.resolver.ts b/src/app/savings/common-resolvers/savings-datatable.resolver.ts index 6ea418d8e1..86e99d05f9 100644 --- a/src/app/savings/common-resolvers/savings-datatable.resolver.ts +++ b/src/app/savings/common-resolvers/savings-datatable.resolver.ts @@ -6,7 +6,7 @@ import { ActivatedRouteSnapshot } from '@angular/router'; import { Observable } from 'rxjs'; /** Custom Services */ -import { SavingsService } from '../savings.service'; +import { DataTablesService } from '@fineract/client'; /** * Savings Datatable data resolver. @@ -14,9 +14,9 @@ import { SavingsService } from '../savings.service'; @Injectable() export class SavingsDatatableResolver { /** - * @param {SavingsService} SavingsService Savings service. + * @param {DataTablesService} dataTablesService DataTables service. */ - constructor(private savingsService: SavingsService) {} + constructor(private dataTablesService: DataTablesService) {} /** * Returns the Savings Account's Datatable data. @@ -28,6 +28,8 @@ export class SavingsDatatableResolver { route.parent.parent.paramMap.get('fixedDepositAccountId') || route.parent.parent.paramMap.get('recurringDepositAccountId'); const datatableName = route.paramMap.get('datatableName'); - return this.savingsService.getSavingsDatatable(accountId, datatableName); + return this.dataTablesService.getDatatables({ + apptable: datatableName + }); } } diff --git a/src/app/savings/common-resolvers/savings-datatables.resolver.ts b/src/app/savings/common-resolvers/savings-datatables.resolver.ts index a68cdb06fa..2c0f05426b 100644 --- a/src/app/savings/common-resolvers/savings-datatables.resolver.ts +++ b/src/app/savings/common-resolvers/savings-datatables.resolver.ts @@ -6,7 +6,7 @@ import { ActivatedRouteSnapshot } from '@angular/router'; import { Observable } from 'rxjs'; /** Custom Services */ -import { SavingsService } from '../savings.service'; +import { DataTablesService } from '@fineract/client'; /** * Saving Accounts Datatables data resolver. @@ -14,15 +14,15 @@ import { SavingsService } from '../savings.service'; @Injectable() export class SavingsDatatablesResolver { /** - * @param {SavingsService} SavingsService Savings service. + * @param {DataTablesService} dataTablesService DataTables service. */ - constructor(private savingsService: SavingsService) {} + constructor(private dataTablesService: DataTablesService) {} /** * Returns the Saving Account's Datatables data. * @returns {Observable} */ resolve(): Observable { - return this.savingsService.getSavingsDatatables(); + return this.dataTablesService.getDatatables(); } } diff --git a/src/app/savings/common-resolvers/transaction-datatable.resolver.ts b/src/app/savings/common-resolvers/transaction-datatable.resolver.ts index 8799f9753f..784b96554e 100644 --- a/src/app/savings/common-resolvers/transaction-datatable.resolver.ts +++ b/src/app/savings/common-resolvers/transaction-datatable.resolver.ts @@ -6,15 +6,15 @@ import { ActivatedRouteSnapshot } from '@angular/router'; import { Observable } from 'rxjs'; // Custom Service -import { SavingsService } from '../savings.service'; +import { DataTablesService } from '@fineract/client'; @Injectable() export class TransactionDatatableResolver { /** * - * @param {SavingsService} savingsService + * @param {DataTablesService} dataTablesService */ - constructor(private savingsService: SavingsService) {} + constructor(private dataTablesService: DataTablesService) {} /** * Returns the Transactions Account's Datatable data. * @returns {Observable} @@ -23,6 +23,8 @@ export class TransactionDatatableResolver { resolve(route: ActivatedRouteSnapshot): Observable { const accountId = route.parent.parent.paramMap.get('id'); const datatableName = route.paramMap.get('datatableName'); - return this.savingsService.getSavingsTransactionDatatable(accountId, datatableName); + return this.dataTablesService.getDatatables({ + apptable: datatableName + }); } } diff --git a/src/app/savings/common-resolvers/transaction-datatables.resolver.ts b/src/app/savings/common-resolvers/transaction-datatables.resolver.ts index eef095be58..d43637e823 100644 --- a/src/app/savings/common-resolvers/transaction-datatables.resolver.ts +++ b/src/app/savings/common-resolvers/transaction-datatables.resolver.ts @@ -6,21 +6,21 @@ import { ActivatedRouteSnapshot } from '@angular/router'; import { Observable } from 'rxjs'; // Custom Service -import { SavingsService } from '../savings.service'; +import { DataTablesService } from '@fineract/client'; @Injectable() export class TransactionDatatablesResolver { /** * - * @param savingsService Savings Service + * @param datatablesService DataTables Service */ - constructor(private savingsService: SavingsService) {} + constructor(private dataTablesService: DataTablesService) {} /** * * @param route * @returns {Observable} */ resolve(route: ActivatedRouteSnapshot): Observable { - return this.savingsService.getSavingsTransactionDatatables(); + return this.dataTablesService.getDatatables(); } } diff --git a/src/app/savings/create-savings-account/create-savings-account.component.ts b/src/app/savings/create-savings-account/create-savings-account.component.ts index e1511acd37..2ab79acc84 100644 --- a/src/app/savings/create-savings-account/create-savings-account.component.ts +++ b/src/app/savings/create-savings-account/create-savings-account.component.ts @@ -8,7 +8,7 @@ import { SavingsAccountTermsStepComponent } from '../savings-account-stepper/sav import { SavingsAccountChargesStepComponent } from '../savings-account-stepper/savings-account-charges-step/savings-account-charges-step.component'; /** Custom Services */ -import { SavingsService } from '../savings.service'; +import { SavingsService } from 'app/customApis.service'; import { SettingsService } from 'app/settings/settings.service'; import { Dates } from 'app/core/utils/dates'; import { MatStepper, MatStepperIcon, MatStep, MatStepLabel } from '@angular/material/stepper'; diff --git a/src/app/savings/edit-savings-account/edit-savings-account.component.ts b/src/app/savings/edit-savings-account/edit-savings-account.component.ts index 015288e35c..66c012e970 100644 --- a/src/app/savings/edit-savings-account/edit-savings-account.component.ts +++ b/src/app/savings/edit-savings-account/edit-savings-account.component.ts @@ -8,7 +8,7 @@ import { SavingsAccountTermsStepComponent } from '../savings-account-stepper/sav import { SavingsAccountChargesStepComponent } from '../savings-account-stepper/savings-account-charges-step/savings-account-charges-step.component'; /** Custom Services */ -import { SavingsService } from '../savings.service'; +import { SavingsAccountService } from '@fineract/client'; import { SettingsService } from 'app/settings/settings.service'; import { Dates } from 'app/core/utils/dates'; import { MatStepper, MatStepperIcon, MatStep, MatStepLabel } from '@angular/material/stepper'; @@ -57,14 +57,14 @@ export class EditSavingsAccountComponent { * @param {ActivatedRoute} route Activated Route * @param {Router} router Router * @param {Dates} dateUtils Date Utils - * @param {SavingsService} savingsService Savings Service + * @param {SavingsAccountService} savingsAccountService Savings Account Service * @param {SettingsService} settingsService Settings Service */ constructor( private route: ActivatedRoute, private router: Router, private dateUtils: Dates, - private savingsService: SavingsService, + private savingsAccountService: SavingsAccountService, private settingsService: SettingsService ) { this.route.data.subscribe((data: { savingsAccountAndTemplate: any }) => { @@ -145,8 +145,8 @@ export class EditSavingsAccountComponent { } else { savingsAccount.groupId = this.savingsAccountAndTemplate.groupId; } - this.savingsService - .updateSavingsAccount(this.savingsAccountAndTemplate.id, savingsAccount) + this.savingsAccountService + .update20(this.savingsAccountAndTemplate.id, savingsAccount) .subscribe((response: any) => { this.router.navigate(['../'], { relativeTo: this.route }); }); diff --git a/src/app/savings/gsim-account/create-gsim-account/create-gsim-account.component.ts b/src/app/savings/gsim-account/create-gsim-account/create-gsim-account.component.ts index 654b120bb9..3445963622 100644 --- a/src/app/savings/gsim-account/create-gsim-account/create-gsim-account.component.ts +++ b/src/app/savings/gsim-account/create-gsim-account/create-gsim-account.component.ts @@ -9,7 +9,7 @@ import { SavingsAccountChargesStepComponent } from '../../savings-account-steppe import { SavingsActiveClientMembersComponent } from '../../savings-account-stepper/savings-active-client-members/savings-active-client-members.component'; /** Custom Services */ -import { SavingsService } from '../../savings.service'; +import { SavingsAccountService } from '@fineract/client'; import { SettingsService } from 'app/settings/settings.service'; import { Dates } from 'app/core/utils/dates'; import { MatStepper, MatStepperIcon, MatStep, MatStepLabel } from '@angular/material/stepper'; @@ -66,14 +66,14 @@ export class CreateGsimAccountComponent { * @param {ActivatedRoute} route Activated Route * @param {Router} router Router * @param {Dates} dateUtils Date Utils - * @param {SavingsService} savingsService Savings Service + * @param {SavingsAccountService} savingsAccountService Savings Account Service * @param {SettingsService} settingsService Settings Service */ constructor( private route: ActivatedRoute, private router: Router, private dateUtils: Dates, - private savingsService: SavingsService, + private savingsAccountService: SavingsAccountService, private settingsService: SettingsService ) { this.route.data.subscribe((data: { savingsAccountTemplate: any; groupsData: any }) => { @@ -179,14 +179,18 @@ export class CreateGsimAccountComponent { const gsimData = { clientArray: data }; - this.savingsService.createGsimAcccount(gsimData).subscribe((response: any) => { - this.router.navigate( - [ - '../', - response.resourceId - ], - { relativeTo: this.route } - ); - }); + this.savingsAccountService + .submitGSIMApplication({ + body: JSON.stringify(gsimData) + }) + .subscribe((response: any) => { + this.router.navigate( + [ + '../', + response.resourceId + ], + { relativeTo: this.route } + ); + }); } } diff --git a/src/app/savings/gsim-account/gsim-account.resolver.ts b/src/app/savings/gsim-account/gsim-account.resolver.ts index ebe8d26b6d..8ba72d363d 100644 --- a/src/app/savings/gsim-account/gsim-account.resolver.ts +++ b/src/app/savings/gsim-account/gsim-account.resolver.ts @@ -6,7 +6,7 @@ import { ActivatedRouteSnapshot } from '@angular/router'; import { Observable } from 'rxjs'; /** Custom Services */ -import { SavingsService } from '../savings.service'; +import { GroupsService } from '@fineract/client'; /** * GSIM Account data resolver. @@ -14,9 +14,9 @@ import { SavingsService } from '../savings.service'; @Injectable() export class GSIMViewResolver { /** - * @param {SavingsService} savingsService Savings service. + * @param {GroupsService} groupsService Groups service. */ - constructor(private savingsService: SavingsService) {} + constructor(private groupsService: GroupsService) {} /** * Returns the Savings Account data. @@ -26,6 +26,9 @@ export class GSIMViewResolver { resolve(route: ActivatedRouteSnapshot): Observable { const groupId = route.paramMap.get('groupId'); const savingAccountId = route.paramMap.get('savingAccountId'); - return this.savingsService.getGSIMAccountData(savingAccountId, groupId); + return this.groupsService.retrieveGsimAccounts({ + groupId: Number(groupId), + parentGSIMId: Number(savingAccountId) + }); } } diff --git a/src/app/savings/saving-account-actions/activate-savings-account/activate-savings-account.component.ts b/src/app/savings/saving-account-actions/activate-savings-account/activate-savings-account.component.ts index e5b96869e4..2dcaee8a6a 100644 --- a/src/app/savings/saving-account-actions/activate-savings-account/activate-savings-account.component.ts +++ b/src/app/savings/saving-account-actions/activate-savings-account/activate-savings-account.component.ts @@ -5,7 +5,7 @@ import { ActivatedRoute, Router, RouterLink } from '@angular/router'; import { Dates } from 'app/core/utils/dates'; /** Custom Services */ -import { SavingsService } from 'app/savings/savings.service'; +import { SavingsAccountService } from '@fineract/client'; import { SettingsService } from 'app/settings/settings.service'; import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module'; @@ -32,7 +32,7 @@ export class ActivateSavingsAccountComponent implements OnInit { /** * @param {FormBuilder} formBuilder Form Builder - * @param {SavingsService} savingsService Savings Service + * @param {SavingsAccountService} savingsAccountService Savings Account Service * @param {Dates} dateUtils Date Utils * @param {ActivatedRoute} route Activated Route * @param {Router} router Router @@ -40,7 +40,7 @@ export class ActivateSavingsAccountComponent implements OnInit { */ constructor( private formBuilder: UntypedFormBuilder, - private savingsService: SavingsService, + private savingsAccountService: SavingsAccountService, private dateUtils: Dates, private route: ActivatedRoute, private router: Router, @@ -86,8 +86,14 @@ export class ActivateSavingsAccountComponent implements OnInit { dateFormat, locale }; - this.savingsService.executeSavingsAccountCommand(this.accountId, 'activate', data).subscribe(() => { - this.router.navigate(['../../transactions'], { relativeTo: this.route }); - }); + this.savingsAccountService + .handleCommands6({ + accountId: this.accountId, + command: 'activate', + postSavingsAccountsAccountIdRequest: data + }) + .subscribe(() => { + this.router.navigate(['../../transactions'], { relativeTo: this.route }); + }); } } diff --git a/src/app/savings/saving-account-actions/add-charge-savings-account/add-charge-savings-account.component.ts b/src/app/savings/saving-account-actions/add-charge-savings-account/add-charge-savings-account.component.ts index aee8073fec..89446cabc1 100644 --- a/src/app/savings/saving-account-actions/add-charge-savings-account/add-charge-savings-account.component.ts +++ b/src/app/savings/saving-account-actions/add-charge-savings-account/add-charge-savings-account.component.ts @@ -10,7 +10,7 @@ import { import { Router, ActivatedRoute, RouterLink } from '@angular/router'; /** Custom Services */ -import { SavingsService } from '../../savings.service'; +import { ChargesService, SavingsChargesService } from '@fineract/client'; import { SettingsService } from 'app/settings/settings.service'; import { Dates } from 'app/core/utils/dates'; import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module'; @@ -46,7 +46,7 @@ export class AddChargeSavingsAccountComponent implements OnInit { * @param {ActivatedRoute} route Activated Route * @param {Router} router Router * @param {Dates} dateUtils Date Utils - * @param {SavingsService} savingsService Savings Service + * @param {ChargesService} chargesService Charges Service * @param {SettingsService} settingsService Settings Service */ constructor( @@ -54,8 +54,9 @@ export class AddChargeSavingsAccountComponent implements OnInit { private route: ActivatedRoute, private router: Router, private dateUtils: Dates, - private savingsService: SavingsService, - private settingsService: SettingsService + private chargesService: ChargesService, + private settingsService: SettingsService, + private savingsChargesService: SavingsChargesService ) { this.route.data.subscribe((data: { savingsAccountActionData: any }) => { this.savingsChargeOptions = data.savingsAccountActionData.chargeOptions; @@ -74,7 +75,7 @@ export class AddChargeSavingsAccountComponent implements OnInit { buildDependencies() { this.savingsChargeForm.controls.chargeId.valueChanges.subscribe((chargeId) => { - this.savingsService.getChargeTemplate(chargeId).subscribe((data: any) => { + this.chargesService.deleteCharge(chargeId).subscribe((data: any) => { this.chargeDetails = data; const chargeTimeType = data.chargeTimeType.id; if (data.chargeTimeType.value === 'Withdrawal Fee' || data.chargeTimeType.value === 'Saving No Activity Fee') { @@ -154,8 +155,13 @@ export class AddChargeSavingsAccountComponent implements OnInit { } } } - this.savingsService.createSavingsCharge(this.savingAccountId, 'charges', savingsCharge).subscribe(() => { - this.router.navigate(['../../transactions'], { relativeTo: this.route }); - }); + this.savingsChargesService + .addSavingsAccountCharge({ + savingsAccountId: parseInt(this.savingAccountId, 10), + postSavingsAccountsSavingsAccountIdChargesRequest: savingsCharge + }) + .subscribe(() => { + this.router.navigate(['../../transactions'], { relativeTo: this.route }); + }); } } diff --git a/src/app/savings/saving-account-actions/apply-annual-fees-savings-account/apply-annual-fees-savings-account.component.ts b/src/app/savings/saving-account-actions/apply-annual-fees-savings-account/apply-annual-fees-savings-account.component.ts index a2e195ca08..33fac2812f 100644 --- a/src/app/savings/saving-account-actions/apply-annual-fees-savings-account/apply-annual-fees-savings-account.component.ts +++ b/src/app/savings/saving-account-actions/apply-annual-fees-savings-account/apply-annual-fees-savings-account.component.ts @@ -5,7 +5,7 @@ import { ActivatedRoute, Router, RouterLink } from '@angular/router'; import { Dates } from 'app/core/utils/dates'; /** Custom Services */ -import { SavingsService } from 'app/savings/savings.service'; +import { SavingsChargesService } from '@fineract/client'; import { SettingsService } from 'app/settings/settings.service'; import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module'; @@ -36,7 +36,7 @@ export class ApplyAnnualFeesSavingsAccountComponent implements OnInit { /** * @param {FormBuilder} formBuilder Form Builder - * @param {SavingsService} savingsService Savings Service + * @param {SavingsChargesService} savingsChargesService Savings Charges Service * @param {Dates} dateUtils Date Utils * @param {ActivatedRoute} route Activated Route * @param {Router} router Router @@ -44,7 +44,7 @@ export class ApplyAnnualFeesSavingsAccountComponent implements OnInit { */ constructor( private formBuilder: UntypedFormBuilder, - private savingsService: SavingsService, + private savingsChargeService: SavingsChargesService, private dateUtils: Dates, private route: ActivatedRoute, private router: Router, @@ -108,8 +108,14 @@ export class ApplyAnnualFeesSavingsAccountComponent implements OnInit { dateFormat, locale }; - this.savingsService - .executeSavingsAccountChargesCommand(this.accountId, 'paycharge', data, this.chargeId) + this.savingsChargeService + .addSavingsAccountCharge({ + savingsAccountId: this.accountId, + postSavingsAccountsSavingsAccountIdChargesRequest: { + ...data, + chargeId: this.chargeId + } + }) .subscribe(() => { this.router.navigate(['../../'], { relativeTo: this.route }); }); diff --git a/src/app/savings/saving-account-actions/approve-savings-account/approve-savings-account.component.ts b/src/app/savings/saving-account-actions/approve-savings-account/approve-savings-account.component.ts index 9a3c59b9cd..7892aec972 100644 --- a/src/app/savings/saving-account-actions/approve-savings-account/approve-savings-account.component.ts +++ b/src/app/savings/saving-account-actions/approve-savings-account/approve-savings-account.component.ts @@ -5,7 +5,7 @@ import { ActivatedRoute, Router, RouterLink } from '@angular/router'; import { Dates } from 'app/core/utils/dates'; /** Custom Services */ -import { SavingsService } from 'app/savings/savings.service'; +import { SavingsAccountService } from '@fineract/client'; import { SettingsService } from 'app/settings/settings.service'; import { CdkTextareaAutosize } from '@angular/cdk/text-field'; import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module'; @@ -34,7 +34,7 @@ export class ApproveSavingsAccountComponent implements OnInit { /** * @param {FormBuilder} formBuilder Form Builder - * @param {SavingsService} savingsService Savings Service + * @param {SavingsAccountService} savingsAccountService Savings Account Service * @param {Dates} dateUtils Date Utils * @param {ActivatedRoute} route Activated Route * @param {Router} router Router @@ -42,7 +42,7 @@ export class ApproveSavingsAccountComponent implements OnInit { */ constructor( private formBuilder: UntypedFormBuilder, - private savingsService: SavingsService, + private savingsAccountService: SavingsAccountService, private dateUtils: Dates, private route: ActivatedRoute, private router: Router, @@ -89,8 +89,14 @@ export class ApproveSavingsAccountComponent implements OnInit { dateFormat, locale }; - this.savingsService.executeSavingsAccountCommand(this.accountId, 'approve', data).subscribe(() => { - this.router.navigate(['../../transactions'], { relativeTo: this.route }); - }); + this.savingsAccountService + .handleCommands6({ + accountId: this.accountId, + postSavingsAccountsAccountIdRequest: data, + command: 'approve' + }) + .subscribe(() => { + this.router.navigate(['../../transactions'], { relativeTo: this.route }); + }); } } diff --git a/src/app/savings/saving-account-actions/close-savings-account/close-savings-account.component.ts b/src/app/savings/saving-account-actions/close-savings-account/close-savings-account.component.ts index b0e0761d26..59f625000e 100644 --- a/src/app/savings/saving-account-actions/close-savings-account/close-savings-account.component.ts +++ b/src/app/savings/saving-account-actions/close-savings-account/close-savings-account.component.ts @@ -11,7 +11,7 @@ import { ActivatedRoute, Router, RouterLink } from '@angular/router'; import { Dates } from 'app/core/utils/dates'; /** Custom Services */ -import { SavingsService } from 'app/savings/savings.service'; +import { SavingsAccountService } from '@fineract/client'; import { SettingsService } from 'app/settings/settings.service'; import { MatCheckbox } from '@angular/material/checkbox'; import { MatSlideToggle } from '@angular/material/slide-toggle'; @@ -50,7 +50,7 @@ export class CloseSavingsAccountComponent implements OnInit { /** * @param {FormBuilder} formBuilder Form Builder - * @param {SavingsService} savingsService Savings Service + * @param {SavingsAccountService} savingsAccountService Savings Account Service * @param {Dates} dateUtils Date Utils * @param {ActivatedRoute} route Activated Route * @param {Router} router Router @@ -58,7 +58,7 @@ export class CloseSavingsAccountComponent implements OnInit { */ constructor( private formBuilder: UntypedFormBuilder, - private savingsService: SavingsService, + private savingsAccountService: SavingsAccountService, private dateUtils: Dates, private route: ActivatedRoute, private router: Router, @@ -150,7 +150,12 @@ export class CloseSavingsAccountComponent implements OnInit { dateFormat, locale }; - this.savingsService.executeSavingsAccountCommand(this.accountId, 'close', data).subscribe(() => { + const requestParameters = { + accountId: this.accountId, + command: 'close', + postSavingsAccountsAccountIdRequest: data + }; + this.savingsAccountService.handleCommands6(requestParameters).subscribe(() => { this.router.navigate(['../../transactions'], { relativeTo: this.route }); }); } diff --git a/src/app/savings/saving-account-actions/manage-savings-account/manage-savings-account.component.ts b/src/app/savings/saving-account-actions/manage-savings-account/manage-savings-account.component.ts index 1c544b2606..2fa4f3fe8d 100644 --- a/src/app/savings/saving-account-actions/manage-savings-account/manage-savings-account.component.ts +++ b/src/app/savings/saving-account-actions/manage-savings-account/manage-savings-account.component.ts @@ -2,7 +2,7 @@ import { Component, Input, OnInit } from '@angular/core'; import { UntypedFormBuilder, UntypedFormGroup, Validators, ReactiveFormsModule } from '@angular/forms'; import { ActivatedRoute, Router, RouterLink } from '@angular/router'; import { Dates } from 'app/core/utils/dates'; -import { SavingsService } from 'app/savings/savings.service'; +import { SavingsAccountTransactionsService, SavingsAccountService } from '@fineract/client'; import { SettingsService } from 'app/settings/settings.service'; import { Currency } from 'app/shared/models/general.model'; import { SystemService } from 'app/system/system.service'; @@ -52,7 +52,8 @@ export class ManageSavingsAccountComponent implements OnInit { /** * @param {FormBuilder} formBuilder Form Builder - * @param {SavingsService} savingsService Savings Service + * @param {SavingsAccountTransactionsService} savingsAccountTransactionsService Savings Account Transactions Service + * @param {SavingsAccountService} savingsAccountService Savings Account Service * @param {Dates} dateUtils Date Utils * @param {ActivatedRoute} route Activated Route * @param {Router} router Router @@ -60,7 +61,8 @@ export class ManageSavingsAccountComponent implements OnInit { */ constructor( private formBuilder: UntypedFormBuilder, - private savingsService: SavingsService, + private savingsAccountTransactionsService: SavingsAccountTransactionsService, + private savingsAccountService: SavingsAccountService, private dateUtils: Dates, private route: ActivatedRoute, private router: Router, @@ -160,8 +162,13 @@ export class ManageSavingsAccountComponent implements OnInit { command = 'holdAmount'; payload['transactionAmount'] = payload['transactionAmount'] * 1; - this.savingsService - .executeSavingsAccountTransactionsCommand(this.savingAccountId, command, payload) + this.savingsAccountTransactionsService + .adjustTransaction1({ + savingsId: parseInt(this.savingAccountId, 10), + transactionId: 0, + command: command, + postSavingsAccountBulkReversalTransactionsRequest: payload as any + }) .subscribe((response: any) => { this.router.navigate(['../../transactions'], { relativeTo: this.route }); }); @@ -176,8 +183,13 @@ export class ManageSavingsAccountComponent implements OnInit { command = 'blockDebit'; } - this.savingsService - .executeSavingsAccountCommand(this.savingAccountId, command, payload) + this.savingsAccountService + .handleCommands6({ + accountId: parseInt(this.savingAccountId, 10), + command: command, + postSavingsAccountsAccountIdRequest: + payload as unknown as import('@fineract/client').PostSavingsAccountsAccountIdRequest + }) .subscribe((response: any) => { this.router.navigate(['../../transactions'], { relativeTo: this.route }); }); diff --git a/src/app/savings/saving-account-actions/post-interest-as-on-savings-account/post-interest-as-on-savings-account.component.ts b/src/app/savings/saving-account-actions/post-interest-as-on-savings-account/post-interest-as-on-savings-account.component.ts index 23d11d8ff6..14c6c61f63 100644 --- a/src/app/savings/saving-account-actions/post-interest-as-on-savings-account/post-interest-as-on-savings-account.component.ts +++ b/src/app/savings/saving-account-actions/post-interest-as-on-savings-account/post-interest-as-on-savings-account.component.ts @@ -5,7 +5,7 @@ import { ActivatedRoute, Router, RouterLink } from '@angular/router'; import { Dates } from 'app/core/utils/dates'; /** Custom Services */ -import { SavingsService } from 'app/savings/savings.service'; +import { SavingsAccountTransactionsService } from '@fineract/client'; import { SettingsService } from 'app/settings/settings.service'; import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module'; @@ -32,7 +32,7 @@ export class PostInterestAsOnSavingsAccountComponent implements OnInit { /** * @param {FormBuilder} formBuilder Form Builder - * @param {SavingsService} savingsService Savings Service + * @param {SavingsAccountTransactionsService} savingsAccountTransactionsService Savings Account Transactions Service * @param {Dates} dateUtils Date Utils * @param {ActivatedRoute} route Activated Route * @param {Router} router Router @@ -40,7 +40,7 @@ export class PostInterestAsOnSavingsAccountComponent implements OnInit { */ constructor( private formBuilder: UntypedFormBuilder, - private savingsService: SavingsService, + private savingsAccountTransactionsService: SavingsAccountTransactionsService, private dateUtils: Dates, private route: ActivatedRoute, private router: Router, @@ -87,8 +87,13 @@ export class PostInterestAsOnSavingsAccountComponent implements OnInit { dateFormat, locale }; - this.savingsService - .executeSavingsAccountTransactionsCommand(this.accountId, 'postInterestAsOn', data) + this.savingsAccountTransactionsService + .adjustTransaction1({ + savingsId: this.accountId, + transactionId: 0, + command: 'postInterestAsOn', + postSavingsAccountBulkReversalTransactionsRequest: data + }) .subscribe(() => { this.router.navigate(['../../transactions'], { relativeTo: this.route }); }); diff --git a/src/app/savings/saving-account-actions/reject-savings-account/reject-savings-account.component.ts b/src/app/savings/saving-account-actions/reject-savings-account/reject-savings-account.component.ts index 82526ca861..8c977fcc15 100644 --- a/src/app/savings/saving-account-actions/reject-savings-account/reject-savings-account.component.ts +++ b/src/app/savings/saving-account-actions/reject-savings-account/reject-savings-account.component.ts @@ -5,7 +5,7 @@ import { ActivatedRoute, Router, RouterLink } from '@angular/router'; import { Dates } from 'app/core/utils/dates'; /** Custom Services */ -import { SavingsService } from 'app/savings/savings.service'; +import { SavingsAccountService } from '@fineract/client'; import { SettingsService } from 'app/settings/settings.service'; import { CdkTextareaAutosize } from '@angular/cdk/text-field'; import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module'; @@ -34,7 +34,7 @@ export class RejectSavingsAccountComponent implements OnInit { /** * @param {FormBuilder} formBuilder Form Builder - * @param {SavingsService} savingsService Savings Service + * @param {SavingsAccountService} savingsAccountService Savings Account Service * @param {Dates} dateUtils Date Utils * @param {ActivatedRoute} route Activated Route * @param {Router} router Router @@ -42,7 +42,7 @@ export class RejectSavingsAccountComponent implements OnInit { */ constructor( private formBuilder: UntypedFormBuilder, - private savingsService: SavingsService, + private savingsAccountService: SavingsAccountService, private dateUtils: Dates, private route: ActivatedRoute, private router: Router, @@ -89,8 +89,14 @@ export class RejectSavingsAccountComponent implements OnInit { dateFormat, locale }; - this.savingsService.executeSavingsAccountCommand(this.accountId, 'reject', data).subscribe(() => { - this.router.navigate(['../../'], { relativeTo: this.route }); - }); + this.savingsAccountService + .handleCommands6({ + accountId: this.accountId, + command: 'reject', + postSavingsAccountsAccountIdRequest: data + }) + .subscribe(() => { + this.router.navigate(['../../'], { relativeTo: this.route }); + }); } } diff --git a/src/app/savings/saving-account-actions/savings-account-assign-staff/savings-account-assign-staff.component.ts b/src/app/savings/saving-account-actions/savings-account-assign-staff/savings-account-assign-staff.component.ts index 510c86992b..9b53e9803f 100644 --- a/src/app/savings/saving-account-actions/savings-account-assign-staff/savings-account-assign-staff.component.ts +++ b/src/app/savings/saving-account-actions/savings-account-assign-staff/savings-account-assign-staff.component.ts @@ -5,7 +5,7 @@ import { ActivatedRoute, Router, RouterLink } from '@angular/router'; import { Dates } from 'app/core/utils/dates'; /** Custom Services */ -import { SavingsService } from 'app/savings/savings.service'; +import { SavingsAccountService } from '@fineract/client'; import { SettingsService } from 'app/settings/settings.service'; import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module'; @@ -36,7 +36,7 @@ export class SavingsAccountAssignStaffComponent implements OnInit { /** * @param {FormBuilder} formBuilder Form Builder - * @param {SavingsService} savingsService Savings Service + * @param {SavingsAccountService} savingsAccountService Savings Account Service * @param {Dates} dateUtils Date Utils * @param {ActivatedRoute} route Activated Route * @param {Router} router Router @@ -44,7 +44,7 @@ export class SavingsAccountAssignStaffComponent implements OnInit { */ constructor( private formBuilder: UntypedFormBuilder, - private savingsService: SavingsService, + private savingsAccountService: SavingsAccountService, private dateUtils: Dates, private route: ActivatedRoute, private router: Router, @@ -96,8 +96,14 @@ export class SavingsAccountAssignStaffComponent implements OnInit { dateFormat, locale }; - this.savingsService.executeSavingsAccountCommand(this.accountId, 'assignSavingsOfficer', data).subscribe(() => { - this.router.navigate(['../../transactions'], { relativeTo: this.route }); - }); + this.savingsAccountService + .handleCommands6({ + accountId: this.accountId, + command: 'assignSavingsOfficer', + postSavingsAccountsAccountIdRequest: data + }) + .subscribe(() => { + this.router.navigate(['../../transactions'], { relativeTo: this.route }); + }); } } diff --git a/src/app/savings/saving-account-actions/savings-account-transactions/savings-account-transactions.component.ts b/src/app/savings/saving-account-actions/savings-account-transactions/savings-account-transactions.component.ts index fd754247af..1add9fd0e3 100644 --- a/src/app/savings/saving-account-actions/savings-account-transactions/savings-account-transactions.component.ts +++ b/src/app/savings/saving-account-actions/savings-account-transactions/savings-account-transactions.component.ts @@ -10,7 +10,7 @@ import { import { Router, ActivatedRoute, RouterLink } from '@angular/router'; /** Custom Services */ -import { SavingsService } from '../../savings.service'; +import { SavingsAccountTransactionsService } from '@fineract/client'; import { SettingsService } from 'app/settings/settings.service'; import { Dates } from 'app/core/utils/dates'; import { Currency } from 'app/shared/models/general.model'; @@ -61,7 +61,7 @@ export class SavingsAccountTransactionsComponent implements OnInit { /** * Retrieves the Saving Account transaction template data from `resolve`. * @param {FormBuilder} formBuilder Form Builder. - * @param {SavingsService} savingsService Savings Service. + * @param {SavingsAccountTransactionsService} savingsAccountTransactionsService Savings Account Transactions Service. * @param {ActivatedRoute} route Activated Route. * @param {Dates} dateUtils Date Utils. * @param {Router} router Router for navigation. @@ -72,7 +72,7 @@ export class SavingsAccountTransactionsComponent implements OnInit { private route: ActivatedRoute, private router: Router, private dateUtils: Dates, - private savingsService: SavingsService, + private savingsAccountTransactionsService: SavingsAccountTransactionsService, private settingsService: SettingsService ) { this.route.data.subscribe((data: { savingsAccountActionData: any }) => { @@ -149,8 +149,13 @@ export class SavingsAccountTransactionsComponent implements OnInit { locale }; data['transactionAmount'] = data['transactionAmount'] * 1; - this.savingsService - .executeSavingsAccountTransactionsCommand(this.savingAccountId, this.transactionCommand, data) + this.savingsAccountTransactionsService + .adjustTransaction1({ + savingsId: Number(this.savingAccountId), + transactionId: 0, + postSavingsAccountBulkReversalTransactionsRequest: data, + command: this.transactionCommand + }) .subscribe((res) => { this.router.navigate(['../../transactions'], { relativeTo: this.route }); }); diff --git a/src/app/savings/saving-account-actions/savings-account-unassign-staff/savings-account-unassign-staff.component.ts b/src/app/savings/saving-account-actions/savings-account-unassign-staff/savings-account-unassign-staff.component.ts index 9f75abb96e..694b1b3897 100644 --- a/src/app/savings/saving-account-actions/savings-account-unassign-staff/savings-account-unassign-staff.component.ts +++ b/src/app/savings/saving-account-actions/savings-account-unassign-staff/savings-account-unassign-staff.component.ts @@ -5,7 +5,7 @@ import { ActivatedRoute, Router, RouterLink } from '@angular/router'; import { Dates } from 'app/core/utils/dates'; /** Custom Services */ -import { SavingsService } from 'app/savings/savings.service'; +import { SavingsAccountService } from '@fineract/client'; import { SettingsService } from 'app/settings/settings.service'; import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module'; @@ -32,7 +32,7 @@ export class SavingsAccountUnassignStaffComponent implements OnInit { /** * @param {FormBuilder} formBuilder Form Builder - * @param {SavingsService} savingsService Savings Service + * @param {SavingsAccountService} savingsAccountService Savings Account Service * @param {Dates} dateUtils Date Utils * @param {ActivatedRoute} route Activated Route * @param {Router} router Router @@ -40,7 +40,7 @@ export class SavingsAccountUnassignStaffComponent implements OnInit { */ constructor( private formBuilder: UntypedFormBuilder, - private savingsService: SavingsService, + private savingsAccountService: SavingsAccountService, private dateUtils: Dates, private route: ActivatedRoute, private router: Router, @@ -86,8 +86,14 @@ export class SavingsAccountUnassignStaffComponent implements OnInit { dateFormat, locale }; - this.savingsService.executeSavingsAccountCommand(this.accountId, 'unassignSavingsOfficer', data).subscribe(() => { - this.router.navigate(['../../transactions'], { relativeTo: this.route }); - }); + this.savingsAccountService + .handleCommands6({ + accountId: parseInt(this.accountId, 10), + command: 'unassignSavingsOfficer', + postSavingsAccountsAccountIdRequest: data + }) + .subscribe(() => { + this.router.navigate(['../../transactions'], { relativeTo: this.route }); + }); } } diff --git a/src/app/savings/saving-account-actions/undo-approval-savings-account/undo-approval-savings-account.component.ts b/src/app/savings/saving-account-actions/undo-approval-savings-account/undo-approval-savings-account.component.ts index d033837c52..1c74ce4883 100644 --- a/src/app/savings/saving-account-actions/undo-approval-savings-account/undo-approval-savings-account.component.ts +++ b/src/app/savings/saving-account-actions/undo-approval-savings-account/undo-approval-savings-account.component.ts @@ -4,7 +4,7 @@ import { UntypedFormGroup, UntypedFormBuilder, ReactiveFormsModule } from '@angu import { ActivatedRoute, Router, RouterLink } from '@angular/router'; /** Custom Services */ -import { SavingsService } from 'app/savings/savings.service'; +import { SavingsAccountService } from '@fineract/client'; import { CdkTextareaAutosize } from '@angular/cdk/text-field'; import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module'; @@ -28,13 +28,13 @@ export class UndoApprovalSavingsAccountComponent implements OnInit { /** * @param {FormBuilder} formBuilder Form Builder - * @param {SavingsService} savingsService Savings Service + * @param {SavingsAccountService} savingsAccountService Savings Account Service * @param {ActivatedRoute} route Activated Route * @param {Router} router Router */ constructor( private formBuilder: UntypedFormBuilder, - private savingsService: SavingsService, + private savingsAccountService: SavingsAccountService, private route: ActivatedRoute, private router: Router ) { @@ -65,8 +65,14 @@ export class UndoApprovalSavingsAccountComponent implements OnInit { const data = { ...this.undoApprovalSavingsAccountForm.value }; - this.savingsService.executeSavingsAccountCommand(this.accountId, 'undoapproval', data).subscribe(() => { - this.router.navigate(['../../transactions'], { relativeTo: this.route }); - }); + this.savingsAccountService + .handleCommands6({ + accountId: this.accountId, + command: 'undoapproval', + postSavingsAccountsAccountIdRequest: data + }) + .subscribe(() => { + this.router.navigate(['../../transactions'], { relativeTo: this.route }); + }); } } diff --git a/src/app/savings/saving-account-actions/withdraw-by-client-savings-account/withdraw-by-client-savings-account.component.ts b/src/app/savings/saving-account-actions/withdraw-by-client-savings-account/withdraw-by-client-savings-account.component.ts index defefd0a53..032da645fb 100644 --- a/src/app/savings/saving-account-actions/withdraw-by-client-savings-account/withdraw-by-client-savings-account.component.ts +++ b/src/app/savings/saving-account-actions/withdraw-by-client-savings-account/withdraw-by-client-savings-account.component.ts @@ -5,7 +5,7 @@ import { ActivatedRoute, Router, RouterLink } from '@angular/router'; import { Dates } from 'app/core/utils/dates'; /** Custom Services */ -import { SavingsService } from 'app/savings/savings.service'; +import { SavingsAccountService } from '@fineract/client'; import { SettingsService } from 'app/settings/settings.service'; import { CdkTextareaAutosize } from '@angular/cdk/text-field'; import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module'; @@ -34,7 +34,7 @@ export class WithdrawByClientSavingsAccountComponent implements OnInit { /** * @param {FormBuilder} formBuilder Form Builder - * @param {SavingsService} savingsService Savings Service + * @param {SavingsAccountService} savingsAccountService Savings Account Service * @param {Dates} dateUtils Date Utils * @param {ActivatedRoute} route Activated Route * @param {Router} router Router @@ -42,7 +42,7 @@ export class WithdrawByClientSavingsAccountComponent implements OnInit { */ constructor( private formBuilder: UntypedFormBuilder, - private savingsService: SavingsService, + private savingsAccountService: SavingsAccountService, private dateUtils: Dates, private route: ActivatedRoute, private router: Router, @@ -89,8 +89,19 @@ export class WithdrawByClientSavingsAccountComponent implements OnInit { dateFormat, locale }; - this.savingsService.executeSavingsAccountCommand(this.accountId, 'withdrawnByApplicant', data).subscribe(() => { - this.router.navigate(['../../'], { relativeTo: this.route }); - }); + const requestParams = { + savingsId: this.accountId, + command: 'withdrawnByApplicant', + body: data + }; + this.savingsAccountService + .handleCommands6({ + accountId: this.accountId, + postSavingsAccountsAccountIdRequest: data, + command: 'withdrawnByApplicant' + }) + .subscribe(() => { + this.router.navigate(['../../'], { relativeTo: this.route }); + }); } } diff --git a/src/app/savings/savings-account-stepper/savings-account-details-step/savings-account-details-step.component.ts b/src/app/savings/savings-account-stepper/savings-account-details-step/savings-account-details-step.component.ts index ebc1230cfc..4135b69667 100644 --- a/src/app/savings/savings-account-stepper/savings-account-details-step/savings-account-details-step.component.ts +++ b/src/app/savings/savings-account-stepper/savings-account-details-step/savings-account-details-step.component.ts @@ -3,7 +3,7 @@ import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; import { UntypedFormGroup, UntypedFormBuilder, Validators, ReactiveFormsModule } from '@angular/forms'; /** Custom Services */ -import { SavingsService } from 'app/savings/savings.service'; +import { SavingsAccountService } from '@fineract/client'; import { SettingsService } from 'app/settings/settings.service'; import { MatStepperPrevious, MatStepperNext } from '@angular/material/stepper'; import { FaIconComponent } from '@fortawesome/angular-fontawesome'; @@ -48,12 +48,12 @@ export class SavingsAccountDetailsStepComponent implements OnInit { /** * Sets share account details form. * @param {FormBuilder} formBuilder Form Builder. - * @param {SavingsService} savingsService Savings Service. + * @param {SavingsAccountService} savingsAccountService Savings Account Service * @param {SettingsService} settingsService Setting service */ constructor( private formBuilder: UntypedFormBuilder, - private savingsService: SavingsService, + private savingsAccountService: SavingsAccountService, private settingsService: SettingsService ) { this.createSavingsAccountDetailsForm(); @@ -104,8 +104,12 @@ export class SavingsAccountDetailsStepComponent implements OnInit { buildDependencies() { const entityId = this.savingsAccountTemplate.groupId || this.savingsAccountTemplate.clientId; this.savingsAccountDetailsForm.get('productId').valueChanges.subscribe((productId: string) => { - this.savingsService - .getSavingsAccountTemplate(entityId, productId, this.savingsAccountTemplate.groupId ? true : false) + this.savingsAccountService + .template14({ + clientId: this.savingsAccountTemplate.groupId ? undefined : entityId ? Number(entityId) : undefined, + groupId: this.savingsAccountTemplate.groupId ? Number(entityId) : undefined, + productId: productId ? Number(productId) : undefined + }) .subscribe((response: any) => { this.savingsAccountProductTemplate.emit(response); this.fieldOfficerData = response.fieldOfficerOptions; diff --git a/src/app/savings/savings-account-view/charges-tab/charges-tab.component.ts b/src/app/savings/savings-account-view/charges-tab/charges-tab.component.ts index e784122c99..b61d368d94 100644 --- a/src/app/savings/savings-account-view/charges-tab/charges-tab.component.ts +++ b/src/app/savings/savings-account-view/charges-tab/charges-tab.component.ts @@ -17,7 +17,7 @@ import { } from '@angular/material/table'; /** Custom Services */ -import { SavingsService } from 'app/savings/savings.service'; +import { SavingsChargesService } from '@fineract/client'; import { SettingsService } from 'app/settings/settings.service'; /** Custom Dialogs */ @@ -98,7 +98,7 @@ export class ChargesTabComponent implements OnInit { * @param {SettingsService} settingsService Setting service */ constructor( - private savingsService: SavingsService, + private savingsChargeService: SavingsChargesService, private route: ActivatedRoute, private dateUtils: Dates, private router: Router, @@ -170,8 +170,13 @@ export class ChargesTabComponent implements OnInit { dateFormat, locale }; - this.savingsService - .executeSavingsAccountChargesCommand(this.savingsAccountData.id, 'paycharge', dataObject, chargeId) + this.savingsChargeService + .payOrWaiveSavingsAccountCharge({ + savingsAccountId: this.savingsAccountData.id, + savingsAccountChargeId: chargeId, + postSavingsAccountsSavingsAccountIdChargesSavingsAccountChargeIdRequest: dataObject, + command: 'paycharge' + }) .subscribe(() => { this.reload(); }); @@ -187,8 +192,13 @@ export class ChargesTabComponent implements OnInit { const waiveChargeDialogRef = this.dialog.open(WaiveChargeDialogComponent, { data: { id: chargeId } }); waiveChargeDialogRef.afterClosed().subscribe((response: any) => { if (response.confirm) { - this.savingsService - .executeSavingsAccountChargesCommand(this.savingsAccountData.id, 'waive', {}, chargeId) + this.savingsChargeService + .payOrWaiveSavingsAccountCharge({ + savingsAccountId: this.savingsAccountData.id, + savingsAccountChargeId: chargeId, + command: 'waive', + postSavingsAccountsSavingsAccountIdChargesSavingsAccountChargeIdRequest: {} + }) .subscribe(() => { this.reload(); }); @@ -204,8 +214,13 @@ export class ChargesTabComponent implements OnInit { const inactivateChargeDialogRef = this.dialog.open(InactivateChargeDialogComponent, { data: { id: chargeId } }); inactivateChargeDialogRef.afterClosed().subscribe((response: any) => { if (response.confirm) { - this.savingsService - .executeSavingsAccountChargesCommand(this.savingsAccountData.id, 'inactivate', {}, chargeId) + this.savingsChargeService + .payOrWaiveSavingsAccountCharge({ + savingsAccountId: this.savingsAccountData.id, + savingsAccountChargeId: chargeId, + command: 'inactivate', + postSavingsAccountsSavingsAccountIdChargesSavingsAccountChargeIdRequest: {} + }) .subscribe(() => { this.reload(); }); @@ -243,8 +258,8 @@ export class ChargesTabComponent implements OnInit { dateFormat, locale }; - this.savingsService - .editSavingsAccountCharge(this.savingsAccountData.id, dataObject, charge.id) + this.savingsChargeService + .updateSavingsAccountCharge(this.savingsAccountData.id, dataObject, charge.id) .subscribe(() => { this.reload(); }); @@ -262,7 +277,7 @@ export class ChargesTabComponent implements OnInit { }); deleteChargeDialogRef.afterClosed().subscribe((response: any) => { if (response.delete) { - this.savingsService.deleteSavingsAccountCharge(this.savingsAccountData.id, chargeId).subscribe(() => { + this.savingsChargeService.deleteSavingsAccountCharge(this.savingsAccountData.id, chargeId).subscribe(() => { this.reload(); }); } diff --git a/src/app/savings/savings-account-view/notes-tab/notes-tab.component.ts b/src/app/savings/savings-account-view/notes-tab/notes-tab.component.ts index d63c551e2e..c461c692e6 100644 --- a/src/app/savings/savings-account-view/notes-tab/notes-tab.component.ts +++ b/src/app/savings/savings-account-view/notes-tab/notes-tab.component.ts @@ -1,7 +1,7 @@ -import { Component } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { AuthenticationService } from 'app/core/authentication/authentication.service'; -import { SavingsService } from 'app/savings/savings.service'; +import { NotesService } from '@fineract/client'; import { EntityNotesTabComponent } from '../../../shared/tabs/entity-notes-tab/entity-notes-tab.component'; import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module'; @@ -14,16 +14,56 @@ import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module'; EntityNotesTabComponent ] }) -export class NotesTabComponent { +export class NotesTabComponent implements OnInit { entityId: string; username: string; entityNotes: any; + /** + * Add a note. + * @param {string} noteContent Note content. + */ + addNote = (noteContent: string) => { + return this.notesService.addNewNote({ + resourceType: 'savings', + resourceId: parseInt(this.entityId, 10), + noteRequest: { note: noteContent } + }); + }; + + /** + * Edit a note. + * @param {string} noteId Note ID. + * @param {string} noteContent Note content. + */ + editNote = (noteId: string, noteContent: string) => { + return this.notesService.updateNote({ + resourceType: 'savings', + resourceId: parseInt(this.entityId, 10), + noteId: parseInt(noteId, 10), + noteRequest: { note: noteContent } + }); + }; + + /** + * Delete a note. + * @param {string} noteId Note ID. + */ + deleteNote = (noteId: string) => { + return this.notesService.deleteNote({ + resourceType: 'savings', + resourceId: parseInt(this.entityId, 10), + noteId: parseInt(noteId, 10) + }); + }; + constructor( private route: ActivatedRoute, - private savingsService: SavingsService, + private notesService: NotesService, private authenticationService: AuthenticationService - ) { + ) {} + + ngOnInit(): void { const savedCredentials = this.authenticationService.getCredentials(); this.username = savedCredentials.username; this.entityId = this.route.parent.snapshot.params['savingAccountId']; @@ -31,27 +71,4 @@ export class NotesTabComponent { this.entityNotes = data.savingAccountNotes; }); } - - addNote(noteContent: any) { - this.savingsService.createSavingsNote(this.entityId, noteContent).subscribe((response: any) => { - this.entityNotes.push({ - id: response.resourceId, - createdByUsername: this.username, - createdOn: new Date(), - note: noteContent.note - }); - }); - } - - editNote(noteId: string, noteContent: any, index: number) { - this.savingsService.editSavingsNote(this.entityId, noteId, noteContent).subscribe(() => { - this.entityNotes[index].note = noteContent.note; - }); - } - - deleteNote(noteId: string, index: number) { - this.savingsService.deleteSavingsNote(this.entityId, noteId).subscribe(() => { - this.entityNotes.splice(index, 1); - }); - } } diff --git a/src/app/savings/savings-account-view/savings-account-view.component.ts b/src/app/savings/savings-account-view/savings-account-view.component.ts index 3a65074d84..c27fea0e45 100644 --- a/src/app/savings/savings-account-view/savings-account-view.component.ts +++ b/src/app/savings/savings-account-view/savings-account-view.component.ts @@ -11,7 +11,7 @@ import { ToggleWithholdTaxDialogComponent } from './custom-dialogs/toggle-withho /** Custom Buttons Configuration */ import { SavingsButtonsConfiguration } from './savings-buttons.config'; -import { SavingsService } from '../savings.service'; +import { SavingsAccountService } from '@fineract/client'; import { ConfirmationDialogComponent } from 'app/shared/confirmation-dialog/confirmation-dialog.component'; import { Currency } from 'app/shared/models/general.model'; import { TranslateService } from '@ngx-translate/core'; @@ -87,12 +87,12 @@ export class SavingsAccountViewComponent implements OnInit { * Fetches savings account data from `resolve` * @param {ActivatedRoute} route Activated Route * @param {Router} router Router - * @param {SavingsService} savingsService Savings Service + * @param {SavingsAccountService} savingsAccountService Savings Account Service */ constructor( private route: ActivatedRoute, private router: Router, - private savingsService: SavingsService, + private savingsAccountService: SavingsAccountService, private translateService: TranslateService, public dialog: MatDialog ) { @@ -267,7 +267,7 @@ export class SavingsAccountViewComponent implements OnInit { }); deleteSavingsAccountDialogRef.afterClosed().subscribe((response: any) => { if (response.delete) { - this.savingsService.deleteSavingsAccount(this.savingsAccountData.id).subscribe(() => { + this.savingsAccountService.delete18(this.savingsAccountData.id).subscribe(() => { this.router.navigate(['../../'], { relativeTo: this.route }); }); } @@ -281,8 +281,12 @@ export class SavingsAccountViewComponent implements OnInit { const calculateInterestAccountDialogRef = this.dialog.open(CalculateInterestDialogComponent); calculateInterestAccountDialogRef.afterClosed().subscribe((response: any) => { if (response.confirm) { - this.savingsService - .executeSavingsAccountCommand(this.savingsAccountData.id, 'calculateInterest', {}) + this.savingsAccountService + .handleCommands6({ + accountId: this.savingsAccountData.id, + command: 'calculateInterest', + postSavingsAccountsAccountIdRequest: {} + }) .subscribe(() => { this.reload(); }); @@ -297,8 +301,12 @@ export class SavingsAccountViewComponent implements OnInit { const postInterestAccountDialogRef = this.dialog.open(PostInterestDialogComponent); postInterestAccountDialogRef.afterClosed().subscribe((response: any) => { if (response.confirm) { - this.savingsService - .executeSavingsAccountCommand(this.savingsAccountData.id, 'postInterest', {}) + this.savingsAccountService + .handleCommands6({ + accountId: this.savingsAccountData.id, + command: 'postInterest', + postSavingsAccountsAccountIdRequest: {} + }) .subscribe(() => { this.reload(); }); @@ -315,8 +323,12 @@ export class SavingsAccountViewComponent implements OnInit { }); deleteSavingsAccountDialogRef.afterClosed().subscribe((response: any) => { if (response.confirm) { - this.savingsService - .executeSavingsAccountUpdateCommand(this.savingsAccountData.id, 'updateWithHoldTax', { withHoldTax: true }) + this.savingsAccountService + .update20({ + accountId: this.savingsAccountData.id, + putSavingsAccountsAccountIdRequest: {}, + command: 'updateWithHoldTax?withHoldTax=true' + }) .subscribe(() => { this.reload(); }); @@ -333,8 +345,12 @@ export class SavingsAccountViewComponent implements OnInit { }); disableWithHoldTaxDialogRef.afterClosed().subscribe((response: any) => { if (response.confirm) { - this.savingsService - .executeSavingsAccountUpdateCommand(this.savingsAccountData.id, 'updateWithHoldTax', { withHoldTax: false }) + this.savingsAccountService + .update20({ + accountId: this.savingsAccountData.id, + putSavingsAccountsAccountIdRequest: {}, + command: 'updateWithHoldTax?withHoldTax=false' + }) .subscribe(() => { this.reload(); }); @@ -364,9 +380,15 @@ export class SavingsAccountViewComponent implements OnInit { } unblockSavingsAccountDialogRef.afterClosed().subscribe((response: { confirm: any }) => { if (response.confirm) { - this.savingsService.executeSavingsAccountCommand(this.savingsAccountData.id, command, {}).subscribe(() => { - this.reload(); - }); + this.savingsAccountService + .handleCommands6({ + accountId: this.savingsAccountData.id, + command: command, + postSavingsAccountsAccountIdRequest: {} + }) + .subscribe(() => { + this.reload(); + }); } }); } diff --git a/src/app/savings/savings-account-view/savings-documents-tab/savings-documents-tab.component.ts b/src/app/savings/savings-account-view/savings-documents-tab/savings-documents-tab.component.ts index 45d1349b0c..8c2dda1b8e 100644 --- a/src/app/savings/savings-account-view/savings-documents-tab/savings-documents-tab.component.ts +++ b/src/app/savings/savings-account-view/savings-documents-tab/savings-documents-tab.component.ts @@ -1,7 +1,7 @@ import { Component } from '@angular/core'; import { MatDialog } from '@angular/material/dialog'; import { ActivatedRoute } from '@angular/router'; -import { SavingsService } from 'app/savings/savings.service'; +import { DocumentsService } from '@fineract/client'; import { SettingsService } from 'app/settings/settings.service'; import { environment } from '../../../../environments/environment'; import { EntityDocumentsTabComponent } from '../../../shared/tabs/entity-documents-tab/entity-documents-tab.component'; @@ -26,10 +26,11 @@ export class SavingsDocumentsTabComponent { /** * Retrieves the savings data from `resolve`. * @param {ActivatedRoute} route Activated Route. + * @param {DocumentsService} documentsService Documents Service. */ constructor( private route: ActivatedRoute, - private savingsService: SavingsService, + private documentsService: DocumentsService, private settingsService: SettingsService, public dialog: MatDialog ) { @@ -68,17 +69,37 @@ export class SavingsDocumentsTabComponent { } downloadDocument(documentId: string) { - this.savingsService.downloadSavingsDocument(this.entityId, documentId).subscribe((res) => { - const url = window.URL.createObjectURL(res); - window.open(url); - }); + this.documentsService + .downloadFile({ + entityType: this.entityType, + entityId: parseInt(this.entityId, 10), + documentId: parseInt(documentId, 10) + }) + .subscribe((res) => { + const url = window.URL.createObjectURL(res); + window.open(url); + }); } uploadDocument(formData: FormData): any { - return this.savingsService.loadSavingsDocument(this.entityId, formData); + return this.documentsService.createDocument({ + entityType: this.entityType, + entityId: parseInt(this.entityId, 10), + uploadedInputStream: formData.get('file') as Blob, + name: formData.get('name') as string, + description: formData.get('description') as string + }); } deleteDocument(documentId: any) { - this.savingsService.deleteSavingsDocument(this.entityId, documentId).subscribe((res: any) => {}); + this.documentsService + .deleteDocument({ + entityType: this.entityType, + entityId: parseInt(this.entityId, 10), + documentId: parseInt(documentId, 10) + }) + .subscribe(() => { + this.entityDocuments = this.entityDocuments.filter((doc: any) => doc.id !== documentId); + }); } } diff --git a/src/app/savings/savings-account-view/standing-instructions-tab/standing-instructions-tab.component.ts b/src/app/savings/savings-account-view/standing-instructions-tab/standing-instructions-tab.component.ts index fbccf16f51..a69caaf661 100644 --- a/src/app/savings/savings-account-view/standing-instructions-tab/standing-instructions-tab.component.ts +++ b/src/app/savings/savings-account-view/standing-instructions-tab/standing-instructions-tab.component.ts @@ -17,7 +17,7 @@ import { import { ActivatedRoute } from '@angular/router'; /** Custom Services */ -import { SavingsService } from 'app/savings/savings.service'; +import { StandingInstructionsService } from '@fineract/client'; import { AccountTransfersService } from 'app/customApis.service'; import { SettingsService } from 'app/settings/settings.service'; @@ -74,11 +74,12 @@ export class StandingInstructionsTabComponent implements OnInit { /** * Retrieves Savings Account Data from `resolve`. * @param {ActivatedRoute} route Activated Route. - * @param {SettingsService} settingsService Setting service + * @param {SettingsService} settingsService Setting service. + * @param {StandingInstructionsService} standingInstructionsService Standing Instructions Service. */ constructor( private route: ActivatedRoute, - private savingsService: SavingsService, + private standingsInstructionsService: StandingInstructionsService, private dialog: MatDialog, private accountTransfersService: AccountTransfersService, private settingsService: SettingsService @@ -101,8 +102,13 @@ export class StandingInstructionsTabComponent implements OnInit { const accountId = this.savingsData.id; const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; - this.savingsService - .getStandingInstructions(clientId, clientName, accountId, locale, dateFormat) + this.standingsInstructionsService + .retrieveAll19({ + clientId: clientId, + clientName: clientName, + fromAccountId: accountId, + limit: 1000 + }) .subscribe((response: any) => { this.instructionsData = response.pageItems; this.dataSource.data = this.instructionsData; diff --git a/src/app/savings/savings-account-view/transactions-tab/transactions-tab.component.ts b/src/app/savings/savings-account-view/transactions-tab/transactions-tab.component.ts index d3ad3636c6..1ca272990d 100644 --- a/src/app/savings/savings-account-view/transactions-tab/transactions-tab.component.ts +++ b/src/app/savings/savings-account-view/transactions-tab/transactions-tab.component.ts @@ -22,7 +22,7 @@ import { SavingsAccountTransaction, SavingsAccountTransactionType } from 'app/savings/models/savings-account-transaction.model'; -import { SavingsService } from 'app/savings/savings.service'; +import { SavingsAccountTransactionsService } from '@fineract/client'; import { SettingsService } from 'app/settings/settings.service'; import { UndoTransactionDialogComponent } from '../custom-dialogs/undo-transaction-dialog/undo-transaction-dialog.component'; import { MatDialog } from '@angular/material/dialog'; @@ -104,11 +104,12 @@ export class TransactionsTabComponent implements OnInit { /** * Retrieves savings account data from `resolve`. * @param {ActivatedRoute} route Activated Route. + * @param {SavingsAccountTransactionsService} SavingsAccountTransactionsService Savings Account Transactions Service */ constructor( private route: ActivatedRoute, private router: Router, - private savingsService: SavingsService, + private savingsAccountTransactionsService: SavingsAccountTransactionsService, private settingsService: SettingsService, private dialog: MatDialog, private dateUtils: Dates @@ -240,8 +241,13 @@ export class TransactionsTabComponent implements OnInit { dateFormat, locale }; - this.savingsService - .executeSavingsAccountTransactionsCommand(this.accountId, 'undo', data, transactionData.id) + this.savingsAccountTransactionsService + .adjustTransaction1({ + savingsId: Number(this.accountId), + transactionId: transactionData.id, + command: 'undo', + postSavingsAccountBulkReversalTransactionsRequest: data as any + }) .subscribe(() => { this.reload(); }); diff --git a/src/app/savings/savings-account-view/transactions/edit-transaction/edit-transaction.component.ts b/src/app/savings/savings-account-view/transactions/edit-transaction/edit-transaction.component.ts index ed3ed98664..d785873afa 100644 --- a/src/app/savings/savings-account-view/transactions/edit-transaction/edit-transaction.component.ts +++ b/src/app/savings/savings-account-view/transactions/edit-transaction/edit-transaction.component.ts @@ -11,7 +11,7 @@ import { Router, ActivatedRoute, RouterLink } from '@angular/router'; import { Dates } from 'app/core/utils/dates'; /** Custom Services */ -import { SavingsService } from 'app/savings/savings.service'; +import { SavingsAccountTransactionsService } from '@fineract/client'; import { SettingsService } from 'app/settings/settings.service'; import { Currency } from 'app/shared/models/general.model'; import { InputAmountComponent } from '../../../../shared/input-amount/input-amount.component'; @@ -57,7 +57,7 @@ export class EditTransactionComponent implements OnInit { /** * Retrieves the Saving Account transaction template data from `resolve`. * @param {FormBuilder} formBuilder Form Builder. - * @param {SavingsService} savingsService Savings Service. + * @param {SavingsAccountTransactionsService} savingsAccountTransactionsService Savings Account Transactions Service. * @param {ActivatedRoute} route Activated Route. * @param {Dates} dateUtils Date Utils. * @param {Router} router Router for navigation. @@ -68,7 +68,7 @@ export class EditTransactionComponent implements OnInit { private route: ActivatedRoute, private router: Router, private dateUtils: Dates, - private savingsService: SavingsService, + private savingsAccountTransactionsService: SavingsAccountTransactionsService, private settingsService: SettingsService ) { this.route.data.subscribe((data: { savingsAccountTransactionTemplate: any }) => { @@ -147,8 +147,13 @@ export class EditTransactionComponent implements OnInit { dateFormat, locale }; - this.savingsService - .executeSavingsAccountTransactionsCommand(this.savingAccountId, 'modify', data, this.transactionTemplateData.id) + this.savingsAccountTransactionsService + .adjustTransaction1({ + savingsId: Number(this.savingAccountId), + transactionId: Number(this.transactionTemplateData.id), + postSavingsAccountBulkReversalTransactionsRequest: data, + command: 'modify' + }) .subscribe((res) => { this.router.navigate(['../'], { relativeTo: this.route }); }); diff --git a/src/app/savings/savings-account-view/transactions/view-transaction/savings-transaction-general-tab/savings-transaction-general-tab.component.ts b/src/app/savings/savings-account-view/transactions/view-transaction/savings-transaction-general-tab/savings-transaction-general-tab.component.ts index a428dbe9ab..eb3a58bba8 100644 --- a/src/app/savings/savings-account-view/transactions/view-transaction/savings-transaction-general-tab/savings-transaction-general-tab.component.ts +++ b/src/app/savings/savings-account-view/transactions/view-transaction/savings-transaction-general-tab/savings-transaction-general-tab.component.ts @@ -4,7 +4,7 @@ import { ActivatedRoute, Router, RouterLink } from '@angular/router'; import { Dates } from 'app/core/utils/dates'; import { ReleaseAmountDialogComponent } from 'app/savings/savings-account-view/custom-dialogs/release-amount-dialog/release-amount-dialog.component'; import { UndoTransactionDialogComponent } from 'app/savings/savings-account-view/custom-dialogs/undo-transaction-dialog/undo-transaction-dialog.component'; -import { SavingsService } from 'app/savings/savings.service'; +import { PostSavingsAccountBulkReversalTransactionsRequest, SavingsAccountTransactionsService } from '@fineract/client'; import { SettingsService } from 'app/settings/settings.service'; import { NgIf, NgClass, CurrencyPipe } from '@angular/common'; import { FaIconComponent } from '@fortawesome/angular-fontawesome'; @@ -31,7 +31,7 @@ export class SavingsTransactionGeneralTabComponent { transactionData: any; constructor( - private savingsService: SavingsService, + private savingsAccountTransactionsService: SavingsAccountTransactionsService, private route: ActivatedRoute, private dateUtils: Dates, private router: Router, @@ -55,12 +55,17 @@ export class SavingsTransactionGeneralTabComponent { const releaseAmountDialogRef = this.dialog.open(ReleaseAmountDialogComponent); releaseAmountDialogRef.afterClosed().subscribe((response: any) => { if (response.confirm) { - const data = {}; - this.savingsService - .executeSavingsAccountTransactionsCommand(this.accountId, 'releaseAmount', data, this.transactionData.id) - .subscribe(() => { - this.router.navigate(['../..'], { relativeTo: this.route }); - }); + const data = {} as PostSavingsAccountBulkReversalTransactionsRequest; + const requestParams = { + savingsId: parseInt(this.accountId), + transactionId: parseInt(this.transactionData.id), + postSavingsAccountBulkReversalTransactionsRequest: data, + command: 'releaseAmount' + }; + + this.savingsAccountTransactionsService.adjustTransaction1(requestParams).subscribe(() => { + this.router.navigate(['../..'], { relativeTo: this.route }); + }); } }); } @@ -79,12 +84,17 @@ export class SavingsTransactionGeneralTabComponent { transactionAmount: 0, dateFormat, locale + } as PostSavingsAccountBulkReversalTransactionsRequest; + const requestParams = { + savingsId: parseInt(this.accountId), + transactionId: parseInt(this.transactionData.id), + postSavingsAccountBulkReversalTransactionsRequest: data, + command: 'undo' }; - this.savingsService - .executeSavingsAccountTransactionsCommand(this.accountId, 'undo', data, this.transactionData.id) - .subscribe(() => { - this.router.navigate(['../..'], { relativeTo: this.route }); - }); + + this.savingsAccountTransactionsService.adjustTransaction1(requestParams).subscribe(() => { + this.router.navigate(['../..'], { relativeTo: this.route }); + }); } }); } diff --git a/src/app/savings/savings-account-view/view-charge/view-charge.component.ts b/src/app/savings/savings-account-view/view-charge/view-charge.component.ts index 823482a9be..29df1644cb 100644 --- a/src/app/savings/savings-account-view/view-charge/view-charge.component.ts +++ b/src/app/savings/savings-account-view/view-charge/view-charge.component.ts @@ -4,7 +4,7 @@ import { ActivatedRoute, Router, RouterLink } from '@angular/router'; import { MatDialog } from '@angular/material/dialog'; /** Custom Services */ -import { SavingsService } from 'app/savings/savings.service'; +import { SavingsChargesService } from '@fineract/client'; import { SettingsService } from 'app/settings/settings.service'; /** Custom Dialogs */ @@ -45,7 +45,7 @@ export class ViewChargeComponent { /** * Retrieves the Charge data from `resolve`. - * @param {SavingsService} savingsService Savings Service + * @param {SavingsChargesService} savingsChargesService Savings Charges Service. * @param {ActivatedRoute} route Activated Route. * @param {Router} router Router for navigation. * @param {MatDialog} dialog Dialog reference. @@ -53,7 +53,7 @@ export class ViewChargeComponent { * @param {SettingsService} settingsService Setting service */ constructor( - private savingsService: SavingsService, + private savingsChargesService: SavingsChargesService, private route: ActivatedRoute, private dateUtils: Dates, private router: Router, @@ -105,8 +105,13 @@ export class ViewChargeComponent { dateFormat, locale }; - this.savingsService - .executeSavingsAccountChargesCommand(this.chargeData.accountId, 'pay', dataObject, this.chargeData.id) + this.savingsChargesService + .payOrWaiveSavingsAccountCharge({ + savingsAccountId: this.chargeData.accountId, + savingsAccountChargeId: this.chargeData.id, + postSavingsAccountsSavingsAccountIdChargesSavingsAccountChargeIdRequest: dataObject, + command: 'pay' + }) .subscribe(() => { this.reload(); }); @@ -121,8 +126,13 @@ export class ViewChargeComponent { const waiveChargeDialogRef = this.dialog.open(WaiveChargeDialogComponent, { data: { id: this.chargeData.id } }); waiveChargeDialogRef.afterClosed().subscribe((response: any) => { if (response.confirm) { - this.savingsService - .executeSavingsAccountChargesCommand(this.chargeData.accountId, 'waive', {}, this.chargeData.id) + this.savingsChargesService + .payOrWaiveSavingsAccountCharge({ + savingsAccountId: this.chargeData.accountId, + savingsAccountChargeId: this.chargeData.id, + postSavingsAccountsSavingsAccountIdChargesSavingsAccountChargeIdRequest: {}, + command: 'waive' + }) .subscribe(() => { this.reload(); }); @@ -139,8 +149,13 @@ export class ViewChargeComponent { }); inactivateChargeDialogRef.afterClosed().subscribe((response: any) => { if (response.confirm) { - this.savingsService - .executeSavingsAccountChargesCommand(this.chargeData.accountId, 'inactivate', {}, this.chargeData.id) + this.savingsChargesService + .payOrWaiveSavingsAccountCharge({ + savingsAccountId: this.chargeData.accountId, + savingsAccountChargeId: this.chargeData.id, + postSavingsAccountsSavingsAccountIdChargesSavingsAccountChargeIdRequest: {}, + command: 'inactivate' + }) .subscribe(() => { this.reload(); }); @@ -177,8 +192,8 @@ export class ViewChargeComponent { dateFormat, locale }; - this.savingsService - .editSavingsAccountCharge(this.chargeData.accountId, dataObject, this.chargeData.id) + this.savingsChargesService + .updateSavingsAccountCharge(this.chargeData.accountId, dataObject, this.chargeData.id) .subscribe(() => { this.reload(); }); @@ -195,9 +210,11 @@ export class ViewChargeComponent { }); deleteChargeDialogRef.afterClosed().subscribe((response: any) => { if (response.delete) { - this.savingsService.deleteSavingsAccountCharge(this.chargeData.accountId, this.chargeData.id).subscribe(() => { - this.reload(); - }); + this.savingsChargesService + .deleteSavingsAccountCharge(this.chargeData.accountId, this.chargeData.id) + .subscribe(() => { + this.reload(); + }); } }); } diff --git a/src/app/shared/tabs/entity-documents-tab/entity-documents-tab.component.ts b/src/app/shared/tabs/entity-documents-tab/entity-documents-tab.component.ts index 6ac551e24c..3cf5cd961d 100644 --- a/src/app/shared/tabs/entity-documents-tab/entity-documents-tab.component.ts +++ b/src/app/shared/tabs/entity-documents-tab/entity-documents-tab.component.ts @@ -18,7 +18,6 @@ import { import { UploadDocumentDialogComponent } from 'app/clients/clients-view/custom-dialogs/upload-document-dialog/upload-document-dialog.component'; import { ClientService } from '@fineract/client'; import { LoansService } from '@fineract/client'; -import { SavingsService } from 'app/savings/savings.service'; import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component'; import { Observable } from 'rxjs'; import { FaIconComponent } from '@fortawesome/angular-fontawesome'; @@ -80,13 +79,11 @@ export class EntityDocumentsTabComponent implements OnInit { /** * * @param {MatDialog} dialog Dialog for Inputs. - * @param {SavingsService} savingsService Savings Account services. * @param {LoansService} loansService Loan Account services. * @param {ClientsService} clientsService Client services. */ constructor( public dialog: MatDialog, - private savingsService: SavingsService, private loansService: LoansService, private clientsService: ClientService ) {} diff --git a/src/app/shared/tabs/entity-notes-tab/entity-notes-tab.component.ts b/src/app/shared/tabs/entity-notes-tab/entity-notes-tab.component.ts index e9b0e8b41a..7aa9da0780 100644 --- a/src/app/shared/tabs/entity-notes-tab/entity-notes-tab.component.ts +++ b/src/app/shared/tabs/entity-notes-tab/entity-notes-tab.component.ts @@ -2,7 +2,6 @@ import { Component, Input, OnInit, ViewChild } from '@angular/core'; import { UntypedFormBuilder, UntypedFormGroup, Validators, ReactiveFormsModule } from '@angular/forms'; import { MatDialog } from '@angular/material/dialog'; import { LoansService, GroupsService, ClientService } from '@fineract/client'; -import { SavingsService } from 'app/savings/savings.service'; import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component'; import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.component'; import { CdkTextareaAutosize } from '@angular/cdk/text-field'; @@ -35,7 +34,6 @@ export class EntityNotesTabComponent implements OnInit { constructor( private formBuilder: UntypedFormBuilder, - private savingsService: SavingsService, private loansService: LoansService, private clientsService: ClientService, private groupsService: GroupsService,