Chore: Reformatted everthing

Fix: Product ledger was not totalling.
This is because for some reason, pydantic was sending the data as string when the field was nullable
This commit is contained in:
2023-08-04 21:00:26 +05:30
parent af27bf74ef
commit ac868257b7
194 changed files with 513 additions and 1580 deletions
@@ -1,9 +1,7 @@
<h1 mat-dialog-title>Edit Product SKU</h1>
<div mat-dialog-content>
<form [formGroup]="form">
<div
class="flex flex-row flex-wrap justify-around content-start items-start sm:max-lg:flex-col"
>
<div class="flex flex-row flex-wrap justify-around content-start items-start sm:max-lg:flex-col">
<mat-form-field class="flex-auto mr-5">
<mat-label>Units</mat-label>
<input matInput formControlName="units" />
@@ -28,8 +26,6 @@
</form>
</div>
<div mat-dialog-actions>
<button mat-raised-button color="warn" [mat-dialog-close]="false" cdkFocusInitial class="mr-5">
Cancel
</button>
<button mat-raised-button color="warn" [mat-dialog-close]="false" cdkFocusInitial class="mr-5">Cancel</button>
<button mat-raised-button color="primary" (click)="accept()">Ok</button>
</div>
@@ -21,9 +21,7 @@
</mat-form-field>
</div>
<div class="flex flex-row justify-around content-start items-start">
<mat-checkbox formControlName="isPurchased" class="flex-auto mr-5"
>Is Purchased?</mat-checkbox
>
<mat-checkbox formControlName="isPurchased" class="flex-auto mr-5">Is Purchased?</mat-checkbox>
<mat-checkbox formControlName="isSold" class="flex-auto mr-5">Is Sold?</mat-checkbox>
<mat-checkbox formControlName="isActive" class="flex-auto">Is Active?</mat-checkbox>
</div>
@@ -87,17 +85,13 @@
<!-- Cost Price Column -->
<ng-container matColumnDef="costPrice">
<mat-header-cell *matHeaderCellDef class="right">Cost Price</mat-header-cell>
<mat-cell *matCellDef="let row" class="right">{{
row.costPrice | currency: 'INR'
}}</mat-cell>
<mat-cell *matCellDef="let row" class="right">{{ row.costPrice | currency: 'INR' }}</mat-cell>
</ng-container>
<!-- Sale Price Column -->
<ng-container matColumnDef="salePrice">
<mat-header-cell *matHeaderCellDef class="right">Sale Price</mat-header-cell>
<mat-cell *matCellDef="let row" class="right">{{
row.salePrice | currency: 'INR'
}}</mat-cell>
<mat-cell *matCellDef="let row" class="right">{{ row.salePrice | currency: 'INR' }}</mat-cell>
</ng-container>
<!-- Action Column -->
@@ -119,8 +113,6 @@
</mat-card-content>
<mat-card-actions>
<button mat-raised-button color="primary" (click)="save()" class="mr-5">Save</button>
<button mat-raised-button color="warn" (click)="confirmDelete()" *ngIf="!!item.id">
Delete
</button>
<button mat-raised-button color="warn" (click)="confirmDelete()" *ngIf="!!item.id">Delete</button>
</mat-card-actions>
</mat-card>
@@ -51,9 +51,9 @@ export class ProductListDataSource extends DataSource<Product> {
return this.filterValue.split(' ').reduce(
(p: Product[], c: string) =>
p.filter((x) => {
const productString = `${x.code} ${x.name} ${x.productGroup?.name}${
x.isPurchased ? ' purchased' : ' made'
}${x.isSold ? 'sold' : 'used'}${x.isActive ? 'active' : 'deactive'}`.toLowerCase();
const productString = `${x.code} ${x.name} ${x.productGroup?.name}${x.isPurchased ? ' purchased' : ' made'}${
x.isSold ? 'sold' : 'used'
}${x.isActive ? 'active' : 'deactive'}`.toLowerCase();
return productString.indexOf(c) !== -1;
}),
Object.assign([], data),
@@ -83,11 +83,7 @@ export class ProductListDataSource extends DataSource<Product> {
case 'name':
return compare(a.name, b.name, isAsc);
case 'productGroup':
return compare(
(a.productGroup as ProductGroup).name,
(b.productGroup as ProductGroup).name,
isAsc,
);
return compare((a.productGroup as ProductGroup).name, (b.productGroup as ProductGroup).name, isAsc);
default:
return 0;
}
@@ -96,5 +92,4 @@ export class ProductListDataSource extends DataSource<Product> {
}
/** Simple sort comparator for example ID/Name columns (for client-side sorting). */
const compare = (a: string | number, b: string | number, isAsc: boolean) =>
(a < b ? -1 : 1) * (isAsc ? 1 : -1);
const compare = (a: string | number, b: string | number, isAsc: boolean) => (a < b ? -1 : 1) * (isAsc ? 1 : -1);
@@ -28,8 +28,7 @@
<ul>
<li *ngFor="let sku of row.skus">
<a [routerLink]="['/products', row.id]"
>{{ row.name }} ({{
showExtended ? sku.fraction + ' ' + row.fractionUnits + ' = 1 ' : ''
>{{ row.name }} ({{ showExtended ? sku.fraction + ' ' + row.fractionUnits + ' = 1 ' : ''
}}{{ sku.units }})</a
>
</li>
@@ -40,10 +40,7 @@ export class ProductListComponent implements OnInit, AfterViewInit {
this.form = new FormGroup({
filter: new FormControl<string>('', { nonNullable: true }),
});
this.filter = this.form.controls.filter.valueChanges.pipe(
debounceTime(150),
distinctUntilChanged(),
);
this.filter = this.form.controls.filter.valueChanges.pipe(debounceTime(150), distinctUntilChanged());
this.dataSource = new ProductListDataSource(this.list, this.filter);
}
@@ -15,8 +15,7 @@ const productRoutes: Routes = [
path: '',
component: ProductListComponent,
canActivate: [
(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) =>
inject(AuthGuard).canActivate(route, state),
(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => inject(AuthGuard).canActivate(route, state),
],
data: {
permission: 'Products',
@@ -29,8 +28,7 @@ const productRoutes: Routes = [
path: 'new',
component: ProductDetailComponent,
canActivate: [
(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) =>
inject(AuthGuard).canActivate(route, state),
(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => inject(AuthGuard).canActivate(route, state),
],
data: {
permission: 'Products',
@@ -44,8 +42,7 @@ const productRoutes: Routes = [
path: ':id',
component: ProductDetailComponent,
canActivate: [
(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) =>
inject(AuthGuard).canActivate(route, state),
(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => inject(AuthGuard).canActivate(route, state),
],
data: {
permission: 'Products',
+2 -6
View File
@@ -64,9 +64,7 @@ export class ProductService {
}
return this.http
.get<ProductSku[]>(`${url}/q-product`, options)
.pipe(catchError(this.log.handleError(serviceName, 'autocomplete'))) as Observable<
ProductSku[]
>;
.pipe(catchError(this.log.handleError(serviceName, 'autocomplete'))) as Observable<ProductSku[]>;
}
autocompleteSku(
@@ -86,8 +84,6 @@ export class ProductService {
}
return this.http
.get<ProductSku[]>(`${url}/q-sku`, options)
.pipe(catchError(this.log.handleError(serviceName, 'autocomplete'))) as Observable<
ProductSku[]
>;
.pipe(catchError(this.log.handleError(serviceName, 'autocomplete'))) as Observable<ProductSku[]>;
}
}