refactor (df/locale): accounting module (#1294)

This commit is contained in:
Shubham Korde
2021-08-08 13:23:35 +05:30
committed by GitHub
parent 18ab9cf128
commit 6a7b88133f
7 changed files with 35 additions and 21 deletions
@@ -5,7 +5,7 @@ import { Router, ActivatedRoute } from '@angular/router';
/** Custom Services */ /** Custom Services */
import { AccountingService } from '../../accounting.service'; import { AccountingService } from '../../accounting.service';
import { SettingsService } from 'app/settings/settings.service';
/** /**
* Create closure component. * Create closure component.
*/ */
@@ -29,11 +29,13 @@ export class CreateClosureComponent implements OnInit {
* Retrieves the offices data from `resolve`. * Retrieves the offices data from `resolve`.
* @param {FormBuilder} formBuilder Form Builder. * @param {FormBuilder} formBuilder Form Builder.
* @param {AccountingService} accountingService Accounting Service. * @param {AccountingService} accountingService Accounting Service.
* @param {SettingsService} settingsService Settings Service.
* @param {ActivatedRoute} route Activated Route. * @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation. * @param {Router} router Router for navigation.
*/ */
constructor(private formBuilder: FormBuilder, constructor(private formBuilder: FormBuilder,
private accountingService: AccountingService, private accountingService: AccountingService,
private settingsService: SettingsService,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router) { private router: Router) {
this.route.data.subscribe((data: { offices: any }) => { this.route.data.subscribe((data: { offices: any }) => {
@@ -66,8 +68,8 @@ export class CreateClosureComponent implements OnInit {
submit() { submit() {
const accountingClosure = this.accountingClosureForm.value; const accountingClosure = this.accountingClosureForm.value;
// TODO: Update once language and date settings are setup // TODO: Update once language and date settings are setup
accountingClosure.locale = 'en'; accountingClosure.locale = this.settingsService.language.code;
accountingClosure.dateFormat = 'yyyy-MM-dd'; accountingClosure.dateFormat = this.settingsService.dateFormat;
if (accountingClosure.closingDate instanceof Date) { if (accountingClosure.closingDate instanceof Date) {
let day = accountingClosure.closingDate.getDate(); let day = accountingClosure.closingDate.getDate();
let month = accountingClosure.closingDate.getMonth() + 1; let month = accountingClosure.closingDate.getMonth() + 1;
@@ -5,7 +5,7 @@ import { Router, ActivatedRoute } from '@angular/router';
/** Custom Services */ /** Custom Services */
import { AccountingService } from '../accounting.service'; import { AccountingService } from '../accounting.service';
import { SettingsService } from 'app/settings/settings.service';
/** /**
* Create Journal Entry component. * Create Journal Entry component.
*/ */
@@ -35,11 +35,13 @@ export class CreateJournalEntryComponent implements OnInit {
* Retrieves the offices, currencies, payment types and gl accounts data from `resolve`. * Retrieves the offices, currencies, payment types and gl accounts data from `resolve`.
* @param {FormBuilder} formBuilder Form Builder. * @param {FormBuilder} formBuilder Form Builder.
* @param {AccountingService} accountingService Accounting Service. * @param {AccountingService} accountingService Accounting Service.
* @param {SettingsService} settingsService Settings Service.
* @param {ActivatedRoute} route Activated Route. * @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation. * @param {Router} router Router for navigation.
*/ */
constructor(private formBuilder: FormBuilder, constructor(private formBuilder: FormBuilder,
private accountingService: AccountingService, private accountingService: AccountingService,
private settingsService: SettingsService,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router) { private router: Router) {
this.route.data.subscribe((data: { this.route.data.subscribe((data: {
@@ -134,8 +136,8 @@ export class CreateJournalEntryComponent implements OnInit {
submit() { submit() {
const journalEntry = this.journalEntryForm.value; const journalEntry = this.journalEntryForm.value;
// TODO: Update once language and date settings are setup // TODO: Update once language and date settings are setup
journalEntry.locale = 'en'; journalEntry.locale = this.settingsService.language.code;
journalEntry.dateFormat = 'yyyy-MM-dd'; journalEntry.dateFormat = this.settingsService.dateFormat;
if (journalEntry.transactionDate instanceof Date) { if (journalEntry.transactionDate instanceof Date) {
let day = journalEntry.transactionDate.getDate(); let day = journalEntry.transactionDate.getDate();
let month = journalEntry.transactionDate.getMonth() + 1; let month = journalEntry.transactionDate.getMonth() + 1;
@@ -5,7 +5,7 @@ import { Router, ActivatedRoute } from '@angular/router';
/** Custom Services */ /** Custom Services */
import { AccountingService } from '../accounting.service'; import { AccountingService } from '../accounting.service';
import { SettingsService } from 'app/settings/settings.service';
/** /**
* Frequent Postings component. * Frequent Postings component.
*/ */
@@ -43,11 +43,13 @@ export class FrequentPostingsComponent implements OnInit {
* Retrieves the offices, accounting rules, currencies and payment types data from `resolve`. * Retrieves the offices, accounting rules, currencies and payment types data from `resolve`.
* @param {FormBuilder} formBuilder Form Builder. * @param {FormBuilder} formBuilder Form Builder.
* @param {AccountingService} accountingService Accounting Service. * @param {AccountingService} accountingService Accounting Service.
* @param {SettingsService} settingsService Settings Service.
* @param {ActivatedRoute} route Activated Route. * @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation. * @param {Router} router Router for navigation.
*/ */
constructor(private formBuilder: FormBuilder, constructor(private formBuilder: FormBuilder,
private accountingService: AccountingService, private accountingService: AccountingService,
private settingsService: SettingsService,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router) { private router: Router) {
this.route.data.subscribe((data: { this.route.data.subscribe((data: {
@@ -165,8 +167,8 @@ export class FrequentPostingsComponent implements OnInit {
const journalEntry = this.frequentPostingsForm.value; const journalEntry = this.frequentPostingsForm.value;
journalEntry.accountingRule = journalEntry.accountingRule.id; journalEntry.accountingRule = journalEntry.accountingRule.id;
// TODO: Update once language and date settings are setup // TODO: Update once language and date settings are setup
journalEntry.locale = 'en'; journalEntry.locale = this.settingsService.language.code;
journalEntry.dateFormat = 'yyyy-MM-dd'; journalEntry.dateFormat = this.settingsService.dateFormat;
if (journalEntry.transactionDate instanceof Date) { if (journalEntry.transactionDate instanceof Date) {
let day = journalEntry.transactionDate.getDate(); let day = journalEntry.transactionDate.getDate();
let month = journalEntry.transactionDate.getMonth() + 1; let month = journalEntry.transactionDate.getMonth() + 1;
@@ -5,7 +5,7 @@ import { ActivatedRoute, Router } from '@angular/router';
/** Custom Services */ /** Custom Services */
import { AccountingService } from '../accounting.service'; import { AccountingService } from '../accounting.service';
import { SettingsService } from 'app/settings/settings.service';
/** Custom Validators */ /** Custom Validators */
import { onlyOneOfTheFieldsIsRequiredValidator } from './only-one-of-the-fields-is-required.validator'; import { onlyOneOfTheFieldsIsRequiredValidator } from './only-one-of-the-fields-is-required.validator';
@@ -40,11 +40,13 @@ export class MigrateOpeningBalancesComponent implements OnInit {
* Retrieves the offices and currencies from `resolve`. * Retrieves the offices and currencies from `resolve`.
* @param {FormBuilder} formBuilder Form Builder. * @param {FormBuilder} formBuilder Form Builder.
* @param {AccountingService} accountingService Accounting Service. * @param {AccountingService} accountingService Accounting Service.
* @param {SettingsService} settingsService Settings Service.
* @param {ActivatedRoute} route Activated Route. * @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation. * @param {Router} router Router for navigation.
*/ */
constructor(private formBuilder: FormBuilder, constructor(private formBuilder: FormBuilder,
private accountingService: AccountingService, private accountingService: AccountingService,
private settingsService: SettingsService,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router) { private router: Router) {
this.route.data.subscribe((data: { this.route.data.subscribe((data: {
@@ -134,8 +136,8 @@ export class MigrateOpeningBalancesComponent implements OnInit {
submit() { submit() {
const openingBalances = this.openingBalancesForm.value; const openingBalances = this.openingBalancesForm.value;
// TODO: Update once language and date settings are setup // TODO: Update once language and date settings are setup
openingBalances.locale = 'en'; openingBalances.locale = this.settingsService.language.code;
openingBalances.dateFormat = 'yyyy-MM-dd'; openingBalances.dateFormat = this.settingsService.dateFormat;
if (openingBalances.transactionDate instanceof Date) { if (openingBalances.transactionDate instanceof Date) {
let day = openingBalances.transactionDate.getDate(); let day = openingBalances.transactionDate.getDate();
let month = openingBalances.transactionDate.getMonth() + 1; let month = openingBalances.transactionDate.getMonth() + 1;
@@ -5,7 +5,7 @@ import { Router, ActivatedRoute } from '@angular/router';
/** Custom Services */ /** Custom Services */
import { AccountingService } from '../accounting.service'; import { AccountingService } from '../accounting.service';
import { SettingsService } from 'app/settings/settings.service';
/** /**
* Periodic accruals component. * Periodic accruals component.
*/ */
@@ -26,11 +26,13 @@ export class PeriodicAccrualsComponent implements OnInit {
/** /**
* @param {FormBuilder} formBuilder Form Builder. * @param {FormBuilder} formBuilder Form Builder.
* @param {AccountingService} accountingService Accounting Service. * @param {AccountingService} accountingService Accounting Service.
* @param {SettingsService} settingsService Settings Service.
* @param {ActivatedRoute} route Activated Route. * @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation. * @param {Router} router Router for navigation.
*/ */
constructor(private formBuilder: FormBuilder, constructor(private formBuilder: FormBuilder,
private accountingService: AccountingService, private accountingService: AccountingService,
private settingsService: SettingsService,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router) { } private router: Router) { }
@@ -57,8 +59,8 @@ export class PeriodicAccrualsComponent implements OnInit {
submit() { submit() {
const periodicAccruals = this.periodicAccrualsForm.value; const periodicAccruals = this.periodicAccrualsForm.value;
// TODO: Update once language and date settings are setup // TODO: Update once language and date settings are setup
periodicAccruals.locale = 'en'; periodicAccruals.locale = this.settingsService.language.code;
periodicAccruals.dateFormat = 'yyyy-MM-dd'; periodicAccruals.dateFormat = this.settingsService.dateFormat;
if (periodicAccruals.tillDate instanceof Date) { if (periodicAccruals.tillDate instanceof Date) {
let day = periodicAccruals.tillDate.getDate(); let day = periodicAccruals.tillDate.getDate();
let month = periodicAccruals.tillDate.getMonth() + 1; let month = periodicAccruals.tillDate.getMonth() + 1;
@@ -5,7 +5,7 @@ import { ActivatedRoute, Router } from '@angular/router';
/** Custom Services */ /** Custom Services */
import { AccountingService } from '../../accounting.service'; import { AccountingService } from '../../accounting.service';
import { SettingsService } from 'app/settings/settings.service';
/** /**
* Create provisioning entry component. * Create provisioning entry component.
*/ */
@@ -26,11 +26,13 @@ export class CreateProvisioningEntryComponent implements OnInit {
/** /**
* @param {FormBuilder} formBuilder Form Builder. * @param {FormBuilder} formBuilder Form Builder.
* @param {AccountingService} accountingService Accounting Service. * @param {AccountingService} accountingService Accounting Service.
* @param {SettingsService} settingsService Settings Service.
* @param {ActivatedRoute} route Activated Route. * @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation. * @param {Router} router Router for navigation.
*/ */
constructor(private formBuilder: FormBuilder, constructor(private formBuilder: FormBuilder,
private accountingService: AccountingService, private accountingService: AccountingService,
private settingsService: SettingsService,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router) { } private router: Router) { }
@@ -58,8 +60,8 @@ export class CreateProvisioningEntryComponent implements OnInit {
submit() { submit() {
const provisioningEntry = this.provisioningEntryForm.value; const provisioningEntry = this.provisioningEntryForm.value;
// TODO: Update once language and date settings are setup // TODO: Update once language and date settings are setup
provisioningEntry.locale = 'en'; provisioningEntry.locale = this.settingsService.language.code;
provisioningEntry.dateFormat = 'yyyy-MM-dd'; provisioningEntry.dateFormat = this.settingsService.dateFormat;
if (provisioningEntry.date instanceof Date) { if (provisioningEntry.date instanceof Date) {
let day = provisioningEntry.date.getDate(); let day = provisioningEntry.date.getDate();
let month = provisioningEntry.date.getMonth() + 1; let month = provisioningEntry.date.getMonth() + 1;
@@ -11,7 +11,7 @@ import { tap, startWith, map, distinctUntilChanged, debounceTime} from 'rxjs/ope
/** Custom Services */ /** Custom Services */
import { AccountingService } from '../accounting.service'; import { AccountingService } from '../accounting.service';
import { SettingsService } from 'app/settings/settings.service';
/** Custom Data Source */ /** Custom Data Source */
import { JournalEntriesDataSource } from './journal-entry.datasource'; import { JournalEntriesDataSource } from './journal-entry.datasource';
@@ -96,11 +96,11 @@ export class SearchJournalEntryComponent implements OnInit, AfterViewInit {
}, },
{ {
type: 'dateFormat', type: 'dateFormat',
value: 'yyyy-MM-dd' value: this.settingsService.dateFormat
}, },
{ {
type: 'locale', type: 'locale',
value: 'en' value: this.settingsService.language.code
} }
]; ];
@@ -113,8 +113,10 @@ export class SearchJournalEntryComponent implements OnInit, AfterViewInit {
* Retrieves the offices and gl accounts data from `resolve`. * Retrieves the offices and gl accounts data from `resolve`.
* @param {AccountingService} accountingService Accounting Service. * @param {AccountingService} accountingService Accounting Service.
* @param {ActivatedRoute} route Activated Route. * @param {ActivatedRoute} route Activated Route.
* @param {SettingsService} settingsService Settings Service.
*/ */
constructor(private accountingService: AccountingService, constructor(private accountingService: AccountingService,
private settingsService: SettingsService,
private route: ActivatedRoute) { private route: ActivatedRoute) {
this.route.data.subscribe((data: { this.route.data.subscribe((data: {
offices: any, offices: any,