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
@@ -18,9 +18,7 @@
[displayWith]="displayFn"
(optionSelected)="batchSelected($event)"
>
<mat-option *ngFor="let batch of batches | async" [value]="batch">{{
batch.name
}}</mat-option>
<mat-option *ngFor="let batch of batches | async" [value]="batch">{{ batch.name }}</mat-option>
</mat-autocomplete>
</mat-form-field>
<mat-form-field class="flex-auto basis-1/3">
@@ -31,8 +29,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>
@@ -38,9 +38,7 @@ export class IssueDialogComponent implements OnInit {
this.batches = this.form.controls.batch.valueChanges.pipe(
debounceTime(150),
distinctUntilChanged(),
switchMap((x) =>
x === null ? observableOf([]) : this.batchSer.autocomplete(this.data.date, x),
),
switchMap((x) => (x === null ? observableOf([]) : this.batchSer.autocomplete(this.data.date, x))),
);
}
@@ -68,8 +66,7 @@ export class IssueDialogComponent implements OnInit {
this.data.inventory.rate = this.batch.rate;
this.data.inventory.tax = this.batch.tax;
this.data.inventory.discount = this.batch.discount;
this.data.inventory.amount =
quantity * this.batch.rate * (1 + this.batch.tax) * (1 - this.batch.discount);
this.data.inventory.amount = quantity * this.batch.rate * (1 + this.batch.tax) * (1 - this.batch.discount);
this.dialogRef.close(this.data.inventory);
}
}
+1 -3
View File
@@ -21,8 +21,6 @@ export class IssueGridService {
issueGrid(date: string): Observable<IssueGridItem[]> {
return this.http
.get<IssueGridItem[]>(`${url}/${date}`)
.pipe(catchError(this.log.handleError(serviceName, 'autocomplete'))) as Observable<
IssueGridItem[]
>;
.pipe(catchError(this.log.handleError(serviceName, 'autocomplete'))) as Observable<IssueGridItem[]>;
}
}
@@ -13,8 +13,7 @@ const issueRoutes: Routes = [
path: '',
component: IssueComponent,
canActivate: [
(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) =>
inject(AuthGuard).canActivate(route, state),
(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => inject(AuthGuard).canActivate(route, state),
],
data: {
permission: 'Issue',
@@ -29,8 +28,7 @@ const issueRoutes: Routes = [
path: ':id',
component: IssueComponent,
canActivate: [
(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) =>
inject(AuthGuard).canActivate(route, state),
(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => inject(AuthGuard).canActivate(route, state),
],
data: {
permission: 'Issue',
+7 -26
View File
@@ -39,10 +39,7 @@
</mat-form-field>
</div>
<div
formGroupName="addRow"
class="flex flex-row justify-around content-start items-start sm:max-lg:flex-col"
>
<div formGroupName="addRow" class="flex flex-row justify-around content-start items-start sm:max-lg:flex-col">
<mat-form-field class="flex-auto basis-[55%] mr-5">
<mat-label>Product</mat-label>
<input
@@ -59,9 +56,7 @@
[displayWith]="displayFn"
(optionSelected)="batchSelected($event)"
>
<mat-option *ngFor="let batch of batches | async" [value]="batch">{{
batch.name
}}</mat-option>
<mat-option *ngFor="let batch of batches | async" [value]="batch">{{ batch.name }}</mat-option>
</mat-autocomplete>
</mat-form-field>
<mat-form-field class="flex-auto basis-1/4 mr-5">
@@ -69,9 +64,7 @@
<input type="text" matInput formControlName="quantity" autocomplete="off" />
</mat-form-field>
<button mat-raised-button color="primary" (click)="addRow()" class="flex-auto basis-2/5">
Add
</button>
<button mat-raised-button color="primary" (click)="addRow()" class="flex-auto basis-2/5">Add</button>
</div>
<mat-table #table [dataSource]="dataSource" matSort aria-label="Elements">
<!-- Product Column -->
@@ -89,9 +82,7 @@
<!-- Quantity Column -->
<ng-container matColumnDef="quantity">
<mat-header-cell *matHeaderCellDef class="right">Quantity</mat-header-cell>
<mat-cell *matCellDef="let row" class="right">{{
row.quantity | number: '1.2-2'
}}</mat-cell>
<mat-cell *matCellDef="let row" class="right">{{ row.quantity | number: '1.2-2' }}</mat-cell>
</ng-container>
<!-- Rate Column -->
@@ -103,9 +94,7 @@
<!-- 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>
<mat-cell *matCellDef="let row" class="right">{{ row.amount | currency: 'INR' }}</mat-cell>
</ng-container>
<!-- Action Column -->
@@ -134,16 +123,8 @@
<button mat-raised-button color="primary" (click)="save()" [disabled]="!canSave()" class="mr-5">
{{ voucher.id ? 'Update' : 'Save' }}
</button>
<button mat-raised-button color="warn" (click)="newVoucher()" *ngIf="voucher.id" class="mr-5">
New Entry
</button>
<button
mat-raised-button
color="warn"
(click)="confirmDelete()"
*ngIf="voucher.id"
[disabled]="!canSave()"
>
<button mat-raised-button color="warn" (click)="newVoucher()" *ngIf="voucher.id" class="mr-5">New Entry</button>
<button mat-raised-button color="warn" (click)="confirmDelete()" *ngIf="voucher.id" [disabled]="!canSave()">
Delete
</button>
<span class="fill-remaining-space"></span>
+2 -8
View File
@@ -217,10 +217,7 @@ export class IssueComponent implements OnInit, AfterViewInit, OnDestroy {
updateView() {
this.inventoryObservable.next(this.voucher.inventories);
const amount = round(
Math.abs(this.voucher.inventories.map((x) => x.amount).reduce((p, c) => p + c, 0)),
2,
);
const amount = round(Math.abs(this.voucher.inventories.map((x) => x.amount).reduce((p, c) => p + c, 0)), 2);
this.form.controls.amount.setValue(amount);
}
@@ -261,10 +258,7 @@ export class IssueComponent implements OnInit, AfterViewInit, OnDestroy {
if (this.voucher.posted && this.auth.allowed('edit-posted-vouchers')) {
return true;
}
return (
this.voucher.user.id === (this.auth.user as User).id ||
this.auth.allowed("edit-other-user's-vouchers")
);
return this.voucher.user.id === (this.auth.user as User).id || this.auth.allowed("edit-other-user's-vouchers");
}
save() {
+1 -6
View File
@@ -7,12 +7,7 @@ import { MatAutocompleteModule } from '@angular/material/autocomplete';
import { MatButtonModule } from '@angular/material/button';
import { MatCardModule } from '@angular/material/card';
import { MatCheckboxModule } from '@angular/material/checkbox';
import {
DateAdapter,
MAT_DATE_FORMATS,
MAT_DATE_LOCALE,
MatNativeDateModule,
} from '@angular/material/core';
import { DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE, MatNativeDateModule } from '@angular/material/core';
import { MatDatepickerModule } from '@angular/material/datepicker';
import { MatDialogModule } from '@angular/material/dialog';
import { MatFormFieldModule } from '@angular/material/form-field';