build: Use prettier for typescript

Stop ignoring .ts files in prettier and fix existing issues.
This commit is contained in:
Ralph Hopman
2025-01-15 11:59:30 +00:00
committed by Adam Saghy
parent 9d6cf1514a
commit cac1d11ad7
1812 changed files with 22516 additions and 16862 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
/dist /dist
/node_modules /node_modules
**/.git **/.git
*.ts src/environments/.env.ts
+1 -1
View File
@@ -16,7 +16,7 @@ The latest code is continuously deployed at https://openmf.github.io/web-app/ wh
[`nodeJs`](https://nodejs.org/en/download/) [`nodeJs`](https://nodejs.org/en/download/)
3. Install [angular-cli](https://github.com/angular/angular-cli) globally. 2. Install [angular-cli](https://github.com/angular/angular-cli) globally.
``` ```
npm install -g @angular/cli@16.0.2 npm install -g @angular/cli@16.0.2
+10 -10
View File
@@ -1,24 +1,24 @@
import { defineConfig } from "cypress"; import { defineConfig } from 'cypress';
export default defineConfig({ export default defineConfig({
videosFolder: "cypress/videos", videosFolder: 'cypress/videos',
screenshotsFolder: "cypress/screenshots", screenshotsFolder: 'cypress/screenshots',
fixturesFolder: "cypress/fixtures", fixturesFolder: 'cypress/fixtures',
e2e: { e2e: {
// We've imported your old cypress plugins here. // We've imported your old cypress plugins here.
// You may want to clean this up later by importing these. // You may want to clean this up later by importing these.
setupNodeEvents(on, config) { setupNodeEvents(on, config) {
return require("./cypress/plugins/index.ts")(on, config); return require('./cypress/plugins/index.ts')(on, config);
}, },
baseUrl: "http://localhost:4200", baseUrl: 'http://localhost:4200'
}, },
component: { component: {
devServer: { devServer: {
framework: "angular", framework: 'angular',
bundler: "webpack", bundler: 'webpack'
},
specPattern: "**/*.cy.ts",
}, },
specPattern: '**/*.cy.ts'
}
}); });
-1
View File
@@ -24,4 +24,3 @@ services:
- MIFOS_SUPPORTED_LANGUAGES=cs-CS,de-DE,en-US,es-MX,fr-FR,it-IT,ko-KO,lt-LT,lv-LV,ne-NE,pt-PT,sw-SW - MIFOS_SUPPORTED_LANGUAGES=cs-CS,de-DE,en-US,es-MX,fr-FR,it-IT,ko-KO,lt-LT,lv-LV,ne-NE,pt-PT,sw-SW
- MIFOS_SESSION_IDLE_TIMEOUT=300000 - MIFOS_SESSION_IDLE_TIMEOUT=300000
- MIFOS_OAUTH_SERVER_ENABLED=false - MIFOS_OAUTH_SERVER_ENABLED=false
-1
View File
@@ -20,5 +20,4 @@ describe('app', () => {
it('should login into the app', () => { it('should login into the app', () => {
page.validLogin(); page.validLogin();
}); });
}); });
-2
View File
@@ -5,7 +5,6 @@ import { browser, element, by } from 'protractor';
* Login Page e2e page object * Login Page e2e page object
*/ */
export class LoginPage { export class LoginPage {
/** username field */ /** username field */
usernameField = element(by.css('input[formControlName="username"]')); usernameField = element(by.css('input[formControlName="username"]'));
/** password field */ /** password field */
@@ -37,5 +36,4 @@ export class LoginPage {
this.passwordField.sendKeys('123'); this.passwordField.sendKeys('123');
this.loginButton.click(); this.loginButton.click();
} }
} }
@@ -26,7 +26,11 @@ const routes: Routes = [
children: [ children: [
{ {
path: 'create-standing-instructions', path: 'create-standing-instructions',
data: { title: 'Create Standing Instructions', breadcrumb: 'Create Standing Instructions', routeParamBreadcrumb: 'Create Standing Instructions' }, data: {
title: 'Create Standing Instructions',
breadcrumb: 'Create Standing Instructions',
routeParamBreadcrumb: 'Create Standing Instructions'
},
component: CreateStandingInstructionsComponent, component: CreateStandingInstructionsComponent,
resolve: { resolve: {
standingIntructionsTemplate: StandingInstructionsTemplateResolver standingIntructionsTemplate: StandingInstructionsTemplateResolver
@@ -42,7 +46,11 @@ const routes: Routes = [
}, },
{ {
path: 'list-standing-instructions', path: 'list-standing-instructions',
data: { title: 'List Standing Instructions', breadcrumb: 'List Standing Instructions', routeParamBreadcrumb: 'List Standing Instructions' }, data: {
title: 'List Standing Instructions',
breadcrumb: 'List Standing Instructions',
routeParamBreadcrumb: 'List Standing Instructions'
},
component: ListStandingInstructionsComponent, component: ListStandingInstructionsComponent,
resolve: { resolve: {
standingIntructionsTemplate: StandingInstructionsTemplateResolver standingIntructionsTemplate: StandingInstructionsTemplateResolver
@@ -71,29 +79,33 @@ const routes: Routes = [
data: { title: 'View Standing Instructions', breadcrumb: 'view', routeParamBreadcrumb: false }, data: { title: 'View Standing Instructions', breadcrumb: 'view', routeParamBreadcrumb: false },
component: ViewStandingInstructionsComponent, component: ViewStandingInstructionsComponent,
resolve: { resolve: {
standingInstructionsData: ViewStandingInstructionsResolver, standingInstructionsData: ViewStandingInstructionsResolver
}, }
}, },
{ {
path: 'edit', path: 'edit',
data: { title: 'Edit Standing Instructions', breadcrumb: 'edit', routeParamBreadcrumb: false }, data: { title: 'Edit Standing Instructions', breadcrumb: 'edit', routeParamBreadcrumb: false },
component: EditStandingInstructionsComponent, component: EditStandingInstructionsComponent,
resolve: { resolve: {
standingInstructionsDataAndTemplate: StandingInstructionsDataAndTemplateResolver, standingInstructionsDataAndTemplate: StandingInstructionsDataAndTemplateResolver
}, }
}, },
{ {
path: 'list-account-transactions', path: 'list-account-transactions',
data: { title: 'List Account Transactions', breadcrumb: 'List Account Transactions', routeParamBreadcrumb: 'List Account Transactions' }, data: {
title: 'List Account Transactions',
breadcrumb: 'List Account Transactions',
routeParamBreadcrumb: 'List Account Transactions'
},
component: ListTransactionsComponent, component: ListTransactionsComponent,
resolve: { resolve: {
listTransactionData: ListTransactionsResolver listTransactionData: ListTransactionsResolver
} }
}, }
] ]
}, }
] ]
}, }
]; ];
@NgModule({ @NgModule({
imports: [RouterModule.forChild(routes)], imports: [RouterModule.forChild(routes)],
@@ -108,5 +120,4 @@ const routes: Routes = [
ViewAccountTransferResolver ViewAccountTransferResolver
] ]
}) })
export class AccountTransfersRoutingModule {}
export class AccountTransfersRoutingModule { }
@@ -21,7 +21,12 @@ import { ViewAccountTransferComponent } from './view-account-transfer/view-accou
* All components related to Account Transfers functions should be declared here. * All components related to Account Transfers functions should be declared here.
*/ */
@NgModule({ @NgModule({
imports: [SharedModule, PipesModule, DirectivesModule, AccountTransfersRoutingModule], imports: [
SharedModule,
PipesModule,
DirectivesModule,
AccountTransfersRoutingModule
],
declarations: [ declarations: [
ViewStandingInstructionsComponent, ViewStandingInstructionsComponent,
EditStandingInstructionsComponent, EditStandingInstructionsComponent,
@@ -31,6 +36,6 @@ import { ViewAccountTransferComponent } from './view-account-transfer/view-accou
ListTransactionsComponent, ListTransactionsComponent,
ViewAccountTransferComponent ViewAccountTransferComponent
], ],
providers: [ ] providers: []
}) })
export class AccountTransfersModule { } export class AccountTransfersModule {}
@@ -12,8 +12,7 @@ import { Observable } from 'rxjs';
providedIn: 'root' providedIn: 'root'
}) })
export class AccountTransfersService { export class AccountTransfersService {
constructor(private http: HttpClient) {}
constructor(private http: HttpClient) { }
/** /**
* @params standingInstructionsId * @params standingInstructionsId
@@ -33,8 +32,14 @@ export class AccountTransfersService {
return this.http.put(`/standinginstructions/${standinginstructionsId}`, data, { params: httpParams }); return this.http.put(`/standinginstructions/${standinginstructionsId}`, data, { params: httpParams });
} }
getStandingInstructionsTemplate(clientId: any, officeId: any, accountTypeId: string, formValue?: any): Observable<any> { getStandingInstructionsTemplate(
let httpParams = new HttpParams().set('fromAccountType', accountTypeId) clientId: any,
officeId: any,
accountTypeId: string,
formValue?: any
): Observable<any> {
let httpParams = new HttpParams()
.set('fromAccountType', accountTypeId)
.set('fromClientId', clientId) .set('fromClientId', clientId)
.set('fromOfficeId', officeId); .set('fromOfficeId', officeId);
if (formValue) { if (formValue) {
@@ -52,8 +57,7 @@ export class AccountTransfersService {
} }
newAccountTranferResource(id: any, accountTypeId: any, formValue?: any): Observable<any> { newAccountTranferResource(id: any, accountTypeId: any, formValue?: any): Observable<any> {
let httpParams = new HttpParams().set('fromAccountId', id) let httpParams = new HttpParams().set('fromAccountId', id).set('fromAccountType', accountTypeId);
.set('fromAccountType', accountTypeId);
if (formValue) { if (formValue) {
const propNames = Object.getOwnPropertyNames(formValue); const propNames = Object.getOwnPropertyNames(formValue);
for (let i = 0; i < propNames.length; i++) { for (let i = 0; i < propNames.length; i++) {
@@ -62,7 +66,6 @@ export class AccountTransfersService {
} }
} }
return this.http.get(`/accounttransfers/template`, { params: httpParams }); return this.http.get(`/accounttransfers/template`, { params: httpParams });
} }
createAccountTransfer(data: any): Observable<any> { createAccountTransfer(data: any): Observable<any> {
@@ -94,9 +97,9 @@ export class AccountTransfersService {
return this.http.delete(`/standinginstructions/${id}`, { params: httpParams }); return this.http.delete(`/standinginstructions/${id}`, { params: httpParams });
} }
getStandingInstructionsTransactions(standingInstructionsId: any, dateFormat: any, locale: any) { getStandingInstructionsTransactions(standingInstructionsId: any, dateFormat: any, locale: any) {
const httpParams = new HttpParams().set('associations', 'transactions') const httpParams = new HttpParams()
.set('associations', 'transactions')
.set('dateFormat', dateFormat) .set('dateFormat', dateFormat)
.set('limit', '14') .set('limit', '14')
.set('locale', locale) .set('locale', locale)
@@ -107,5 +110,4 @@ export class AccountTransfersService {
getViewAccountTransferDetails(transferId: any): Observable<any> { getViewAccountTransferDetails(transferId: any): Observable<any> {
return this.http.get(`/accounttransfers/${transferId}`); return this.http.get(`/accounttransfers/${transferId}`);
} }
} }
@@ -14,13 +14,14 @@ import { SettingsService } from 'app/settings/settings.service';
*/ */
@Injectable() @Injectable()
export class ListTransactionsResolver implements Resolve<Object> { export class ListTransactionsResolver implements Resolve<Object> {
/** /**
* @param {AccountTransfersService} accountTransfersService Account Transfers service. * @param {AccountTransfersService} accountTransfersService Account Transfers service.
* @param {SettingsService} settingsService Settings Service. * @param {SettingsService} settingsService Settings Service.
*/ */
constructor(private accountTransfersService: AccountTransfersService, constructor(
private settingsService: SettingsService) { } private accountTransfersService: AccountTransfersService,
private settingsService: SettingsService
) {}
/** /**
* Returns the Standing Instructions Data. * Returns the Standing Instructions Data.
@@ -13,13 +13,12 @@ import { AccountTransfersService } from '../account-transfers.service';
*/ */
@Injectable() @Injectable()
export class MakeAccountTransferTemplateResolver implements Resolve<Object> { export class MakeAccountTransferTemplateResolver implements Resolve<Object> {
accountTypeId: string; accountTypeId: string;
id: any; id: any;
/** /**
* @param {accountTransfersService} AccountTransfersService Account Transfers service. * @param {accountTransfersService} AccountTransfersService Account Transfers service.
*/ */
constructor(private accountTransfersService: AccountTransfersService) { } constructor(private accountTransfersService: AccountTransfersService) {}
/** /**
* Returns the Standing Instructions Data. * Returns the Standing Instructions Data.
@@ -42,5 +41,4 @@ export class MakeAccountTransferTemplateResolver implements Resolve<Object> {
} }
return this.accountTransfersService.newAccountTranferResource(this.id, this.accountTypeId); return this.accountTransfersService.newAccountTranferResource(this.id, this.accountTypeId);
} }
} }
@@ -13,11 +13,10 @@ import { AccountTransfersService } from '../account-transfers.service';
*/ */
@Injectable() @Injectable()
export class StandingInstructionsDataAndTemplateResolver implements Resolve<Object> { export class StandingInstructionsDataAndTemplateResolver implements Resolve<Object> {
/** /**
* @param {accountTransfersService} AccountTransfersService Account Transfers service. * @param {accountTransfersService} AccountTransfersService Account Transfers service.
*/ */
constructor(private accountTransfersService: AccountTransfersService) { } constructor(private accountTransfersService: AccountTransfersService) {}
/** /**
* Returns the Standing Instructions Data. * Returns the Standing Instructions Data.
@@ -28,5 +27,4 @@ export class StandingInstructionsDataAndTemplateResolver implements Resolve<Obje
const standingInstructionsId = route.parent.paramMap.get('standingInstructionsId'); const standingInstructionsId = route.parent.paramMap.get('standingInstructionsId');
return this.accountTransfersService.getStandingInstructionsDataAndTemplate(standingInstructionsId); return this.accountTransfersService.getStandingInstructionsDataAndTemplate(standingInstructionsId);
} }
} }
@@ -13,13 +13,12 @@ import { AccountTransfersService } from '../account-transfers.service';
*/ */
@Injectable() @Injectable()
export class StandingInstructionsTemplateResolver implements Resolve<Object> { export class StandingInstructionsTemplateResolver implements Resolve<Object> {
accountTypeId: string; accountTypeId: string;
/** /**
* @param {accountTransfersService} AccountTransfersService Account Transfers service. * @param {accountTransfersService} AccountTransfersService Account Transfers service.
*/ */
constructor(private accountTransfersService: AccountTransfersService) { } constructor(private accountTransfersService: AccountTransfersService) {}
/** /**
* Returns the Standing Instructions Data. * Returns the Standing Instructions Data.
@@ -42,5 +41,4 @@ export class StandingInstructionsTemplateResolver implements Resolve<Object> {
} }
return this.accountTransfersService.getStandingInstructionsTemplate(clientId, officeId, this.accountTypeId); return this.accountTransfersService.getStandingInstructionsTemplate(clientId, officeId, this.accountTypeId);
} }
} }
@@ -13,11 +13,10 @@ import { AccountTransfersService } from '../account-transfers.service';
*/ */
@Injectable() @Injectable()
export class ViewAccountTransferResolver implements Resolve<Object> { export class ViewAccountTransferResolver implements Resolve<Object> {
/** /**
* @param {AccountTransfersService} AccountTransfersService Savings service. * @param {AccountTransfersService} AccountTransfersService Savings service.
*/ */
constructor(private accountTransfersService: AccountTransfersService) { } constructor(private accountTransfersService: AccountTransfersService) {}
/** /**
* Returns the View Account Transfer data. * Returns the View Account Transfer data.
@@ -27,5 +26,4 @@ export class ViewAccountTransferResolver implements Resolve<Object> {
const transferId = route.paramMap.get('transferid'); const transferId = route.paramMap.get('transferid');
return this.accountTransfersService.getViewAccountTransferDetails(transferId); return this.accountTransfersService.getViewAccountTransferDetails(transferId);
} }
} }
@@ -13,11 +13,10 @@ import { AccountTransfersService } from '../account-transfers.service';
*/ */
@Injectable() @Injectable()
export class ViewStandingInstructionsResolver implements Resolve<Object> { export class ViewStandingInstructionsResolver implements Resolve<Object> {
/** /**
* @param {accountTransfersService} AccountTransfersService Account Transfers service. * @param {accountTransfersService} AccountTransfersService Account Transfers service.
*/ */
constructor(private accountTransfersService: AccountTransfersService) { } constructor(private accountTransfersService: AccountTransfersService) {}
/** /**
* Returns the Standing Instructions Data. * Returns the Standing Instructions Data.
@@ -28,5 +27,4 @@ export class ViewStandingInstructionsResolver implements Resolve<Object> {
const standingInstructionsId = route.parent.paramMap.get('standingInstructionsId'); const standingInstructionsId = route.parent.paramMap.get('standingInstructionsId');
return this.accountTransfersService.getStandingInstructionsData(standingInstructionsId); return this.accountTransfersService.getStandingInstructionsData(standingInstructionsId);
} }
} }
@@ -8,9 +8,8 @@ describe('CreateStandingInstructionsComponent', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ CreateStandingInstructionsComponent ] declarations: [CreateStandingInstructionsComponent]
}) }).compileComponents();
.compileComponents();
})); }));
beforeEach(() => { beforeEach(() => {
@@ -17,7 +17,6 @@ import { Dates } from 'app/core/utils/dates';
styleUrls: ['./create-standing-instructions.component.scss'] styleUrls: ['./create-standing-instructions.component.scss']
}) })
export class CreateStandingInstructionsComponent implements OnInit { export class CreateStandingInstructionsComponent implements OnInit {
/** Standing Instructions Data */ /** Standing Instructions Data */
standingIntructionsTemplate: any; standingIntructionsTemplate: any;
/** Minimum date allowed. */ /** Minimum date allowed. */
@@ -45,7 +44,7 @@ export class CreateStandingInstructionsComponent implements OnInit {
/** From Account Data */ /** From Account Data */
fromAccountData: any; fromAccountData: any;
/** Destination Type Data */ /** Destination Type Data */
destinationTypeData: { id: number; value: string; }[]; destinationTypeData: { id: number; value: string }[];
/** To Office Type Data */ /** To Office Type Data */
toOfficeTypeData: any; toOfficeTypeData: any;
/** To Client Type Data */ /** To Client Type Data */
@@ -76,12 +75,14 @@ export class CreateStandingInstructionsComponent implements OnInit {
* @param {SettingsService} settingsService Settings Service * @param {SettingsService} settingsService Settings Service
* @param {Dates} dateUtils Date Utils * @param {Dates} dateUtils Date Utils
*/ */
constructor(private formBuilder: UntypedFormBuilder, constructor(
private formBuilder: UntypedFormBuilder,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router, private router: Router,
private accountTransfersService: AccountTransfersService, private accountTransfersService: AccountTransfersService,
private settingsService: SettingsService, private settingsService: SettingsService,
private dateUtils: Dates) { private dateUtils: Dates
) {
this.route.data.subscribe((data: { standingIntructionsTemplate: any }) => { this.route.data.subscribe((data: { standingIntructionsTemplate: any }) => {
this.standingIntructionsTemplate = data.standingIntructionsTemplate; this.standingIntructionsTemplate = data.standingIntructionsTemplate;
this.setParams(); this.setParams();
@@ -113,7 +114,7 @@ export class CreateStandingInstructionsComponent implements OnInit {
this.createCreateStandingInstructionsForm(); this.createCreateStandingInstructionsForm();
this.buildDependencies(); this.buildDependencies();
this.createStandingInstructionsForm.patchValue({ this.createStandingInstructionsForm.patchValue({
'applicant': this.standingIntructionsTemplate.fromClient.displayName applicant: this.standingIntructionsTemplate.fromClient.displayName
}); });
} }
@@ -122,26 +123,83 @@ export class CreateStandingInstructionsComponent implements OnInit {
*/ */
createCreateStandingInstructionsForm() { createCreateStandingInstructionsForm() {
this.createStandingInstructionsForm = this.formBuilder.group({ this.createStandingInstructionsForm = this.formBuilder.group({
'name': ['', Validators.required], name: [
'applicant': [{ value: '', disabled: true }], '',
'transferType': ['', Validators.required], Validators.required
'priority': ['', Validators.required], ],
'status': ['', Validators.required], applicant: [{ value: '', disabled: true }],
'fromAccountType': ['', Validators.required], transferType: [
'fromAccountId': ['', Validators.required], '',
'destination': ['', Validators.required], Validators.required
'toOfficeId': ['', Validators.required], ],
'toClientId': ['', Validators.required], priority: [
'toAccountType': ['', Validators.required], '',
'toAccountId': ['', Validators.required], Validators.required
'instructionType': ['', Validators.required], ],
'amount': ['', Validators.required], status: [
'validFrom': ['', Validators.required], '',
'validTill': ['', Validators.required], Validators.required
'recurrenceType': ['', Validators.required], ],
'recurrenceInterval': ['', Validators.required], fromAccountType: [
'recurrenceFrequency': ['', Validators.required], '',
'recurrenceOnMonthDay': ['', Validators.required] Validators.required
],
fromAccountId: [
'',
Validators.required
],
destination: [
'',
Validators.required
],
toOfficeId: [
'',
Validators.required
],
toClientId: [
'',
Validators.required
],
toAccountType: [
'',
Validators.required
],
toAccountId: [
'',
Validators.required
],
instructionType: [
'',
Validators.required
],
amount: [
'',
Validators.required
],
validFrom: [
'',
Validators.required
],
validTill: [
'',
Validators.required
],
recurrenceType: [
'',
Validators.required
],
recurrenceInterval: [
'',
Validators.required
],
recurrenceFrequency: [
'',
Validators.required
],
recurrenceOnMonthDay: [
'',
Validators.required
]
}); });
} }
@@ -152,7 +210,10 @@ export class CreateStandingInstructionsComponent implements OnInit {
this.statusTypeData = this.standingIntructionsTemplate.statusOptions; this.statusTypeData = this.standingIntructionsTemplate.statusOptions;
this.fromAccountTypeData = this.standingIntructionsTemplate.fromAccountTypeOptions; this.fromAccountTypeData = this.standingIntructionsTemplate.fromAccountTypeOptions;
this.fromAccountData = this.standingIntructionsTemplate.fromAccountOptions; this.fromAccountData = this.standingIntructionsTemplate.fromAccountOptions;
this.destinationTypeData = [{ id: 1, value: 'own account' }, { id: 2, value: 'with in bank' }]; this.destinationTypeData = [
{ id: 1, value: 'own account' },
{ id: 2, value: 'with in bank' }
];
this.toOfficeTypeData = this.standingIntructionsTemplate.toOfficeOptions; this.toOfficeTypeData = this.standingIntructionsTemplate.toOfficeOptions;
this.toClientTypeData = this.standingIntructionsTemplate.toClientOptions; this.toClientTypeData = this.standingIntructionsTemplate.toClientOptions;
this.toAccountTypeData = this.standingIntructionsTemplate.toAccountTypeOptions; this.toAccountTypeData = this.standingIntructionsTemplate.toAccountTypeOptions;
@@ -170,8 +231,8 @@ export class CreateStandingInstructionsComponent implements OnInit {
if (destination === 1) { if (destination === 1) {
this.allowclientedit = false; this.allowclientedit = false;
this.createStandingInstructionsForm.patchValue({ this.createStandingInstructionsForm.patchValue({
'toOfficeId': this.officeId, toOfficeId: this.officeId,
'toClientId': this.clientId toClientId: this.clientId
}); });
this.ToOfficeId = true; this.ToOfficeId = true;
this.ToClientId = true; this.ToClientId = true;
@@ -179,20 +240,21 @@ export class CreateStandingInstructionsComponent implements OnInit {
} else { } else {
this.allowclientedit = true; this.allowclientedit = true;
this.createStandingInstructionsForm.patchValue({ this.createStandingInstructionsForm.patchValue({
'toOfficeId': '', toOfficeId: '',
'toClientId': '' toClientId: ''
}); });
this.createStandingInstructionsForm.controls['toOfficeId'].enable(); this.createStandingInstructionsForm.controls['toOfficeId'].enable();
this.createStandingInstructionsForm.controls['toClientId'].enable(); this.createStandingInstructionsForm.controls['toClientId'].enable();
} }
}); });
} }
/** Executes on change of various select options */ /** Executes on change of various select options */
changeEvent() { changeEvent() {
const formValue = this.refineObject(this.createStandingInstructionsForm.value); const formValue = this.refineObject(this.createStandingInstructionsForm.value);
this.accountTransfersService.getStandingInstructionsTemplate(this.clientId, this.officeId, this.accountTypeId, formValue).subscribe((response: any) => { this.accountTransfersService
.getStandingInstructionsTemplate(this.clientId, this.officeId, this.accountTypeId, formValue)
.subscribe((response: any) => {
this.standingIntructionsTemplate = response; this.standingIntructionsTemplate = response;
this.setOptions(); this.setOptions();
}); });
@@ -219,7 +281,7 @@ export class CreateStandingInstructionsComponent implements OnInit {
const dateFormat = this.settingsService.dateFormat; const dateFormat = this.settingsService.dateFormat;
const locale = this.settingsService.language.code; const locale = this.settingsService.language.code;
const standingInstructionData = { const standingInstructionData = {
... this.createStandingInstructionsForm.value, ...this.createStandingInstructionsForm.value,
dateFormat, dateFormat,
locale, locale,
monthDayFormat: 'dd MMMM', monthDayFormat: 'dd MMMM',
@@ -227,7 +289,10 @@ export class CreateStandingInstructionsComponent implements OnInit {
fromOfficeId: this.officeId, fromOfficeId: this.officeId,
validFrom: this.dateUtils.formatDate(this.createStandingInstructionsForm.value.validFrom, dateFormat), validFrom: this.dateUtils.formatDate(this.createStandingInstructionsForm.value.validFrom, dateFormat),
validTill: this.dateUtils.formatDate(this.createStandingInstructionsForm.value.validTill, dateFormat), validTill: this.dateUtils.formatDate(this.createStandingInstructionsForm.value.validTill, dateFormat),
recurrenceOnMonthDay: this.dateUtils.formatDate(this.createStandingInstructionsForm.value.recurrenceOnMonthDay, 'dd MMMM'), recurrenceOnMonthDay: this.dateUtils.formatDate(
this.createStandingInstructionsForm.value.recurrenceOnMonthDay,
'dd MMMM'
)
}; };
delete standingInstructionData['destination']; delete standingInstructionData['destination'];
delete standingInstructionData['applicant']; delete standingInstructionData['applicant'];
@@ -235,5 +300,4 @@ export class CreateStandingInstructionsComponent implements OnInit {
this.router.navigate(['../../'], { relativeTo: this.route }); this.router.navigate(['../../'], { relativeTo: this.route });
}); });
} }
} }
@@ -8,9 +8,8 @@ describe('EditStandingInstructionsComponent', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ EditStandingInstructionsComponent ] declarations: [EditStandingInstructionsComponent]
}) }).compileComponents();
.compileComponents();
})); }));
beforeEach(() => { beforeEach(() => {
@@ -17,7 +17,6 @@ import { Dates } from 'app/core/utils/dates';
styleUrls: ['./edit-standing-instructions.component.scss'] styleUrls: ['./edit-standing-instructions.component.scss']
}) })
export class EditStandingInstructionsComponent implements OnInit { export class EditStandingInstructionsComponent implements OnInit {
/** Standing Instructions Data */ /** Standing Instructions Data */
standingInstructionsData: any; standingInstructionsData: any;
/** Standing Instructions Id */ /** Standing Instructions Id */
@@ -50,12 +49,14 @@ export class EditStandingInstructionsComponent implements OnInit {
* @param {SettingsService} settingsService Settings Service * @param {SettingsService} settingsService Settings Service
* @param {Dates} dateUtils Date Utils * @param {Dates} dateUtils Date Utils
*/ */
constructor(private formBuilder: UntypedFormBuilder, constructor(
private formBuilder: UntypedFormBuilder,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router, private router: Router,
private accountTransfersService: AccountTransfersService, private accountTransfersService: AccountTransfersService,
private settingsService: SettingsService, private settingsService: SettingsService,
private dateUtils: Dates) { private dateUtils: Dates
) {
this.route.data.subscribe((data: { standingInstructionsDataAndTemplate: any }) => { this.route.data.subscribe((data: { standingInstructionsDataAndTemplate: any }) => {
this.standingInstructionsData = data.standingInstructionsDataAndTemplate; this.standingInstructionsData = data.standingInstructionsDataAndTemplate;
this.standingInstructionsId = data.standingInstructionsDataAndTemplate.id; this.standingInstructionsId = data.standingInstructionsDataAndTemplate.id;
@@ -77,26 +78,28 @@ export class EditStandingInstructionsComponent implements OnInit {
this.standingInstructionsData.recurrenceOnMonthDay.push(n); this.standingInstructionsData.recurrenceOnMonthDay.push(n);
} }
this.editStandingInstructionsForm.patchValue({ this.editStandingInstructionsForm.patchValue({
'name': this.standingInstructionsData.name, name: this.standingInstructionsData.name,
'applicant': this.standingInstructionsData.fromClient.displayName, applicant: this.standingInstructionsData.fromClient.displayName,
'type': this.standingInstructionsData.transferType.value, type: this.standingInstructionsData.transferType.value,
'priority': this.standingInstructionsData.priority.id, priority: this.standingInstructionsData.priority.id,
'status': this.standingInstructionsData.status.id, status: this.standingInstructionsData.status.id,
'fromAccountType': this.standingInstructionsData.fromAccountType.value, fromAccountType: this.standingInstructionsData.fromAccountType.value,
'fromAccount': this.standingInstructionsData.fromAccount.productName, fromAccount: this.standingInstructionsData.fromAccount.productName,
'destination': this.allowclientedit ? 'Within Bank' : 'Own Account', destination: this.allowclientedit ? 'Within Bank' : 'Own Account',
'toOffice': this.standingInstructionsData.toOffice.name, toOffice: this.standingInstructionsData.toOffice.name,
'toClientId': this.standingInstructionsData.toClient.displayName, toClientId: this.standingInstructionsData.toClient.displayName,
'toAccountType': this.standingInstructionsData.toAccountType.value, toAccountType: this.standingInstructionsData.toAccountType.value,
'toAccount': this.standingInstructionsData.toAccount.productName, toAccount: this.standingInstructionsData.toAccount.productName,
'instructionType': this.standingInstructionsData.instructionType.id, instructionType: this.standingInstructionsData.instructionType.id,
'amount': this.standingInstructionsData.amount, amount: this.standingInstructionsData.amount,
'validFrom': this.standingInstructionsData.validFrom && new Date(this.standingInstructionsData.validFrom), validFrom: this.standingInstructionsData.validFrom && new Date(this.standingInstructionsData.validFrom),
'validTill': this.standingInstructionsData.validTill && new Date(this.standingInstructionsData.validTill), validTill: this.standingInstructionsData.validTill && new Date(this.standingInstructionsData.validTill),
'recurrenceType': this.standingInstructionsData.recurrenceType.id, recurrenceType: this.standingInstructionsData.recurrenceType.id,
'recurrenceInterval': this.standingInstructionsData.recurrenceInterval, recurrenceInterval: this.standingInstructionsData.recurrenceInterval,
'recurrenceFrequency': this.standingInstructionsData.recurrenceFrequency.id, recurrenceFrequency: this.standingInstructionsData.recurrenceFrequency.id,
'recurrenceOnMonthDay': this.standingInstructionsData.recurrenceOnMonthDay && new Date(this.standingInstructionsData.recurrenceOnMonthDay) recurrenceOnMonthDay:
this.standingInstructionsData.recurrenceOnMonthDay &&
new Date(this.standingInstructionsData.recurrenceOnMonthDay)
}); });
} }
@@ -105,26 +108,41 @@ export class EditStandingInstructionsComponent implements OnInit {
*/ */
createEditStandingInstructionsForm() { createEditStandingInstructionsForm() {
this.editStandingInstructionsForm = this.formBuilder.group({ this.editStandingInstructionsForm = this.formBuilder.group({
'name': [{value: '', disabled: true}], name: [{ value: '', disabled: true }],
'applicant': [{ value: '', disabled: true }], applicant: [{ value: '', disabled: true }],
'type': [{ value: '', disabled: true }], type: [{ value: '', disabled: true }],
'priority': ['', Validators.required], priority: [
'status': ['', Validators.required], '',
'fromAccountType': [{ value: '', disabled: true }], Validators.required
'fromAccount': [{ value: '', disabled: true }], ],
'destination': [{ value: '', disabled: true }], status: [
'toOffice': [{ value: '', disabled: true }], '',
'toClientId': [{ value: '', disabled: true }], Validators.required
'toAccountType': [{ value: '', disabled: true }], ],
'toAccount': [{ value: '', disabled: true }], fromAccountType: [{ value: '', disabled: true }],
'instructionType': '', fromAccount: [{ value: '', disabled: true }],
'amount': '', destination: [{ value: '', disabled: true }],
'validFrom': ['', Validators.required], toOffice: [{ value: '', disabled: true }],
'validTill': ['', Validators.required], toClientId: [{ value: '', disabled: true }],
'recurrenceType': ['', Validators.required], toAccountType: [{ value: '', disabled: true }],
'recurrenceInterval': '', toAccount: [{ value: '', disabled: true }],
'recurrenceFrequency': '', instructionType: '',
'recurrenceOnMonthDay': '' amount: '',
validFrom: [
'',
Validators.required
],
validTill: [
'',
Validators.required
],
recurrenceType: [
'',
Validators.required
],
recurrenceInterval: '',
recurrenceFrequency: '',
recurrenceOnMonthDay: ''
}); });
} }
@@ -151,15 +169,19 @@ export class EditStandingInstructionsComponent implements OnInit {
priority: this.editStandingInstructionsForm.value.priority, priority: this.editStandingInstructionsForm.value.priority,
recurrenceFrequency: this.editStandingInstructionsForm.value.recurrenceFrequency, recurrenceFrequency: this.editStandingInstructionsForm.value.recurrenceFrequency,
recurrenceInterval: this.editStandingInstructionsForm.value.recurrenceInterval, recurrenceInterval: this.editStandingInstructionsForm.value.recurrenceInterval,
recurrenceOnMonthDay: this.dateUtils.formatDate(this.editStandingInstructionsForm.value.recurrenceOnMonthDay, 'dd MMMM'), recurrenceOnMonthDay: this.dateUtils.formatDate(
this.editStandingInstructionsForm.value.recurrenceOnMonthDay,
'dd MMMM'
),
recurrenceType: this.editStandingInstructionsForm.value.recurrenceType, recurrenceType: this.editStandingInstructionsForm.value.recurrenceType,
status: this.editStandingInstructionsForm.value.status, status: this.editStandingInstructionsForm.value.status,
validFrom: this.dateUtils.formatDate(this.editStandingInstructionsForm.value.validFrom, dateFormat), validFrom: this.dateUtils.formatDate(this.editStandingInstructionsForm.value.validFrom, dateFormat),
validTill: this.dateUtils.formatDate(this.editStandingInstructionsForm.value.validTill, dateFormat) validTill: this.dateUtils.formatDate(this.editStandingInstructionsForm.value.validTill, dateFormat)
}; };
this.accountTransfersService.updateStandingInstructionsData(this.standingInstructionsId, standingInstructionData).subscribe((response: any) => { this.accountTransfersService
.updateStandingInstructionsData(this.standingInstructionsId, standingInstructionData)
.subscribe((response: any) => {
this.router.navigate(['../view'], { relativeTo: this.route }); this.router.navigate(['../view'], { relativeTo: this.route });
}); });
} }
} }
@@ -8,9 +8,8 @@ describe('ListStandingInstructionsComponent', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ ListStandingInstructionsComponent ] declarations: [ListStandingInstructionsComponent]
}) }).compileComponents();
.compileComponents();
})); }));
beforeEach(() => { beforeEach(() => {
@@ -22,7 +22,6 @@ import { SettingsService } from 'app/settings/settings.service';
styleUrls: ['./list-standing-instructions.component.scss'] styleUrls: ['./list-standing-instructions.component.scss']
}) })
export class ListStandingInstructionsComponent { export class ListStandingInstructionsComponent {
/** Recurring Deposits Data */ /** Recurring Deposits Data */
standingIntructionsTemplateData: any; standingIntructionsTemplateData: any;
/** Instructions Data */ /** Instructions Data */
@@ -50,14 +49,21 @@ export class ListStandingInstructionsComponent {
/** Data source for instructions table. */ /** Data source for instructions table. */
dataSource = new MatTableDataSource(); dataSource = new MatTableDataSource();
/** Columns to be displayed in instructions table. */ /** Columns to be displayed in instructions table. */
displayedColumns: string[] = ['client', 'fromAccount', 'beneficiary', 'toAccount', 'amount', 'validity', 'actions']; displayedColumns: string[] = [
'client',
'fromAccount',
'beneficiary',
'toAccount',
'amount',
'validity',
'actions'
];
/** Instruction Table Reference */ /** Instruction Table Reference */
@ViewChild('instructionsTable', { static: true }) instructionTableRef: MatTable<Element>; @ViewChild('instructionsTable', { static: true }) instructionTableRef: MatTable<Element>;
/** Paginator for centers table. */ /** Paginator for centers table. */
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator; @ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
/** /**
* Retrieves Standing Instructions Data from `resolve`. * Retrieves Standing Instructions Data from `resolve`.
* @param {ActivatedRoute} route Activated Route. * @param {ActivatedRoute} route Activated Route.
@@ -65,10 +71,12 @@ export class ListStandingInstructionsComponent {
* @param {SettingsService} settingsService Settings Service * @param {SettingsService} settingsService Settings Service
* @param {AccountTransfersService} accountTransfersService Account Transfers Service * @param {AccountTransfersService} accountTransfersService Account Transfers Service
*/ */
constructor(private route: ActivatedRoute, constructor(
private route: ActivatedRoute,
private accountTransfersService: AccountTransfersService, private accountTransfersService: AccountTransfersService,
private settingsService: SettingsService, private settingsService: SettingsService,
private dialog: MatDialog) { private dialog: MatDialog
) {
this.route.data.subscribe((data: { standingIntructionsTemplate: any }) => { this.route.data.subscribe((data: { standingIntructionsTemplate: any }) => {
this.standingIntructionsTemplateData = data.standingIntructionsTemplate; this.standingIntructionsTemplateData = data.standingIntructionsTemplate;
if (data.standingIntructionsTemplate.fromClient) { if (data.standingIntructionsTemplate.fromClient) {
@@ -106,7 +114,7 @@ export class ListStandingInstructionsComponent {
const dateFormat = this.settingsService.dateFormat; const dateFormat = this.settingsService.dateFormat;
const locale = this.settingsService.language.code; const locale = this.settingsService.language.code;
const searchData = { const searchData = {
clientId : this.standingIntructionsTemplateData.fromClient.id || this.fromClientId.value, clientId: this.standingIntructionsTemplateData.fromClient.id || this.fromClientId.value,
clientName: this.standingIntructionsTemplateData.fromClient.displayName || this.clientNameControl.value, clientName: this.standingIntructionsTemplateData.fromClient.displayName || this.clientNameControl.value,
locale, locale,
dateFormat, dateFormat,
@@ -130,11 +138,8 @@ export class ListStandingInstructionsComponent {
}); });
deleteStandingInstructionDialogRef.afterClosed().subscribe((response: any) => { deleteStandingInstructionDialogRef.afterClosed().subscribe((response: any) => {
if (response.delete) { if (response.delete) {
this.accountTransfersService.deleteStandingInstrucions(instructionId) this.accountTransfersService.deleteStandingInstrucions(instructionId).subscribe(() => {});
.subscribe(() => {});
} }
}); });
} }
} }
@@ -8,9 +8,8 @@ describe('ListTransactionsComponent', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ ListTransactionsComponent ] declarations: [ListTransactionsComponent]
}) }).compileComponents();
.compileComponents();
})); }));
beforeEach(() => { beforeEach(() => {
@@ -13,14 +13,17 @@ import { ActivatedRoute } from '@angular/router';
styleUrls: ['./list-transactions.component.scss'] styleUrls: ['./list-transactions.component.scss']
}) })
export class ListTransactionsComponent { export class ListTransactionsComponent {
/** List Transactions Data */ /** List Transactions Data */
listTransactionData: any; listTransactionData: any;
/** Data source for instructions table. */ /** Data source for instructions table. */
dataSource = new MatTableDataSource(); dataSource = new MatTableDataSource();
/** Columns to be displayed in instructions table. */ /** Columns to be displayed in instructions table. */
displayedColumns: string[] = ['transactionDate', 'amount', 'notes', 'reversed']; displayedColumns: string[] = [
'transactionDate',
'amount',
'notes',
'reversed'
];
/** Paginator for centers table. */ /** Paginator for centers table. */
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator; @ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
@@ -36,5 +39,4 @@ export class ListTransactionsComponent {
this.dataSource.paginator = this.paginator; this.dataSource.paginator = this.paginator;
}); });
} }
} }
@@ -8,9 +8,8 @@ describe('MakeAccountTransfersComponent', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ MakeAccountTransfersComponent ] declarations: [MakeAccountTransfersComponent]
}) }).compileComponents();
.compileComponents();
})); }));
beforeEach(() => { beforeEach(() => {
@@ -9,7 +9,6 @@ import { SettingsService } from 'app/settings/settings.service';
import { ClientsService } from 'app/clients/clients.service'; import { ClientsService } from 'app/clients/clients.service';
import { Dates } from 'app/core/utils/dates'; import { Dates } from 'app/core/utils/dates';
/** /**
* Create account transfers * Create account transfers
*/ */
@@ -19,7 +18,6 @@ import { Dates } from 'app/core/utils/dates';
styleUrls: ['./make-account-transfers.component.scss'] styleUrls: ['./make-account-transfers.component.scss']
}) })
export class MakeAccountTransfersComponent implements OnInit, AfterViewInit { export class MakeAccountTransfersComponent implements OnInit, AfterViewInit {
/** Standing Instructions Data */ /** Standing Instructions Data */
accountTransferTemplateData: any; accountTransferTemplateData: any;
/** Minimum date allowed. */ /** Minimum date allowed. */
@@ -55,13 +53,15 @@ export class MakeAccountTransfersComponent implements OnInit, AfterViewInit {
* @param {SettingsService} settingsService Settings Service * @param {SettingsService} settingsService Settings Service
* @param {ClientsService} clientsService Clients Service * @param {ClientsService} clientsService Clients Service
*/ */
constructor(private formBuilder: UntypedFormBuilder, constructor(
private formBuilder: UntypedFormBuilder,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router, private router: Router,
private accountTransfersService: AccountTransfersService, private accountTransfersService: AccountTransfersService,
private dateUtils: Dates, private dateUtils: Dates,
private settingsService: SettingsService, private settingsService: SettingsService,
private clientsService: ClientsService) { private clientsService: ClientsService
) {
this.route.data.subscribe((data: { accountTransferTemplate: any }) => { this.route.data.subscribe((data: { accountTransferTemplate: any }) => {
this.accountTransferTemplateData = data.accountTransferTemplate; this.accountTransferTemplateData = data.accountTransferTemplate;
this.setParams(); this.setParams();
@@ -98,13 +98,34 @@ export class MakeAccountTransfersComponent implements OnInit, AfterViewInit {
*/ */
createMakeAccountTransferForm() { createMakeAccountTransferForm() {
this.makeAccountTransferForm = this.formBuilder.group({ this.makeAccountTransferForm = this.formBuilder.group({
'toOfficeId': ['', Validators.required], toOfficeId: [
'toClientId': ['', Validators.required], '',
'toAccountType': ['', Validators.required], Validators.required
'toAccountId': ['', Validators.required], ],
'transferAmount': [this.accountTransferTemplateData.transferAmount, Validators.required], toClientId: [
'transferDate': [this.settingsService.businessDate, Validators.required], '',
'transferDescription': ['', Validators.required], Validators.required
],
toAccountType: [
'',
Validators.required
],
toAccountId: [
'',
Validators.required
],
transferAmount: [
this.accountTransferTemplateData.transferAmount,
Validators.required
],
transferDate: [
this.settingsService.businessDate,
Validators.required
],
transferDescription: [
'',
Validators.required
]
}); });
} }
@@ -118,7 +139,9 @@ export class MakeAccountTransfersComponent implements OnInit, AfterViewInit {
/** Executes on change of various select options */ /** Executes on change of various select options */
changeEvent() { changeEvent() {
const formValue = this.refineObject(this.makeAccountTransferForm.value); const formValue = this.refineObject(this.makeAccountTransferForm.value);
this.accountTransfersService.newAccountTranferResource(this.id, this.accountTypeId, formValue).subscribe((response: any) => { this.accountTransfersService
.newAccountTranferResource(this.id, this.accountTypeId, formValue)
.subscribe((response: any) => {
this.accountTransferTemplateData = response; this.accountTransferTemplateData = response;
this.toClientTypeData = response.toClientOptions; this.toClientTypeData = response.toClientOptions;
this.setOptions(); this.setOptions();
@@ -128,7 +151,7 @@ export class MakeAccountTransfersComponent implements OnInit, AfterViewInit {
/** Refine Object /** Refine Object
* Removes the object param with null or '' values * Removes the object param with null or '' values
*/ */
refineObject(dataObj: { [x: string]: any; transferAmount: any; transferDate: any; transferDescription: any; }) { refineObject(dataObj: { [x: string]: any; transferAmount: any; transferDate: any; transferDescription: any }) {
delete dataObj.transferAmount; delete dataObj.transferAmount;
delete dataObj.transferDate; delete dataObj.transferDate;
delete dataObj.transferDescription; delete dataObj.transferDescription;
@@ -151,8 +174,7 @@ export class MakeAccountTransfersComponent implements OnInit, AfterViewInit {
ngAfterViewInit() { ngAfterViewInit() {
this.makeAccountTransferForm.controls.toClientId.valueChanges.subscribe((value: string) => { this.makeAccountTransferForm.controls.toClientId.valueChanges.subscribe((value: string) => {
if (value.length >= 2) { if (value.length >= 2) {
this.clientsService.getFilteredClients('displayName', 'ASC', true, value) this.clientsService.getFilteredClients('displayName', 'ASC', true, value).subscribe((data: any) => {
.subscribe((data: any) => {
this.clientsData = data.pageItems; this.clientsData = data.pageItems;
}); });
this.changeEvent(); this.changeEvent();
@@ -176,7 +198,7 @@ export class MakeAccountTransfersComponent implements OnInit, AfterViewInit {
const dateFormat = this.settingsService.dateFormat; const dateFormat = this.settingsService.dateFormat;
const locale = this.settingsService.language.code; const locale = this.settingsService.language.code;
const makeAccountTransferData = { const makeAccountTransferData = {
... this.makeAccountTransferForm.value, ...this.makeAccountTransferForm.value,
transferDate: this.dateUtils.formatDate(this.makeAccountTransferForm.value.transferDate, dateFormat), transferDate: this.dateUtils.formatDate(this.makeAccountTransferForm.value.transferDate, dateFormat),
dateFormat, dateFormat,
locale, locale,
@@ -190,5 +212,4 @@ export class MakeAccountTransfersComponent implements OnInit, AfterViewInit {
this.router.navigate(['../../transactions'], { relativeTo: this.route }); this.router.navigate(['../../transactions'], { relativeTo: this.route });
}); });
} }
} }
@@ -8,9 +8,8 @@ describe('ViewAccountTransferComponent', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ ViewAccountTransferComponent ] declarations: [ViewAccountTransferComponent]
}) }).compileComponents();
.compileComponents();
})); }));
beforeEach(() => { beforeEach(() => {
@@ -9,15 +9,16 @@ import { ActivatedRoute } from '@angular/router';
styleUrls: ['./view-account-transfer.component.scss'] styleUrls: ['./view-account-transfer.component.scss']
}) })
export class ViewAccountTransferComponent { export class ViewAccountTransferComponent {
viewAccountTransferData: any; viewAccountTransferData: any;
/** /**
* Retrieves the view account transfer data from `resolve`. * Retrieves the view account transfer data from `resolve`.
* @param {ActivatedRoute} route Activated Route. * @param {ActivatedRoute} route Activated Route.
* @param {Location} location Location. * @param {Location} location Location.
*/ */
constructor(private route: ActivatedRoute, constructor(
private location: Location) { private route: ActivatedRoute,
private location: Location
) {
this.route.data.subscribe((data: { viewAccountTransferData: any }) => { this.route.data.subscribe((data: { viewAccountTransferData: any }) => {
this.viewAccountTransferData = data.viewAccountTransferData; this.viewAccountTransferData = data.viewAccountTransferData;
}); });
@@ -38,5 +39,4 @@ export class ViewAccountTransferComponent {
transactionColor(): string { transactionColor(): string {
return this.viewAccountTransferData.reversed ? 'undo' : 'active'; return this.viewAccountTransferData.reversed ? 'undo' : 'active';
} }
} }
@@ -8,9 +8,8 @@ describe('ViewStandingInstructionsComponent', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ ViewStandingInstructionsComponent ] declarations: [ViewStandingInstructionsComponent]
}) }).compileComponents();
.compileComponents();
})); }));
beforeEach(() => { beforeEach(() => {
@@ -8,7 +8,6 @@ import { ActivatedRoute } from '@angular/router';
styleUrls: ['./view-standing-instructions.component.scss'] styleUrls: ['./view-standing-instructions.component.scss']
}) })
export class ViewStandingInstructionsComponent { export class ViewStandingInstructionsComponent {
/** Standing Instructions Data */ /** Standing Instructions Data */
standingInstructionsData: any; standingInstructionsData: any;
/** Allow Client Edit */ /** Allow Client Edit */
@@ -19,12 +18,11 @@ export class ViewStandingInstructionsComponent {
* @param {ActivatedRoute} route Activated Route. * @param {ActivatedRoute} route Activated Route.
*/ */
constructor(private route: ActivatedRoute) { constructor(private route: ActivatedRoute) {
this.route.data.subscribe((data: { standingInstructionsData: any}) => { this.route.data.subscribe((data: { standingInstructionsData: any }) => {
this.standingInstructionsData = data.standingInstructionsData; this.standingInstructionsData = data.standingInstructionsData;
if (this.standingInstructionsData.fromClient.id === this.standingInstructionsData.toClient.id) { if (this.standingInstructionsData.fromClient.id === this.standingInstructionsData.toClient.id) {
this.allowclientedit = false; this.allowclientedit = false;
} }
}); });
} }
} }
@@ -84,7 +84,7 @@ const routes: Routes = [
resolve: { resolve: {
offices: OfficesResolver, offices: OfficesResolver,
glAccounts: GlAccountsResolver glAccounts: GlAccountsResolver
}, }
}, },
{ {
path: 'frequent-postings', path: 'frequent-postings',
@@ -121,7 +121,7 @@ const routes: Routes = [
} }
} }
] ]
}, }
] ]
}, },
{ {
@@ -199,7 +199,10 @@ const routes: Routes = [
}, },
{ {
path: 'view/:id', path: 'view/:id',
data: { title: 'View GL Account', routeResolveBreadcrumb: ['glAccountAndChartOfAccountsTemplate', 'name'] }, data: { title: 'View GL Account', routeResolveBreadcrumb: [
'glAccountAndChartOfAccountsTemplate',
'name'
] },
resolve: { resolve: {
glAccountAndChartOfAccountsTemplate: GlAccountAndChartOfAccountsTemplateResolver glAccountAndChartOfAccountsTemplate: GlAccountAndChartOfAccountsTemplateResolver
}, },
@@ -282,7 +285,10 @@ const routes: Routes = [
}, },
{ {
path: 'view/:id', path: 'view/:id',
data: { title: 'View Accounting Rule', routeResolveBreadcrumb: ['accountingRule', 'name'] }, data: { title: 'View Accounting Rule', routeResolveBreadcrumb: [
'accountingRule',
'name'
] },
resolve: { resolve: {
accountingRule: AccountingRuleResolver accountingRule: AccountingRuleResolver
}, },
@@ -357,7 +363,7 @@ const routes: Routes = [
}, },
{ {
path: 'journal-entry', path: 'journal-entry',
data: {title: 'Journal Entries', breadcrumb: 'Journal Entries' }, data: { title: 'Journal Entries', breadcrumb: 'Journal Entries' },
children: [ children: [
{ {
path: 'view/:id', path: 'view/:id',
@@ -378,6 +384,7 @@ const routes: Routes = [
] ]
} }
]) ])
]; ];
/** /**
@@ -415,4 +422,4 @@ const routes: Routes = [
ProvisioningJournalEntriesResolver ProvisioningJournalEntriesResolver
] ]
}) })
export class AccountingRoutingModule { } export class AccountingRoutingModule {}
@@ -13,7 +13,6 @@ import { AccountingService } from '../accounting.service';
*/ */
@Injectable() @Injectable()
export class AccountingRuleResolver implements Resolve<Object> { export class AccountingRuleResolver implements Resolve<Object> {
/** /**
* @param {AccountingService} accountingService Accounting service. * @param {AccountingService} accountingService Accounting service.
*/ */
@@ -27,5 +26,4 @@ export class AccountingRuleResolver implements Resolve<Object> {
const id = route.paramMap.get('id'); const id = route.paramMap.get('id');
return this.accountingService.getAccountingRule(id); return this.accountingService.getAccountingRule(id);
} }
} }
@@ -13,7 +13,6 @@ import { AccountingService } from '../accounting.service';
*/ */
@Injectable() @Injectable()
export class AccountingRulesTemplateResolver implements Resolve<Object> { export class AccountingRulesTemplateResolver implements Resolve<Object> {
/** /**
* @param {AccountingService} accountingService Accounting service. * @param {AccountingService} accountingService Accounting service.
*/ */
@@ -26,5 +25,4 @@ export class AccountingRulesTemplateResolver implements Resolve<Object> {
resolve(): Observable<any> { resolve(): Observable<any> {
return this.accountingService.getAccountingRulesTemplate(); return this.accountingService.getAccountingRulesTemplate();
} }
} }
@@ -8,9 +8,8 @@ describe('AccountingRulesComponent', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ AccountingRulesComponent ] declarations: [AccountingRulesComponent]
}) }).compileComponents();
.compileComponents();
})); }));
beforeEach(() => { beforeEach(() => {
@@ -14,11 +14,17 @@ import { ActivatedRoute } from '@angular/router';
styleUrls: ['./accounting-rules.component.scss'] styleUrls: ['./accounting-rules.component.scss']
}) })
export class AccountingRulesComponent implements OnInit { export class AccountingRulesComponent implements OnInit {
/** Accounting rule data. */ /** Accounting rule data. */
accountingRuleData: any; accountingRuleData: any;
/** Columns to be displayed in accounting rules table. */ /** Columns to be displayed in accounting rules table. */
displayedColumns: string[] = ['name', 'officeName', 'debitTags', 'debitAccount', 'creditTags', 'creditAccount']; displayedColumns: string[] = [
'name',
'officeName',
'debitTags',
'debitAccount',
'creditTags',
'creditAccount'
];
/** Data source for accounting rules table. */ /** Data source for accounting rules table. */
dataSource: MatTableDataSource<any>; dataSource: MatTableDataSource<any>;
@@ -49,16 +55,23 @@ export class AccountingRulesComponent implements OnInit {
*/ */
setAccountingRules() { setAccountingRules() {
this.accountingRuleData.forEach((accountingRule: any) => { this.accountingRuleData.forEach((accountingRule: any) => {
accountingRule.debitTags = accountingRule.debitTags ? accountingRule.debitTags.map((debitTag: any) => debitTag.tag.name).join(', ') : ''; accountingRule.debitTags = accountingRule.debitTags
accountingRule.creditTags = accountingRule.creditTags ? accountingRule.creditTags.map((creditTag: any) => creditTag.tag.name).join(', ') : ''; ? accountingRule.debitTags.map((debitTag: any) => debitTag.tag.name).join(', ')
: '';
accountingRule.creditTags = accountingRule.creditTags
? accountingRule.creditTags.map((creditTag: any) => creditTag.tag.name).join(', ')
: '';
}); });
this.dataSource = new MatTableDataSource(this.accountingRuleData); this.dataSource = new MatTableDataSource(this.accountingRuleData);
this.dataSource.paginator = this.paginator; this.dataSource.paginator = this.paginator;
this.dataSource.sortingDataAccessor = (accountingRule: any, property: any) => { this.dataSource.sortingDataAccessor = (accountingRule: any, property: any) => {
switch (property) { switch (property) {
case 'debitAccount': return accountingRule.debitAccounts[0].name; case 'debitAccount':
case 'creditAccount': return accountingRule.creditAccounts[0].name; return accountingRule.debitAccounts[0].name;
default: return accountingRule[property]; case 'creditAccount':
return accountingRule.creditAccounts[0].name;
default:
return accountingRule[property];
} }
}; };
this.dataSource.sort = this.sort; this.dataSource.sort = this.sort;
@@ -71,5 +84,4 @@ export class AccountingRulesComponent implements OnInit {
applyFilter(filterValue: string) { applyFilter(filterValue: string) {
this.dataSource.filter = filterValue.trim().toLowerCase(); this.dataSource.filter = filterValue.trim().toLowerCase();
} }
} }
@@ -13,7 +13,6 @@ import { AccountingService } from '../accounting.service';
*/ */
@Injectable() @Injectable()
export class AccountingRulesResolver implements Resolve<Object> { export class AccountingRulesResolver implements Resolve<Object> {
/** /**
* @param {AccountingService} accountingService Accounting service. * @param {AccountingService} accountingService Accounting service.
*/ */
@@ -26,5 +25,4 @@ export class AccountingRulesResolver implements Resolve<Object> {
resolve(): Observable<any> { resolve(): Observable<any> {
return this.accountingService.getAccountingRules(); return this.accountingService.getAccountingRules();
} }
} }
@@ -8,9 +8,8 @@ describe('CreateRuleComponent', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ CreateRuleComponent ] declarations: [CreateRuleComponent]
}) }).compileComponents();
.compileComponents();
})); }));
beforeEach(() => { beforeEach(() => {
@@ -18,7 +18,6 @@ import { oneOfTheFieldsIsRequiredValidator } from '../one-of-the-fields-is-requi
styleUrls: ['./create-rule.component.scss'] styleUrls: ['./create-rule.component.scss']
}) })
export class CreateRuleComponent implements OnInit { export class CreateRuleComponent implements OnInit {
/** Accounting rule form. */ /** Accounting rule form. */
accountingRuleForm: UntypedFormGroup; accountingRuleForm: UntypedFormGroup;
/** Office data. */ /** Office data. */
@@ -37,10 +36,12 @@ export class CreateRuleComponent implements OnInit {
* @param {ActivatedRoute} route Activated Route. * @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation. * @param {Router} router Router for navigation.
*/ */
constructor(private formBuilder: UntypedFormBuilder, constructor(
private formBuilder: UntypedFormBuilder,
private accountingService: AccountingService, private accountingService: AccountingService,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router) { private router: Router
) {
this.route.data.subscribe((data: { accountingRulesTemplate: any }) => { this.route.data.subscribe((data: { accountingRulesTemplate: any }) => {
this.officeData = data.accountingRulesTemplate.allowedOffices; this.officeData = data.accountingRulesTemplate.allowedOffices;
this.glAccountData = data.accountingRulesTemplate.allowedAccounts; this.glAccountData = data.accountingRulesTemplate.allowedAccounts;
@@ -61,19 +62,28 @@ export class CreateRuleComponent implements OnInit {
* Creates accounting rule form. * Creates accounting rule form.
*/ */
createAccountingRuleForm() { createAccountingRuleForm() {
this.accountingRuleForm = this.formBuilder.group({ this.accountingRuleForm = this.formBuilder.group(
'name': ['', Validators.required], {
'officeId': ['', Validators.required], name: [
'debitRuleType': ['fixedAccount'], '',
'accountToDebit': [''], Validators.required
'debitTags': [''], ],
'allowMultipleDebitEntries': [''], officeId: [
'creditRuleType': ['fixedAccount'], '',
'accountToCredit': [''], Validators.required
'creditTags': [''], ],
'allowMultipleCreditEntries': [''], debitRuleType: ['fixedAccount'],
'description': [''] accountToDebit: [''],
}, { validator: oneOfTheFieldsIsRequiredValidator }); debitTags: [''],
allowMultipleDebitEntries: [''],
creditRuleType: ['fixedAccount'],
accountToCredit: [''],
creditTags: [''],
allowMultipleCreditEntries: [''],
description: ['']
},
{ validator: oneOfTheFieldsIsRequiredValidator }
);
} }
/** /**
@@ -121,8 +131,13 @@ export class CreateRuleComponent implements OnInit {
delete accountingRule.debitRuleType; delete accountingRule.debitRuleType;
delete accountingRule.creditRuleType; delete accountingRule.creditRuleType;
this.accountingService.createAccountingRule(accountingRule).subscribe((response: any) => { this.accountingService.createAccountingRule(accountingRule).subscribe((response: any) => {
this.router.navigate(['../view', response.resourceId], { relativeTo: this.route }); this.router.navigate(
[
'../view',
response.resourceId
],
{ relativeTo: this.route }
);
}); });
} }
} }
@@ -8,9 +8,8 @@ describe('EditRuleComponent', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ EditRuleComponent ] declarations: [EditRuleComponent]
}) }).compileComponents();
.compileComponents();
})); }));
beforeEach(() => { beforeEach(() => {
@@ -18,7 +18,6 @@ import { oneOfTheFieldsIsRequiredValidator } from '../one-of-the-fields-is-requi
styleUrls: ['./edit-rule.component.scss'] styleUrls: ['./edit-rule.component.scss']
}) })
export class EditRuleComponent implements OnInit { export class EditRuleComponent implements OnInit {
/** Accounting rule form. */ /** Accounting rule form. */
accountingRuleForm: UntypedFormGroup; accountingRuleForm: UntypedFormGroup;
/** Accounting rule. */ /** Accounting rule. */
@@ -39,14 +38,13 @@ export class EditRuleComponent implements OnInit {
* @param {ActivatedRoute} route Activated Route. * @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation. * @param {Router} router Router for navigation.
*/ */
constructor(private formBuilder: UntypedFormBuilder, constructor(
private formBuilder: UntypedFormBuilder,
private accountingService: AccountingService, private accountingService: AccountingService,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router) { private router: Router
this.route.data.subscribe((data: { ) {
accountingRulesTemplate: any, this.route.data.subscribe((data: { accountingRulesTemplate: any; accountingRule: any }) => {
accountingRule: any
}) => {
this.officeData = data.accountingRulesTemplate.allowedOffices; this.officeData = data.accountingRulesTemplate.allowedOffices;
this.glAccountData = data.accountingRulesTemplate.allowedAccounts; this.glAccountData = data.accountingRulesTemplate.allowedAccounts;
this.debitTagData = data.accountingRulesTemplate.allowedDebitTagOptions; this.debitTagData = data.accountingRulesTemplate.allowedDebitTagOptions;
@@ -67,26 +65,35 @@ export class EditRuleComponent implements OnInit {
* Creates accounting rule form. * Creates accounting rule form.
*/ */
createAccountingRuleForm() { createAccountingRuleForm() {
this.accountingRuleForm = this.formBuilder.group({ this.accountingRuleForm = this.formBuilder.group(
'name': [this.accountingRule.name, Validators.required], {
'officeId': [this.accountingRule.officeId, Validators.required], name: [
'debitRuleType': [''], this.accountingRule.name,
'accountToDebit': [''], Validators.required
'debitTags': [''], ],
'allowMultipleDebitEntries': [''], officeId: [
'creditRuleType': [''], this.accountingRule.officeId,
'accountToCredit': [''], Validators.required
'creditTags': [''], ],
'allowMultipleCreditEntries': [''], debitRuleType: [''],
'description': [this.accountingRule.description] accountToDebit: [''],
}, { validator: oneOfTheFieldsIsRequiredValidator }); debitTags: [''],
allowMultipleDebitEntries: [''],
creditRuleType: [''],
accountToCredit: [''],
creditTags: [''],
allowMultipleCreditEntries: [''],
description: [this.accountingRule.description]
},
{ validator: oneOfTheFieldsIsRequiredValidator }
);
} }
/** /**
* Sets accounting rule form for selected accounting rule type. * Sets accounting rule form for selected accounting rule type.
*/ */
setAccountingRulesForm() { setAccountingRulesForm() {
this.accountingRuleForm.get('debitRuleType').valueChanges.subscribe(debitRuleType => { this.accountingRuleForm.get('debitRuleType').valueChanges.subscribe((debitRuleType) => {
if (debitRuleType === 'fixedAccount') { if (debitRuleType === 'fixedAccount') {
this.accountingRuleForm.get('debitTags').reset(); this.accountingRuleForm.get('debitTags').reset();
this.accountingRuleForm.get('allowMultipleDebitEntries').reset(); this.accountingRuleForm.get('allowMultipleDebitEntries').reset();
@@ -95,7 +102,7 @@ export class EditRuleComponent implements OnInit {
this.accountingRuleForm.get('allowMultipleDebitEntries').setValue(false); this.accountingRuleForm.get('allowMultipleDebitEntries').setValue(false);
} }
}); });
this.accountingRuleForm.get('creditRuleType').valueChanges.subscribe(creditRuleType => { this.accountingRuleForm.get('creditRuleType').valueChanges.subscribe((creditRuleType) => {
if (creditRuleType === 'fixedAccount') { if (creditRuleType === 'fixedAccount') {
this.accountingRuleForm.get('creditTags').reset(); this.accountingRuleForm.get('creditTags').reset();
this.accountingRuleForm.get('allowMultipleCreditEntries').reset(); this.accountingRuleForm.get('allowMultipleCreditEntries').reset();
@@ -110,7 +117,9 @@ export class EditRuleComponent implements OnInit {
this.accountingRuleForm.get('accountToDebit').setValue(this.accountingRule.debitAccounts[0].id); this.accountingRuleForm.get('accountToDebit').setValue(this.accountingRule.debitAccounts[0].id);
} else { } else {
this.accountingRuleForm.get('debitRuleType').setValue('listOfAccounts'); this.accountingRuleForm.get('debitRuleType').setValue('listOfAccounts');
this.accountingRuleForm.get('debitTags').setValue(this.accountingRule.debitTags.map((debitTag: any) => debitTag.tag.id)); this.accountingRuleForm
.get('debitTags')
.setValue(this.accountingRule.debitTags.map((debitTag: any) => debitTag.tag.id));
this.accountingRuleForm.get('allowMultipleDebitEntries').setValue(this.accountingRule.allowMultipleDebitEntries); this.accountingRuleForm.get('allowMultipleDebitEntries').setValue(this.accountingRule.allowMultipleDebitEntries);
} }
@@ -119,8 +128,12 @@ export class EditRuleComponent implements OnInit {
this.accountingRuleForm.get('accountToCredit').setValue(this.accountingRule.creditAccounts[0].id); this.accountingRuleForm.get('accountToCredit').setValue(this.accountingRule.creditAccounts[0].id);
} else { } else {
this.accountingRuleForm.get('creditRuleType').setValue('listOfAccounts'); this.accountingRuleForm.get('creditRuleType').setValue('listOfAccounts');
this.accountingRuleForm.get('creditTags').setValue(this.accountingRule.creditTags.map((creditTag: any) => creditTag.tag.id)); this.accountingRuleForm
this.accountingRuleForm.get('allowMultipleCreditEntries').setValue(this.accountingRule.allowMultipleCreditEntries); .get('creditTags')
.setValue(this.accountingRule.creditTags.map((creditTag: any) => creditTag.tag.id));
this.accountingRuleForm
.get('allowMultipleCreditEntries')
.setValue(this.accountingRule.allowMultipleCreditEntries);
} }
} }
@@ -145,8 +158,13 @@ export class EditRuleComponent implements OnInit {
delete accountingRule.debitRuleType; delete accountingRule.debitRuleType;
delete accountingRule.creditRuleType; delete accountingRule.creditRuleType;
this.accountingService.updateAccountingRule(this.accountingRule.id, accountingRule).subscribe((response: any) => { this.accountingService.updateAccountingRule(this.accountingRule.id, accountingRule).subscribe((response: any) => {
this.router.navigate(['../../', response.resourceId], { relativeTo: this.route }); this.router.navigate(
[
'../../',
response.resourceId
],
{ relativeTo: this.route }
);
}); });
} }
} }
@@ -2,10 +2,12 @@
import { UntypedFormGroup, ValidatorFn, ValidationErrors } from '@angular/forms'; import { UntypedFormGroup, ValidatorFn, ValidationErrors } from '@angular/forms';
/** Validates that one of the fields for debit or credit is filled for a given accounting rule type. */ /** Validates that one of the fields for debit or credit is filled for a given accounting rule type. */
export const oneOfTheFieldsIsRequiredValidator: ValidatorFn = (accountingRuleForm: UntypedFormGroup): ValidationErrors | null => { export const oneOfTheFieldsIsRequiredValidator: ValidatorFn = (
accountingRuleForm: UntypedFormGroup
): ValidationErrors | null => {
const accountToDebit = accountingRuleForm.controls.accountToDebit.value; const accountToDebit = accountingRuleForm.controls.accountToDebit.value;
const debitTags = accountingRuleForm.controls.debitTags.value; const debitTags = accountingRuleForm.controls.debitTags.value;
const accountToCredit = accountingRuleForm.controls.accountToCredit.value; const accountToCredit = accountingRuleForm.controls.accountToCredit.value;
const creditTags = accountingRuleForm.controls.creditTags.value; const creditTags = accountingRuleForm.controls.creditTags.value;
return ((accountToDebit || debitTags) && (accountToCredit || creditTags)) ? null : { 'error': true }; return (accountToDebit || debitTags) && (accountToCredit || creditTags) ? null : { error: true };
}; };
@@ -8,9 +8,8 @@ describe('ViewRuleComponent', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ ViewRuleComponent ] declarations: [ViewRuleComponent]
}) }).compileComponents();
.compileComponents();
})); }));
beforeEach(() => { beforeEach(() => {
@@ -18,7 +18,6 @@ import { DeleteDialogComponent } from '../../../shared/delete-dialog/delete-dial
styleUrls: ['./view-rule.component.scss'] styleUrls: ['./view-rule.component.scss']
}) })
export class ViewRuleComponent { export class ViewRuleComponent {
/** Accounting rule. */ /** Accounting rule. */
accountingRule: any; accountingRule: any;
@@ -29,10 +28,12 @@ export class ViewRuleComponent {
* @param {Router} router Router for navigation. * @param {Router} router Router for navigation.
* @param {MatDialog} dialog Dialog reference. * @param {MatDialog} dialog Dialog reference.
*/ */
constructor(private accountingService: AccountingService, constructor(
private accountingService: AccountingService,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router, private router: Router,
public dialog: MatDialog) { public dialog: MatDialog
) {
this.route.data.subscribe((data: { accountingRule: any }) => { this.route.data.subscribe((data: { accountingRule: any }) => {
this.accountingRule = data.accountingRule; this.accountingRule = data.accountingRule;
}); });
@@ -47,12 +48,10 @@ export class ViewRuleComponent {
}); });
deleteAccountingRuleDialogRef.afterClosed().subscribe((response: any) => { deleteAccountingRuleDialogRef.afterClosed().subscribe((response: any) => {
if (response.delete) { if (response.delete) {
this.accountingService.deleteAccountingRule(this.accountingRule.id) this.accountingService.deleteAccountingRule(this.accountingRule.id).subscribe(() => {
.subscribe(() => {
this.router.navigate(['/accounting/accounting-rules']); this.router.navigate(['/accounting/accounting-rules']);
}); });
} }
}); });
} }
} }
+16 -6
View File
@@ -15,7 +15,6 @@ import { PopoverService } from '../configuration-wizard/popover/popover.service'
styleUrls: ['./accounting.component.scss'] styleUrls: ['./accounting.component.scss']
}) })
export class AccountingComponent implements AfterViewInit { export class AccountingComponent implements AfterViewInit {
/* Reference of Chart of Accounts */ /* Reference of Chart of Accounts */
@ViewChild('chartofAccounts') chartofAccounts: ElementRef<any>; @ViewChild('chartofAccounts') chartofAccounts: ElementRef<any>;
/* Template for popover on Chart of Accounts */ /* Template for popover on Chart of Accounts */
@@ -44,9 +43,11 @@ export class AccountingComponent implements AfterViewInit {
* @param {ConfigurationWizardService} configurationWizardService ConfigurationWizard Service. * @param {ConfigurationWizardService} configurationWizardService ConfigurationWizard Service.
* @param {PopoverService} popoverService PopoverService. * @param {PopoverService} popoverService PopoverService.
*/ */
constructor(private router: Router, constructor(
private router: Router,
private configurationWizardService: ConfigurationWizardService, private configurationWizardService: ConfigurationWizardService,
private popoverService: PopoverService) { } private popoverService: PopoverService
) {}
/** /**
* Popover function * Popover function
@@ -56,7 +57,12 @@ export class AccountingComponent implements AfterViewInit {
* @param backdrop Boolean. * @param backdrop Boolean.
* @param arrowNumber - The index of the boolean value to toggle. * @param arrowNumber - The index of the boolean value to toggle.
*/ */
showPopover(template: TemplateRef<any>, target: HTMLElement | ElementRef<any>, position: string, backdrop: boolean): void { showPopover(
template: TemplateRef<any>,
target: HTMLElement | ElementRef<any>,
position: string,
backdrop: boolean
): void {
setTimeout(() => this.popoverService.open(template, target, position, backdrop, {}), 200); setTimeout(() => this.popoverService.open(template, target, position, backdrop, {}), 200);
} }
@@ -76,7 +82,12 @@ export class AccountingComponent implements AfterViewInit {
} }
if (this.configurationWizardService.showMigrateOpeningBalances === true) { if (this.configurationWizardService.showMigrateOpeningBalances === true) {
setTimeout(() => { setTimeout(() => {
this.showPopover(this.templateMigrateOpeningBalances, this.migrateOpeningBalances.nativeElement, 'bottom', true); this.showPopover(
this.templateMigrateOpeningBalances,
this.migrateOpeningBalances.nativeElement,
'bottom',
true
);
}); });
} }
if (this.configurationWizardService.showClosingEntries === true) { if (this.configurationWizardService.showClosingEntries === true) {
@@ -181,5 +192,4 @@ export class AccountingComponent implements AfterViewInit {
// Toggle the boolean value at the given index // Toggle the boolean value at the given index
this.arrowBooleans[arrowNumber] = !this.arrowBooleans[arrowNumber]; this.arrowBooleans[arrowNumber] = !this.arrowBooleans[arrowNumber];
} }
} }
+1 -1
View File
@@ -78,4 +78,4 @@ import { PipesModule } from 'app/pipes/pipes.module';
ViewProvisioningJournalEntriesComponent ViewProvisioningJournalEntriesComponent
] ]
}) })
export class AccountingModule { } export class AccountingModule {}
+3 -10
View File
@@ -14,11 +14,10 @@ import { Observable } from 'rxjs';
providedIn: 'root' providedIn: 'root'
}) })
export class AccountingService { export class AccountingService {
/** /**
* @param {HttpClient} http Http Client to send requests. * @param {HttpClient} http Http Client to send requests.
*/ */
constructor(private http: HttpClient) { } constructor(private http: HttpClient) {}
/** /**
* @returns {Observable<any>} Offices data ordered by id. * @returns {Observable<any>} Offices data ordered by id.
@@ -66,10 +65,7 @@ export class AccountingService {
* @returns {Observable<any>} GL Accounts. * @returns {Observable<any>} GL Accounts.
*/ */
getGlAccounts(): Observable<any> { getGlAccounts(): Observable<any> {
const httpParams = new HttpParams() const httpParams = new HttpParams().set('manualEntriesAllowed', 'true').set('usage', '1').set('disabled', 'false');
.set('manualEntriesAllowed', 'true')
.set('usage', '1')
.set('disabled', 'false');
return this.http.get(`/glaccounts`, { params: httpParams }); return this.http.get(`/glaccounts`, { params: httpParams });
} }
@@ -78,9 +74,7 @@ export class AccountingService {
* @returns {Observable<any>} Journal Entries. * @returns {Observable<any>} Journal Entries.
*/ */
getJournalEntry(transactionId: string): Observable<any> { getJournalEntry(transactionId: string): Observable<any> {
const httpParams = new HttpParams() const httpParams = new HttpParams().set('transactionId', transactionId).set('transactionDetails', 'true');
.set('transactionId', transactionId)
.set('transactionDetails', 'true');
return this.http.get(`/journalentries`, { params: httpParams }); return this.http.get(`/journalentries`, { params: httpParams });
} }
@@ -397,5 +391,4 @@ export class AccountingService {
const httpParams = new HttpParams().set('command', 'recreateprovisioningentry'); const httpParams = new HttpParams().set('command', 'recreateprovisioningentry');
return this.http.post(`/provisioningentries/${provisioningEntryId}`, {}, { params: httpParams }); return this.http.post(`/provisioningentries/${provisioningEntryId}`, {}, { params: httpParams });
} }
} }
@@ -8,9 +8,8 @@ describe('ChartOfAccountsComponent', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ ChartOfAccountsComponent ] declarations: [ChartOfAccountsComponent]
}) }).compileComponents();
.compileComponents();
})); }));
beforeEach(() => { beforeEach(() => {
@@ -29,13 +29,19 @@ import { TreeControlService } from 'app/shared/common-logic/tree-control.service
styleUrls: ['./chart-of-accounts.component.scss'] styleUrls: ['./chart-of-accounts.component.scss']
}) })
export class ChartOfAccountsComponent implements AfterViewInit, OnInit { export class ChartOfAccountsComponent implements AfterViewInit, OnInit {
/** Button toggle group form control for type of view. (list/tree) */ /** Button toggle group form control for type of view. (list/tree) */
viewGroup = new UntypedFormControl('listView'); viewGroup = new UntypedFormControl('listView');
/** GL Account data. */ /** GL Account data. */
glAccountData: any; glAccountData: any;
/** Columns to be displayed in chart of accounts table. */ /** Columns to be displayed in chart of accounts table. */
displayedColumns: string[] = ['name', 'glCode', 'glAccountType', 'disabled', 'manualEntriesAllowed', 'usedAs']; displayedColumns: string[] = [
'name',
'glCode',
'glAccountType',
'disabled',
'manualEntriesAllowed',
'usedAs'
];
/** Data source for chart of accounts table. */ /** Data source for chart of accounts table. */
tableDataSource: MatTableDataSource<any>; tableDataSource: MatTableDataSource<any>;
/** Nested tree control for chart of accounts tree. */ /** Nested tree control for chart of accounts tree. */
@@ -69,12 +75,14 @@ export class ChartOfAccountsComponent implements AfterViewInit, OnInit {
* @param {ConfigurationWizardService} configurationWizardService ConfigurationWizard Service. * @param {ConfigurationWizardService} configurationWizardService ConfigurationWizard Service.
* @param {PopoverService} popoverService PopoverService. * @param {PopoverService} popoverService PopoverService.
*/ */
constructor(private glAccountTreeService: GlAccountTreeService, constructor(
private glAccountTreeService: GlAccountTreeService,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router, private router: Router,
private treeControlService: TreeControlService, private treeControlService: TreeControlService,
private configurationWizardService: ConfigurationWizardService, private configurationWizardService: ConfigurationWizardService,
private popoverService: PopoverService) { private popoverService: PopoverService
) {
this.route.data.subscribe((data: { chartOfAccounts: any }) => { this.route.data.subscribe((data: { chartOfAccounts: any }) => {
this.glAccountData = data.chartOfAccounts; this.glAccountData = data.chartOfAccounts;
glAccountTreeService.initialize(this.glAccountData); glAccountTreeService.initialize(this.glAccountData);
@@ -102,9 +110,12 @@ export class ChartOfAccountsComponent implements AfterViewInit, OnInit {
this.tableDataSource.paginator = this.paginator; this.tableDataSource.paginator = this.paginator;
this.tableDataSource.sortingDataAccessor = (glAccount: any, property: any) => { this.tableDataSource.sortingDataAccessor = (glAccount: any, property: any) => {
switch (property) { switch (property) {
case 'glAccountType': return glAccount.type.value; case 'glAccountType':
case 'usedAs': return glAccount.usage.value; return glAccount.type.value;
default: return glAccount[property]; case 'usedAs':
return glAccount.usage.value;
default:
return glAccount[property];
} }
}; };
this.tableDataSource.sort = this.sort; this.tableDataSource.sort = this.sort;
@@ -158,7 +169,12 @@ export class ChartOfAccountsComponent implements AfterViewInit, OnInit {
* @param position String. * @param position String.
* @param backdrop Boolean. * @param backdrop Boolean.
*/ */
showPopover(template: TemplateRef<any>, target: HTMLElement | ElementRef<any>, position: string, backdrop: boolean): void { showPopover(
template: TemplateRef<any>,
target: HTMLElement | ElementRef<any>,
position: string,
backdrop: boolean
): void {
setTimeout(() => this.popoverService.open(template, target, position, backdrop, {}), 200); setTimeout(() => this.popoverService.open(template, target, position, backdrop, {}), 200);
} }
@@ -188,5 +204,4 @@ export class ChartOfAccountsComponent implements AfterViewInit, OnInit {
toggleExpandCollapse() { toggleExpandCollapse() {
this.isTreeExpanded = this.treeControlService.toggleExpandCollapse(this.nestedTreeControl, this.isTreeExpanded); this.isTreeExpanded = this.treeControlService.toggleExpandCollapse(this.nestedTreeControl, this.isTreeExpanded);
} }
} }
@@ -13,7 +13,6 @@ import { AccountingService } from '../accounting.service';
*/ */
@Injectable() @Injectable()
export class ChartOfAccountsResolver implements Resolve<Object> { export class ChartOfAccountsResolver implements Resolve<Object> {
/** /**
* @param {AccountingService} accountingService Accounting service. * @param {AccountingService} accountingService Accounting service.
*/ */
@@ -26,5 +25,4 @@ export class ChartOfAccountsResolver implements Resolve<Object> {
resolve(): Observable<any> { resolve(): Observable<any> {
return this.accountingService.getChartOfAccounts(); return this.accountingService.getChartOfAccounts();
} }
} }
@@ -13,7 +13,6 @@ import { AccountingService } from '../../accounting.service';
*/ */
@Injectable() @Injectable()
export class ChartOfAccountsTemplateResolver implements Resolve<Object> { export class ChartOfAccountsTemplateResolver implements Resolve<Object> {
/** /**
* @param {AccountingService} accountingService Accounting service. * @param {AccountingService} accountingService Accounting service.
*/ */
@@ -26,5 +25,4 @@ export class ChartOfAccountsTemplateResolver implements Resolve<Object> {
resolve(): Observable<any> { resolve(): Observable<any> {
return this.accountingService.getChartOfAccountsTemplate(); return this.accountingService.getChartOfAccountsTemplate();
} }
} }
@@ -8,9 +8,8 @@ describe('CreateGlAccountComponent', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ CreateGlAccountComponent ] declarations: [CreateGlAccountComponent]
}) }).compileComponents();
.compileComponents();
})); }));
beforeEach(() => { beforeEach(() => {
@@ -22,7 +22,6 @@ import { GLAccount } from 'app/shared/models/general.model';
styleUrls: ['./create-gl-account.component.scss'] styleUrls: ['./create-gl-account.component.scss']
}) })
export class CreateGlAccountComponent implements OnInit, AfterViewInit { export class CreateGlAccountComponent implements OnInit, AfterViewInit {
/** GL account form. */ /** GL account form. */
glAccountForm: UntypedFormGroup; glAccountForm: UntypedFormGroup;
/** Chart of accounts data. */ /** Chart of accounts data. */
@@ -57,14 +56,16 @@ export class CreateGlAccountComponent implements OnInit, AfterViewInit {
* @param {PopoverService} popoverService PopoverService. * @param {PopoverService} popoverService PopoverService.
* @param {Matdialog} dialog Matdialog. * @param {Matdialog} dialog Matdialog.
*/ */
constructor(private formBuilder: UntypedFormBuilder, constructor(
private formBuilder: UntypedFormBuilder,
private accountingService: AccountingService, private accountingService: AccountingService,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router, private router: Router,
private configurationWizardService: ConfigurationWizardService, private configurationWizardService: ConfigurationWizardService,
private popoverService: PopoverService, private popoverService: PopoverService,
public dialog: MatDialog) { public dialog: MatDialog
this.route.queryParamMap.subscribe(params => { ) {
this.route.queryParamMap.subscribe((params) => {
this.accountTypeId = Number(params.get('accountType')); this.accountTypeId = Number(params.get('accountType'));
this.parentId = Number(params.get('parent')); this.parentId = Number(params.get('parent'));
if (this.parentId) { if (this.parentId) {
@@ -92,14 +93,26 @@ export class CreateGlAccountComponent implements OnInit, AfterViewInit {
*/ */
createGlAccountForm() { createGlAccountForm() {
this.glAccountForm = this.formBuilder.group({ this.glAccountForm = this.formBuilder.group({
'type': ['', Validators.required], type: [
'name': ['', Validators.required], '',
'usage': ['', Validators.required], Validators.required
'glCode': ['', Validators.required], ],
'parentId': [this.parentId || undefined], name: [
'tagId': [''], '',
'manualEntriesAllowed': [true], Validators.required
'description': [''] ],
usage: [
'',
Validators.required
],
glCode: [
'',
Validators.required
],
parentId: [this.parentId || undefined],
tagId: [''],
manualEntriesAllowed: [true],
description: ['']
}); });
} }
@@ -107,21 +120,26 @@ export class CreateGlAccountComponent implements OnInit, AfterViewInit {
* Sets gl account form for selected account type. * Sets gl account form for selected account type.
*/ */
setGLAccountForm() { setGLAccountForm() {
this.glAccountForm.get('type').valueChanges.subscribe(accountTypeId => { this.glAccountForm.get('type').valueChanges.subscribe((accountTypeId) => {
switch (accountTypeId) { switch (accountTypeId) {
case 1: this.parentData = this.chartOfAccountsData.assetHeaderAccountOptions; case 1:
this.parentData = this.chartOfAccountsData.assetHeaderAccountOptions;
this.tagData = this.chartOfAccountsData.allowedAssetsTagOptions; this.tagData = this.chartOfAccountsData.allowedAssetsTagOptions;
break; break;
case 2: this.parentData = this.chartOfAccountsData.liabilityHeaderAccountOptions; case 2:
this.parentData = this.chartOfAccountsData.liabilityHeaderAccountOptions;
this.tagData = this.chartOfAccountsData.allowedLiabilitiesTagOptions; this.tagData = this.chartOfAccountsData.allowedLiabilitiesTagOptions;
break; break;
case 3: this.parentData = this.chartOfAccountsData.equityHeaderAccountOptions; case 3:
this.parentData = this.chartOfAccountsData.equityHeaderAccountOptions;
this.tagData = this.chartOfAccountsData.allowedEquityTagOptions; this.tagData = this.chartOfAccountsData.allowedEquityTagOptions;
break; break;
case 4: this.parentData = this.chartOfAccountsData.incomeHeaderAccountOptions; case 4:
this.parentData = this.chartOfAccountsData.incomeHeaderAccountOptions;
this.tagData = this.chartOfAccountsData.allowedIncomeTagOptions; this.tagData = this.chartOfAccountsData.allowedIncomeTagOptions;
break; break;
case 5: this.parentData = this.chartOfAccountsData.expenseHeaderAccountOptions; case 5:
this.parentData = this.chartOfAccountsData.expenseHeaderAccountOptions;
this.tagData = this.chartOfAccountsData.allowedExpensesTagOptions; this.tagData = this.chartOfAccountsData.allowedExpensesTagOptions;
break; break;
} }
@@ -140,7 +158,13 @@ export class CreateGlAccountComponent implements OnInit, AfterViewInit {
this.configurationWizardService.showChartofAccounts = false; this.configurationWizardService.showChartofAccounts = false;
this.openDialog(); this.openDialog();
} else { } else {
this.router.navigate(['../view', response.resourceId], { relativeTo: this.route }); this.router.navigate(
[
'../view',
response.resourceId
],
{ relativeTo: this.route }
);
} }
}); });
} }
@@ -152,7 +176,12 @@ export class CreateGlAccountComponent implements OnInit, AfterViewInit {
* @param position String. * @param position String.
* @param backdrop Boolean. * @param backdrop Boolean.
*/ */
showPopover(template: TemplateRef<any>, target: HTMLElement | ElementRef<any>, position: string, backdrop: boolean): void { showPopover(
template: TemplateRef<any>,
target: HTMLElement | ElementRef<any>,
position: string,
backdrop: boolean
): void {
setTimeout(() => this.popoverService.open(template, target, position, backdrop, {}), 200); setTimeout(() => this.popoverService.open(template, target, position, backdrop, {}), 200);
} }
@@ -192,7 +221,7 @@ export class CreateGlAccountComponent implements OnInit, AfterViewInit {
const continueSetupDialogRef = this.dialog.open(ContinueSetupDialogComponent, { const continueSetupDialogRef = this.dialog.open(ContinueSetupDialogComponent, {
data: { data: {
stepName: 'GL account' stepName: 'GL account'
}, }
}); });
continueSetupDialogRef.afterClosed().subscribe((response: { step: number }) => { continueSetupDialogRef.afterClosed().subscribe((response: { step: number }) => {
if (response.step === 1) { if (response.step === 1) {
@@ -8,9 +8,8 @@ describe('EditGlAccountComponent', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ EditGlAccountComponent ] declarations: [EditGlAccountComponent]
}) }).compileComponents();
.compileComponents();
})); }));
beforeEach(() => { beforeEach(() => {
@@ -15,7 +15,6 @@ import { AccountingService } from '../../accounting.service';
styleUrls: ['./edit-gl-account.component.scss'] styleUrls: ['./edit-gl-account.component.scss']
}) })
export class EditGlAccountComponent implements OnInit { export class EditGlAccountComponent implements OnInit {
/** GL account form. */ /** GL account form. */
glAccountForm: UntypedFormGroup; glAccountForm: UntypedFormGroup;
/** GL account and chart of accounts data. */ /** GL account and chart of accounts data. */
@@ -36,10 +35,12 @@ export class EditGlAccountComponent implements OnInit {
* @param {ActivatedRoute} route Activated Route. * @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation. * @param {Router} router Router for navigation.
*/ */
constructor(private formBuilder: UntypedFormBuilder, constructor(
private formBuilder: UntypedFormBuilder,
private accountingService: AccountingService, private accountingService: AccountingService,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router) { private router: Router
) {
this.route.data.subscribe((data: { glAccountAndChartOfAccountsTemplate: any }) => { this.route.data.subscribe((data: { glAccountAndChartOfAccountsTemplate: any }) => {
this.glAccount = data.glAccountAndChartOfAccountsTemplate; this.glAccount = data.glAccountAndChartOfAccountsTemplate;
}); });
@@ -58,14 +59,29 @@ export class EditGlAccountComponent implements OnInit {
*/ */
createGlAccountForm() { createGlAccountForm() {
this.glAccountForm = this.formBuilder.group({ this.glAccountForm = this.formBuilder.group({
'type': ['', Validators.required], type: [
'name': [this.glAccount.name, Validators.required], '',
'usage': [this.glAccount.usage.id, Validators.required], Validators.required
'glCode': [this.glAccount.glCode, Validators.required], ],
'parentId': [this.glAccount.parentId], name: [
'tagId': [this.glAccount.tagId.id], this.glAccount.name,
'manualEntriesAllowed': [this.glAccount.manualEntriesAllowed, Validators.required], Validators.required
'description': [this.glAccount.description] ],
usage: [
this.glAccount.usage.id,
Validators.required
],
glCode: [
this.glAccount.glCode,
Validators.required
],
parentId: [this.glAccount.parentId],
tagId: [this.glAccount.tagId.id],
manualEntriesAllowed: [
this.glAccount.manualEntriesAllowed,
Validators.required
],
description: [this.glAccount.description]
}); });
} }
@@ -75,21 +91,26 @@ export class EditGlAccountComponent implements OnInit {
setGLAccountForm() { setGLAccountForm() {
this.accountTypeData = this.glAccount.accountTypeOptions; this.accountTypeData = this.glAccount.accountTypeOptions;
this.accountUsageData = this.glAccount.usageOptions; this.accountUsageData = this.glAccount.usageOptions;
this.glAccountForm.get('type').valueChanges.subscribe(accountTypeId => { this.glAccountForm.get('type').valueChanges.subscribe((accountTypeId) => {
switch (accountTypeId) { switch (accountTypeId) {
case 1: this.parentData = this.glAccount.assetHeaderAccountOptions; case 1:
this.parentData = this.glAccount.assetHeaderAccountOptions;
this.tagData = this.glAccount.allowedAssetsTagOptions; this.tagData = this.glAccount.allowedAssetsTagOptions;
break; break;
case 2: this.parentData = this.glAccount.liabilityHeaderAccountOptions; case 2:
this.parentData = this.glAccount.liabilityHeaderAccountOptions;
this.tagData = this.glAccount.allowedLiabilitiesTagOptions; this.tagData = this.glAccount.allowedLiabilitiesTagOptions;
break; break;
case 3: this.parentData = this.glAccount.equityHeaderAccountOptions; case 3:
this.parentData = this.glAccount.equityHeaderAccountOptions;
this.tagData = this.glAccount.allowedEquityTagOptions; this.tagData = this.glAccount.allowedEquityTagOptions;
break; break;
case 4: this.parentData = this.glAccount.incomeHeaderAccountOptions; case 4:
this.parentData = this.glAccount.incomeHeaderAccountOptions;
this.tagData = this.glAccount.allowedIncomeTagOptions; this.tagData = this.glAccount.allowedIncomeTagOptions;
break; break;
case 5: this.parentData = this.glAccount.expenseHeaderAccountOptions; case 5:
this.parentData = this.glAccount.expenseHeaderAccountOptions;
this.tagData = this.glAccount.allowedExpensesTagOptions; this.tagData = this.glAccount.allowedExpensesTagOptions;
break; break;
} }
@@ -103,10 +124,14 @@ export class EditGlAccountComponent implements OnInit {
* if successful redirects to view updated account. * if successful redirects to view updated account.
*/ */
submit() { submit() {
this.accountingService.updateGlAccount(this.glAccount.id, this.glAccountForm.value) this.accountingService.updateGlAccount(this.glAccount.id, this.glAccountForm.value).subscribe((response: any) => {
.subscribe((response: any) => { this.router.navigate(
this.router.navigate(['../../', response.resourceId], { relativeTo: this.route }); [
'../../',
response.resourceId
],
{ relativeTo: this.route }
);
}); });
} }
} }
@@ -14,7 +14,6 @@ import { AccountingService } from '../accounting.service';
*/ */
@Injectable() @Injectable()
export class GlAccountAndChartOfAccountsTemplateResolver implements Resolve<Object> { export class GlAccountAndChartOfAccountsTemplateResolver implements Resolve<Object> {
/** /**
* @param {AccountingService} accountingService Accounting service. * @param {AccountingService} accountingService Accounting service.
*/ */
@@ -31,15 +30,20 @@ export class GlAccountAndChartOfAccountsTemplateResolver implements Resolve<Obje
map((glAccountData: any) => { map((glAccountData: any) => {
let accountOptions = []; let accountOptions = [];
switch (glAccountData.type.value) { switch (glAccountData.type.value) {
case 'ASSET': accountOptions = glAccountData.assetHeaderAccountOptions; case 'ASSET':
accountOptions = glAccountData.assetHeaderAccountOptions;
break; break;
case 'EQUITY': accountOptions = glAccountData.equityHeaderAccountOptions; case 'EQUITY':
accountOptions = glAccountData.equityHeaderAccountOptions;
break; break;
case 'EXPENSE': accountOptions = glAccountData.expenseHeaderAccountOptions; case 'EXPENSE':
accountOptions = glAccountData.expenseHeaderAccountOptions;
break; break;
case 'INCOME': accountOptions = glAccountData.incomeHeaderAccountOptions; case 'INCOME':
accountOptions = glAccountData.incomeHeaderAccountOptions;
break; break;
case 'LIABILITY': accountOptions = glAccountData.liabilityHeaderAccountOptions; case 'LIABILITY':
accountOptions = glAccountData.liabilityHeaderAccountOptions;
break; break;
} }
if (glAccountData.parentId) { if (glAccountData.parentId) {
@@ -51,5 +55,4 @@ export class GlAccountAndChartOfAccountsTemplateResolver implements Resolve<Obje
}) })
); );
} }
} }
@@ -2,7 +2,6 @@
* GL Account Node model. * GL Account Node model.
*/ */
export class GLAccountNode { export class GLAccountNode {
/** GL Account Node children. */ /** GL Account Node children. */
children: GLAccountNode[]; children: GLAccountNode[];
@@ -13,12 +12,14 @@ export class GLAccountNode {
manualEntriesAllowed: boolean; manualEntriesAllowed: boolean;
description: string; description: string;
constructor(name: string, constructor(
name: string,
glCode: string = '', glCode: string = '',
type: string = '', type: string = '',
usage: string = '', usage: string = '',
manualEntriesAllowed: boolean = false, manualEntriesAllowed: boolean = false,
description: string = '') { description: string = ''
) {
this.name = name; this.name = name;
this.glCode = glCode; this.glCode = glCode;
this.type = type; this.type = type;
@@ -27,5 +28,4 @@ export class GLAccountNode {
this.description = description; this.description = description;
this.children = []; this.children = [];
} }
} }
@@ -16,7 +16,6 @@ import { GLAccount } from 'app/shared/models/general.model';
providedIn: 'root' providedIn: 'root'
}) })
export class GlAccountTreeService { export class GlAccountTreeService {
/** GL Account data. */ /** GL Account data. */
glAccountData: any; glAccountData: any;
/** Chart of accounts tree data behavior subject to represent chart of accounts tree nodes. */ /** Chart of accounts tree data behavior subject to represent chart of accounts tree nodes. */
@@ -25,10 +24,11 @@ export class GlAccountTreeService {
/** /**
* Gets the chart of accounts tree nodes. * Gets the chart of accounts tree nodes.
*/ */
get treeData(): GLAccountNode[] { return this.treeDataChange.value; } get treeData(): GLAccountNode[] {
return this.treeDataChange.value;
}
constructor( constructor(private translateService: TranslateService) {}
private translateService: TranslateService) { }
/** /**
* Builds the chart of accounts tree and emits the value. * Builds the chart of accounts tree and emits the value.
@@ -51,9 +51,13 @@ export class GlAccountTreeService {
glAccountTree.push(new GLAccountNode('ACCOUNTS')); glAccountTree.push(new GLAccountNode('ACCOUNTS'));
glAccountTree[0].children.push(new GLAccountNode(this.translateService.instant('labels.inputs.accounting.ASSET'))); glAccountTree[0].children.push(new GLAccountNode(this.translateService.instant('labels.inputs.accounting.ASSET')));
glAccountTree[0].children.push(new GLAccountNode(this.translateService.instant('labels.inputs.accounting.EQUITY'))); glAccountTree[0].children.push(new GLAccountNode(this.translateService.instant('labels.inputs.accounting.EQUITY')));
glAccountTree[0].children.push(new GLAccountNode(this.translateService.instant('labels.inputs.accounting.EXPENSE'))); glAccountTree[0].children.push(
new GLAccountNode(this.translateService.instant('labels.inputs.accounting.EXPENSE'))
);
glAccountTree[0].children.push(new GLAccountNode(this.translateService.instant('labels.inputs.accounting.INCOME'))); glAccountTree[0].children.push(new GLAccountNode(this.translateService.instant('labels.inputs.accounting.INCOME')));
glAccountTree[0].children.push(new GLAccountNode(this.translateService.instant('labels.inputs.accounting.LIABILITY'))); glAccountTree[0].children.push(
new GLAccountNode(this.translateService.instant('labels.inputs.accounting.LIABILITY'))
);
// Sort by parent id (so that child nodes can be added properly) // Sort by parent id (so that child nodes can be added properly)
if (!glAccountData[0].parentId) { if (!glAccountData[0].parentId) {
@@ -70,8 +74,14 @@ export class GlAccountTreeService {
// Add gl accounts to any array where index for each is denoted by its id // Add gl accounts to any array where index for each is denoted by its id
for (const glAccount of glAccountData) { for (const glAccount of glAccountData) {
glAccounts[glAccount.id] = glAccounts[glAccount.id] = new GLAccountNode(
new GLAccountNode(glAccount.name, glAccount.glCode, glAccount.type.value, glAccount.usage.value, glAccount.manualEntriesAllowed, glAccount.description); glAccount.name,
glAccount.glCode,
glAccount.type.value,
glAccount.usage.value,
glAccount.manualEntriesAllowed,
glAccount.description
);
} }
// Construct gl account tree by adding all nodes belonging to headers (with parent id = 0) by their type, // Construct gl account tree by adding all nodes belonging to headers (with parent id = 0) by their type,
@@ -99,5 +109,4 @@ export class GlAccountTreeService {
return glAccountTree; return glAccountTree;
} }
} }
@@ -8,9 +8,8 @@ describe('ViewGlAccountComponent', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ ViewGlAccountComponent ] declarations: [ViewGlAccountComponent]
}) }).compileComponents();
.compileComponents();
})); }));
beforeEach(() => { beforeEach(() => {
@@ -19,7 +19,6 @@ import { Location } from '@angular/common';
styleUrls: ['./view-gl-account.component.scss'] styleUrls: ['./view-gl-account.component.scss']
}) })
export class ViewGlAccountComponent { export class ViewGlAccountComponent {
/** GL Account. */ /** GL Account. */
glAccount: any; glAccount: any;
@@ -30,11 +29,13 @@ export class ViewGlAccountComponent {
* @param {Router} router Router for navigation. * @param {Router} router Router for navigation.
* @param {MatDialog} dialog Dialog reference. * @param {MatDialog} dialog Dialog reference.
*/ */
constructor(private accountingService: AccountingService, constructor(
private accountingService: AccountingService,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router, private router: Router,
private dialog: MatDialog, private dialog: MatDialog,
private location: Location) { private location: Location
) {
this.route.data.subscribe((data: { glAccountAndChartOfAccountsTemplate: any }) => { this.route.data.subscribe((data: { glAccountAndChartOfAccountsTemplate: any }) => {
this.glAccount = data.glAccountAndChartOfAccountsTemplate; this.glAccount = data.glAccountAndChartOfAccountsTemplate;
}); });
@@ -49,8 +50,7 @@ export class ViewGlAccountComponent {
}); });
deleteGlAccountDialogRef.afterClosed().subscribe((response: any) => { deleteGlAccountDialogRef.afterClosed().subscribe((response: any) => {
if (response.delete) { if (response.delete) {
this.accountingService.deleteGlAccount(this.glAccount.id) this.accountingService.deleteGlAccount(this.glAccount.id).subscribe(() => {
.subscribe(() => {
this.router.navigate(['/accounting/chart-of-accounts']); this.router.navigate(['/accounting/chart-of-accounts']);
}); });
} }
@@ -61,7 +61,8 @@ export class ViewGlAccountComponent {
* Changes state of gl account. (enabled/disabled) * Changes state of gl account. (enabled/disabled)
*/ */
changeGlAccountState() { changeGlAccountState() {
this.accountingService.updateGlAccount(this.glAccount.id, { disabled: !this.glAccount.disabled }) this.accountingService
.updateGlAccount(this.glAccount.id, { disabled: !this.glAccount.disabled })
.subscribe((response: any) => { .subscribe((response: any) => {
this.glAccount.disabled = response.changes.disabled; this.glAccount.disabled = response.changes.disabled;
}); });
@@ -70,5 +71,4 @@ export class ViewGlAccountComponent {
goBack(): void { goBack(): void {
this.location.back(); this.location.back();
} }
} }
@@ -8,9 +8,8 @@ describe('ClosingEntriesComponent', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ ClosingEntriesComponent ] declarations: [ClosingEntriesComponent]
}) }).compileComponents();
.compileComponents();
})); }));
beforeEach(() => { beforeEach(() => {
@@ -22,9 +22,13 @@ import { ConfigurationWizardService } from '../../configuration-wizard/configura
styleUrls: ['./closing-entries.component.scss'] styleUrls: ['./closing-entries.component.scss']
}) })
export class ClosingEntriesComponent implements OnInit, AfterViewInit { export class ClosingEntriesComponent implements OnInit, AfterViewInit {
/** Columns to be displayed in closing entries table. */ /** Columns to be displayed in closing entries table. */
displayedColumns: string[] = ['officeName', 'closingDate', 'comments', 'createdByUsername']; displayedColumns: string[] = [
'officeName',
'closingDate',
'comments',
'createdByUsername'
];
/** Data source for closing entries table. */ /** Data source for closing entries table. */
dataSource: MatTableDataSource<any>; dataSource: MatTableDataSource<any>;
/** Office name filter form control. */ /** Office name filter form control. */
@@ -57,14 +61,13 @@ export class ClosingEntriesComponent implements OnInit, AfterViewInit {
* @param {ConfigurationWizardService} configurationWizardService ConfigurationWizard Service. * @param {ConfigurationWizardService} configurationWizardService ConfigurationWizard Service.
* @param {PopoverService} popoverService PopoverService. * @param {PopoverService} popoverService PopoverService.
*/ */
constructor(private route: ActivatedRoute, constructor(
private route: ActivatedRoute,
private router: Router, private router: Router,
private configurationWizardService: ConfigurationWizardService, private configurationWizardService: ConfigurationWizardService,
private popoverService: PopoverService) { private popoverService: PopoverService
this.route.data.subscribe((data: { ) {
offices: any, this.route.data.subscribe((data: { offices: any; glAccountClosures: any }) => {
glAccountClosures: any
}) => {
this.officeData = data.offices; this.officeData = data.offices;
this.glAccountClosureData = data.glAccountClosures; this.glAccountClosureData = data.glAccountClosures;
}); });
@@ -101,11 +104,10 @@ export class ClosingEntriesComponent implements OnInit, AfterViewInit {
* Sets filtered offices for autocomplete. * Sets filtered offices for autocomplete.
*/ */
setFilteredOffices() { setFilteredOffices() {
this.filteredOfficeData = this.officeName.valueChanges this.filteredOfficeData = this.officeName.valueChanges.pipe(
.pipe(
startWith(''), startWith(''),
map((office: any) => typeof office === 'string' ? office : office.name), map((office: any) => (typeof office === 'string' ? office : office.name)),
map((officeName: string) => officeName ? this.filterOfficeAutocompleteData(officeName) : this.officeData) map((officeName: string) => (officeName ? this.filterOfficeAutocompleteData(officeName) : this.officeData))
); );
} }
@@ -125,7 +127,12 @@ export class ClosingEntriesComponent implements OnInit, AfterViewInit {
* @param position String. * @param position String.
* @param backdrop Boolean. * @param backdrop Boolean.
*/ */
showPopover(template: TemplateRef<any>, target: HTMLElement | ElementRef<any>, position: string, backdrop: boolean): void { showPopover(
template: TemplateRef<any>,
target: HTMLElement | ElementRef<any>,
position: string,
backdrop: boolean
): void {
setTimeout(() => this.popoverService.open(template, target, position, backdrop, {}), 200); setTimeout(() => this.popoverService.open(template, target, position, backdrop, {}), 200);
} }
@@ -13,7 +13,6 @@ import { AccountingService } from '../accounting.service';
*/ */
@Injectable() @Injectable()
export class ClosingEntriesResolver implements Resolve<Object> { export class ClosingEntriesResolver implements Resolve<Object> {
/** /**
* @param {AccountingService} accountingService Accounting service. * @param {AccountingService} accountingService Accounting service.
*/ */
@@ -26,5 +25,4 @@ export class ClosingEntriesResolver implements Resolve<Object> {
resolve(): Observable<any> { resolve(): Observable<any> {
return this.accountingService.getAccountingClosures(); return this.accountingService.getAccountingClosures();
} }
} }
@@ -13,7 +13,6 @@ import { AccountingService } from '../accounting.service';
*/ */
@Injectable() @Injectable()
export class ClosingEntryResolver implements Resolve<Object> { export class ClosingEntryResolver implements Resolve<Object> {
/** /**
* @param {AccountingService} accountingService Accounting service. * @param {AccountingService} accountingService Accounting service.
*/ */
@@ -27,5 +26,4 @@ export class ClosingEntryResolver implements Resolve<Object> {
const glAccountClosureId = route.paramMap.get('id'); const glAccountClosureId = route.paramMap.get('id');
return this.accountingService.getAccountingClosure(glAccountClosureId); return this.accountingService.getAccountingClosure(glAccountClosureId);
} }
} }
@@ -8,9 +8,8 @@ describe('CreateClosureComponent', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ CreateClosureComponent ] declarations: [CreateClosureComponent]
}) }).compileComponents();
.compileComponents();
})); }));
beforeEach(() => { beforeEach(() => {
@@ -16,7 +16,6 @@ import { Dates } from 'app/core/utils/dates';
styleUrls: ['./create-closure.component.scss'] styleUrls: ['./create-closure.component.scss']
}) })
export class CreateClosureComponent implements OnInit { export class CreateClosureComponent implements OnInit {
/** Minimum closing date allowed. */ /** Minimum closing date allowed. */
minDate = new Date(2000, 0, 1); minDate = new Date(2000, 0, 1);
/** Maximum closing date allowed. */ /** Maximum closing date allowed. */
@@ -34,12 +33,14 @@ export class CreateClosureComponent implements OnInit {
* @param {ActivatedRoute} route Activated Route. * @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation. * @param {Router} router Router for navigation.
*/ */
constructor(private formBuilder: UntypedFormBuilder, constructor(
private formBuilder: UntypedFormBuilder,
private accountingService: AccountingService, private accountingService: AccountingService,
private settingsService: SettingsService, private settingsService: SettingsService,
private dateUtils: Dates, private dateUtils: Dates,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router) { private router: Router
) {
this.route.data.subscribe((data: { offices: any }) => { this.route.data.subscribe((data: { offices: any }) => {
this.officeData = data.offices; this.officeData = data.offices;
}); });
@@ -58,9 +59,15 @@ export class CreateClosureComponent implements OnInit {
*/ */
createAccountingClosureForm() { createAccountingClosureForm() {
this.accountingClosureForm = this.formBuilder.group({ this.accountingClosureForm = this.formBuilder.group({
'officeId': ['', Validators.required], officeId: [
'closingDate': ['', Validators.required], '',
'comments': [''] Validators.required
],
closingDate: [
'',
Validators.required
],
comments: ['']
}); });
} }
@@ -74,11 +81,19 @@ export class CreateClosureComponent implements OnInit {
accountingClosure.locale = this.settingsService.language.code; accountingClosure.locale = this.settingsService.language.code;
accountingClosure.dateFormat = this.settingsService.dateFormat; accountingClosure.dateFormat = this.settingsService.dateFormat;
if (accountingClosure.closingDate) { if (accountingClosure.closingDate) {
accountingClosure.closingDate = this.dateUtils.formatDate(accountingClosure.closingDate, this.settingsService.dateFormat); accountingClosure.closingDate = this.dateUtils.formatDate(
accountingClosure.closingDate,
this.settingsService.dateFormat
);
} }
this.accountingService.createAccountingClosure(accountingClosure).subscribe((response: any) => { this.accountingService.createAccountingClosure(accountingClosure).subscribe((response: any) => {
this.router.navigate(['../view', response.resourceId], { relativeTo: this.route }); this.router.navigate(
[
'../view',
response.resourceId
],
{ relativeTo: this.route }
);
}); });
} }
} }
@@ -8,9 +8,8 @@ describe('EditClosureComponent', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ EditClosureComponent ] declarations: [EditClosureComponent]
}) }).compileComponents();
.compileComponents();
})); }));
beforeEach(() => { beforeEach(() => {
@@ -15,7 +15,6 @@ import { AccountingService } from '../../accounting.service';
styleUrls: ['./edit-closure.component.scss'] styleUrls: ['./edit-closure.component.scss']
}) })
export class EditClosureComponent implements OnInit { export class EditClosureComponent implements OnInit {
/** Accounting closure form. */ /** Accounting closure form. */
accountingClosureForm: UntypedFormGroup; accountingClosureForm: UntypedFormGroup;
/** GL Account closure. */ /** GL Account closure. */
@@ -30,10 +29,12 @@ export class EditClosureComponent implements OnInit {
* @param {ActivatedRoute} route Activated Route. * @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation. * @param {Router} router Router for navigation.
*/ */
constructor(private formBuilder: UntypedFormBuilder, constructor(
private formBuilder: UntypedFormBuilder,
private accountingService: AccountingService, private accountingService: AccountingService,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router) { private router: Router
) {
this.route.data.subscribe((data: { glAccountClosure: any }) => { this.route.data.subscribe((data: { glAccountClosure: any }) => {
this.glAccountClosure = data.glAccountClosure; this.glAccountClosure = data.glAccountClosure;
}); });
@@ -52,9 +53,15 @@ export class EditClosureComponent implements OnInit {
*/ */
createAccountingClosureForm() { createAccountingClosureForm() {
this.accountingClosureForm = this.formBuilder.group({ this.accountingClosureForm = this.formBuilder.group({
'officeId': [{ value: '', disabled: true }, Validators.required], officeId: [
'closingDate': [{ value: '', disabled: true }, Validators.required], { value: '', disabled: true },
'comments': [''] Validators.required
],
closingDate: [
{ value: '', disabled: true },
Validators.required
],
comments: ['']
}); });
} }
@@ -68,17 +75,21 @@ export class EditClosureComponent implements OnInit {
this.accountingClosureForm.get('comments').setValue(this.glAccountClosure.comments); this.accountingClosureForm.get('comments').setValue(this.glAccountClosure.comments);
} }
/** /**
* Submits the accounting closure form and updates accounting closure, * Submits the accounting closure form and updates accounting closure,
* if successful redirects to view updated closure. * if successful redirects to view updated closure.
*/ */
submit() { submit() {
this.accountingService.updateAccountingClosure(this.glAccountClosure.id, this.accountingService
{ comments: this.accountingClosureForm.value.comments }) .updateAccountingClosure(this.glAccountClosure.id, { comments: this.accountingClosureForm.value.comments })
.subscribe((response: any) => { .subscribe((response: any) => {
this.router.navigate(['../../', response.resourceId], { relativeTo: this.route }); this.router.navigate(
[
'../../',
response.resourceId
],
{ relativeTo: this.route }
);
}); });
} }
} }
@@ -8,9 +8,8 @@ describe('ViewClosureComponent', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ ViewClosureComponent ] declarations: [ViewClosureComponent]
}) }).compileComponents();
.compileComponents();
})); }));
beforeEach(() => { beforeEach(() => {
@@ -18,7 +18,6 @@ import { DeleteDialogComponent } from '../../../shared/delete-dialog/delete-dial
styleUrls: ['./view-closure.component.scss'] styleUrls: ['./view-closure.component.scss']
}) })
export class ViewClosureComponent { export class ViewClosureComponent {
/** GL Account closure. */ /** GL Account closure. */
glAccountClosure: any; glAccountClosure: any;
@@ -29,10 +28,12 @@ export class ViewClosureComponent {
* @param {Router} router Router for navigation. * @param {Router} router Router for navigation.
* @param {MatDialog} dialog Dialog reference. * @param {MatDialog} dialog Dialog reference.
*/ */
constructor(private accountingService: AccountingService, constructor(
private accountingService: AccountingService,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router, private router: Router,
public dialog: MatDialog) { public dialog: MatDialog
) {
this.route.data.subscribe((data: { glAccountClosure: any }) => { this.route.data.subscribe((data: { glAccountClosure: any }) => {
this.glAccountClosure = data.glAccountClosure; this.glAccountClosure = data.glAccountClosure;
}); });
@@ -47,12 +48,10 @@ export class ViewClosureComponent {
}); });
deleteAccountingClosureDialogRef.afterClosed().subscribe((response: any) => { deleteAccountingClosureDialogRef.afterClosed().subscribe((response: any) => {
if (response.delete) { if (response.delete) {
this.accountingService.deleteAccountingClosure(this.glAccountClosure.id) this.accountingService.deleteAccountingClosure(this.glAccountClosure.id).subscribe(() => {
.subscribe(() => {
this.router.navigate(['/accounting/closing-entries']); this.router.navigate(['/accounting/closing-entries']);
}); });
} }
}); });
} }
} }
@@ -13,7 +13,6 @@ import { AccountingService } from '../accounting.service';
*/ */
@Injectable() @Injectable()
export class AccountingRulesAssociationsResolver implements Resolve<Object> { export class AccountingRulesAssociationsResolver implements Resolve<Object> {
/** /**
* @param {AccountingService} accountingService Accounting service. * @param {AccountingService} accountingService Accounting service.
*/ */
@@ -26,5 +25,4 @@ export class AccountingRulesAssociationsResolver implements Resolve<Object> {
resolve(): Observable<any> { resolve(): Observable<any> {
return this.accountingService.getAccountingRules(true); return this.accountingService.getAccountingRules(true);
} }
} }
@@ -13,7 +13,6 @@ import { AccountingService } from '../accounting.service';
*/ */
@Injectable() @Injectable()
export class CurrenciesResolver implements Resolve<Object> { export class CurrenciesResolver implements Resolve<Object> {
/** /**
* @param {AccountingService} accountingService Accounting service. * @param {AccountingService} accountingService Accounting service.
*/ */
@@ -26,5 +25,4 @@ export class CurrenciesResolver implements Resolve<Object> {
resolve(): Observable<any> { resolve(): Observable<any> {
return this.accountingService.getCurrencies(); return this.accountingService.getCurrencies();
} }
} }
@@ -13,7 +13,6 @@ import { AccountingService } from '../accounting.service';
*/ */
@Injectable() @Injectable()
export class GlAccountsResolver implements Resolve<Object> { export class GlAccountsResolver implements Resolve<Object> {
/** /**
* @param {AccountingService} accountingService Accounting service. * @param {AccountingService} accountingService Accounting service.
*/ */
@@ -26,5 +25,4 @@ export class GlAccountsResolver implements Resolve<Object> {
resolve(): Observable<any> { resolve(): Observable<any> {
return this.accountingService.getGlAccounts(); return this.accountingService.getGlAccounts();
} }
} }
@@ -13,7 +13,6 @@ import { AccountingService } from '../accounting.service';
*/ */
@Injectable() @Injectable()
export class JournalEntryTransactionResolver implements Resolve<Object> { export class JournalEntryTransactionResolver implements Resolve<Object> {
/** /**
* @param {AccountingService} accountingService Accounting service. * @param {AccountingService} accountingService Accounting service.
*/ */
@@ -27,5 +26,4 @@ export class JournalEntryTransactionResolver implements Resolve<Object> {
const transactionId = route.paramMap.get('id'); const transactionId = route.paramMap.get('id');
return this.accountingService.getJournalEntry(transactionId); return this.accountingService.getJournalEntry(transactionId);
} }
} }
@@ -13,7 +13,6 @@ import { AccountingService } from '../accounting.service';
*/ */
@Injectable() @Injectable()
export class LoanProductsResolver implements Resolve<Object> { export class LoanProductsResolver implements Resolve<Object> {
/** /**
* @param {AccountingService} accountingService Accounting service. * @param {AccountingService} accountingService Accounting service.
*/ */
@@ -26,5 +25,4 @@ export class LoanProductsResolver implements Resolve<Object> {
resolve(): Observable<any> { resolve(): Observable<any> {
return this.accountingService.getLoanProducts(); return this.accountingService.getLoanProducts();
} }
} }
@@ -13,7 +13,6 @@ import { AccountingService } from '../accounting.service';
*/ */
@Injectable() @Injectable()
export class OfficesResolver implements Resolve<Object> { export class OfficesResolver implements Resolve<Object> {
/** /**
* @param {AccountingService} accountingService Accounting service. * @param {AccountingService} accountingService Accounting service.
*/ */
@@ -26,5 +25,4 @@ export class OfficesResolver implements Resolve<Object> {
resolve(): Observable<any> { resolve(): Observable<any> {
return this.accountingService.getOffices(); return this.accountingService.getOffices();
} }
} }
@@ -13,7 +13,6 @@ import { AccountingService } from '../accounting.service';
*/ */
@Injectable() @Injectable()
export class PaymentTypesResolver implements Resolve<Object> { export class PaymentTypesResolver implements Resolve<Object> {
/** /**
* @param {AccountingService} accountingService Accounting service. * @param {AccountingService} accountingService Accounting service.
*/ */
@@ -26,5 +25,4 @@ export class PaymentTypesResolver implements Resolve<Object> {
resolve(): Observable<any> { resolve(): Observable<any> {
return this.accountingService.getPaymentTypes(); return this.accountingService.getPaymentTypes();
} }
} }
@@ -13,7 +13,6 @@ import { AccountingService } from '../accounting.service';
*/ */
@Injectable() @Injectable()
export class ProvisioningCategoriesResolver implements Resolve<Object> { export class ProvisioningCategoriesResolver implements Resolve<Object> {
/** /**
* @param {AccountingService} accountingService Accounting service. * @param {AccountingService} accountingService Accounting service.
*/ */
@@ -26,5 +25,4 @@ export class ProvisioningCategoriesResolver implements Resolve<Object> {
resolve(): Observable<any> { resolve(): Observable<any> {
return this.accountingService.getProvisioningCategories(); return this.accountingService.getProvisioningCategories();
} }
} }
@@ -8,9 +8,8 @@ describe('CreateJournalEntryComponent', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ CreateJournalEntryComponent ] declarations: [CreateJournalEntryComponent]
}) }).compileComponents();
.compileComponents();
})); }));
beforeEach(() => { beforeEach(() => {
@@ -22,7 +22,6 @@ import { NextStepDialogComponent } from '../../configuration-wizard/next-step-di
styleUrls: ['./create-journal-entry.component.scss'] styleUrls: ['./create-journal-entry.component.scss']
}) })
export class CreateJournalEntryComponent implements OnInit, AfterViewInit { export class CreateJournalEntryComponent implements OnInit, AfterViewInit {
/** Minimum transaction date allowed. */ /** Minimum transaction date allowed. */
minDate = new Date(2000, 0, 1); minDate = new Date(2000, 0, 1);
/** Maximum transaction date allowed. */ /** Maximum transaction date allowed. */
@@ -53,7 +52,8 @@ export class CreateJournalEntryComponent implements OnInit, AfterViewInit {
* @param {ConfigurationWizardService} configurationWizardService ConfigurationWizard Service. * @param {ConfigurationWizardService} configurationWizardService ConfigurationWizard Service.
* @param {PopoverService} popoverService PopoverService. * @param {PopoverService} popoverService PopoverService.
*/ */
constructor(private formBuilder: UntypedFormBuilder, constructor(
private formBuilder: UntypedFormBuilder,
private accountingService: AccountingService, private accountingService: AccountingService,
private settingsService: SettingsService, private settingsService: SettingsService,
private dateUtils: Dates, private dateUtils: Dates,
@@ -61,13 +61,9 @@ export class CreateJournalEntryComponent implements OnInit, AfterViewInit {
private router: Router, private router: Router,
private dialog: MatDialog, private dialog: MatDialog,
private configurationWizardService: ConfigurationWizardService, private configurationWizardService: ConfigurationWizardService,
private popoverService: PopoverService) { private popoverService: PopoverService
this.route.data.subscribe((data: { ) {
offices: any, this.route.data.subscribe((data: { offices: any; currencies: any; paymentTypes: any; glAccounts: any }) => {
currencies: any,
paymentTypes: any,
glAccounts: any
}) => {
this.officeData = data.offices; this.officeData = data.offices;
this.currencyData = data.currencies.selectedCurrencyOptions; this.currencyData = data.currencies.selectedCurrencyOptions;
this.paymentTypeData = data.paymentTypes; this.paymentTypeData = data.paymentTypes;
@@ -88,19 +84,28 @@ export class CreateJournalEntryComponent implements OnInit, AfterViewInit {
*/ */
createJournalEntryForm() { createJournalEntryForm() {
this.journalEntryForm = this.formBuilder.group({ this.journalEntryForm = this.formBuilder.group({
'officeId': ['', Validators.required], officeId: [
'currencyCode': ['', Validators.required], '',
'debits': this.formBuilder.array([this.createAffectedGLEntryForm()]), Validators.required
'credits': this.formBuilder.array([this.createAffectedGLEntryForm()]), ],
'referenceNumber': [''], currencyCode: [
'transactionDate': ['', Validators.required], '',
'paymentTypeId': [''], Validators.required
'accountNumber': [''], ],
'checkNumber': [''], debits: this.formBuilder.array([this.createAffectedGLEntryForm()]),
'routingCode': [''], credits: this.formBuilder.array([this.createAffectedGLEntryForm()]),
'receiptNumber': [''], referenceNumber: [''],
'bankNumber': [''], transactionDate: [
'comments': [''] '',
Validators.required
],
paymentTypeId: [''],
accountNumber: [''],
checkNumber: [''],
routingCode: [''],
receiptNumber: [''],
bankNumber: [''],
comments: ['']
}); });
} }
@@ -110,8 +115,14 @@ export class CreateJournalEntryComponent implements OnInit, AfterViewInit {
*/ */
createAffectedGLEntryForm(): UntypedFormGroup { createAffectedGLEntryForm(): UntypedFormGroup {
return this.formBuilder.group({ return this.formBuilder.group({
'glAccountId': ['', Validators.required], glAccountId: [
'amount': ['', Validators.required] '',
Validators.required
],
amount: [
'',
Validators.required
]
}); });
} }
@@ -158,10 +169,19 @@ export class CreateJournalEntryComponent implements OnInit, AfterViewInit {
journalEntry.locale = this.settingsService.language.code; journalEntry.locale = this.settingsService.language.code;
journalEntry.dateFormat = this.settingsService.dateFormat; journalEntry.dateFormat = this.settingsService.dateFormat;
if (journalEntry.transactionDate) { if (journalEntry.transactionDate) {
journalEntry.transactionDate = this.dateUtils.formatDate(journalEntry.transactionDate, this.settingsService.dateFormat); journalEntry.transactionDate = this.dateUtils.formatDate(
journalEntry.transactionDate,
this.settingsService.dateFormat
);
} }
this.accountingService.createJournalEntry(journalEntry).subscribe(response => { this.accountingService.createJournalEntry(journalEntry).subscribe((response) => {
this.router.navigate(['../transactions/view', response.transactionId], { relativeTo: this.route }); this.router.navigate(
[
'../transactions/view',
response.transactionId
],
{ relativeTo: this.route }
);
}); });
} }
@@ -172,7 +192,12 @@ export class CreateJournalEntryComponent implements OnInit, AfterViewInit {
* @param position String. * @param position String.
* @param backdrop Boolean. * @param backdrop Boolean.
*/ */
showPopover(template: TemplateRef<any>, target: HTMLElement | ElementRef<any>, position: string, backdrop: boolean): void { showPopover(
template: TemplateRef<any>,
target: HTMLElement | ElementRef<any>,
position: string,
backdrop: boolean
): void {
setTimeout(() => this.popoverService.open(template, target, position, backdrop, {}), 200); setTimeout(() => this.popoverService.open(template, target, position, backdrop, {}), 200);
} }
@@ -206,12 +231,12 @@ export class CreateJournalEntryComponent implements OnInit, AfterViewInit {
* Next Step (Products) Dialog Configuration Wizard. * Next Step (Products) Dialog Configuration Wizard.
*/ */
openNextStepDialog() { openNextStepDialog() {
const nextStepDialogRef = this.dialog.open( NextStepDialogComponent, { const nextStepDialogRef = this.dialog.open(NextStepDialogComponent, {
data: { data: {
nextStepName: 'Setup Products', nextStepName: 'Setup Products',
previousStepName: 'Accounting', previousStepName: 'Accounting',
stepPercentage: 74 stepPercentage: 74
}, }
}); });
nextStepDialogRef.afterClosed().subscribe((response: { nextStep: boolean }) => { nextStepDialogRef.afterClosed().subscribe((response: { nextStep: boolean }) => {
if (response.nextStep) { if (response.nextStep) {
@@ -8,9 +8,8 @@ describe('CreateFinancialActivityMappingComponent', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ CreateFinancialActivityMappingComponent ] declarations: [CreateFinancialActivityMappingComponent]
}) }).compileComponents();
.compileComponents();
})); }));
beforeEach(() => { beforeEach(() => {
@@ -16,7 +16,6 @@ import { GLAccount } from 'app/shared/models/general.model';
styleUrls: ['./create-financial-activity-mapping.component.scss'] styleUrls: ['./create-financial-activity-mapping.component.scss']
}) })
export class CreateFinancialActivityMappingComponent implements OnInit { export class CreateFinancialActivityMappingComponent implements OnInit {
/** Financial activity mapping form. */ /** Financial activity mapping form. */
financialActivityMappingForm: UntypedFormGroup; financialActivityMappingForm: UntypedFormGroup;
/** GL Account options. */ /** GL Account options. */
@@ -33,10 +32,12 @@ export class CreateFinancialActivityMappingComponent implements OnInit {
* @param {ActivatedRoute} route Activated Route. * @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation. * @param {Router} router Router for navigation.
*/ */
constructor(private formBuilder: UntypedFormBuilder, constructor(
private formBuilder: UntypedFormBuilder,
private accountingService: AccountingService, private accountingService: AccountingService,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router) { private router: Router
) {
this.route.data.subscribe((data: { financialActivityAccountsTemplate: any }) => { this.route.data.subscribe((data: { financialActivityAccountsTemplate: any }) => {
this.glAccountOptions = data.financialActivityAccountsTemplate.glAccountOptions; this.glAccountOptions = data.financialActivityAccountsTemplate.glAccountOptions;
this.financialActivityData = data.financialActivityAccountsTemplate.financialActivityOptions; this.financialActivityData = data.financialActivityAccountsTemplate.financialActivityOptions;
@@ -56,8 +57,14 @@ export class CreateFinancialActivityMappingComponent implements OnInit {
*/ */
createFinancialActivityMappingForm() { createFinancialActivityMappingForm() {
this.financialActivityMappingForm = this.formBuilder.group({ this.financialActivityMappingForm = this.formBuilder.group({
'financialActivityId': ['', Validators.required], financialActivityId: [
'glAccountId': ['', Validators.required] '',
Validators.required
],
glAccountId: [
'',
Validators.required
]
}); });
} }
@@ -65,18 +72,20 @@ export class CreateFinancialActivityMappingComponent implements OnInit {
* Sets the gl account data on the basis of selected financial activity. * Sets the gl account data on the basis of selected financial activity.
*/ */
setGlAccountData() { setGlAccountData() {
this.financialActivityMappingForm.get('financialActivityId').valueChanges this.financialActivityMappingForm.get('financialActivityId').valueChanges.subscribe((financialActivityId) => {
.subscribe(financialActivityId => {
switch (financialActivityId) { switch (financialActivityId) {
case 100: case 100:
case 101: case 101:
case 102: case 102:
case 103: this.glAccountData = this.glAccountOptions.assetAccountOptions; case 103:
this.glAccountData = this.glAccountOptions.assetAccountOptions;
break; break;
case 200: case 200:
case 201: this.glAccountData = this.glAccountOptions.liabilityAccountOptions; case 201:
this.glAccountData = this.glAccountOptions.liabilityAccountOptions;
break; break;
case 300: this.glAccountData = this.glAccountOptions.equityAccountOptions; case 300:
this.glAccountData = this.glAccountOptions.equityAccountOptions;
break; break;
} }
}); });
@@ -87,10 +96,16 @@ export class CreateFinancialActivityMappingComponent implements OnInit {
* if successful redirects to view created account. * if successful redirects to view created account.
*/ */
submit() { submit() {
this.accountingService.createFinancialActivityAccount(this.financialActivityMappingForm.value) this.accountingService
.createFinancialActivityAccount(this.financialActivityMappingForm.value)
.subscribe((response: any) => { .subscribe((response: any) => {
this.router.navigate(['../view', response.resourceId], { relativeTo: this.route }); this.router.navigate(
[
'../view',
response.resourceId
],
{ relativeTo: this.route }
);
}); });
} }
} }
@@ -13,7 +13,6 @@ import { AccountingService } from '../../accounting.service';
*/ */
@Injectable() @Injectable()
export class FinancialActivityMappingsTemplateResolver implements Resolve<Object> { export class FinancialActivityMappingsTemplateResolver implements Resolve<Object> {
/** /**
* @param {AccountingService} accountingService Accounting service. * @param {AccountingService} accountingService Accounting service.
*/ */
@@ -26,5 +25,4 @@ export class FinancialActivityMappingsTemplateResolver implements Resolve<Object
resolve(): Observable<any> { resolve(): Observable<any> {
return this.accountingService.getFinancialActivityAccountsTemplate(); return this.accountingService.getFinancialActivityAccountsTemplate();
} }
} }
@@ -8,9 +8,8 @@ describe('EditFinancialActivityMappingComponent', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ EditFinancialActivityMappingComponent ] declarations: [EditFinancialActivityMappingComponent]
}) }).compileComponents();
.compileComponents();
})); }));
beforeEach(() => { beforeEach(() => {
@@ -16,7 +16,6 @@ import { GLAccount } from 'app/shared/models/general.model';
styleUrls: ['./edit-financial-activity-mapping.component.scss'] styleUrls: ['./edit-financial-activity-mapping.component.scss']
}) })
export class EditFinancialActivityMappingComponent implements OnInit { export class EditFinancialActivityMappingComponent implements OnInit {
/** Financial activity mapping form. */ /** Financial activity mapping form. */
financialActivityMappingForm: UntypedFormGroup; financialActivityMappingForm: UntypedFormGroup;
/** GL Account options. */ /** GL Account options. */
@@ -39,10 +38,12 @@ export class EditFinancialActivityMappingComponent implements OnInit {
* @param {ActivatedRoute} route Activated Route. * @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation. * @param {Router} router Router for navigation.
*/ */
constructor(private formBuider: UntypedFormBuilder, constructor(
private formBuider: UntypedFormBuilder,
private accountingService: AccountingService, private accountingService: AccountingService,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router) { private router: Router
) {
this.route.data.subscribe((data: { financialActivityAccountAndTemplate: any }) => { this.route.data.subscribe((data: { financialActivityAccountAndTemplate: any }) => {
this.financialActivityAccountId = data.financialActivityAccountAndTemplate.id; this.financialActivityAccountId = data.financialActivityAccountAndTemplate.id;
console.log(data.financialActivityAccountAndTemplate.financialActivityData); console.log(data.financialActivityAccountAndTemplate.financialActivityData);
@@ -68,8 +69,14 @@ export class EditFinancialActivityMappingComponent implements OnInit {
*/ */
createFinancialActivityMappingForm() { createFinancialActivityMappingForm() {
this.financialActivityMappingForm = this.formBuider.group({ this.financialActivityMappingForm = this.formBuider.group({
'financialActivityId': ['', Validators.required], financialActivityId: [
'glAccountId': ['', Validators.required] '',
Validators.required
],
glAccountId: [
'',
Validators.required
]
}); });
} }
@@ -77,18 +84,20 @@ export class EditFinancialActivityMappingComponent implements OnInit {
* Sets the gl account data on the basis of selected financial activity. * Sets the gl account data on the basis of selected financial activity.
*/ */
setGLAccountData() { setGLAccountData() {
this.financialActivityMappingForm.get('financialActivityId').valueChanges this.financialActivityMappingForm.get('financialActivityId').valueChanges.subscribe((financialActivityId) => {
.subscribe(financialActivityId => {
switch (financialActivityId) { switch (financialActivityId) {
case 100: case 100:
case 101: case 101:
case 102: case 102:
case 103: this.glAccountData = this.glAccountOptions.assetAccountOptions; case 103:
this.glAccountData = this.glAccountOptions.assetAccountOptions;
break; break;
case 200: case 200:
case 201: this.glAccountData = this.glAccountOptions.liabilityAccountOptions; case 201:
this.glAccountData = this.glAccountOptions.liabilityAccountOptions;
break; break;
case 300: this.glAccountData = this.glAccountOptions.equityAccountOptions; case 300:
this.glAccountData = this.glAccountOptions.equityAccountOptions;
break; break;
} }
}); });
@@ -99,10 +108,16 @@ export class EditFinancialActivityMappingComponent implements OnInit {
* if successful redirects to view updated account. * if successful redirects to view updated account.
*/ */
submit() { submit() {
this.accountingService.updateFinancialActivityAccount(this.financialActivityAccountId, this.financialActivityMappingForm.value) this.accountingService
.updateFinancialActivityAccount(this.financialActivityAccountId, this.financialActivityMappingForm.value)
.subscribe((response: any) => { .subscribe((response: any) => {
this.router.navigate(['../../', response.resourceId], { relativeTo: this.route }); this.router.navigate(
[
'../../',
response.resourceId
],
{ relativeTo: this.route }
);
}); });
} }
} }
@@ -13,7 +13,6 @@ import { AccountingService } from '../../accounting.service';
*/ */
@Injectable() @Injectable()
export class FinancialActivityMappingAndTemplateResolver implements Resolve<Object> { export class FinancialActivityMappingAndTemplateResolver implements Resolve<Object> {
/** /**
* @param {AccountingService} accountingService Accounting service. * @param {AccountingService} accountingService Accounting service.
*/ */
@@ -27,5 +26,4 @@ export class FinancialActivityMappingAndTemplateResolver implements Resolve<Obje
const financialActivityAccountId = route.paramMap.get('id'); const financialActivityAccountId = route.paramMap.get('id');
return this.accountingService.getFinancialActivityAccount(financialActivityAccountId, true); return this.accountingService.getFinancialActivityAccount(financialActivityAccountId, true);
} }
} }
@@ -8,9 +8,8 @@ describe('FinancialActivityMappingsComponent', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ FinancialActivityMappingsComponent ] declarations: [FinancialActivityMappingsComponent]
}) }).compileComponents();
.compileComponents();
})); }));
beforeEach(() => { beforeEach(() => {
@@ -18,11 +18,15 @@ import { ConfigurationWizardService } from '../../configuration-wizard/configura
styleUrls: ['./financial-activity-mappings.component.scss'] styleUrls: ['./financial-activity-mappings.component.scss']
}) })
export class FinancialActivityMappingsComponent implements OnInit, AfterViewInit { export class FinancialActivityMappingsComponent implements OnInit, AfterViewInit {
/** Financial activity account data. */ /** Financial activity account data. */
financialActivityAccountData: any; financialActivityAccountData: any;
/** Columns to be displayed in financial activity mappings table. */ /** Columns to be displayed in financial activity mappings table. */
displayedColumns: string[] = ['financialActivity', 'glAccountType', 'glAccountCode', 'glAccountName']; displayedColumns: string[] = [
'financialActivity',
'glAccountType',
'glAccountCode',
'glAccountName'
];
/** Data source for financial activity mappings table. */ /** Data source for financial activity mappings table. */
dataSource: MatTableDataSource<any>; dataSource: MatTableDataSource<any>;
@@ -47,11 +51,13 @@ export class FinancialActivityMappingsComponent implements OnInit, AfterViewInit
* @param {ConfigurationWizardService} configurationWizardService ConfigurationWizard Service. * @param {ConfigurationWizardService} configurationWizardService ConfigurationWizard Service.
* @param {PopoverService} popoverService PopoverService. * @param {PopoverService} popoverService PopoverService.
*/ */
constructor(private route: ActivatedRoute, constructor(
private route: ActivatedRoute,
private router: Router, private router: Router,
private configurationWizardService: ConfigurationWizardService, private configurationWizardService: ConfigurationWizardService,
private popoverService: PopoverService) { private popoverService: PopoverService
this.route.data.subscribe(( data: { financialActivityAccounts: any }) => { ) {
this.route.data.subscribe((data: { financialActivityAccounts: any }) => {
this.financialActivityAccountData = data.financialActivityAccounts; this.financialActivityAccountData = data.financialActivityAccounts;
}); });
} }
@@ -71,10 +77,14 @@ export class FinancialActivityMappingsComponent implements OnInit, AfterViewInit
this.dataSource.paginator = this.paginator; this.dataSource.paginator = this.paginator;
this.dataSource.sortingDataAccessor = (financialActivityAccount: any, property: any) => { this.dataSource.sortingDataAccessor = (financialActivityAccount: any, property: any) => {
switch (property) { switch (property) {
case 'financialActivity': return financialActivityAccount.financialActivityData.name; case 'financialActivity':
case 'glAccountName': return financialActivityAccount.glAccountData.name; return financialActivityAccount.financialActivityData.name;
case 'glAccountCode': return financialActivityAccount.glAccountData.glCode; case 'glAccountName':
default: return financialActivityAccount[property]; return financialActivityAccount.glAccountData.name;
case 'glAccountCode':
return financialActivityAccount.glAccountData.glCode;
default:
return financialActivityAccount[property];
} }
}; };
this.dataSource.sort = this.sort; this.dataSource.sort = this.sort;
@@ -87,7 +97,12 @@ export class FinancialActivityMappingsComponent implements OnInit, AfterViewInit
* @param position String. * @param position String.
* @param backdrop Boolean. * @param backdrop Boolean.
*/ */
showPopover(template: TemplateRef<any>, target: HTMLElement | ElementRef<any>, position: string, backdrop: boolean): void { showPopover(
template: TemplateRef<any>,
target: HTMLElement | ElementRef<any>,
position: string,
backdrop: boolean
): void {
setTimeout(() => this.popoverService.open(template, target, position, backdrop, {}), 200); setTimeout(() => this.popoverService.open(template, target, position, backdrop, {}), 200);
} }
@@ -127,5 +142,4 @@ export class FinancialActivityMappingsComponent implements OnInit, AfterViewInit
this.configurationWizardService.showAccountsLinked = true; this.configurationWizardService.showAccountsLinked = true;
this.router.navigate(['/accounting']); this.router.navigate(['/accounting']);
} }
} }
@@ -13,7 +13,6 @@ import { AccountingService } from '../accounting.service';
*/ */
@Injectable() @Injectable()
export class FinancialActivityMappingsResolver implements Resolve<Object> { export class FinancialActivityMappingsResolver implements Resolve<Object> {
/** /**
* @param {AccountingService} accountingService Accounting service. * @param {AccountingService} accountingService Accounting service.
*/ */
@@ -26,5 +25,4 @@ export class FinancialActivityMappingsResolver implements Resolve<Object> {
resolve(): Observable<any> { resolve(): Observable<any> {
return this.accountingService.getFinancialActivityAccounts(); return this.accountingService.getFinancialActivityAccounts();
} }
} }
@@ -13,7 +13,6 @@ import { AccountingService } from '../../accounting.service';
*/ */
@Injectable() @Injectable()
export class FinancialActivityMappingResolver implements Resolve<Object> { export class FinancialActivityMappingResolver implements Resolve<Object> {
/** /**
* @param {AccountingService} accountingService Accounting service. * @param {AccountingService} accountingService Accounting service.
*/ */
@@ -27,5 +26,4 @@ export class FinancialActivityMappingResolver implements Resolve<Object> {
const financialActivityAccountId = route.paramMap.get('id'); const financialActivityAccountId = route.paramMap.get('id');
return this.accountingService.getFinancialActivityAccount(financialActivityAccountId, false); return this.accountingService.getFinancialActivityAccount(financialActivityAccountId, false);
} }
} }
@@ -8,9 +8,8 @@ describe('ViewFinancialActivityMappingComponent', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ ViewFinancialActivityMappingComponent ] declarations: [ViewFinancialActivityMappingComponent]
}) }).compileComponents();
.compileComponents();
})); }));
beforeEach(() => { beforeEach(() => {
@@ -19,7 +19,6 @@ import { Location } from '@angular/common';
styleUrls: ['./view-financial-activity-mapping.component.scss'] styleUrls: ['./view-financial-activity-mapping.component.scss']
}) })
export class ViewFinancialActivityMappingComponent { export class ViewFinancialActivityMappingComponent {
/** Financial activity account ID. */ /** Financial activity account ID. */
financialActivityAccountId: any; financialActivityAccountId: any;
/** Financial activity account data. */ /** Financial activity account data. */
@@ -32,11 +31,13 @@ export class ViewFinancialActivityMappingComponent {
* @param {Router} router Router for navigation. * @param {Router} router Router for navigation.
* @param {MatDialog} dialog Dialog reference. * @param {MatDialog} dialog Dialog reference.
*/ */
constructor(private accountingService: AccountingService, constructor(
private accountingService: AccountingService,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router, private router: Router,
private dialog: MatDialog, private dialog: MatDialog,
private location: Location) { private location: Location
) {
this.route.data.subscribe((data: { financialActivityAccount: any }) => { this.route.data.subscribe((data: { financialActivityAccount: any }) => {
this.financialActivityAccount = data.financialActivityAccount; this.financialActivityAccount = data.financialActivityAccount;
this.financialActivityAccountId = data.financialActivityAccount.id; this.financialActivityAccountId = data.financialActivityAccount.id;
@@ -52,8 +53,7 @@ export class ViewFinancialActivityMappingComponent {
}); });
deleteFinancialActivityAccountDialogRef.afterClosed().subscribe((response: any) => { deleteFinancialActivityAccountDialogRef.afterClosed().subscribe((response: any) => {
if (response.delete) { if (response.delete) {
this.accountingService.deleteFinancialActivityAccount(this.financialActivityAccountId) this.accountingService.deleteFinancialActivityAccount(this.financialActivityAccountId).subscribe(() => {
.subscribe(() => {
this.router.navigate(['/accounting/financial-activity-mappings']); this.router.navigate(['/accounting/financial-activity-mappings']);
}); });
} }
@@ -63,5 +63,4 @@ export class ViewFinancialActivityMappingComponent {
goBack(): void { goBack(): void {
this.location.back(); this.location.back();
} }
} }
@@ -8,9 +8,8 @@ describe('FrequentPostingsComponent', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ FrequentPostingsComponent ] declarations: [FrequentPostingsComponent]
}) }).compileComponents();
.compileComponents();
})); }));
beforeEach(() => { beforeEach(() => {
@@ -16,7 +16,6 @@ import { Dates } from 'app/core/utils/dates';
styleUrls: ['./frequent-postings.component.scss'] styleUrls: ['./frequent-postings.component.scss']
}) })
export class FrequentPostingsComponent implements OnInit { export class FrequentPostingsComponent implements OnInit {
/** Minimum transaction date allowed. */ /** Minimum transaction date allowed. */
minDate = new Date(2000, 0, 1); minDate = new Date(2000, 0, 1);
/** Maximum transaction date allowed. */ /** Maximum transaction date allowed. */
@@ -48,18 +47,15 @@ export class FrequentPostingsComponent implements OnInit {
* @param {ActivatedRoute} route Activated Route. * @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation. * @param {Router} router Router for navigation.
*/ */
constructor(private formBuilder: UntypedFormBuilder, constructor(
private formBuilder: UntypedFormBuilder,
private accountingService: AccountingService, private accountingService: AccountingService,
private settingsService: SettingsService, private settingsService: SettingsService,
private dateUtils: Dates, private dateUtils: Dates,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router) { private router: Router
this.route.data.subscribe((data: { ) {
offices: any, this.route.data.subscribe((data: { offices: any; accountingRules: any; currencies: any; paymentTypes: any }) => {
accountingRules: any,
currencies: any,
paymentTypes: any
}) => {
this.officeData = data.offices; this.officeData = data.offices;
this.accountingRuleData = data.accountingRules; this.accountingRuleData = data.accountingRules;
this.currencyData = data.currencies.selectedCurrencyOptions; this.currencyData = data.currencies.selectedCurrencyOptions;
@@ -81,20 +77,32 @@ export class FrequentPostingsComponent implements OnInit {
*/ */
createFrequentPostingsForm() { createFrequentPostingsForm() {
this.frequentPostingsForm = this.formBuilder.group({ this.frequentPostingsForm = this.formBuilder.group({
'officeId': ['', Validators.required], officeId: [
'accountingRule': ['', Validators.required], '',
'currencyCode': ['', Validators.required], Validators.required
'debits': this.formBuilder.array([]), ],
'credits': this.formBuilder.array([]), accountingRule: [
'referenceNumber': [''], '',
'transactionDate': ['', Validators.required], Validators.required
'paymentTypeId': [''], ],
'accountNumber': [''], currencyCode: [
'checkNumber': [''], '',
'routingCode': [''], Validators.required
'receiptNumber': [''], ],
'bankNumber': [''], debits: this.formBuilder.array([]),
'comments': [''] credits: this.formBuilder.array([]),
referenceNumber: [''],
transactionDate: [
'',
Validators.required
],
paymentTypeId: [''],
accountNumber: [''],
checkNumber: [''],
routingCode: [''],
receiptNumber: [''],
bankNumber: [''],
comments: ['']
}); });
} }
@@ -102,7 +110,7 @@ export class FrequentPostingsComponent implements OnInit {
* Sets the affected gl entry form array. * Sets the affected gl entry form array.
*/ */
setAffectedGLEntryForm() { setAffectedGLEntryForm() {
this.frequentPostingsForm.get('accountingRule').valueChanges.subscribe(accountingRule => { this.frequentPostingsForm.get('accountingRule').valueChanges.subscribe((accountingRule) => {
while (this.debits.length) { while (this.debits.length) {
this.debits.removeAt(0); this.debits.removeAt(0);
} }
@@ -124,8 +132,14 @@ export class FrequentPostingsComponent implements OnInit {
*/ */
createAffectedGLEntryForm(): UntypedFormGroup { createAffectedGLEntryForm(): UntypedFormGroup {
return this.formBuilder.group({ return this.formBuilder.group({
'glAccountId': ['', Validators.required], glAccountId: [
'amount': ['', Validators.required] '',
Validators.required
],
amount: [
'',
Validators.required
]
}); });
} }
@@ -173,11 +187,19 @@ export class FrequentPostingsComponent implements OnInit {
journalEntry.locale = this.settingsService.language.code; journalEntry.locale = this.settingsService.language.code;
journalEntry.dateFormat = this.settingsService.dateFormat; journalEntry.dateFormat = this.settingsService.dateFormat;
if (journalEntry.transactionDate instanceof Date) { if (journalEntry.transactionDate instanceof Date) {
journalEntry.transactionDate = this.dateUtils.formatDate(journalEntry.transactionDate, this.settingsService.dateFormat); journalEntry.transactionDate = this.dateUtils.formatDate(
journalEntry.transactionDate,
this.settingsService.dateFormat
);
} }
this.accountingService.createJournalEntry(journalEntry).subscribe(response => { this.accountingService.createJournalEntry(journalEntry).subscribe((response) => {
this.router.navigate(['../transactions/view', response.transactionId], { relativeTo: this.route }); this.router.navigate(
[
'../transactions/view',
response.transactionId
],
{ relativeTo: this.route }
);
}); });
} }
} }
@@ -8,9 +8,8 @@ describe('MigrateOpeningBalancesComponent', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ MigrateOpeningBalancesComponent ] declarations: [MigrateOpeningBalancesComponent]
}) }).compileComponents();
.compileComponents();
})); }));
beforeEach(() => { beforeEach(() => {
@@ -23,7 +23,6 @@ import { TranslateService } from '@ngx-translate/core';
styleUrls: ['./migrate-opening-balances.component.scss'] styleUrls: ['./migrate-opening-balances.component.scss']
}) })
export class MigrateOpeningBalancesComponent implements OnInit, AfterViewInit { export class MigrateOpeningBalancesComponent implements OnInit, AfterViewInit {
/** Minimum opening balances date allowed. */ /** Minimum opening balances date allowed. */
minDate = new Date(2000, 0, 1); minDate = new Date(2000, 0, 1);
/** Maximum opening balances date allowed. */ /** Maximum opening balances date allowed. */
@@ -57,7 +56,8 @@ export class MigrateOpeningBalancesComponent implements OnInit, AfterViewInit {
* @param {ConfigurationWizardService} configurationWizardService ConfigurationWizard Service. * @param {ConfigurationWizardService} configurationWizardService ConfigurationWizard Service.
* @param {PopoverService} popoverService PopoverService. * @param {PopoverService} popoverService PopoverService.
*/ */
constructor(private formBuilder: UntypedFormBuilder, constructor(
private formBuilder: UntypedFormBuilder,
private accountingService: AccountingService, private accountingService: AccountingService,
private settingsService: SettingsService, private settingsService: SettingsService,
private dateUtils: Dates, private dateUtils: Dates,
@@ -65,11 +65,9 @@ export class MigrateOpeningBalancesComponent implements OnInit, AfterViewInit {
private router: Router, private router: Router,
private configurationWizardService: ConfigurationWizardService, private configurationWizardService: ConfigurationWizardService,
private popoverService: PopoverService, private popoverService: PopoverService,
private translateService: TranslateService) { private translateService: TranslateService
this.route.data.subscribe((data: { ) {
offices: any, this.route.data.subscribe((data: { offices: any; currencies: any }) => {
currencies: any
}) => {
this.officeData = data.offices; this.officeData = data.offices;
this.currencyData = data.currencies.selectedCurrencyOptions; this.currencyData = data.currencies.selectedCurrencyOptions;
}); });
@@ -88,10 +86,19 @@ export class MigrateOpeningBalancesComponent implements OnInit, AfterViewInit {
*/ */
createOpeningBalancesForm() { createOpeningBalancesForm() {
this.openingBalancesForm = this.formBuilder.group({ this.openingBalancesForm = this.formBuilder.group({
'officeId': ['', Validators.required], officeId: [
'currencyCode': ['', Validators.required], '',
'transactionDate': ['', Validators.required], Validators.required
'glAccountEntries': this.formBuilder.array([]) ],
currencyCode: [
'',
Validators.required
],
transactionDate: [
'',
Validators.required
],
glAccountEntries: this.formBuilder.array([])
}); });
this.openingBalancesForm.controls.currencyCode.valueChanges.subscribe((value: string) => { this.openingBalancesForm.controls.currencyCode.valueChanges.subscribe((value: string) => {
@@ -105,11 +112,14 @@ export class MigrateOpeningBalancesComponent implements OnInit, AfterViewInit {
* @returns {FormGroup} GL Account entry form. * @returns {FormGroup} GL Account entry form.
*/ */
createGLAccountEntryForm(glAccount: any): UntypedFormGroup { createGLAccountEntryForm(glAccount: any): UntypedFormGroup {
return this.formBuilder.group({ return this.formBuilder.group(
'glAccountId': [glAccount.glAccountId], {
'debit': [null], glAccountId: [glAccount.glAccountId],
'credit': [null] debit: [null],
}, { validator: onlyOneOfTheFieldsIsRequiredValidator }); credit: [null]
},
{ validator: onlyOneOfTheFieldsIsRequiredValidator }
);
} }
/** /**
@@ -124,15 +134,17 @@ export class MigrateOpeningBalancesComponent implements OnInit, AfterViewInit {
* Retrieves gl accounts on the basis of specified office. * Retrieves gl accounts on the basis of specified office.
*/ */
retrieveOpeningBalances() { retrieveOpeningBalances() {
this.accountingService.retrieveOpeningBalances(this.openingBalancesForm.value.officeId) this.accountingService
.retrieveOpeningBalances(this.openingBalancesForm.value.officeId)
.subscribe((openingBalancesData: any) => { .subscribe((openingBalancesData: any) => {
const entry = this.openingBalancesForm.get('glAccountEntries') as UntypedFormArray; const entry = this.openingBalancesForm.get('glAccountEntries') as UntypedFormArray;
openingBalancesData.glAccounts = openingBalancesData.assetAccountOpeningBalances openingBalancesData.glAccounts = openingBalancesData.assetAccountOpeningBalances.concat(
.concat(openingBalancesData.liabityAccountOpeningBalances, openingBalancesData.liabityAccountOpeningBalances,
openingBalancesData.equityAccountOpeningBalances, openingBalancesData.equityAccountOpeningBalances,
openingBalancesData.incomeAccountOpeningBalances, openingBalancesData.incomeAccountOpeningBalances,
openingBalancesData.expenseAccountOpeningBalances); openingBalancesData.expenseAccountOpeningBalances
);
openingBalancesData.glAccounts.forEach((glAccount: any) => { openingBalancesData.glAccounts.forEach((glAccount: any) => {
entry.push(this.createGLAccountEntryForm(glAccount)); entry.push(this.createGLAccountEntryForm(glAccount));
@@ -143,7 +155,7 @@ export class MigrateOpeningBalancesComponent implements OnInit, AfterViewInit {
entry.valueChanges.subscribe(() => { entry.valueChanges.subscribe(() => {
this.debitsSum = 0; this.debitsSum = 0;
this.creditsSum = 0; this.creditsSum = 0;
entry.controls.forEach(value => { entry.controls.forEach((value) => {
this.debitsSum += value.value.debit; this.debitsSum += value.value.debit;
this.creditsSum += value.value.credit; this.creditsSum += value.value.credit;
}); });
@@ -161,7 +173,10 @@ export class MigrateOpeningBalancesComponent implements OnInit, AfterViewInit {
openingBalances.locale = this.settingsService.language.code; openingBalances.locale = this.settingsService.language.code;
openingBalances.dateFormat = this.settingsService.dateFormat; openingBalances.dateFormat = this.settingsService.dateFormat;
if (openingBalances.transactionDate instanceof Date) { if (openingBalances.transactionDate instanceof Date) {
openingBalances.transactionDate = this.dateUtils.formatDate(openingBalances.transactionDate, this.settingsService.dateFormat); openingBalances.transactionDate = this.dateUtils.formatDate(
openingBalances.transactionDate,
this.settingsService.dateFormat
);
} }
openingBalances.debits = []; openingBalances.debits = [];
openingBalances.credits = []; openingBalances.credits = [];
@@ -175,7 +190,10 @@ export class MigrateOpeningBalancesComponent implements OnInit, AfterViewInit {
}); });
delete openingBalances.glAccountEntries; delete openingBalances.glAccountEntries;
this.accountingService.defineOpeningBalances(openingBalances).subscribe((response: any) => { this.accountingService.defineOpeningBalances(openingBalances).subscribe((response: any) => {
this.router.navigate(['/accounting/journal-entries/transactions/view', response.transactionId]); this.router.navigate([
'/accounting/journal-entries/transactions/view',
response.transactionId
]);
}); });
} }
} }
@@ -187,7 +205,12 @@ export class MigrateOpeningBalancesComponent implements OnInit, AfterViewInit {
* @param position String. * @param position String.
* @param backdrop Boolean. * @param backdrop Boolean.
*/ */
showPopover(template: TemplateRef<any>, target: HTMLElement | ElementRef<any>, position: string, backdrop: boolean): void { showPopover(
template: TemplateRef<any>,
target: HTMLElement | ElementRef<any>,
position: string,
backdrop: boolean
): void {
setTimeout(() => this.popoverService.open(template, target, position, backdrop, {}), 200); setTimeout(() => this.popoverService.open(template, target, position, backdrop, {}), 200);
} }
@@ -229,11 +252,10 @@ export class MigrateOpeningBalancesComponent implements OnInit, AfterViewInit {
creditsSum = creditsSum + entry.credit; creditsSum = creditsSum + entry.credit;
} }
}); });
return (debitsSum > 0 && debitsSum === creditsSum); return debitsSum > 0 && debitsSum === creditsSum;
} }
glAccountTypeLabel(accountType: string): string { glAccountTypeLabel(accountType: string): string {
return this.translateService.instant('labels.inputs.accounting.' + accountType); return this.translateService.instant('labels.inputs.accounting.' + accountType);
} }
} }
@@ -2,12 +2,14 @@
import { UntypedFormGroup, ValidatorFn, ValidationErrors } from '@angular/forms'; import { UntypedFormGroup, ValidatorFn, ValidationErrors } from '@angular/forms';
/** Validates that atleast one of the fields debit or credit is filled (but not both) for a given gl account. */ /** Validates that atleast one of the fields debit or credit is filled (but not both) for a given gl account. */
export const onlyOneOfTheFieldsIsRequiredValidator: ValidatorFn = (glAccountEntriesForm: UntypedFormGroup): ValidationErrors | null => { export const onlyOneOfTheFieldsIsRequiredValidator: ValidatorFn = (
glAccountEntriesForm: UntypedFormGroup
): ValidationErrors | null => {
const debit = glAccountEntriesForm.controls.debit.value; const debit = glAccountEntriesForm.controls.debit.value;
const credit = glAccountEntriesForm.controls.credit.value; const credit = glAccountEntriesForm.controls.credit.value;
if (debit && credit) { if (debit && credit) {
if (debit > 0 && credit > 0) { if (debit > 0 && credit > 0) {
return { 'error': true }; return { error: true };
} }
} }
return null; return null;
@@ -8,9 +8,8 @@ describe('PeriodicAccrualsComponent', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ PeriodicAccrualsComponent ] declarations: [PeriodicAccrualsComponent]
}) }).compileComponents();
.compileComponents();
})); }));
beforeEach(() => { beforeEach(() => {
@@ -16,7 +16,6 @@ import { Dates } from 'app/core/utils/dates';
styleUrls: ['./periodic-accruals.component.scss'] styleUrls: ['./periodic-accruals.component.scss']
}) })
export class PeriodicAccrualsComponent implements OnInit { export class PeriodicAccrualsComponent implements OnInit {
/** Minimum accrue date allowed. */ /** Minimum accrue date allowed. */
minDate = new Date(2000, 0, 1); minDate = new Date(2000, 0, 1);
/** Maximum accrue date allowed. */ /** Maximum accrue date allowed. */
@@ -31,12 +30,14 @@ export class PeriodicAccrualsComponent implements OnInit {
* @param {ActivatedRoute} route Activated Route. * @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation. * @param {Router} router Router for navigation.
*/ */
constructor(private formBuilder: UntypedFormBuilder, constructor(
private formBuilder: UntypedFormBuilder,
private accountingService: AccountingService, private accountingService: AccountingService,
private settingsService: SettingsService, private settingsService: SettingsService,
private dateUtils: Dates, private dateUtils: Dates,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router) { } private router: Router
) {}
/** /**
* Creates periodic accruals form. * Creates periodic accruals form.
@@ -51,7 +52,10 @@ export class PeriodicAccrualsComponent implements OnInit {
*/ */
createPeriodicAccrualsForm() { createPeriodicAccrualsForm() {
this.periodicAccrualsForm = this.formBuilder.group({ this.periodicAccrualsForm = this.formBuilder.group({
'tillDate': ['', Validators.required] tillDate: [
'',
Validators.required
]
}); });
} }
@@ -71,5 +75,4 @@ export class PeriodicAccrualsComponent implements OnInit {
this.router.navigate(['../'], { relativeTo: this.route }); this.router.navigate(['../'], { relativeTo: this.route });
}); });
} }
} }
@@ -8,9 +8,8 @@ describe('CreateProvisioningEntryComponent', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ CreateProvisioningEntryComponent ] declarations: [CreateProvisioningEntryComponent]
}) }).compileComponents();
.compileComponents();
})); }));
beforeEach(() => { beforeEach(() => {
@@ -16,7 +16,6 @@ import { Dates } from 'app/core/utils/dates';
styleUrls: ['./create-provisioning-entry.component.scss'] styleUrls: ['./create-provisioning-entry.component.scss']
}) })
export class CreateProvisioningEntryComponent implements OnInit { export class CreateProvisioningEntryComponent implements OnInit {
/** Minimum provisioning date allowed. */ /** Minimum provisioning date allowed. */
minDate = new Date(2000, 0, 1); minDate = new Date(2000, 0, 1);
/** Maximum provisioning date allowed. */ /** Maximum provisioning date allowed. */
@@ -31,12 +30,14 @@ export class CreateProvisioningEntryComponent implements OnInit {
* @param {ActivatedRoute} route Activated Route. * @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation. * @param {Router} router Router for navigation.
*/ */
constructor(private formBuilder: UntypedFormBuilder, constructor(
private formBuilder: UntypedFormBuilder,
private accountingService: AccountingService, private accountingService: AccountingService,
private settingsService: SettingsService, private settingsService: SettingsService,
private dateUtils: Dates, private dateUtils: Dates,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router) { } private router: Router
) {}
/** /**
* Creates the provisioning entry form. * Creates the provisioning entry form.
@@ -51,8 +52,11 @@ export class CreateProvisioningEntryComponent implements OnInit {
*/ */
createProvisioningEntryForm() { createProvisioningEntryForm() {
this.provisioningEntryForm = this.formBuilder.group({ this.provisioningEntryForm = this.formBuilder.group({
'date': ['', Validators.required], date: [
'createjournalentries': [false] '',
Validators.required
],
createjournalentries: [false]
}); });
} }
@@ -68,10 +72,14 @@ export class CreateProvisioningEntryComponent implements OnInit {
if (provisioningEntry.date instanceof Date) { if (provisioningEntry.date instanceof Date) {
provisioningEntry.date = this.dateUtils.formatDate(provisioningEntry.date, this.settingsService.dateFormat); provisioningEntry.date = this.dateUtils.formatDate(provisioningEntry.date, this.settingsService.dateFormat);
} }
this.accountingService.createProvisioningEntry(provisioningEntry) this.accountingService.createProvisioningEntry(provisioningEntry).subscribe((response: any) => {
.subscribe((response: any) => { this.router.navigate(
this.router.navigate(['../view', response.resourceId], { relativeTo: this.route }); [
'../view',
response.resourceId
],
{ relativeTo: this.route }
);
}); });
} }
} }
@@ -8,9 +8,8 @@ describe('ProvisioningEntriesComponent', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ ProvisioningEntriesComponent ] declarations: [ProvisioningEntriesComponent]
}) }).compileComponents();
.compileComponents();
})); }));
beforeEach(() => { beforeEach(() => {

Some files were not shown because too many files have changed in this diff Show More