Bill Settlement Report Done (Bill Details)
TODO: Rename Bill Details Permission to Bill Settlement Report
This commit is contained in:
@ -363,6 +363,7 @@ def includeme(config):
|
|||||||
config.add_route("v1_sale_analysis", "/v1/sale-analysis")
|
config.add_route("v1_sale_analysis", "/v1/sale-analysis")
|
||||||
|
|
||||||
config.add_route("v1_product_sale_report", "/v1/product-sale-report")
|
config.add_route("v1_product_sale_report", "/v1/product-sale-report")
|
||||||
|
config.add_route("v1_bill_settlement_report", "/v1/bill-settlement-report")
|
||||||
# Done till here
|
# Done till here
|
||||||
|
|
||||||
config.add_route("customer", "/Customer.json")
|
config.add_route("customer", "/Customer.json")
|
||||||
@ -402,6 +403,5 @@ def includeme(config):
|
|||||||
# config.add_route('customer_id', '/Customer/{id}.json')
|
# config.add_route('customer_id', '/Customer/{id}.json')
|
||||||
|
|
||||||
config.add_route("beer_consumption", "/BeerConsumption.json")
|
config.add_route("beer_consumption", "/BeerConsumption.json")
|
||||||
config.add_route("bill_details", "/BillDetails.json")
|
|
||||||
|
|
||||||
config.add_static_view("", "barker:static")
|
config.add_static_view("", "barker:static")
|
||||||
|
|||||||
@ -1,53 +0,0 @@
|
|||||||
import datetime
|
|
||||||
|
|
||||||
from pyramid.httpexceptions import HTTPForbidden
|
|
||||||
from pyramid.view import view_config
|
|
||||||
from sqlalchemy.orm import joinedload
|
|
||||||
|
|
||||||
from barker.models import Settlement, SettleOption, Voucher
|
|
||||||
|
|
||||||
|
|
||||||
@view_config(request_method='GET', route_name='bill_details', renderer='json', permission='Bill Details',
|
|
||||||
request_param=('s', 'f'))
|
|
||||||
def bill_details(request):
|
|
||||||
start_date = datetime.datetime.strptime(request.GET['s'], '%d-%b-%Y %H:%M')
|
|
||||||
finish_date = datetime.datetime.strptime(request.GET['f'], '%d-%b-%Y %H:%M')
|
|
||||||
|
|
||||||
if (datetime.date.today() - start_date.date()).days > 5 and 'Accounts Audit' not in request.effective_principals:
|
|
||||||
raise HTTPForbidden("Accounts Audit")
|
|
||||||
|
|
||||||
# TODO: Should be left outer join incase some bill is missing the settlements
|
|
||||||
vouchers = request.dbsession.query(
|
|
||||||
Voucher
|
|
||||||
).options(
|
|
||||||
joinedload(Voucher.settlements, innerjoin=True).joinedload(Settlement.settle_option, innerjoin=True),
|
|
||||||
joinedload(Voucher.customer, innerjoin=True)
|
|
||||||
).filter(
|
|
||||||
Voucher.date >= start_date,
|
|
||||||
Voucher.date <= finish_date
|
|
||||||
).order_by(
|
|
||||||
Voucher.voucher_type
|
|
||||||
).order_by(
|
|
||||||
Voucher.bill_id
|
|
||||||
).all()
|
|
||||||
|
|
||||||
report = []
|
|
||||||
for item in vouchers:
|
|
||||||
if item.is_void:
|
|
||||||
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(next(
|
|
||||||
s.amount for s in item.settlements if s.settled == SettleOption.AMOUNT()
|
|
||||||
) * -1, 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
|
|
||||||
70
barker/views/reports/bill_settlement_report.py
Normal file
70
barker/views/reports/bill_settlement_report.py
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
|
from pyramid.view import view_config
|
||||||
|
|
||||||
|
from barker.models import Settlement, SettleOption, Voucher
|
||||||
|
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_bill_settlement_report",
|
||||||
|
renderer="json",
|
||||||
|
permission="Bill Details",
|
||||||
|
)
|
||||||
|
def bill_details(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")
|
||||||
|
|
||||||
|
vouchers = (
|
||||||
|
request.dbsession.query(Voucher)
|
||||||
|
.join(Voucher.settlements)
|
||||||
|
.join(Settlement.settle_option)
|
||||||
|
.filter(Voucher.date >= start_date, Voucher.date <= finish_date)
|
||||||
|
.order_by(Voucher.voucher_type)
|
||||||
|
.order_by(Voucher.bill_id)
|
||||||
|
.all()
|
||||||
|
)
|
||||||
|
|
||||||
|
report = []
|
||||||
|
for item in vouchers:
|
||||||
|
if item.is_void:
|
||||||
|
amount = (
|
||||||
|
next(
|
||||||
|
s.amount
|
||||||
|
for s in item.settlements
|
||||||
|
if s.settled == SettleOption.AMOUNT()
|
||||||
|
)
|
||||||
|
* -1
|
||||||
|
)
|
||||||
|
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),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
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 {
|
||||||
|
"startDate": start_date.date().strftime("%d-%b-%Y"),
|
||||||
|
"finishDate": (finish_date - timedelta(days=1)).date().strftime("%d-%b-%Y"),
|
||||||
|
"amounts": report,
|
||||||
|
}
|
||||||
@ -5,6 +5,10 @@ import {LogoutComponent} from './auth/logout/logout.component';
|
|||||||
import {HomeComponent} from './home/home.component';
|
import {HomeComponent} from './home/home.component';
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
|
{
|
||||||
|
path: 'bill-settlement-report',
|
||||||
|
loadChildren: () => import('./bill-settlement-report/bill-settlement-report.module').then(mod => mod.BillSettlementReportModule)
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: 'checkout',
|
path: 'checkout',
|
||||||
loadChildren: () => import('./cashier-checkout/cashier-checkout.module').then(mod => mod.CashierCheckoutModule)
|
loadChildren: () => import('./cashier-checkout/cashier-checkout.module').then(mod => mod.CashierCheckoutModule)
|
||||||
|
|||||||
@ -0,0 +1,18 @@
|
|||||||
|
import { DataSource } from '@angular/cdk/collections';
|
||||||
|
import { Observable, of as observableOf } from 'rxjs';
|
||||||
|
import { BillSettlementReportItem } from './bill-settlement-report';
|
||||||
|
|
||||||
|
|
||||||
|
export class BillSettlementReportDataSource extends DataSource<BillSettlementReportItem> {
|
||||||
|
|
||||||
|
constructor(public data: BillSettlementReportItem[]) {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
connect(): Observable<BillSettlementReportItem[]> {
|
||||||
|
return observableOf(this.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
disconnect() {
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
import {inject, TestBed} from '@angular/core/testing';
|
||||||
|
|
||||||
|
import {BillSettlementReportResolver} from './bill-settlement-report-resolver.service';
|
||||||
|
|
||||||
|
describe('BillSettlementReportResolver', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
providers: [BillSettlementReportResolver]
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be created', inject([BillSettlementReportResolver], (service: BillSettlementReportResolver) => {
|
||||||
|
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 {BillSettlementReport} from './bill-settlement-report';
|
||||||
|
import {BillSettlementReportService} from './bill-settlement-report.service';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class BillSettlementReportResolver implements Resolve<BillSettlementReport> {
|
||||||
|
|
||||||
|
constructor(private ser: BillSettlementReportService) {
|
||||||
|
}
|
||||||
|
|
||||||
|
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<BillSettlementReport> {
|
||||||
|
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 {BillSettlementReportRoutingModule} from './bill-settlement-report-routing.module';
|
||||||
|
|
||||||
|
describe('BillSettlementReportRoutingModule', () => {
|
||||||
|
let pbillSettlementReportRoutingModule: BillSettlementReportRoutingModule;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
pbillSettlementReportRoutingModule = new BillSettlementReportRoutingModule();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create an instance', () => {
|
||||||
|
expect(pbillSettlementReportRoutingModule).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,37 @@
|
|||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { RouterModule, Routes } from '@angular/router';
|
||||||
|
import { BillSettlementReportResolver } from './bill-settlement-report-resolver.service';
|
||||||
|
import { AuthGuard } from '../auth/auth-guard.service';
|
||||||
|
import { BillSettlementReportComponent } from './bill-settlement-report.component';
|
||||||
|
|
||||||
|
const BillSettlementReportRoutes: Routes = [
|
||||||
|
{
|
||||||
|
path: '',
|
||||||
|
component: BillSettlementReportComponent,
|
||||||
|
canActivate: [AuthGuard],
|
||||||
|
data: {
|
||||||
|
permission: 'Bill Details' // rename to Bill Settlement Report
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
info: BillSettlementReportResolver
|
||||||
|
},
|
||||||
|
runGuardsAndResolvers: 'always'
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [
|
||||||
|
CommonModule,
|
||||||
|
RouterModule.forChild(BillSettlementReportRoutes)
|
||||||
|
|
||||||
|
],
|
||||||
|
exports: [
|
||||||
|
RouterModule
|
||||||
|
],
|
||||||
|
providers: [
|
||||||
|
BillSettlementReportResolver
|
||||||
|
]
|
||||||
|
})
|
||||||
|
export class BillSettlementReportRoutingModule {
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
.right {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
@ -0,0 +1,57 @@
|
|||||||
|
<mat-card>
|
||||||
|
<mat-card-title-group>
|
||||||
|
<mat-card-title>Bill Settlement 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>
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
|
||||||
|
|
||||||
|
import {BillSettlementReportComponent} from './bill-settlement-report.component';
|
||||||
|
|
||||||
|
describe('BillSettlementReportComponent', () => {
|
||||||
|
let component: BillSettlementReportComponent;
|
||||||
|
let fixture: ComponentFixture<BillSettlementReportComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [BillSettlementReportComponent]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(BillSettlementReportComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,90 @@
|
|||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||||
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
|
import * as moment from 'moment';
|
||||||
|
import { BillSettlementReportDataSource } from './bill-settlement-report-datasource';
|
||||||
|
import { BillSettlementReport } from './bill-settlement-report';
|
||||||
|
import { ToCsvService } from '../shared/to-csv.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-bill-settlement-report',
|
||||||
|
templateUrl: './bill-settlement-report.component.html',
|
||||||
|
styleUrls: ['./bill-settlement-report.component.css']
|
||||||
|
})
|
||||||
|
export class BillSettlementReportComponent implements OnInit {
|
||||||
|
dataSource: BillSettlementReportDataSource;
|
||||||
|
form: FormGroup;
|
||||||
|
info: BillSettlementReport;
|
||||||
|
|
||||||
|
/** 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: BillSettlementReport }) => {
|
||||||
|
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 BillSettlementReportDataSource(this.info.amounts);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
show() {
|
||||||
|
const info = this.getInfo();
|
||||||
|
this.router.navigate(['bill-settlement-report'], {
|
||||||
|
queryParams: {
|
||||||
|
startDate: info.startDate,
|
||||||
|
finishDate: info.finishDate
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
createForm() {
|
||||||
|
this.form = this.fb.group({
|
||||||
|
startDate: '',
|
||||||
|
finishDate: ''
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getInfo(): BillSettlementReport {
|
||||||
|
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', 'bill-settlement-report.csv');
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
document.body.removeChild(link);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
import {BillSettlementReportModule} from './bill-settlement-report.module';
|
||||||
|
|
||||||
|
describe('BillSettlementReportModule', () => {
|
||||||
|
let pbillSettlementReportModule: BillSettlementReportModule;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
pbillSettlementReportModule = new BillSettlementReportModule();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create an instance', () => {
|
||||||
|
expect(pbillSettlementReportModule).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,61 @@
|
|||||||
|
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 { BillSettlementReportRoutingModule } from './bill-settlement-report-routing.module';
|
||||||
|
import { BillSettlementReportComponent } from './bill-settlement-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,
|
||||||
|
BillSettlementReportRoutingModule
|
||||||
|
],
|
||||||
|
declarations: [
|
||||||
|
BillSettlementReportComponent
|
||||||
|
],
|
||||||
|
providers: [
|
||||||
|
{provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE]},
|
||||||
|
{provide: MAT_DATE_FORMATS, useValue: MY_FORMATS},
|
||||||
|
]
|
||||||
|
})
|
||||||
|
export class BillSettlementReportModule {
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
import {inject, TestBed} from '@angular/core/testing';
|
||||||
|
|
||||||
|
import {BillSettlementReportService} from './bill-settlement-report.service';
|
||||||
|
|
||||||
|
describe('BillSettlementReportService', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
providers: [BillSettlementReportService]
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be created', inject([BillSettlementReportService], (service: BillSettlementReportService) => {
|
||||||
|
expect(service).toBeTruthy();
|
||||||
|
}));
|
||||||
|
});
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
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 { BillSettlementReport } from './bill-settlement-report';
|
||||||
|
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||||
|
|
||||||
|
const httpOptions = {
|
||||||
|
headers: new HttpHeaders({'Content-Type': 'application/json'})
|
||||||
|
};
|
||||||
|
|
||||||
|
const url = '/v1/bill-settlement-report';
|
||||||
|
const serviceName = 'BillSettlementReportService';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class BillSettlementReportService {
|
||||||
|
|
||||||
|
constructor(private http: HttpClient, private log: ErrorLoggerService) {
|
||||||
|
}
|
||||||
|
|
||||||
|
get(startDate: string, finishDate): Observable<BillSettlementReport> {
|
||||||
|
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<BillSettlementReport>>this.http.get<BillSettlementReport>(url, options)
|
||||||
|
.pipe(
|
||||||
|
catchError(this.log.handleError(serviceName, 'get'))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
export class BillSettlementReportItem {
|
||||||
|
date: string;
|
||||||
|
billId: string;
|
||||||
|
amount: number;
|
||||||
|
settlement: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class BillSettlementReport {
|
||||||
|
startDate: string;
|
||||||
|
finishDate: string;
|
||||||
|
amounts?: BillSettlementReportItem[];
|
||||||
|
}
|
||||||
@ -23,6 +23,9 @@
|
|||||||
<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('Sales Detail')" [routerLink]="['/', 'product-sale-report']">
|
||||||
<h3 class="item-name">Product Sale Report</h3>
|
<h3 class="item-name">Product Sale Report</h3>
|
||||||
</mat-card>
|
</mat-card>
|
||||||
|
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.hasPermission('Bill Details')" [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('Tables')" [routerLink]="['/', 'tables']">
|
<mat-card fxLayout="column" class="square-button" matRipple *ngIf="auth.hasPermission('Tables')" [routerLink]="['/', 'tables']">
|
||||||
<h3 class="item-name">Tables</h3>
|
<h3 class="item-name">Tables</h3>
|
||||||
</mat-card>
|
</mat-card>
|
||||||
|
|||||||
Reference in New Issue
Block a user