Fix: Raw material cost detail report borked on sort at the end as order was not in RawMaterialCost schema. Although it is not needed in the frontend, added it as optional.

This commit is contained in:
Amritanshu Agrawal 2020-12-11 07:47:36 +05:30
parent ccf2f704b6
commit 158f3e0e36
33 changed files with 70 additions and 41 deletions

@ -20,6 +20,7 @@ class RawMaterialCostItem(BaseModel):
quantity: Optional[Decimal]
net: Optional[Decimal]
gross: Optional[Decimal]
order: Optional[int]
heading: Optional[bool]

@ -55,7 +55,6 @@
"@typescript-eslint/eslint-plugin": "^4.9.0",
"@typescript-eslint/parser": "^4.9.0",
"eslint": "^7.14.0",
"eslint-config-airbnb-typescript": "^12.0.0",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsdoc": "^30.7.8",

@ -8,7 +8,8 @@ import { map, tap } from 'rxjs/operators';
import { Account } from '../../core/account';
/** Simple sort comparator for example ID/Name columns (for client-side sorting). */
const compare = (a: string | number | boolean, b: string | number | boolean, isAsc: boolean) => (a < b ? -1 : 1) * (isAsc ? 1 : -1);
const compare = (a: string | number | boolean, b: string | number | boolean, isAsc: boolean) =>
(a < b ? -1 : 1) * (isAsc ? 1 : -1);
export class AccountListDataSource extends DataSource<Account> {
private filterValue = '';

@ -8,7 +8,8 @@ import { map } from 'rxjs/operators';
import { BalanceSheetItem } from './balance-sheet-item';
/** 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);
export class BalanceSheetDataSource extends DataSource<BalanceSheetItem> {
constructor(
public data: BalanceSheetItem[],

@ -8,7 +8,8 @@ import { map } from 'rxjs/operators';
import { Client } from '../client';
/** 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);
export class ClientListDataSource extends DataSource<Client> {
constructor(public data: Client[], private paginator?: MatPaginator, private sort?: MatSort) {
super();

@ -8,7 +8,8 @@ import { map } from 'rxjs/operators';
import { ClosingStockItem } from './closing-stock-item';
/** 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);
export class ClosingStockDataSource extends DataSource<ClosingStockItem> {
constructor(
public data: ClosingStockItem[],

@ -8,7 +8,8 @@ import { map } from 'rxjs/operators';
import { CostCentre } from '../../core/cost-centre';
/** 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);
export class CostCentreListDataSource extends DataSource<CostCentre> {
constructor(public data: CostCentre[], private paginator?: MatPaginator, private sort?: MatSort) {
super();

@ -8,7 +8,8 @@ import { map } from 'rxjs/operators';
import { DaybookItem } from './daybook-item';
/** 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);
export class DaybookDataSource extends DataSource<DaybookItem> {
constructor(
public data: DaybookItem[],

@ -30,9 +30,7 @@ export class EmployeeAttendanceService {
return this.http
.get<EmployeeAttendance>(getUrl, options)
.pipe(
catchError(
this.log.handleError(serviceName, `get id=${id}`),
),
catchError(this.log.handleError(serviceName, `get id=${id}`)),
) as Observable<EmployeeAttendance>;
}

@ -198,7 +198,7 @@ export class EmployeeBenefitsComponent implements OnInit, AfterViewInit {
}
return (
this.voucher.user.id === (this.auth.user as User).id ||
this.auth.allowed('edit-other-user\'s-vouchers')
this.auth.allowed("edit-other-user's-vouchers")
);
}

@ -8,7 +8,8 @@ import { map, tap } from 'rxjs/operators';
import { Employee } from '../employee';
/** 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);
export class EmployeeListDataSource extends DataSource<Employee> {
private filterValue = '';

@ -134,7 +134,7 @@ export class IncentiveComponent implements OnInit {
}
return (
this.voucher.user.id === (this.auth.user as User).id ||
this.auth.allowed('edit-other-user\'s-vouchers')
this.auth.allowed("edit-other-user's-vouchers")
);
}

@ -262,7 +262,7 @@ export class IssueComponent implements OnInit, AfterViewInit, OnDestroy {
}
return (
this.voucher.user.id === (this.auth.user as User).id ||
this.auth.allowed('edit-other-user\'s-vouchers')
this.auth.allowed("edit-other-user's-vouchers")
);
}

@ -253,7 +253,7 @@ export class JournalComponent implements OnInit, AfterViewInit, OnDestroy {
}
return (
this.voucher.user.id === (this.auth.user as User).id ||
this.auth.allowed('edit-other-user\'s-vouchers')
this.auth.allowed("edit-other-user's-vouchers")
);
}

@ -8,7 +8,8 @@ import { map } from 'rxjs/operators';
import { LedgerItem } from './ledger-item';
/** 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);
export class LedgerDataSource extends DataSource<LedgerItem> {
constructor(public data: LedgerItem[], private paginator?: MatPaginator, private sort?: MatSort) {
super();

@ -8,7 +8,8 @@ import { map } from 'rxjs/operators';
import { NetTransactionsItem } from './net-transactions-item';
/** 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);
export class NetTransactionsDataSource extends DataSource<NetTransactionsItem> {
constructor(
public data: NetTransactionsItem[],

@ -265,7 +265,7 @@ export class PaymentComponent implements OnInit, AfterViewInit, OnDestroy {
}
return (
this.voucher.user.id === (this.auth.user as User).id ||
this.auth.allowed('edit-other-user\'s-vouchers')
this.auth.allowed("edit-other-user's-vouchers")
);
}

@ -8,7 +8,8 @@ import { map } from 'rxjs/operators';
import { ProductGroup } from '../../core/product-group';
/** 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);
export class ProductGroupListDataSource extends DataSource<ProductGroup> {
constructor(
public data: ProductGroup[],

@ -8,7 +8,8 @@ import { map } from 'rxjs/operators';
import { ProductLedgerItem } from './product-ledger-item';
/** 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);
export class ProductLedgerDataSource extends DataSource<ProductLedgerItem> {
constructor(
public data: ProductLedgerItem[],

@ -9,7 +9,8 @@ import { Product } from '../../core/product';
import { ProductGroup } from '../../core/product-group';
/** 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);
export class ProductListDataSource extends DataSource<Product> {
private filterValue = '';

@ -8,7 +8,8 @@ import { map } from 'rxjs/operators';
import { ProfitLossItem } from './profit-loss-item';
/** 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);
export class ProfitLossDataSource extends DataSource<ProfitLossItem> {
constructor(
public data: ProfitLossItem[],

@ -8,7 +8,8 @@ import { map } from 'rxjs/operators';
import { PurchaseEntriesItem } from './purchase-entries-item';
/** 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);
export class PurchaseEntriesDataSource extends DataSource<PurchaseEntriesItem> {
constructor(
public data: PurchaseEntriesItem[],

@ -260,7 +260,7 @@ export class PurchaseReturnComponent implements OnInit, AfterViewInit, OnDestroy
}
return (
this.voucher.user.id === (this.auth.user as User).id ||
this.auth.allowed('edit-other-user\'s-vouchers')
this.auth.allowed("edit-other-user's-vouchers")
);
}

@ -269,7 +269,7 @@ export class PurchaseComponent implements OnInit, AfterViewInit, OnDestroy {
}
return (
this.voucher.user.id === (this.auth.user as User).id ||
this.auth.allowed('edit-other-user\'s-vouchers')
this.auth.allowed("edit-other-user's-vouchers")
);
}

@ -8,7 +8,8 @@ import { map } from 'rxjs/operators';
import { PurchasesItem } from './purchases-item';
/** 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);
export class PurchasesDataSource extends DataSource<PurchasesItem> {
constructor(
public data: PurchasesItem[],

@ -8,7 +8,8 @@ import { map } from 'rxjs/operators';
import { RawMaterialCostItem } from './raw-material-cost-item';
/** 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);
export class RawMaterialCostDataSource extends DataSource<RawMaterialCostItem> {
constructor(
public data: RawMaterialCostItem[],

@ -264,7 +264,7 @@ export class ReceiptComponent implements OnInit, AfterViewInit, OnDestroy {
}
return (
this.voucher.user.id === (this.auth.user as User).id ||
this.auth.allowed('edit-other-user\'s-vouchers')
this.auth.allowed("edit-other-user's-vouchers")
);
}

@ -8,7 +8,8 @@ import { map } from 'rxjs/operators';
import { Role } from '../role';
/** 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);
export class RoleListDatasource extends DataSource<Role> {
constructor(public data: Role[], private paginator?: MatPaginator, private sort?: MatSort) {
super();

@ -56,28 +56,38 @@ export class SettingsService {
rebaseDatabase(date: string): Observable<Record<string, never>> {
const url = '/api/rebase';
return this.http
.post<Record<string, never>>(`${url}/${date}`, {})
.pipe(catchError(this.log.handleError(serviceName, 'rebaseDatabase'))) as Observable<Record<string, never>>;
.post<Record<string, never>>(`${url}/${date}`, {})
.pipe(catchError(this.log.handleError(serviceName, 'rebaseDatabase'))) as Observable<
Record<string, never>
>;
}
setMaintenance(enable: boolean): Observable<{ enabled: boolean; user: string }> {
const url = '/api/maintenance';
return this.http
.post<{ enabled: boolean; user: string }>(url, { enabled: enable })
.pipe(catchError(this.log.handleError(serviceName, 'setMaintenance'))) as Observable<{ enabled: boolean; user: string }>;
.pipe(catchError(this.log.handleError(serviceName, 'setMaintenance'))) as Observable<{
enabled: boolean;
user: string;
}>;
}
getMaintenance(): Observable<{ enabled: boolean; user: string }> {
const url = '/api/maintenance';
return this.http
.get<{ enabled: boolean; user: string }>(url)
.pipe(catchError(this.log.handleError(serviceName, 'getMaintenance'))) as Observable<{ enabled: boolean; user: string }>;
.get<{ enabled: boolean; user: string }>(url)
.pipe(catchError(this.log.handleError(serviceName, 'getMaintenance'))) as Observable<{
enabled: boolean;
user: string;
}>;
}
checkDatabaseIntegrity(): Observable<{ 'attendanceCount': number }> {
checkDatabaseIntegrity(): Observable<{ attendanceCount: number }> {
const url = '/api/db-integrity';
return this.http
.post<{ 'attendanceCount': number }>(url, {})
.pipe(catchError(this.log.handleError(serviceName, 'checkDatabaseIntegrity'))) as Observable<{ 'attendanceCount': number }>;
.post<{ attendanceCount: number }>(url, {})
.pipe(catchError(this.log.handleError(serviceName, 'checkDatabaseIntegrity'))) as Observable<{
attendanceCount: number;
}>;
}
}

@ -8,7 +8,8 @@ import { map } from 'rxjs/operators';
import { StockMovementItem } from './stock-movement-item';
/** 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);
export class StockMovementDataSource extends DataSource<StockMovementItem> {
constructor(
public data: StockMovementItem[],

@ -8,7 +8,8 @@ import { map } from 'rxjs/operators';
import { TrialBalanceItem } from './trial-balance-item';
/** 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);
export class TrialBalanceDataSource extends DataSource<TrialBalanceItem> {
constructor(
public data: TrialBalanceItem[],

@ -8,7 +8,8 @@ import { map } from 'rxjs/operators';
import { Unposted } from './unposted';
/** 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);
export class UnpostedDataSource extends DataSource<Unposted> {
constructor(public data: Unposted[], private paginator?: MatPaginator, private sort?: MatSort) {

@ -8,7 +8,8 @@ import { map } from 'rxjs/operators';
import { User } from '../../core/user';
/** 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);
export class UserListDataSource extends DataSource<User> {
constructor(public data: User[], private paginator?: MatPaginator, private sort?: MatSort) {