Instanceof operator was not working so changed the way of checking it
This commit is contained in:
parent
4072733dfe
commit
dbdd00119a
docker
overlord
.eslintrc.json
src/app
account
account-detail
account-list
closing-stock
core
employee-attendance
entries
issue
ledger
product-ledger
purchase-return
purchase
rate-contract/rate-contract-detail
recipe/recipe-detail
role/role-detail
shared
@ -9,14 +9,16 @@
|
||||
|
||||
tasks:
|
||||
- name: Copy dockerfile
|
||||
synchronize: src=app dest=/tmp
|
||||
synchronize:
|
||||
src: app
|
||||
dest: "/tmp/{{ host_directory }}"
|
||||
|
||||
- name: Build brewman image
|
||||
docker_image:
|
||||
name: brewman:latest
|
||||
build:
|
||||
path: /tmp/app/
|
||||
dockerfile: /tmp/app/Dockerfile
|
||||
path: "/tmp/{{ host_directory }}/"
|
||||
dockerfile: "/tmp/{{ host_directory }}/Dockerfile"
|
||||
pull: yes
|
||||
state: present
|
||||
source: build
|
||||
|
@ -56,6 +56,9 @@
|
||||
"newlines-between": "always"
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/no-explicit-any": [
|
||||
"error"
|
||||
],
|
||||
"unused-imports/no-unused-imports": "error"
|
||||
}
|
||||
},
|
||||
|
@ -20,7 +20,7 @@ export class AccountDetailComponent implements OnInit, AfterViewInit {
|
||||
form: FormGroup<{
|
||||
code: FormControl<number | string>;
|
||||
name: FormControl<string | null>;
|
||||
type: FormControl<any>;
|
||||
type: FormControl<number>;
|
||||
isActive: FormControl<boolean>;
|
||||
isReconcilable: FormControl<boolean>;
|
||||
costCentre: FormControl<string | null>;
|
||||
@ -40,7 +40,7 @@ export class AccountDetailComponent implements OnInit, AfterViewInit {
|
||||
this.form = new FormGroup({
|
||||
code: new FormControl<string | number>({ value: 0, disabled: true }, { nonNullable: true }),
|
||||
name: new FormControl<string | null>(null),
|
||||
type: new FormControl<any>(''),
|
||||
type: new FormControl<number>(0, { nonNullable: true }),
|
||||
isActive: new FormControl<boolean>(true, { nonNullable: true }),
|
||||
isReconcilable: new FormControl<boolean>(false, { nonNullable: true }),
|
||||
costCentre: new FormControl<string | null>(null),
|
||||
@ -121,7 +121,7 @@ export class AccountDetailComponent implements OnInit, AfterViewInit {
|
||||
getItem(): Account {
|
||||
const formModel = this.form.value;
|
||||
this.item.name = formModel.name!;
|
||||
this.item.type = formModel.type;
|
||||
this.item.type = formModel.type!;
|
||||
this.item.isActive = formModel.isActive!;
|
||||
this.item.isReconcilable = formModel.isReconcilable!;
|
||||
this.item.costCentre.id = formModel.costCentre!;
|
||||
|
@ -6,7 +6,6 @@ import { merge, Observable, of as observableOf } from 'rxjs';
|
||||
import { map, tap } from 'rxjs/operators';
|
||||
|
||||
import { Account } from '../../core/account';
|
||||
import { AccountType } from '../../core/account-type';
|
||||
|
||||
/** Simple sort comparator for example ID/Name columns (for client-side sorting). */
|
||||
const compare = (a: string | number | boolean, b: string | number | boolean, isAsc: boolean) =>
|
||||
@ -92,7 +91,7 @@ export class AccountListDataSource extends DataSource<Account> {
|
||||
case 'name':
|
||||
return compare(a.name, b.name, isAsc);
|
||||
case 'type':
|
||||
return compare((a.type as AccountType).name, (b.type as AccountType).name, isAsc);
|
||||
return compare(a.typeName, b.typeName, isAsc);
|
||||
case 'isActive':
|
||||
return compare(a.isActive, b.isActive, isAsc);
|
||||
case 'isReconcilable':
|
||||
|
@ -42,7 +42,7 @@
|
||||
<!-- Type Column -->
|
||||
<ng-container matColumnDef="type">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header>Type</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{ row.type.name }}</mat-cell>
|
||||
<mat-cell *matCellDef="let row">{{ row.typeName }}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Is Active? Column -->
|
||||
|
@ -50,10 +50,7 @@ export class AccountListComponent implements OnInit, AfterViewInit {
|
||||
const data = value as { list: Account[]; accountTypes: AccountType[] };
|
||||
this.accountTypes = data.accountTypes;
|
||||
data.list.forEach(
|
||||
(x) =>
|
||||
(x.type = new AccountType({
|
||||
name: this.accountTypes.find((y) => y.id === x.type)?.name,
|
||||
})),
|
||||
(x) => (x.typeName = this.accountTypes.find((y) => y.id === x.type)?.name!),
|
||||
);
|
||||
this.list = data.list;
|
||||
});
|
||||
|
@ -124,7 +124,6 @@ export class ClosingStockComponent implements OnInit {
|
||||
? undefined
|
||||
: new CostCentre({ id: array.controls[index].value.costCentre });
|
||||
});
|
||||
console.log('getClosingStock', this.info);
|
||||
return this.info;
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
import { AccountType } from './account-type';
|
||||
import { CostCentre } from './cost-centre';
|
||||
|
||||
export class Account {
|
||||
id: string | undefined;
|
||||
code: number;
|
||||
name: string;
|
||||
type: AccountType | number;
|
||||
type: number;
|
||||
typeName: string;
|
||||
isActive: boolean;
|
||||
isReconcilable: boolean;
|
||||
isStarred: boolean;
|
||||
@ -15,7 +15,8 @@ export class Account {
|
||||
public constructor(init?: Partial<Account>) {
|
||||
this.code = 0;
|
||||
this.name = '';
|
||||
this.type = new AccountType();
|
||||
this.type = 0;
|
||||
this.typeName = '';
|
||||
this.isActive = true;
|
||||
this.isReconcilable = false;
|
||||
this.isStarred = false;
|
||||
|
@ -7,7 +7,6 @@ import { Observable } from 'rxjs/internal/Observable';
|
||||
})
|
||||
export class ErrorLoggerService {
|
||||
public static log(serviceName = 'error-logger', message: string) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`${serviceName}Service: ${message}`);
|
||||
}
|
||||
|
||||
@ -18,7 +17,6 @@ export class ErrorLoggerService {
|
||||
* @param operation - name of the operation that failed
|
||||
* @param result - optional value to return as the observable result
|
||||
*/
|
||||
// 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: unknown): Observable<T> => {
|
||||
ErrorLoggerService.log(serviceName, `${operation} failed: ${error}`);
|
||||
|
@ -22,7 +22,6 @@ export class JwtInterceptor implements HttpInterceptor {
|
||||
}
|
||||
const currentUser = this.authService.user;
|
||||
if (currentUser?.access_token) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
request = request.clone({
|
||||
setHeaders: {
|
||||
Authorization: `Bearer ${currentUser.access_token}`,
|
||||
|
@ -41,7 +41,6 @@ export class VoucherService {
|
||||
const endpoint = type.replace(/ /g, '-').toLowerCase();
|
||||
let options = {};
|
||||
if (account !== undefined && account !== null) {
|
||||
// eslint-disable-next-line @typescript-eslint/dot-notation
|
||||
options = { params: new HttpParams().set('a', account) };
|
||||
}
|
||||
return this.http
|
||||
|
@ -65,7 +65,7 @@ export class EmployeeAttendanceComponent implements OnInit, AfterViewInit {
|
||||
});
|
||||
// Listen to Employee Value Changes
|
||||
this.employees = this.form.controls.employee.valueChanges.pipe(
|
||||
map((x) => (x instanceof Employee ? x.name : x)),
|
||||
map((x) => ((x as Employee).name !== undefined ? (x as Employee).name : (x as string))),
|
||||
map((x) => (x !== null && x.length >= 1 ? x : null)),
|
||||
debounceTime(150),
|
||||
distinctUntilChanged(),
|
||||
|
@ -116,7 +116,6 @@ export class EntriesComponent implements OnInit {
|
||||
}
|
||||
|
||||
togglePosted($event: MatRadioChange) {
|
||||
console.log($event.value);
|
||||
this.posted = $event.value;
|
||||
if (this.posted === false) {
|
||||
this.issue = false;
|
||||
|
@ -36,7 +36,7 @@ export class IssueDialogComponent implements OnInit {
|
||||
});
|
||||
// Listen to Batch Autocomplete Change
|
||||
this.batches = this.form.controls.batch.valueChanges.pipe(
|
||||
map((x) => (x instanceof Batch ? x.name : x)),
|
||||
map((x) => ((x as Batch).name !== undefined ? (x as Batch).name : (x as string))),
|
||||
map((x) => (x !== null && x.length >= 1 ? x : '')),
|
||||
debounceTime(150),
|
||||
distinctUntilChanged(),
|
||||
|
@ -85,7 +85,7 @@ export class IssueComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
});
|
||||
// Listen to Batch Autocomplete Change
|
||||
this.batches = this.form.controls.addRow.controls.batch.valueChanges.pipe(
|
||||
map((x) => (x instanceof Batch ? x.name : x)),
|
||||
map((x) => ((x as Batch).name !== undefined ? (x as Batch).name : (x as string))),
|
||||
map((x) => (x !== null && x.length >= 1 ? x : '')),
|
||||
debounceTime(150),
|
||||
distinctUntilChanged(),
|
||||
|
@ -56,7 +56,7 @@ export class LedgerComponent implements OnInit, AfterViewInit {
|
||||
});
|
||||
|
||||
this.accounts = this.form.controls.account.valueChanges.pipe(
|
||||
map((x) => (x instanceof Account ? x.name : x)),
|
||||
map((x) => ((x as Account).name !== undefined ? (x as Account).name : (x as string))),
|
||||
map((x) => (x !== null && x.length >= 1 ? x : null)),
|
||||
debounceTime(150),
|
||||
distinctUntilChanged(),
|
||||
|
@ -71,7 +71,7 @@ export class ProductLedgerComponent implements OnInit, AfterViewInit {
|
||||
});
|
||||
|
||||
this.products = this.form.controls.product.valueChanges.pipe(
|
||||
map((x) => (x instanceof Product ? x.name : x)),
|
||||
map((x) => ((x as Product).name !== undefined ? (x as Product).name : (x as string))),
|
||||
map((x) => (x !== null && x.length >= 1 ? x : null)),
|
||||
debounceTime(150),
|
||||
distinctUntilChanged(),
|
||||
|
@ -36,7 +36,7 @@ export class PurchaseReturnDialogComponent implements OnInit {
|
||||
});
|
||||
// Listen to Batch Autocomplete Change
|
||||
this.batches = this.form.controls.batch.valueChanges.pipe(
|
||||
map((x) => (x instanceof Batch ? x.name : x)),
|
||||
map((x) => ((x as Batch).name !== undefined ? (x as Batch).name : (x as string))),
|
||||
map((x) => (x !== null && x.length >= 1 ? x : '')),
|
||||
debounceTime(150),
|
||||
distinctUntilChanged(),
|
||||
|
@ -85,7 +85,7 @@ export class PurchaseReturnComponent implements OnInit, AfterViewInit, OnDestroy
|
||||
});
|
||||
// Listen to Account Autocomplete Change
|
||||
this.accounts = this.form.controls.account.valueChanges.pipe(
|
||||
map((x) => (x instanceof Account ? x.name : x)),
|
||||
map((x) => ((x as Account).name !== undefined ? (x as Account).name : (x as string))),
|
||||
map((x) => (x !== null && x.length >= 1 ? x : null)),
|
||||
debounceTime(150),
|
||||
distinctUntilChanged(),
|
||||
@ -93,7 +93,7 @@ export class PurchaseReturnComponent implements OnInit, AfterViewInit, OnDestroy
|
||||
);
|
||||
// Listen to Batch Autocomplete Change
|
||||
this.batches = this.form.controls.addRow.controls.batch.valueChanges.pipe(
|
||||
map((x) => (x instanceof Batch ? x.name : x)),
|
||||
map((x) => ((x as Batch).name !== undefined ? (x as Batch).name : (x as string))),
|
||||
map((x) => (x !== null && x.length >= 1 ? x : '')),
|
||||
debounceTime(150),
|
||||
distinctUntilChanged(),
|
||||
@ -298,7 +298,7 @@ export class PurchaseReturnComponent implements OnInit, AfterViewInit, OnDestroy
|
||||
getVoucher(): Voucher {
|
||||
const formModel = this.form.value;
|
||||
this.voucher.date = moment(formModel.date).format('DD-MMM-YYYY');
|
||||
if (formModel.account instanceof Account) {
|
||||
if (formModel.account !== null && typeof formModel.account !== 'string') {
|
||||
this.voucher.vendor = formModel.account;
|
||||
}
|
||||
this.voucher.narration = formModel.narration!;
|
||||
|
@ -45,7 +45,7 @@ export class PurchaseDialogComponent implements OnInit {
|
||||
});
|
||||
// Listen to Product Autocomplete Change
|
||||
this.products = this.form.controls.product.valueChanges.pipe(
|
||||
map((x) => (x instanceof ProductSku ? x.name : x)),
|
||||
map((x) => ((x as ProductSku).name !== undefined ? (x as ProductSku).name : (x as string))),
|
||||
map((x) => (x !== null && x.length >= 1 ? x : null)),
|
||||
debounceTime(150),
|
||||
distinctUntilChanged(),
|
||||
|
@ -94,7 +94,7 @@ export class PurchaseComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
this.accBal = null;
|
||||
// Listen to Account Autocomplete Change
|
||||
this.accounts = this.form.controls.account.valueChanges.pipe(
|
||||
map((x) => (x instanceof Account ? x.name : x)),
|
||||
map((x) => ((x as Account).name !== undefined ? (x as Account).name : (x as string))),
|
||||
map((x) => (x !== null && x.length >= 1 ? x : null)),
|
||||
debounceTime(150),
|
||||
distinctUntilChanged(),
|
||||
@ -329,7 +329,7 @@ export class PurchaseComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
getVoucher(): Voucher {
|
||||
const formModel = this.form.value;
|
||||
this.voucher.date = moment(formModel.date).format('DD-MMM-YYYY');
|
||||
if (formModel.account instanceof Account) {
|
||||
if (formModel.account !== null && typeof formModel.account !== 'string') {
|
||||
this.voucher.vendor = formModel.account;
|
||||
}
|
||||
this.voucher.narration = formModel.narration!;
|
||||
|
@ -74,8 +74,7 @@ export class RateContractDetailComponent implements OnInit, AfterViewInit {
|
||||
narration: new FormControl('', { nonNullable: true }),
|
||||
});
|
||||
this.accounts = this.form.controls.account.valueChanges.pipe(
|
||||
map((x) => (x instanceof Account ? x.name : x)),
|
||||
map((x) => (x !== null && x.length >= 1 ? x : null)),
|
||||
map((x) => ((x as Account).name !== undefined ? (x as Account).name : (x as string))),
|
||||
map((x) => (x !== null && x.length >= 1 ? x : null)),
|
||||
debounceTime(150),
|
||||
distinctUntilChanged(),
|
||||
@ -216,8 +215,8 @@ export class RateContractDetailComponent implements OnInit, AfterViewInit {
|
||||
this.item.date = moment(formModel.date).format('DD-MMM-YYYY');
|
||||
this.item.validFrom = moment(formModel.validFrom).format('DD-MMM-YYYY');
|
||||
this.item.validTill = moment(formModel.validTill).format('DD-MMM-YYYY');
|
||||
if (formModel.account instanceof Account) {
|
||||
this.item.vendor = formModel.account;
|
||||
if (formModel.account !== null && typeof formModel.account !== 'string') {
|
||||
this.item.vendor = formModel.account!;
|
||||
}
|
||||
this.item.narration = formModel.narration!;
|
||||
return this.item;
|
||||
|
@ -80,7 +80,7 @@ export class RecipeDetailComponent implements OnInit, AfterViewInit {
|
||||
});
|
||||
// Setup Product Autocomplete
|
||||
this.products = this.form.controls.product.valueChanges.pipe(
|
||||
map((x) => (x instanceof ProductSku ? x.name : x)),
|
||||
map((x) => ((x as ProductSku).name !== undefined ? (x as ProductSku).name : (x as string))),
|
||||
map((x) => (x !== null && x.length >= 1 ? x : null)),
|
||||
debounceTime(150),
|
||||
distinctUntilChanged(),
|
||||
|
@ -42,9 +42,10 @@ export class RoleDetailComponent implements OnInit, AfterViewInit {
|
||||
ngOnInit() {
|
||||
this.route.data.subscribe((value) => {
|
||||
const data = value as { item: Role };
|
||||
|
||||
this.item = data.item;
|
||||
|
||||
this.form.controls.name.setValue(this.item.name);
|
||||
this.form.controls.permissions.reset();
|
||||
this.item.permissions.forEach((x) =>
|
||||
this.form.controls.permissions.push(
|
||||
new FormGroup({
|
||||
|
@ -4,7 +4,6 @@ import { Injectable } from '@angular/core';
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class CookieService {
|
||||
// eslint-disable-next-line class-methods-use-this
|
||||
public getCookie(name: string) {
|
||||
const ca: Array<string> = document.cookie.split(';');
|
||||
const caLen: number = ca.length;
|
||||
@ -24,7 +23,6 @@ export class CookieService {
|
||||
this.setCookie(name, '', -1);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line class-methods-use-this
|
||||
public setCookie(name: string, value: string, expireDays: number, path: string = '') {
|
||||
const d: Date = new Date();
|
||||
d.setTime(d.getTime() + expireDays * 24 * 60 * 60 * 1000);
|
||||
|
@ -9,7 +9,6 @@ import { Voucher } from '../core/voucher';
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ImageService {
|
||||
// eslint-disable-next-line class-methods-use-this
|
||||
resizeImage(image: string, maxWidth: number, maxHeight: number) {
|
||||
const canvas = document.createElement('canvas');
|
||||
const ctx = canvas.getContext('2d') as CanvasRenderingContext2D;
|
||||
|
@ -6,7 +6,6 @@ import { ToCsvType } from './to-csv-type';
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ToCsvService {
|
||||
// eslint-disable-next-line class-methods-use-this
|
||||
toCsv(headers: { [display: string]: string }, data: unknown[]): string {
|
||||
const header = Object.keys(headers);
|
||||
const replacer = (key: string, value: string | number | null) => (value === null ? '' : value);
|
||||
|
Loading…
x
Reference in New Issue
Block a user