Renamed Report permissions to make more sense
Removed the void and reprints report and added it to the bill settlement report updated the import to add a new sql to be executed later to update the settlements and report permission names Export works on all reports
This commit is contained in:
1 parent
05860fb0b9
commit
6d0f30503a
98 files changed
+527
-1079
No files matched your search
@@ -0,0 +1,9 @@
|
||||
update permissions set name = 'Beer Consumption Report' where name = 'Beer Consumption';
|
||||
update permissions set name = 'Bill Settlement Report' where name = 'Bill Details';
|
||||
update permissions set name = 'Cashier Report' where name = 'Cashier Checkout';
|
||||
update permissions set name = 'Product Sale Report' where name = 'Sales Detail';
|
||||
update permissions set name = 'Sale Report' where name = 'Sales Analysis';
|
||||
update permissions set name = 'Tax Report' where name = 'Tax Analysis';
|
||||
delete from role_permissions where permission_id = (select id from permissions where name = 'Void or Reprinted Bill Report');
|
||||
delete from permissions where name = 'Void or Reprinted Bill Report';
|
||||
update settlements as s set settled = 9 from vouchers v where v.id = s.voucher_id and v.voucher_type = 5 and s.settled = 1;
|
||||
+12
-22
@@ -369,38 +369,36 @@ def includeme(config):
|
||||
config.add_route("v1_move_kot", "/v1/move-kot")
|
||||
|
||||
config.add_route("v1_active_cashiers", "/v1/active-cashiers")
|
||||
config.add_route("v1_checkout_id", "/v1/checkout/{id}")
|
||||
config.add_route("checkout_id", "/checkout/{id}")
|
||||
config.add_route("v1_cashier_report_id", "/v1/cashier-report/{id}")
|
||||
config.add_route("cashier_report_id", "/cashier-report/{id}")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="checkout_id",
|
||||
route_name="cashier_report_id",
|
||||
request_method="GET",
|
||||
permission="Cashier Checkout",
|
||||
)
|
||||
config.add_route("v1_checkout_blank", "/v1/checkout")
|
||||
config.add_route("checkout_blank", "/checkout")
|
||||
config.add_route("v1_cashier_report", "/v1/cashier-report")
|
||||
config.add_route("cashier_report", "/cashier-report")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="checkout_blank",
|
||||
route_name="cashier_report",
|
||||
request_method="GET",
|
||||
permission="Cashier Checkout",
|
||||
)
|
||||
|
||||
config.add_route("v1_sa_sale", "/v1/sale-analysis/sale")
|
||||
config.add_route("v1_sa_settlements", "/v1/sale-analysis/settlements")
|
||||
config.add_route("v1_sa_tax", "/v1/sale-analysis/tax")
|
||||
config.add_route("v1_sale_analysis", "/v1/sale-analysis")
|
||||
config.add_route("sale_analysis", "/sale-analysis")
|
||||
config.add_route("v1_sale_report", "/v1/sale-report")
|
||||
config.add_route("sale_report", "/sale-report")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="sale_analysis",
|
||||
route_name="sale_report",
|
||||
request_method="GET",
|
||||
permission="Sales Analysis",
|
||||
)
|
||||
config.add_route("tax_analysis", "/tax-analysis")
|
||||
config.add_route("v1_tax_report", "/v1/tax-report")
|
||||
config.add_route("tax_report", "/tax-report")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="tax_analysis",
|
||||
route_name="tax_report",
|
||||
request_method="GET",
|
||||
permission="Tax Analysis",
|
||||
)
|
||||
@@ -440,14 +438,6 @@ def includeme(config):
|
||||
permission="Discount Report",
|
||||
)
|
||||
|
||||
config.add_route("v1_voids_reprints_report", "/v1/voids-reprints-report")
|
||||
config.add_route("voids_reprints_report", "/voids-reprints-report")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="voids_reprints_report",
|
||||
request_method="GET",
|
||||
permission="Void or Reprinted Bill Report",
|
||||
)
|
||||
# config.add_route("v1_bills_new", "/v1/bills/new")
|
||||
# config.add_route("v1_bills_id", "/v1/bills/{id}")
|
||||
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ from barker.views.reports import get_start_date, get_finish_date
|
||||
request_method="GET",
|
||||
route_name="v1_beer_consumption_report",
|
||||
renderer="json",
|
||||
permission="Beer Consumption",
|
||||
permission="Beer Consumption Report",
|
||||
)
|
||||
def beer_consumption(request):
|
||||
start_date = get_start_date(request.GET.get("s", None)) - timedelta(hours=7)
|
||||
@@ -2,7 +2,7 @@ from datetime import datetime, timedelta
|
||||
|
||||
from pyramid.view import view_config
|
||||
|
||||
from barker.models import Settlement, SettleOption, Voucher, VoucherType
|
||||
from barker.models import Settlement, SettleOption, Voucher, VoucherType, Reprint
|
||||
from barker.models.validation_exception import ValidationError
|
||||
from barker.views.reports import get_start_date, get_finish_date
|
||||
|
||||
@@ -11,7 +11,7 @@ from barker.views.reports import get_start_date, get_finish_date
|
||||
request_method="GET",
|
||||
route_name="v1_bill_settlement_report",
|
||||
renderer="json",
|
||||
permission="Bill Details",
|
||||
permission="Bill Settlement Report",
|
||||
)
|
||||
def bill_details(request):
|
||||
start_date = get_start_date(request.GET.get("s", None))
|
||||
@@ -22,8 +22,17 @@ def bill_details(request):
|
||||
).days > 5 and "Accounts Audit" not in request.effective_principals:
|
||||
raise ValidationError("Accounts Audit")
|
||||
|
||||
return {
|
||||
"startDate": start_date.date().strftime("%d-%b-%Y"),
|
||||
"finishDate": (finish_date - timedelta(days=1)).date().strftime("%d-%b-%Y"),
|
||||
"amounts": settlements(start_date, finish_date, request.dbsession)
|
||||
+ reprints(start_date, finish_date, request.dbsession),
|
||||
}
|
||||
|
||||
|
||||
def settlements(start_date, finish_date, dbsession):
|
||||
vouchers = (
|
||||
request.dbsession.query(Voucher)
|
||||
dbsession.query(Voucher)
|
||||
.join(Voucher.settlements)
|
||||
.join(Settlement.settle_option)
|
||||
.filter(Voucher.date >= start_date, Voucher.date <= finish_date)
|
||||
@@ -34,37 +43,43 @@ def bill_details(request):
|
||||
|
||||
report = []
|
||||
for item in vouchers:
|
||||
if item.voucher_type == VoucherType.VOID:
|
||||
amount = (
|
||||
next(
|
||||
s.amount
|
||||
for s in item.settlements
|
||||
if s.settled == SettleOption.AMOUNT()
|
||||
)
|
||||
* -1
|
||||
)
|
||||
for so in (so for so in item.settlements if so.settle_option.show_in_choices):
|
||||
if item.voucher_type == VoucherType.VOID:
|
||||
details = f"Void: {item.reason}"
|
||||
elif item.voucher_type == VoucherType.STAFF:
|
||||
details = f"Staff: {item.reason}"
|
||||
elif item.voucher_type == VoucherType.NO_CHARGE:
|
||||
details = f"NC: {item.reason}"
|
||||
else:
|
||||
details = so.settle_option.name
|
||||
report.append(
|
||||
{
|
||||
"date": item.date.strftime("%d-%b-%Y %H:%M:%S"),
|
||||
"billId": item.full_bill_id,
|
||||
"settlement": "Void: {0}".format(item.void_reason),
|
||||
"amount": round(amount, 2),
|
||||
"settlement": details,
|
||||
"amount": round(so.amount, 2),
|
||||
}
|
||||
)
|
||||
else:
|
||||
for so in (
|
||||
so for so in item.settlements if so.settle_option.show_in_choices
|
||||
):
|
||||
report.append(
|
||||
{
|
||||
"date": item.date.strftime("%d-%b-%Y %H:%M:%S"),
|
||||
"billId": item.full_bill_id,
|
||||
"settlement": so.settle_option.name,
|
||||
"amount": round(so.amount, 2),
|
||||
}
|
||||
return report
|
||||
|
||||
|
||||
def reprints(start_date, finish_date, dbsession):
|
||||
return [
|
||||
{
|
||||
"date": item.date.strftime("%d-%b-%Y %H:%M:%S"),
|
||||
"billId": item.voucher.full_bill_id,
|
||||
"settlement": f"Reprinted by {item.user.name}",
|
||||
"Amount": round(
|
||||
next(
|
||||
s.amount
|
||||
for s in item.voucher.settlements
|
||||
if s.settled == SettleOption.AMOUNT()
|
||||
)
|
||||
return {
|
||||
"startDate": start_date.date().strftime("%d-%b-%Y"),
|
||||
"finishDate": (finish_date - timedelta(days=1)).date().strftime("%d-%b-%Y"),
|
||||
"amounts": report,
|
||||
}
|
||||
* -1,
|
||||
2,
|
||||
),
|
||||
}
|
||||
for item in dbsession.query(Reprint)
|
||||
.filter(Reprint.date >= start_date, Reprint.date <= finish_date)
|
||||
.all()
|
||||
]
|
||||
@@ -14,7 +14,7 @@ __author__ = "tanshu"
|
||||
request_method="GET",
|
||||
route_name="v1_active_cashiers",
|
||||
renderer="json",
|
||||
permission="Cashier Checkout",
|
||||
permission="Cashier Report",
|
||||
)
|
||||
def active_cashiers(request):
|
||||
start_date = get_start_date(request.GET.get("s", None))
|
||||
@@ -38,9 +38,9 @@ def active_cashiers(request):
|
||||
|
||||
@view_config(
|
||||
request_method="GET",
|
||||
route_name="v1_checkout_blank",
|
||||
route_name="v1_cashier_report",
|
||||
renderer="json",
|
||||
permission="Cashier Checkout",
|
||||
permission="Cashier Report",
|
||||
)
|
||||
def blank_out(request):
|
||||
start_date = request.GET.get("s", datetime.today().strftime("%d-%b-%Y"))
|
||||
@@ -57,9 +57,9 @@ def blank_out(request):
|
||||
|
||||
@view_config(
|
||||
request_method="GET",
|
||||
route_name="v1_checkout_id",
|
||||
route_name="v1_cashier_report_id",
|
||||
renderer="json",
|
||||
permission="Cashier Checkout",
|
||||
permission="Cashier Report",
|
||||
request_param=("s", "f"),
|
||||
)
|
||||
def check_me_out(request):
|
||||
@@ -19,7 +19,7 @@ from barker.views.reports import get_start_date, get_finish_date
|
||||
request_method="GET",
|
||||
route_name="v1_product_sale_report",
|
||||
renderer="json",
|
||||
permission="Sales Detail",
|
||||
permission="Product Sale Report",
|
||||
)
|
||||
def product_sale_report_view(request):
|
||||
start_date = get_start_date(request.GET.get("s", None))
|
||||
|
||||
@@ -19,9 +19,9 @@ from barker.views.reports import get_start_date, get_finish_date
|
||||
|
||||
@view_config(
|
||||
request_method="GET",
|
||||
route_name="v1_sale_analysis",
|
||||
route_name="v1_sale_report",
|
||||
renderer="json",
|
||||
permission="Sales Analysis",
|
||||
permission="Sale Report",
|
||||
)
|
||||
def get_sale_analysis(request):
|
||||
start_date = get_start_date(request.GET.get("s", None))
|
||||
@@ -45,28 +45,6 @@ def get_sale_analysis(request):
|
||||
}
|
||||
|
||||
|
||||
@view_config(
|
||||
request_method="GET",
|
||||
route_name="v1_sa_sale",
|
||||
renderer="json",
|
||||
permission="Sales Analysis",
|
||||
)
|
||||
def get_sale_view(request):
|
||||
start_date = get_start_date(request.GET.get("s", None))
|
||||
finish_date = get_finish_date(request.GET.get("f", None))
|
||||
|
||||
if (
|
||||
datetime.today() - start_date.replace(hour=0)
|
||||
).days > 5 and "Accounts Audit" not in request.effective_principals:
|
||||
raise ValidationError("Accounts Audit")
|
||||
|
||||
return {
|
||||
"startDate": start_date.date().strftime("%d-%b-%Y"),
|
||||
"finishDate": (finish_date - timedelta(days=1)).date().strftime("%d-%b-%Y"),
|
||||
"amounts": get_sale(start_date, finish_date, request.dbsession),
|
||||
}
|
||||
|
||||
|
||||
def get_sale(start_date, finish_date, dbsession):
|
||||
list_ = (
|
||||
dbsession.query(SaleCategory.name, func.sum(Inventory.net))
|
||||
@@ -91,28 +69,6 @@ def get_sale(start_date, finish_date, dbsession):
|
||||
return info + [{"name": "Total Settled", "amount": total}]
|
||||
|
||||
|
||||
@view_config(
|
||||
request_method="GET",
|
||||
route_name="v1_sa_settlements",
|
||||
renderer="json",
|
||||
permission="Sales Analysis",
|
||||
)
|
||||
def get_settlements_view(request):
|
||||
start_date = get_start_date(request.GET.get("s", None))
|
||||
finish_date = get_finish_date(request.GET.get("f", None))
|
||||
|
||||
if (
|
||||
datetime.today() - start_date.replace(hour=0)
|
||||
).days > 5 and "Accounts Audit" not in request.effective_principals:
|
||||
raise ValidationError("Accounts Audit")
|
||||
|
||||
return {
|
||||
"startDate": start_date.date().strftime("%d-%b-%Y"),
|
||||
"finishDate": (finish_date - timedelta(days=1)).date().strftime("%d-%b-%Y"),
|
||||
"amounts": get_settlements(start_date, finish_date, request.dbsession),
|
||||
}
|
||||
|
||||
|
||||
def get_settlements(start_date, finish_date, dbsession):
|
||||
list_ = (
|
||||
dbsession.query(SettleOption.name, func.sum(Settlement.amount))
|
||||
@@ -133,9 +89,9 @@ def get_settlements(start_date, finish_date, dbsession):
|
||||
|
||||
@view_config(
|
||||
request_method="GET",
|
||||
route_name="v1_sa_tax",
|
||||
route_name="v1_tax_report",
|
||||
renderer="json",
|
||||
permission=("Tax Analysis", "Sales Analysis"),
|
||||
permission="Tax Report",
|
||||
)
|
||||
def get_tax_view(request):
|
||||
start_date = get_start_date(request.GET.get("s", None))
|
||||
@@ -1,65 +0,0 @@
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from pyramid.view import view_config
|
||||
|
||||
from barker.models import Settlement, SettleOption, Voucher, VoucherType, Reprint
|
||||
from barker.models.validation_exception import ValidationError
|
||||
from barker.views.reports import get_start_date, get_finish_date
|
||||
|
||||
|
||||
@view_config(
|
||||
request_method="GET",
|
||||
route_name="v1_voids_reprints_report",
|
||||
renderer="json",
|
||||
permission="Void or Reprinted Bill Report",
|
||||
)
|
||||
def voids_reprints_report_view(request):
|
||||
start_date = get_start_date(request.GET.get("s", None))
|
||||
finish_date = get_finish_date(request.GET.get("f", None))
|
||||
|
||||
if (
|
||||
datetime.today() - start_date.replace(hour=0)
|
||||
).days > 5 and "Accounts Audit" not in request.effective_principals:
|
||||
raise ValidationError("Accounts Audit")
|
||||
|
||||
return {
|
||||
"startDate": start_date.date().strftime("%d-%b-%Y"),
|
||||
"finishDate": (finish_date - timedelta(days=1)).date().strftime("%d-%b-%Y"),
|
||||
"amounts": voids_reprints_report(start_date, finish_date, request.dbsession),
|
||||
}
|
||||
|
||||
|
||||
def voids_reprints_report(start_date, finish_date, dbsession):
|
||||
vouchers = (
|
||||
dbsession.query(Voucher, Settlement.amount * -1)
|
||||
.join(Voucher.settlements)
|
||||
.filter(Voucher.date >= start_date, Voucher.date <= finish_date, Voucher.voucher_type == VoucherType.VOID.value, Settlement.settled == SettleOption.AMOUNT())
|
||||
.order_by(Voucher.date)
|
||||
.all()
|
||||
)
|
||||
print(str(vouchers))
|
||||
report = []
|
||||
for item, amount in vouchers:
|
||||
report.append(
|
||||
{
|
||||
"date": item.date.strftime("%d-%b-%Y %H:%M:%S"),
|
||||
"billId": item.full_bill_id,
|
||||
"settlement": f"Void: {item.void_reason}",
|
||||
"amount": round(amount, 2),
|
||||
}
|
||||
)
|
||||
reprints = dbsession.query(Reprint).filter(
|
||||
Reprint.date >= start_date,
|
||||
Reprint.date <= finish_date
|
||||
).all()
|
||||
|
||||
for item in reprints:
|
||||
report.append({
|
||||
'date': item.date.strftime('%d-%b-%Y %H:%M:%S'),
|
||||
'billId': item.voucher.full_bill_id,
|
||||
'settlement': f"Reprinted by {item.user.name}",
|
||||
'Amount': round(next(
|
||||
s.amount for s in item.voucher.settlements if s.settled == SettleOption.AMOUNT()
|
||||
) * -1, 2)
|
||||
})
|
||||
return report
|
||||
@@ -14,8 +14,8 @@ const routes: Routes = [
|
||||
loadChildren: () => import('./bill-settlement-report/bill-settlement-report.module').then(mod => mod.BillSettlementReportModule)
|
||||
},
|
||||
{
|
||||
path: 'checkout',
|
||||
loadChildren: () => import('./cashier-checkout/cashier-checkout.module').then(mod => mod.CashierCheckoutModule)
|
||||
path: 'cashier-report',
|
||||
loadChildren: () => import('./cashier-report/cashier-report.module').then(mod => mod.CashierReportModule)
|
||||
},
|
||||
{
|
||||
path: 'devices',
|
||||
@@ -62,8 +62,8 @@ const routes: Routes = [
|
||||
loadChildren: () => import('./sales/sales.module').then(mod => mod.SalesModule)
|
||||
},
|
||||
{
|
||||
path: 'sale-analysis',
|
||||
loadChildren: () => import('./sale-analysis/sale-analysis.module').then(mod => mod.SaleAnalysisModule)
|
||||
path: 'sale-report',
|
||||
loadChildren: () => import('./sale-report/sale-report.module').then(mod => mod.SaleReportModule)
|
||||
},
|
||||
{
|
||||
path: 'sale-categories',
|
||||
@@ -86,17 +86,13 @@ const routes: Routes = [
|
||||
loadChildren: () => import('./taxes/taxes.module').then(mod => mod.TaxesModule)
|
||||
},
|
||||
{
|
||||
path: 'tax-analysis',
|
||||
loadChildren: () => import('./tax-analysis/tax-analysis.module').then(mod => mod.TaxAnalysisModule)
|
||||
path: 'tax-report',
|
||||
loadChildren: () => import('./tax-report/tax-report.module').then(mod => mod.TaxReportModule)
|
||||
},
|
||||
{
|
||||
path: 'users',
|
||||
loadChildren: () => import('./users/users.module').then(mod => mod.UsersModule)
|
||||
},
|
||||
{
|
||||
path: 'voids-reprints-report',
|
||||
loadChildren: () => import('./voids-reprints-report/voids-reprints-report.module').then(mod => mod.VoidsReprintsReportModule)
|
||||
},
|
||||
{path: 'login', component: LoginComponent},
|
||||
{path: 'logout', component: LogoutComponent},
|
||||
{path: '', component: HomeComponent},
|
||||
|
||||
@@ -5,13 +5,13 @@ import { BeerConsumptionReportResolver } from './beer-consumption-report-resolve
|
||||
import { AuthGuard } from '../auth/auth-guard.service';
|
||||
import { BeerConsumptionReportComponent } from './beer-consumption-report.component';
|
||||
|
||||
const BeerConsumptionReportRoutes: Routes = [
|
||||
const beerConsumptionReportRoutes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: BeerConsumptionReportComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Beer Consumption' // rename to Bill Settlement Report
|
||||
permission: 'Beer Consumption Report'
|
||||
},
|
||||
resolve: {
|
||||
info: BeerConsumptionReportResolver
|
||||
@@ -23,7 +23,7 @@ const BeerConsumptionReportRoutes: Routes = [
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
RouterModule.forChild(BeerConsumptionReportRoutes)
|
||||
RouterModule.forChild(beerConsumptionReportRoutes)
|
||||
|
||||
],
|
||||
exports: [
|
||||
|
||||
@@ -70,17 +70,13 @@ export class BeerConsumptionReportComponent implements OnInit {
|
||||
}
|
||||
|
||||
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 headers = this.info.headers.reduce((a, c) => {
|
||||
a[c] = c;
|
||||
return a
|
||||
}, {
|
||||
Date: 'date'
|
||||
});
|
||||
const csvData = new Blob([this.toCsv.toCsv(headers, this.info.data)], {type: 'text/csv;charset=utf-8;'});
|
||||
const link = document.createElement('a');
|
||||
link.href = window.URL.createObjectURL(csvData);
|
||||
link.setAttribute('download', 'beer-consumption-report.csv');
|
||||
|
||||
@@ -5,13 +5,13 @@ import { BillSettlementReportResolver } from './bill-settlement-report-resolver.
|
||||
import { AuthGuard } from '../auth/auth-guard.service';
|
||||
import { BillSettlementReportComponent } from './bill-settlement-report.component';
|
||||
|
||||
const BillSettlementReportRoutes: Routes = [
|
||||
const billSettlementReportRoutes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: BillSettlementReportComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Bill Details' // rename to Bill Settlement Report
|
||||
permission: 'Bill Settlement Report'
|
||||
},
|
||||
resolve: {
|
||||
info: BillSettlementReportResolver
|
||||
@@ -23,7 +23,7 @@ const BillSettlementReportRoutes: Routes = [
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
RouterModule.forChild(BillSettlementReportRoutes)
|
||||
RouterModule.forChild(billSettlementReportRoutes)
|
||||
|
||||
],
|
||||
exports: [
|
||||
|
||||
@@ -71,13 +71,9 @@ export class BillSettlementReportComponent implements OnInit {
|
||||
exportCsv() {
|
||||
const headers = {
|
||||
Date: 'date',
|
||||
Name: 'name',
|
||||
Type: 'type',
|
||||
Narration: 'narration',
|
||||
Debit: 'debit',
|
||||
Credit: 'credit',
|
||||
Running: 'running',
|
||||
Posted: 'posted'
|
||||
BillID: 'billId',
|
||||
Amount: 'amount',
|
||||
Settlement: 'settlement'
|
||||
};
|
||||
const csvData = new Blob([this.toCsv.toCsv(headers, this.dataSource.data)], {type: 'text/csv;charset=utf-8;'});
|
||||
const link = document.createElement('a');
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
import { DataSource } from '@angular/cdk/collections';
|
||||
import { Observable, of as observableOf } from 'rxjs';
|
||||
import { CashierCheckoutDisplayItem } from './cashier-checkout';
|
||||
|
||||
|
||||
export class CashierCheckoutDataSource extends DataSource<CashierCheckoutDisplayItem> {
|
||||
|
||||
constructor(public data: CashierCheckoutDisplayItem[]) {
|
||||
super();
|
||||
}
|
||||
|
||||
connect(): Observable<CashierCheckoutDisplayItem[]> {
|
||||
return observableOf(this.data);
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
import {inject, TestBed} from '@angular/core/testing';
|
||||
|
||||
import {CashierCheckoutResolver} from './cashier-checkout-resolver.service';
|
||||
|
||||
describe('CashierCheckoutResolver', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [CashierCheckoutResolver]
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([CashierCheckoutResolver], (service: CashierCheckoutResolver) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
});
|
||||
@@ -1,13 +0,0 @@
|
||||
import {CashierCheckoutRoutingModule} from './cashier-checkout-routing.module';
|
||||
|
||||
describe('CashierCheckoutRoutingModule', () => {
|
||||
let cashierCheckoutRoutingModule: CashierCheckoutRoutingModule;
|
||||
|
||||
beforeEach(() => {
|
||||
cashierCheckoutRoutingModule = new CashierCheckoutRoutingModule();
|
||||
});
|
||||
|
||||
it('should create an instance', () => {
|
||||
expect(cashierCheckoutRoutingModule).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -1,13 +0,0 @@
|
||||
import {CashierCheckoutModule} from './cashier-checkout.module';
|
||||
|
||||
describe('CashierCheckoutModule', () => {
|
||||
let cashierCheckoutModule: CashierCheckoutModule;
|
||||
|
||||
beforeEach(() => {
|
||||
cashierCheckoutModule = new CashierCheckoutModule();
|
||||
});
|
||||
|
||||
it('should create an instance', () => {
|
||||
expect(cashierCheckoutModule).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -1,15 +0,0 @@
|
||||
import {inject, TestBed} from '@angular/core/testing';
|
||||
|
||||
import {CashierCheckoutService} from './cashier-checkout.service';
|
||||
|
||||
describe('CashierCheckoutService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [CashierCheckoutService]
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([CashierCheckoutService], (service: CashierCheckoutService) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
});
|
||||
File renamed without changes.
+2
-2
@@ -1,7 +1,7 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { CashierCheckoutService } from './cashier-checkout.service';
|
||||
import { CashierReportService } from './cashier-report.service';
|
||||
import { User } from '../core/user';
|
||||
|
||||
@Injectable({
|
||||
@@ -9,7 +9,7 @@ import { User } from '../core/user';
|
||||
})
|
||||
export class ActiveCashiersResolver implements Resolve<User[]> {
|
||||
|
||||
constructor(private ser: CashierCheckoutService) {
|
||||
constructor(private ser: CashierReportService) {
|
||||
}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<User[]> {
|
||||
@@ -0,0 +1,18 @@
|
||||
import { DataSource } from '@angular/cdk/collections';
|
||||
import { Observable, of as observableOf } from 'rxjs';
|
||||
import { CashierReportDisplayItem } from './cashier-report';
|
||||
|
||||
|
||||
export class CashierReportDataSource extends DataSource<CashierReportDisplayItem> {
|
||||
|
||||
constructor(public data: CashierReportDisplayItem[]) {
|
||||
super();
|
||||
}
|
||||
|
||||
connect(): Observable<CashierReportDisplayItem[]> {
|
||||
return observableOf(this.data);
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import {inject, TestBed} from '@angular/core/testing';
|
||||
|
||||
import {CashierReportResolver} from './cashier-report-resolver.service';
|
||||
|
||||
describe('CashierReportResolver', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [CashierReportResolver]
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([CashierReportResolver], (service: CashierReportResolver) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
});
|
||||
+5
-5
@@ -1,18 +1,18 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {ActivatedRouteSnapshot, Resolve, RouterStateSnapshot} from '@angular/router';
|
||||
import {Observable} from 'rxjs/internal/Observable';
|
||||
import {CashierCheckout} from './cashier-checkout';
|
||||
import {CashierCheckoutService} from './cashier-checkout.service';
|
||||
import {CashierReport} from './cashier-report';
|
||||
import {CashierReportService} from './cashier-report.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class CashierCheckoutResolver implements Resolve<CashierCheckout> {
|
||||
export class CashierReportResolver implements Resolve<CashierReport> {
|
||||
|
||||
constructor(private ser: CashierCheckoutService) {
|
||||
constructor(private ser: CashierReportService) {
|
||||
}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<CashierCheckout> {
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<CashierReport> {
|
||||
const id = route.paramMap.get('id');
|
||||
const startDate = route.queryParamMap.get('startDate') || null;
|
||||
const finishDate = route.queryParamMap.get('finishDate') || null;
|
||||
@@ -0,0 +1,13 @@
|
||||
import {CashierReportRoutingModule} from './cashier-report-routing.module';
|
||||
|
||||
describe('CashierReportRoutingModule', () => {
|
||||
let cashierReportRoutingModule: CashierReportRoutingModule;
|
||||
|
||||
beforeEach(() => {
|
||||
cashierReportRoutingModule = new CashierReportRoutingModule();
|
||||
});
|
||||
|
||||
it('should create an instance', () => {
|
||||
expect(cashierReportRoutingModule).toBeTruthy();
|
||||
});
|
||||
});
|
||||
+12
-12
@@ -1,34 +1,34 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
import { CashierCheckoutResolver } from './cashier-checkout-resolver.service';
|
||||
import { CashierReportResolver } from './cashier-report-resolver.service';
|
||||
import { AuthGuard } from '../auth/auth-guard.service';
|
||||
import { CashierCheckoutComponent } from './cashier-checkout.component';
|
||||
import { CashierReportComponent } from './cashier-report.component';
|
||||
import { ActiveCashiersResolver } from './active-cashiers-resolver.service';
|
||||
|
||||
const CashierCheckoutRoutes: Routes = [
|
||||
const cashierReportRoutes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: CashierCheckoutComponent,
|
||||
component: CashierReportComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Cashier Checkout'
|
||||
permission: 'Cashier Report'
|
||||
},
|
||||
resolve: {
|
||||
info: CashierCheckoutResolver,
|
||||
info: CashierReportResolver,
|
||||
cashiers: ActiveCashiersResolver
|
||||
},
|
||||
runGuardsAndResolvers: 'always'
|
||||
},
|
||||
{
|
||||
path: ':id',
|
||||
component: CashierCheckoutComponent,
|
||||
component: CashierReportComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Cashier Checkout'
|
||||
permission: 'Cashier Report'
|
||||
},
|
||||
resolve: {
|
||||
info: CashierCheckoutResolver,
|
||||
info: CashierReportResolver,
|
||||
cashiers: ActiveCashiersResolver
|
||||
},
|
||||
runGuardsAndResolvers: 'always'
|
||||
@@ -38,15 +38,15 @@ const CashierCheckoutRoutes: Routes = [
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
RouterModule.forChild(CashierCheckoutRoutes)
|
||||
RouterModule.forChild(cashierReportRoutes)
|
||||
|
||||
],
|
||||
exports: [
|
||||
RouterModule
|
||||
],
|
||||
providers: [
|
||||
CashierCheckoutResolver
|
||||
CashierReportResolver
|
||||
]
|
||||
})
|
||||
export class CashierCheckoutRoutingModule {
|
||||
export class CashierReportRoutingModule {
|
||||
}
|
||||
File renamed without changes.
+1
-1
@@ -1,6 +1,6 @@
|
||||
<mat-card>
|
||||
<mat-card-title-group>
|
||||
<mat-card-title>Checkout</mat-card-title>
|
||||
<mat-card-title>Cashier Report</mat-card-title>
|
||||
<button mat-button mat-icon-button (click)="exportCsv()">
|
||||
<mat-icon>save_alt</mat-icon>
|
||||
</button>
|
||||
+6
-6
@@ -1,20 +1,20 @@
|
||||
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
|
||||
|
||||
import {CashierCheckoutComponent} from './cashier-checkout.component';
|
||||
import {CashierReportComponent} from './cashier-report.component';
|
||||
|
||||
describe('CashierCheckoutComponent', () => {
|
||||
let component: CashierCheckoutComponent;
|
||||
let fixture: ComponentFixture<CashierCheckoutComponent>;
|
||||
describe('CashierReportComponent', () => {
|
||||
let component: CashierReportComponent;
|
||||
let fixture: ComponentFixture<CashierReportComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [CashierCheckoutComponent]
|
||||
declarations: [CashierReportComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(CashierCheckoutComponent);
|
||||
fixture = TestBed.createComponent(CashierReportComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
+14
-20
@@ -2,21 +2,21 @@ import { Component, OnInit } from '@angular/core';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import * as moment from 'moment';
|
||||
import { CashierCheckoutDataSource } from './cashier-checkout-datasource';
|
||||
import { CashierCheckout } from './cashier-checkout';
|
||||
import { CashierReportDataSource } from './cashier-report-datasource';
|
||||
import { CashierReport } from './cashier-report';
|
||||
import { ToCsvService } from '../shared/to-csv.service';
|
||||
import { User } from '../core/user';
|
||||
|
||||
@Component({
|
||||
selector: 'app-cashier-checkout',
|
||||
templateUrl: './cashier-checkout.component.html',
|
||||
styleUrls: ['./cashier-checkout.component.css']
|
||||
selector: 'app-cashier-report',
|
||||
templateUrl: './cashier-report.component.html',
|
||||
styleUrls: ['./cashier-report.component.css']
|
||||
})
|
||||
export class CashierCheckoutComponent implements OnInit {
|
||||
dataSource: CashierCheckoutDataSource;
|
||||
export class CashierReportComponent implements OnInit {
|
||||
dataSource: CashierReportDataSource;
|
||||
form: FormGroup;
|
||||
activeCashiers: User[];
|
||||
info: CashierCheckout;
|
||||
info: CashierReport;
|
||||
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
displayedColumns = ['name', 'amount'];
|
||||
@@ -34,7 +34,7 @@ export class CashierCheckoutComponent implements OnInit {
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data
|
||||
.subscribe((data: { cashiers: User[], info: CashierCheckout }) => {
|
||||
.subscribe((data: { cashiers: User[], info: CashierReport }) => {
|
||||
this.activeCashiers = data.cashiers;
|
||||
this.info = data.info;
|
||||
this.form.setValue({
|
||||
@@ -42,13 +42,13 @@ export class CashierCheckoutComponent implements OnInit {
|
||||
startDate: moment(this.info.startDate, 'DD-MMM-YYYY').toDate(),
|
||||
finishDate: moment(this.info.finishDate, 'DD-MMM-YYYY').toDate()
|
||||
});
|
||||
this.dataSource = new CashierCheckoutDataSource(this.info.amounts);
|
||||
this.dataSource = new CashierReportDataSource(this.info.amounts);
|
||||
});
|
||||
}
|
||||
|
||||
show() {
|
||||
const info = this.getInfo();
|
||||
const url = ['checkout'];
|
||||
const url = ['cashier-report'];
|
||||
if (!!info.user.id) {
|
||||
url.push(info.user.id);
|
||||
}
|
||||
@@ -68,7 +68,7 @@ export class CashierCheckoutComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
getInfo(): CashierCheckout {
|
||||
getInfo(): CashierReport {
|
||||
const formModel = this.form.value;
|
||||
|
||||
return {
|
||||
@@ -80,19 +80,13 @@ export class CashierCheckoutComponent implements OnInit {
|
||||
|
||||
exportCsv() {
|
||||
const headers = {
|
||||
Date: 'date',
|
||||
Name: 'name',
|
||||
Type: 'type',
|
||||
Narration: 'narration',
|
||||
Debit: 'debit',
|
||||
Credit: 'credit',
|
||||
Running: 'running',
|
||||
Posted: 'posted'
|
||||
Amount: 'amount'
|
||||
};
|
||||
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', 'cashier-checkout.csv');
|
||||
link.setAttribute('download', 'cashier-report.csv');
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
@@ -0,0 +1,13 @@
|
||||
import {CashierReportModule} from './cashier-report.module';
|
||||
|
||||
describe('CashierReportModule', () => {
|
||||
let cashierReportModule: CashierReportModule;
|
||||
|
||||
beforeEach(() => {
|
||||
cashierReportModule = new CashierReportModule();
|
||||
});
|
||||
|
||||
it('should create an instance', () => {
|
||||
expect(cashierReportModule).toBeTruthy();
|
||||
});
|
||||
});
|
||||
+5
-5
@@ -16,8 +16,8 @@ import { MatTableModule } from '@angular/material/table';
|
||||
import { SharedModule} from '../shared/shared.module';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { CdkTableModule } from '@angular/cdk/table';
|
||||
import { CashierCheckoutRoutingModule } from './cashier-checkout-routing.module';
|
||||
import { CashierCheckoutComponent } from './cashier-checkout.component';
|
||||
import { CashierReportRoutingModule } from './cashier-report-routing.module';
|
||||
import { CashierReportComponent } from './cashier-report.component';
|
||||
import { MomentDateAdapter } from '@angular/material-moment-adapter';
|
||||
import { A11yModule } from '@angular/cdk/a11y';
|
||||
import { FlexLayoutModule } from '@angular/flex-layout';
|
||||
@@ -57,15 +57,15 @@ export const MY_FORMATS = {
|
||||
MatTableModule,
|
||||
ReactiveFormsModule,
|
||||
SharedModule,
|
||||
CashierCheckoutRoutingModule
|
||||
CashierReportRoutingModule
|
||||
],
|
||||
declarations: [
|
||||
CashierCheckoutComponent
|
||||
CashierReportComponent
|
||||
],
|
||||
providers: [
|
||||
{provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE]},
|
||||
{provide: MAT_DATE_FORMATS, useValue: MY_FORMATS},
|
||||
]
|
||||
})
|
||||
export class CashierCheckoutModule {
|
||||
export class CashierReportModule {
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import {inject, TestBed} from '@angular/core/testing';
|
||||
|
||||
import {CashierReportService} from './cashier-report.service';
|
||||
|
||||
describe('CashierReportService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [CashierReportService]
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([CashierReportService], (service: CashierReportService) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
});
|
||||
+6
-6
@@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
||||
import { CashierCheckout } from './cashier-checkout';
|
||||
import { CashierReport } from './cashier-report';
|
||||
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||
import { User } from '../core/user';
|
||||
|
||||
@@ -10,19 +10,19 @@ const httpOptions = {
|
||||
headers: new HttpHeaders({'Content-Type': 'application/json'})
|
||||
};
|
||||
|
||||
const url = '/v1/checkout';
|
||||
const url = '/v1/cashier-report';
|
||||
const urlActiveCashiers = '/v1/active-cashiers';
|
||||
const serviceName = 'CashierCheckoutService';
|
||||
const serviceName = 'CashierReportService';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class CashierCheckoutService {
|
||||
export class CashierReportService {
|
||||
|
||||
constructor(private http: HttpClient, private log: ErrorLoggerService) {
|
||||
}
|
||||
|
||||
list(id: string, startDate: string, finishDate): Observable<CashierCheckout> {
|
||||
list(id: string, startDate: string, finishDate): Observable<CashierReport> {
|
||||
const listUrl = (id === null) ? url : `${url}/${id}`;
|
||||
const options = {params: new HttpParams()};
|
||||
if (startDate !== null) {
|
||||
@@ -31,7 +31,7 @@ export class CashierCheckoutService {
|
||||
if (finishDate !== null) {
|
||||
options.params = options.params.set('f', finishDate);
|
||||
}
|
||||
return <Observable<CashierCheckout>>this.http.get<CashierCheckout>(listUrl, options)
|
||||
return <Observable<CashierReport>>this.http.get<CashierReport>(listUrl, options)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'list'))
|
||||
);
|
||||
+5
-5
@@ -1,21 +1,21 @@
|
||||
import { User } from '../core/user';
|
||||
|
||||
export class CashierCheckoutPrintItem {
|
||||
export class CashierReportPrintItem {
|
||||
date: string;
|
||||
billId: string;
|
||||
customer: string;
|
||||
amount: number;
|
||||
}
|
||||
|
||||
export class CashierCheckoutDisplayItem {
|
||||
export class CashierReportDisplayItem {
|
||||
name: string;
|
||||
amount: number;
|
||||
}
|
||||
|
||||
export class CashierCheckout {
|
||||
export class CashierReport {
|
||||
startDate: string;
|
||||
finishDate: string;
|
||||
user: User;
|
||||
amounts?: CashierCheckoutDisplayItem[];
|
||||
info?: CashierCheckoutPrintItem[];
|
||||
amounts?: CashierReportDisplayItem[];
|
||||
info?: CashierReportPrintItem[];
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import { DiscountReportResolver } from './discount-report-resolver.service';
|
||||
import { AuthGuard } from '../auth/auth-guard.service';
|
||||
import { DiscountReportComponent } from './discount-report.component';
|
||||
|
||||
const DiscountReportRoutes: Routes = [
|
||||
const discountReportRoutes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: DiscountReportComponent,
|
||||
@@ -23,7 +23,7 @@ const DiscountReportRoutes: Routes = [
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
RouterModule.forChild(DiscountReportRoutes)
|
||||
RouterModule.forChild(discountReportRoutes)
|
||||
|
||||
],
|
||||
exports: [
|
||||
|
||||
@@ -70,14 +70,8 @@ export class DiscountReportComponent implements OnInit {
|
||||
|
||||
exportCsv() {
|
||||
const headers = {
|
||||
Date: 'date',
|
||||
Name: 'name',
|
||||
Type: 'type',
|
||||
Narration: 'narration',
|
||||
Debit: 'debit',
|
||||
Credit: 'credit',
|
||||
Running: 'running',
|
||||
Posted: 'posted'
|
||||
Amount: 'amount'
|
||||
};
|
||||
const csvData = new Blob([this.toCsv.toCsv(headers, this.dataSource.data)], {type: 'text/csv;charset=utf-8;'});
|
||||
const link = document.createElement('a');
|
||||
|
||||
@@ -5,27 +5,24 @@
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.hasPermission('Sales')" [routerLink]="['/', 'sales']">
|
||||
<h3 class="item-name">Sales</h3>
|
||||
</mat-card>
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.hasPermission('Cashier Checkout')" [routerLink]="['/', 'checkout']">
|
||||
<h3 class="item-name">Cashier Checkout</h3>
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.hasPermission('Cashier Report')" [routerLink]="['/', 'cashier-report']">
|
||||
<h3 class="item-name">Cashier Report</h3>
|
||||
</mat-card>
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.hasPermission('Sales Analysis')" [routerLink]="['/', 'sale-analysis']">
|
||||
<h3 class="item-name">Sale Analysis</h3>
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.hasPermission('Sale Report')" [routerLink]="['/', 'sale-report']">
|
||||
<h3 class="item-name">Sale Report</h3>
|
||||
</mat-card>
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.hasPermission('Tax Analysis')" [routerLink]="['/', 'tax-analysis']">
|
||||
<h3 class="item-name">Tax Analysis</h3>
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.hasPermission('Tax Report')" [routerLink]="['/', 'tax-report']">
|
||||
<h3 class="item-name">Tax Report</h3>
|
||||
</mat-card>
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.hasPermission('Sales Detail')" [routerLink]="['/', 'product-sale-report']">
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.hasPermission('Product Sale Report')" [routerLink]="['/', 'product-sale-report']">
|
||||
<h3 class="item-name">Product Sale Report</h3>
|
||||
</mat-card>
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.hasPermission('Bill Details')" [routerLink]="['/', 'bill-settlement-report']">
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.hasPermission('Bill Settlement Report')" [routerLink]="['/', 'bill-settlement-report']">
|
||||
<h3 class="item-name">Bill Settlement Report</h3>
|
||||
</mat-card>
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.hasPermission('Beer Consumption')" [routerLink]="['/', 'beer-consumption-report']">
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.hasPermission('Beer Consumption Report')" [routerLink]="['/', 'beer-consumption-report']">
|
||||
<h3 class="item-name">Beer Consumption Report</h3>
|
||||
</mat-card>
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.hasPermission('Void or Reprinted Bill Report')" [routerLink]="['/', 'voids-reprints-report']">
|
||||
<h3 class="item-name">Voids and Reprints Report</h3>
|
||||
</mat-card>
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.hasPermission('Discount Report')" [routerLink]="['/', 'discount-report']">
|
||||
<h3 class="item-name">Discount Report</h3>
|
||||
</mat-card>
|
||||
|
||||
@@ -7,7 +7,7 @@ import { ModifierCategoryListComponent } from './modifier-category-list/modifier
|
||||
import { ModifierCategoryDetailComponent } from './modifier-category-detail/modifier-category-detail.component';
|
||||
import { AuthGuard } from '../auth/auth-guard.service';
|
||||
|
||||
const roleRoutes: Routes = [
|
||||
const modifierCategoriesRoutes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: ModifierCategoryListComponent,
|
||||
@@ -46,7 +46,7 @@ const roleRoutes: Routes = [
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
RouterModule.forChild(roleRoutes)
|
||||
RouterModule.forChild(modifierCategoriesRoutes)
|
||||
|
||||
],
|
||||
exports: [
|
||||
|
||||
@@ -10,7 +10,7 @@ import { ModifierListComponent } from './modifier-list/modifier-list.component';
|
||||
import { AuthGuard } from '../auth/auth-guard.service';
|
||||
import { ModifierCategoryListResolver } from '../modifier-categories/modifier-category-list-resolver.service';
|
||||
|
||||
const modifierRoutes: Routes = [
|
||||
const modifiersRoutes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: ModifierListComponent,
|
||||
@@ -52,7 +52,7 @@ const modifierRoutes: Routes = [
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
RouterModule.forChild(modifierRoutes)
|
||||
RouterModule.forChild(modifiersRoutes)
|
||||
|
||||
],
|
||||
exports: [
|
||||
|
||||
@@ -5,13 +5,13 @@ import { ProductSaleReportResolver } from './product-sale-report-resolver.servic
|
||||
import { AuthGuard } from '../auth/auth-guard.service';
|
||||
import { ProductSaleReportComponent } from './product-sale-report.component';
|
||||
|
||||
const ProductSaleReportRoutes: Routes = [
|
||||
const productSaleReportRoutes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: ProductSaleReportComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Sales Detail' // rename to Product Sale Report
|
||||
permission: 'Product Sale Report'
|
||||
},
|
||||
resolve: {
|
||||
info: ProductSaleReportResolver
|
||||
@@ -23,7 +23,7 @@ const ProductSaleReportRoutes: Routes = [
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
RouterModule.forChild(ProductSaleReportRoutes)
|
||||
RouterModule.forChild(productSaleReportRoutes)
|
||||
|
||||
],
|
||||
exports: [
|
||||
|
||||
@@ -70,14 +70,12 @@ export class ProductSaleReportComponent implements OnInit {
|
||||
|
||||
exportCsv() {
|
||||
const headers = {
|
||||
Date: 'date',
|
||||
Name: 'name',
|
||||
Type: 'type',
|
||||
Narration: 'narration',
|
||||
Debit: 'debit',
|
||||
Credit: 'credit',
|
||||
Running: 'running',
|
||||
Posted: 'posted'
|
||||
Unbilled: 'kot',
|
||||
Sold: 'regularBill',
|
||||
'No Charge': 'noCharge',
|
||||
Staff: 'staff',
|
||||
Void: 'void'
|
||||
};
|
||||
const csvData = new Blob([this.toCsv.toCsv(headers, this.dataSource.data)], {type: 'text/csv;charset=utf-8;'});
|
||||
const link = document.createElement('a');
|
||||
|
||||
@@ -11,7 +11,7 @@ import { AuthGuard } from '../auth/auth-guard.service';
|
||||
import { MenuCategoryListResolver } from '../menu-category/menu-category-list-resolver.service';
|
||||
import { SaleCategoryListResolver } from '../sale-category/sale-category-list-resolver.service';
|
||||
|
||||
const productRoutes: Routes = [
|
||||
const productsRoutes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: ProductListComponent,
|
||||
@@ -55,7 +55,7 @@ const productRoutes: Routes = [
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
RouterModule.forChild(productRoutes)
|
||||
RouterModule.forChild(productsRoutes)
|
||||
|
||||
],
|
||||
exports: [
|
||||
|
||||
@@ -7,7 +7,7 @@ import {RoleListComponent} from './role-list/role-list.component';
|
||||
import {RoleDetailComponent} from './role-detail/role-detail.component';
|
||||
import {AuthGuard} from '../auth/auth-guard.service';
|
||||
|
||||
const roleRoutes: Routes = [
|
||||
const rolesRoutes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: RoleListComponent,
|
||||
@@ -46,7 +46,7 @@ const roleRoutes: Routes = [
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
RouterModule.forChild(roleRoutes)
|
||||
RouterModule.forChild(rolesRoutes)
|
||||
|
||||
],
|
||||
exports: [
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
import { DataSource } from '@angular/cdk/collections';
|
||||
import { Observable, of as observableOf } from 'rxjs';
|
||||
import { SaleAnalysisItem } from './sale-analysis';
|
||||
|
||||
|
||||
export class SaleAnalysisDataSource extends DataSource<SaleAnalysisItem> {
|
||||
|
||||
constructor(public data: SaleAnalysisItem[]) {
|
||||
super();
|
||||
}
|
||||
|
||||
connect(): Observable<SaleAnalysisItem[]> {
|
||||
return observableOf(this.data);
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
import {inject, TestBed} from '@angular/core/testing';
|
||||
|
||||
import {SaleAnalysisResolver} from './sale-analysis-resolver.service';
|
||||
|
||||
describe('SaleAnalysisResolver', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [SaleAnalysisResolver]
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([SaleAnalysisResolver], (service: SaleAnalysisResolver) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
});
|
||||
@@ -1,20 +0,0 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {ActivatedRouteSnapshot, Resolve, RouterStateSnapshot} from '@angular/router';
|
||||
import {Observable} from 'rxjs/internal/Observable';
|
||||
import {SaleAnalysis} from './sale-analysis';
|
||||
import {SaleAnalysisService} from './sale-analysis.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class SaleAnalysisResolver implements Resolve<SaleAnalysis> {
|
||||
|
||||
constructor(private ser: SaleAnalysisService) {
|
||||
}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<SaleAnalysis> {
|
||||
const startDate = route.queryParamMap.get('startDate') || null;
|
||||
const finishDate = route.queryParamMap.get('finishDate') || null;
|
||||
return this.ser.get(startDate, finishDate);
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
import {SaleAnalysisRoutingModule} from './sale-analysis-routing.module';
|
||||
|
||||
describe('SaleAnalysisRoutingModule', () => {
|
||||
let saleAnalysisRoutingModule: SaleAnalysisRoutingModule;
|
||||
|
||||
beforeEach(() => {
|
||||
saleAnalysisRoutingModule = new SaleAnalysisRoutingModule();
|
||||
});
|
||||
|
||||
it('should create an instance', () => {
|
||||
expect(saleAnalysisRoutingModule).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -1,13 +0,0 @@
|
||||
import {SaleAnalysisModule} from './sale-analysis.module';
|
||||
|
||||
describe('SaleAnalysisModule', () => {
|
||||
let saleAnalysisModule: SaleAnalysisModule;
|
||||
|
||||
beforeEach(() => {
|
||||
saleAnalysisModule = new SaleAnalysisModule();
|
||||
});
|
||||
|
||||
it('should create an instance', () => {
|
||||
expect(saleAnalysisModule).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -1,15 +0,0 @@
|
||||
import {inject, TestBed} from '@angular/core/testing';
|
||||
|
||||
import {SaleAnalysisService} from './sale-analysis.service';
|
||||
|
||||
describe('SaleAnalysisService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [SaleAnalysisService]
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([SaleAnalysisService], (service: SaleAnalysisService) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
});
|
||||
@@ -1,10 +0,0 @@
|
||||
export class SaleAnalysisItem {
|
||||
name: string;
|
||||
amount: number;
|
||||
}
|
||||
|
||||
export class SaleAnalysis {
|
||||
startDate: string;
|
||||
finishDate: string;
|
||||
amounts?: SaleAnalysisItem[];
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { DataSource } from '@angular/cdk/collections';
|
||||
import { Observable, of as observableOf } from 'rxjs';
|
||||
import { SaleReportItem } from './sale-report';
|
||||
|
||||
|
||||
export class SaleReportDatasource extends DataSource<SaleReportItem> {
|
||||
|
||||
constructor(public data: SaleReportItem[]) {
|
||||
super();
|
||||
}
|
||||
|
||||
connect(): Observable<SaleReportItem[]> {
|
||||
return observableOf(this.data);
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import {inject, TestBed} from '@angular/core/testing';
|
||||
|
||||
import {SaleReportResolver} from './sale-report-resolver.service';
|
||||
|
||||
describe('SaleReportResolver', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [SaleReportResolver]
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([SaleReportResolver], (service: SaleReportResolver) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
});
|
||||
@@ -0,0 +1,20 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { SaleReport } from './sale-report';
|
||||
import { SaleReportService } from './sale-report.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class SaleReportResolver implements Resolve<SaleReport> {
|
||||
|
||||
constructor(private ser: SaleReportService) {
|
||||
}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<SaleReport> {
|
||||
const startDate = route.queryParamMap.get('startDate') || null;
|
||||
const finishDate = route.queryParamMap.get('finishDate') || null;
|
||||
return this.ser.get(startDate, finishDate);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import {SaleReportRoutingModule} from './sale-report-routing.module';
|
||||
|
||||
describe('SaleReportRoutingModule', () => {
|
||||
let saleReportRoutingModule: SaleReportRoutingModule;
|
||||
|
||||
beforeEach(() => {
|
||||
saleReportRoutingModule = new SaleReportRoutingModule();
|
||||
});
|
||||
|
||||
it('should create an instance', () => {
|
||||
expect(saleReportRoutingModule).toBeTruthy();
|
||||
});
|
||||
});
|
||||
+9
-9
@@ -1,20 +1,20 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
import { TaxAnalysisResolver } from './tax-analysis-resolver.service';
|
||||
import { SaleReportResolver } from './sale-report-resolver.service';
|
||||
import { AuthGuard } from '../auth/auth-guard.service';
|
||||
import { TaxAnalysisComponent } from './tax-analysis.component';
|
||||
import { SaleReportComponent } from './sale-report.component';
|
||||
|
||||
const TaxAnalysisRoutes: Routes = [
|
||||
const saleReportRoutes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: TaxAnalysisComponent,
|
||||
component: SaleReportComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Tax Analysis'
|
||||
permission: 'Sale Report'
|
||||
},
|
||||
resolve: {
|
||||
info: TaxAnalysisResolver
|
||||
info: SaleReportResolver
|
||||
},
|
||||
runGuardsAndResolvers: 'always'
|
||||
}
|
||||
@@ -23,15 +23,15 @@ const TaxAnalysisRoutes: Routes = [
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
RouterModule.forChild(TaxAnalysisRoutes)
|
||||
RouterModule.forChild(saleReportRoutes)
|
||||
|
||||
],
|
||||
exports: [
|
||||
RouterModule
|
||||
],
|
||||
providers: [
|
||||
TaxAnalysisResolver
|
||||
SaleReportResolver
|
||||
]
|
||||
})
|
||||
export class TaxAnalysisRoutingModule {
|
||||
export class SaleReportRoutingModule {
|
||||
}
|
||||
File renamed without changes.
+1
-1
@@ -1,6 +1,6 @@
|
||||
<mat-card>
|
||||
<mat-card-title-group>
|
||||
<mat-card-title>Sale Analysis</mat-card-title>
|
||||
<mat-card-title>Sale Report</mat-card-title>
|
||||
<button mat-button mat-icon-button (click)="exportCsv()">
|
||||
<mat-icon>save_alt</mat-icon>
|
||||
</button>
|
||||
+6
-6
@@ -1,20 +1,20 @@
|
||||
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
|
||||
|
||||
import {TaxAnalysisComponent} from './tax-analysis.component';
|
||||
import {SaleReportComponent} from './sale-report.component';
|
||||
|
||||
describe('TaxAnalysisComponent', () => {
|
||||
let component: TaxAnalysisComponent;
|
||||
let fixture: ComponentFixture<TaxAnalysisComponent>;
|
||||
describe('SaleReportComponent', () => {
|
||||
let component: SaleReportComponent;
|
||||
let fixture: ComponentFixture<SaleReportComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [TaxAnalysisComponent]
|
||||
declarations: [SaleReportComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(TaxAnalysisComponent);
|
||||
fixture = TestBed.createComponent(SaleReportComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
+14
-20
@@ -2,19 +2,19 @@ import { Component, OnInit } from '@angular/core';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import * as moment from 'moment';
|
||||
import { SaleAnalysisDataSource } from './sale-analysis-datasource';
|
||||
import { SaleAnalysis } from './sale-analysis';
|
||||
import { SaleReportDatasource } from './sale-report-datasource';
|
||||
import { SaleReport } from './sale-report';
|
||||
import { ToCsvService } from '../shared/to-csv.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-sale-analysis',
|
||||
templateUrl: './sale-analysis.component.html',
|
||||
styleUrls: ['./sale-analysis.component.css']
|
||||
selector: 'app-sale-report',
|
||||
templateUrl: './sale-report.component.html',
|
||||
styleUrls: ['./sale-report.component.css']
|
||||
})
|
||||
export class SaleAnalysisComponent implements OnInit {
|
||||
dataSource: SaleAnalysisDataSource;
|
||||
export class SaleReportComponent implements OnInit {
|
||||
dataSource: SaleReportDatasource;
|
||||
form: FormGroup;
|
||||
info: SaleAnalysis;
|
||||
info: SaleReport;
|
||||
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
displayedColumns = ['name', 'amount'];
|
||||
@@ -32,19 +32,19 @@ export class SaleAnalysisComponent implements OnInit {
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data
|
||||
.subscribe((data: { info: SaleAnalysis }) => {
|
||||
.subscribe((data: { info: SaleReport }) => {
|
||||
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 SaleAnalysisDataSource(this.info.amounts);
|
||||
this.dataSource = new SaleReportDatasource(this.info.amounts);
|
||||
});
|
||||
}
|
||||
|
||||
show() {
|
||||
const info = this.getInfo();
|
||||
this.router.navigate(['sale-analysis'], {
|
||||
this.router.navigate(['sale-report'], {
|
||||
queryParams: {
|
||||
startDate: info.startDate,
|
||||
finishDate: info.finishDate
|
||||
@@ -59,7 +59,7 @@ export class SaleAnalysisComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
getInfo(): SaleAnalysis {
|
||||
getInfo(): SaleReport {
|
||||
const formModel = this.form.value;
|
||||
|
||||
return {
|
||||
@@ -70,19 +70,13 @@ export class SaleAnalysisComponent implements OnInit {
|
||||
|
||||
exportCsv() {
|
||||
const headers = {
|
||||
Date: 'date',
|
||||
Name: 'name',
|
||||
Type: 'type',
|
||||
Narration: 'narration',
|
||||
Debit: 'debit',
|
||||
Credit: 'credit',
|
||||
Running: 'running',
|
||||
Posted: 'posted'
|
||||
Amount: 'amount'
|
||||
};
|
||||
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', 'sale-analysis.csv');
|
||||
link.setAttribute('download', 'sale-report.csv');
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
@@ -0,0 +1,13 @@
|
||||
import {SaleReportModule} from './sale-report.module';
|
||||
|
||||
describe('SaleReportModule', () => {
|
||||
let saleReportModule: SaleReportModule;
|
||||
|
||||
beforeEach(() => {
|
||||
saleReportModule = new SaleReportModule();
|
||||
});
|
||||
|
||||
it('should create an instance', () => {
|
||||
expect(saleReportModule).toBeTruthy();
|
||||
});
|
||||
});
|
||||
+5
-5
@@ -12,8 +12,8 @@ import { MatTableModule } from '@angular/material/table';
|
||||
import { SharedModule} from '../shared/shared.module';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { CdkTableModule } from '@angular/cdk/table';
|
||||
import { TaxAnalysisRoutingModule } from './tax-analysis-routing.module';
|
||||
import { TaxAnalysisComponent } from './tax-analysis.component';
|
||||
import { SaleReportRoutingModule } from './sale-report-routing.module';
|
||||
import { SaleReportComponent } from './sale-report.component';
|
||||
import { MomentDateAdapter } from '@angular/material-moment-adapter';
|
||||
import { A11yModule } from '@angular/cdk/a11y';
|
||||
import { FlexLayoutModule } from '@angular/flex-layout';
|
||||
@@ -47,15 +47,15 @@ export const MY_FORMATS = {
|
||||
MatTableModule,
|
||||
ReactiveFormsModule,
|
||||
SharedModule,
|
||||
TaxAnalysisRoutingModule
|
||||
SaleReportRoutingModule
|
||||
],
|
||||
declarations: [
|
||||
TaxAnalysisComponent
|
||||
SaleReportComponent
|
||||
],
|
||||
providers: [
|
||||
{provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE]},
|
||||
{provide: MAT_DATE_FORMATS, useValue: MY_FORMATS},
|
||||
]
|
||||
})
|
||||
export class TaxAnalysisModule {
|
||||
export class SaleReportModule {
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import {inject, TestBed} from '@angular/core/testing';
|
||||
|
||||
import {SaleReportService} from './sale-report.service';
|
||||
|
||||
describe('SaleReportService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [SaleReportService]
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([SaleReportService], (service: SaleReportService) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
});
|
||||
+6
-6
@@ -2,25 +2,25 @@ import { Injectable } from '@angular/core';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
||||
import { TaxAnalysis } from './tax-analysis';
|
||||
import { SaleReport } from './sale-report';
|
||||
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||
|
||||
const httpOptions = {
|
||||
headers: new HttpHeaders({'Content-Type': 'application/json'})
|
||||
};
|
||||
|
||||
const url = '/v1/sale-analysis/tax';
|
||||
const serviceName = 'TaxAnalysisService';
|
||||
const url = '/v1/sale-report';
|
||||
const serviceName = 'SaleReportService';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class TaxAnalysisService {
|
||||
export class SaleReportService {
|
||||
|
||||
constructor(private http: HttpClient, private log: ErrorLoggerService) {
|
||||
}
|
||||
|
||||
get(startDate: string, finishDate): Observable<TaxAnalysis> {
|
||||
get(startDate: string, finishDate): Observable<SaleReport> {
|
||||
const options = {params: new HttpParams()};
|
||||
if (startDate !== null) {
|
||||
options.params = options.params.set('s', startDate);
|
||||
@@ -28,7 +28,7 @@ export class TaxAnalysisService {
|
||||
if (finishDate !== null) {
|
||||
options.params = options.params.set('f', finishDate);
|
||||
}
|
||||
return <Observable<TaxAnalysis>>this.http.get<TaxAnalysis>(url, options)
|
||||
return <Observable<SaleReport>>this.http.get<SaleReport>(url, options)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'get'))
|
||||
);
|
||||
@@ -0,0 +1,10 @@
|
||||
export class SaleReportItem {
|
||||
name: string;
|
||||
amount: number;
|
||||
}
|
||||
|
||||
export class SaleReport {
|
||||
startDate: string;
|
||||
finishDate: string;
|
||||
amounts?: SaleReportItem[];
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
import { DataSource } from '@angular/cdk/collections';
|
||||
import { Observable, of as observableOf } from 'rxjs';
|
||||
import { TaxAnalysisItem } from './tax-analysis';
|
||||
|
||||
|
||||
export class TaxAnalysisDataSource extends DataSource<TaxAnalysisItem> {
|
||||
|
||||
constructor(public data: TaxAnalysisItem[]) {
|
||||
super();
|
||||
}
|
||||
|
||||
connect(): Observable<TaxAnalysisItem[]> {
|
||||
return observableOf(this.data);
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
import {inject, TestBed} from '@angular/core/testing';
|
||||
|
||||
import {TaxAnalysisResolver} from './tax-analysis-resolver.service';
|
||||
|
||||
describe('TaxAnalysisResolver', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [TaxAnalysisResolver]
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([TaxAnalysisResolver], (service: TaxAnalysisResolver) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
});
|
||||
@@ -1,13 +0,0 @@
|
||||
import {TaxAnalysisRoutingModule} from './tax-analysis-routing.module';
|
||||
|
||||
describe('TaxAnalysisRoutingModule', () => {
|
||||
let taxAnalysisRoutingModule: TaxAnalysisRoutingModule;
|
||||
|
||||
beforeEach(() => {
|
||||
taxAnalysisRoutingModule = new TaxAnalysisRoutingModule();
|
||||
});
|
||||
|
||||
it('should create an instance', () => {
|
||||
expect(taxAnalysisRoutingModule).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -1,13 +0,0 @@
|
||||
import {TaxAnalysisModule} from './tax-analysis.module';
|
||||
|
||||
describe('TaxAnalysisModule', () => {
|
||||
let taxAnalysisModule: TaxAnalysisModule;
|
||||
|
||||
beforeEach(() => {
|
||||
taxAnalysisModule = new TaxAnalysisModule();
|
||||
});
|
||||
|
||||
it('should create an instance', () => {
|
||||
expect(taxAnalysisModule).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -1,15 +0,0 @@
|
||||
import {inject, TestBed} from '@angular/core/testing';
|
||||
|
||||
import {TaxAnalysisService} from './tax-analysis.service';
|
||||
|
||||
describe('TaxAnalysisService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [TaxAnalysisService]
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([TaxAnalysisService], (service: TaxAnalysisService) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
});
|
||||
@@ -0,0 +1,18 @@
|
||||
import { DataSource } from '@angular/cdk/collections';
|
||||
import { Observable, of as observableOf } from 'rxjs';
|
||||
import { TaxReportItem } from './tax-report';
|
||||
|
||||
|
||||
export class TaxReportDatasource extends DataSource<TaxReportItem> {
|
||||
|
||||
constructor(public data: TaxReportItem[]) {
|
||||
super();
|
||||
}
|
||||
|
||||
connect(): Observable<TaxReportItem[]> {
|
||||
return observableOf(this.data);
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import {inject, TestBed} from '@angular/core/testing';
|
||||
|
||||
import {TaxReportResolver} from './tax-report-resolver.service';
|
||||
|
||||
describe('TaxReportResolver', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [TaxReportResolver]
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([TaxReportResolver], (service: TaxReportResolver) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
});
|
||||
+5
-5
@@ -1,18 +1,18 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {ActivatedRouteSnapshot, Resolve, RouterStateSnapshot} from '@angular/router';
|
||||
import {Observable} from 'rxjs/internal/Observable';
|
||||
import {TaxAnalysis} from './tax-analysis';
|
||||
import {TaxAnalysisService} from './tax-analysis.service';
|
||||
import {TaxReport} from './tax-report';
|
||||
import {TaxReportService} from './tax-report.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class TaxAnalysisResolver implements Resolve<TaxAnalysis> {
|
||||
export class TaxReportResolver implements Resolve<TaxReport> {
|
||||
|
||||
constructor(private ser: TaxAnalysisService) {
|
||||
constructor(private ser: TaxReportService) {
|
||||
}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<TaxAnalysis> {
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<TaxReport> {
|
||||
const startDate = route.queryParamMap.get('startDate') || null;
|
||||
const finishDate = route.queryParamMap.get('finishDate') || null;
|
||||
return this.ser.get(startDate, finishDate);
|
||||
@@ -0,0 +1,13 @@
|
||||
import {TaxReportRoutingModule} from './tax-report-routing.module';
|
||||
|
||||
describe('TaxReportRoutingModule', () => {
|
||||
let taxReportRoutingModule: TaxReportRoutingModule;
|
||||
|
||||
beforeEach(() => {
|
||||
taxReportRoutingModule = new TaxReportRoutingModule();
|
||||
});
|
||||
|
||||
it('should create an instance', () => {
|
||||
expect(taxReportRoutingModule).toBeTruthy();
|
||||
});
|
||||
});
|
||||
+9
-9
@@ -1,20 +1,20 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
import { SaleAnalysisResolver } from './sale-analysis-resolver.service';
|
||||
import { TaxReportResolver } from './tax-report-resolver.service';
|
||||
import { AuthGuard } from '../auth/auth-guard.service';
|
||||
import { SaleAnalysisComponent } from './sale-analysis.component';
|
||||
import { TaxReportComponent } from './tax-report.component';
|
||||
|
||||
const SaleAnalysisRoutes: Routes = [
|
||||
const taxReportRoutes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: SaleAnalysisComponent,
|
||||
component: TaxReportComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Sales Analysis'
|
||||
permission: 'Tax Report'
|
||||
},
|
||||
resolve: {
|
||||
info: SaleAnalysisResolver
|
||||
info: TaxReportResolver
|
||||
},
|
||||
runGuardsAndResolvers: 'always'
|
||||
}
|
||||
@@ -23,15 +23,15 @@ const SaleAnalysisRoutes: Routes = [
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
RouterModule.forChild(SaleAnalysisRoutes)
|
||||
RouterModule.forChild(taxReportRoutes)
|
||||
|
||||
],
|
||||
exports: [
|
||||
RouterModule
|
||||
],
|
||||
providers: [
|
||||
SaleAnalysisResolver
|
||||
TaxReportResolver
|
||||
]
|
||||
})
|
||||
export class SaleAnalysisRoutingModule {
|
||||
export class TaxReportRoutingModule {
|
||||
}
|
||||
File renamed without changes.
+1
-1
@@ -1,6 +1,6 @@
|
||||
<mat-card>
|
||||
<mat-card-title-group>
|
||||
<mat-card-title>Tax Analysis</mat-card-title>
|
||||
<mat-card-title>Tax Report</mat-card-title>
|
||||
<button mat-button mat-icon-button (click)="exportCsv()">
|
||||
<mat-icon>save_alt</mat-icon>
|
||||
</button>
|
||||
+6
-6
@@ -1,20 +1,20 @@
|
||||
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
|
||||
|
||||
import {SaleAnalysisComponent} from './sale-analysis.component';
|
||||
import {TaxReportComponent} from './tax-report.component';
|
||||
|
||||
describe('SaleAnalysisComponent', () => {
|
||||
let component: SaleAnalysisComponent;
|
||||
let fixture: ComponentFixture<SaleAnalysisComponent>;
|
||||
describe('TaxReportComponent', () => {
|
||||
let component: TaxReportComponent;
|
||||
let fixture: ComponentFixture<TaxReportComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [SaleAnalysisComponent]
|
||||
declarations: [TaxReportComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(SaleAnalysisComponent);
|
||||
fixture = TestBed.createComponent(TaxReportComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
+14
-20
@@ -2,19 +2,19 @@ import { Component, OnInit } from '@angular/core';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import * as moment from 'moment';
|
||||
import { TaxAnalysisDataSource } from './tax-analysis-datasource';
|
||||
import { TaxAnalysis } from './tax-analysis';
|
||||
import { TaxReportDatasource } from './tax-report-datasource';
|
||||
import { TaxReport } from './tax-report';
|
||||
import { ToCsvService } from '../shared/to-csv.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-tax-analysis',
|
||||
templateUrl: './tax-analysis.component.html',
|
||||
styleUrls: ['./tax-analysis.component.css']
|
||||
selector: 'app-tax-report',
|
||||
templateUrl: './tax-report.component.html',
|
||||
styleUrls: ['./tax-report.component.css']
|
||||
})
|
||||
export class TaxAnalysisComponent implements OnInit {
|
||||
dataSource: TaxAnalysisDataSource;
|
||||
export class TaxReportComponent implements OnInit {
|
||||
dataSource: TaxReportDatasource;
|
||||
form: FormGroup;
|
||||
info: TaxAnalysis;
|
||||
info: TaxReport;
|
||||
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
displayedColumns = ['name', 'taxRate', 'saleAmount', 'taxAmount'];
|
||||
@@ -32,19 +32,19 @@ export class TaxAnalysisComponent implements OnInit {
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data
|
||||
.subscribe((data: { info: TaxAnalysis }) => {
|
||||
.subscribe((data: { info: TaxReport }) => {
|
||||
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 TaxAnalysisDataSource(this.info.amounts);
|
||||
this.dataSource = new TaxReportDatasource(this.info.amounts);
|
||||
});
|
||||
}
|
||||
|
||||
show() {
|
||||
const info = this.getInfo();
|
||||
this.router.navigate(['tax-analysis'], {
|
||||
this.router.navigate(['tax-report'], {
|
||||
queryParams: {
|
||||
startDate: info.startDate,
|
||||
finishDate: info.finishDate
|
||||
@@ -59,7 +59,7 @@ export class TaxAnalysisComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
getInfo(): TaxAnalysis {
|
||||
getInfo(): TaxReport {
|
||||
const formModel = this.form.value;
|
||||
|
||||
return {
|
||||
@@ -70,19 +70,13 @@ export class TaxAnalysisComponent implements OnInit {
|
||||
|
||||
exportCsv() {
|
||||
const headers = {
|
||||
Date: 'date',
|
||||
Name: 'name',
|
||||
Type: 'type',
|
||||
Narration: 'narration',
|
||||
Debit: 'debit',
|
||||
Credit: 'credit',
|
||||
Running: 'running',
|
||||
Posted: 'posted'
|
||||
Amount: 'amount'
|
||||
};
|
||||
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', 'tax-analysis.csv');
|
||||
link.setAttribute('download', 'tax-report.csv');
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
@@ -0,0 +1,13 @@
|
||||
import {TaxReportModule} from './tax-report.module';
|
||||
|
||||
describe('TaxReportModule', () => {
|
||||
let taxReportModule: TaxReportModule;
|
||||
|
||||
beforeEach(() => {
|
||||
taxReportModule = new TaxReportModule();
|
||||
});
|
||||
|
||||
it('should create an instance', () => {
|
||||
expect(taxReportModule).toBeTruthy();
|
||||
});
|
||||
});
|
||||
+5
-5
@@ -12,8 +12,8 @@ import { MatTableModule } from '@angular/material/table';
|
||||
import { SharedModule} from '../shared/shared.module';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { CdkTableModule } from '@angular/cdk/table';
|
||||
import { SaleAnalysisRoutingModule } from './sale-analysis-routing.module';
|
||||
import { SaleAnalysisComponent } from './sale-analysis.component';
|
||||
import { TaxReportRoutingModule } from './tax-report-routing.module';
|
||||
import { TaxReportComponent } from './tax-report.component';
|
||||
import { MomentDateAdapter } from '@angular/material-moment-adapter';
|
||||
import { A11yModule } from '@angular/cdk/a11y';
|
||||
import { FlexLayoutModule } from '@angular/flex-layout';
|
||||
@@ -47,15 +47,15 @@ export const MY_FORMATS = {
|
||||
MatTableModule,
|
||||
ReactiveFormsModule,
|
||||
SharedModule,
|
||||
SaleAnalysisRoutingModule
|
||||
TaxReportRoutingModule
|
||||
],
|
||||
declarations: [
|
||||
SaleAnalysisComponent
|
||||
TaxReportComponent
|
||||
],
|
||||
providers: [
|
||||
{provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE]},
|
||||
{provide: MAT_DATE_FORMATS, useValue: MY_FORMATS},
|
||||
]
|
||||
})
|
||||
export class SaleAnalysisModule {
|
||||
export class TaxReportModule {
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import {inject, TestBed} from '@angular/core/testing';
|
||||
|
||||
import {TaxReportService} from './tax-report.service';
|
||||
|
||||
describe('TaxReportService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [TaxReportService]
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([TaxReportService], (service: TaxReportService) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
});
|
||||
+6
-6
@@ -2,25 +2,25 @@ import { Injectable } from '@angular/core';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
||||
import { SaleAnalysis } from './sale-analysis';
|
||||
import { TaxReport } from './tax-report';
|
||||
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||
|
||||
const httpOptions = {
|
||||
headers: new HttpHeaders({'Content-Type': 'application/json'})
|
||||
};
|
||||
|
||||
const url = '/v1/sale-analysis';
|
||||
const serviceName = 'SaleAnalysisService';
|
||||
const url = '/v1/tax-report';
|
||||
const serviceName = 'TaxReportService';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class SaleAnalysisService {
|
||||
export class TaxReportService {
|
||||
|
||||
constructor(private http: HttpClient, private log: ErrorLoggerService) {
|
||||
}
|
||||
|
||||
get(startDate: string, finishDate): Observable<SaleAnalysis> {
|
||||
get(startDate: string, finishDate): Observable<TaxReport> {
|
||||
const options = {params: new HttpParams()};
|
||||
if (startDate !== null) {
|
||||
options.params = options.params.set('s', startDate);
|
||||
@@ -28,7 +28,7 @@ export class SaleAnalysisService {
|
||||
if (finishDate !== null) {
|
||||
options.params = options.params.set('f', finishDate);
|
||||
}
|
||||
return <Observable<SaleAnalysis>>this.http.get<SaleAnalysis>(url, options)
|
||||
return <Observable<TaxReport>>this.http.get<TaxReport>(url, options)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'get'))
|
||||
);
|
||||
+3
-3
@@ -1,12 +1,12 @@
|
||||
export class TaxAnalysisItem {
|
||||
export class TaxReportItem {
|
||||
name: string;
|
||||
taxRate: number;
|
||||
saleAmount: number;
|
||||
amount: number;
|
||||
}
|
||||
|
||||
export class TaxAnalysis {
|
||||
export class TaxReport {
|
||||
startDate: string;
|
||||
finishDate: string;
|
||||
amounts?: TaxAnalysisItem[];
|
||||
amounts?: TaxReportItem[];
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import {UserListComponent} from './user-list/user-list.component';
|
||||
import {UserDetailComponent} from './user-detail/user-detail.component';
|
||||
import {AuthGuard} from '../auth/auth-guard.service';
|
||||
|
||||
const userRoutes: Routes = [
|
||||
const usersRoutes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: UserListComponent,
|
||||
@@ -43,7 +43,7 @@ const userRoutes: Routes = [
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
RouterModule.forChild(userRoutes)
|
||||
RouterModule.forChild(usersRoutes)
|
||||
|
||||
],
|
||||
exports: [
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
import { DataSource } from '@angular/cdk/collections';
|
||||
import { Observable, of as observableOf } from 'rxjs';
|
||||
import { VoidsReprintsReportItem } from './voids-reprints-report';
|
||||
|
||||
|
||||
export class VoidsReprintsReportDataSource extends DataSource<VoidsReprintsReportItem> {
|
||||
|
||||
constructor(public data: VoidsReprintsReportItem[]) {
|
||||
super();
|
||||
}
|
||||
|
||||
connect(): Observable<VoidsReprintsReportItem[]> {
|
||||
return observableOf(this.data);
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
import {inject, TestBed} from '@angular/core/testing';
|
||||
|
||||
import {VoidsReprintsReportResolver} from './voids-reprints-report-resolver.service';
|
||||
|
||||
describe('VoidsReprintsReportResolver', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [VoidsReprintsReportResolver]
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([VoidsReprintsReportResolver], (service: VoidsReprintsReportResolver) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
});
|
||||
@@ -1,20 +0,0 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {ActivatedRouteSnapshot, Resolve, RouterStateSnapshot} from '@angular/router';
|
||||
import {Observable} from 'rxjs/internal/Observable';
|
||||
import {VoidsReprintsReport} from './voids-reprints-report';
|
||||
import {VoidsReprintsReportService} from './voids-reprints-report.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class VoidsReprintsReportResolver implements Resolve<VoidsReprintsReport> {
|
||||
|
||||
constructor(private ser: VoidsReprintsReportService) {
|
||||
}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<VoidsReprintsReport> {
|
||||
const startDate = route.queryParamMap.get('startDate') || null;
|
||||
const finishDate = route.queryParamMap.get('finishDate') || null;
|
||||
return this.ser.get(startDate, finishDate);
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
import {VoidsReprintsReportRoutingModule} from './voids-reprints-report-routing.module';
|
||||
|
||||
describe('VoidsReprintsReportRoutingModule', () => {
|
||||
let pvoidsReprintsReportRoutingModule: VoidsReprintsReportRoutingModule;
|
||||
|
||||
beforeEach(() => {
|
||||
pvoidsReprintsReportRoutingModule = new VoidsReprintsReportRoutingModule();
|
||||
});
|
||||
|
||||
it('should create an instance', () => {
|
||||
expect(pvoidsReprintsReportRoutingModule).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -1,37 +0,0 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
import { VoidsReprintsReportResolver } from './voids-reprints-report-resolver.service';
|
||||
import { AuthGuard } from '../auth/auth-guard.service';
|
||||
import { VoidsReprintsReportComponent } from './voids-reprints-report.component';
|
||||
|
||||
const VoidsReprintsReportRoutes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: VoidsReprintsReportComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Void or Reprinted Bill Report' // rename to Void and Reprinted Bill Report
|
||||
},
|
||||
resolve: {
|
||||
info: VoidsReprintsReportResolver
|
||||
},
|
||||
runGuardsAndResolvers: 'always'
|
||||
}
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
RouterModule.forChild(VoidsReprintsReportRoutes)
|
||||
|
||||
],
|
||||
exports: [
|
||||
RouterModule
|
||||
],
|
||||
providers: [
|
||||
VoidsReprintsReportResolver
|
||||
]
|
||||
})
|
||||
export class VoidsReprintsReportRoutingModule {
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
.right {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
<mat-card>
|
||||
<mat-card-title-group>
|
||||
<mat-card-title>Voids and Reprints Report</mat-card-title>
|
||||
<button mat-button mat-icon-button (click)="exportCsv()">
|
||||
<mat-icon>save_alt</mat-icon>
|
||||
</button>
|
||||
</mat-card-title-group>
|
||||
<mat-card-content>
|
||||
<form [formGroup]="form" fxLayout="column">
|
||||
<div fxLayout="row" fxLayout.lt-md="column" fxLayoutGap="20px" fxLayoutGap.lt-md="0px"
|
||||
fxLayoutAlign="space-around start">
|
||||
<mat-form-field fxFlex="40">
|
||||
<input matInput [matDatepicker]="startDate" (focus)="startDate.open()" placeholder="Start Date"
|
||||
formControlName="startDate" autocomplete="off">
|
||||
<mat-datepicker-toggle matSuffix [for]="startDate"></mat-datepicker-toggle>
|
||||
<mat-datepicker #startDate></mat-datepicker>
|
||||
</mat-form-field>
|
||||
<mat-form-field fxFlex="40">
|
||||
<input matInput [matDatepicker]="finishDate" (focus)="finishDate.open()" placeholder="Finish Date"
|
||||
formControlName="finishDate" autocomplete="off">
|
||||
<mat-datepicker-toggle matSuffix [for]="finishDate"></mat-datepicker-toggle>
|
||||
<mat-datepicker #finishDate></mat-datepicker>
|
||||
</mat-form-field>
|
||||
<button fxFlex="20" mat-raised-button color="primary" (click)="show()">Show</button>
|
||||
</div>
|
||||
</form>
|
||||
<mat-table #table [dataSource]="dataSource" aria-label="Elements">
|
||||
|
||||
<!-- Date Column -->
|
||||
<ng-container matColumnDef="date">
|
||||
<mat-header-cell *matHeaderCellDef>Time</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{row.date}}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Bill ID Column -->
|
||||
<ng-container matColumnDef="billId">
|
||||
<mat-header-cell *matHeaderCellDef class="right">Bill ID</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row" class="right">{{row.billId}}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Amount Column -->
|
||||
<ng-container matColumnDef="amount">
|
||||
<mat-header-cell *matHeaderCellDef class="right">Amount</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row" class="right">{{row.amount | number:'1.2-2'}}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Settlement Column -->
|
||||
<ng-container matColumnDef="settlement">
|
||||
<mat-header-cell *matHeaderCellDef class="right">Settlement</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row" class="right">{{row.settlement}}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
|
||||
<mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row>
|
||||
</mat-table>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
@@ -1,25 +0,0 @@
|
||||
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
|
||||
|
||||
import {VoidsReprintsReportComponent} from './voids-reprints-report.component';
|
||||
|
||||
describe('VoidsReprintsReportComponent', () => {
|
||||
let component: VoidsReprintsReportComponent;
|
||||
let fixture: ComponentFixture<VoidsReprintsReportComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [VoidsReprintsReportComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(VoidsReprintsReportComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -1,90 +0,0 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import * as moment from 'moment';
|
||||
import { VoidsReprintsReportDataSource } from './voids-reprints-report-datasource';
|
||||
import { VoidsReprintsReport } from './voids-reprints-report';
|
||||
import { ToCsvService } from '../shared/to-csv.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-voids-reprints-report',
|
||||
templateUrl: './voids-reprints-report.component.html',
|
||||
styleUrls: ['./voids-reprints-report.component.css']
|
||||
})
|
||||
export class VoidsReprintsReportComponent implements OnInit {
|
||||
dataSource: VoidsReprintsReportDataSource;
|
||||
form: FormGroup;
|
||||
info: VoidsReprintsReport;
|
||||
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
displayedColumns = ['date', 'billId', 'amount', 'settlement'];
|
||||
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private fb: FormBuilder,
|
||||
private toCsv: ToCsvService
|
||||
) {
|
||||
this.createForm();
|
||||
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data
|
||||
.subscribe((data: { info: VoidsReprintsReport }) => {
|
||||
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 VoidsReprintsReportDataSource(this.info.amounts);
|
||||
});
|
||||
}
|
||||
|
||||
show() {
|
||||
const info = this.getInfo();
|
||||
this.router.navigate(['voids-reprints-report'], {
|
||||
queryParams: {
|
||||
startDate: info.startDate,
|
||||
finishDate: info.finishDate
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
createForm() {
|
||||
this.form = this.fb.group({
|
||||
startDate: '',
|
||||
finishDate: ''
|
||||
});
|
||||
}
|
||||
|
||||
getInfo(): VoidsReprintsReport {
|
||||
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', 'voids-reprints-report.csv');
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
import {VoidsReprintsReportModule} from './voids-reprints-report.module';
|
||||
|
||||
describe('VoidsReprintsReportModule', () => {
|
||||
let pvoidsReprintsReportModule: VoidsReprintsReportModule;
|
||||
|
||||
beforeEach(() => {
|
||||
pvoidsReprintsReportModule = new VoidsReprintsReportModule();
|
||||
});
|
||||
|
||||
it('should create an instance', () => {
|
||||
expect(pvoidsReprintsReportModule).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -1,61 +0,0 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { MatAutocompleteModule } from '@angular/material/autocomplete';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE, MatNativeDateModule } from '@angular/material/core';
|
||||
import { MatDatepickerModule } from '@angular/material/datepicker';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { MatTableModule } from '@angular/material/table';
|
||||
import { SharedModule} from '../shared/shared.module';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { CdkTableModule } from '@angular/cdk/table';
|
||||
import { VoidsReprintsReportRoutingModule } from './voids-reprints-report-routing.module';
|
||||
import { VoidsReprintsReportComponent } from './voids-reprints-report.component';
|
||||
import { MomentDateAdapter } from '@angular/material-moment-adapter';
|
||||
import { A11yModule } from '@angular/cdk/a11y';
|
||||
import { FlexLayoutModule } from '@angular/flex-layout';
|
||||
|
||||
export const MY_FORMATS = {
|
||||
parse: {
|
||||
dateInput: 'DD-MMM-YYYY',
|
||||
},
|
||||
display: {
|
||||
dateInput: 'DD-MMM-YYYY',
|
||||
monthYearLabel: 'MMM YYYY',
|
||||
dateA11yLabel: 'DD-MMM-YYYY',
|
||||
monthYearA11yLabel: 'MMM YYYY',
|
||||
},
|
||||
};
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
A11yModule,
|
||||
CommonModule,
|
||||
CdkTableModule,
|
||||
FlexLayoutModule,
|
||||
MatAutocompleteModule,
|
||||
MatButtonModule,
|
||||
MatCardModule,
|
||||
MatDatepickerModule,
|
||||
MatFormFieldModule,
|
||||
MatIconModule,
|
||||
MatInputModule,
|
||||
MatNativeDateModule,
|
||||
MatTableModule,
|
||||
ReactiveFormsModule,
|
||||
SharedModule,
|
||||
VoidsReprintsReportRoutingModule
|
||||
],
|
||||
declarations: [
|
||||
VoidsReprintsReportComponent
|
||||
],
|
||||
providers: [
|
||||
{provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE]},
|
||||
{provide: MAT_DATE_FORMATS, useValue: MY_FORMATS},
|
||||
]
|
||||
})
|
||||
export class VoidsReprintsReportModule {
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
import {inject, TestBed} from '@angular/core/testing';
|
||||
|
||||
import {VoidsReprintsReportService} from './voids-reprints-report.service';
|
||||
|
||||
describe('VoidsReprintsReportService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [VoidsReprintsReportService]
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([VoidsReprintsReportService], (service: VoidsReprintsReportService) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
});
|
||||
@@ -1,36 +0,0 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
||||
import { VoidsReprintsReport } from './voids-reprints-report';
|
||||
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||
|
||||
const httpOptions = {
|
||||
headers: new HttpHeaders({'Content-Type': 'application/json'})
|
||||
};
|
||||
|
||||
const url = '/v1/voids-reprints-report';
|
||||
const serviceName = 'VoidsReprintsReportService';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class VoidsReprintsReportService {
|
||||
|
||||
constructor(private http: HttpClient, private log: ErrorLoggerService) {
|
||||
}
|
||||
|
||||
get(startDate: string, finishDate): Observable<VoidsReprintsReport> {
|
||||
const options = {params: new HttpParams()};
|
||||
if (startDate !== null) {
|
||||
options.params = options.params.set('s', startDate);
|
||||
}
|
||||
if (finishDate !== null) {
|
||||
options.params = options.params.set('f', finishDate);
|
||||
}
|
||||
return <Observable<VoidsReprintsReport>>this.http.get<VoidsReprintsReport>(url, options)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'get'))
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
export class VoidsReprintsReportItem {
|
||||
date: string;
|
||||
billId: string;
|
||||
amount: number;
|
||||
settlement: string;
|
||||
}
|
||||
|
||||
export class VoidsReprintsReport {
|
||||
startDate: string;
|
||||
finishDate: string;
|
||||
amounts?: VoidsReprintsReportItem[];
|
||||
}
|
||||
Reference in new issue
Block a user