Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2dfbfd8fcb | ||
|
|
221fadfdfc | ||
|
|
11b93cb11c | ||
|
|
302a4eb311 |
@@ -1 +1 @@
|
|||||||
__version__ = "15.1.4"
|
__version__ = "15.1.6"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "barker"
|
name = "barker"
|
||||||
version = "15.1.4"
|
version = "15.1.6"
|
||||||
description = "Point of Sale for a restaurant"
|
description = "Point of Sale for a restaurant"
|
||||||
requires-python = ">=3.14"
|
requires-python = ">=3.14"
|
||||||
authors = [{ name = "tanshu", email = "git@tanshu.com" }]
|
authors = [{ name = "tanshu", email = "git@tanshu.com" }]
|
||||||
|
|||||||
Generated
+1
-1
@@ -231,7 +231,7 @@ wheels = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "barker"
|
name = "barker"
|
||||||
version = "15.1.4"
|
version = "15.1.6"
|
||||||
source = { editable = "." }
|
source = { editable = "." }
|
||||||
dependencies = [
|
dependencies = [
|
||||||
{ name = "aiohttp" },
|
{ name = "aiohttp" },
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "bookie",
|
"name": "bookie",
|
||||||
"version": "15.1.4",
|
"version": "15.1.6",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"ng": "ng",
|
"ng": "ng",
|
||||||
"start": "ng serve",
|
"start": "ng serve",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
export const environment = {
|
export const environment = {
|
||||||
production: true,
|
production: true,
|
||||||
ACCESS_TOKEN_REFRESH_MINUTES: 10, // refresh token 10 minutes before expiry
|
ACCESS_TOKEN_REFRESH_MINUTES: 10, // refresh token 10 minutes before expiry
|
||||||
version: '15.1.4',
|
version: '15.1.6',
|
||||||
};
|
};
|
||||||
|
|
||||||
export const dateFormat = {
|
export const dateFormat = {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
</mat-card>
|
</mat-card>
|
||||||
</div>
|
</div>
|
||||||
</mat-dialog-content>
|
</mat-dialog-content>
|
||||||
<mat-dialog-actions align="end">
|
<mat-dialog-actions>
|
||||||
<button mat-button [mat-dialog-close]="false">Cancel</button>
|
<button mat-button [mat-dialog-close]="false">Cancel</button>
|
||||||
<button mat-button [mat-dialog-close]="selectedVal">Done</button>
|
<button mat-button [mat-dialog-close]="selectedVal">Done</button>
|
||||||
</mat-dialog-actions>
|
</mat-dialog-actions>
|
||||||
|
|||||||
@@ -27,22 +27,22 @@
|
|||||||
<div class="row-container">
|
<div class="row-container">
|
||||||
<mat-form-field class="flex-auto">
|
<mat-form-field class="flex-auto">
|
||||||
<mat-label>Name</mat-label>
|
<mat-label>Name</mat-label>
|
||||||
<input matInput [value]="formModel().name" readonly />
|
<input matInput [formField]="form.name" />
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
<div class="row-container">
|
<div class="row-container">
|
||||||
<mat-form-field class="flex-auto">
|
<mat-form-field class="flex-auto">
|
||||||
<mat-label>Address</mat-label>
|
<mat-label>Address</mat-label>
|
||||||
<textarea matInput [value]="formModel().address" readonly> </textarea>
|
<textarea matInput [formField]="form.address"> </textarea>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
<div class="row-container">
|
<div class="row-container">
|
||||||
<mat-checkbox [checked]="formModel().printInBill" [disabled]="true">Print in Bill?</mat-checkbox>
|
<mat-checkbox [formField]="form.printInBill">Print in Bill?</mat-checkbox>
|
||||||
</div>
|
</div>
|
||||||
<p></p>
|
<p></p>
|
||||||
<div class="discounts">
|
<div class="discounts">
|
||||||
<ul>
|
<ul>
|
||||||
@for (r of formModel().discounts; track r.id) {
|
@for (r of form().value().discounts; track r.id) {
|
||||||
@if (r.discount > 0) {
|
@if (r.discount > 0) {
|
||||||
<li>{{ r.name }} - {{ r.discount | percent: '1.2-2' }}</li>
|
<li>{{ r.name }} - {{ r.discount | percent: '1.2-2' }}</li>
|
||||||
}
|
}
|
||||||
@@ -51,7 +51,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</mat-dialog-content>
|
</mat-dialog-content>
|
||||||
<mat-dialog-actions align="end">
|
<mat-dialog-actions>
|
||||||
<button mat-button [mat-dialog-close]="false">Cancel</button>
|
<button mat-button [mat-dialog-close]="false">Cancel</button>
|
||||||
<button type="button" mat-raised-button color="primary" (click)="save()">Select</button>
|
<button type="button" mat-raised-button color="primary" (click)="save()">Select</button>
|
||||||
</mat-dialog-actions>
|
</mat-dialog-actions>
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ export class ChooseCustomerComponent {
|
|||||||
|
|
||||||
save() {
|
save() {
|
||||||
const customer = this.getItem();
|
const customer = this.getItem();
|
||||||
|
console.log(customer);
|
||||||
const promise = this.ser.saveOrUpdate(customer);
|
const promise = this.ser.saveOrUpdate(customer);
|
||||||
promise.subscribe((x) => this.dialogRef.close(x));
|
promise.subscribe((x) => this.dialogRef.close(x));
|
||||||
}
|
}
|
||||||
@@ -96,15 +97,15 @@ export class ChooseCustomerComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getItem(): Customer {
|
getItem(): Customer {
|
||||||
const formModel = this.formModel();
|
const formValue = this.form().value();
|
||||||
|
|
||||||
return new Customer({
|
return new Customer({
|
||||||
id: formModel.id,
|
id: formValue.id,
|
||||||
name: formModel.name ?? '',
|
name: formValue.name ?? '',
|
||||||
phone: formModel.phone ?? '',
|
phone: formValue.phone ?? '',
|
||||||
address: formModel.address ?? '',
|
address: formValue.address ?? '',
|
||||||
printInBill: formModel.printInBill ?? false,
|
printInBill: formValue.printInBill ?? false,
|
||||||
discounts: formModel.discounts.map((item) => ({ ...item })),
|
discounts: formValue.discounts.map((item) => ({ ...item })),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
<input matInput type="number" [formField]="form.discounts[i].discount" autocomplete="off" />
|
<input matInput type="number" [formField]="form.discounts[i].discount" autocomplete="off" />
|
||||||
<span matTextSuffix>%</span>
|
<span matTextSuffix>%</span>
|
||||||
<mat-hint>Cust: {{ row.customer | percent: '1.2-2' }}</mat-hint>
|
<mat-hint>Cust: {{ row.customer | percent: '1.2-2' }}</mat-hint>
|
||||||
<mat-hint align="end">Max: {{ row.limit | percent: '1.2-2' }}</mat-hint>
|
<mat-hint>Max: {{ row.limit | percent: '1.2-2' }}</mat-hint>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</mat-cell>
|
</mat-cell>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
</mat-table>
|
</mat-table>
|
||||||
</form>
|
</form>
|
||||||
</mat-dialog-content>
|
</mat-dialog-content>
|
||||||
<mat-dialog-actions align="end">
|
<mat-dialog-actions>
|
||||||
<button mat-button [mat-dialog-close]="false">Cancel</button>
|
<button mat-button [mat-dialog-close]="false">Cancel</button>
|
||||||
<button type="button" mat-button (click)="accept()" color="primary">Ok</button>
|
<button type="button" mat-button (click)="accept()" color="primary">Ok</button>
|
||||||
</mat-dialog-actions>
|
</mat-dialog-actions>
|
||||||
|
|||||||
@@ -30,6 +30,6 @@
|
|||||||
}
|
}
|
||||||
</mat-tab-group>
|
</mat-tab-group>
|
||||||
</mat-dialog-content>
|
</mat-dialog-content>
|
||||||
<mat-dialog-actions align="end">
|
<mat-dialog-actions>
|
||||||
<button mat-button [mat-dialog-close]="selected()">Done</button>
|
<button mat-button [mat-dialog-close]="selected()">Done</button>
|
||||||
</mat-dialog-actions>
|
</mat-dialog-actions>
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
</mat-table>
|
</mat-table>
|
||||||
</form>
|
</form>
|
||||||
</mat-dialog-content>
|
</mat-dialog-content>
|
||||||
<mat-dialog-actions align="end">
|
<mat-dialog-actions>
|
||||||
<button mat-button [mat-dialog-close]="false">Cancel</button>
|
<button mat-button [mat-dialog-close]="false">Cancel</button>
|
||||||
<button type="button" mat-button (click)="accept()" color="primary" [disabled]="!selected">Ok</button>
|
<button type="button" mat-button (click)="accept()" color="primary" [disabled]="!selected">Ok</button>
|
||||||
</mat-dialog-actions>
|
</mat-dialog-actions>
|
||||||
|
|||||||
@@ -6,7 +6,12 @@
|
|||||||
<h2 mat-dialog-title>Receive Payment</h2>
|
<h2 mat-dialog-title>Receive Payment</h2>
|
||||||
<mat-dialog-content>
|
<mat-dialog-content>
|
||||||
<form class="flex-col">
|
<form class="flex-col">
|
||||||
<mat-table #table [dataSource]="dataSource()" [style.visibility]="this.displayTable() ? 'visible' : 'hidden'">
|
<mat-table
|
||||||
|
#table
|
||||||
|
[dataSource]="formModel().amounts"
|
||||||
|
[trackBy]="trackByRow"
|
||||||
|
[style.visibility]="displayTable() ? 'visible' : 'hidden'"
|
||||||
|
>
|
||||||
<!-- Name Column -->
|
<!-- Name Column -->
|
||||||
<ng-container matColumnDef="name">
|
<ng-container matColumnDef="name">
|
||||||
<mat-header-cell *matHeaderCellDef class="bold">Amount</mat-header-cell>
|
<mat-header-cell *matHeaderCellDef class="bold">Amount</mat-header-cell>
|
||||||
@@ -16,7 +21,7 @@
|
|||||||
<!-- Amount Column -->
|
<!-- Amount Column -->
|
||||||
<ng-container matColumnDef="amount">
|
<ng-container matColumnDef="amount">
|
||||||
<mat-header-cell *matHeaderCellDef class="center bold" class="flex-auto">{{
|
<mat-header-cell *matHeaderCellDef class="center bold" class="flex-auto">{{
|
||||||
amount | currency: 'INR'
|
data.amount | currency: 'INR'
|
||||||
}}</mat-header-cell>
|
}}</mat-header-cell>
|
||||||
<mat-cell *matCellDef="let row; let i = index" class="center flex-auto">
|
<mat-cell *matCellDef="let row; let i = index" class="center flex-auto">
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
@@ -29,7 +34,7 @@
|
|||||||
<mat-row *matRowDef="let row; columns: displayedColumns"></mat-row>
|
<mat-row *matRowDef="let row; columns: displayedColumns"></mat-row>
|
||||||
<mat-footer-row *matFooterRowDef="displayedColumns"></mat-footer-row>
|
<mat-footer-row *matFooterRowDef="displayedColumns"></mat-footer-row>
|
||||||
</mat-table>
|
</mat-table>
|
||||||
<mat-form-field class="flex-auto" [style.visibility]="this.displayReason() ? 'visible' : 'hidden'">
|
<mat-form-field class="flex-auto" [style.visibility]="displayReason() ? 'visible' : 'hidden'">
|
||||||
<mat-label>Reason</mat-label>
|
<mat-label>Reason</mat-label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
@@ -43,7 +48,7 @@
|
|||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</form>
|
</form>
|
||||||
</mat-dialog-content>
|
</mat-dialog-content>
|
||||||
<mat-dialog-actions align="end">
|
<mat-dialog-actions>
|
||||||
<button mat-button [mat-dialog-close]>Cancel</button>
|
<button mat-button [mat-dialog-close]>Cancel</button>
|
||||||
<button type="button" mat-button (click)="accept()" color="primary" [disabled]="!!balance()">Ok</button>
|
<button type="button" mat-button (click)="accept()" color="primary" [disabled]="!!balance()">Ok</button>
|
||||||
</mat-dialog-actions>
|
</mat-dialog-actions>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { CdkScrollableModule } from '@angular/cdk/scrolling';
|
import { CdkScrollableModule } from '@angular/cdk/scrolling';
|
||||||
import { CurrencyPipe } from '@angular/common';
|
import { CurrencyPipe } from '@angular/common';
|
||||||
import { Component, computed, effect, inject, signal } from '@angular/core';
|
import { Component, computed, inject, linkedSignal, signal } from '@angular/core';
|
||||||
import { FormField, form } from '@angular/forms/signals';
|
import { form, FormField } from '@angular/forms/signals';
|
||||||
import { MatButtonModule } from '@angular/material/button';
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog';
|
import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog';
|
||||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||||
@@ -15,10 +15,7 @@ import { SkeletonLoaderComponent } from '../../shared/skeleton-loader/skeleton-l
|
|||||||
import { VoucherType } from '../bills/voucher-type';
|
import { VoucherType } from '../bills/voucher-type';
|
||||||
|
|
||||||
export interface ReceivePaymentFormData {
|
export interface ReceivePaymentFormData {
|
||||||
amounts: {
|
amounts: ReceivePaymentItem[];
|
||||||
name: string;
|
|
||||||
amount: number;
|
|
||||||
}[];
|
|
||||||
son: string;
|
son: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,59 +44,45 @@ export class ReceivePaymentComponent {
|
|||||||
amount: number;
|
amount: number;
|
||||||
}>(MAT_DIALOG_DATA);
|
}>(MAT_DIALOG_DATA);
|
||||||
|
|
||||||
typeSignal = signal<VoucherType | undefined>(this.data.type);
|
type = this.data.type;
|
||||||
|
|
||||||
|
typeSignal = signal<VoucherType | undefined>(this.type);
|
||||||
settleOptionsResource = this.ser.listForType(this.typeSignal);
|
settleOptionsResource = this.ser.listForType(this.typeSignal);
|
||||||
|
|
||||||
choices = signal<ReceivePaymentItem[]>([]);
|
displayReason = computed(() => this.settleOptionsResource.value()?.some((n) => n.hasReason) ?? false);
|
||||||
choicesWithAmount = computed(() => {
|
displayTable = computed(() => (this.settleOptionsResource.value()?.length ?? 0) > 1);
|
||||||
const amounts = this.formModel().amounts;
|
|
||||||
return this.choices().map((c, i) => ({ ...c, amount: amounts[i]?.amount ?? 0 }));
|
|
||||||
});
|
|
||||||
|
|
||||||
type: VoucherType;
|
formModel = linkedSignal({
|
||||||
amount: number;
|
source: () => this.settleOptionsResource.value(),
|
||||||
balance = computed(() => {
|
computation: (options): ReceivePaymentFormData => {
|
||||||
return this.amount - this.formModel().amounts.reduce((a, c) => a + (c.amount ?? 0), 0);
|
if (!options) {
|
||||||
});
|
return { amounts: [], son: '' };
|
||||||
|
}
|
||||||
reason = '';
|
const isTable = options.length > 1;
|
||||||
displayReason = signal<boolean | undefined>(undefined);
|
return {
|
||||||
displayTable = signal<boolean | undefined>(undefined);
|
amounts: options.map(
|
||||||
formModel = signal<ReceivePaymentFormData>({
|
(y) =>
|
||||||
amounts: [],
|
({
|
||||||
|
...y,
|
||||||
|
amount: !isTable ? this.data.amount : 0,
|
||||||
|
}) as ReceivePaymentItem,
|
||||||
|
),
|
||||||
son: '',
|
son: '',
|
||||||
|
};
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
form = form(this.formModel);
|
form = form(this.formModel);
|
||||||
|
|
||||||
dataSource = this.choicesWithAmount;
|
balance = computed(() => {
|
||||||
|
return this.data.amount - this.formModel().amounts.reduce((a, c) => a + (c.amount ?? 0), 0);
|
||||||
|
});
|
||||||
|
|
||||||
displayedColumns = ['name', 'amount'];
|
displayedColumns = ['name', 'amount'];
|
||||||
|
|
||||||
constructor() {
|
reason = '';
|
||||||
const data = this.data;
|
|
||||||
this.type = data.type;
|
|
||||||
this.amount = data.amount;
|
|
||||||
this.displayReason.set(false);
|
|
||||||
this.displayTable.set(false);
|
|
||||||
|
|
||||||
effect(() => {
|
trackByRow = (_: number, row: ReceivePaymentItem) => row.id ?? row.name ?? _;
|
||||||
const x = this.settleOptionsResource.value();
|
|
||||||
if (!x) return;
|
|
||||||
this.displayReason.set(x.reduce((o, n) => o || n.hasReason, false));
|
|
||||||
this.displayTable.set(x.length > 1);
|
|
||||||
const isTable = x.length > 1;
|
|
||||||
const choices = x.map((y) => ({ ...y, amount: !isTable ? this.amount : 0 }) as ReceivePaymentItem);
|
|
||||||
this.choices.set(choices);
|
|
||||||
this.formModel.update((f) => ({
|
|
||||||
...f,
|
|
||||||
amounts: x.map((y) => ({
|
|
||||||
name: y.name,
|
|
||||||
amount: !isTable ? this.amount : 0,
|
|
||||||
})),
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
select(reason: string) {
|
select(reason: string) {
|
||||||
this.reason = reason.trim();
|
this.reason = reason.trim();
|
||||||
@@ -107,7 +90,7 @@ export class ReceivePaymentComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
accept(): void {
|
accept(): void {
|
||||||
this.dialogRef.close({ choices: this.choicesWithAmount(), reason: this.reason });
|
this.dialogRef.close({ choices: this.formModel().amounts, reason: this.formModel().son.trim() || this.reason });
|
||||||
}
|
}
|
||||||
|
|
||||||
maxAmount(row: ReceivePaymentItem, index: number) {
|
maxAmount(row: ReceivePaymentItem, index: number) {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</mat-dialog-content>
|
</mat-dialog-content>
|
||||||
<mat-dialog-actions align="end">
|
<mat-dialog-actions>
|
||||||
<button mat-button [mat-dialog-close]="false">Cancel</button>
|
<button mat-button [mat-dialog-close]="false">Cancel</button>
|
||||||
<button type="button" mat-button (click)="accept()" color="primary">Ok</button>
|
<button type="button" mat-button (click)="accept()" color="primary">Ok</button>
|
||||||
</mat-dialog-actions>
|
</mat-dialog-actions>
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</mat-dialog-content>
|
</mat-dialog-content>
|
||||||
<mat-dialog-actions align="end">
|
<mat-dialog-actions>
|
||||||
<button mat-button [mat-dialog-close]="false">Cancel</button>
|
<button mat-button [mat-dialog-close]="false">Cancel</button>
|
||||||
<button type="button" mat-button (click)="accept()" color="primary">Ok</button>
|
<button type="button" mat-button (click)="accept()" color="primary">Ok</button>
|
||||||
</mat-dialog-actions>
|
</mat-dialog-actions>
|
||||||
|
|||||||
Reference in New Issue
Block a user