Updated to angular 11
Now compiling with strict mode in typescript Need to error checking now
This commit is contained in:
@ -3,6 +3,16 @@ export class ProductSaleReportItem {
|
||||
kot: number;
|
||||
regularBill: number;
|
||||
noCharge: number;
|
||||
staf: number;
|
||||
staff: number;
|
||||
void: number;
|
||||
|
||||
public constructor(init?: Partial<ProductSaleReportItem>) {
|
||||
this.name = '';
|
||||
this.kot = 0;
|
||||
this.regularBill = 0;
|
||||
this.noCharge = 0;
|
||||
this.staff = 0;
|
||||
this.void = 0;
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
||||
|
||||
import { ProductSaleReportComponent } from './product-sale-report.component';
|
||||
|
||||
@ -6,11 +6,13 @@ describe('ProductSaleReportComponent', () => {
|
||||
let component: ProductSaleReportComponent;
|
||||
let fixture: ComponentFixture<ProductSaleReportComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ProductSaleReportComponent],
|
||||
}).compileComponents();
|
||||
}));
|
||||
beforeEach(
|
||||
waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ProductSaleReportComponent],
|
||||
}).compileComponents();
|
||||
}),
|
||||
);
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ProductSaleReportComponent);
|
||||
|
||||
@ -14,9 +14,9 @@ import { ProductSaleReportDataSource } from './product-sale-report-datasource';
|
||||
styleUrls: ['./product-sale-report.component.css'],
|
||||
})
|
||||
export class ProductSaleReportComponent implements OnInit {
|
||||
dataSource: ProductSaleReportDataSource;
|
||||
info: ProductSaleReport = new ProductSaleReport();
|
||||
dataSource: ProductSaleReportDataSource = new ProductSaleReportDataSource(this.info.amounts);
|
||||
form: FormGroup;
|
||||
info: ProductSaleReport;
|
||||
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
displayedColumns = ['name', 'unbilled', 'sale', 'noCharge', 'staff', 'void'];
|
||||
@ -27,11 +27,16 @@ export class ProductSaleReportComponent implements OnInit {
|
||||
private fb: FormBuilder,
|
||||
private toCsv: ToCsvService,
|
||||
) {
|
||||
this.createForm();
|
||||
// Create form
|
||||
this.form = this.fb.group({
|
||||
startDate: '',
|
||||
finishDate: '',
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data.subscribe((data: { info: ProductSaleReport }) => {
|
||||
this.route.data.subscribe((value) => {
|
||||
const data = value as { info: ProductSaleReport };
|
||||
this.info = data.info;
|
||||
this.form.setValue({
|
||||
startDate: moment(this.info.startDate, 'DD-MMM-YYYY').toDate(),
|
||||
@ -51,20 +56,13 @@ export class ProductSaleReportComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
createForm() {
|
||||
this.form = this.fb.group({
|
||||
startDate: '',
|
||||
finishDate: '',
|
||||
});
|
||||
}
|
||||
|
||||
getInfo(): ProductSaleReport {
|
||||
const formModel = this.form.value;
|
||||
|
||||
return {
|
||||
return new ProductSaleReport({
|
||||
startDate: moment(formModel.startDate).format('DD-MMM-YYYY'),
|
||||
finishDate: moment(formModel.finishDate).format('DD-MMM-YYYY'),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
exportCsv() {
|
||||
|
||||
@ -16,7 +16,7 @@ const serviceName = 'ProductSaleReportService';
|
||||
export class ProductSaleReportService {
|
||||
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
|
||||
|
||||
get(startDate: string, finishDate): Observable<ProductSaleReport> {
|
||||
get(startDate: string | null, finishDate: string | null): Observable<ProductSaleReport> {
|
||||
const options = { params: new HttpParams() };
|
||||
if (startDate !== null) {
|
||||
options.params = options.params.set('s', startDate);
|
||||
|
||||
@ -3,5 +3,12 @@ import { ProductSaleReportItem } from './product-sale-report-item';
|
||||
export class ProductSaleReport {
|
||||
startDate: string;
|
||||
finishDate: string;
|
||||
amounts?: ProductSaleReportItem[];
|
||||
amounts: ProductSaleReportItem[];
|
||||
|
||||
public constructor(init?: Partial<ProductSaleReport>) {
|
||||
this.startDate = '';
|
||||
this.finishDate = '';
|
||||
this.amounts = [];
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user