Tax is added directly to product for sale

Auth guard and auth service simplified and fixed so that user is updated upon login
Home component changed to use square buttons
Fixed showing the totals in the bill

ng linted the project
This commit is contained in:
Amritanshu committed 2019-08-11 01:37:14 +05:30
1 parent d7fdf751b9
commit dcaf23b390
23 files changed
+334 -266

No files matched your search

@@ -39,26 +39,29 @@
<button mat-icon-button (click)="modifier(row)" [disabled]="row.isPrinted" *ngIf="!row.isKot">
<mat-icon class="del">assignment</mat-icon>
</button>
<button mat-icon-button (click)="modifier(row)" [disabled]="row.newKot" *ngIf="row.isKot">
<mat-icon class="del">open_in_new</mat-icon>
</button>
</mat-cell>
<mat-footer-cell *matFooterCellDef class="grey900 bold right-align">{{ amount() | currency: 'INR' }}</mat-footer-cell>
<mat-footer-cell *matFooterCellDef class="grey900 bold right-align">{{ bs.amount | async | currency: 'INR' }}</mat-footer-cell>
</ng-container>
<ng-container matColumnDef="net-title">
<mat-footer-cell *matFooterCellDef class="grey300 bold">Net</mat-footer-cell>
</ng-container>
<ng-container matColumnDef="net-amount">
<mat-footer-cell *matFooterCellDef class="grey300 bold right-align">{{ netAmount() | currency: 'INR' }}</mat-footer-cell>
<mat-footer-cell *matFooterCellDef class="grey300 bold right-align">{{ bs.netAmount | async | currency: 'INR' }}</mat-footer-cell>
</ng-container>
<ng-container matColumnDef="discount-title">
<mat-footer-cell *matFooterCellDef class="grey500 bold">Discount</mat-footer-cell>
</ng-container>
<ng-container matColumnDef="discount-amount">
<mat-footer-cell *matFooterCellDef class="grey500 bold right-align">{{ discountAmount() | currency: 'INR' }}</mat-footer-cell>
<mat-footer-cell *matFooterCellDef class="grey500 bold right-align">{{ bs.discountAmount | async | currency: 'INR' }}</mat-footer-cell>
</ng-container>
<ng-container matColumnDef="tax-title">
<mat-footer-cell *matFooterCellDef class="grey700 bold">Tax</mat-footer-cell>
</ng-container>
<ng-container matColumnDef="tax-amount">
<mat-footer-cell *matFooterCellDef class="grey700 bold right-align">{{ taxAmount() | currency: 'INR' }}</mat-footer-cell>
<mat-footer-cell *matFooterCellDef class="grey700 bold right-align">{{ bs.taxAmount | async | currency: 'INR' }}</mat-footer-cell>
</ng-container>
<mat-row *matRowDef="let row; columns: displayedColumns;" [class.blue400]="row.oldKot" [class.blue800]="row.newKot"
+13 -19
View File
@@ -1,10 +1,17 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Bill } from './bill';
import { ActivatedRoute, Router } from '@angular/router';
import { Bill, Kot } from './bill';
import { BillsDataSource } from './bills-datasource';
import { BillService } from '../bill.service';
import { QuantityComponent } from '../quantity/quantity.component';
import { MatDialog } from '@angular/material';
import { Table } from '../../core/table';
import { Observable, throwError } from 'rxjs';
import { ConfirmDialogComponent } from '../../shared/confirm-dialog/confirm-dialog.component';
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';
@Component({
selector: 'app-bills',
@@ -19,8 +26,11 @@ export class BillsComponent implements OnInit {
constructor(
private route: ActivatedRoute,
private router: Router,
private dialog: MatDialog,
private bs: BillService
private toaster: ToasterService,
private bs: BillService,
private tSer: TableService
) {
}
@@ -62,20 +72,4 @@ export class BillsComponent implements OnInit {
modifier(item: any): void {
this.bs.modifier(item);
}
netAmount(): number {
return this.bs.netAmount();
}
discountAmount(): number {
return this.bs.discountAmount();
}
taxAmount(): number {
return this.bs.taxAmount();
}
amount(): number {
return this.bs.amount();
}
}
@@ -4,7 +4,7 @@ import { catchError } from 'rxjs/operators';
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { ErrorLoggerService } from '../../core/error-logger.service';
import { Bill, PrintType } from './bill';
import { Table } from "../../core/table";
import { Table } from '../../core/table';
const httpOptions = {
headers: new HttpHeaders({'Content-Type': 'application/json'})
@@ -50,7 +50,7 @@ export class VoucherService {
save(voucher: Bill, printType: PrintType, guest_book_id: string, updateTable: boolean): Observable<Bill> {
const options = {params: new HttpParams().set('p', printType).set('u', updateTable.toString())};
if (guest_book_id !== null) {
options.params = options.params.set('g', guest_book_id)
options.params = options.params.set('g', guest_book_id);
}
return <Observable<Bill>>this.http.post<Bill>(`${url}/new`, voucher, options)
.pipe(
@@ -61,7 +61,7 @@ export class VoucherService {
update(voucher: Bill, printType: PrintType, guest_book_id: string, updateTable: boolean): Observable<Bill> {
const options = {params: new HttpParams().set('p', printType).set('u', updateTable.toString())};
if (guest_book_id !== null) {
options.params = options.params.set('g', guest_book_id)
options.params = options.params.set('g', guest_book_id);
}
return <Observable<Bill>>this.http.put<Bill>(`${url}/${voucher.id}`, voucher, options)
.pipe(
@@ -78,7 +78,7 @@ export class VoucherService {
}
receivePayment(id: string, amounts: { id: string; name: string; amount: number }[], updateTable: boolean): Observable<boolean> {
const options = {params: new HttpParams().set('receive-payment', "").set('u', updateTable.toString())};
const options = {params: new HttpParams().set('receive-payment', '').set('u', updateTable.toString())};
return <Observable<boolean>>this.http.post<boolean>(`${url}/${id}`, amounts, options)
.pipe(
catchError(this.log.handleError(serviceName, 'receivePayment'))
@@ -87,14 +87,14 @@ export class VoucherService {
moveTable(id: string, table: Table): Observable<boolean> {
const options = {params: new HttpParams().set('move-table', '')};
return <Observable<boolean>>this.http.post<boolean>(`${url}/${id}`, {table:{id: table.id}}, options)
return <Observable<boolean>>this.http.post<boolean>(`${url}/${id}`, {table: {id: table.id}}, options)
.pipe(
catchError(this.log.handleError(serviceName, 'moveTable'))
);
}
voidBill(id: string, reason: string, updateTable: boolean): Observable<boolean> {
const options = {params: new HttpParams().set('void-bill', "").set('u', updateTable.toString())};
const options = {params: new HttpParams().set('void-bill', '').set('u', updateTable.toString())};
return <Observable<boolean>>this.http.post<boolean>(`${url}/${id}`, {reason: reason}, options)
.pipe(
catchError(this.log.handleError(serviceName, 'voidBill'))