Search and Create Journal entry page is broken - Filtering by dates are broken #1496

This commit is contained in:
Adam Saghy
2022-08-05 12:31:31 +02:00
parent 1c8a772de6
commit c0dcf9bfb8
10 changed files with 113 additions and 62 deletions
@@ -35,11 +35,11 @@ export class CreateClosureComponent implements OnInit {
* @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 settingsService: SettingsService,
private dateUtils: Dates, private dateUtils: Dates,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router) { private router: Router) {
this.route.data.subscribe((data: { offices: any }) => { this.route.data.subscribe((data: { offices: any }) => {
this.officeData = data.offices; this.officeData = data.offices;
}); });
@@ -74,7 +74,7 @@ export class CreateClosureComponent implements OnInit {
accountingClosure.locale = this.settingsService.language.code; accountingClosure.locale = this.settingsService.language.code;
accountingClosure.dateFormat = this.settingsService.dateFormat; accountingClosure.dateFormat = this.settingsService.dateFormat;
if (accountingClosure.closingDate) { if (accountingClosure.closingDate) {
accountingClosure.closingDate = this.dateUtils.getDate(accountingClosure.closingDate); accountingClosure.closingDate = this.dateUtils.formatDate(accountingClosure.closingDate, this.settingsService.dateFormat);
} }
this.accountingService.createAccountingClosure(accountingClosure).subscribe((response: any) => { this.accountingService.createAccountingClosure(accountingClosure).subscribe((response: any) => {
this.router.navigate(['../view', response.resourceId], { relativeTo: this.route }); this.router.navigate(['../view', response.resourceId], { relativeTo: this.route });
@@ -41,22 +41,22 @@ export class CreateJournalEntryComponent implements OnInit {
* @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 settingsService: SettingsService,
private dateUtils: Dates, private dateUtils: Dates,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router) { private router: Router) {
this.route.data.subscribe((data: { this.route.data.subscribe((data: {
offices: any, offices: any,
currencies: any, currencies: any,
paymentTypes: any, paymentTypes: any,
glAccounts: any glAccounts: any
}) => { }) => {
this.officeData = data.offices; this.officeData = data.offices;
this.currencyData = data.currencies.selectedCurrencyOptions; this.currencyData = data.currencies.selectedCurrencyOptions;
this.paymentTypeData = data.paymentTypes; this.paymentTypeData = data.paymentTypes;
this.glAccountData = data.glAccounts; this.glAccountData = data.glAccounts;
}); });
} }
/** /**
@@ -142,7 +142,7 @@ export class CreateJournalEntryComponent implements OnInit {
journalEntry.locale = this.settingsService.language.code; journalEntry.locale = this.settingsService.language.code;
journalEntry.dateFormat = this.settingsService.dateFormat; journalEntry.dateFormat = this.settingsService.dateFormat;
if (journalEntry.transactionDate) { if (journalEntry.transactionDate) {
journalEntry.transactionDate = this.dateUtils.getDate(journalEntry.transactionDate); journalEntry.transactionDate = this.dateUtils.formatDate(journalEntry.transactionDate, this.settingsService.dateFormat);
} }
this.accountingService.createJournalEntry(journalEntry).subscribe(response => { this.accountingService.createJournalEntry(journalEntry).subscribe(response => {
this.router.navigate(['../transactions/view', response.transactionId], { relativeTo: this.route }); this.router.navigate(['../transactions/view', response.transactionId], { relativeTo: this.route });
@@ -173,7 +173,7 @@ export class FrequentPostingsComponent implements OnInit {
journalEntry.locale = this.settingsService.language.code; journalEntry.locale = this.settingsService.language.code;
journalEntry.dateFormat = this.settingsService.dateFormat; journalEntry.dateFormat = this.settingsService.dateFormat;
if (journalEntry.transactionDate instanceof Date) { if (journalEntry.transactionDate instanceof Date) {
journalEntry.transactionDate = this.dateUtils.getDate(journalEntry.transactionDate); journalEntry.transactionDate = this.dateUtils.formatDate(journalEntry.transactionDate, this.settingsService.dateFormat);
} }
this.accountingService.createJournalEntry(journalEntry).subscribe(response => { this.accountingService.createJournalEntry(journalEntry).subscribe(response => {
this.router.navigate(['../transactions/view', response.transactionId], { relativeTo: this.route }); this.router.navigate(['../transactions/view', response.transactionId], { relativeTo: this.route });
@@ -46,18 +46,18 @@ export class MigrateOpeningBalancesComponent implements OnInit {
* @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 settingsService: SettingsService,
private dateUtils: Dates, private dateUtils: Dates,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router) { private router: Router) {
this.route.data.subscribe((data: { this.route.data.subscribe((data: {
offices: any, offices: any,
currencies: any currencies: any
}) => { }) => {
this.officeData = data.offices; this.officeData = data.offices;
this.currencyData = data.currencies.selectedCurrencyOptions; this.currencyData = data.currencies.selectedCurrencyOptions;
}); });
} }
/** /**
@@ -111,13 +111,13 @@ export class MigrateOpeningBalancesComponent implements OnInit {
openingBalancesData.glAccounts = openingBalancesData.assetAccountOpeningBalances openingBalancesData.glAccounts = openingBalancesData.assetAccountOpeningBalances
.concat(openingBalancesData.liabityAccountOpeningBalances, .concat(openingBalancesData.liabityAccountOpeningBalances,
openingBalancesData.equityAccountOpeningBalances, openingBalancesData.equityAccountOpeningBalances,
openingBalancesData.incomeAccountOpeningBalances, openingBalancesData.incomeAccountOpeningBalances,
openingBalancesData.expenseAccountOpeningBalances); openingBalancesData.expenseAccountOpeningBalances);
openingBalancesData.glAccounts.forEach((glAccount: any) => { openingBalancesData.glAccounts.forEach((glAccount: any) => {
entry.push(this.createGLAccountEntryForm(glAccount)); entry.push(this.createGLAccountEntryForm(glAccount));
}); });
this.openingBalancesData = openingBalancesData; this.openingBalancesData = openingBalancesData;
@@ -142,7 +142,7 @@ export class MigrateOpeningBalancesComponent implements OnInit {
openingBalances.locale = this.settingsService.language.code; openingBalances.locale = this.settingsService.language.code;
openingBalances.dateFormat = this.settingsService.dateFormat; openingBalances.dateFormat = this.settingsService.dateFormat;
if (openingBalances.transactionDate instanceof Date) { if (openingBalances.transactionDate instanceof Date) {
openingBalances.transactionDate = this.dateUtils.getDate(openingBalances.transactionDate); openingBalances.transactionDate = this.dateUtils.formatDate(openingBalances.transactionDate, this.settingsService.dateFormat);
} }
openingBalances.debits = []; openingBalances.debits = [];
openingBalances.credits = []; openingBalances.credits = [];
@@ -32,11 +32,11 @@ export class PeriodicAccrualsComponent implements OnInit {
* @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 settingsService: SettingsService,
private dateUtils: Dates, private dateUtils: Dates,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router) { } private router: Router) { }
/** /**
* Creates periodic accruals form. * Creates periodic accruals form.
@@ -65,7 +65,7 @@ export class PeriodicAccrualsComponent implements OnInit {
periodicAccruals.locale = this.settingsService.language.code; periodicAccruals.locale = this.settingsService.language.code;
periodicAccruals.dateFormat = this.settingsService.dateFormat; periodicAccruals.dateFormat = this.settingsService.dateFormat;
if (periodicAccruals.tillDate instanceof Date) { if (periodicAccruals.tillDate instanceof Date) {
periodicAccruals.tillDate = this.dateUtils.getDate(periodicAccruals.tillDate); periodicAccruals.tillDate = this.dateUtils.formatDate(periodicAccruals.tillDate, this.settingsService.dateFormat);
} }
this.accountingService.executePeriodicAccruals(periodicAccruals).subscribe(() => { this.accountingService.executePeriodicAccruals(periodicAccruals).subscribe(() => {
this.router.navigate(['../'], { relativeTo: this.route }); this.router.navigate(['../'], { relativeTo: this.route });
@@ -32,11 +32,11 @@ export class CreateProvisioningEntryComponent implements OnInit {
* @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 settingsService: SettingsService,
private dateUtils: Dates, private dateUtils: Dates,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router) { } private router: Router) { }
/** /**
* Creates the provisioning entry form. * Creates the provisioning entry form.
@@ -66,7 +66,7 @@ export class CreateProvisioningEntryComponent implements OnInit {
provisioningEntry.locale = this.settingsService.language.code; provisioningEntry.locale = this.settingsService.language.code;
provisioningEntry.dateFormat = this.settingsService.dateFormat; provisioningEntry.dateFormat = this.settingsService.dateFormat;
if (provisioningEntry.date instanceof Date) { if (provisioningEntry.date instanceof Date) {
provisioningEntry.date = this.dateUtils.getDate(provisioningEntry.date); provisioningEntry.date = this.dateUtils.formatDate(provisioningEntry.date, this.settingsService.dateFormat);
} }
this.accountingService.createProvisioningEntry(provisioningEntry) this.accountingService.createProvisioningEntry(provisioningEntry)
.subscribe((response: any) => { .subscribe((response: any) => {
@@ -38,6 +38,20 @@
<input matInput [formControl]="transactionId"> <input matInput [formControl]="transactionId">
</mat-form-field> </mat-form-field>
<mat-form-field fxFlex="31%" (click)="submittedOnDateFromPicker.open()">
<mat-label>Submitted on Date From</mat-label>
<input matInput [min]="minDate" [max]="maxDate" [matDatepicker]="submittedOnDateFromPicker" [formControl]="submittedOnDateFrom">
<mat-datepicker-toggle matSuffix [for]="submittedOnDateFromPicker"></mat-datepicker-toggle>
<mat-datepicker #submittedOnDateFromPicker></mat-datepicker>
</mat-form-field>
<mat-form-field fxFlex="31%" (click)="submittedOnDateToPicker.open()">
<mat-label>Submitted on Date To</mat-label>
<input matInput [min]="minDate" [max]="maxDate" [matDatepicker]="submittedOnDateToPicker" [formControl]="submittedOnDateTo">
<mat-datepicker-toggle matSuffix [for]="submittedOnDateToPicker"></mat-datepicker-toggle>
<mat-datepicker #submittedOnDateToPicker></mat-datepicker>
</mat-form-field>
</div> </div>
@@ -89,6 +103,11 @@
<td mat-cell *matCellDef="let journalEntry"> {{ journalEntry.createdByUserName }} </td> <td mat-cell *matCellDef="let journalEntry"> {{ journalEntry.createdByUserName }} </td>
</ng-container> </ng-container>
<ng-container matColumnDef="submittedOnDate">
<th mat-header-cell *matHeaderCellDef> Submitted on date </th>
<td mat-cell *matCellDef="let journalEntry"> {{ journalEntry.submittedOnDate }} </td>
</ng-container>
<ng-container matColumnDef="glAccountCode"> <ng-container matColumnDef="glAccountCode">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Account Code </th> <th mat-header-cell *matHeaderCellDef mat-sort-header> Account Code </th>
<td mat-cell *matCellDef="let journalEntry"> {{ journalEntry.glAccountCode }} </td> <td mat-cell *matCellDef="let journalEntry"> {{ journalEntry.glAccountCode }} </td>
@@ -3,7 +3,7 @@ import { Component, OnInit, ViewChild, AfterViewInit } from '@angular/core';
import { MatPaginator } from '@angular/material/paginator'; import { MatPaginator } from '@angular/material/paginator';
import { MatSort } from '@angular/material/sort'; import { MatSort } from '@angular/material/sort';
import { FormControl } from '@angular/forms'; import { FormControl } from '@angular/forms';
import { Router, ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
/** rxjs Imports */ /** rxjs Imports */
import { merge } from 'rxjs'; import { merge } from 'rxjs';
@@ -65,8 +65,12 @@ export class SearchJournalEntryComponent implements OnInit, AfterViewInit {
transactionDateTo = new FormControl(new Date()); transactionDateTo = new FormControl(new Date());
/** Transaction ID form control. */ /** Transaction ID form control. */
transactionId = new FormControl(); transactionId = new FormControl();
/** Submitted on date from form control. */
submittedOnDateFrom = new FormControl();
/** Submitted on date to form control. */
submittedOnDateTo = new FormControl();
/** Columns to be displayed in journal entries table. */ /** Columns to be displayed in journal entries table. */
displayedColumns: string[] = ['id', 'officeName', 'transactionId', 'transactionDate', 'glAccountType', 'createdByUserName', 'glAccountCode', 'glAccountName', 'debit', 'credit']; displayedColumns: string[] = ['id', 'officeName', 'transactionId', 'transactionDate', 'glAccountType', 'createdByUserName', 'submittedOnDate', 'glAccountCode', 'glAccountName', 'debit', 'credit'];
/** Data source for journal entries table. */ /** Data source for journal entries table. */
dataSource: JournalEntriesDataSource; dataSource: JournalEntriesDataSource;
/** Journal entries filter. */ /** Journal entries filter. */
@@ -89,11 +93,19 @@ export class SearchJournalEntryComponent implements OnInit, AfterViewInit {
}, },
{ {
type: 'fromDate', type: 'fromDate',
value: this.dateUtils.getDate(new Date(new Date().setMonth(new Date().getMonth() - 1))) value: this.dateUtils.formatDate(new Date(new Date().setMonth(new Date().getMonth() - 1)), this.settingsService.dateFormat)
}, },
{ {
type: 'toDate', type: 'toDate',
value: this.dateUtils.getDate(new Date()) value: this.dateUtils.formatDate(new Date(), this.settingsService.dateFormat)
},
{
type: 'submittedOnDateFrom',
value: ''
},
{
type: 'submittedOnDateTo',
value: ''
}, },
{ {
type: 'dateFormat', type: 'dateFormat',
@@ -182,7 +194,7 @@ export class SearchJournalEntryComponent implements OnInit, AfterViewInit {
debounceTime(500), debounceTime(500),
distinctUntilChanged(), distinctUntilChanged(),
tap((filterValue) => { tap((filterValue) => {
this.applyFilter(this.dateUtils.getDate(filterValue), 'fromDate'); this.applyFilter(this.dateUtils.formatDate(filterValue, this.settingsService.dateFormat), 'fromDate');
}) })
) )
.subscribe(); .subscribe();
@@ -192,7 +204,27 @@ export class SearchJournalEntryComponent implements OnInit, AfterViewInit {
debounceTime(500), debounceTime(500),
distinctUntilChanged(), distinctUntilChanged(),
tap((filterValue) => { tap((filterValue) => {
this.applyFilter(this.dateUtils.getDate(filterValue), 'toDate'); this.applyFilter(this.dateUtils.formatDate(filterValue, this.settingsService.dateFormat), 'toDate');
})
)
.subscribe();
this.submittedOnDateFrom.valueChanges
.pipe(
debounceTime(500),
distinctUntilChanged(),
tap((filterValue) => {
this.applyFilter(this.dateUtils.formatDate(filterValue, this.settingsService.dateFormat), 'submittedOnDateFrom');
})
)
.subscribe();
this.submittedOnDateTo.valueChanges
.pipe(
debounceTime(500),
distinctUntilChanged(),
tap((filterValue) => {
this.applyFilter(this.dateUtils.formatDate(filterValue, this.settingsService.dateFormat), 'submittedOnDateTo');
}) })
) )
.subscribe(); .subscribe();
@@ -99,8 +99,8 @@
</tr> </tr>
<tr> <tr>
<th>Created on</th> <th>Submitted on</th>
<td>{{ data.journalEntry.createdDate }}</td> <td>{{ data.journalEntry.submittedOnDate }}</td>
</tr> </tr>
</table> </table>
@@ -41,11 +41,11 @@
</div> </div>
<div fxFlex="25%" fxFlex.lt-md="50%" class="header"> <div fxFlex="25%" fxFlex.lt-md="50%" class="header">
Created On Submitted on
</div> </div>
<div fxFlex="25%" fxFlex.lt-md="50%"> <div fxFlex="25%" fxFlex.lt-md="50%">
{{ dataSource.data[0].createdDate }} {{ dataSource.data[0].submittedOnDate }}
</div> </div>
</div> </div>