Feature: Sale Analysis is working
Fix: Cashier Checkout multiple entries
This commit is contained in:
@ -45,6 +45,10 @@ const routes: Routes = [
|
||||
path: 'sales',
|
||||
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-categories',
|
||||
loadChildren: () => import('./sale-category/sale-categories.module').then(mod => mod.SaleCategoriesModule)
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { LOCALE_ID, NgModule } from '@angular/core';
|
||||
import { registerLocaleData } from '@angular/common';
|
||||
import { HttpClientModule } from "@angular/common/http";
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
import enIN from '@angular/common/locales/en-IN';
|
||||
|
||||
import { AppRoutingModule } from './app-routing.module';
|
||||
|
||||
@ -2,7 +2,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 { User } from "../core/user";
|
||||
import { User } from '../core/user';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
import {CashierCheckoutRoutingModule} from './cashier-checkout-routing.module';
|
||||
|
||||
describe('CashierCheckoutRoutingModule', () => {
|
||||
let CashierCheckoutRoutingModule: CashierCheckoutRoutingModule;
|
||||
let cashierCheckoutRoutingModule: CashierCheckoutRoutingModule;
|
||||
|
||||
beforeEach(() => {
|
||||
CashierCheckoutRoutingModule = new CashierCheckoutRoutingModule();
|
||||
cashierCheckoutRoutingModule = new CashierCheckoutRoutingModule();
|
||||
});
|
||||
|
||||
it('should create an instance', () => {
|
||||
expect(CashierCheckoutRoutingModule).toBeTruthy();
|
||||
expect(cashierCheckoutRoutingModule).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
@ -4,7 +4,7 @@ import { RouterModule, Routes } from '@angular/router';
|
||||
import { CashierCheckoutResolver } from './cashier-checkout-resolver.service';
|
||||
import { AuthGuard } from '../auth/auth-guard.service';
|
||||
import { CashierCheckoutComponent } from './cashier-checkout.component';
|
||||
import { ActiveCashiersResolver } from "./active-cashiers-resolver.service";
|
||||
import { ActiveCashiersResolver } from './active-cashiers-resolver.service';
|
||||
|
||||
const CashierCheckoutRoutes: Routes = [
|
||||
{
|
||||
|
||||
@ -41,7 +41,7 @@
|
||||
<!-- Name Column -->
|
||||
<ng-container matColumnDef="name">
|
||||
<mat-header-cell *matHeaderCellDef>Name</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row"><a [href]="row.url">{{row.name}}</a></mat-cell>
|
||||
<mat-cell *matCellDef="let row">{{row.name}}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Amount Column -->
|
||||
|
||||
@ -5,7 +5,7 @@ import * as moment from 'moment';
|
||||
import { CashierCheckoutDataSource } from './cashier-checkout-datasource';
|
||||
import { CashierCheckout } from './cashier-checkout';
|
||||
import { ToCsvService } from '../shared/to-csv.service';
|
||||
import { User } from "../core/user";
|
||||
import { User } from '../core/user';
|
||||
|
||||
@Component({
|
||||
selector: 'app-cashier-checkout',
|
||||
@ -48,7 +48,11 @@ export class CashierCheckoutComponent implements OnInit {
|
||||
|
||||
show() {
|
||||
const info = this.getInfo();
|
||||
this.router.navigate(['checkout', this.form.value.cashier], {
|
||||
const url = ['checkout'];
|
||||
if (!!info.user.id) {
|
||||
url.push(info.user.id);
|
||||
}
|
||||
this.router.navigate(url, {
|
||||
queryParams: {
|
||||
startDate: info.startDate,
|
||||
finishDate: info.finishDate
|
||||
@ -68,7 +72,7 @@ export class CashierCheckoutComponent implements OnInit {
|
||||
const formModel = this.form.value;
|
||||
|
||||
return {
|
||||
user: formModel.cashier,
|
||||
user: new User({id: formModel.cashier}),
|
||||
startDate: moment(formModel.startDate).format('DD-MMM-YYYY'),
|
||||
finishDate: moment(formModel.finishDate).format('DD-MMM-YYYY')
|
||||
};
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
import {CashierCheckoutModule} from './cashier-checkout.module';
|
||||
|
||||
describe('CashierCheckoutModule', () => {
|
||||
let CashierCheckoutModule: CashierCheckoutModule;
|
||||
let cashierCheckoutModule: CashierCheckoutModule;
|
||||
|
||||
beforeEach(() => {
|
||||
CashierCheckoutModule = new CashierCheckoutModule();
|
||||
cashierCheckoutModule = new CashierCheckoutModule();
|
||||
});
|
||||
|
||||
it('should create an instance', () => {
|
||||
expect(CashierCheckoutModule).toBeTruthy();
|
||||
expect(cashierCheckoutModule).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
@ -21,7 +21,7 @@ import { CashierCheckoutComponent } from './cashier-checkout.component';
|
||||
import { MomentDateAdapter } from '@angular/material-moment-adapter';
|
||||
import { A11yModule } from '@angular/cdk/a11y';
|
||||
import { FlexLayoutModule } from '@angular/flex-layout';
|
||||
import { MatSelectModule } from "@angular/material";
|
||||
import { MatSelectModule } from '@angular/material';
|
||||
|
||||
export const MY_FORMATS = {
|
||||
parse: {
|
||||
|
||||
@ -4,7 +4,7 @@ import { Observable } from 'rxjs/internal/Observable';
|
||||
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
||||
import { CashierCheckout } from './cashier-checkout';
|
||||
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||
import {User} from "../core/user";
|
||||
import { User } from '../core/user';
|
||||
|
||||
const httpOptions = {
|
||||
headers: new HttpHeaders({'Content-Type': 'application/json'})
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import {User} from "../core/user";
|
||||
import { User } from '../core/user';
|
||||
|
||||
export class CashierCheckoutPrintItem {
|
||||
date: string;
|
||||
|
||||
@ -14,6 +14,9 @@
|
||||
<mat-card fxLayout="column" class="square-button" matRipple [routerLink]="['/', 'checkout']">
|
||||
<h3 class="item-name">Cashier Checkout</h3>
|
||||
</mat-card>
|
||||
<mat-card fxLayout="column" class="square-button" matRipple [routerLink]="['/', 'sale-analysis']">
|
||||
<h3 class="item-name">Sale Analysis</h3>
|
||||
</mat-card>
|
||||
<mat-card fxLayout="column" class="square-button" matRipple [routerLink]="['/', 'tables']">
|
||||
<h3 class="item-name">Tables</h3>
|
||||
</mat-card>
|
||||
|
||||
18
bookie/src/app/sale-analysis/sale-analysis-datasource.ts
Normal file
18
bookie/src/app/sale-analysis/sale-analysis-datasource.ts
Normal file
@ -0,0 +1,18 @@
|
||||
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() {
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
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();
|
||||
}));
|
||||
});
|
||||
@ -0,0 +1,20 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
import {SaleAnalysisRoutingModule} from './sale-analysis-routing.module';
|
||||
|
||||
describe('SaleAnalysisRoutingModule', () => {
|
||||
let saleAnalysisRoutingModule: SaleAnalysisRoutingModule;
|
||||
|
||||
beforeEach(() => {
|
||||
saleAnalysisRoutingModule = new SaleAnalysisRoutingModule();
|
||||
});
|
||||
|
||||
it('should create an instance', () => {
|
||||
expect(saleAnalysisRoutingModule).toBeTruthy();
|
||||
});
|
||||
});
|
||||
37
bookie/src/app/sale-analysis/sale-analysis-routing.module.ts
Normal file
37
bookie/src/app/sale-analysis/sale-analysis-routing.module.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
import { SaleAnalysisResolver } from './sale-analysis-resolver.service';
|
||||
import { AuthGuard } from '../auth/auth-guard.service';
|
||||
import { SaleAnalysisComponent } from './sale-analysis.component';
|
||||
|
||||
const SaleAnalysisRoutes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: SaleAnalysisComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Sales Analysis'
|
||||
},
|
||||
resolve: {
|
||||
info: SaleAnalysisResolver
|
||||
},
|
||||
runGuardsAndResolvers: 'always'
|
||||
}
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
RouterModule.forChild(SaleAnalysisRoutes)
|
||||
|
||||
],
|
||||
exports: [
|
||||
RouterModule
|
||||
],
|
||||
providers: [
|
||||
SaleAnalysisResolver
|
||||
]
|
||||
})
|
||||
export class SaleAnalysisRoutingModule {
|
||||
}
|
||||
4
bookie/src/app/sale-analysis/sale-analysis.component.css
Normal file
4
bookie/src/app/sale-analysis/sale-analysis.component.css
Normal file
@ -0,0 +1,4 @@
|
||||
.right {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
44
bookie/src/app/sale-analysis/sale-analysis.component.html
Normal file
44
bookie/src/app/sale-analysis/sale-analysis.component.html
Normal file
@ -0,0 +1,44 @@
|
||||
<mat-card>
|
||||
<mat-card-title-group>
|
||||
<mat-card-title>Sale Analysis</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">
|
||||
|
||||
<!-- Name Column -->
|
||||
<ng-container matColumnDef="name">
|
||||
<mat-header-cell *matHeaderCellDef>Name</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{row.name}}</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 | currency:'INR'}}</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>
|
||||
25
bookie/src/app/sale-analysis/sale-analysis.component.spec.ts
Normal file
25
bookie/src/app/sale-analysis/sale-analysis.component.spec.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
|
||||
|
||||
import {SaleAnalysisComponent} from './sale-analysis.component';
|
||||
|
||||
describe('SaleAnalysisComponent', () => {
|
||||
let component: SaleAnalysisComponent;
|
||||
let fixture: ComponentFixture<SaleAnalysisComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [SaleAnalysisComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(SaleAnalysisComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
90
bookie/src/app/sale-analysis/sale-analysis.component.ts
Normal file
90
bookie/src/app/sale-analysis/sale-analysis.component.ts
Normal file
@ -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 { SaleAnalysisDataSource } from './sale-analysis-datasource';
|
||||
import { SaleAnalysis } from './sale-analysis';
|
||||
import { ToCsvService } from '../shared/to-csv.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-sale-analysis',
|
||||
templateUrl: './sale-analysis.component.html',
|
||||
styleUrls: ['./sale-analysis.component.css']
|
||||
})
|
||||
export class SaleAnalysisComponent implements OnInit {
|
||||
dataSource: SaleAnalysisDataSource;
|
||||
form: FormGroup;
|
||||
info: SaleAnalysis;
|
||||
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
displayedColumns = ['name', 'amount'];
|
||||
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private fb: FormBuilder,
|
||||
private toCsv: ToCsvService
|
||||
) {
|
||||
this.createForm();
|
||||
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data
|
||||
.subscribe((data: { info: SaleAnalysis }) => {
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
||||
show() {
|
||||
const info = this.getInfo();
|
||||
this.router.navigate(['sale-analysis'], {
|
||||
queryParams: {
|
||||
startDate: info.startDate,
|
||||
finishDate: info.finishDate
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
createForm() {
|
||||
this.form = this.fb.group({
|
||||
startDate: '',
|
||||
finishDate: ''
|
||||
});
|
||||
}
|
||||
|
||||
getInfo(): SaleAnalysis {
|
||||
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', 'sale-analysis.csv');
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
}
|
||||
}
|
||||
13
bookie/src/app/sale-analysis/sale-analysis.module.spec.ts
Normal file
13
bookie/src/app/sale-analysis/sale-analysis.module.spec.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import {SaleAnalysisModule} from './sale-analysis.module';
|
||||
|
||||
describe('SaleAnalysisModule', () => {
|
||||
let saleAnalysisModule: SaleAnalysisModule;
|
||||
|
||||
beforeEach(() => {
|
||||
saleAnalysisModule = new SaleAnalysisModule();
|
||||
});
|
||||
|
||||
it('should create an instance', () => {
|
||||
expect(saleAnalysisModule).toBeTruthy();
|
||||
});
|
||||
});
|
||||
61
bookie/src/app/sale-analysis/sale-analysis.module.ts
Normal file
61
bookie/src/app/sale-analysis/sale-analysis.module.ts
Normal file
@ -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 { SaleAnalysisRoutingModule } from './sale-analysis-routing.module';
|
||||
import { SaleAnalysisComponent } from './sale-analysis.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,
|
||||
SaleAnalysisRoutingModule
|
||||
],
|
||||
declarations: [
|
||||
SaleAnalysisComponent
|
||||
],
|
||||
providers: [
|
||||
{provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE]},
|
||||
{provide: MAT_DATE_FORMATS, useValue: MY_FORMATS},
|
||||
]
|
||||
})
|
||||
export class SaleAnalysisModule {
|
||||
}
|
||||
15
bookie/src/app/sale-analysis/sale-analysis.service.spec.ts
Normal file
15
bookie/src/app/sale-analysis/sale-analysis.service.spec.ts
Normal file
@ -0,0 +1,15 @@
|
||||
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();
|
||||
}));
|
||||
});
|
||||
36
bookie/src/app/sale-analysis/sale-analysis.service.ts
Normal file
36
bookie/src/app/sale-analysis/sale-analysis.service.ts
Normal file
@ -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 { SaleAnalysis } from './sale-analysis';
|
||||
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||
|
||||
const httpOptions = {
|
||||
headers: new HttpHeaders({'Content-Type': 'application/json'})
|
||||
};
|
||||
|
||||
const url = '/v1/sale-analysis';
|
||||
const serviceName = 'SaleAnalysisService';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class SaleAnalysisService {
|
||||
|
||||
constructor(private http: HttpClient, private log: ErrorLoggerService) {
|
||||
}
|
||||
|
||||
get(startDate: string, finishDate): Observable<SaleAnalysis> {
|
||||
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<SaleAnalysis>>this.http.get<SaleAnalysis>(url, options)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'list'))
|
||||
);
|
||||
}
|
||||
}
|
||||
10
bookie/src/app/sale-analysis/sale-analysis.ts
Normal file
10
bookie/src/app/sale-analysis/sale-analysis.ts
Normal file
@ -0,0 +1,10 @@
|
||||
export class SaleAnalysisItem {
|
||||
name: string;
|
||||
amount: number;
|
||||
}
|
||||
|
||||
export class SaleAnalysis {
|
||||
startDate: string;
|
||||
finishDate: string;
|
||||
amounts?: SaleAnalysisItem[];
|
||||
}
|
||||
@ -11,7 +11,7 @@ import { Bill, Inventory, Kot, PrintType } from './bills/bill';
|
||||
import { VoucherService } from './bills/voucher.service';
|
||||
import { ToasterService } from '../core/toaster.service';
|
||||
import { Table } from '../core/table';
|
||||
import { SelectionModel } from "@angular/cdk/collections";
|
||||
import { SelectionModel } from '@angular/cdk/collections';
|
||||
|
||||
@Injectable()
|
||||
export class BillService {
|
||||
@ -184,7 +184,7 @@ export class BillService {
|
||||
printKot(guest_book_id: string): Observable<boolean> {
|
||||
const item = JSON.parse(JSON.stringify(this.bill));
|
||||
const newKot = this.getKot();
|
||||
if (newKot.inventories.length == 0) {
|
||||
if (newKot.inventories.length === 0) {
|
||||
this.toaster.show('Error', 'Cannot print a blank KOT\nPlease add some products!');
|
||||
}
|
||||
item.kots.push(newKot);
|
||||
@ -262,7 +262,7 @@ export class BillService {
|
||||
}
|
||||
|
||||
splitBill(table: Table): Observable<boolean> {
|
||||
const inventoriesToMove: string[] = this.selection.selected.map((x:any)=> x.id)
|
||||
const inventoriesToMove: string[] = this.selection.selected.map((x: any) => x.id);
|
||||
return this.ser.splitBill(this.bill.id, inventoriesToMove, table);
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,8 +12,8 @@ import { map, switchMap } from 'rxjs/operators';
|
||||
import { TablesDialogComponent } from '../tables-dialog/tables-dialog.component';
|
||||
import { TableService } from '../../tables/table.service';
|
||||
import { ToasterService } from '../../core/toaster.service';
|
||||
import { AuthService } from "../../auth/auth.service";
|
||||
import { SelectionModel } from "@angular/cdk/collections";
|
||||
import { AuthService } from '../../auth/auth.service';
|
||||
import { SelectionModel } from '@angular/cdk/collections';
|
||||
|
||||
@Component({
|
||||
selector: 'app-bills',
|
||||
@ -56,8 +56,8 @@ export class BillsComponent implements OnInit {
|
||||
}
|
||||
|
||||
isAnySelected(kot: Kot) {
|
||||
let total: number = 0,
|
||||
found: number = 0;
|
||||
let total = 0,
|
||||
found = 0;
|
||||
this.bs.data.filter(
|
||||
x => x.kotId === kot.id
|
||||
).forEach((c: any) => {
|
||||
@ -118,7 +118,7 @@ export class BillsComponent implements OnInit {
|
||||
}
|
||||
|
||||
moveKot(kot: Kot) {
|
||||
const canMergeTables = this.auth.hasPermission("Merge Tables");
|
||||
const canMergeTables = this.auth.hasPermission('Merge Tables');
|
||||
this.dialog.open(TablesDialogComponent, {
|
||||
// width: '750px',
|
||||
data: {
|
||||
|
||||
@ -160,7 +160,7 @@ export class SalesHomeComponent implements OnInit {
|
||||
}
|
||||
|
||||
moveTable() {
|
||||
const canMergeTables = this.auth.hasPermission("Merge Tables");
|
||||
const canMergeTables = this.auth.hasPermission('Merge Tables');
|
||||
this.dialog.open(TablesDialogComponent, {
|
||||
// width: '750px',
|
||||
data: {
|
||||
@ -296,7 +296,7 @@ export class SalesHomeComponent implements OnInit {
|
||||
return false;
|
||||
}
|
||||
if (this.bs.bill.voucherType === PrintType.Kot) {
|
||||
return false
|
||||
return false;
|
||||
}
|
||||
if (this.bs.bill.isVoid) {
|
||||
return false;
|
||||
|
||||
@ -91,7 +91,7 @@ export class ReceivePaymentComponent {
|
||||
(z, i) => array.controls[i].valueChanges.pipe(
|
||||
distinctUntilChanged()
|
||||
).subscribe(x => {
|
||||
this.choices[this.type].find(s => s.name == x.name).amount = (x.amount === '' ? 0 : parseInt(x.amount, 10));
|
||||
this.choices[this.type].find(s => s.name === x.name).amount = (x.amount === '' ? 0 : parseInt(x.amount, 10));
|
||||
this.balance = this.amount - this.choices[this.type].reduce((a, c) => a + c.amount, 0);
|
||||
})
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user