Skip to content

Commit

Permalink
Search and Create Journal entry page is broken - Filtering by dates a…
Browse files Browse the repository at this point in the history
…re broken #1496
  • Loading branch information
adamsaghy committed Aug 5, 2022
1 parent 1c8a772 commit c0dcf9b
Show file tree
Hide file tree
Showing 10 changed files with 113 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ export class CreateClosureComponent implements OnInit {
* @param {Router} router Router for navigation.
*/
constructor(private formBuilder: FormBuilder,
private accountingService: AccountingService,
private settingsService: SettingsService,
private dateUtils: Dates,
private route: ActivatedRoute,
private router: Router) {
private accountingService: AccountingService,
private settingsService: SettingsService,
private dateUtils: Dates,
private route: ActivatedRoute,
private router: Router) {
this.route.data.subscribe((data: { offices: any }) => {
this.officeData = data.offices;
});
Expand Down Expand Up @@ -74,7 +74,7 @@ export class CreateClosureComponent implements OnInit {
accountingClosure.locale = this.settingsService.language.code;
accountingClosure.dateFormat = this.settingsService.dateFormat;
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.router.navigate(['../view', response.resourceId], { relativeTo: this.route });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,22 @@ export class CreateJournalEntryComponent implements OnInit {
* @param {Router} router Router for navigation.
*/
constructor(private formBuilder: FormBuilder,
private accountingService: AccountingService,
private settingsService: SettingsService,
private dateUtils: Dates,
private route: ActivatedRoute,
private router: Router) {
private accountingService: AccountingService,
private settingsService: SettingsService,
private dateUtils: Dates,
private route: ActivatedRoute,
private router: Router) {
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;
this.glAccountData = data.glAccounts;
});
offices: any,
currencies: any,
paymentTypes: any,
glAccounts: any
}) => {
this.officeData = data.offices;
this.currencyData = data.currencies.selectedCurrencyOptions;
this.paymentTypeData = data.paymentTypes;
this.glAccountData = data.glAccounts;
});
}

/**
Expand Down Expand Up @@ -142,7 +142,7 @@ export class CreateJournalEntryComponent implements OnInit {
journalEntry.locale = this.settingsService.language.code;
journalEntry.dateFormat = this.settingsService.dateFormat;
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.router.navigate(['../transactions/view', response.transactionId], { relativeTo: this.route });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ 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.getDate(journalEntry.transactionDate);
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 });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,18 @@ export class MigrateOpeningBalancesComponent implements OnInit {
* @param {Router} router Router for navigation.
*/
constructor(private formBuilder: FormBuilder,
private accountingService: AccountingService,
private settingsService: SettingsService,
private dateUtils: Dates,
private route: ActivatedRoute,
private router: Router) {
private accountingService: AccountingService,
private settingsService: SettingsService,
private dateUtils: Dates,
private route: ActivatedRoute,
private router: Router) {
this.route.data.subscribe((data: {
offices: any,
currencies: any
}) => {
this.officeData = data.offices;
this.currencyData = data.currencies.selectedCurrencyOptions;
});
offices: any,
currencies: any
}) => {
this.officeData = data.offices;
this.currencyData = data.currencies.selectedCurrencyOptions;
});
}

/**
Expand Down Expand Up @@ -111,13 +111,13 @@ export class MigrateOpeningBalancesComponent implements OnInit {

openingBalancesData.glAccounts = openingBalancesData.assetAccountOpeningBalances
.concat(openingBalancesData.liabityAccountOpeningBalances,
openingBalancesData.equityAccountOpeningBalances,
openingBalancesData.incomeAccountOpeningBalances,
openingBalancesData.expenseAccountOpeningBalances);
openingBalancesData.equityAccountOpeningBalances,
openingBalancesData.incomeAccountOpeningBalances,
openingBalancesData.expenseAccountOpeningBalances);

openingBalancesData.glAccounts.forEach((glAccount: any) => {
entry.push(this.createGLAccountEntryForm(glAccount));
});
entry.push(this.createGLAccountEntryForm(glAccount));
});

this.openingBalancesData = openingBalancesData;

Expand All @@ -142,7 +142,7 @@ export class MigrateOpeningBalancesComponent implements OnInit {
openingBalances.locale = this.settingsService.language.code;
openingBalances.dateFormat = this.settingsService.dateFormat;
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.credits = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ export class PeriodicAccrualsComponent implements OnInit {
* @param {Router} router Router for navigation.
*/
constructor(private formBuilder: FormBuilder,
private accountingService: AccountingService,
private settingsService: SettingsService,
private dateUtils: Dates,
private route: ActivatedRoute,
private router: Router) { }
private accountingService: AccountingService,
private settingsService: SettingsService,
private dateUtils: Dates,
private route: ActivatedRoute,
private router: Router) { }

