diff --git a/overlord/.eslintrc.js b/overlord/.eslintrc.js index 0bbf8cb1..fe395d1a 100644 --- a/overlord/.eslintrc.js +++ b/overlord/.eslintrc.js @@ -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", } }; diff --git a/overlord/package.json b/overlord/package.json index c0e542fd..d01e5e1d 100644 --- a/overlord/package.json +++ b/overlord/package.json @@ -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": { diff --git a/overlord/src/app/account/account-detail/account-detail.component.spec.ts b/overlord/src/app/account/account-detail/account-detail.component.spec.ts index 506c00ca..92a88194 100644 --- a/overlord/src/app/account/account-detail/account-detail.component.spec.ts +++ b/overlord/src/app/account/account-detail/account-detail.component.spec.ts @@ -9,12 +9,14 @@ describe('AccountDetailComponent', () => { let component: AccountDetailComponent; let fixture: ComponentFixture; - 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); diff --git a/overlord/src/app/account/account-list/account-list-datasource.ts b/overlord/src/app/account/account-list/account-list-datasource.ts index 4d4f97b6..4377930d 100644 --- a/overlord/src/app/account/account-list/account-list-datasource.ts +++ b/overlord/src/app/account/account-list/account-list-datasource.ts @@ -45,7 +45,7 @@ export class AccountListDataSource extends DataSource { 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() {} diff --git a/overlord/src/app/app-routing.module.ts b/overlord/src/app/app-routing.module.ts index 100a1a2b..a50c7cd2 100644 --- a/overlord/src/app/app-routing.module.ts +++ b/overlord/src/app/app-routing.module.ts @@ -176,9 +176,9 @@ const appRoutes: Routes = [ imports: [ CommonModule, RouterModule.forRoot(appRoutes, { - onSameUrlNavigation: 'reload', - relativeLinkResolution: 'legacy' -}), + onSameUrlNavigation: 'reload', + relativeLinkResolution: 'legacy', + }), ], exports: [RouterModule], declarations: [], diff --git a/overlord/src/app/app.component.spec.ts b/overlord/src/app/app.component.spec.ts index 7f2e0818..5f33816a 100644 --- a/overlord/src/app/app.component.spec.ts +++ b/overlord/src/app/app.component.spec.ts @@ -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!'); + }), + ); }); diff --git a/overlord/src/app/attendance/attendance.component.html b/overlord/src/app/attendance/attendance.component.html index b07fb1cb..f6240a59 100644 --- a/overlord/src/app/attendance/attendance.component.html +++ b/overlord/src/app/attendance/attendance.component.html @@ -61,9 +61,7 @@ Prints {{ row.prints }} - new_releases + new_releases { let component: AttendanceComponent; let fixture: ComponentFixture; - 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); diff --git a/overlord/src/app/attendance/attendance.component.ts b/overlord/src/app/attendance/attendance.component.ts index 16ef0e48..fded5fb9 100644 --- a/overlord/src/app/attendance/attendance.component.ts +++ b/overlord/src/app/attendance/attendance.component.ts @@ -100,4 +100,8 @@ export class AttendanceComponent implements OnInit { }); return this.info; } + + get attendancesArray(): FormArray { + return this.form.get('attendances') as FormArray; + } } diff --git a/overlord/src/app/auth/auth.service.ts b/overlord/src/app/auth/auth.service.ts index 3ac0bff6..a0f15615 100644 --- a/overlord/src/app/auth/auth.service.ts +++ b/overlord/src/app/auth/auth.service.ts @@ -83,7 +83,7 @@ export class AuthService { formData.append('otp', otp); formData.append('grant_type', 'password'); return this.http - .post(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(refreshUrl, {}) + .post<{ access_token: string; token_type: string }>(refreshUrl, {}) .pipe(map((u) => u.access_token)) .pipe(map((u) => AuthService.parseJwt(u))) .pipe( diff --git a/overlord/src/app/auth/login/login.component.spec.ts b/overlord/src/app/auth/login/login.component.spec.ts index d5f3eef5..39be77e6 100644 --- a/overlord/src/app/auth/login/login.component.spec.ts +++ b/overlord/src/app/auth/login/login.component.spec.ts @@ -8,12 +8,14 @@ describe('LoginComponent', () => { let component: LoginComponent; let fixture: ComponentFixture; - 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); diff --git a/overlord/src/app/auth/logout/logout.component.spec.ts b/overlord/src/app/auth/logout/logout.component.spec.ts index dc6efc93..c16dede8 100644 --- a/overlord/src/app/auth/logout/logout.component.spec.ts +++ b/overlord/src/app/auth/logout/logout.component.spec.ts @@ -8,12 +8,14 @@ describe('LogoutComponent', () => { let component: LogoutComponent; let fixture: ComponentFixture; - 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); diff --git a/overlord/src/app/balance-sheet/balance-sheet-datasource.ts b/overlord/src/app/balance-sheet/balance-sheet-datasource.ts index 64b5696f..8e923d99 100644 --- a/overlord/src/app/balance-sheet/balance-sheet-datasource.ts +++ b/overlord/src/app/balance-sheet/balance-sheet-datasource.ts @@ -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 { - constructor(public data: any[], private paginator?: MatPaginator, private sort?: MatSort) { +export class BalanceSheetDataSource extends DataSource { + constructor( + public data: BalanceSheetItem[], + private paginator?: MatPaginator, + private sort?: MatSort, + ) { super(); } - connect(): Observable { - const dataMutations: (Observable | EventEmitter | EventEmitter)[] = [ - observableOf(this.data), - ]; + connect(): Observable { + const dataMutations: ( + | Observable + | EventEmitter + | EventEmitter + )[] = [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 { 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 { 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; } diff --git a/overlord/src/app/balance-sheet/balance-sheet.component.spec.ts b/overlord/src/app/balance-sheet/balance-sheet.component.spec.ts index 82cc5aad..a282c1d4 100644 --- a/overlord/src/app/balance-sheet/balance-sheet.component.spec.ts +++ b/overlord/src/app/balance-sheet/balance-sheet.component.spec.ts @@ -8,12 +8,14 @@ describe('BalanceSheetComponent', () => { let component: BalanceSheetComponent; let fixture: ComponentFixture; - 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); diff --git a/overlord/src/app/cash-flow/cash-flow.component.spec.ts b/overlord/src/app/cash-flow/cash-flow.component.spec.ts index ab507574..50bdd070 100644 --- a/overlord/src/app/cash-flow/cash-flow.component.spec.ts +++ b/overlord/src/app/cash-flow/cash-flow.component.spec.ts @@ -8,12 +8,14 @@ describe('CashFlowComponent', () => { let component: CashFlowComponent; let fixture: ComponentFixture; - 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); diff --git a/overlord/src/app/client/client-detail/client-detail.component.spec.ts b/overlord/src/app/client/client-detail/client-detail.component.spec.ts index 446d9038..df8712a2 100644 --- a/overlord/src/app/client/client-detail/client-detail.component.spec.ts +++ b/overlord/src/app/client/client-detail/client-detail.component.spec.ts @@ -9,12 +9,14 @@ describe('ClientDetailComponent', () => { let component: ClientDetailComponent; let fixture: ComponentFixture; - 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); diff --git a/overlord/src/app/closing-stock/closing-stock.component.spec.ts b/overlord/src/app/closing-stock/closing-stock.component.spec.ts index a4d2ed28..70acbb95 100644 --- a/overlord/src/app/closing-stock/closing-stock.component.spec.ts +++ b/overlord/src/app/closing-stock/closing-stock.component.spec.ts @@ -8,12 +8,14 @@ describe('ClosingStockComponent', () => { let component: ClosingStockComponent; let fixture: ComponentFixture; - 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); diff --git a/overlord/src/app/core/account-balance.ts b/overlord/src/app/core/account-balance.ts new file mode 100644 index 00000000..d0147b2a --- /dev/null +++ b/overlord/src/app/core/account-balance.ts @@ -0,0 +1,10 @@ +export class AccountBalance { + date: number; + total: number; + + public constructor(init?: Partial) { + this.date = 0; + this.total = 0; + Object.assign(this, init); + } +} diff --git a/overlord/src/app/core/account.service.ts b/overlord/src/app/core/account.service.ts index e8753a3a..c24e3c09 100644 --- a/overlord/src/app/core/account.service.ts +++ b/overlord/src/app/core/account.service.ts @@ -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 { + balance(id: string, date: string): Observable { const options = { params: new HttpParams().set('d', date) }; - return >( + return >( this.http - .get(`${url}/${id}/balance`, options) + .get(`${url}/${id}/balance`, options) .pipe(catchError(this.log.handleError(serviceName, 'balance'))) ); } diff --git a/overlord/src/app/core/error-logger.service.ts b/overlord/src/app/core/error-logger.service.ts index 5cf63a68..3d875cf7 100644 --- a/overlord/src/app/core/error-logger.service.ts +++ b/overlord/src/app/core/error-logger.service.ts @@ -19,7 +19,7 @@ export class ErrorLoggerService { */ // eslint-disable-next-line @typescript-eslint/no-unused-vars, class-methods-use-this public handleError(serviceName = 'error-logger', operation = 'operation', result?: T) { - return (error: any): Observable => { + return (error: unknown): Observable => { ErrorLoggerService.log(serviceName, `${operation} failed: ${error}`); return throwError(error); }; diff --git a/overlord/src/app/core/http-auth-interceptor.ts b/overlord/src/app/core/http-auth-interceptor.ts index 1d1001c5..25c2b4b7 100644 --- a/overlord/src/app/core/http-auth-interceptor.ts +++ b/overlord/src/app/core/http-auth-interceptor.ts @@ -19,7 +19,7 @@ export class ErrorInterceptor implements HttpInterceptor { private toaster: ToasterService, ) {} - intercept(request: HttpRequest, next: HttpHandler): Observable> { + intercept(request: HttpRequest, next: HttpHandler): Observable> { return next.handle(request).pipe( catchError((err) => { // We don't want to refresh token for some requests like login or refresh token itself diff --git a/overlord/src/app/core/issue-grid-item.ts b/overlord/src/app/core/issue-grid-item.ts new file mode 100644 index 00000000..831d65c8 --- /dev/null +++ b/overlord/src/app/core/issue-grid-item.ts @@ -0,0 +1,14 @@ +export class IssueGridItem { + id: string; + amount: number; + source: string; + destination: string; + + public constructor(init?: Partial) { + this.id = ''; + this.amount = 0; + this.source = ''; + this.destination = ''; + Object.assign(this, init); + } +} diff --git a/overlord/src/app/core/jwt.interceptor.ts b/overlord/src/app/core/jwt.interceptor.ts index 4076b8d8..0f4529aa 100644 --- a/overlord/src/app/core/jwt.interceptor.ts +++ b/overlord/src/app/core/jwt.interceptor.ts @@ -10,7 +10,7 @@ export class JwtInterceptor implements HttpInterceptor { constructor(private authService: AuthService) {} - intercept(request: HttpRequest, next: HttpHandler): Observable> { + intercept(request: HttpRequest, next: HttpHandler): Observable> { // add authorization header with jwt token if available // We use this line to debug token refreshing diff --git a/overlord/src/app/cost-centre/cost-centre-detail/cost-centre-detail.component.spec.ts b/overlord/src/app/cost-centre/cost-centre-detail/cost-centre-detail.component.spec.ts index 32aa0e0e..9c0aeec1 100644 --- a/overlord/src/app/cost-centre/cost-centre-detail/cost-centre-detail.component.spec.ts +++ b/overlord/src/app/cost-centre/cost-centre-detail/cost-centre-detail.component.spec.ts @@ -8,12 +8,14 @@ describe('CostCentreDetailComponent', () => { let component: CostCentreDetailComponent; let fixture: ComponentFixture; - 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); diff --git a/overlord/src/app/daybook/daybook.component.spec.ts b/overlord/src/app/daybook/daybook.component.spec.ts index fb7bd586..106ef770 100644 --- a/overlord/src/app/daybook/daybook.component.spec.ts +++ b/overlord/src/app/daybook/daybook.component.spec.ts @@ -8,12 +8,14 @@ describe('DaybookComponent', () => { let component: DaybookComponent; let fixture: ComponentFixture; - 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); diff --git a/overlord/src/app/employee-attendance/employee-attendance.component.html b/overlord/src/app/employee-attendance/employee-attendance.component.html index f6512336..5c1b3c0c 100644 --- a/overlord/src/app/employee-attendance/employee-attendance.component.html +++ b/overlord/src/app/employee-attendance/employee-attendance.component.html @@ -90,9 +90,7 @@ Prints {{ row.prints }} - new_releases + new_releases { let component: EmployeeDetailComponent; let fixture: ComponentFixture; - 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); diff --git a/overlord/src/app/employee/employee-list/employee-list-datasource.ts b/overlord/src/app/employee/employee-list/employee-list-datasource.ts index 04d1c3fe..306e0095 100644 --- a/overlord/src/app/employee/employee-list/employee-list-datasource.ts +++ b/overlord/src/app/employee/employee-list/employee-list-datasource.ts @@ -45,7 +45,7 @@ export class EmployeeListDataSource extends DataSource { 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() {} diff --git a/overlord/src/app/home/home.component.spec.ts b/overlord/src/app/home/home.component.spec.ts index d7c6165d..3fa303d8 100644 --- a/overlord/src/app/home/home.component.spec.ts +++ b/overlord/src/app/home/home.component.spec.ts @@ -6,11 +6,13 @@ describe('HomeComponent', () => { let component: HomeComponent; let fixture: ComponentFixture; - beforeEach(waitForAsync(() => { - TestBed.configureTestingModule({ - declarations: [HomeComponent], - }).compileComponents(); - })); + beforeEach( + waitForAsync(() => { + TestBed.configureTestingModule({ + declarations: [HomeComponent], + }).compileComponents(); + }), + ); beforeEach(() => { fixture = TestBed.createComponent(HomeComponent); diff --git a/overlord/src/app/incentive/incentive.component.spec.ts b/overlord/src/app/incentive/incentive.component.spec.ts index 84bc2a10..c4e23902 100644 --- a/overlord/src/app/incentive/incentive.component.spec.ts +++ b/overlord/src/app/incentive/incentive.component.spec.ts @@ -9,12 +9,14 @@ describe('IncentiveComponent', () => { let component: IncentiveComponent; let fixture: ComponentFixture; - 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); diff --git a/overlord/src/app/incentive/incentive.component.ts b/overlord/src/app/incentive/incentive.component.ts index 170e0040..d30194c5 100644 --- a/overlord/src/app/incentive/incentive.component.ts +++ b/overlord/src/app/incentive/incentive.component.ts @@ -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']; diff --git a/overlord/src/app/issue/issue-dialog.component.spec.ts b/overlord/src/app/issue/issue-dialog.component.spec.ts index 92751f47..b290580a 100644 --- a/overlord/src/app/issue/issue-dialog.component.spec.ts +++ b/overlord/src/app/issue/issue-dialog.component.spec.ts @@ -6,11 +6,13 @@ describe('IssueDialogComponent', () => { let component: IssueDialogComponent; let fixture: ComponentFixture; - beforeEach(waitForAsync(() => { - TestBed.configureTestingModule({ - declarations: [IssueDialogComponent], - }).compileComponents(); - })); + beforeEach( + waitForAsync(() => { + TestBed.configureTestingModule({ + declarations: [IssueDialogComponent], + }).compileComponents(); + }), + ); beforeEach(() => { fixture = TestBed.createComponent(IssueDialogComponent); diff --git a/overlord/src/app/issue/issue-dialog.component.ts b/overlord/src/app/issue/issue-dialog.component.ts index b9293d6e..3596fd0b 100644 --- a/overlord/src/app/issue/issue-dialog.component.ts +++ b/overlord/src/app/issue/issue-dialog.component.ts @@ -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, - @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 { diff --git a/overlord/src/app/issue/issue-grid-datasource.ts b/overlord/src/app/issue/issue-grid-datasource.ts index 90b5554a..0730fb93 100644 --- a/overlord/src/app/issue/issue-grid-datasource.ts +++ b/overlord/src/app/issue/issue-grid-datasource.ts @@ -1,12 +1,14 @@ import { DataSource } from '@angular/cdk/collections'; import { Observable } from 'rxjs'; -export class IssueGridDataSource extends DataSource { - constructor(private data: Observable) { +import { IssueGridItem } from '../core/issue-grid-item'; + +export class IssueGridDataSource extends DataSource { + constructor(private data: Observable) { super(); } - connect(): Observable { + connect(): Observable { return this.data; } diff --git a/overlord/src/app/issue/issue-grid.service.ts b/overlord/src/app/issue/issue-grid.service.ts index 48652827..70f76088 100644 --- a/overlord/src/app/issue/issue-grid.service.ts +++ b/overlord/src/app/issue/issue-grid.service.ts @@ -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 { - return >( + issueGrid(date: string): Observable { + return >( this.http - .get(`${url}/${date}`) + .get(`${url}/${date}`) .pipe(catchError(this.log.handleError(serviceName, 'autocomplete'))) ); } diff --git a/overlord/src/app/issue/issue.component.spec.ts b/overlord/src/app/issue/issue.component.spec.ts index 87b20d1a..f92eef03 100644 --- a/overlord/src/app/issue/issue.component.spec.ts +++ b/overlord/src/app/issue/issue.component.spec.ts @@ -9,12 +9,14 @@ describe('IssueComponent', () => { let component: IssueComponent; let fixture: ComponentFixture; - 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); diff --git a/overlord/src/app/issue/issue.component.ts b/overlord/src/app/issue/issue.component.ts index 1f6ce6e8..7fcd4a77 100644 --- a/overlord/src/app/issue/issue.component.ts +++ b/overlord/src/app/issue/issue.component.ts @@ -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([]); - public gridObservable = new BehaviorSubject([]); + public gridObservable = new BehaviorSubject([]); dataSource: IssueDataSource = new IssueDataSource(this.inventoryObservable); gridDataSource: IssueGridDataSource = new IssueGridDataSource(this.gridObservable); form: FormGroup; diff --git a/overlord/src/app/journal/journal-dialog.component.spec.ts b/overlord/src/app/journal/journal-dialog.component.spec.ts index 1271720c..402cd914 100644 --- a/overlord/src/app/journal/journal-dialog.component.spec.ts +++ b/overlord/src/app/journal/journal-dialog.component.spec.ts @@ -6,11 +6,13 @@ describe('JournalDialogComponent', () => { let component: JournalDialogComponent; let fixture: ComponentFixture; - beforeEach(waitForAsync(() => { - TestBed.configureTestingModule({ - declarations: [JournalDialogComponent], - }).compileComponents(); - })); + beforeEach( + waitForAsync(() => { + TestBed.configureTestingModule({ + declarations: [JournalDialogComponent], + }).compileComponents(); + }), + ); beforeEach(() => { fixture = TestBed.createComponent(JournalDialogComponent); diff --git a/overlord/src/app/journal/journal-dialog.component.ts b/overlord/src/app/journal/journal-dialog.component.ts index a6b56bbf..2865d8e8 100644 --- a/overlord/src/app/journal/journal-dialog.component.ts +++ b/overlord/src/app/journal/journal-dialog.component.ts @@ -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; form: FormGroup; account: Account = new Account(); - accBal: any; + accBal: AccountBalance | null = null; constructor( public dialogRef: MatDialogRef, - @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, diff --git a/overlord/src/app/journal/journal.component.spec.ts b/overlord/src/app/journal/journal.component.spec.ts index 02f43698..6db73e2a 100644 --- a/overlord/src/app/journal/journal.component.spec.ts +++ b/overlord/src/app/journal/journal.component.spec.ts @@ -9,12 +9,14 @@ describe('JournalComponent', () => { let component: JournalComponent; let fixture: ComponentFixture; - 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); diff --git a/overlord/src/app/journal/journal.component.ts b/overlord/src/app/journal/journal.component.ts index 8cbc18df..922d8b6a 100644 --- a/overlord/src/app/journal/journal.component.ts +++ b/overlord/src/app/journal/journal.component.ts @@ -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']; diff --git a/overlord/src/app/ledger/ledger.component.spec.ts b/overlord/src/app/ledger/ledger.component.spec.ts index d53f37d4..34313218 100644 --- a/overlord/src/app/ledger/ledger.component.spec.ts +++ b/overlord/src/app/ledger/ledger.component.spec.ts @@ -9,12 +9,14 @@ describe('LedgerComponent', () => { let component: LedgerComponent; let fixture: ComponentFixture; - 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); diff --git a/overlord/src/app/net-transactions/net-transactions.component.spec.ts b/overlord/src/app/net-transactions/net-transactions.component.spec.ts index 4c9603b6..1f05c654 100644 --- a/overlord/src/app/net-transactions/net-transactions.component.spec.ts +++ b/overlord/src/app/net-transactions/net-transactions.component.spec.ts @@ -8,12 +8,14 @@ describe('NetTransactionsComponent', () => { let component: NetTransactionsComponent; let fixture: ComponentFixture; - 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); diff --git a/overlord/src/app/payment/payment-dialog.component.spec.ts b/overlord/src/app/payment/payment-dialog.component.spec.ts index 488f0f27..8bfd2bd8 100644 --- a/overlord/src/app/payment/payment-dialog.component.spec.ts +++ b/overlord/src/app/payment/payment-dialog.component.spec.ts @@ -6,11 +6,13 @@ describe('PaymentDialogComponent', () => { let component: PaymentDialogComponent; let fixture: ComponentFixture; - beforeEach(waitForAsync(() => { - TestBed.configureTestingModule({ - declarations: [PaymentDialogComponent], - }).compileComponents(); - })); + beforeEach( + waitForAsync(() => { + TestBed.configureTestingModule({ + declarations: [PaymentDialogComponent], + }).compileComponents(); + }), + ); beforeEach(() => { fixture = TestBed.createComponent(PaymentDialogComponent); diff --git a/overlord/src/app/payment/payment-dialog.component.ts b/overlord/src/app/payment/payment-dialog.component.ts index 1126ae4c..b057753a 100644 --- a/overlord/src/app/payment/payment-dialog.component.ts +++ b/overlord/src/app/payment/payment-dialog.component.ts @@ -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; form: FormGroup; account: Account = new Account(); - accBal: any; + accBal: AccountBalance | null = null; constructor( public dialogRef: MatDialogRef, - @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, diff --git a/overlord/src/app/payment/payment.component.spec.ts b/overlord/src/app/payment/payment.component.spec.ts index 42f0ae90..132a4152 100644 --- a/overlord/src/app/payment/payment.component.spec.ts +++ b/overlord/src/app/payment/payment.component.spec.ts @@ -9,12 +9,14 @@ describe('PaymentComponent', () => { let component: PaymentComponent; let fixture: ComponentFixture; - 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); diff --git a/overlord/src/app/payment/payment.component.ts b/overlord/src/app/payment/payment.component.ts index 01119ee5..8c2cc8dc 100644 --- a/overlord/src/app/payment/payment.component.ts +++ b/overlord/src/app/payment/payment.component.ts @@ -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']; diff --git a/overlord/src/app/product-group/product-group-detail/product-group-detail.component.spec.ts b/overlord/src/app/product-group/product-group-detail/product-group-detail.component.spec.ts index 73d6ac3d..7c6b17d5 100644 --- a/overlord/src/app/product-group/product-group-detail/product-group-detail.component.spec.ts +++ b/overlord/src/app/product-group/product-group-detail/product-group-detail.component.spec.ts @@ -8,12 +8,14 @@ describe('ProductGroupDetailComponent', () => { let component: ProductGroupDetailComponent; let fixture: ComponentFixture; - 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); diff --git a/overlord/src/app/product-ledger/product-ledger.component.spec.ts b/overlord/src/app/product-ledger/product-ledger.component.spec.ts index 13093293..82d4bdef 100644 --- a/overlord/src/app/product-ledger/product-ledger.component.spec.ts +++ b/overlord/src/app/product-ledger/product-ledger.component.spec.ts @@ -9,12 +9,14 @@ describe('ProductLedgerComponent', () => { let component: ProductLedgerComponent; let fixture: ComponentFixture; - 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); diff --git a/overlord/src/app/product/product-detail/product-detail.component.spec.ts b/overlord/src/app/product/product-detail/product-detail.component.spec.ts index 728efadb..11a911f7 100644 --- a/overlord/src/app/product/product-detail/product-detail.component.spec.ts +++ b/overlord/src/app/product/product-detail/product-detail.component.spec.ts @@ -9,12 +9,14 @@ describe('ProductDetailComponent', () => { let component: ProductDetailComponent; let fixture: ComponentFixture; - 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); diff --git a/overlord/src/app/product/product-list/product-list-datasource.ts b/overlord/src/app/product/product-list/product-list-datasource.ts index 60f61648..2adea36d 100644 --- a/overlord/src/app/product/product-list/product-list-datasource.ts +++ b/overlord/src/app/product/product-list/product-list-datasource.ts @@ -45,7 +45,7 @@ export class ProductListDataSource extends DataSource { 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() {} diff --git a/overlord/src/app/profit-loss/profit-loss.component.spec.ts b/overlord/src/app/profit-loss/profit-loss.component.spec.ts index c119894a..84f9d91b 100644 --- a/overlord/src/app/profit-loss/profit-loss.component.spec.ts +++ b/overlord/src/app/profit-loss/profit-loss.component.spec.ts @@ -8,12 +8,14 @@ describe('ProfitLossComponent', () => { let component: ProfitLossComponent; let fixture: ComponentFixture; - 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); diff --git a/overlord/src/app/purchase-entries/purchase-entries.component.spec.ts b/overlord/src/app/purchase-entries/purchase-entries.component.spec.ts index d7f495e5..e36ae26a 100644 --- a/overlord/src/app/purchase-entries/purchase-entries.component.spec.ts +++ b/overlord/src/app/purchase-entries/purchase-entries.component.spec.ts @@ -8,12 +8,14 @@ describe('PurchaseEntriesComponent', () => { let component: PurchaseEntriesComponent; let fixture: ComponentFixture; - 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); diff --git a/overlord/src/app/purchase-return/purchase-return-dialog.component.spec.ts b/overlord/src/app/purchase-return/purchase-return-dialog.component.spec.ts index 9d220723..86c8dc6a 100644 --- a/overlord/src/app/purchase-return/purchase-return-dialog.component.spec.ts +++ b/overlord/src/app/purchase-return/purchase-return-dialog.component.spec.ts @@ -6,11 +6,13 @@ describe('PurchaseReturnDialogComponent', () => { let component: PurchaseReturnDialogComponent; let fixture: ComponentFixture; - beforeEach(waitForAsync(() => { - TestBed.configureTestingModule({ - declarations: [PurchaseReturnDialogComponent], - }).compileComponents(); - })); + beforeEach( + waitForAsync(() => { + TestBed.configureTestingModule({ + declarations: [PurchaseReturnDialogComponent], + }).compileComponents(); + }), + ); beforeEach(() => { fixture = TestBed.createComponent(PurchaseReturnDialogComponent); diff --git a/overlord/src/app/purchase-return/purchase-return-dialog.component.ts b/overlord/src/app/purchase-return/purchase-return-dialog.component.ts index 47976223..f4cb752b 100644 --- a/overlord/src/app/purchase-return/purchase-return-dialog.component.ts +++ b/overlord/src/app/purchase-return/purchase-return-dialog.component.ts @@ -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, - @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 { diff --git a/overlord/src/app/purchase-return/purchase-return.component.spec.ts b/overlord/src/app/purchase-return/purchase-return.component.spec.ts index d5f2a6c8..bcc4f040 100644 --- a/overlord/src/app/purchase-return/purchase-return.component.spec.ts +++ b/overlord/src/app/purchase-return/purchase-return.component.spec.ts @@ -9,12 +9,14 @@ describe('PurchaseReturnComponent', () => { let component: PurchaseReturnComponent; let fixture: ComponentFixture; - 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); diff --git a/overlord/src/app/purchase-return/purchase-return.component.ts b/overlord/src/app/purchase-return/purchase-return.component.ts index 6795b34f..1d0853ea 100644 --- a/overlord/src/app/purchase-return/purchase-return.component.ts +++ b/overlord/src/app/purchase-return/purchase-return.component.ts @@ -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']; diff --git a/overlord/src/app/purchase/purchase-dialog.component.spec.ts b/overlord/src/app/purchase/purchase-dialog.component.spec.ts index 3b006d9b..222d67f1 100644 --- a/overlord/src/app/purchase/purchase-dialog.component.spec.ts +++ b/overlord/src/app/purchase/purchase-dialog.component.spec.ts @@ -7,11 +7,13 @@ describe('PurchaseDialogComponent', () => { let component: PurchaseDialogComponent; let fixture: ComponentFixture; - beforeEach(waitForAsync(() => { - TestBed.configureTestingModule({ - declarations: [MatDialogModule, PurchaseDialogComponent], - }).compileComponents(); - })); + beforeEach( + waitForAsync(() => { + TestBed.configureTestingModule({ + declarations: [MatDialogModule, PurchaseDialogComponent], + }).compileComponents(); + }), + ); beforeEach(() => { fixture = TestBed.createComponent(PurchaseDialogComponent); diff --git a/overlord/src/app/purchase/purchase-dialog.component.ts b/overlord/src/app/purchase/purchase-dialog.component.ts index dc8dad8d..b97c0353 100644 --- a/overlord/src/app/purchase/purchase-dialog.component.ts +++ b/overlord/src/app/purchase/purchase-dialog.component.ts @@ -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, - @Inject(MAT_DIALOG_DATA) public data: any, + @Inject(MAT_DIALOG_DATA) public data: { inventory: Inventory }, private fb: FormBuilder, private math: MathService, private productSer: ProductService, diff --git a/overlord/src/app/purchase/purchase.component.spec.ts b/overlord/src/app/purchase/purchase.component.spec.ts index 76f59443..1035459a 100644 --- a/overlord/src/app/purchase/purchase.component.spec.ts +++ b/overlord/src/app/purchase/purchase.component.spec.ts @@ -9,12 +9,14 @@ describe('PurchaseComponent', () => { let component: PurchaseComponent; let fixture: ComponentFixture; - 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); diff --git a/overlord/src/app/purchase/purchase.component.ts b/overlord/src/app/purchase/purchase.component.ts index 6da83d47..16197217 100644 --- a/overlord/src/app/purchase/purchase.component.ts +++ b/overlord/src/app/purchase/purchase.component.ts @@ -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']; diff --git a/overlord/src/app/purchases/purchases.component.spec.ts b/overlord/src/app/purchases/purchases.component.spec.ts index 06e31b92..e592e594 100644 --- a/overlord/src/app/purchases/purchases.component.spec.ts +++ b/overlord/src/app/purchases/purchases.component.spec.ts @@ -9,12 +9,14 @@ describe('PurchasesComponent', () => { let component: PurchasesComponent; let fixture: ComponentFixture; - 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); diff --git a/overlord/src/app/raw-material-cost/raw-material-cost.component.spec.ts b/overlord/src/app/raw-material-cost/raw-material-cost.component.spec.ts index e465686e..a661da8a 100644 --- a/overlord/src/app/raw-material-cost/raw-material-cost.component.spec.ts +++ b/overlord/src/app/raw-material-cost/raw-material-cost.component.spec.ts @@ -8,12 +8,14 @@ describe('RawMaterialCostComponent', () => { let component: RawMaterialCostComponent; let fixture: ComponentFixture; - 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); diff --git a/overlord/src/app/receipt/receipt-dialog.component.spec.ts b/overlord/src/app/receipt/receipt-dialog.component.spec.ts index d354f1cb..76398059 100644 --- a/overlord/src/app/receipt/receipt-dialog.component.spec.ts +++ b/overlord/src/app/receipt/receipt-dialog.component.spec.ts @@ -7,12 +7,14 @@ describe('ReceiptDialogComponent', () => { let component: ReceiptDialogComponent; let fixture: ComponentFixture; - beforeEach(waitForAsync(() => { - TestBed.configureTestingModule({ - imports: [MatDialogRef], - declarations: [ReceiptDialogComponent], - }).compileComponents(); - })); + beforeEach( + waitForAsync(() => { + TestBed.configureTestingModule({ + imports: [MatDialogRef], + declarations: [ReceiptDialogComponent], + }).compileComponents(); + }), + ); beforeEach(() => { fixture = TestBed.createComponent(ReceiptDialogComponent); diff --git a/overlord/src/app/receipt/receipt-dialog.component.ts b/overlord/src/app/receipt/receipt-dialog.component.ts index e9028593..1d2ed069 100644 --- a/overlord/src/app/receipt/receipt-dialog.component.ts +++ b/overlord/src/app/receipt/receipt-dialog.component.ts @@ -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; form: FormGroup; account: Account = new Account(); - accBal: any; + accBal: AccountBalance | null = null; constructor( public dialogRef: MatDialogRef, - @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, diff --git a/overlord/src/app/receipt/receipt.component.spec.ts b/overlord/src/app/receipt/receipt.component.spec.ts index 33184782..8a69235f 100644 --- a/overlord/src/app/receipt/receipt.component.spec.ts +++ b/overlord/src/app/receipt/receipt.component.spec.ts @@ -9,12 +9,14 @@ describe('ReceiptComponent', () => { let component: ReceiptComponent; let fixture: ComponentFixture; - 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); diff --git a/overlord/src/app/receipt/receipt.component.ts b/overlord/src/app/receipt/receipt.component.ts index e556848d..e53bd548 100644 --- a/overlord/src/app/receipt/receipt.component.ts +++ b/overlord/src/app/receipt/receipt.component.ts @@ -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']; diff --git a/overlord/src/app/role/role-detail/role-detail.component.spec.ts b/overlord/src/app/role/role-detail/role-detail.component.spec.ts index f90227ca..554366ac 100644 --- a/overlord/src/app/role/role-detail/role-detail.component.spec.ts +++ b/overlord/src/app/role/role-detail/role-detail.component.spec.ts @@ -8,12 +8,14 @@ describe('RoleDetailComponent', () => { let component: RoleDetailComponent; let fixture: ComponentFixture; - 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); diff --git a/overlord/src/app/settings/lock-info.ts b/overlord/src/app/settings/lock-info.ts new file mode 100644 index 00000000..03a5e984 --- /dev/null +++ b/overlord/src/app/settings/lock-info.ts @@ -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) { + this.lockOlder = false; + this.lockNewer = false; + Object.assign(this, init); + } +} diff --git a/overlord/src/app/settings/lock-information-resolver.service.ts b/overlord/src/app/settings/lock-information-resolver.service.ts index c455e343..9781898a 100644 --- a/overlord/src/app/settings/lock-information-resolver.service.ts +++ b/overlord/src/app/settings/lock-information-resolver.service.ts @@ -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 { +export class LockInformationResolver implements Resolve { constructor(private ser: SettingsService) {} - resolve(): Observable { + resolve(): Observable { return this.ser.getLockInformation(); } } diff --git a/overlord/src/app/settings/maintenance-resolver.service.ts b/overlord/src/app/settings/maintenance-resolver.service.ts index 83969e9c..fd448eda 100644 --- a/overlord/src/app/settings/maintenance-resolver.service.ts +++ b/overlord/src/app/settings/maintenance-resolver.service.ts @@ -7,10 +7,10 @@ import { SettingsService } from './settings.service'; @Injectable({ providedIn: 'root', }) -export class MaintenanceResolver implements Resolve { +export class MaintenanceResolver implements Resolve<{ enabled: boolean; user: string }> { constructor(private ser: SettingsService) {} - resolve(): Observable { + resolve(): Observable<{ enabled: boolean; user: string }> { return this.ser.getMaintenance(); } } diff --git a/overlord/src/app/settings/settings.component.ts b/overlord/src/app/settings/settings.component.ts index af6b7305..ec9a4c41 100644 --- a/overlord/src/app/settings/settings.component.ts +++ b/overlord/src/app/settings/settings.component.ts @@ -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; - 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) => { diff --git a/overlord/src/app/settings/settings.service.ts b/overlord/src/app/settings/settings.service.ts index 2f655aac..a626e1a1 100644 --- a/overlord/src/app/settings/settings.service.ts +++ b/overlord/src/app/settings/settings.service.ts @@ -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 { + getLockInformation(): Observable { const url = '/api/lock-information'; - return >( + return >( this.http - .get(url) + .get(url) .pipe(catchError(this.log.handleError(serviceName, 'getLockInformation'))) ); } - setLockInformation(lockInformation: any): Observable { + setLockInformation(lockInformation: LockInfo): Observable { const url = '/api/lock-information'; - return >( + return >( this.http - .post(url, lockInformation) + .post(url, lockInformation) .pipe(catchError(this.log.handleError(serviceName, 'setLockInformation'))) ); } - deleteLockInformation(): Observable { + deleteLockInformation(): Observable { const url = '/api/lock-information'; - return >( + return >( this.http - .delete(url) + .delete(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 { + rebaseDatabase(date: string): Observable<{}> { const url = '/api/rebase'; - return >( + return >( this.http - .post(`${url}/${date}`, {}) + .post<{}>(`${url}/${date}`, {}) .pipe(catchError(this.log.handleError(serviceName, 'rebaseDatabase'))) ); } - setMaintenance(enable: boolean): Observable { + setMaintenance(enable: boolean): Observable<{ enabled: boolean; user: string }> { const url = '/api/maintenance'; - return this.http - .post(url, { enabled: enable }) + return >this.http + .post<{ enabled: boolean; user: string }>(url, { enabled: enable }) .pipe(catchError(this.log.handleError(serviceName, 'setMaintenance'))); } - getMaintenance(): Observable { + getMaintenance(): Observable<{ enabled: boolean; user: string }> { const url = '/api/maintenance'; - return >( - this.http.get(url).pipe(catchError(this.log.handleError(serviceName, 'getMaintenance'))) + return >( + this.http + .get<{ enabled: boolean; user: string }>(url) + .pipe(catchError(this.log.handleError(serviceName, 'getMaintenance'))) ); } - checkDatabaseIntegrity(): Observable { + checkDatabaseIntegrity(): Observable<{ 'Duplicate Attendances Fixed': number }> { const url = '/api/db-integrity'; - return >( + return >( this.http - .post(url, {}) + .post<{ 'Duplicate Attendances Fixed': number }>(url, {}) .pipe(catchError(this.log.handleError(serviceName, 'checkDatabaseIntegrity'))) ); } diff --git a/overlord/src/app/shared/clear.pipe.ts b/overlord/src/app/shared/clear.pipe.ts index 0d8ef17d..e7403ce5 100644 --- a/overlord/src/app/shared/clear.pipe.ts +++ b/overlord/src/app/shared/clear.pipe.ts @@ -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; } } diff --git a/overlord/src/app/shared/confirm-dialog/confirm-dialog.component.spec.ts b/overlord/src/app/shared/confirm-dialog/confirm-dialog.component.spec.ts index ad57d9b1..beda8e35 100644 --- a/overlord/src/app/shared/confirm-dialog/confirm-dialog.component.spec.ts +++ b/overlord/src/app/shared/confirm-dialog/confirm-dialog.component.spec.ts @@ -6,11 +6,13 @@ describe('ConfirmDialogComponent', () => { let component: ConfirmDialogComponent; let fixture: ComponentFixture; - beforeEach(waitForAsync(() => { - TestBed.configureTestingModule({ - declarations: [ConfirmDialogComponent], - }).compileComponents(); - })); + beforeEach( + waitForAsync(() => { + TestBed.configureTestingModule({ + declarations: [ConfirmDialogComponent], + }).compileComponents(); + }), + ); beforeEach(() => { fixture = TestBed.createComponent(ConfirmDialogComponent); diff --git a/overlord/src/app/shared/confirm-dialog/confirm-dialog.component.ts b/overlord/src/app/shared/confirm-dialog/confirm-dialog.component.ts index 437ec3a5..a22e1b98 100644 --- a/overlord/src/app/shared/confirm-dialog/confirm-dialog.component.ts +++ b/overlord/src/app/shared/confirm-dialog/confirm-dialog.component.ts @@ -9,6 +9,6 @@ import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; export class ConfirmDialogComponent { constructor( public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: any, + @Inject(MAT_DIALOG_DATA) public data: { title: string; content: string }, ) {} } diff --git a/overlord/src/app/shared/image-dialog/image-dialog.component.spec.ts b/overlord/src/app/shared/image-dialog/image-dialog.component.spec.ts index a718757c..63497b31 100644 --- a/overlord/src/app/shared/image-dialog/image-dialog.component.spec.ts +++ b/overlord/src/app/shared/image-dialog/image-dialog.component.spec.ts @@ -6,11 +6,13 @@ describe('ImageDialogComponent', () => { let component: ImageDialogComponent; let fixture: ComponentFixture; - beforeEach(waitForAsync(() => { - TestBed.configureTestingModule({ - declarations: [ImageDialogComponent], - }).compileComponents(); - })); + beforeEach( + waitForAsync(() => { + TestBed.configureTestingModule({ + declarations: [ImageDialogComponent], + }).compileComponents(); + }), + ); beforeEach(() => { fixture = TestBed.createComponent(ImageDialogComponent); diff --git a/overlord/src/app/shared/image-dialog/image-dialog.component.ts b/overlord/src/app/shared/image-dialog/image-dialog.component.ts index 69efa1d2..3878fc27 100644 --- a/overlord/src/app/shared/image-dialog/image-dialog.component.ts +++ b/overlord/src/app/shared/image-dialog/image-dialog.component.ts @@ -9,7 +9,7 @@ import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; export class ImageDialogComponent { constructor( public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: any, + @Inject(MAT_DIALOG_DATA) public data: string, ) {} close(): void { diff --git a/overlord/src/app/shared/image.service.ts b/overlord/src/app/shared/image.service.ts index bc99d7c6..4c1ddd02 100644 --- a/overlord/src/app/shared/image.service.ts +++ b/overlord/src/app/shared/image.service.ts @@ -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] })), ); diff --git a/overlord/src/app/shared/math.service.ts b/overlord/src/app/shared/math.service.ts index 6ccfc4c1..ab3e154a 100644 --- a/overlord/src/app/shared/math.service.ts +++ b/overlord/src/app/shared/math.service.ts @@ -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) { diff --git a/overlord/src/app/shared/to-csv-type.ts b/overlord/src/app/shared/to-csv-type.ts new file mode 100644 index 00000000..87d1981c --- /dev/null +++ b/overlord/src/app/shared/to-csv-type.ts @@ -0,0 +1,3 @@ +export interface ToCsvType { + [column: string]: string | number | boolean | null; +} diff --git a/overlord/src/app/shared/to-csv.service.ts b/overlord/src/app/shared/to-csv.service.ts index 3fcfe657..01654fbb 100644 --- a/overlord/src/app/shared/to-csv.service.ts +++ b/overlord/src/app/shared/to-csv.service.ts @@ -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'); diff --git a/overlord/src/app/stock-movement/stock-movement.component.spec.ts b/overlord/src/app/stock-movement/stock-movement.component.spec.ts index 15f9cd73..3bcbeabf 100644 --- a/overlord/src/app/stock-movement/stock-movement.component.spec.ts +++ b/overlord/src/app/stock-movement/stock-movement.component.spec.ts @@ -8,12 +8,14 @@ describe('StockMovementComponent', () => { let component: StockMovementComponent; let fixture: ComponentFixture; - 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); diff --git a/overlord/src/app/trial-balance/trial-balance.component.spec.ts b/overlord/src/app/trial-balance/trial-balance.component.spec.ts index ee255890..aa2a37be 100644 --- a/overlord/src/app/trial-balance/trial-balance.component.spec.ts +++ b/overlord/src/app/trial-balance/trial-balance.component.spec.ts @@ -8,12 +8,14 @@ describe('TrialBalanceComponent', () => { let component: TrialBalanceComponent; let fixture: ComponentFixture; - 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); diff --git a/overlord/src/app/unposted/unposted.component.css b/overlord/src/app/unposted/unposted.component.css index a9626b3c..4add356c 100644 --- a/overlord/src/app/unposted/unposted.component.css +++ b/overlord/src/app/unposted/unposted.component.css @@ -2,3 +2,6 @@ display: flex; justify-content: flex-end; } +.my-margin { + margin: 0 12px; +} diff --git a/overlord/src/app/unposted/unposted.component.html b/overlord/src/app/unposted/unposted.component.html index e3072fc0..1860b376 100644 --- a/overlord/src/app/unposted/unposted.component.html +++ b/overlord/src/app/unposted/unposted.component.html @@ -6,6 +6,39 @@ Refresh + + + Self aware panel + + Currently I am {{ panelOpenState ? 'open' : 'closed' }} + + + + Unposted + +

+ + All userscv + + + Unposted + +
diff --git a/overlord/src/app/unposted/unposted.component.spec.ts b/overlord/src/app/unposted/unposted.component.spec.ts index fd54271f..945a84ed 100644 --- a/overlord/src/app/unposted/unposted.component.spec.ts +++ b/overlord/src/app/unposted/unposted.component.spec.ts @@ -8,12 +8,14 @@ describe('UnpostedComponent', () => { let component: UnpostedComponent; let fixture: ComponentFixture; - 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); diff --git a/overlord/src/app/unposted/unposted.component.ts b/overlord/src/app/unposted/unposted.component.ts index 855058ec..44094d71 100644 --- a/overlord/src/app/unposted/unposted.component.ts +++ b/overlord/src/app/unposted/unposted.component.ts @@ -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; + } + } } diff --git a/overlord/src/app/unposted/unposted.module.ts b/overlord/src/app/unposted/unposted.module.ts index 6ea1496e..f78e608f 100644 --- a/overlord/src/app/unposted/unposted.module.ts +++ b/overlord/src/app/unposted/unposted.module.ts @@ -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], }) diff --git a/overlord/src/app/user/user-detail/user-detail.component.spec.ts b/overlord/src/app/user/user-detail/user-detail.component.spec.ts index 6f918161..74e94f17 100644 --- a/overlord/src/app/user/user-detail/user-detail.component.spec.ts +++ b/overlord/src/app/user/user-detail/user-detail.component.spec.ts @@ -8,12 +8,14 @@ describe('UserDetailComponent', () => { let component: UserDetailComponent; let fixture: ComponentFixture; - 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);