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
@@ -12,8 +12,7 @@ const incentiveRoutes: Routes = [
path: '',
component: IncentiveComponent,
canActivate: [
(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) =>
inject(AuthGuard).canActivate(route, state),
(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => inject(AuthGuard).canActivate(route, state),
],
data: {
permission: 'incentive',
@@ -27,8 +26,7 @@ const incentiveRoutes: Routes = [
path: ':id',
component: IncentiveComponent,
canActivate: [
(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) =>
inject(AuthGuard).canActivate(route, state),
(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => inject(AuthGuard).canActivate(route, state),
],
data: {
permission: 'incentive',
@@ -7,13 +7,7 @@
<div class="flex flex-row justify-around content-start items-start">
<mat-form-field class="flex-auto">
<mat-label>Date</mat-label>
<input
matInput
[matDatepicker]="date"
(focus)="date.open()"
formControlName="date"
autocomplete="off"
/>
<input matInput [matDatepicker]="date" (focus)="date.open()" formControlName="date" autocomplete="off" />
<mat-datepicker-toggle matSuffix [for]="date"></mat-datepicker-toggle>
<mat-datepicker #date></mat-datepicker>
</mat-form-field>
@@ -45,9 +39,7 @@
<!-- DaysWorked Column -->
<ng-container matColumnDef="daysWorked">
<mat-header-cell *matHeaderCellDef class="right">DaysWorked</mat-header-cell>
<mat-cell *matCellDef="let row" class="right">{{
row.daysWorked | number: '1.2-2'
}}</mat-cell>
<mat-cell *matCellDef="let row" class="right">{{ row.daysWorked | number: '1.2-2' }}</mat-cell>
</ng-container>
<!-- Points Column -->
@@ -58,13 +50,7 @@
<button mat-icon-button color="warn" matPrefix (click)="less(row, i)">
<mat-icon>remove</mat-icon>
</button>
<input
matInput
formControlName="points"
autocomplete="off"
(change)="change(row, i)"
class="flex-auto"
/>
<input matInput formControlName="points" autocomplete="off" (change)="change(row, i)" class="flex-auto" />
<button mat-icon-button color="primary" matSuffix (click)="more(row, i)">
<mat-icon>add</mat-icon>
</button>
@@ -75,9 +61,7 @@
<!-- Amount Column -->
<ng-container matColumnDef="amount">
<mat-header-cell *matHeaderCellDef class="right">Amount</mat-header-cell>
<mat-cell *matCellDef="let row" class="right">{{
amount(row) | currency: 'INR'
}}</mat-cell>
<mat-cell *matCellDef="let row" class="right">{{ amount(row) | currency: 'INR' }}</mat-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
@@ -97,20 +81,13 @@
>
{{ voucher.posted ? 'Posted' : 'Post' }}
</button>
<button
mat-raised-button
color="warn"
(click)="confirmDelete()"
*ngIf="voucher.id"
[disabled]="!canSave()"
>
<button mat-raised-button color="warn" (click)="confirmDelete()" *ngIf="voucher.id" [disabled]="!canSave()">
Delete
</button>
</mat-card-actions>
<mat-card-subtitle *ngIf="voucher.id">
Created on <strong>{{ voucher.creationDate | localTime }}</strong> and Last Edited on
<strong>{{ voucher.lastEditDate | localTime }}</strong> by
<strong>{{ voucher.user.name }}</strong
<strong>{{ voucher.lastEditDate | localTime }}</strong> by <strong>{{ voucher.user.name }}</strong
>. {{ voucher.poster ? 'Posted by ' + voucher.poster : '' }}
</mat-card-subtitle>
</mat-card>
@@ -54,16 +54,14 @@ export class IncentiveComponent implements OnInit {
incentives: new FormArray<FormGroup<{ points: FormControl<number> }>>([]),
});
// Listen to Date Change
this.form.controls.date.valueChanges
.pipe(map((x) => moment(x).format('DD-MMM-YYYY')))
.subscribe((x) => {
if (x !== this.voucher.date && !this.voucher.id) {
return this.ser.getIncentive(x).subscribe((voucher: Voucher) => {
this.loadVoucher(voucher);
});
}
return '';
});
this.form.controls.date.valueChanges.pipe(map((x) => moment(x).format('DD-MMM-YYYY'))).subscribe((x) => {
if (x !== this.voucher.date && !this.voucher.id) {
return this.ser.getIncentive(x).subscribe((voucher: Voucher) => {
this.loadVoucher(voucher);
});
}
return '';
});
}
ngOnInit() {
@@ -90,9 +88,7 @@ export class IncentiveComponent implements OnInit {
}
totalPoints() {
return this.voucher.incentives
.map((item) => item.daysWorked * item.points)
.reduce((sum, item) => sum + item);
return this.voucher.incentives.map((item) => item.daysWorked * item.points).reduce((sum, item) => sum + item);
}
pointValue() {
@@ -129,10 +125,7 @@ export class IncentiveComponent implements OnInit {
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");
}
post() {
@@ -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';