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

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