/**
* Creates periodic accruals form.
Expand Down Expand Up @@ -65,7 +65,7 @@ export class PeriodicAccrualsComponent implements OnInit {
periodicAccruals.locale = this.settingsService.language.code;
periodicAccruals.dateFormat = this.settingsService.dateFormat;
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.router.navigate(['../'], { relativeTo: this.route });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ export class CreateProvisioningEntryComponent implements OnInit {
* @param {Router} router Router for navigation.
*/
constructor(private formBuilder: FormBuilder,
private accountingService: AccountingService,
private settingsService: SettingsService,
private dateUtils: Dates,
private route: ActivatedRoute,
private router: Router) { }
private accountingService: AccountingService,
private settingsService: SettingsService,
private dateUtils: Dates,
private route: ActivatedRoute,
private router: Router) { }

/**
* Creates the provisioning entry form.
Expand Down Expand Up @@ -66,7 +66,7 @@ export class CreateProvisioningEntryComponent implements OnInit {
provisioningEntry.locale = this.settingsService.language.code;
provisioningEntry.dateFormat = this.settingsService.dateFormat;
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)
.subscribe((response: any) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@
<input matInput [formControl]="transactionId">
</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>


Expand Down Expand Up @@ -89,6 +103,11 @@
<td mat-cell *matCellDef="let journalEntry"> {{ journalEntry.createdByUserName }} </td>
</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">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Account Code </th>
<td mat-cell *matCellDef="let journalEntry"> {{ journalEntry.glAccountCode }} </td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Component, OnInit, ViewChild, AfterViewInit } from '@angular/core';
import { MatPaginator } from '@angular/material/paginator';
import { MatSort } from '@angular/material/sort';
import { FormControl } from '@angular/forms';
import { Router, ActivatedRoute } from '@angular/router';
import { ActivatedRoute } from '@angular/router';

/** rxjs Imports */
import { merge } from 'rxjs';
Expand Down Expand Up @@ -65,8 +65,12 @@ export class SearchJournalEntryComponent implements OnInit, AfterViewInit {
transactionDateTo = new FormControl(new Date());
/** Transaction ID form control. */
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. */
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. */
dataSource: JournalEntriesDataSource;
/** Journal entries filter. */
Expand All @@ -89,11 +93,19 @@ export class SearchJournalEntryComponent implements OnInit, AfterViewInit {
},
{
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',
value: this.dateUtils.getDate(new Date())
value: this.dateUtils.formatDate(new Date(), this.settingsService.dateFormat)
},
{
type: 'submittedOnDateFrom',
value: ''
},
{
type: 'submittedOnDateTo',
value: ''
},
{
type: 'dateFormat',
Expand Down Expand Up @@ -182,7 +194,7 @@ export class SearchJournalEntryComponent implements OnInit, AfterViewInit {
debounceTime(500),
distinctUntilChanged(),
tap((filterValue) => {
this.applyFilter(this.dateUtils.getDate(filterValue), 'fromDate');
this.applyFilter(this.dateUtils.formatDate(filterValue, this.settingsService.dateFormat), 'fromDate');
})
)
.subscribe();
Expand All @@ -192,7 +204,27 @@ export class SearchJournalEntryComponent implements OnInit, AfterViewInit {
debounceTime(500),
distinctUntilChanged(),
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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ <h1 mat-dialog-title>View Journal Entry</h1>
</tr>

<tr>
<th>Created on</th>
<td>{{ data.journalEntry.createdDate }}</td>
<th>Submitted on</th>
<td>{{ data.journalEntry.submittedOnDate }}</td>
</tr>

</table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@
</div>

<div fxFlex="25%" fxFlex.lt-md="50%" class="header">
Created On
Submitted on
</div>

<div fxFlex="25%" fxFlex.lt-md="50%">
{{ dataSource.data[0].createdDate }}
{{ dataSource.data[0].submittedOnDate }}
</div>

</div>
Expand Down

0 comments on commit c0dcf9b

Please sign in to comment.