Skip to content

Commit f087bcc

Browse files
committed
WEB-340 replace custom api of saving.service.ts
1 parent 61f63cd commit f087bcc

File tree

54 files changed

+720
-348
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+720
-348
lines changed

src/app/customApis.service.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,3 +231,20 @@ export class OrganizationService {
231231
});
232232
}
233233
}
234+
/**
235+
* Savings Service
236+
*/
237+
@Injectable({
238+
providedIn: 'root'
239+
})
240+
export class SavingsService {
241+
constructor(private http: HttpClient) {}
242+
243+
/**
244+
* @param {any} savingsAccount Savings Account
245+
* @returns {Observable<any>}
246+
*/
247+
createSavingsAccount(savingsAccount: any): Observable<any> {
248+
return this.http.post('/savingsaccounts', savingsAccount);
249+
}
250+
}

src/app/deposits/fixed-deposits/common-resolvers/fixed-deposit-account-actions.resolver.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { ActivatedRouteSnapshot } from '@angular/router';
66
import { Observable } from 'rxjs';
77

88
/** Custom Services */
9-
import { SavingsService } from 'app/savings/savings.service';
9+
import { SavingsChargesService } from '@fineract/client';
1010
import { FixedDepositsService } from '../fixed-deposits.service';
1111

1212
/**
@@ -15,11 +15,11 @@ import { FixedDepositsService } from '../fixed-deposits.service';
1515
@Injectable()
1616
export class FixedDepositsAccountActionsResolver {
1717
/**
18-
* @param {SavingsService} SavingsService Savings service.
18+
* @param {SavingsChargesService} SavingsChargesService Savings charges service.
1919
* @param {FixedDepositsService} fixedDepositsService Fixed Deposits Service.
2020
*/
2121
constructor(
22-
private savingsService: SavingsService,
22+
private savingsChargesService: SavingsChargesService,
2323
private fixedDepositsService: FixedDepositsService
2424
) {}
2525

