Strict done!!
This commit is contained in:
@ -9,4 +9,18 @@ export class LedgerItem {
|
||||
running: number;
|
||||
posted: boolean;
|
||||
url: string;
|
||||
|
||||
public constructor(init?: Partial<LedgerItem>) {
|
||||
this.date = '';
|
||||
this.id = '';
|
||||
this.name = '';
|
||||
this.type = '';
|
||||
this.narration = '';
|
||||
this.debit = 0;
|
||||
this.credit = 0;
|
||||
this.running = 0;
|
||||
this.posted = true;
|
||||
this.url = '';
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { FormBuilder, FormControl, FormGroup } from '@angular/forms';
|
||||
import { MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
|
||||
import { MatPaginator } from '@angular/material/paginator';
|
||||
import { MatSort } from '@angular/material/sort';
|
||||
@ -25,13 +25,13 @@ export class LedgerComponent implements OnInit, AfterViewInit {
|
||||
@ViewChild('accountElement', { static: true }) accountElement?: ElementRef;
|
||||
@ViewChild(MatPaginator, { static: true }) paginator?: MatPaginator;
|
||||
@ViewChild(MatSort, { static: true }) sort?: MatSort;
|
||||
dataSource: LedgerDataSource;
|
||||
info: Ledger = new Ledger();
|
||||
dataSource: LedgerDataSource = new LedgerDataSource(this.info.body);
|
||||
form: FormGroup;
|
||||
info: Ledger;
|
||||
selectedRowId: string;
|
||||
debit: number;
|
||||
credit: number;
|
||||
running: number;
|
||||
selectedRowId = '';
|
||||
debit = 0;
|
||||
credit = 0;
|
||||
running = 0;
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
displayedColumns = ['date', 'particulars', 'type', 'narration', 'debit', 'credit', 'running'];
|
||||
|
||||
@ -51,7 +51,7 @@ export class LedgerComponent implements OnInit, AfterViewInit {
|
||||
account: '',
|
||||
});
|
||||
|
||||
this.accounts = this.form.get('account').valueChanges.pipe(
|
||||
this.accounts = (this.form.get('account') as FormControl).valueChanges.pipe(
|
||||
startWith(null),
|
||||
map((x) => (x !== null && x.length >= 1 ? x : null)),
|
||||
debounceTime(150),
|
||||
@ -71,18 +71,18 @@ export class LedgerComponent implements OnInit, AfterViewInit {
|
||||
startDate: moment(this.info.startDate, 'DD-MMM-YYYY').toDate(),
|
||||
finishDate: moment(this.info.finishDate, 'DD-MMM-YYYY').toDate(),
|
||||
});
|
||||
this.dataSource = new LedgerDataSource(this.paginator, this.sort, this.info.body);
|
||||
this.dataSource = new LedgerDataSource(this.info.body, this.paginator, this.sort);
|
||||
});
|
||||
}
|
||||
|
||||
ngAfterViewInit() {
|
||||
setTimeout(() => {
|
||||
this.accountElement.nativeElement.focus();
|
||||
if (this.accountElement) this.accountElement.nativeElement.focus();
|
||||
}, 0);
|
||||
}
|
||||
|
||||
displayFn(account?: Account): string | undefined {
|
||||
return account ? account.name : undefined;
|
||||
displayFn(account?: Account): string {
|
||||
return account ? account.name : '';
|
||||
}
|
||||
|
||||
calculateTotals() {
|
||||
@ -124,11 +124,11 @@ export class LedgerComponent implements OnInit, AfterViewInit {
|
||||
getInfo(): Ledger {
|
||||
const formModel = this.form.value;
|
||||
|
||||
return {
|
||||
return new Ledger({
|
||||
account: formModel.account,
|
||||
startDate: moment(formModel.startDate).format('DD-MMM-YYYY'),
|
||||
finishDate: moment(formModel.finishDate).format('DD-MMM-YYYY'),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
exportCsv() {
|
||||
|
||||
@ -16,7 +16,7 @@ const serviceName = 'LedgerService';
|
||||
export class LedgerService {
|
||||
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
|
||||
|
||||
list(id: string, startDate: string, finishDate): Observable<Ledger> {
|
||||
list(id: string | null, startDate: string | null, finishDate: string | null): Observable<Ledger> {
|
||||
const listUrl = id === null ? url : `${url}/${id}`;
|
||||
const options = { params: new HttpParams() };
|
||||
if (startDate !== null) {
|
||||
|
||||
@ -6,5 +6,13 @@ export class Ledger {
|
||||
startDate: string;
|
||||
finishDate: string;
|
||||
account: Account;
|
||||
body?: LedgerItem[];
|
||||
body: LedgerItem[];
|
||||
|
||||
public constructor(init?: Partial<Ledger>) {
|
||||
this.startDate = '';
|
||||
this.finishDate = '';
|
||||
this.account = new Account();
|
||||
this.body = [];
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user