Moved from tslint to eslint as tslint was depreciated.
Added prettier and also prettied all the typescript files using prettier ESLint is using the AirBnB rules which are the most strict to lint the files.
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
import {Component, Inject, OnInit} from '@angular/core';
|
||||
import { Component, Inject, OnInit } from '@angular/core';
|
||||
import { MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
import {FormBuilder, FormGroup} from '@angular/forms';
|
||||
import {debounceTime, distinctUntilChanged, map, startWith, switchMap} from 'rxjs/operators';
|
||||
import {Observable, of as observableOf} from 'rxjs';
|
||||
import {Batch} from '../core/voucher';
|
||||
import {BatchService} from '../core/batch.service';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { debounceTime, distinctUntilChanged, map, startWith, switchMap } from 'rxjs/operators';
|
||||
import { Observable, of as observableOf } from 'rxjs';
|
||||
import { Batch } from '../core/voucher';
|
||||
import { BatchService } from '../core/batch.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-issue-dialog',
|
||||
templateUrl: './issue-dialog.component.html',
|
||||
styleUrls: ['./issue-dialog.component.css']
|
||||
styleUrls: ['./issue-dialog.component.css'],
|
||||
})
|
||||
export class IssueDialogComponent implements OnInit {
|
||||
batches: Observable<Batch[]>;
|
||||
@@ -21,7 +21,8 @@ export class IssueDialogComponent implements OnInit {
|
||||
public dialogRef: MatDialogRef<IssueDialogComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: any,
|
||||
private fb: FormBuilder,
|
||||
private batchSer: BatchService) {
|
||||
private batchSer: BatchService,
|
||||
) {
|
||||
this.createForm();
|
||||
this.listenToBatchAutocompleteChange();
|
||||
}
|
||||
@@ -29,7 +30,7 @@ export class IssueDialogComponent implements OnInit {
|
||||
ngOnInit() {
|
||||
this.form.setValue({
|
||||
batch: this.data.inventory.batch,
|
||||
quantity: this.data.inventory.quantity
|
||||
quantity: this.data.inventory.quantity,
|
||||
});
|
||||
this.batch = this.data.inventory.batch;
|
||||
}
|
||||
@@ -37,19 +38,21 @@ export class IssueDialogComponent implements OnInit {
|
||||
createForm() {
|
||||
this.form = this.fb.group({
|
||||
batch: '',
|
||||
quantity: ''
|
||||
quantity: '',
|
||||
});
|
||||
}
|
||||
|
||||
listenToBatchAutocompleteChange(): void {
|
||||
const control = this.form.get('batch');
|
||||
this.batches = control.valueChanges
|
||||
.pipe(
|
||||
startWith(null),
|
||||
map(x => (x !== null && x.length >= 1) ? x : null),
|
||||
debounceTime(150),
|
||||
distinctUntilChanged(),
|
||||
switchMap(x => (x === null) ? observableOf([]) : this.batchSer.autocomplete(this.data.date, x)));
|
||||
this.batches = control.valueChanges.pipe(
|
||||
startWith(null),
|
||||
map((x) => (x !== null && x.length >= 1 ? x : null)),
|
||||
debounceTime(150),
|
||||
distinctUntilChanged(),
|
||||
switchMap((x) =>
|
||||
x === null ? observableOf([]) : this.batchSer.autocomplete(this.data.date, x),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
displayBatchName(batch?: Batch): string | undefined {
|
||||
@@ -62,14 +65,15 @@ export class IssueDialogComponent implements OnInit {
|
||||
|
||||
accept(): void {
|
||||
const formValue = this.form.value;
|
||||
const quantity = +(formValue.quantity);
|
||||
const quantity = +formValue.quantity;
|
||||
this.data.inventory.batch = this.batch;
|
||||
this.data.inventory.product = this.batch.product;
|
||||
this.data.inventory.quantity = quantity;
|
||||
this.data.inventory.rate = this.batch.rate;
|
||||
this.data.inventory.tax = this.batch.tax;
|
||||
this.data.inventory.discount = this.batch.discount;
|
||||
this.data.inventory.amount = quantity * this.batch.rate * (1 + this.batch.tax) * (1 - this.batch.discount);
|
||||
this.data.inventory.amount =
|
||||
quantity * this.batch.rate * (1 + this.batch.tax) * (1 - this.batch.discount);
|
||||
this.dialogRef.close(this.data.inventory);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user