Moved the batch integrity report from settings to its own report in products with permission of product ledger.
It also automatically fixes the issue prices.
This commit is contained in:
@ -21,6 +21,11 @@ const appRoutes: Routes = [
|
||||
loadChildren: () =>
|
||||
import('./balance-sheet/balance-sheet.module').then((mod) => mod.BalanceSheetModule),
|
||||
},
|
||||
{
|
||||
path: 'batch-integrity-report',
|
||||
loadChildren: () =>
|
||||
import('./batch-integrity-report/batch-integrity-report.module').then((mod) => mod.BatchIntegrityReportModule),
|
||||
},
|
||||
{
|
||||
path: 'cash-flow',
|
||||
loadChildren: () => import('./cash-flow/cash-flow.module').then((mod) => mod.CashFlowModule),
|
||||
|
||||
@ -58,7 +58,7 @@ export class LoginComponent implements OnInit, AfterViewInit {
|
||||
// .pipe(first())
|
||||
.subscribe(
|
||||
() => {
|
||||
this.router.navigate([this.returnUrl]);
|
||||
this.router.navigateByUrl(this.returnUrl);
|
||||
},
|
||||
(error) => {
|
||||
if (error.status === 401 && error.error.detail === 'Client is not registered') {
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
import { DataSource } from '@angular/cdk/collections';
|
||||
import { Observable, of as observableOf } from 'rxjs';
|
||||
|
||||
import { BatchIntegrity } from './batch-integrity';
|
||||
|
||||
export class BatchIntegrityReportDatasource extends DataSource<BatchIntegrity> {
|
||||
constructor(public data: BatchIntegrity[]) {
|
||||
super();
|
||||
}
|
||||
|
||||
connect(): Observable<BatchIntegrity[]> {
|
||||
return observableOf(this.data);
|
||||
}
|
||||
|
||||
disconnect() {}
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
import { BatchIntegrityReportRoutingModule } from './batch-integrity-report-routing.module';
|
||||
|
||||
describe('BatchIntegrityRoutingModule', () => {
|
||||
let batchIntegrityRoutingModule: BatchIntegrityReportRoutingModule;
|
||||
|
||||
beforeEach(() => {
|
||||
batchIntegrityRoutingModule = new BatchIntegrityReportRoutingModule();
|
||||
});
|
||||
|
||||
it('should create an instance', () => {
|
||||
expect(batchIntegrityRoutingModule).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@ -0,0 +1,30 @@
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
|
||||
import { AuthGuard } from '../auth/auth-guard.service';
|
||||
|
||||
import { BatchIntegrityReportComponent } from './batch-integrity-report.component';
|
||||
import { BatchIntegrityResolverService } from './batch-integrity-resolver.service';
|
||||
|
||||
const batchIntegrityRoutes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: BatchIntegrityReportComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Product Ledger',
|
||||
},
|
||||
resolve: {
|
||||
info: BatchIntegrityResolverService,
|
||||
},
|
||||
runGuardsAndResolvers: 'always',
|
||||
},
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [CommonModule, RouterModule.forChild(batchIntegrityRoutes)],
|
||||
exports: [RouterModule],
|
||||
providers: [BatchIntegrityResolverService],
|
||||
})
|
||||
export class BatchIntegrityReportRoutingModule {}
|
||||
@ -0,0 +1,19 @@
|
||||
.right {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
.my-margin {
|
||||
margin: 0 12px;
|
||||
}
|
||||
.selected {
|
||||
background: #fff3cd;
|
||||
}
|
||||
|
||||
.unposted {
|
||||
background: #f8d7da;
|
||||
}
|
||||
|
||||
.mat-column-date,
|
||||
.mat-column-voucherType {
|
||||
max-width: 100px;
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
<mat-card>
|
||||
<mat-card-title-group>
|
||||
<mat-card-title>BatchReport</mat-card-title>
|
||||
</mat-card-title-group>
|
||||
<mat-card-content>
|
||||
<mat-table [dataSource]="dataSource" aria-label="Elements">
|
||||
<!-- Batch Column -->
|
||||
<ng-container matColumnDef="batch">
|
||||
<mat-header-cell *matHeaderCellDef>Batch</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">
|
||||
{{ row.product }} dated {{ row.date }} @ {{ row.price | currency: 'INR' }} is showing
|
||||
{{ row.showing }} instead of {{ row.actual }}
|
||||
</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Details Column -->
|
||||
<ng-container matColumnDef="details">
|
||||
<mat-header-cell *matHeaderCellDef>Details</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">
|
||||
<ul>
|
||||
<li *ngFor="let detail of row.details">
|
||||
<a [routerLink]="detail.url">{{ detail.type }}</a> on {{ detail.date }} of
|
||||
{{ detail.quantity }} @
|
||||
{{ detail.price | currency: 'INR' }}
|
||||
</li>
|
||||
</ul>
|
||||
</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
|
||||
<mat-row *matRowDef="let row; columns: displayedColumns"></mat-row>
|
||||
</mat-table>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
@ -0,0 +1,29 @@
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
|
||||
import { BatchIntegrityReportComponent } from './batch-integrity-report.component';
|
||||
|
||||
describe('BatchIntegrityComponent', () => {
|
||||
let component: BatchIntegrityReportComponent;
|
||||
let fixture: ComponentFixture<BatchIntegrityReportComponent>;
|
||||
|
||||
beforeEach(
|
||||
waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [HttpClientModule, RouterTestingModule],
|
||||
declarations: [BatchIntegrityReportComponent],
|
||||
}).compileComponents();
|
||||
}),
|
||||
);
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(BatchIntegrityReportComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@ -0,0 +1,30 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
|
||||
import { BatchIntegrity } from './batch-integrity';
|
||||
import { BatchIntegrityReportDatasource } from './batch-integrity-report-datasource';
|
||||
|
||||
@Component({
|
||||
selector: 'app-batch-integrity',
|
||||
templateUrl: './batch-integrity-report.component.html',
|
||||
styleUrls: ['./batch-integrity-report.component.css'],
|
||||
})
|
||||
export class BatchIntegrityReportComponent implements OnInit {
|
||||
info: BatchIntegrity[] = [];
|
||||
dataSource: BatchIntegrityReportDatasource = new BatchIntegrityReportDatasource(this.info);
|
||||
displayedColumns = ['batch', 'details'];
|
||||
|
||||
constructor(private route: ActivatedRoute, private router: Router) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data.subscribe((value) => {
|
||||
const data = value as { info: BatchIntegrity[] };
|
||||
this.info = data.info;
|
||||
this.dataSource = new BatchIntegrityReportDatasource(this.info);
|
||||
});
|
||||
}
|
||||
|
||||
refresh() {
|
||||
this.router.navigate([]);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
import { BatchIntegrityReportModule } from './batch-integrity-report.module';
|
||||
|
||||
describe('BatchIntegrityModule', () => {
|
||||
let batchIntegrityModule: BatchIntegrityReportModule;
|
||||
|
||||
beforeEach(() => {
|
||||
batchIntegrityModule = new BatchIntegrityReportModule();
|
||||
});
|
||||
|
||||
it('should create an instance', () => {
|
||||
expect(batchIntegrityModule).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@ -0,0 +1,73 @@
|
||||
import { A11yModule } from '@angular/cdk/a11y';
|
||||
import { CdkTableModule } from '@angular/cdk/table';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { FlexLayoutModule } from '@angular/flex-layout';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { MomentDateAdapter } from '@angular/material-moment-adapter';
|
||||
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 { MatDatepickerModule } from '@angular/material/datepicker';
|
||||
import { MatExpansionModule } from '@angular/material/expansion';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { MatPaginatorModule } from '@angular/material/paginator';
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { MatRadioModule } from '@angular/material/radio';
|
||||
import { MatSortModule } from '@angular/material/sort';
|
||||
import { MatTableModule } from '@angular/material/table';
|
||||
|
||||
import { SharedModule } from '../shared/shared.module';
|
||||
|
||||
import { BatchIntegrityReportRoutingModule } from './batch-integrity-report-routing.module';
|
||||
import { BatchIntegrityReportComponent } from './batch-integrity-report.component';
|
||||
|
||||
export const MY_FORMATS = {
|
||||
parse: {
|
||||
dateInput: 'DD-MMM-YYYY',
|
||||
},
|
||||
display: {
|
||||
dateInput: 'DD-MMM-YYYY',
|
||||
monthYearLabel: 'MMM YYYY',
|
||||
dateA11yLabel: 'DD-MMM-YYYY',
|
||||
monthYearA11yLabel: 'MMM YYYY',
|
||||
},
|
||||
};
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
A11yModule,
|
||||
CommonModule,
|
||||
CdkTableModule,
|
||||
MatButtonModule,
|
||||
MatCardModule,
|
||||
MatCheckboxModule,
|
||||
MatIconModule,
|
||||
MatInputModule,
|
||||
MatNativeDateModule,
|
||||
MatPaginatorModule,
|
||||
MatProgressSpinnerModule,
|
||||
MatRadioModule,
|
||||
MatSortModule,
|
||||
MatTableModule,
|
||||
SharedModule,
|
||||
BatchIntegrityReportRoutingModule,
|
||||
MatExpansionModule,
|
||||
MatDatepickerModule,
|
||||
ReactiveFormsModule,
|
||||
FlexLayoutModule,
|
||||
],
|
||||
declarations: [BatchIntegrityReportComponent],
|
||||
providers: [
|
||||
{ provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE] },
|
||||
{ provide: MAT_DATE_FORMATS, useValue: MY_FORMATS },
|
||||
],
|
||||
})
|
||||
export class BatchIntegrityReportModule {}
|
||||
@ -0,0 +1,20 @@
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
import { inject, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { BatchIntegrityReportService } from './batch-integrity-report.service';
|
||||
|
||||
describe('BatchIntegrityService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [HttpClientModule],
|
||||
providers: [BatchIntegrityReportService],
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject(
|
||||
[BatchIntegrityReportService],
|
||||
(service: BatchIntegrityReportService) => {
|
||||
expect(service).toBeTruthy();
|
||||
},
|
||||
));
|
||||
});
|
||||
@ -0,0 +1,27 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||
|
||||
import { BatchIntegrity } from './batch-integrity';
|
||||
|
||||
const url = '/api/batchIntegrity';
|
||||
const serviceName = 'BatchIntegrityReportService';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class BatchIntegrityReportService {
|
||||
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
|
||||
|
||||
batchIntegrity(): Observable<BatchIntegrity[]> {
|
||||
const url = '/api/batch-integrity';
|
||||
return this.http
|
||||
.post<BatchIntegrity[]>(url, {})
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'batchIntegrity'))) as Observable<
|
||||
BatchIntegrity[]
|
||||
>;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
import { inject, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { BatchIntegrityResolverService } from './batch-integrity-resolver.service';
|
||||
|
||||
describe('BatchIntegrityResolverService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [HttpClientModule],
|
||||
providers: [BatchIntegrityResolverService],
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject(
|
||||
[BatchIntegrityResolverService],
|
||||
(service: BatchIntegrityResolverService) => {
|
||||
expect(service).toBeTruthy();
|
||||
},
|
||||
));
|
||||
});
|
||||
@ -0,0 +1,17 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, Resolve } from '@angular/router';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
|
||||
import { BatchIntegrity } from './batch-integrity';
|
||||
import { BatchIntegrityReportService } from './batch-integrity-report.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class BatchIntegrityResolverService implements Resolve<BatchIntegrity[]> {
|
||||
constructor(private ser: BatchIntegrityReportService) {}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot): Observable<BatchIntegrity[]> {
|
||||
return this.ser.batchIntegrity();
|
||||
}
|
||||
}
|
||||
@ -1,14 +1,18 @@
|
||||
export class BatchDate {
|
||||
export class BatchIntegrity {
|
||||
product: string;
|
||||
batchDate: string;
|
||||
voucherDate: string;
|
||||
type: string;
|
||||
date: string;
|
||||
price: number;
|
||||
showing: number;
|
||||
actual: number;
|
||||
details: BatchDetail[];
|
||||
|
||||
public constructor(init?: Partial<BatchDate>) {
|
||||
public constructor(init?: Partial<BatchIntegrity>) {
|
||||
this.product = '';
|
||||
this.batchDate = '';
|
||||
this.voucherDate = '';
|
||||
this.type = '';
|
||||
this.date = '';
|
||||
this.price = 0;
|
||||
this.showing = 0;
|
||||
this.actual = 0;
|
||||
this.details = [];
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
@ -16,29 +20,16 @@ export class BatchDate {
|
||||
export class BatchDetail {
|
||||
date: string;
|
||||
type: string;
|
||||
url: string[];
|
||||
quantity: number;
|
||||
price: number;
|
||||
|
||||
public constructor(init?: Partial<BatchDetail>) {
|
||||
this.date = '';
|
||||
this.type = '';
|
||||
this.url = [];
|
||||
this.quantity = 0;
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export class IntegrityBatch {
|
||||
product: string;
|
||||
date: string;
|
||||
showing: number;
|
||||
actual: number;
|
||||
details: BatchDetail[];
|
||||
|
||||
public constructor(init?: Partial<IntegrityBatch>) {
|
||||
this.product = '';
|
||||
this.date = '';
|
||||
this.showing = 0;
|
||||
this.actual = 0;
|
||||
this.details = [];
|
||||
this.price = 0;
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
@ -33,6 +33,7 @@
|
||||
<a mat-menu-item routerLink="/closing-stock">Closing Stock</a>
|
||||
<a mat-menu-item routerLink="/stock-movement">Stock Movement</a>
|
||||
<a mat-menu-item routerLink="/rate-contracts">Rate Contracts</a>
|
||||
<a mat-menu-item routerLink="/batch-integrity-report">Batch Integrity</a>
|
||||
</mat-menu>
|
||||
<button mat-button [matMenuTriggerFor]="productReportMenu">Product Reports</button>
|
||||
|
||||
|
||||
@ -300,56 +300,6 @@
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</mat-tab>
|
||||
<mat-tab label="Integrity Check">
|
||||
<mat-card>
|
||||
<mat-card-content>
|
||||
<div
|
||||
fxLayout="row"
|
||||
fxLayoutAlign="space-around start"
|
||||
fxLayout.lt-md="column"
|
||||
fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px"
|
||||
>
|
||||
<button mat-raised-button color="warn" (click)="checkIntegrity()" fxFlex="100">
|
||||
Integrity Check
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
fxLayout="row"
|
||||
fxLayoutAlign="space-around start"
|
||||
fxLayout.lt-md="column"
|
||||
fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px"
|
||||
>
|
||||
<ul>
|
||||
<li *ngFor="let batch of batches">
|
||||
Batch of {{ batch.product }} dated {{ batch.date }} is showing
|
||||
{{ batch.showing }} instead of {{ batch.actual }}
|
||||
<ul>
|
||||
<li *ngFor="let detail of batch.details">
|
||||
{{ detail.type }} of {{ detail.quantity }} on {{ detail.date }}
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div
|
||||
fxLayout="row"
|
||||
fxLayoutAlign="space-around start"
|
||||
fxLayout.lt-md="column"
|
||||
fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px"
|
||||
>
|
||||
<ul>
|
||||
<li *ngFor="let batch of batchDates">
|
||||
{{ batch.type }} of {{ batch.product }} dated {{ batch.batchDate }} on
|
||||
{{ batch.voucherDate }}
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</mat-tab>
|
||||
<mat-tab label="Maintenance Mode">
|
||||
<mat-card>
|
||||
<mat-card-content>
|
||||
|
||||
@ -15,7 +15,6 @@ import { ToasterService } from '../core/toaster.service';
|
||||
import { ProductService } from '../product/product.service';
|
||||
import { ConfirmDialogComponent } from '../shared/confirm-dialog/confirm-dialog.component';
|
||||
|
||||
import { BatchDate, IntegrityBatch } from './integrity-batch';
|
||||
import { LockDataSource } from './lock-datasource';
|
||||
import { LockInfo } from './lock-info';
|
||||
import { SettingsService } from './settings.service';
|
||||
@ -45,8 +44,6 @@ export class SettingsComponent implements OnInit {
|
||||
product: Product = new Product();
|
||||
products: Observable<Product[]>;
|
||||
|
||||
batches: IntegrityBatch[] = [];
|
||||
batchDates: BatchDate[] = [];
|
||||
maintenance: { enabled: boolean; user: string };
|
||||
|
||||
displayedColumns = ['index', 'validity', 'voucherTypes', 'accountTypes', 'lock', 'action'];
|
||||
@ -291,19 +288,6 @@ export class SettingsComponent implements OnInit {
|
||||
);
|
||||
}
|
||||
|
||||
checkIntegrity() {
|
||||
this.ser.checkDatabaseIntegrity().subscribe(
|
||||
(x) => {
|
||||
this.batches = x.batches;
|
||||
this.batchDates = x.batchDates;
|
||||
this.toaster.show('Success', 'Database checked, it is fine!');
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Danger', error);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
toggleMaintenance() {
|
||||
this.ser.setMaintenance(!this.maintenance.enabled).subscribe((x) => {
|
||||
this.maintenance = x;
|
||||
|
||||
@ -6,7 +6,6 @@ import { catchError } from 'rxjs/operators';
|
||||
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||
import { Product } from '../core/product';
|
||||
|
||||
import { BatchDate, IntegrityBatch } from './integrity-batch';
|
||||
import { LockInfo } from './lock-info';
|
||||
|
||||
const serviceName = 'SettingsService';
|
||||
@ -83,21 +82,12 @@ export class SettingsService {
|
||||
}>;
|
||||
}
|
||||
|
||||
checkDatabaseIntegrity(): Observable<{
|
||||
attendanceCount: number;
|
||||
batches: IntegrityBatch[];
|
||||
batchDates: BatchDate[];
|
||||
}> {
|
||||
checkDatabaseIntegrity(): Observable<{ attendanceCount: number }> {
|
||||
const url = '/api/db-integrity';
|
||||
return this.http
|
||||
.post<{ attendanceCount: number; batches: IntegrityBatch[]; batchDates: BatchDate[] }>(
|
||||
url,
|
||||
{},
|
||||
)
|
||||
.post<{ attendanceCount: number }>(url, {})
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'checkDatabaseIntegrity'))) as Observable<{
|
||||
attendanceCount: number;
|
||||
batches: IntegrityBatch[];
|
||||
batchDates: BatchDate[];
|
||||
}>;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user