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:
@ -13,8 +13,8 @@
|
||||
autocomplete="off"
|
||||
/>
|
||||
<mat-hint *ngIf="accBal">
|
||||
Balance as on Date: <strong>{{ accBal.date | currency: 'INR' | accounting }}</strong> /
|
||||
Final balance: <strong>{{ accBal.total | currency: 'INR' | accounting }}</strong>
|
||||
Balance as on Date: <strong>{{ accBal.date | currency: 'INR' | accounting }}</strong> / Final balance:
|
||||
<strong>{{ accBal.total | currency: 'INR' | accounting }}</strong>
|
||||
</mat-hint>
|
||||
</mat-form-field>
|
||||
<mat-autocomplete
|
||||
@ -23,9 +23,7 @@
|
||||
[displayWith]="displayFn"
|
||||
(optionSelected)="accountSelected($event)"
|
||||
>
|
||||
<mat-option *ngFor="let account of accounts | async" [value]="account">{{
|
||||
account.name
|
||||
}}</mat-option>
|
||||
<mat-option *ngFor="let account of accounts | async" [value]="account">{{ account.name }}</mat-option>
|
||||
</mat-autocomplete>
|
||||
<mat-form-field class="flex-auto basis-1/3">
|
||||
<mat-label>Amount</mat-label>
|
||||
@ -36,8 +34,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>
|
||||
|
||||
@ -13,8 +13,7 @@ const receiptRoutes: Routes = [
|
||||
path: '',
|
||||
component: ReceiptComponent,
|
||||
canActivate: [
|
||||
(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) =>
|
||||
inject(AuthGuard).canActivate(route, state),
|
||||
(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => inject(AuthGuard).canActivate(route, state),
|
||||
],
|
||||
data: {
|
||||
permission: 'journal',
|
||||
@ -29,8 +28,7 @@ const receiptRoutes: Routes = [
|
||||
path: ':id',
|
||||
component: ReceiptComponent,
|
||||
canActivate: [
|
||||
(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) =>
|
||||
inject(AuthGuard).canActivate(route, state),
|
||||
(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => inject(AuthGuard).canActivate(route, state),
|
||||
],
|
||||
data: {
|
||||
permission: 'journal',
|
||||
|
||||
@ -42,10 +42,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>Account</mat-label>
|
||||
<input
|
||||
@ -57,8 +54,8 @@
|
||||
autocomplete="off"
|
||||
/>
|
||||
<mat-hint *ngIf="accBal">
|
||||
Balance as on Date: <strong>{{ accBal.date | currency: 'INR' | accounting }}</strong> /
|
||||
Final balance: <strong>{{ accBal.total | currency: 'INR' | accounting }}</strong>
|
||||
Balance as on Date: <strong>{{ accBal.date | currency: 'INR' | accounting }}</strong> / Final balance:
|
||||
<strong>{{ accBal.total | currency: 'INR' | accounting }}</strong>
|
||||
</mat-hint>
|
||||
</mat-form-field>
|
||||
<mat-autocomplete
|
||||
@ -67,9 +64,7 @@
|
||||
[displayWith]="displayFn"
|
||||
(optionSelected)="accountSelected($event)"
|
||||
>
|
||||
<mat-option *ngFor="let account of accounts | async" [value]="account">{{
|
||||
account.name
|
||||
}}</mat-option>
|
||||
<mat-option *ngFor="let account of accounts | async" [value]="account">{{ account.name }}</mat-option>
|
||||
</mat-autocomplete>
|
||||
<mat-form-field class="flex-auto basis-1/4 mr-5">
|
||||
<mat-label>Amount</mat-label>
|
||||
@ -77,9 +72,7 @@
|
||||
<span matTextPrefix>₹ </span>
|
||||
</mat-form-field>
|
||||
|
||||
<button mat-raised-button color="primary" (click)="addRow()" class="flex-auto basis-1/5">
|
||||
Add
|
||||
</button>
|
||||
<button mat-raised-button color="primary" (click)="addRow()" class="flex-auto basis-1/5">Add</button>
|
||||
</div>
|
||||
<mat-table #table [dataSource]="dataSource" matSort aria-label="Elements">
|
||||
<!-- Account Column -->
|
||||
@ -91,9 +84,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 -->
|
||||
@ -117,11 +108,7 @@
|
||||
<textarea matInput matAutosizeMinRows="5" formControlName="narration"></textarea>
|
||||
</mat-form-field>
|
||||
<div class="flex flex-row justify-center items-stretch">
|
||||
<div
|
||||
class="img-container"
|
||||
class="flex-auto mr-5 basis-1/5"
|
||||
*ngFor="let item of voucher.files"
|
||||
>
|
||||
<div class="img-container" class="flex-auto mr-5 basis-1/5" *ngFor="let item of voucher.files">
|
||||
<img [src]="item.thumbnail" (click)="zoomImage(item)" />
|
||||
<button mat-icon-button class="overlay" (click)="deleteImage(item)">
|
||||
<mat-icon>delete</mat-icon>
|
||||
@ -158,13 +145,7 @@
|
||||
>
|
||||
{{ 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>
|
||||
<span class="fill-remaining-space"></span>
|
||||
|
||||
@ -183,9 +183,7 @@ export class ReceiptComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
if (this.account === null || amount <= 0) {
|
||||
return;
|
||||
}
|
||||
const oldFiltered = this.voucher.journals.filter(
|
||||
(x) => x.account.id === (this.account as Account).id,
|
||||
);
|
||||
const oldFiltered = this.voucher.journals.filter((x) => x.account.id === (this.account as Account).id);
|
||||
const old = oldFiltered.length ? oldFiltered[0] : null;
|
||||
if (old && (old.debit === 1 || old.id === this.receiptJournal.id)) {
|
||||
return;
|
||||
@ -220,10 +218,7 @@ export class ReceiptComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
updateView() {
|
||||
const journals = this.voucher.journals.filter((x) => x.debit === -1);
|
||||
this.journalObservable.next(journals);
|
||||
this.receiptJournal.amount = round(
|
||||
Math.abs(journals.map((x) => x.amount).reduce((p, c) => p + c, 0)),
|
||||
2,
|
||||
);
|
||||
this.receiptJournal.amount = round(Math.abs(journals.map((x) => x.amount).reduce((p, c) => p + c, 0)), 2);
|
||||
this.form.controls.receiptAmount.setValue(this.receiptJournal.amount);
|
||||
}
|
||||
|
||||
@ -264,10 +259,7 @@ export class ReceiptComponent 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");
|
||||
}
|
||||
|
||||
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';
|
||||
|
||||
Reference in New Issue
Block a user