@@ -34,7 +34,7 @@ export class FixedDepositsAccountActionsResolver {
3434
route.paramMap.get('fixedDepositAccountId') || route.parent.parent.paramMap.get('fixedDepositAccountId');
3535
switch (actionName) {
3636
case 'Add Charge':
37-
return this.savingsService.getSavingsChargeTemplateResource(fixedDepositAccountId);
37+
return this.savingsChargesService.retrieveTemplate18({ savingsAccountId: Number(fixedDepositAccountId) });
3838
case 'Close':
3939
return this.fixedDepositsService.getFixedDepositsAccountClosureTemplate(fixedDepositAccountId);
4040
case 'Withdrawal':

src/app/deposits/fixed-deposits/fixed-deposit-account-view/charges-tab/charges-tab.component.ts

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
} from '@angular/material/table';
1818

1919
/** Custom Services */
20-
import { SavingsService } from 'app/savings/savings.service';
20+
import { SavingsAccountService } from '@fineract/client';
2121
import { SettingsService } from 'app/settings/settings.service';
2222

2323
/** Custom Dialogs */
@@ -90,15 +90,15 @@ export class ChargesTabComponent implements OnInit {
9090

9191
/**
9292
* Retrieves the Fixed Deposits account data from `resolve`.
93-
* @param {SavingsService} savingsService Savings Service
93+
* @param {SavingsAccountService} savingsAccountService Savings Account Service
9494
* @param {ActivatedRoute} route Activated Route.
9595
* @param {Router} router Router for navigation.
9696
* @param {MatDialog} dialog Dialog reference.
9797
* @param {Dates} dateUtils Date Utils.
9898
* @param {SettingsService} settingsService Settings Service.
9999
*/
100100
constructor(
101-
private savingsService: SavingsService,
101+
private savingsAccountService: SavingsAccountService,
102102
private route: ActivatedRoute,
103103
private dateUtils: Dates,
104104
private router: Router,
@@ -169,8 +169,12 @@ export class ChargesTabComponent implements OnInit {
169169
dateFormat,
170170
locale
171171
};
172-
this.savingsService
173-
.executeSavingsAccountChargesCommand(this.fixedDepositsAccountData.id, 'paycharge', dataObject, chargeId)
172+
this.savingsAccountService
173+
.handleCommands6({
174+
accountId: this.fixedDepositsAccountData.id,
175+
postSavingsAccountsAccountIdRequest: dataObject,
176+
command: 'paycharge'
177+
})
174178
.subscribe(() => {
175179
this.reload();
176180
});
@@ -186,8 +190,18 @@ export class ChargesTabComponent implements OnInit {
186190
const waiveChargeDialogRef = this.dialog.open(WaiveChargeDialogComponent, { data: { id: chargeId } });
187191
waiveChargeDialogRef.afterClosed().subscribe((response: any) => {
188192
if (response.confirm) {
189-
this.savingsService
190-
.executeSavingsAccountChargesCommand(this.fixedDepositsAccountData.id, 'waive', {}, chargeId)
193+
const locale = this.settingsService.language.code;
194+
const dateFormat = this.settingsService.dateFormat;
195+
const dataObject = {
196+
dateFormat,
197+
locale
198+
};
199+
this.savingsAccountService
200+
.handleCommands6({
201+
accountId: this.fixedDepositsAccountData.id,
202+
postSavingsAccountsAccountIdRequest: dataObject,
203+
command: 'waive'
204+
})
191205
.subscribe(() => {
192206
this.reload();
193207
});
@@ -203,8 +217,18 @@ export class ChargesTabComponent implements OnInit {
203217
const inactivateChargeDialogRef = this.dialog.open(InactivateChargeDialogComponent, { data: { id: chargeId } });
204218
inactivateChargeDialogRef.afterClosed().subscribe((response: any) => {
205219
if (response.confirm) {
206-
this.savingsService
207-
.executeSavingsAccountChargesCommand(this.fixedDepositsAccountData.id, 'inactivate', {}, chargeId)
220+
const locale = this.settingsService.language.code;
221+
const dateFormat = this.settingsService.dateFormat;
222+
const dataObject = {
223+
dateFormat,
224+
locale
225+
};
226+
this.savingsAccountService
227+
.handleCommands6({
228+
accountId: this.fixedDepositsAccountData.id,
229+
postSavingsAccountsAccountIdRequest: dataObject,
230+
command: 'inactivate'
231+
})
208232
.subscribe(() => {
209233
this.reload();
210234
});
@@ -242,8 +266,8 @@ export class ChargesTabComponent implements OnInit {
242266
dateFormat,
243267
locale
244268
};
245-
this.savingsService
246-
.editSavingsAccountCharge(this.fixedDepositsAccountData.id, dataObject, charge.id)
269+
this.savingsAccountService
270+
.handleCommands6(this.fixedDepositsAccountData.id, dataObject, charge.id)
247271
.subscribe(() => {
248272
this.reload();
249273
});
@@ -261,7 +285,7 @@ export class ChargesTabComponent implements OnInit {
261285
});
262286
deleteChargeDialogRef.afterClosed().subscribe((response: any) => {
263287
if (response.delete) {
264-
this.savingsService.deleteSavingsAccountCharge(this.fixedDepositsAccountData.id, chargeId).subscribe(() => {
288+
this.savingsAccountService.delete18(this.fixedDepositsAccountData.id, chargeId).subscribe(() => {
265289
this.reload();
266290
});
267291
}

src/app/deposits/fixed-deposits/fixed-deposit-account-view/fixed-deposit-account-view.component.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { FixedDepositsButtonsConfiguration } from './fixed-deposits-buttons.conf
1414

1515
/** Custom Services */
1616
import { FixedDepositsService } from '../fixed-deposits.service';
17-
import { SavingsService } from 'app/savings/savings.service';
17+
import { SavingsAccountService } from '@fineract/client';
1818
import { Currency } from 'app/shared/models/general.model';
1919
import {
2020
MatCard,
@@ -83,14 +83,14 @@ export class FixedDepositAccountViewComponent implements OnInit {
8383
* @param {ActivatedRoute} route Activated Route
8484
* @param {Router} router Router
8585
* @param {FixedDepositsService} fixedDepositsService Fixed Deposits Service
86-
* @param {SavingsService} savingsService Savings Service
86+
* @param {SavingsAccountService} savingsAccountService Savings Account Service
8787
* @param {MatDialog} dialog Mat Dialog
8888
*/
8989
constructor(
9090
private route: ActivatedRoute,
9191
private router: Router,
9292
private fixedDepositsService: FixedDepositsService,
93-
private savingsService: SavingsService,
93+
private savingsAccountService: SavingsAccountService,
9494
public dialog: MatDialog
9595
) {
9696
this.route.data.subscribe((data: { fixedDepositsAccountData: any; savingsDatatables: any }) => {
@@ -240,9 +240,13 @@ export class FixedDepositAccountViewComponent implements OnInit {
240240
});
241241
deleteSavingsAccountDialogRef.afterClosed().subscribe((response: any) => {
242242
if (response.confirm) {
243-
this.savingsService
244-
.executeSavingsAccountUpdateCommand(this.fixedDepositsAccountData.id, 'updateWithHoldTax', {
245-
withHoldTax: true
243+
this.savingsAccountService
244+
.update20({
245+
accountId: this.fixedDepositsAccountData.id,
246+
command: 'updateWithHoldTax',
247+
putSavingsAccountsAccountIdRequest: {
248+
withHoldTax: true
249+
} as any
246250
})
247251
.subscribe(() => {
248252
this.reload();
@@ -261,9 +265,13 @@ export class FixedDepositAccountViewComponent implements OnInit {
261265
});
262266
disableWithHoldTaxDialogRef.afterClosed().subscribe((response: any) => {
263267
if (response.confirm) {
264-
this.savingsService
265-
.executeSavingsAccountUpdateCommand(this.fixedDepositsAccountData.id, 'updateWithHoldTax', {
266-
withHoldTax: false
268+
this.savingsAccountService
269+
.update20({
270+
accountId: this.fixedDepositsAccountData.id,
271+
command: 'updateWithHoldTax',
272+
putSavingsAccountsAccountIdRequest: {
273+
withHoldTax: false
274+
} as any
267275
})
268276
.subscribe(() => {
269277
this.reload();

src/app/deposits/fixed-deposits/fixed-deposit-account-view/view-transaction/view-transaction.component.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { ActivatedRoute, Router, RouterLink } from '@angular/router';
44
import { MatDialog } from '@angular/material/dialog';
55
import { UndoTransactionDialogComponent } from 'app/savings/savings-account-view/custom-dialogs/undo-transaction-dialog/undo-transaction-dialog.component';
66
import { Dates } from 'app/core/utils/dates';
7-
import { SavingsService } from 'app/savings/savings.service';
7+
import { SavingsAccountTransactionsService } from '@fineract/client';
88
import { SettingsService } from 'app/settings/settings.service';
99
import { NgIf, NgClass, CurrencyPipe } from '@angular/common';
1010
import { FaIconComponent } from '@fortawesome/angular-fontawesome';
@@ -37,7 +37,7 @@ export class ViewTransactionComponent {
3737
/**
3838
*/
3939
constructor(
40-
private savingsService: SavingsService,
40+
private savingsAccountTransactionsService: SavingsAccountTransactionsService,
4141
private route: ActivatedRoute,
4242
private dateUtils: Dates,
4343
private router: Router,
@@ -76,8 +76,13 @@ export class ViewTransactionComponent {
7676
dateFormat,
7777
locale
7878
};
79-
this.savingsService
80-
.executeSavingsAccountTransactionsCommand(this.accountId, 'undo', data, this.transactionData.id)
79+
this.savingsAccountTransactionsService
80+
.adjustTransaction1({
81+
savingsId: Number(this.accountId),
82+
transactionId: this.transactionData.id,
83+
command: 'undo',
84+
postSavingsAccountBulkReversalTransactionsRequest: data as any
85+
})
8186
.subscribe(() => {
8287
this.router.navigate(['../'], { relativeTo: this.route });
8388
});

src/app/deposits/fixed-deposits/fixed-deposits-account-actions/activate-fixed-deposits-account/activate-fixed-deposits-account.component.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { ActivatedRoute, Router, RouterLink } from '@angular/router';
55
import { Dates } from 'app/core/utils/dates';
66

77
/** Custom Services */
8-
import { SavingsService } from 'app/savings/savings.service';
8+
import { SavingsAccountService } from '@fineract/client';
99
import { SettingsService } from 'app/settings/settings.service';
1010
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
1111

@@ -33,15 +33,15 @@ export class ActivateFixedDepositsAccountComponent implements OnInit {
3333
/**
3434
* Fixed deposits endpoint is not supported so using Savings endpoint.
3535
* @param {FormBuilder} formBuilder Form Builder
36-
* @param {SavingsService} savingsService Savings Service
36+
* @param {SavingsAccountService} savingsAccountService Savings Account Service
3737
* @param {Dates} dateUtils Date Utils
3838
* @param {ActivatedRoute} route Activated Route
3939
* @param {Router} router Router
4040
* @param {SettingsService} settingsService Settings Service
4141
*/
4242
constructor(
4343
private formBuilder: UntypedFormBuilder,
44-
private savingsService: SavingsService,
44+
private savingsAccountService: SavingsAccountService,
4545
private dateUtils: Dates,
4646
private route: ActivatedRoute,
4747
private router: Router,
@@ -87,8 +87,14 @@ export class ActivateFixedDepositsAccountComponent implements OnInit {
8787
dateFormat,
8888
locale
8989
};
90-
this.savingsService.executeSavingsAccountCommand(this.accountId, 'activate', data).subscribe(() => {
91-
this.router.navigate(['../../'], { relativeTo: this.route });
92-
});
90+
this.savingsAccountService
91+
.handleCommands6({
92+
accountId: this.accountId,
93+
command: 'activate',
94+
postSavingsAccountsAccountIdRequest: data
95+
})
96+
.subscribe(() => {
97+
this.router.navigate(['../../'], { relativeTo: this.route });
98+
});
9399
}
94100
}

src/app/deposits/fixed-deposits/fixed-deposits-account-actions/add-charge-fixed-deposits-account/add-charge-fixed-deposits-account.component.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { Router, ActivatedRoute, RouterLink } from '@angular/router';
1111
import { Dates } from 'app/core/utils/dates';
1212

1313
/** Custom Services */
14-
import { SavingsService } from 'app/savings/savings.service';
14+
import { ChargesService, SavingsAccountService } from '@fineract/client';
1515
import { SettingsService } from 'app/settings/settings.service';
1616
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
1717

@@ -47,15 +47,17 @@ export class AddChargeFixedDepositsAccountComponent implements OnInit {
4747
* @param {ActivatedRoute} route Activated Route
4848
* @param {Router} router Router
4949
* @param {Dates} dateUtils Date Utils
50-
* @param {SavingsService} savingsService Savings Service
50+
* @param {ChargesService} chargesService Charges Service
51+
* @param {SavingsAccountService} savingsAccountService Savings Account Service
5152
* @param {SettingsService} settingsService Settings Service
5253
*/
5354
constructor(
5455
private formBuilder: UntypedFormBuilder,
5556
private route: ActivatedRoute,
5657
private router: Router,
5758
private dateUtils: Dates,
58-
private savingsService: SavingsService,
59+
private chargesService: ChargesService,
60+
private savingsAccountService: SavingsAccountService,
5961
private settingsService: SettingsService
6062
) {
6163
this.route.data.subscribe((data: { fixedDepositsAccountActionData: any }) => {
@@ -75,7 +77,7 @@ export class AddChargeFixedDepositsAccountComponent implements OnInit {
7577

7678
buildDependencies() {
7779
this.fixedDepositsChargeForm.controls.chargeId.valueChanges.subscribe((chargeId) => {
78-
this.savingsService.getChargeTemplate(chargeId).subscribe((data: any) => {
80+
this.chargesService.retrieveCharge(chargeId).subscribe((data: any) => {
7981
this.chargeDetails = data;
8082
const chargeTimeType = data.chargeTimeType.id;
8183
if (data.chargeTimeType.value === 'Withdrawal Fee' || data.chargeTimeType.value === 'Saving No Activity Fee') {
@@ -155,8 +157,14 @@ export class AddChargeFixedDepositsAccountComponent implements OnInit {
155157
}
156158
}
157159
}
158-
this.savingsService.createSavingsCharge(this.fixedDepositAccountId, 'charges', savingsCharge).subscribe(() => {
159-
this.router.navigate(['../../'], { relativeTo: this.route });
160-
});
160+
this.savingsAccountService
161+
.handleCommands6({
162+
accountId: Number(this.fixedDepositAccountId),
163+
command: 'charges',
164+
postSavingsAccountsAccountIdRequest: savingsCharge
165+
})
166+
.subscribe(() => {
167+
this.router.navigate(['../../'], { relativeTo: this.route });
168+
});
161169
}
162170
}

src/app/deposits/fixed-deposits/fixed-deposits-account-actions/undo-approval-fixed-deposits-account/undo-approval-fixed-deposits-account.component.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { UntypedFormGroup, UntypedFormBuilder, ReactiveFormsModule } from '@angu
44
import { ActivatedRoute, Router, RouterLink } from '@angular/router';
55

66
/** Custom Services */
7-
import { SavingsService } from 'app/savings/savings.service';
7+
import { SavingsAccountService } from '@fineract/client';
88
import { FixedDepositsService } from '../../fixed-deposits.service';
99
import { CdkTextareaAutosize } from '@angular/cdk/text-field';
1010
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
@@ -33,13 +33,13 @@ export class UndoApprovalFixedDepositsAccountComponent implements OnInit {
3333
/**
3434
* Fixed deposits endpoint is not supported so using Savings endpoint.
3535
* @param {FormBuilder} formBuilder Form Builder
36-
* @param {SavingsService} savingsService Savings Service
36+
* @param {SavingsAccountService } savingsAccountService Savings Account Service
3737
* @param {ActivatedRoute} route Activated Route
3838
* @param {Router} router Router
3939
*/
4040
constructor(
4141
private formBuilder: UntypedFormBuilder,
42-
private savingsService: SavingsService,
42+
private savingsAccountService: SavingsAccountService,
4343
private fixedDepositsService: FixedDepositsService,
4444
private route: ActivatedRoute,
4545
private router: Router
@@ -83,9 +83,15 @@ export class UndoApprovalFixedDepositsAccountComponent implements OnInit {
8383
this.router.navigate(['../../'], { relativeTo: this.route });
8484
});
8585
} else {
86-
this.savingsService.executeSavingsAccountCommand(this.accountId, this.undoCommand, data).subscribe(() => {
87-
this.router.navigate(['../../'], { relativeTo: this.route });
88-
});
86+
this.savingsAccountService
87+
.handleCommands6({
88+
accountId: this.accountId,
89+
command: this.undoCommand,
90+
postSavingsAccountsAccountIdRequest: data
91+
})
92+
.subscribe(() => {
93+
this.router.navigate(['../../'], { relativeTo: this.route });
94+
});
8995
}
9096
}
9197
}

0 commit comments

Comments
 (0)