Feature: Cancelled bills are now separate from void bills.

Void bills are automatically generated when printed bills are changed.
Manually cancelled bills are called cancelled bills.
This commit is contained in:
2023-03-17 08:27:30 +05:30
parent a62018ad1f
commit 1a08066c2d
15 changed files with 170 additions and 39 deletions

View File

@ -4,7 +4,7 @@ export class ProductSaleReportItem {
regularBill: number;
noCharge: number;
staff: number;
void: number;
cancel: number;
public constructor(init?: Partial<ProductSaleReportItem>) {
this.name = '';
@ -12,7 +12,7 @@ export class ProductSaleReportItem {
this.regularBill = 0;
this.noCharge = 0;
this.staff = 0;
this.void = 0;
this.cancel = 0;
Object.assign(this, init);
}
}

View File

@ -72,10 +72,10 @@
<mat-cell *matCellDef="let row" class="right">{{ row.staff | number : '1.2-2' }}</mat-cell>
</ng-container>
<!-- Void Column -->
<ng-container matColumnDef="void">
<mat-header-cell *matHeaderCellDef class="right">Void</mat-header-cell>
<mat-cell *matCellDef="let row" class="right">{{ row.void | number : '1.2-2' }}</mat-cell>
<!-- Cancelled Column -->
<ng-container matColumnDef="cancel">
<mat-header-cell *matHeaderCellDef class="right">Cancelled</mat-header-cell>
<mat-cell *matCellDef="let row" class="right">{{ row.cancel | number : '1.2-2' }}</mat-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>

View File

@ -24,7 +24,7 @@ export class ProductSaleReportComponent implements OnInit {
}>;
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
displayedColumns = ['name', 'unbilled', 'sale', 'noCharge', 'staff', 'void'];
displayedColumns = ['name', 'unbilled', 'sale', 'noCharge', 'staff', 'cancel'];
constructor(
private route: ActivatedRoute,

View File

@ -271,8 +271,8 @@ export class BillService {
return this.ser.mergeKotWithOldBill(this.bill.id as string, kotId, table);
}
voidBill(reason: string): Observable<boolean> {
return this.ser.voidBill(this.bill.id as string, reason, this.updateTable);
cancelBill(reason: string): Observable<boolean> {
return this.ser.cancelBill(this.bill.id as string, reason, this.updateTable);
}
updateAmounts() {

View File

@ -123,13 +123,13 @@ export class VoucherService {
.pipe(catchError(this.log.handleError(serviceName, 'receivePayment'))) as Observable<boolean>;
}
voidBill(id: string, reason: string, updateTable: boolean): Observable<boolean> {
cancelBill(id: string, reason: string, updateTable: boolean): Observable<boolean> {
const options = {
params: new HttpParams().set('reason', reason).set('u', updateTable.toString()),
};
return this.http
.post<boolean>(`${url}/void-bill/${id}`, {}, options)
.pipe(catchError(this.log.handleError(serviceName, 'voidBill'))) as Observable<boolean>;
.post<boolean>(`${url}/cancel-bill/${id}`, {}, options)
.pipe(catchError(this.log.handleError(serviceName, 'cancelBill'))) as Observable<boolean>;
}
moveTable(id: string, table: Table): Observable<boolean> {

View File

@ -58,11 +58,11 @@
<mat-card
class="flex flex-col square-button mr-5, mb-5"
matRipple
(click)="voidBill()"
[class.disabled]="!voidBillAllowed()"
[class.face]="voidBillAllowed()"
(click)="cancelBill()"
[class.disabled]="!cancelBillAllowed()"
[class.face]="cancelBillAllowed()"
>
<h3 class="item-name">Void Bill</h3>
<h3 class="item-name">Cancel Bill</h3>
</mat-card>
<mat-card
class="flex flex-col square-button mr-5, mb-5"

View File

@ -112,11 +112,11 @@ export class SalesHomeComponent {
.pipe(map((x: boolean) => (x ? table : x)));
}
confirmVoidDialog(reason: string): Observable<string | boolean> {
confirmCancelDialog(reason: string): Observable<string | boolean> {
return this.dialog
.open(ConfirmDialogComponent, {
width: '250px',
data: { title: 'Void Bill?', content: 'Are you sure?' },
data: { title: 'Cancel Bill?', content: 'Are you sure?' },
})
.afterClosed()
.pipe(map((x: boolean) => (x ? reason : x)));
@ -267,7 +267,7 @@ export class SalesHomeComponent {
);
}
voidBillAllowed(): boolean {
cancelBillAllowed(): boolean {
if (!this.auth.allowed('void-bill')) {
return false;
}
@ -277,15 +277,15 @@ export class SalesHomeComponent {
return true;
}
voidBill() {
if (!this.voidBillAllowed()) {
cancelBill() {
if (!this.cancelBillAllowed()) {
return;
}
this.dialog
.open(ReasonComponent, {
// width: '750px'
data: {
title: 'Void Reason',
title: 'Cancel Reason',
reasons: [
'Discount',
'Printing fault',
@ -301,15 +301,15 @@ export class SalesHomeComponent {
.pipe(
switchMap((x: boolean | string) => {
if (x) {
return this.confirmVoidDialog(x as string);
return this.confirmCancelDialog(x as string);
}
throw new Error('Please choose a reason to void the bill');
throw new Error('Please choose a reason to cancel the bill');
}),
switchMap((x: boolean | string) => {
if (x) {
return this.bs.voidBill(x as string);
return this.bs.cancelBill(x as string);
}
throw new Error('You chose not to void the bill');
throw new Error('You chose not to cancel the bill');
}),
)
.subscribe(