Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/app/customApis.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,18 @@ export class OrganizationService {
});
}
}

@Injectable({
providedIn: 'root'
})
export class SharesService {
constructor(private http: HttpClient) {}

/**
* @param {string} accountId shares account Id
* @returns {Observable<any>}
*/
deleteSharesAccount(accountId: string): Observable<any> {
return this.http.delete(`/accounts/share/${accountId}`);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ import { ActivatedRouteSnapshot } from '@angular/router';
import { Observable } from 'rxjs';

/** Custom Services */
import { SharesService } from '../shares.service';
import { ShareAccountService } from '@fineract/client';

/**
* Shares Account Actions data resolver.
*/
@Injectable()
export class ShareAccountActionsResolver {
/**
* @param {sharesService} SharesService Shares service.
* @param {ShareAccountService} ShareAccountService Shares account service.
*/
constructor(private sharesService: SharesService) {}
constructor(private shareAccountService: ShareAccountService) {}

/**
* Returns the Shares account actions data.
Expand All @@ -31,7 +31,10 @@ export class ShareAccountActionsResolver {
case 'Redeem Shares':
case 'Approve Additional Shares':
case 'Reject Additional Shares':
return this.sharesService.getSharesAccountData(shareAccountId, true);
return this.shareAccountService.retrieveAccount({
accountId: Number(shareAccountId),
type: 'full'
});
default:
return undefined;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ import { ActivatedRouteSnapshot } from '@angular/router';
import { Observable } from 'rxjs';

/** Custom Services */
import { SharesService } from '../shares.service';
import { ShareAccountService } from '@fineract/client';

/**
* Shares Account data and template resolver.
*/
@Injectable()
export class SharesAccountAndTemplateResolver {
/**
* @param {SharesService} SharesService Shares service.
* @param {ShareAccountService} ShareAccountService Share account service.
*/
constructor(private sharesService: SharesService) {}
constructor(private shareAccountService: ShareAccountService) {}

/**
* Returns the Shares Account data and template.
Expand All @@ -25,6 +25,9 @@ export class SharesAccountAndTemplateResolver {
*/
resolve(route: ActivatedRouteSnapshot): Observable<any> {
const shareAccountId = route.paramMap.get('shareAccountId');
return this.sharesService.getSharesAccountData(shareAccountId, true);
return this.shareAccountService.retrieveAccount({
accountId: Number(shareAccountId),
type: 'true'
});
}
}
11 changes: 7 additions & 4 deletions src/app/shares/common-resolvers/share-account-view.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ import { ActivatedRouteSnapshot } from '@angular/router';
import { Observable } from 'rxjs';

/** Custom Services */
import { SharesService } from '../shares.service';
import { ShareAccountService } from '@fineract/client';

/**
* Shares Account data resolver.
*/
@Injectable()
export class SharesAccountViewResolver {
/**
* @param {SharesService} SharesService Shares service.
* @param {ShareAccountService} ShareAccountService Shares account service.
*/
constructor(private sharesService: SharesService) {}
constructor(private shareAccountService: ShareAccountService) {}

/**
* Returns the Shares Account data.
Expand All @@ -25,6 +25,9 @@ export class SharesAccountViewResolver {
*/
resolve(route: ActivatedRouteSnapshot): Observable<any> {
const shareAccountId = route.paramMap.get('shareAccountId') || route.parent.paramMap.get('shareAccountId');
return this.sharesService.getSharesAccountData(shareAccountId, false);
return this.shareAccountService.retrieveAccount({
accountId: Number(shareAccountId),
type: 'default'
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ import { ActivatedRouteSnapshot } from '@angular/router';
import { Observable } from 'rxjs';

/** Custom Services */
import { SharesService } from '../shares.service';
import { ShareAccountService } from '@fineract/client';

/**
* Shares Account Template resolver.
*/
@Injectable()
export class SharesAccountTemplateResolver {
/**
* @param {SharesService} SharesService Shares service.
* @param {ShareAccountService} ShareAccountService Shares account service.
*/
constructor(private sharesService: SharesService) {}
constructor(private shareAccountService: ShareAccountService) {}

/**
* Returns the Shares Account Template.
Expand All @@ -25,6 +25,6 @@ export class SharesAccountTemplateResolver {
*/
resolve(route: ActivatedRouteSnapshot): Observable<any> {
const clientId = route.parent.parent.paramMap.get('clientId');
return this.sharesService.getSharesAccountTemplate(clientId);
return this.shareAccountService.template7({ type: 'client', clientId: clientId ? +clientId : undefined });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { SharesAccountTermsStepComponent } from '../shares-account-stepper/share
import { SharesAccountChargesStepComponent } from '../shares-account-stepper/shares-account-charges-step/shares-account-charges-step.component';

/** Custom Services */
import { SharesService } from '../shares.service';
import { ShareAccountService } 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';
Expand Down Expand Up @@ -56,14 +56,14 @@ export class CreateSharesAccountComponent {
* @param {ActivatedRoute} route Activated Route
* @param {Router} router Router
* @param {Dates} dateUtils Date Utils
* @param {SharesService} sharesService Shares Service
* @param {ShareAccountService} ShareAccountService Shares Account Service
* @param {SettingsService} settingsService Settings Service
*/
constructor(
private route: ActivatedRoute,
private router: Router,
private dateUtils: Dates,
private sharesService: SharesService,
private shareAccountService: ShareAccountService,
private settingsService: SettingsService
) {
this.route.data.subscribe((data: { sharesAccountTemplate: any }) => {
Expand Down Expand Up @@ -121,14 +121,15 @@ export class CreateSharesAccountComponent {
const sharesAccount = {
...this.sharesAccount,
clientId: this.sharesAccountTemplate.clientId,
charges: this.sharesAccount.charges.map((charge: any) => ({ chargeId: charge.id, amount: charge.amount })),
charges: this.sharesAccount.charges?.map((charge: any) => ({ chargeId: charge.id, amount: charge.amount })) || [],
applicationDate: this.dateUtils.formatDate(this.sharesAccount.applicationDate, dateFormat),
submittedDate: this.dateUtils.formatDate(this.sharesAccount.submittedDate, dateFormat),
unitPrice: this.sharesAccountTermsForm.get('unitPrice').value,
dateFormat,
locale
locale,
type: this.sharesAccount.type || 'client'
};
this.sharesService.createSharesAccount(sharesAccount).subscribe((response: any) => {
this.shareAccountService.createAccount(sharesAccount).subscribe((response: any) => {
this.router.navigate(
[
'../',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { SharesAccountTermsStepComponent } from '../shares-account-stepper/share
import { SharesAccountChargesStepComponent } from '../shares-account-stepper/shares-account-charges-step/shares-account-charges-step.component';

/** Custom Services */
import { SharesService } from '../shares.service';
import { ShareAccountService } 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';
Expand Down Expand Up @@ -56,14 +56,14 @@ export class EditSharesAccountComponent {
* @param {ActivatedRoute} route Activated Route
* @param {Router} router Router
* @param {Dates} dateUtils Date Utils
* @param {SharesService} sharesService Shares Service
* @param {ShareAccountService} shareAccountService Shares Account Service
* @param {SettingsService} settingsService Settings Service
*/
constructor(
private route: ActivatedRoute,
private router: Router,
private dateUtils: Dates,
private sharesService: SharesService,
private shareAccountService: ShareAccountService,
private settingsService: SettingsService
) {
this.route.data.subscribe((data: { sharesAccountAndTemplate: any }) => {
Expand Down Expand Up @@ -134,8 +134,8 @@ export class EditSharesAccountComponent {
dateFormat,
locale
};
this.sharesService
.updateSharesAccount(this.sharesAccountAndTemplate.id, sharesAccount)
this.shareAccountService
.updateAccount(this.sharesAccountAndTemplate.id, sharesAccount)
.subscribe((response: any) => {
this.router.navigate(['../'], { relativeTo: this.route });
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { UntypedFormGroup, UntypedFormBuilder, Validators, ReactiveFormsModule }
import { ActivatedRoute, Router, RouterLink } from '@angular/router';

/** Custom Services */
import { SharesService } from 'app/shares/shares.service';
import { ShareAccountService } 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';
Expand Down Expand Up @@ -32,15 +32,15 @@ export class ActivateSharesAccountComponent implements OnInit {

/**
* @param {FormBuilder} formBuilder Form Builder
* @param {SharesService} sharesService Shares Service
* @param {ShareAccountService} shareAccountService Shares Account Service
* @param {Dates} dateUtils Date Utils
* @param {ActivatedRoute} route Activated Route
* @param {Router} router Router
* @param {SettingsService} settingsService Settings Service.
*/
constructor(
private formBuilder: UntypedFormBuilder,
private sharesService: SharesService,
private shareAccountService: ShareAccountService,
private dateUtils: Dates,
private route: ActivatedRoute,
private router: Router,
Expand Down Expand Up @@ -86,7 +86,13 @@ export class ActivateSharesAccountComponent implements OnInit {
dateFormat,
locale
};
this.sharesService.executeSharesAccountCommand(this.accountId, 'activate', data).subscribe(() => {
const params = {
type: 'shares',
accountId: this.accountId,
postAccountsTypeAccountIdRequest: data,
command: 'activate'
};
this.shareAccountService.handleCommands2(params).subscribe(() => {
this.router.navigate(['../../'], { relativeTo: this.route });
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { UntypedFormGroup, UntypedFormBuilder, Validators, ReactiveFormsModule }
import { ActivatedRoute, Router, RouterLink } from '@angular/router';

/** Custom Services */
import { SharesService } from 'app/shares/shares.service';
import { ShareAccountService } 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';
Expand Down Expand Up @@ -35,15 +35,15 @@ export class ApplySharesComponent implements OnInit {

/**
* @param {FormBuilder} formBuilder Form Builder
* @param {SharesService} sharesService Shares Service
* @param {ShareAccountService} shareAccountService Shares Account Service
* @param {Dates} dateUtils Date Utils
* @param {ActivatedRoute} route Activated Route
* @param {Router} router Router
* @param {SettingsService} settingsService Settings Service
*/
constructor(
private formBuilder: UntypedFormBuilder,
private sharesService: SharesService,
private shareAccountService: ShareAccountService,
private dateUtils: Dates,
private route: ActivatedRoute,
private router: Router,
Expand Down Expand Up @@ -101,7 +101,13 @@ export class ApplySharesComponent implements OnInit {
dateFormat,
locale
};
this.sharesService.executeSharesAccountCommand(this.accountId, 'applyadditionalshares', data).subscribe(() => {
const params = {
type: 'shares',
accountId: this.accountId,
postAccountsTypeAccountIdRequest: data,
command: 'applyadditionalshares'
};
this.shareAccountService.handleCommands2(params).subscribe(() => {
this.router.navigate(['../../'], { relativeTo: this.route });
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { UntypedFormGroup, UntypedFormBuilder, Validators, ReactiveFormsModule }
import { ActivatedRoute, Router, RouterLink } from '@angular/router';

/** Custom Services */
import { SharesService } from 'app/shares/shares.service';
import { ShareAccountService } from '@fineract/client';
import { SettingsService } from 'app/settings/settings.service';
import { Dates } from 'app/core/utils/dates';
import { CdkTextareaAutosize } from '@angular/cdk/text-field';
Expand Down Expand Up @@ -34,15 +34,15 @@ export class ApproveSharesAccountComponent implements OnInit {

/**
* @param {FormBuilder} formBuilder Form Builder
* @param {SharesService} sharesService Shares Service
* @param {ShareAccountService} ShareAccountService Shares Account Service.
* @param {Dates} dateUtils Date Utils
* @param {ActivatedRoute} route Activated Route
* @param {Router} router Router
* @param {SettingsService} settingsService Settings Service.
*/
constructor(
private formBuilder: UntypedFormBuilder,
private sharesService: SharesService,
private shareAccountService: ShareAccountService,
private dateUtils: Dates,
private route: ActivatedRoute,
private router: Router,
Expand Down Expand Up @@ -89,7 +89,13 @@ export class ApproveSharesAccountComponent implements OnInit {
dateFormat,
locale
};
this.sharesService.executeSharesAccountCommand(this.accountId, 'approve', data).subscribe(() => {
const params = {
type: 'shares',
accountId: this.accountId,
postAccountsTypeAccountIdRequest: data,
command: 'approve'
};
this.shareAccountService.handleCommands2(params).subscribe(() => {
this.router.navigate(['../../'], { relativeTo: this.route });
});
}
Expand Down
Loading