Removed the use of any and enabled the rule in eslint.

Now according to me the conversion is final.
Testing is required.
This commit is contained in:
tanshu committed 2020-11-24 08:03:43 +05:30
1 parent 715e35ef38
commit 2972203148
92 files changed
+610 -378

No files matched your search

+1 -1
View File
@@ -38,6 +38,6 @@ module.exports = {
"@typescript-eslint/lines-between-class-members": ["error", "always", { "exceptAfterSingleLine": true }],
"class-methods-use-this": ["error", {"exceptMethods": ["disconnect", "displayFn", "transform"]}],
"import/order": ["error", {"alphabetize": {"order": "asc", "caseInsensitive": true}, "newlines-between": "always"}],
"@typescript-eslint/no-explicit-any": "off", // Disabled for now, but needed to transition to strict compiling
"@typescript-eslint/no-explicit-any": "error",
}
};
+21 -21
View File
@@ -15,14 +15,14 @@
"private": true,
"dependencies": {
"@angular/animations": "^11.0.2",
"@angular/cdk": "^10.2.7",
"@angular/cdk": "^11.0.0",
"@angular/common": "^11.0.2",
"@angular/compiler": "^11.0.2",
"@angular/core": "^11.0.2",
"@angular/flex-layout": "^10.0.0-beta.32",
"@angular/flex-layout": "^11.0.0-beta.33",
"@angular/forms": "^11.0.2",
"@angular/material": "^10.2.7",
"@angular/material-moment-adapter": "^10.2.7",
"@angular/material": "^11.0.0",
"@angular/material-moment-adapter": "^11.0.0",
"@angular/platform-browser": "^11.0.2",
"@angular/platform-browser-dynamic": "^11.0.2",
"@angular/router": "^11.0.2",
@@ -31,49 +31,49 @@
"@ngx-loading-bar/router": "^5.1.0",
"@types/mousetrap": "1.6.3",
"angular2-hotkeys": "^2.2.0",
"core-js": "^3.6.5",
"mathjs": "^7.6.0",
"core-js": "^3.7.0",
"mathjs": "^8.0.1",
"moment": "^2.29.1",
"rxjs": "^6.6.3",
"tslib": "^2.0.0",
"zone.js": "^0.11.2"
"zone.js": "^0.11.3"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.1100.2",
"@angular-eslint/builder": "^0.6.0-beta.0",
"@angular-eslint/eslint-plugin": "^0.6.0-beta.0",
"@angular-eslint/eslint-plugin-template": "^0.6.0-beta.0",
"@angular-eslint/schematics": "^0.6.0-beta.0",
"@angular-eslint/template-parser": "^0.6.0-beta.0",
"@angular-eslint/builder": "^0.8.0-beta.2",
"@angular-eslint/eslint-plugin": "^0.8.0-beta.2",
"@angular-eslint/eslint-plugin-template": "^0.8.0-beta.2",
"@angular-eslint/schematics": "^0.8.0-beta.2",
"@angular-eslint/template-parser": "^0.8.0-beta.2",
"@angular/cli": "^11.0.2",
"@angular/compiler-cli": "^11.0.2",
"@angular/language-service": "^11.0.2",
"@types/jasmine": "~3.6.0",
"@types/jasmine": "~3.6.2",
"@types/jasminewd2": "^2.0.3",
"@types/mathjs": "^6.0.7",
"@types/node": "^14.14.6",
"@typescript-eslint/eslint-plugin": "^4.6.1",
"@typescript-eslint/parser": "^4.6.1",
"@types/node": "^14.14.9",
"@typescript-eslint/eslint-plugin": "^4.8.1",
"@typescript-eslint/parser": "^4.8.1",
"codelyzer": "^6.0.0",
"eslint": "^7.12.1",
"eslint": "^7.14.0",
"eslint-config-airbnb-typescript": "^12.0.0",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsdoc": "^30.7.6",
"eslint-plugin-jsdoc": "^30.7.8",
"husky": "^4.3.0",
"jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~5.0.0",
"jasmine-spec-reporter": "6.0.0",
"karma": "^5.2.3",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~3.0.2",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"lint-staged": "^10.5.1",
"prettier": "^2.1.2",
"prettier": "^2.2.0",
"protractor": "~7.0.0",
"standard-version": "^9.0.0",
"ts-node": "^9.0.0",
"typescript": "^4.0.5"
"typescript": "~4.0.5"
},
"husky": {
"hooks": {
@@ -9,12 +9,14 @@ describe('AccountDetailComponent', () => {
let component: AccountDetailComponent;
let fixture: ComponentFixture<AccountDetailComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [MatDialogModule, ReactiveFormsModule, RouterTestingModule],
declarations: [AccountDetailComponent],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [MatDialogModule, ReactiveFormsModule, RouterTestingModule],
declarations: [AccountDetailComponent],
}).compileComponents();
}),
);
beforeEach(() => {
fixture = TestBed.createComponent(AccountDetailComponent);
@@ -45,7 +45,7 @@ export class AccountListDataSource extends DataSource<Account> {
if (this.paginator) this.paginator.length = x.length;
}),
)
.pipe(map((x: any) => this.getPagedData(this.getSortedData(x))));
.pipe(map((x: Account[]) => this.getPagedData(this.getSortedData(x))));
}
disconnect() {}
+3 -3
View File
@@ -176,9 +176,9 @@ const appRoutes: Routes = [
imports: [
CommonModule,
RouterModule.forRoot(appRoutes, {
onSameUrlNavigation: 'reload',
relativeLinkResolution: 'legacy'
}),
onSameUrlNavigation: 'reload',
relativeLinkResolution: 'legacy',
}),
],
exports: [RouterModule],
declarations: [],
+32 -21
View File
@@ -2,25 +2,36 @@ import { TestBed, waitForAsync } from '@angular/core/testing';
import { AppComponent } from './app.component';
describe('AppComponent', () => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [AppComponent],
}).compileComponents();
}));
it('should create the app', waitForAsync(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
}));
it(`should have as title 'app'`, waitForAsync(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app.title).toEqual('app');
}));
it('should render title in a h1 tag', waitForAsync(() => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!');
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [AppComponent],
}).compileComponents();
}),
);
it(
'should create the app',
waitForAsync(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
}),
);
it(
`should have as title 'app'`,
waitForAsync(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app.title).toEqual('app');
}),
);
it(
'should render title in a h1 tag',
waitForAsync(() => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!');
}),
);
});
@@ -61,9 +61,7 @@
<mat-header-cell *matHeaderCellDef>Prints</mat-header-cell>
<mat-cell *matCellDef="let row; let i = index" class="no-bg">
{{ row.prints }}
<mat-icon *ngIf="!$any(form.controls.attendances).controls[i].pristine"
>new_releases</mat-icon
>
<mat-icon *ngIf="!attendancesArray.controls[i].pristine">new_releases</mat-icon>
<mat-chip-list class="no-bg">
<mat-chip
*ngIf="row.hoursWorked.length"
@@ -9,12 +9,14 @@ describe('AttendanceComponent', () => {
let component: AttendanceComponent;
let fixture: ComponentFixture<AttendanceComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [MatDialogModule, ReactiveFormsModule, RouterTestingModule],
declarations: [AttendanceComponent],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [MatDialogModule, ReactiveFormsModule, RouterTestingModule],
declarations: [AttendanceComponent],
}).compileComponents();
}),
);
beforeEach(() => {
fixture = TestBed.createComponent(AttendanceComponent);
@@ -100,4 +100,8 @@ export class AttendanceComponent implements OnInit {
});
return this.info;
}
get attendancesArray(): FormArray {
return this.form.get('attendances') as FormArray;
}
}
+2 -2
View File
@@ -83,7 +83,7 @@ export class AuthService {
formData.append('otp', otp);
formData.append('grant_type', 'password');
return this.http
.post<any>(loginUrl, formData)
.post<{ access_token: string; token_type: string }>(loginUrl, formData)
.pipe(map((u) => u.access_token))
.pipe(map((u) => AuthService.parseJwt(u)))
.pipe(
@@ -113,7 +113,7 @@ export class AuthService {
refreshToken() {
return this.http
.post<any>(refreshUrl, {})
.post<{ access_token: string; token_type: string }>(refreshUrl, {})
.pipe(map((u) => u.access_token))
.pipe(map((u) => AuthService.parseJwt(u)))
.pipe(
@@ -8,12 +8,14 @@ describe('LoginComponent', () => {
let component: LoginComponent;
let fixture: ComponentFixture<LoginComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [HttpClientModule, RouterTestingModule],
declarations: [LoginComponent],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [HttpClientModule, RouterTestingModule],
declarations: [LoginComponent],
}).compileComponents();
}),
);
beforeEach(() => {
fixture = TestBed.createComponent(LoginComponent);
@@ -8,12 +8,14 @@ describe('LogoutComponent', () => {
let component: LogoutComponent;
let fixture: ComponentFixture<LogoutComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [HttpClientModule, RouterTestingModule],
declarations: [LogoutComponent],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [HttpClientModule, RouterTestingModule],
declarations: [LogoutComponent],
}).compileComponents();
}),
);
beforeEach(() => {
fixture = TestBed.createComponent(LogoutComponent);
@@ -5,19 +5,27 @@ import { MatSort, Sort } from '@angular/material/sort';
import { merge, Observable, of as observableOf } from 'rxjs';
import { map } from 'rxjs/operators';
import { BalanceSheetItem } from './balance-sheet-item';
/** Simple sort comparator for example ID/Name columns (for client-side sorting). */
function compare(a: string | number, b: string | number, isAsc: boolean) {
return (a < b ? -1 : 1) * (isAsc ? 1 : -1);
}
export class BalanceSheetDataSource extends DataSource<any> {
constructor(public data: any[], private paginator?: MatPaginator, private sort?: MatSort) {
export class BalanceSheetDataSource extends DataSource<BalanceSheetItem> {
constructor(
public data: BalanceSheetItem[],
private paginator?: MatPaginator,
private sort?: MatSort,
) {
super();
}
connect(): Observable<any[]> {
const dataMutations: (Observable<any[]> | EventEmitter<PageEvent> | EventEmitter<Sort>)[] = [
observableOf(this.data),
];
connect(): Observable<BalanceSheetItem[]> {
const dataMutations: (
| Observable<BalanceSheetItem[]>
| EventEmitter<PageEvent>
| EventEmitter<Sort>
)[] = [observableOf(this.data)];
if (this.paginator) dataMutations.push((this.paginator as MatPaginator).page);
if (this.sort) dataMutations.push((this.sort as MatSort).sortChange);
@@ -31,13 +39,13 @@ export class BalanceSheetDataSource extends DataSource<any> {
disconnect() {}
private getPagedData(data: any[]) {
private getPagedData(data: BalanceSheetItem[]) {
if (this.paginator === undefined) return data;
const startIndex = this.paginator.pageIndex * this.paginator.pageSize;
return data.splice(startIndex, this.paginator.pageSize);
}
private getSortedData(data: any[]) {
private getSortedData(data: BalanceSheetItem[]) {
if (this.sort === undefined) return data;
if (!this.sort.active || this.sort.direction === '') {
return data;
@@ -48,9 +56,8 @@ export class BalanceSheetDataSource extends DataSource<any> {
const isAsc = sort.direction === 'asc';
switch (sort.active) {
case 'name':
if (a.name === undefined || b.name === undefined) return 0;
return compare(a.name, b.name, isAsc);
case 'id':
return compare(+a.id, +b.id, isAsc);
default:
return 0;
}
@@ -8,12 +8,14 @@ describe('BalanceSheetComponent', () => {
let component: BalanceSheetComponent;
let fixture: ComponentFixture<BalanceSheetComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [ReactiveFormsModule, RouterTestingModule],
declarations: [BalanceSheetComponent],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [ReactiveFormsModule, RouterTestingModule],
declarations: [BalanceSheetComponent],
}).compileComponents();
}),
);
beforeEach(() => {
fixture = TestBed.createComponent(BalanceSheetComponent);
@@ -8,12 +8,14 @@ describe('CashFlowComponent', () => {
let component: CashFlowComponent;
let fixture: ComponentFixture<CashFlowComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [ReactiveFormsModule, RouterTestingModule],
declarations: [CashFlowComponent],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [ReactiveFormsModule, RouterTestingModule],
declarations: [CashFlowComponent],
}).compileComponents();
}),
);
beforeEach(() => {
fixture = TestBed.createComponent(CashFlowComponent);
@@ -9,12 +9,14 @@ describe('ClientDetailComponent', () => {
let component: ClientDetailComponent;
let fixture: ComponentFixture<ClientDetailComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [MatDialogModule, ReactiveFormsModule, RouterTestingModule],
declarations: [ClientDetailComponent],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [MatDialogModule, ReactiveFormsModule, RouterTestingModule],
declarations: [ClientDetailComponent],
}).compileComponents();
}),
);
beforeEach(() => {
fixture = TestBed.createComponent(ClientDetailComponent);
@@ -8,12 +8,14 @@ describe('ClosingStockComponent', () => {
let component: ClosingStockComponent;
let fixture: ComponentFixture<ClosingStockComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [ReactiveFormsModule, RouterTestingModule],
declarations: [ClosingStockComponent],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [ReactiveFormsModule, RouterTestingModule],
declarations: [ClosingStockComponent],
}).compileComponents();
}),
);
beforeEach(() => {
fixture = TestBed.createComponent(ClosingStockComponent);
+10
View File
@@ -0,0 +1,10 @@
export class AccountBalance {
date: number;
total: number;
public constructor(init?: Partial<AccountBalance>) {
this.date = 0;
this.total = 0;
Object.assign(this, init);
}
}
+4 -3
View File
@@ -4,6 +4,7 @@ import { Observable } from 'rxjs/internal/Observable';
import { catchError } from 'rxjs/operators';
import { Account } from './account';
import { AccountBalance } from './account-balance';
import { ErrorLoggerService } from './error-logger.service';
const httpOptions = {
@@ -92,11 +93,11 @@ export class AccountService {
);
}
balance(id: string, date: string): Observable<any> {
balance(id: string, date: string): Observable<AccountBalance> {
const options = { params: new HttpParams().set('d', date) };
return <Observable<any>>(
return <Observable<AccountBalance>>(
this.http
.get<any>(`${url}/${id}/balance`, options)
.get<AccountBalance>(`${url}/${id}/balance`, options)
.pipe(catchError(this.log.handleError(serviceName, 'balance')))
);
}
@@ -19,7 +19,7 @@ export class ErrorLoggerService {
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars, class-methods-use-this
public handleError<T>(serviceName = 'error-logger', operation = 'operation', result?: T) {
return (error: any): Observable<T> => {
return (error: unknown): Observable<T> => {
ErrorLoggerService.log(serviceName, `${operation} failed: ${error}`);
return throwError(error);
};
@@ -19,7 +19,7 @@ export class ErrorInterceptor implements HttpInterceptor {
private toaster: ToasterService,
) {}
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
intercept(request: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>> {
return next.handle(request).pipe(
catchError((err) => {
// We don't want to refresh token for some requests like login or refresh token itself
+14
View File
@@ -0,0 +1,14 @@
export class IssueGridItem {
id: string;
amount: number;
source: string;
destination: string;
public constructor(init?: Partial<IssueGridItem>) {
this.id = '';
this.amount = 0;
this.source = '';
this.destination = '';
Object.assign(this, init);
}
}
+1 -1
View File
@@ -10,7 +10,7 @@ export class JwtInterceptor implements HttpInterceptor {
constructor(private authService: AuthService) {}
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
intercept(request: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>> {
// add authorization header with jwt token if available
// We use this line to debug token refreshing
@@ -8,12 +8,14 @@ describe('CostCentreDetailComponent', () => {
let component: CostCentreDetailComponent;
let fixture: ComponentFixture<CostCentreDetailComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [ReactiveFormsModule, RouterTestingModule],
declarations: [CostCentreDetailComponent],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [ReactiveFormsModule, RouterTestingModule],
declarations: [CostCentreDetailComponent],
}).compileComponents();
}),
);
beforeEach(() => {
fixture = TestBed.createComponent(CostCentreDetailComponent);
@@ -8,12 +8,14 @@ describe('DaybookComponent', () => {
let component: DaybookComponent;
let fixture: ComponentFixture<DaybookComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [ReactiveFormsModule, RouterTestingModule],
declarations: [DaybookComponent],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [ReactiveFormsModule, RouterTestingModule],
declarations: [DaybookComponent],
}).compileComponents();
}),
);
beforeEach(() => {
fixture = TestBed.createComponent(DaybookComponent);
@@ -90,9 +90,7 @@
<mat-header-cell *matHeaderCellDef>Prints</mat-header-cell>
<mat-cell *matCellDef="let row; let i = index" class="no-bg">
{{ row.prints }}
<mat-icon *ngIf="!$any(form.controls.attendances).controls[i].pristine"
>new_releases</mat-icon
>
<mat-icon *ngIf="!attendancesArray.controls[i].pristine">new_releases</mat-icon>
<mat-chip-list class="no-bg">
<mat-chip
*ngIf="row.hoursWorked.length"
@@ -147,4 +147,8 @@ export class EmployeeAttendanceComponent implements OnInit, AfterViewInit {
});
return this.info;
}
get attendancesArray(): FormArray {
return this.form.get('attendances') as FormArray;
}
}
@@ -8,6 +8,7 @@ import { BehaviorSubject, Observable, of as observableOf } from 'rxjs';
import { debounceTime, distinctUntilChanged, map, startWith, switchMap } from 'rxjs/operators';
import { AuthService } from '../auth/auth.service';
import { AccountBalance } from '../core/account-balance';
import { EmployeeBenefit } from '../core/employee-benefit';
import { ToasterService } from '../core/toaster.service';
import { User } from '../core/user';
@@ -31,7 +32,7 @@ export class EmployeeBenefitsComponent implements OnInit, AfterViewInit {
form: FormGroup;
voucher: Voucher = new Voucher();
employee: Employee | null = null;
accBal: any;
accBal: AccountBalance | null = null;
displayedColumns = [
'name',
@@ -9,12 +9,14 @@ describe('EmployeeDetailComponent', () => {
let component: EmployeeDetailComponent;
let fixture: ComponentFixture<EmployeeDetailComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [MatDialogModule, ReactiveFormsModule, RouterTestingModule],
declarations: [EmployeeDetailComponent],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [MatDialogModule, ReactiveFormsModule, RouterTestingModule],
declarations: [EmployeeDetailComponent],
}).compileComponents();
}),
);
beforeEach(() => {
fixture = TestBed.createComponent(EmployeeDetailComponent);
@@ -45,7 +45,7 @@ export class EmployeeListDataSource extends DataSource<Employee> {
if (this.paginator) this.paginator.length = x.length;
}),
)
.pipe(map((x: any) => this.getPagedData(this.getSortedData(x))));
.pipe(map((x: Employee[]) => this.getPagedData(this.getSortedData(x))));
}
disconnect() {}
+7 -5
View File
@@ -6,11 +6,13 @@ describe('HomeComponent', () => {
let component: HomeComponent;
let fixture: ComponentFixture<HomeComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [HomeComponent],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [HomeComponent],
}).compileComponents();
}),
);
beforeEach(() => {
fixture = TestBed.createComponent(HomeComponent);
@@ -9,12 +9,14 @@ describe('IncentiveComponent', () => {
let component: IncentiveComponent;
let fixture: ComponentFixture<IncentiveComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [MatDialogModule, ReactiveFormsModule, RouterTestingModule],
declarations: [IncentiveComponent],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [MatDialogModule, ReactiveFormsModule, RouterTestingModule],
declarations: [IncentiveComponent],
}).compileComponents();
}),
);
beforeEach(() => {
fixture = TestBed.createComponent(IncentiveComponent);
@@ -8,6 +8,7 @@ import { map } from 'rxjs/operators';
import { AuthService } from '../auth/auth.service';
import { Account } from '../core/account';
import { AccountBalance } from '../core/account-balance';
import { Incentive } from '../core/incentive';
import { ToasterService } from '../core/toaster.service';
import { User } from '../core/user';
@@ -28,7 +29,7 @@ export class IncentiveComponent implements OnInit {
form: FormGroup;
voucher: Voucher = new Voucher();
account: Account = new Account();
accBal: any;
accBal: AccountBalance | null = null;
displayedColumns = ['name', 'designation', 'department', 'daysWorked', 'points', 'amount'];
@@ -6,11 +6,13 @@ describe('IssueDialogComponent', () => {
let component: IssueDialogComponent;
let fixture: ComponentFixture<IssueDialogComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [IssueDialogComponent],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [IssueDialogComponent],
}).compileComponents();
}),
);
beforeEach(() => {
fixture = TestBed.createComponent(IssueDialogComponent);
@@ -7,6 +7,7 @@ import { debounceTime, distinctUntilChanged, startWith, switchMap } from 'rxjs/o
import { Batch } from '../core/batch';
import { BatchService } from '../core/batch.service';
import { Inventory } from '../core/inventory';
import { MathService } from '../shared/math.service';
@Component({
@@ -21,7 +22,7 @@ export class IssueDialogComponent implements OnInit {
constructor(
public dialogRef: MatDialogRef<IssueDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: any,
@Inject(MAT_DIALOG_DATA) public data: { inventory: Inventory; date: string },
private fb: FormBuilder,
private math: MathService,
private batchSer: BatchService,
@@ -44,7 +45,7 @@ export class IssueDialogComponent implements OnInit {
batch: this.data.inventory.batch,
quantity: this.data.inventory.quantity,
});
this.batch = this.data.inventory.batch;
this.batch = this.data.inventory.batch as Batch;
}
displayFn(batch?: Batch): string {
@@ -1,12 +1,14 @@
import { DataSource } from '@angular/cdk/collections';
import { Observable } from 'rxjs';
export class IssueGridDataSource extends DataSource<any> {
constructor(private data: Observable<any[]>) {
import { IssueGridItem } from '../core/issue-grid-item';
export class IssueGridDataSource extends DataSource<IssueGridItem> {
constructor(private data: Observable<IssueGridItem[]>) {
super();
}
connect(): Observable<any[]> {
connect(): Observable<IssueGridItem[]> {
return this.data;
}
+4 -3
View File
@@ -4,6 +4,7 @@ import { Observable } from 'rxjs/internal/Observable';
import { catchError } from 'rxjs/operators';
import { ErrorLoggerService } from '../core/error-logger.service';
import { IssueGridItem } from '../core/issue-grid-item';
const url = '/api/issue-grid';
const serviceName = 'IssueGridService';
@@ -14,10 +15,10 @@ const serviceName = 'IssueGridService';
export class IssueGridService {
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
issueGrid(date: string): Observable<any[]> {
return <Observable<any[]>>(
issueGrid(date: string): Observable<IssueGridItem[]> {
return <Observable<IssueGridItem[]>>(
this.http
.get<any[]>(`${url}/${date}`)
.get<IssueGridItem[]>(`${url}/${date}`)
.pipe(catchError(this.log.handleError(serviceName, 'autocomplete')))
);
}
@@ -9,12 +9,14 @@ describe('IssueComponent', () => {
let component: IssueComponent;
let fixture: ComponentFixture<IssueComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [MatDialogModule, ReactiveFormsModule, RouterTestingModule],
declarations: [IssueComponent],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [MatDialogModule, ReactiveFormsModule, RouterTestingModule],
declarations: [IssueComponent],
}).compileComponents();
}),
);
beforeEach(() => {
fixture = TestBed.createComponent(IssueComponent);
+2 -1
View File
@@ -14,6 +14,7 @@ import { Batch } from '../core/batch';
import { BatchService } from '../core/batch.service';
import { CostCentre } from '../core/cost-centre';
import { Inventory } from '../core/inventory';
import { IssueGridItem } from '../core/issue-grid-item';
import { ToasterService } from '../core/toaster.service';
import { User } from '../core/user';
import { Voucher } from '../core/voucher';
@@ -35,7 +36,7 @@ export class IssueComponent implements OnInit, AfterViewInit, OnDestroy {
@ViewChild('batchElement', { static: true }) batchElement?: ElementRef;
@ViewChild('dateElement', { static: true }) dateElement?: ElementRef;
public inventoryObservable = new BehaviorSubject<Inventory[]>([]);
public gridObservable = new BehaviorSubject<any[]>([]);
public gridObservable = new BehaviorSubject<IssueGridItem[]>([]);
dataSource: IssueDataSource = new IssueDataSource(this.inventoryObservable);
gridDataSource: IssueGridDataSource = new IssueGridDataSource(this.gridObservable);
form: FormGroup;
@@ -6,11 +6,13 @@ describe('JournalDialogComponent', () => {
let component: JournalDialogComponent;
let fixture: ComponentFixture<JournalDialogComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [JournalDialogComponent],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [JournalDialogComponent],
}).compileComponents();
}),
);
beforeEach(() => {
fixture = TestBed.createComponent(JournalDialogComponent);
@@ -6,7 +6,9 @@ import { Observable, of as observableOf } from 'rxjs';
import { debounceTime, distinctUntilChanged, map, startWith, switchMap } from 'rxjs/operators';
import { Account } from '../core/account';
import { AccountBalance } from '../core/account-balance';
import { AccountService } from '../core/account.service';
import { Journal } from '../core/journal';
import { MathService } from '../shared/math.service';
@Component({
@@ -18,11 +20,11 @@ export class JournalDialogComponent implements OnInit {
accounts: Observable<Account[]>;
form: FormGroup;
account: Account = new Account();
accBal: any;
accBal: AccountBalance | null = null;
constructor(
public dialogRef: MatDialogRef<JournalDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: any,
@Inject(MAT_DIALOG_DATA) public data: { journal: Journal; date: string },
private fb: FormBuilder,
private math: MathService,
private accountSer: AccountService,
@@ -9,12 +9,14 @@ describe('JournalComponent', () => {
let component: JournalComponent;
let fixture: ComponentFixture<JournalComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [MatDialogModule, ReactiveFormsModule, RouterTestingModule],
declarations: [JournalComponent],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [MatDialogModule, ReactiveFormsModule, RouterTestingModule],
declarations: [JournalComponent],
}).compileComponents();
}),
);
beforeEach(() => {
fixture = TestBed.createComponent(JournalComponent);
@@ -11,6 +11,7 @@ import { debounceTime, distinctUntilChanged, map, startWith, switchMap } from 'r
import { AuthService } from '../auth/auth.service';
import { Account } from '../core/account';
import { AccountBalance } from '../core/account-balance';
import { AccountService } from '../core/account.service';
import { DbFile } from '../core/db-file';
import { Journal } from '../core/journal';
@@ -39,7 +40,7 @@ export class JournalComponent implements OnInit, AfterViewInit, OnDestroy {
form: FormGroup;
voucher: Voucher = new Voucher();
account: Account | null;
accBal: any;
accBal: AccountBalance | null = null;
displayedColumns = ['debit', 'account', 'amount', 'action'];
@@ -9,12 +9,14 @@ describe('LedgerComponent', () => {
let component: LedgerComponent;
let fixture: ComponentFixture<LedgerComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [HttpClientModule, ReactiveFormsModule, RouterTestingModule],
declarations: [LedgerComponent],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [HttpClientModule, ReactiveFormsModule, RouterTestingModule],
declarations: [LedgerComponent],
}).compileComponents();
}),
);
beforeEach(() => {
fixture = TestBed.createComponent(LedgerComponent);
@@ -8,12 +8,14 @@ describe('NetTransactionsComponent', () => {
let component: NetTransactionsComponent;
let fixture: ComponentFixture<NetTransactionsComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [ReactiveFormsModule, RouterTestingModule],
declarations: [NetTransactionsComponent],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [ReactiveFormsModule, RouterTestingModule],
declarations: [NetTransactionsComponent],
}).compileComponents();
}),
);
beforeEach(() => {
fixture = TestBed.createComponent(NetTransactionsComponent);
@@ -6,11 +6,13 @@ describe('PaymentDialogComponent', () => {
let component: PaymentDialogComponent;
let fixture: ComponentFixture<PaymentDialogComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [PaymentDialogComponent],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [PaymentDialogComponent],
}).compileComponents();
}),
);
beforeEach(() => {
fixture = TestBed.createComponent(PaymentDialogComponent);
@@ -6,7 +6,9 @@ import { Observable, of as observableOf } from 'rxjs';
import { debounceTime, distinctUntilChanged, map, startWith, switchMap } from 'rxjs/operators';
import { Account } from '../core/account';
import { AccountBalance } from '../core/account-balance';
import { AccountService } from '../core/account.service';
import { Journal } from '../core/journal';
import { MathService } from '../shared/math.service';
@Component({
@@ -18,11 +20,11 @@ export class PaymentDialogComponent implements OnInit {
accounts: Observable<Account[]>;
form: FormGroup;
account: Account = new Account();
accBal: any;
accBal: AccountBalance | null = null;
constructor(
public dialogRef: MatDialogRef<PaymentDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: any,
@Inject(MAT_DIALOG_DATA) public data: { journal: Journal; date: string },
private fb: FormBuilder,
private math: MathService,
private accountSer: AccountService,
@@ -9,12 +9,14 @@ describe('PaymentComponent', () => {
let component: PaymentComponent;
let fixture: ComponentFixture<PaymentComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [MatDialogModule, ReactiveFormsModule, RouterTestingModule],
declarations: [PaymentComponent],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [MatDialogModule, ReactiveFormsModule, RouterTestingModule],
declarations: [PaymentComponent],
}).compileComponents();
}),
);
beforeEach(() => {
fixture = TestBed.createComponent(PaymentComponent);
@@ -11,6 +11,7 @@ import { debounceTime, distinctUntilChanged, map, startWith, switchMap } from 'r
import { AuthService } from '../auth/auth.service';
import { Account } from '../core/account';
import { AccountBalance } from '../core/account-balance';
import { AccountService } from '../core/account.service';
import { DbFile } from '../core/db-file';
import { Journal } from '../core/journal';
@@ -41,7 +42,7 @@ export class PaymentComponent implements OnInit, AfterViewInit, OnDestroy {
paymentJournal: Journal = new Journal();
voucher: Voucher = new Voucher();
account: Account | null;
accBal: any;
accBal: AccountBalance | null = null;
displayedColumns = ['account', 'amount', 'action'];
@@ -8,12 +8,14 @@ describe('ProductGroupDetailComponent', () => {
let component: ProductGroupDetailComponent;
let fixture: ComponentFixture<ProductGroupDetailComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [ReactiveFormsModule, RouterTestingModule],
declarations: [ProductGroupDetailComponent],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [ReactiveFormsModule, RouterTestingModule],
declarations: [ProductGroupDetailComponent],
}).compileComponents();
}),
);
beforeEach(() => {
fixture = TestBed.createComponent(ProductGroupDetailComponent);
@@ -9,12 +9,14 @@ describe('ProductLedgerComponent', () => {
let component: ProductLedgerComponent;
let fixture: ComponentFixture<ProductLedgerComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [HttpClientModule, ReactiveFormsModule, RouterTestingModule],
declarations: [ProductLedgerComponent],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [HttpClientModule, ReactiveFormsModule, RouterTestingModule],
declarations: [ProductLedgerComponent],
}).compileComponents();
}),
);
beforeEach(() => {
fixture = TestBed.createComponent(ProductLedgerComponent);
@@ -9,12 +9,14 @@ describe('ProductDetailComponent', () => {
let component: ProductDetailComponent;
let fixture: ComponentFixture<ProductDetailComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [MatDialogModule, ReactiveFormsModule, RouterTestingModule],
declarations: [ProductDetailComponent],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [MatDialogModule, ReactiveFormsModule, RouterTestingModule],
declarations: [ProductDetailComponent],
}).compileComponents();
}),
);
beforeEach(() => {
fixture = TestBed.createComponent(ProductDetailComponent);
@@ -45,7 +45,7 @@ export class ProductListDataSource extends DataSource<Product> {
if (this.paginator) this.paginator.length = x.length;
}),
)
.pipe(map((x: any) => this.getPagedData(this.getSortedData(x))));
.pipe(map((x: Product[]) => this.getPagedData(this.getSortedData(x))));
}
disconnect() {}
@@ -8,12 +8,14 @@ describe('ProfitLossComponent', () => {
let component: ProfitLossComponent;
let fixture: ComponentFixture<ProfitLossComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [ReactiveFormsModule, RouterTestingModule],
declarations: [ProfitLossComponent],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [ReactiveFormsModule, RouterTestingModule],
declarations: [ProfitLossComponent],
}).compileComponents();
}),
);
beforeEach(() => {
fixture = TestBed.createComponent(ProfitLossComponent);
@@ -8,12 +8,14 @@ describe('PurchaseEntriesComponent', () => {
let component: PurchaseEntriesComponent;
let fixture: ComponentFixture<PurchaseEntriesComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [ReactiveFormsModule, RouterTestingModule],
declarations: [PurchaseEntriesComponent],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [ReactiveFormsModule, RouterTestingModule],
declarations: [PurchaseEntriesComponent],
}).compileComponents();
}),
);
beforeEach(() => {
fixture = TestBed.createComponent(PurchaseEntriesComponent);
@@ -6,11 +6,13 @@ describe('PurchaseReturnDialogComponent', () => {
let component: PurchaseReturnDialogComponent;
let fixture: ComponentFixture<PurchaseReturnDialogComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [PurchaseReturnDialogComponent],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [PurchaseReturnDialogComponent],
}).compileComponents();
}),
);
beforeEach(() => {
fixture = TestBed.createComponent(PurchaseReturnDialogComponent);
@@ -7,6 +7,7 @@ import { debounceTime, distinctUntilChanged, startWith, switchMap } from 'rxjs/o
import { Batch } from '../core/batch';
import { BatchService } from '../core/batch.service';
import { Inventory } from '../core/inventory';
import { MathService } from '../shared/math.service';
@Component({
@@ -21,7 +22,7 @@ export class PurchaseReturnDialogComponent implements OnInit {
constructor(
public dialogRef: MatDialogRef<PurchaseReturnDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: any,
@Inject(MAT_DIALOG_DATA) public data: { inventory: Inventory; date: string },
private fb: FormBuilder,
private math: MathService,
private batchSer: BatchService,
@@ -44,7 +45,7 @@ export class PurchaseReturnDialogComponent implements OnInit {
batch: this.data.inventory.batch,
quantity: this.data.inventory.quantity,
});
this.batch = this.data.inventory.batch;
this.batch = this.data.inventory.batch as Batch;
}
displayFn(batch?: Batch): string {
@@ -9,12 +9,14 @@ describe('PurchaseReturnComponent', () => {
let component: PurchaseReturnComponent;
let fixture: ComponentFixture<PurchaseReturnComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [MatDialogModule, ReactiveFormsModule, RouterTestingModule],
declarations: [PurchaseReturnComponent],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [MatDialogModule, ReactiveFormsModule, RouterTestingModule],
declarations: [PurchaseReturnComponent],
}).compileComponents();
}),
);
beforeEach(() => {
fixture = TestBed.createComponent(PurchaseReturnComponent);
@@ -11,6 +11,7 @@ import { debounceTime, distinctUntilChanged, map, startWith, switchMap } from 'r
import { AuthService } from '../auth/auth.service';
import { Account } from '../core/account';
import { AccountBalance } from '../core/account-balance';
import { AccountService } from '../core/account.service';
import { Batch } from '../core/batch';
import { BatchService } from '../core/batch.service';
@@ -42,7 +43,7 @@ export class PurchaseReturnComponent implements OnInit, AfterViewInit, OnDestroy
form: FormGroup;
voucher: Voucher = new Voucher();
batch: Batch | null = null;
accBal: any;
accBal: AccountBalance | null = null;
displayedColumns = ['product', 'quantity', 'rate', 'tax', 'discount', 'amount', 'action'];
@@ -7,11 +7,13 @@ describe('PurchaseDialogComponent', () => {
let component: PurchaseDialogComponent;
let fixture: ComponentFixture<PurchaseDialogComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [MatDialogModule, PurchaseDialogComponent],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [MatDialogModule, PurchaseDialogComponent],
}).compileComponents();
}),
);
beforeEach(() => {
fixture = TestBed.createComponent(PurchaseDialogComponent);
@@ -6,6 +6,7 @@ import { round } from 'mathjs';
import { Observable, of as observableOf } from 'rxjs';
import { debounceTime, distinctUntilChanged, map, startWith, switchMap } from 'rxjs/operators';
import { Inventory } from '../core/inventory';
import { Product } from '../core/product';
import { ProductService } from '../product/product.service';
import { MathService } from '../shared/math.service';
@@ -22,7 +23,7 @@ export class PurchaseDialogComponent implements OnInit {
constructor(
public dialogRef: MatDialogRef<PurchaseDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: any,
@Inject(MAT_DIALOG_DATA) public data: { inventory: Inventory },
private fb: FormBuilder,
private math: MathService,
private productSer: ProductService,
@@ -9,12 +9,14 @@ describe('PurchaseComponent', () => {
let component: PurchaseComponent;
let fixture: ComponentFixture<PurchaseComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [MatDialogModule, ReactiveFormsModule, RouterTestingModule],
declarations: [PurchaseComponent],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [MatDialogModule, ReactiveFormsModule, RouterTestingModule],
declarations: [PurchaseComponent],
}).compileComponents();
}),
);
beforeEach(() => {
fixture = TestBed.createComponent(PurchaseComponent);
@@ -11,6 +11,7 @@ import { debounceTime, distinctUntilChanged, map, startWith, switchMap } from 'r
import { AuthService } from '../auth/auth.service';
import { Account } from '../core/account';
import { AccountBalance } from '../core/account-balance';
import { AccountService } from '../core/account.service';
import { DbFile } from '../core/db-file';
import { Inventory } from '../core/inventory';
@@ -42,7 +43,7 @@ export class PurchaseComponent implements OnInit, AfterViewInit, OnDestroy {
form: FormGroup;
voucher: Voucher = new Voucher();
product: Product | null = null;
accBal: any;
accBal: AccountBalance | null = null;
displayedColumns = ['product', 'quantity', 'rate', 'tax', 'discount', 'amount', 'action'];
@@ -9,12 +9,14 @@ describe('PurchasesComponent', () => {
let component: PurchasesComponent;
let fixture: ComponentFixture<PurchasesComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [MatDialogModule, ReactiveFormsModule, RouterTestingModule],
declarations: [PurchasesComponent],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [MatDialogModule, ReactiveFormsModule, RouterTestingModule],
declarations: [PurchasesComponent],
}).compileComponents();
}),
);
beforeEach(() => {
fixture = TestBed.createComponent(PurchasesComponent);
@@ -8,12 +8,14 @@ describe('RawMaterialCostComponent', () => {
let component: RawMaterialCostComponent;
let fixture: ComponentFixture<RawMaterialCostComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [ReactiveFormsModule, RouterTestingModule],
declarations: [RawMaterialCostComponent],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [ReactiveFormsModule, RouterTestingModule],
declarations: [RawMaterialCostComponent],
}).compileComponents();
}),
);
beforeEach(() => {
fixture = TestBed.createComponent(RawMaterialCostComponent);
@@ -7,12 +7,14 @@ describe('ReceiptDialogComponent', () => {
let component: ReceiptDialogComponent;
let fixture: ComponentFixture<ReceiptDialogComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [MatDialogRef],
declarations: [ReceiptDialogComponent],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [MatDialogRef],
declarations: [ReceiptDialogComponent],
}).compileComponents();
}),
);
beforeEach(() => {
fixture = TestBed.createComponent(ReceiptDialogComponent);
@@ -6,7 +6,9 @@ import { Observable, of as observableOf } from 'rxjs';
import { debounceTime, distinctUntilChanged, map, startWith, switchMap } from 'rxjs/operators';
import { Account } from '../core/account';
import { AccountBalance } from '../core/account-balance';
import { AccountService } from '../core/account.service';
import { Journal } from '../core/journal';
import { MathService } from '../shared/math.service';
@Component({
@@ -18,11 +20,11 @@ export class ReceiptDialogComponent implements OnInit {
accounts: Observable<Account[]>;
form: FormGroup;
account: Account = new Account();
accBal: any;
accBal: AccountBalance | null = null;
constructor(
public dialogRef: MatDialogRef<ReceiptDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: any,
@Inject(MAT_DIALOG_DATA) public data: { journal: Journal; date: string },
private fb: FormBuilder,
private math: MathService,
private accountSer: AccountService,
@@ -9,12 +9,14 @@ describe('ReceiptComponent', () => {
let component: ReceiptComponent;
let fixture: ComponentFixture<ReceiptComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [MatDialogModule, ReactiveFormsModule, RouterTestingModule],
declarations: [ReceiptComponent],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [MatDialogModule, ReactiveFormsModule, RouterTestingModule],
declarations: [ReceiptComponent],
}).compileComponents();
}),
);
beforeEach(() => {
fixture = TestBed.createComponent(ReceiptComponent);
@@ -11,6 +11,7 @@ import { debounceTime, distinctUntilChanged, map, startWith, switchMap } from 'r
import { AuthService } from '../auth/auth.service';
import { Account } from '../core/account';
import { AccountBalance } from '../core/account-balance';
import { AccountService } from '../core/account.service';
import { DbFile } from '../core/db-file';
import { Journal } from '../core/journal';
@@ -41,7 +42,7 @@ export class ReceiptComponent implements OnInit, AfterViewInit, OnDestroy {
receiptJournal: Journal = new Journal();
voucher: Voucher = new Voucher();
account: Account | null = null;
accBal: any;
accBal: AccountBalance | null = null;
displayedColumns = ['account', 'amount', 'action'];
@@ -8,12 +8,14 @@ describe('RoleDetailComponent', () => {
let component: RoleDetailComponent;
let fixture: ComponentFixture<RoleDetailComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [ReactiveFormsModule, RouterTestingModule],
declarations: [RoleDetailComponent],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [ReactiveFormsModule, RouterTestingModule],
declarations: [RoleDetailComponent],
}).compileComponents();
}),
);
beforeEach(() => {
fixture = TestBed.createComponent(RoleDetailComponent);
+17
View File
@@ -0,0 +1,17 @@
export class LockInfo {
lockOlder: boolean;
olderRolling?: boolean;
olderDays?: number;
olderDate?: string;
lockNewer: boolean;
newerRolling?: boolean;
newerDays?: number;
newerDate?: string;
public constructor(init?: Partial<LockInfo>) {
this.lockOlder = false;
this.lockNewer = false;
Object.assign(this, init);
}
}
@@ -2,15 +2,16 @@ import { Injectable } from '@angular/core';
import { Resolve } from '@angular/router';
import { Observable } from 'rxjs/internal/Observable';
import { LockInfo } from './lock-info';
import { SettingsService } from './settings.service';
@Injectable({
providedIn: 'root',
})
export class LockInformationResolver implements Resolve<any> {
export class LockInformationResolver implements Resolve<LockInfo> {
constructor(private ser: SettingsService) {}
resolve(): Observable<any> {
resolve(): Observable<LockInfo> {
return this.ser.getLockInformation();
}
}
@@ -7,10 +7,10 @@ import { SettingsService } from './settings.service';
@Injectable({
providedIn: 'root',
})
export class MaintenanceResolver implements Resolve<any> {
export class MaintenanceResolver implements Resolve<{ enabled: boolean; user: string }> {
constructor(private ser: SettingsService) {}
resolve(): Observable<any> {
resolve(): Observable<{ enabled: boolean; user: string }> {
return this.ser.getMaintenance();
}
}
@@ -14,6 +14,7 @@ import { ToasterService } from '../core/toaster.service';
import { ProductService } from '../product/product.service';
import { ConfirmDialogComponent } from '../shared/confirm-dialog/confirm-dialog.component';
import { LockInfo } from './lock-info';
import { SettingsService } from './settings.service';
@Component({
@@ -23,7 +24,7 @@ import { SettingsService } from './settings.service';
})
export class SettingsComponent implements OnInit {
lockDatesForm: FormGroup;
lockInformation: any;
lockInformation: LockInfo;
rebaseDataForm: FormGroup;
@@ -31,7 +32,7 @@ export class SettingsComponent implements OnInit {
product: Product = new Product();
products: Observable<Product[]>;
maintenance: any;
maintenance: { enabled: boolean; user: string };
version: string;
@@ -89,7 +90,10 @@ export class SettingsComponent implements OnInit {
ngOnInit() {
this.route.data.subscribe((value) => {
const data = value as { maintenance: any; lockInformation: any };
const data = value as {
maintenance: { enabled: boolean; user: string };
lockInformation: LockInfo;
};
this.maintenance = data.maintenance;
this.lockInformation = data.lockInformation;
@@ -176,8 +180,7 @@ export class SettingsComponent implements OnInit {
rebaseData(rebaseDate: string) {
this.ser.rebaseDatabase(rebaseDate).subscribe(
(result) => {
this.lockInformation = result;
() => {
this.toaster.show('Success', 'Data has been rebased!');
},
(error) => {
@@ -230,8 +233,7 @@ export class SettingsComponent implements OnInit {
checkIntegrity() {
this.ser.checkDatabaseIntegrity().subscribe(
(result) => {
this.lockInformation = result;
() => {
this.toaster.show('Success', 'Database checked, it is fine!');
},
(error) => {
+25 -21
View File
@@ -6,35 +6,37 @@ import { catchError } from 'rxjs/operators';
import { ErrorLoggerService } from '../core/error-logger.service';
import { Product } from '../core/product';
import { LockInfo } from './lock-info';
const serviceName = 'SettingsService';
@Injectable({ providedIn: 'root' })
export class SettingsService {
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
getLockInformation(): Observable<any> {
getLockInformation(): Observable<LockInfo> {
const url = '/api/lock-information';
return <Observable<any>>(
return <Observable<LockInfo>>(
this.http
.get<any>(url)
.get<LockInfo>(url)
.pipe(catchError(this.log.handleError(serviceName, 'getLockInformation')))
);
}
setLockInformation(lockInformation: any): Observable<any> {
setLockInformation(lockInformation: LockInfo): Observable<LockInfo> {
const url = '/api/lock-information';
return <Observable<any>>(
return <Observable<LockInfo>>(
this.http
.post<any>(url, lockInformation)
.post<LockInfo>(url, lockInformation)
.pipe(catchError(this.log.handleError(serviceName, 'setLockInformation')))
);
}
deleteLockInformation(): Observable<any> {
deleteLockInformation(): Observable<LockInfo> {
const url = '/api/lock-information';
return <Observable<any>>(
return <Observable<LockInfo>>(
this.http
.delete<any>(url)
.delete<LockInfo>(url)
.pipe(catchError(this.log.handleError(serviceName, 'deleteLockInformation')))
);
}
@@ -51,34 +53,36 @@ export class SettingsService {
.pipe(catchError(this.log.handleError(serviceName, 'resetStock')));
}
rebaseDatabase(date: string): Observable<boolean> {
rebaseDatabase(date: string): Observable<{}> {
const url = '/api/rebase';
return <Observable<any>>(
return <Observable<{}>>(
this.http
.post<any>(`${url}/${date}`, {})
.post<{}>(`${url}/${date}`, {})
.pipe(catchError(this.log.handleError(serviceName, 'rebaseDatabase')))
);
}
setMaintenance(enable: boolean): Observable<any> {
setMaintenance(enable: boolean): Observable<{ enabled: boolean; user: string }> {
const url = '/api/maintenance';
return this.http
.post<any>(url, { enabled: enable })
return <Observable<{ enabled: boolean; user: string }>>this.http
.post<{ enabled: boolean; user: string }>(url, { enabled: enable })
.pipe(catchError(this.log.handleError(serviceName, 'setMaintenance')));
}
getMaintenance(): Observable<any> {
getMaintenance(): Observable<{ enabled: boolean; user: string }> {
const url = '/api/maintenance';
return <Observable<any>>(
this.http.get<any>(url).pipe(catchError(this.log.handleError(serviceName, 'getMaintenance')))
return <Observable<{ enabled: boolean; user: string }>>(
this.http
.get<{ enabled: boolean; user: string }>(url)
.pipe(catchError(this.log.handleError(serviceName, 'getMaintenance')))
);
}
checkDatabaseIntegrity(): Observable<any> {
checkDatabaseIntegrity(): Observable<{ 'Duplicate Attendances Fixed': number }> {
const url = '/api/db-integrity';
return <Observable<any>>(
return <Observable<{ 'Duplicate Attendances Fixed': number }>>(
this.http
.post<any>(url, {})
.post<{ 'Duplicate Attendances Fixed': number }>(url, {})
.pipe(catchError(this.log.handleError(serviceName, 'checkDatabaseIntegrity')))
);
}
+2 -1
View File
@@ -4,7 +4,8 @@ import { Pipe, PipeTransform } from '@angular/core';
name: 'clear',
})
export class ClearPipe implements PipeTransform {
transform(value: any): any {
transform(value: string | null): string {
if (value === null) return '';
return value === '₹ 0.00' || value === '0.00' ? '' : value;
}
}
@@ -6,11 +6,13 @@ describe('ConfirmDialogComponent', () => {
let component: ConfirmDialogComponent;
let fixture: ComponentFixture<ConfirmDialogComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ConfirmDialogComponent],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ConfirmDialogComponent],
}).compileComponents();
}),
);
beforeEach(() => {
fixture = TestBed.createComponent(ConfirmDialogComponent);
@@ -9,6 +9,6 @@ import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
export class ConfirmDialogComponent {
constructor(
public dialogRef: MatDialogRef<ConfirmDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: any,
@Inject(MAT_DIALOG_DATA) public data: { title: string; content: string },
) {}
}
@@ -6,11 +6,13 @@ describe('ImageDialogComponent', () => {
let component: ImageDialogComponent;
let fixture: ComponentFixture<ImageDialogComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ImageDialogComponent],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ImageDialogComponent],
}).compileComponents();
}),
);
beforeEach(() => {
fixture = TestBed.createComponent(ImageDialogComponent);
@@ -9,7 +9,7 @@ import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
export class ImageDialogComponent {
constructor(
public dialogRef: MatDialogRef<ImageDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: any,
@Inject(MAT_DIALOG_DATA) public data: string,
) {}
close(): void {
+5 -4
View File
@@ -45,11 +45,12 @@ export class ImageService {
for (let i = 0; i < files.length; i += 1) {
const file = files[i];
const reader = new FileReader();
reader.onload = (e: any) => {
reader.onload = (e) => {
const target = e.target as FileReader;
zip(
of(e.target.result),
this.resizeImage(e.target.result, 100, 150),
this.resizeImage(e.target.result, 825, 1170),
of(target.result),
this.resizeImage(target.result as string, 100, 150),
this.resizeImage(target.result as string, 825, 1170),
).subscribe((val) =>
voucher.files.push(new DbFile({ thumbnail: val[1], resized: val[2] })),
);
+1 -1
View File
@@ -6,7 +6,7 @@ import { evaluate, round } from 'mathjs';
})
export class MathService {
// eslint-disable-next-line class-methods-use-this
journalAmount(amount: string = '', debit: number): any {
journalAmount(amount: string = '', debit: number): { debit: number; amount: number } {
const val = this.parseAmount(amount, 2);
let newDebit = debit;
if (val < 0) {
+3
View File
@@ -0,0 +1,3 @@
export interface ToCsvType {
[column: string]: string | number | boolean | null;
}
+6 -2
View File
@@ -1,15 +1,19 @@
import { Injectable } from '@angular/core';
import { ToCsvType } from './to-csv-type';
@Injectable({
providedIn: 'root',
})
export class ToCsvService {
// eslint-disable-next-line class-methods-use-this
toCsv(headers: any, data: any[]): string {
toCsv(headers: { [display: string]: string }, data: unknown[]): string {
const header = Object.keys(headers);
const replacer = (key: string, value: string | number | null) => (value === null ? '' : value);
const csv = data.map((row) =>
header.map((fieldName) => JSON.stringify(row[headers[fieldName]], replacer)).join(','),
header
.map((fieldName) => JSON.stringify((row as ToCsvType)[headers[fieldName]], replacer))
.join(','),
);
csv.unshift(header.join(','));
return csv.join('\r\n');
@@ -8,12 +8,14 @@ describe('StockMovementComponent', () => {
let component: StockMovementComponent;
let fixture: ComponentFixture<StockMovementComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [ReactiveFormsModule, RouterTestingModule],
declarations: [StockMovementComponent],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [ReactiveFormsModule, RouterTestingModule],
declarations: [StockMovementComponent],
}).compileComponents();
}),
);
beforeEach(() => {
fixture = TestBed.createComponent(StockMovementComponent);
@@ -8,12 +8,14 @@ describe('TrialBalanceComponent', () => {
let component: TrialBalanceComponent;
let fixture: ComponentFixture<TrialBalanceComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [ReactiveFormsModule, RouterTestingModule],
declarations: [TrialBalanceComponent],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [ReactiveFormsModule, RouterTestingModule],
declarations: [TrialBalanceComponent],
}).compileComponents();
}),
);
beforeEach(() => {
fixture = TestBed.createComponent(TrialBalanceComponent);
@@ -2,3 +2,6 @@
display: flex;
justify-content: flex-end;
}
.my-margin {
margin: 0 12px;
}
@@ -6,6 +6,39 @@
Refresh
</a>
</mat-card-title-group>
<mat-expansion-panel (opened)="panelOpenState = true" (closed)="panelOpenState = false">
<mat-expansion-panel-header>
<mat-panel-title> Self aware panel </mat-panel-title>
<mat-panel-description>
Currently I am {{ panelOpenState ? 'open' : 'closed' }}
</mat-panel-description>
</mat-expansion-panel-header>
<mat-checkbox
class="my-margin"
[checked]="!!unposted"
[indeterminate]="unposted === undefined"
(change)="toggleUnposted()"
>
Unposted
</mat-checkbox>
<p></p>
<mat-checkbox
class="my-margin"
[checked]="!!unposted"
[indeterminate]="unposted === undefined"
(change)="toggleUnposted()"
>
All userscv
</mat-checkbox>
<mat-checkbox
class="my-margin"
[checked]="!!unposted"
[indeterminate]="unposted === undefined"
(change)="toggleUnposted()"
>
Unposted
</mat-checkbox>
</mat-expansion-panel>
<mat-card-content>
<mat-table #table [dataSource]="dataSource" matSort aria-label="Elements">
<!-- Date Column -->
@@ -8,12 +8,14 @@ describe('UnpostedComponent', () => {
let component: UnpostedComponent;
let fixture: ComponentFixture<UnpostedComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [HttpClientModule, RouterTestingModule],
declarations: [UnpostedComponent],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [HttpClientModule, RouterTestingModule],
declarations: [UnpostedComponent],
}).compileComponents();
}),
);
beforeEach(() => {
fixture = TestBed.createComponent(UnpostedComponent);
@@ -28,6 +28,8 @@ export class UnpostedComponent implements OnInit {
'creditAmount',
];
panelOpenState = false;
unposted: boolean | undefined = undefined;
constructor(
private route: ActivatedRoute,
private router: Router,
@@ -48,4 +50,14 @@ export class UnpostedComponent implements OnInit {
this.info = info;
});
}
toggleUnposted() {
if (this.unposted === undefined) {
this.unposted = false;
} else if (!this.unposted) {
this.unposted = true;
} else {
this.unposted = undefined;
}
}
}
@@ -6,6 +6,7 @@ import { MatButtonModule } from '@angular/material/button';
import { MatCardModule } from '@angular/material/card';
import { MatCheckboxModule } from '@angular/material/checkbox';
import { MatNativeDateModule } from '@angular/material/core';
import { MatExpansionModule } from '@angular/material/expansion';
import { MatIconModule } from '@angular/material/icon';
import { MatInputModule } from '@angular/material/input';
import { MatPaginatorModule } from '@angular/material/paginator';
@@ -47,6 +48,7 @@ export const MY_FORMATS = {
MatTableModule,
SharedModule,
UnpostedRoutingModule,
MatExpansionModule,
],
declarations: [UnpostedComponent],
})
@@ -8,12 +8,14 @@ describe('UserDetailComponent', () => {
let component: UserDetailComponent;
let fixture: ComponentFixture<UserDetailComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [ReactiveFormsModule, RouterTestingModule],
declarations: [UserDetailComponent],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [ReactiveFormsModule, RouterTestingModule],
declarations: [UserDetailComponent],
}).compileComponents();
}),
);
beforeEach(() => {
fixture = TestBed.createComponent(UserDetailComponent);