Updated to angular 11

Now compiling with strict mode in typescript
Need to error checking now
This commit is contained in:
2020-11-22 10:13:37 +05:30
parent cabd6f2ea1
commit 6567f560ab
187 changed files with 1709 additions and 1184 deletions

View File

@ -3,4 +3,12 @@ export class TaxReportItem {
taxRate: number;
saleAmount: number;
amount: number;
public constructor(init?: Partial<TaxReportItem>) {
this.name = '';
this.taxRate = 0;
this.saleAmount = 0;
this.amount = 0;
Object.assign(this, init);
}
}

View File

@ -1,4 +1,4 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { TaxReportComponent } from './tax-report.component';
@ -6,11 +6,13 @@ describe('TaxReportComponent', () => {
let component: TaxReportComponent;
let fixture: ComponentFixture<TaxReportComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [TaxReportComponent],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [TaxReportComponent],
}).compileComponents();
}),
);
beforeEach(() => {
fixture = TestBed.createComponent(TaxReportComponent);

View File

@ -14,9 +14,9 @@ import { TaxReportDatasource } from './tax-report-datasource';
styleUrls: ['./tax-report.component.css'],
})
export class TaxReportComponent implements OnInit {
dataSource: TaxReportDatasource;
info: TaxReport = new TaxReport();
dataSource: TaxReportDatasource = new TaxReportDatasource(this.info.amounts);
form: FormGroup;
info: TaxReport;
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
displayedColumns = ['name', 'taxRate', 'saleAmount', 'taxAmount'];
@ -27,11 +27,16 @@ export class TaxReportComponent 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: TaxReport }) => {
this.route.data.subscribe((value) => {
const data = value as { info: TaxReport };
this.info = data.info;
this.form.setValue({
startDate: moment(this.info.startDate, 'DD-MMM-YYYY').toDate(),
@ -51,20 +56,13 @@ export class TaxReportComponent implements OnInit {
});
}
createForm() {
this.form = this.fb.group({
startDate: '',
finishDate: '',
});
}
getInfo(): TaxReport {
const formModel = this.form.value;
return {
return new TaxReport({
startDate: moment(formModel.startDate).format('DD-MMM-YYYY'),
finishDate: moment(formModel.finishDate).format('DD-MMM-YYYY'),
};
});
}
exportCsv() {

View File

@ -16,7 +16,7 @@ const serviceName = 'TaxReportService';
export class TaxReportService {
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
get(startDate: string, finishDate): Observable<TaxReport> {
get(startDate: string | null, finishDate: string | null): Observable<TaxReport> {
const options = { params: new HttpParams() };
if (startDate !== null) {
options.params = options.params.set('s', startDate);

View File

@ -3,5 +3,12 @@ import { TaxReportItem } from './tax-report-item';
export class TaxReport {
startDate: string;
finishDate: string;
amounts?: TaxReportItem[];
amounts: TaxReportItem[];
public constructor(init?: Partial<TaxReport>) {
this.startDate = '';
this.finishDate = '';
this.amounts = [];
Object.assign(this, init);
}
}