Product Sale Module done (Sales Detail) -- need to rename the permission

This commit is contained in:
Amritanshu
2019-08-21 09:27:19 +05:30
parent 241568622e
commit 0f00d96dc9
19 changed files with 528 additions and 0 deletions
@@ -0,0 +1,90 @@
import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import * as moment from 'moment';
import { ProductSaleReportDataSource } from './product-sale-report-datasource';
import { ProductSaleReport } from './product-sale-report';
import { ToCsvService } from '../shared/to-csv.service';
@Component({
selector: 'app-product-sale-report',
templateUrl: './product-sale-report.component.html',
styleUrls: ['./product-sale-report.component.css']
})
export class ProductSaleReportComponent implements OnInit {
dataSource: ProductSaleReportDataSource;
form: FormGroup;
info: ProductSaleReport;
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
displayedColumns = ['name', 'unbilled', 'sale', 'noCharge', 'staff', 'void'];
constructor(
private route: ActivatedRoute,
private router: Router,
private fb: FormBuilder,
private toCsv: ToCsvService
) {
this.createForm();
}
ngOnInit() {
this.route.data
.subscribe((data: { info: ProductSaleReport }) => {
this.info = data.info;
this.form.setValue({
startDate: moment(this.info.startDate, 'DD-MMM-YYYY').toDate(),
finishDate: moment(this.info.finishDate, 'DD-MMM-YYYY').toDate()
});
this.dataSource = new ProductSaleReportDataSource(this.info.amounts);
});
}
show() {
const info = this.getInfo();
this.router.navigate(['product-sale-report'], {
queryParams: {
startDate: info.startDate,
finishDate: info.finishDate
}
});
}
createForm() {
this.form = this.fb.group({
startDate: '',
finishDate: ''
});
}
getInfo(): ProductSaleReport {
const formModel = this.form.value;
return {
startDate: moment(formModel.startDate).format('DD-MMM-YYYY'),
finishDate: moment(formModel.finishDate).format('DD-MMM-YYYY')
};
}
exportCsv() {
const headers = {
Date: 'date',
Name: 'name',
Type: 'type',
Narration: 'narration',
Debit: 'debit',
Credit: 'credit',
Running: 'running',
Posted: 'posted'
};
const csvData = new Blob([this.toCsv.toCsv(headers, this.dataSource.data)], {type: 'text/csv;charset=utf-8;'});
const link = document.createElement('a');
link.href = window.URL.createObjectURL(csvData);
link.setAttribute('download', 'product-sale-report.csv');
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
}