mirror of
https://github.com/frappe/books.git
synced 2024-12-23 11:29:03 +00:00
Merge pull request #525 from wahni-green/batch-wise-item
feat: batch-wise inventory
This commit is contained in:
commit
35179ec2eb
@ -137,7 +137,8 @@ export class BespokeQueries {
|
|||||||
item: string,
|
item: string,
|
||||||
location?: string,
|
location?: string,
|
||||||
fromDate?: string,
|
fromDate?: string,
|
||||||
toDate?: string
|
toDate?: string,
|
||||||
|
batchNumber?: string
|
||||||
): Promise<number | null> {
|
): Promise<number | null> {
|
||||||
const query = db.knex!(ModelNameEnum.StockLedgerEntry)
|
const query = db.knex!(ModelNameEnum.StockLedgerEntry)
|
||||||
.sum('quantity')
|
.sum('quantity')
|
||||||
@ -147,6 +148,10 @@ export class BespokeQueries {
|
|||||||
query.andWhere('location', location);
|
query.andWhere('location', location);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (batchNumber) {
|
||||||
|
query.andWhere('batchNumber', batchNumber);
|
||||||
|
}
|
||||||
|
|
||||||
if (fromDate) {
|
if (fromDate) {
|
||||||
query.andWhereRaw('datetime(date) > datetime(?)', [fromDate]);
|
query.andWhereRaw('datetime(date) > datetime(?)', [fromDate]);
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ import {
|
|||||||
DatabaseBase,
|
DatabaseBase,
|
||||||
DatabaseDemuxBase,
|
DatabaseDemuxBase,
|
||||||
GetAllOptions,
|
GetAllOptions,
|
||||||
QueryFilter
|
QueryFilter,
|
||||||
} from 'utils/db/types';
|
} from 'utils/db/types';
|
||||||
import { schemaTranslateables } from 'utils/translationHelpers';
|
import { schemaTranslateables } from 'utils/translationHelpers';
|
||||||
import { LanguageMap } from 'utils/types';
|
import { LanguageMap } from 'utils/types';
|
||||||
@ -19,7 +19,7 @@ import {
|
|||||||
DatabaseDemuxConstructor,
|
DatabaseDemuxConstructor,
|
||||||
DocValue,
|
DocValue,
|
||||||
DocValueMap,
|
DocValueMap,
|
||||||
RawValueMap
|
RawValueMap,
|
||||||
} from './types';
|
} from './types';
|
||||||
|
|
||||||
// Return types of Bespoke Queries
|
// Return types of Bespoke Queries
|
||||||
@ -312,14 +312,16 @@ export class DatabaseHandler extends DatabaseBase {
|
|||||||
item: string,
|
item: string,
|
||||||
location?: string,
|
location?: string,
|
||||||
fromDate?: string,
|
fromDate?: string,
|
||||||
toDate?: string
|
toDate?: string,
|
||||||
|
batchNumber?: string
|
||||||
): Promise<number | null> {
|
): Promise<number | null> {
|
||||||
return (await this.#demux.callBespoke(
|
return (await this.#demux.callBespoke(
|
||||||
'getStockQuantity',
|
'getStockQuantity',
|
||||||
item,
|
item,
|
||||||
location,
|
location,
|
||||||
fromDate,
|
fromDate,
|
||||||
toDate
|
toDate,
|
||||||
|
batchNumber
|
||||||
)) as number | null;
|
)) as number | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
13
models/baseModels/BatchNumber/BatchNumber.ts
Normal file
13
models/baseModels/BatchNumber/BatchNumber.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import { Doc } from 'fyo/model/doc';
|
||||||
|
import {
|
||||||
|
ListViewSettings,
|
||||||
|
} from 'fyo/model/types';
|
||||||
|
|
||||||
|
export class BatchNumber extends Doc {
|
||||||
|
static getListViewSettings(): ListViewSettings {
|
||||||
|
return {
|
||||||
|
columns: ["name", "expiryDate", "manufactureDate"],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -11,6 +11,7 @@ import {
|
|||||||
ValidationMap,
|
ValidationMap,
|
||||||
} from 'fyo/model/types';
|
} from 'fyo/model/types';
|
||||||
import { ValidationError } from 'fyo/utils/errors';
|
import { ValidationError } from 'fyo/utils/errors';
|
||||||
|
import { ModelNameEnum } from 'models/types';
|
||||||
import { Money } from 'pesa';
|
import { Money } from 'pesa';
|
||||||
import { AccountRootTypeEnum, AccountTypeEnum } from '../Account/types';
|
import { AccountRootTypeEnum, AccountTypeEnum } from '../Account/types';
|
||||||
|
|
||||||
@ -18,6 +19,7 @@ export class Item extends Doc {
|
|||||||
trackItem?: boolean;
|
trackItem?: boolean;
|
||||||
itemType?: 'Product' | 'Service';
|
itemType?: 'Product' | 'Service';
|
||||||
for?: 'Purchases' | 'Sales' | 'Both';
|
for?: 'Purchases' | 'Sales' | 'Both';
|
||||||
|
hasBatchNumber?: boolean;
|
||||||
|
|
||||||
formulas: FormulaMap = {
|
formulas: FormulaMap = {
|
||||||
incomeAccount: {
|
incomeAccount: {
|
||||||
@ -74,6 +76,29 @@ export class Item extends Doc {
|
|||||||
throw new ValidationError(this.fyo.t`Rate can't be negative.`);
|
throw new ValidationError(this.fyo.t`Rate can't be negative.`);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
hasBatchNumber: async (value: DocValue) => {
|
||||||
|
const { hasBatchNumber } = await this.fyo.db.get(
|
||||||
|
'Item',
|
||||||
|
this.name!,
|
||||||
|
'hasBatchNumber'
|
||||||
|
);
|
||||||
|
|
||||||
|
if (hasBatchNumber && value !== hasBatchNumber) {
|
||||||
|
const itemEntriesInSLE = await this.fyo.db.count(
|
||||||
|
ModelNameEnum.StockLedgerEntry,
|
||||||
|
{
|
||||||
|
filters: { item: this.name! },
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (itemEntriesInSLE > 0) {
|
||||||
|
throw new ValidationError(
|
||||||
|
this.fyo.t`Cannot change value of Has Batch No as Item ${this
|
||||||
|
.name!} already has transactions against it. `
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
static getActions(fyo: Fyo): Action[] {
|
static getActions(fyo: Fyo): Action[] {
|
||||||
@ -121,6 +146,7 @@ export class Item extends Doc {
|
|||||||
!this.fyo.singles.AccountingSettings?.enableInventory ||
|
!this.fyo.singles.AccountingSettings?.enableInventory ||
|
||||||
this.itemType !== 'Product' ||
|
this.itemType !== 'Product' ||
|
||||||
(this.inserted && !this.trackItem),
|
(this.inserted && !this.trackItem),
|
||||||
|
hasBatchNumber: () => !this.trackItem,
|
||||||
barcode: () => !this.fyo.singles.InventorySettings?.enableBarcodes,
|
barcode: () => !this.fyo.singles.InventorySettings?.enableBarcodes,
|
||||||
uomConversions: () => !this.fyo.singles.AccountingSettings?.enableInventory,
|
uomConversions: () => !this.fyo.singles.AccountingSettings?.enableInventory,
|
||||||
};
|
};
|
||||||
@ -129,5 +155,6 @@ export class Item extends Doc {
|
|||||||
unit: () => this.inserted,
|
unit: () => this.inserted,
|
||||||
itemType: () => this.inserted,
|
itemType: () => this.inserted,
|
||||||
trackItem: () => this.inserted,
|
trackItem: () => this.inserted,
|
||||||
|
hasBatchNumber: () => this.inserted,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -26,12 +26,14 @@ import { ShipmentItem } from './inventory/ShipmentItem';
|
|||||||
import { StockLedgerEntry } from './inventory/StockLedgerEntry';
|
import { StockLedgerEntry } from './inventory/StockLedgerEntry';
|
||||||
import { StockMovement } from './inventory/StockMovement';
|
import { StockMovement } from './inventory/StockMovement';
|
||||||
import { StockMovementItem } from './inventory/StockMovementItem';
|
import { StockMovementItem } from './inventory/StockMovementItem';
|
||||||
|
import { BatchNumber } from './baseModels/BatchNumber/BatchNumber';
|
||||||
|
|
||||||
export const models = {
|
export const models = {
|
||||||
Account,
|
Account,
|
||||||
AccountingLedgerEntry,
|
AccountingLedgerEntry,
|
||||||
AccountingSettings,
|
AccountingSettings,
|
||||||
Address,
|
Address,
|
||||||
|
BatchNumber,
|
||||||
Defaults,
|
Defaults,
|
||||||
Item,
|
Item,
|
||||||
JournalEntry,
|
JournalEntry,
|
||||||
|
@ -10,4 +10,5 @@ export class StockLedgerEntry extends Doc {
|
|||||||
location?: string;
|
location?: string;
|
||||||
referenceName?: string;
|
referenceName?: string;
|
||||||
referenceType?: string;
|
referenceType?: string;
|
||||||
|
batchNumber?: string;
|
||||||
}
|
}
|
||||||
|
@ -132,16 +132,54 @@ export class StockManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const date = details.date.toISOString();
|
const date = details.date.toISOString();
|
||||||
|
const formattedDate = this.fyo.format(details.date, 'Datetime');
|
||||||
|
const isItemHasBatchNumber = await this.fyo.getValue(
|
||||||
|
'Item',
|
||||||
|
details.item,
|
||||||
|
'hasBatchNumber'
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isItemHasBatchNumber && !this.isCancelled) {
|
||||||
|
if (!details.batchNumber) {
|
||||||
|
throw new ValidationError(
|
||||||
|
t`Please enter Batch Number for ${details.item}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const itemsInBatch =
|
||||||
|
(await this.fyo.db.getStockQuantity(
|
||||||
|
details.item,
|
||||||
|
details.fromLocation,
|
||||||
|
undefined,
|
||||||
|
date,
|
||||||
|
details.batchNumber
|
||||||
|
)) ?? 0;
|
||||||
|
|
||||||
|
if (details.quantity <= itemsInBatch) return;
|
||||||
|
|
||||||
|
throw new ValidationError(
|
||||||
|
[
|
||||||
|
t`Insufficient Quantity`,
|
||||||
|
t`Additional quantity (${
|
||||||
|
details.quantity - itemsInBatch
|
||||||
|
}) is required in batch ${
|
||||||
|
details.batchNumber
|
||||||
|
} to make the outward transfer of item ${details.item} from ${
|
||||||
|
details.fromLocation
|
||||||
|
} on ${formattedDate}`,
|
||||||
|
].join('\n')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
let quantityBefore =
|
let quantityBefore =
|
||||||
(await this.fyo.db.getStockQuantity(
|
(await this.fyo.db.getStockQuantity(
|
||||||
details.item,
|
details.item,
|
||||||
details.fromLocation,
|
details.fromLocation,
|
||||||
undefined,
|
undefined,
|
||||||
date
|
date,
|
||||||
|
undefined
|
||||||
)) ?? 0;
|
)) ?? 0;
|
||||||
|
|
||||||
const formattedDate = this.fyo.format(details.date, 'Datetime');
|
|
||||||
|
|
||||||
if (this.isCancelled) {
|
if (this.isCancelled) {
|
||||||
quantityBefore += details.quantity;
|
quantityBefore += details.quantity;
|
||||||
}
|
}
|
||||||
@ -162,7 +200,9 @@ export class StockManager {
|
|||||||
const quantityAfter = await this.fyo.db.getStockQuantity(
|
const quantityAfter = await this.fyo.db.getStockQuantity(
|
||||||
details.item,
|
details.item,
|
||||||
details.fromLocation,
|
details.fromLocation,
|
||||||
details.date.toISOString()
|
details.date.toISOString(),
|
||||||
|
undefined,
|
||||||
|
undefined
|
||||||
);
|
);
|
||||||
if (quantityAfter === null) {
|
if (quantityAfter === null) {
|
||||||
// No future transactions
|
// No future transactions
|
||||||
@ -204,6 +244,7 @@ class StockManagerItem {
|
|||||||
referenceType: string;
|
referenceType: string;
|
||||||
fromLocation?: string;
|
fromLocation?: string;
|
||||||
toLocation?: string;
|
toLocation?: string;
|
||||||
|
batchNumber?: string;
|
||||||
|
|
||||||
stockLedgerEntries?: StockLedgerEntry[];
|
stockLedgerEntries?: StockLedgerEntry[];
|
||||||
|
|
||||||
@ -218,6 +259,7 @@ class StockManagerItem {
|
|||||||
this.toLocation = details.toLocation;
|
this.toLocation = details.toLocation;
|
||||||
this.referenceName = details.referenceName;
|
this.referenceName = details.referenceName;
|
||||||
this.referenceType = details.referenceType;
|
this.referenceType = details.referenceType;
|
||||||
|
this.batchNumber = details.batchNumber;
|
||||||
|
|
||||||
this.fyo = fyo;
|
this.fyo = fyo;
|
||||||
}
|
}
|
||||||
@ -270,6 +312,7 @@ class StockManagerItem {
|
|||||||
date: this.date,
|
date: this.date,
|
||||||
item: this.item,
|
item: this.item,
|
||||||
rate: this.rate,
|
rate: this.rate,
|
||||||
|
batchNumber: this.batchNumber,
|
||||||
quantity,
|
quantity,
|
||||||
location,
|
location,
|
||||||
referenceName: this.referenceName,
|
referenceName: this.referenceName,
|
||||||
|
@ -109,6 +109,7 @@ export class StockMovement extends Transfer {
|
|||||||
item: row.item!,
|
item: row.item!,
|
||||||
rate: row.rate!,
|
rate: row.rate!,
|
||||||
quantity: row.quantity!,
|
quantity: row.quantity!,
|
||||||
|
batchNumber: row.batchNumber!,
|
||||||
fromLocation: row.fromLocation,
|
fromLocation: row.fromLocation,
|
||||||
toLocation: row.toLocation,
|
toLocation: row.toLocation,
|
||||||
}));
|
}));
|
||||||
|
@ -30,6 +30,7 @@ export class StockMovementItem extends Doc {
|
|||||||
rate?: Money;
|
rate?: Money;
|
||||||
amount?: Money;
|
amount?: Money;
|
||||||
parentdoc?: StockMovement;
|
parentdoc?: StockMovement;
|
||||||
|
batchNumber?: string;
|
||||||
|
|
||||||
get isIssue() {
|
get isIssue() {
|
||||||
return this.parentdoc?.movementType === MovementType.MaterialIssue;
|
return this.parentdoc?.movementType === MovementType.MaterialIssue;
|
||||||
|
@ -82,6 +82,7 @@ export abstract class StockTransfer extends Transfer {
|
|||||||
item: row.item!,
|
item: row.item!,
|
||||||
rate: row.rate!,
|
rate: row.rate!,
|
||||||
quantity: row.quantity!,
|
quantity: row.quantity!,
|
||||||
|
batchNumber: row.batchNumber!,
|
||||||
fromLocation,
|
fromLocation,
|
||||||
toLocation,
|
toLocation,
|
||||||
};
|
};
|
||||||
|
@ -21,6 +21,7 @@ export class StockTransferItem extends Doc {
|
|||||||
amount?: Money;
|
amount?: Money;
|
||||||
description?: string;
|
description?: string;
|
||||||
hsnCode?: number;
|
hsnCode?: number;
|
||||||
|
batchNumber?: string
|
||||||
|
|
||||||
formulas: FormulaMap = {
|
formulas: FormulaMap = {
|
||||||
description: {
|
description: {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { Fyo } from 'fyo';
|
import { Fyo } from 'fyo';
|
||||||
|
import { BatchNumber } from 'models/baseModels/BatchNumber/BatchNumber';
|
||||||
import { ModelNameEnum } from 'models/types';
|
import { ModelNameEnum } from 'models/types';
|
||||||
import { StockMovement } from '../StockMovement';
|
import { StockMovement } from '../StockMovement';
|
||||||
import { StockTransfer } from '../StockTransfer';
|
import { StockTransfer } from '../StockTransfer';
|
||||||
@ -26,6 +27,7 @@ type Transfer = {
|
|||||||
item: string;
|
item: string;
|
||||||
from?: string;
|
from?: string;
|
||||||
to?: string;
|
to?: string;
|
||||||
|
batchNumber?: string;
|
||||||
quantity: number;
|
quantity: number;
|
||||||
rate: number;
|
rate: number;
|
||||||
};
|
};
|
||||||
@ -34,8 +36,23 @@ interface TransferTwo extends Omit<Transfer, 'from' | 'to'> {
|
|||||||
location: string;
|
location: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getItem(name: string, rate: number) {
|
export function getItem(name: string, rate: number, hasBatchNumber?: boolean) {
|
||||||
return { name, rate, trackItem: true };
|
return { name, rate, trackItem: true, hasBatchNumber };
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getBatchNumber(
|
||||||
|
schemaName: ModelNameEnum.BatchNumber,
|
||||||
|
batchNumber: string,
|
||||||
|
expiryDate: Date,
|
||||||
|
manufactureDate: Date,
|
||||||
|
fyo: Fyo
|
||||||
|
): Promise<BatchNumber> {
|
||||||
|
const doc = fyo.doc.getNewDoc(schemaName, {
|
||||||
|
batchNumber,
|
||||||
|
expiryDate,
|
||||||
|
manufactureDate,
|
||||||
|
}) as BatchNumber;
|
||||||
|
return doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getStockTransfer(
|
export async function getStockTransfer(
|
||||||
@ -62,11 +79,11 @@ export async function getStockMovement(
|
|||||||
movementType,
|
movementType,
|
||||||
date,
|
date,
|
||||||
}) as StockMovement;
|
}) as StockMovement;
|
||||||
|
|
||||||
for (const {
|
for (const {
|
||||||
item,
|
item,
|
||||||
from: fromLocation,
|
from: fromLocation,
|
||||||
to: toLocation,
|
to: toLocation,
|
||||||
|
batchNumber: batchNumber,
|
||||||
quantity,
|
quantity,
|
||||||
rate,
|
rate,
|
||||||
} of transfers) {
|
} of transfers) {
|
||||||
@ -74,6 +91,7 @@ export async function getStockMovement(
|
|||||||
item,
|
item,
|
||||||
fromLocation,
|
fromLocation,
|
||||||
toLocation,
|
toLocation,
|
||||||
|
batchNumber,
|
||||||
rate,
|
rate,
|
||||||
quantity,
|
quantity,
|
||||||
});
|
});
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
assertDoesNotThrow,
|
assertDoesNotThrow,
|
||||||
assertThrows
|
assertThrows,
|
||||||
} from 'backend/database/tests/helpers';
|
} from 'backend/database/tests/helpers';
|
||||||
import { ModelNameEnum } from 'models/types';
|
import { ModelNameEnum } from 'models/types';
|
||||||
import { default as tape, default as test } from 'tape';
|
import { default as tape, default as test } from 'tape';
|
||||||
@ -17,10 +17,12 @@ const itemMap = {
|
|||||||
Pen: {
|
Pen: {
|
||||||
name: 'Pen',
|
name: 'Pen',
|
||||||
rate: 700,
|
rate: 700,
|
||||||
|
hasBatchNumber: true,
|
||||||
},
|
},
|
||||||
Ink: {
|
Ink: {
|
||||||
name: 'Ink',
|
name: 'Ink',
|
||||||
rate: 50,
|
rate: 50,
|
||||||
|
hasBatchNumber: false,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -29,14 +31,22 @@ const locationMap = {
|
|||||||
LocationTwo: 'LocationTwo',
|
LocationTwo: 'LocationTwo',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const batchNumberMap = {
|
||||||
|
batchNumberOne: {
|
||||||
|
name: 'IK-AB001',
|
||||||
|
manufactureDate: '2022-11-03T09:57:04.528',
|
||||||
|
expiryDate: '2023-11-03T09:57:04.528',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Section 1: Test Creation of Items and Locations
|
* Section 1: Test Creation of Items and Locations
|
||||||
*/
|
*/
|
||||||
|
|
||||||
test('create dummy items & locations', async (t) => {
|
test('create dummy items & locations', async (t) => {
|
||||||
// Create Items
|
// Create Items
|
||||||
for (const { name, rate } of Object.values(itemMap)) {
|
for (const { name, rate, hasBatchNumber } of Object.values(itemMap)) {
|
||||||
const item = getItem(name, rate);
|
const item = getItem(name, rate, hasBatchNumber);
|
||||||
await fyo.doc.getNewDoc(ModelNameEnum.Item, item).sync();
|
await fyo.doc.getNewDoc(ModelNameEnum.Item, item).sync();
|
||||||
t.ok(await fyo.db.exists(ModelNameEnum.Item, name), `${name} exists`);
|
t.ok(await fyo.db.exists(ModelNameEnum.Item, name), `${name} exists`);
|
||||||
}
|
}
|
||||||
@ -48,6 +58,25 @@ test('create dummy items & locations', async (t) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('create dummy batch numbers', async (t) => {
|
||||||
|
// create batchNumber
|
||||||
|
for (const { name, manufactureDate, expiryDate } of Object.values(
|
||||||
|
batchNumberMap
|
||||||
|
)) {
|
||||||
|
await fyo.doc
|
||||||
|
.getNewDoc(ModelNameEnum.BatchNumber, {
|
||||||
|
name,
|
||||||
|
expiryDate,
|
||||||
|
manufactureDate,
|
||||||
|
})
|
||||||
|
.sync();
|
||||||
|
t.ok(
|
||||||
|
await fyo.db.exists(ModelNameEnum.BatchNumber, name),
|
||||||
|
`${name} exists`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Section 2: Test Creation of Stock Movements
|
* Section 2: Test Creation of Stock Movements
|
||||||
*/
|
*/
|
||||||
@ -90,6 +119,55 @@ test('create stock movement, material receipt', async (t) => {
|
|||||||
t.equal(await fyo.db.getStockQuantity(itemMap.Ink.name), quantity);
|
t.equal(await fyo.db.getStockQuantity(itemMap.Ink.name), quantity);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Batch Enabled : create stock movement, material receipt', async (t) => {
|
||||||
|
const { rate } = itemMap.Pen;
|
||||||
|
const quantity = 2;
|
||||||
|
const batchNumber = batchNumberMap.batchNumberOne.name;
|
||||||
|
const amount = rate * quantity;
|
||||||
|
const stockMovement = await getStockMovement(
|
||||||
|
MovementType.MaterialReceipt,
|
||||||
|
new Date('2022-11-03T09:57:04.528'),
|
||||||
|
[
|
||||||
|
{
|
||||||
|
item: itemMap.Pen.name,
|
||||||
|
to: locationMap.LocationOne,
|
||||||
|
quantity,
|
||||||
|
batchNumber,
|
||||||
|
rate,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
fyo
|
||||||
|
);
|
||||||
|
|
||||||
|
await (await stockMovement.sync()).submit();
|
||||||
|
t.ok(stockMovement.name?.startsWith('SMOV-'));
|
||||||
|
t.equal(stockMovement.amount?.float, amount);
|
||||||
|
t.equal(stockMovement.items?.[0].amount?.float, amount);
|
||||||
|
|
||||||
|
const name = stockMovement.name!;
|
||||||
|
|
||||||
|
const sles = await getSLEs(name, ModelNameEnum.StockMovement, fyo);
|
||||||
|
t.equal(sles.length, 1);
|
||||||
|
|
||||||
|
const sle = sles[0];
|
||||||
|
t.notEqual(new Date(sle.date).toString(), 'Invalid Date');
|
||||||
|
t.equal(parseInt(sle.name), 2);
|
||||||
|
t.equal(sle.item, itemMap.Pen.name);
|
||||||
|
t.equal(parseFloat(sle.rate), rate);
|
||||||
|
t.equal(sle.quantity, quantity);
|
||||||
|
t.equal(sle.location, locationMap.LocationOne);
|
||||||
|
t.equal(
|
||||||
|
await fyo.db.getStockQuantity(
|
||||||
|
itemMap.Pen.name,
|
||||||
|
locationMap.LocationOne,
|
||||||
|
undefined,
|
||||||
|
undefined,
|
||||||
|
batchNumber
|
||||||
|
),
|
||||||
|
quantity
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
test('create stock movement, material transfer', async (t) => {
|
test('create stock movement, material transfer', async (t) => {
|
||||||
const { rate } = itemMap.Ink;
|
const { rate } = itemMap.Ink;
|
||||||
const quantity = 2;
|
const quantity = 2;
|
||||||
@ -136,6 +214,69 @@ test('create stock movement, material transfer', async (t) => {
|
|||||||
t.equal(await fyo.db.getStockQuantity(itemMap.Ink.name), quantity);
|
t.equal(await fyo.db.getStockQuantity(itemMap.Ink.name), quantity);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Batch Enabled create stock movement, material transfer', async (t) => {
|
||||||
|
const { rate } = itemMap.Pen;
|
||||||
|
const quantity = 2;
|
||||||
|
const batchNumber = batchNumberMap.batchNumberOne.name;
|
||||||
|
|
||||||
|
const stockMovement = await getStockMovement(
|
||||||
|
MovementType.MaterialTransfer,
|
||||||
|
new Date('2022-11-03T09:58:04.528'),
|
||||||
|
[
|
||||||
|
{
|
||||||
|
item: itemMap.Pen.name,
|
||||||
|
from: locationMap.LocationOne,
|
||||||
|
to: locationMap.LocationTwo,
|
||||||
|
batchNumber,
|
||||||
|
quantity,
|
||||||
|
rate,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
fyo
|
||||||
|
);
|
||||||
|
|
||||||
|
await (await stockMovement.sync()).submit();
|
||||||
|
const name = stockMovement.name!;
|
||||||
|
|
||||||
|
const sles = await getSLEs(name, ModelNameEnum.StockMovement, fyo);
|
||||||
|
t.equal(sles.length, 2);
|
||||||
|
|
||||||
|
for (const sle of sles) {
|
||||||
|
t.notEqual(new Date(sle.date).toString(), 'Invalid Date');
|
||||||
|
t.equal(sle.item, itemMap.Pen.name);
|
||||||
|
t.equal(parseFloat(sle.rate), rate);
|
||||||
|
|
||||||
|
if (sle.location === locationMap.LocationOne) {
|
||||||
|
t.equal(sle.quantity, -quantity);
|
||||||
|
} else if (sle.location === locationMap.LocationTwo) {
|
||||||
|
t.equal(sle.quantity, quantity);
|
||||||
|
} else {
|
||||||
|
t.ok(false, 'no-op');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
t.equal(
|
||||||
|
await fyo.db.getStockQuantity(
|
||||||
|
itemMap.Pen.name,
|
||||||
|
locationMap.LocationOne,
|
||||||
|
undefined,
|
||||||
|
undefined,
|
||||||
|
batchNumber
|
||||||
|
),
|
||||||
|
0
|
||||||
|
);
|
||||||
|
t.equal(
|
||||||
|
await fyo.db.getStockQuantity(
|
||||||
|
itemMap.Pen.name,
|
||||||
|
locationMap.LocationTwo,
|
||||||
|
undefined,
|
||||||
|
undefined,
|
||||||
|
batchNumber
|
||||||
|
),
|
||||||
|
quantity
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
test('create stock movement, material issue', async (t) => {
|
test('create stock movement, material issue', async (t) => {
|
||||||
const { rate } = itemMap.Ink;
|
const { rate } = itemMap.Ink;
|
||||||
const quantity = 2;
|
const quantity = 2;
|
||||||
@ -169,6 +310,50 @@ test('create stock movement, material issue', async (t) => {
|
|||||||
t.equal(await fyo.db.getStockQuantity(itemMap.Ink.name), 0);
|
t.equal(await fyo.db.getStockQuantity(itemMap.Ink.name), 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Batch Enabled create stock movement, material issue', async (t) => {
|
||||||
|
const { rate } = itemMap.Pen;
|
||||||
|
const quantity = 2;
|
||||||
|
const batchNumber = batchNumberMap.batchNumberOne.name;
|
||||||
|
|
||||||
|
const stockMovement = await getStockMovement(
|
||||||
|
MovementType.MaterialIssue,
|
||||||
|
new Date('2022-11-03T09:59:04.528'),
|
||||||
|
[
|
||||||
|
{
|
||||||
|
item: itemMap.Pen.name,
|
||||||
|
from: locationMap.LocationTwo,
|
||||||
|
batchNumber,
|
||||||
|
quantity,
|
||||||
|
rate,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
fyo
|
||||||
|
);
|
||||||
|
|
||||||
|
await (await stockMovement.sync()).submit();
|
||||||
|
const name = stockMovement.name!;
|
||||||
|
|
||||||
|
const sles = await getSLEs(name, ModelNameEnum.StockMovement, fyo);
|
||||||
|
t.equal(sles.length, 1);
|
||||||
|
|
||||||
|
const sle = sles[0];
|
||||||
|
t.notEqual(new Date(sle.date).toString(), 'Invalid Date');
|
||||||
|
t.equal(sle.item, itemMap.Pen.name);
|
||||||
|
t.equal(parseFloat(sle.rate), rate);
|
||||||
|
t.equal(sle.quantity, -quantity);
|
||||||
|
t.equal(sle.location, locationMap.LocationTwo);
|
||||||
|
t.equal(
|
||||||
|
await fyo.db.getStockQuantity(
|
||||||
|
itemMap.Pen.name,
|
||||||
|
undefined,
|
||||||
|
undefined,
|
||||||
|
undefined,
|
||||||
|
batchNumber
|
||||||
|
),
|
||||||
|
0
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Section 3: Test Cancellation of Stock Movements
|
* Section 3: Test Cancellation of Stock Movements
|
||||||
*/
|
*/
|
||||||
@ -214,6 +399,7 @@ async function runEntries(
|
|||||||
item: string;
|
item: string;
|
||||||
to?: string;
|
to?: string;
|
||||||
from?: string;
|
from?: string;
|
||||||
|
batchNumber?: string;
|
||||||
quantity: number;
|
quantity: number;
|
||||||
rate: number;
|
rate: number;
|
||||||
}[];
|
}[];
|
||||||
@ -235,7 +421,7 @@ async function runEntries(
|
|||||||
}
|
}
|
||||||
|
|
||||||
test('create stock movements, invalid entries, in sequence', async (t) => {
|
test('create stock movements, invalid entries, in sequence', async (t) => {
|
||||||
const { name: item, rate } = itemMap.Ink;
|
const { name: item, rate } = itemMap.Pen;
|
||||||
const quantity = 10;
|
const quantity = 10;
|
||||||
await runEntries(
|
await runEntries(
|
||||||
item,
|
item,
|
||||||
@ -249,6 +435,7 @@ test('create stock movements, invalid entries, in sequence', async (t) => {
|
|||||||
{
|
{
|
||||||
item,
|
item,
|
||||||
to: locationMap.LocationOne,
|
to: locationMap.LocationOne,
|
||||||
|
batchNumber: batchNumberMap.batchNumberOne.name,
|
||||||
quantity,
|
quantity,
|
||||||
rate,
|
rate,
|
||||||
},
|
},
|
||||||
@ -264,6 +451,7 @@ test('create stock movements, invalid entries, in sequence', async (t) => {
|
|||||||
item,
|
item,
|
||||||
from: locationMap.LocationOne,
|
from: locationMap.LocationOne,
|
||||||
to: locationMap.LocationTwo,
|
to: locationMap.LocationTwo,
|
||||||
|
batchNumber: batchNumberMap.batchNumberOne.name,
|
||||||
quantity: quantity + 1,
|
quantity: quantity + 1,
|
||||||
rate,
|
rate,
|
||||||
},
|
},
|
||||||
@ -278,6 +466,7 @@ test('create stock movements, invalid entries, in sequence', async (t) => {
|
|||||||
{
|
{
|
||||||
item,
|
item,
|
||||||
from: locationMap.LocationOne,
|
from: locationMap.LocationOne,
|
||||||
|
batchNumber: batchNumberMap.batchNumberOne.name,
|
||||||
quantity: quantity + 1,
|
quantity: quantity + 1,
|
||||||
rate,
|
rate,
|
||||||
},
|
},
|
||||||
@ -292,6 +481,7 @@ test('create stock movements, invalid entries, in sequence', async (t) => {
|
|||||||
{
|
{
|
||||||
item,
|
item,
|
||||||
from: locationMap.LocationOne,
|
from: locationMap.LocationOne,
|
||||||
|
batchNumber: batchNumberMap.batchNumberOne.name,
|
||||||
to: locationMap.LocationTwo,
|
to: locationMap.LocationTwo,
|
||||||
quantity,
|
quantity,
|
||||||
rate,
|
rate,
|
||||||
@ -307,6 +497,7 @@ test('create stock movements, invalid entries, in sequence', async (t) => {
|
|||||||
{
|
{
|
||||||
item,
|
item,
|
||||||
from: locationMap.LocationTwo,
|
from: locationMap.LocationTwo,
|
||||||
|
batchNumber: batchNumberMap.batchNumberOne.name,
|
||||||
quantity,
|
quantity,
|
||||||
rate,
|
rate,
|
||||||
},
|
},
|
||||||
@ -371,4 +562,28 @@ test('create stock movements, invalid entries, out of sequence', async (t) => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('create stock movements, material issue, insufficient quantity', async (t) => {
|
||||||
|
const { name, rate } = itemMap.Pen;
|
||||||
|
const quantity = 2;
|
||||||
|
const batchNumber = batchNumberMap.batchNumberOne.name;
|
||||||
|
|
||||||
|
const stockMovement = await getStockMovement(
|
||||||
|
MovementType.MaterialIssue,
|
||||||
|
new Date('2022-11-03T09:59:04.528'),
|
||||||
|
[
|
||||||
|
{
|
||||||
|
item: itemMap.Pen.name,
|
||||||
|
from: locationMap.LocationTwo,
|
||||||
|
batchNumber,
|
||||||
|
quantity,
|
||||||
|
rate,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
fyo
|
||||||
|
);
|
||||||
|
|
||||||
|
await assertThrows(async () => (await stockMovement.sync()).submit());
|
||||||
|
t.equal(await fyo.db.getStockQuantity(name), 0);
|
||||||
|
});
|
||||||
|
|
||||||
closeTestFyo(fyo, __filename);
|
closeTestFyo(fyo, __filename);
|
||||||
|
@ -22,6 +22,7 @@ export interface SMTransferDetails {
|
|||||||
item: string;
|
item: string;
|
||||||
rate: Money;
|
rate: Money;
|
||||||
quantity: number;
|
quantity: number;
|
||||||
|
batchNumber?: string;
|
||||||
fromLocation?: string;
|
fromLocation?: string;
|
||||||
toLocation?: string;
|
toLocation?: string;
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ export enum ModelNameEnum {
|
|||||||
AccountingLedgerEntry = 'AccountingLedgerEntry',
|
AccountingLedgerEntry = 'AccountingLedgerEntry',
|
||||||
AccountingSettings = 'AccountingSettings',
|
AccountingSettings = 'AccountingSettings',
|
||||||
Address = 'Address',
|
Address = 'Address',
|
||||||
|
BatchNumber= 'BatchNumber',
|
||||||
Color = 'Color',
|
Color = 'Color',
|
||||||
CompanySettings = 'CompanySettings',
|
CompanySettings = 'CompanySettings',
|
||||||
Currency = 'Currency',
|
Currency = 'Currency',
|
||||||
|
@ -260,6 +260,11 @@ export class StockLedger extends Report {
|
|||||||
label: 'Location',
|
label: 'Location',
|
||||||
fieldtype: 'Link',
|
fieldtype: 'Link',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
fieldname: 'batchNumber',
|
||||||
|
label: 'Batch No.',
|
||||||
|
fieldtype: 'Link',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
fieldname: 'quantity',
|
fieldname: 'quantity',
|
||||||
label: 'Quantity',
|
label: 'Quantity',
|
||||||
|
@ -17,6 +17,7 @@ export async function getRawStockLedgerEntries(fyo: Fyo) {
|
|||||||
'name',
|
'name',
|
||||||
'date',
|
'date',
|
||||||
'item',
|
'item',
|
||||||
|
'batchNumber',
|
||||||
'rate',
|
'rate',
|
||||||
'quantity',
|
'quantity',
|
||||||
'location',
|
'location',
|
||||||
@ -42,7 +43,14 @@ export function getStockLedgerEntries(
|
|||||||
const name = safeParseInt(sle.name);
|
const name = safeParseInt(sle.name);
|
||||||
const date = new Date(sle.date);
|
const date = new Date(sle.date);
|
||||||
const rate = safeParseFloat(sle.rate);
|
const rate = safeParseFloat(sle.rate);
|
||||||
const { item, location, quantity, referenceName, referenceType } = sle;
|
const {
|
||||||
|
item,
|
||||||
|
location,
|
||||||
|
batchNumber,
|
||||||
|
quantity,
|
||||||
|
referenceName,
|
||||||
|
referenceType,
|
||||||
|
} = sle;
|
||||||
|
|
||||||
if (quantity === 0) {
|
if (quantity === 0) {
|
||||||
continue;
|
continue;
|
||||||
@ -80,6 +88,7 @@ export function getStockLedgerEntries(
|
|||||||
|
|
||||||
item,
|
item,
|
||||||
location,
|
location,
|
||||||
|
batchNumber,
|
||||||
|
|
||||||
quantity,
|
quantity,
|
||||||
balanceQuantity,
|
balanceQuantity,
|
||||||
@ -124,7 +133,11 @@ export function getStockBalanceEntries(
|
|||||||
}
|
}
|
||||||
|
|
||||||
sbeMap[sle.item] ??= {};
|
sbeMap[sle.item] ??= {};
|
||||||
sbeMap[sle.item][sle.location] ??= getSBE(sle.item, sle.location);
|
sbeMap[sle.item][sle.location] ??= getSBE(
|
||||||
|
sle.item,
|
||||||
|
sle.location,
|
||||||
|
sle.batchNumber
|
||||||
|
);
|
||||||
const date = sle.date.valueOf();
|
const date = sle.date.valueOf();
|
||||||
|
|
||||||
if (fromDate && date < fromDate) {
|
if (fromDate && date < fromDate) {
|
||||||
@ -146,12 +159,17 @@ export function getStockBalanceEntries(
|
|||||||
.flat();
|
.flat();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSBE(item: string, location: string): StockBalanceEntry {
|
function getSBE(
|
||||||
|
item: string,
|
||||||
|
location: string,
|
||||||
|
batchNumber: string
|
||||||
|
): StockBalanceEntry {
|
||||||
return {
|
return {
|
||||||
name: 0,
|
name: 0,
|
||||||
|
|
||||||
item,
|
item,
|
||||||
location,
|
location,
|
||||||
|
batchNumber,
|
||||||
|
|
||||||
balanceQuantity: 0,
|
balanceQuantity: 0,
|
||||||
balanceValue: 0,
|
balanceValue: 0,
|
||||||
|
@ -5,6 +5,7 @@ export interface RawStockLedgerEntry {
|
|||||||
date: string;
|
date: string;
|
||||||
item: string;
|
item: string;
|
||||||
rate: string;
|
rate: string;
|
||||||
|
batchNumber: string;
|
||||||
quantity: number;
|
quantity: number;
|
||||||
location: string;
|
location: string;
|
||||||
referenceName: string;
|
referenceName: string;
|
||||||
@ -19,6 +20,7 @@ export interface ComputedStockLedgerEntry{
|
|||||||
|
|
||||||
item: string;
|
item: string;
|
||||||
location:string;
|
location:string;
|
||||||
|
batchNumber: string;
|
||||||
|
|
||||||
quantity: number;
|
quantity: number;
|
||||||
balanceQuantity: number;
|
balanceQuantity: number;
|
||||||
@ -39,6 +41,7 @@ export interface StockBalanceEntry{
|
|||||||
|
|
||||||
item: string;
|
item: string;
|
||||||
location:string;
|
location:string;
|
||||||
|
batchNumber: string;
|
||||||
|
|
||||||
balanceQuantity: number;
|
balanceQuantity: number;
|
||||||
balanceValue: number;
|
balanceValue: number;
|
||||||
|
27
schemas/app/BatchNumber.json
Normal file
27
schemas/app/BatchNumber.json
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"name": "BatchNumber",
|
||||||
|
"label": "Batch Number",
|
||||||
|
"naming": "manual",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldname": "name",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Batch Number",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "expiryDate",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"label": "Expiry Date",
|
||||||
|
"required": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "manufactureDate",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"label": "Manufacture Date",
|
||||||
|
"required": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"quickEditFields": ["expiryDate", "manufactureDate"],
|
||||||
|
"keywordFields": ["name"]
|
||||||
|
}
|
@ -47,6 +47,14 @@
|
|||||||
"placeholder": "Unit",
|
"placeholder": "Unit",
|
||||||
"readOnly": true
|
"readOnly": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "batchNumber",
|
||||||
|
"label": "Batch No",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"create": true,
|
||||||
|
"target": "BatchNumber",
|
||||||
|
"placeholder": "Batch No"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "quantity",
|
"fieldname": "quantity",
|
||||||
"label": "Quantity",
|
"label": "Quantity",
|
||||||
@ -126,7 +134,7 @@
|
|||||||
"readOnly": true
|
"readOnly": true
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"tableFields": ["item", "tax", "quantity", "rate", "amount"],
|
"tableFields": ["item", "tax", "batchNumber", "quantity", "rate", "amount"],
|
||||||
"keywordFields": ["item", "tax"],
|
"keywordFields": ["item", "tax"],
|
||||||
"quickEditFields": [
|
"quickEditFields": [
|
||||||
"item",
|
"item",
|
||||||
@ -138,6 +146,7 @@
|
|||||||
|
|
||||||
"transferQuantity",
|
"transferQuantity",
|
||||||
"transferUnit",
|
"transferUnit",
|
||||||
|
"batchNumber",
|
||||||
"quantity",
|
"quantity",
|
||||||
"unit",
|
"unit",
|
||||||
"unitConversionFactor",
|
"unitConversionFactor",
|
||||||
|
@ -131,6 +131,13 @@
|
|||||||
"section": "Inventory",
|
"section": "Inventory",
|
||||||
"default": false
|
"default": false
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "hasBatchNumber",
|
||||||
|
"label": "Has Batch No",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"default": false,
|
||||||
|
"section": "Inventory"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "uomConversions",
|
"fieldname": "uomConversions",
|
||||||
"label": "UOM Conversions",
|
"label": "UOM Conversions",
|
||||||
@ -151,6 +158,7 @@
|
|||||||
"barcode",
|
"barcode",
|
||||||
"hsnCode",
|
"hsnCode",
|
||||||
"trackItem",
|
"trackItem",
|
||||||
|
"hasBatchNumber",
|
||||||
"uom"
|
"uom"
|
||||||
],
|
],
|
||||||
"keywordFields": ["name", "itemType", "for"]
|
"keywordFields": ["name", "itemType", "for"]
|
||||||
|
@ -29,6 +29,11 @@
|
|||||||
"label": "Display Tax Invoice",
|
"label": "Display Tax Invoice",
|
||||||
"fieldtype": "Check"
|
"fieldtype": "Check"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "displayBatchNumber",
|
||||||
|
"label": "Display Batch Number",
|
||||||
|
"fieldtype": "Check"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "phone",
|
"fieldname": "phone",
|
||||||
"label": "Phone",
|
"label": "Phone",
|
||||||
@ -138,6 +143,7 @@
|
|||||||
"logo",
|
"logo",
|
||||||
"displayLogo",
|
"displayLogo",
|
||||||
"displayTaxInvoice",
|
"displayTaxInvoice",
|
||||||
|
"displayBatchNumber",
|
||||||
"template",
|
"template",
|
||||||
"color",
|
"color",
|
||||||
"font",
|
"font",
|
||||||
|
@ -49,6 +49,13 @@
|
|||||||
"label": "Ref. Type",
|
"label": "Ref. Type",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"readOnly": true
|
"readOnly": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "batchNumber",
|
||||||
|
"label": "Batch No",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"target": "BatchNumber",
|
||||||
|
"readOnly": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,13 @@
|
|||||||
"placeholder": "Unit",
|
"placeholder": "Unit",
|
||||||
"readOnly": true
|
"readOnly": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "batchNumber",
|
||||||
|
"label": "Batch No",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"target": "BatchNumber",
|
||||||
|
"create": true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "quantity",
|
"fieldname": "quantity",
|
||||||
"label": "Quantity",
|
"label": "Quantity",
|
||||||
@ -77,7 +84,7 @@
|
|||||||
"readOnly": true
|
"readOnly": true
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"tableFields": ["item", "fromLocation", "toLocation", "quantity", "rate"],
|
"tableFields": ["item", "fromLocation", "toLocation", "batchNumber", "quantity", "rate"],
|
||||||
"keywordFields": ["item"],
|
"keywordFields": ["item"],
|
||||||
"quickEditFields": [
|
"quickEditFields": [
|
||||||
"item",
|
"item",
|
||||||
@ -86,6 +93,7 @@
|
|||||||
|
|
||||||
"transferQuantity",
|
"transferQuantity",
|
||||||
"transferUnit",
|
"transferUnit",
|
||||||
|
"batchNumber",
|
||||||
"quantity",
|
"quantity",
|
||||||
"unit",
|
"unit",
|
||||||
"unitConversionFactor",
|
"unitConversionFactor",
|
||||||
|
@ -41,6 +41,12 @@
|
|||||||
"placeholder": "Unit",
|
"placeholder": "Unit",
|
||||||
"readOnly": true
|
"readOnly": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "batchNumber",
|
||||||
|
"label": "Batch No",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"target": "BatchNumber"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "quantity",
|
"fieldname": "quantity",
|
||||||
"label": "Quantity",
|
"label": "Quantity",
|
||||||
@ -80,12 +86,13 @@
|
|||||||
"placeholder": "HSN/SAC Code"
|
"placeholder": "HSN/SAC Code"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"tableFields": ["item", "location", "quantity", "rate", "amount"],
|
"tableFields": ["item", "location", "batchNumber", "quantity", "rate", "amount"],
|
||||||
"quickEditFields": [
|
"quickEditFields": [
|
||||||
"item",
|
"item",
|
||||||
|
|
||||||
"transferQuantity",
|
"transferQuantity",
|
||||||
"transferUnit",
|
"transferUnit",
|
||||||
|
"batchNumber",
|
||||||
"quantity",
|
"quantity",
|
||||||
"unit",
|
"unit",
|
||||||
"unitConversionFactor",
|
"unitConversionFactor",
|
||||||
|
@ -47,6 +47,7 @@ import submittable from './meta/submittable.json';
|
|||||||
import tree from './meta/tree.json';
|
import tree from './meta/tree.json';
|
||||||
import { Schema, SchemaStub } from './types';
|
import { Schema, SchemaStub } from './types';
|
||||||
import InventorySettings from './app/inventory/InventorySettings.json';
|
import InventorySettings from './app/inventory/InventorySettings.json';
|
||||||
|
import BatchNumber from './app/BatchNumber.json'
|
||||||
|
|
||||||
export const coreSchemas: Schema[] = [
|
export const coreSchemas: Schema[] = [
|
||||||
PatchRun as Schema,
|
PatchRun as Schema,
|
||||||
@ -114,4 +115,6 @@ export const appSchemas: Schema[] | SchemaStub[] = [
|
|||||||
ShipmentItem as Schema,
|
ShipmentItem as Schema,
|
||||||
PurchaseReceipt as Schema,
|
PurchaseReceipt as Schema,
|
||||||
PurchaseReceiptItem as Schema,
|
PurchaseReceiptItem as Schema,
|
||||||
|
|
||||||
|
BatchNumber as Schema
|
||||||
];
|
];
|
||||||
|
@ -83,6 +83,7 @@ export default {
|
|||||||
showHSN: this.showHSN,
|
showHSN: this.showHSN,
|
||||||
displayLogo: this.printSettings.displayLogo,
|
displayLogo: this.printSettings.displayLogo,
|
||||||
displayTaxInvoice: this.printSettings.displayTaxInvoice,
|
displayTaxInvoice: this.printSettings.displayTaxInvoice,
|
||||||
|
displayBatchNumber: this.printSettings.displayBatchNumber,
|
||||||
discountAfterTax: this.doc.discountAfterTax,
|
discountAfterTax: this.doc.discountAfterTax,
|
||||||
logo: this.printSettings.logo,
|
logo: this.printSettings.logo,
|
||||||
companyName: this.fyo.singles.AccountingSettings.companyName,
|
companyName: this.fyo.singles.AccountingSettings.companyName,
|
||||||
|
@ -71,7 +71,13 @@
|
|||||||
<div class="py-4 text-end w-2/12" v-if="printObject.showHSN">
|
<div class="py-4 text-end w-2/12" v-if="printObject.showHSN">
|
||||||
HSN/SAC
|
HSN/SAC
|
||||||
</div>
|
</div>
|
||||||
<div class="py-4 text-end w-1/12">Quantity</div>
|
<div class="py-4 text-end w-2/12">Quantity</div>
|
||||||
|
<div
|
||||||
|
class="w-3/12 text-end py-4"
|
||||||
|
v-if="printObject.displayBatchNumber"
|
||||||
|
>
|
||||||
|
Batch No
|
||||||
|
</div>
|
||||||
<div class="py-4 text-end w-3/12">Rate</div>
|
<div class="py-4 text-end w-3/12">Rate</div>
|
||||||
<div class="py-4 text-end w-3/12">Amount</div>
|
<div class="py-4 text-end w-3/12">Amount</div>
|
||||||
</div>
|
</div>
|
||||||
@ -84,7 +90,13 @@
|
|||||||
<div class="w-2/12 text-end py-4" v-if="printObject.showHSN">
|
<div class="w-2/12 text-end py-4" v-if="printObject.showHSN">
|
||||||
{{ row.hsnCode }}
|
{{ row.hsnCode }}
|
||||||
</div>
|
</div>
|
||||||
<div class="w-1/12 text-end py-4">{{ row.quantity }}</div>
|
<div class="w-2/12 text-end py-4">{{ row.quantity }}</div>
|
||||||
|
<div
|
||||||
|
class="w-3/12 text-end py-4"
|
||||||
|
v-if="printObject.displayBatchNumber"
|
||||||
|
>
|
||||||
|
{{ row.batchNumber }}
|
||||||
|
</div>
|
||||||
<div class="w-3/12 text-end py-4">{{ row.rate }}</div>
|
<div class="w-3/12 text-end py-4">{{ row.rate }}</div>
|
||||||
<div class="w-3/12 text-end py-4">{{ row.amount }}</div>
|
<div class="w-3/12 text-end py-4">{{ row.amount }}</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -68,6 +68,9 @@
|
|||||||
<div class="w-4/12">Item</div>
|
<div class="w-4/12">Item</div>
|
||||||
<div class="w-2/12 text-end" v-if="printObject.showHSN">HSN/SAC</div>
|
<div class="w-2/12 text-end" v-if="printObject.showHSN">HSN/SAC</div>
|
||||||
<div class="w-2/12 text-end">Quantity</div>
|
<div class="w-2/12 text-end">Quantity</div>
|
||||||
|
<div class="w-3/12 text-end" v-if="printObject.displayBatchNumber">
|
||||||
|
Batch No
|
||||||
|
</div>
|
||||||
<div class="w-3/12 text-end">Rate</div>
|
<div class="w-3/12 text-end">Rate</div>
|
||||||
<div class="w-3/12 text-end">Amount</div>
|
<div class="w-3/12 text-end">Amount</div>
|
||||||
</div>
|
</div>
|
||||||
@ -81,6 +84,9 @@
|
|||||||
{{ row.hsnCode }}
|
{{ row.hsnCode }}
|
||||||
</div>
|
</div>
|
||||||
<div class="w-2/12 text-end">{{ row.quantity }}</div>
|
<div class="w-2/12 text-end">{{ row.quantity }}</div>
|
||||||
|
<div class="w-3/12 text-end" v-if="printObject.displayBatchNumber">
|
||||||
|
{{ row.batchNumber }}
|
||||||
|
</div>
|
||||||
<div class="w-3/12 text-end">{{ row.rate }}</div>
|
<div class="w-3/12 text-end">{{ row.rate }}</div>
|
||||||
<div class="w-3/12 text-end">{{ row.amount }}</div>
|
<div class="w-3/12 text-end">{{ row.amount }}</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -112,6 +112,9 @@
|
|||||||
<div class="w-4/12">Item</div>
|
<div class="w-4/12">Item</div>
|
||||||
<div class="w-2/12 text-end" v-if="printObject.showHSN">HSN/SAC</div>
|
<div class="w-2/12 text-end" v-if="printObject.showHSN">HSN/SAC</div>
|
||||||
<div class="w-2/12 text-end">Quantity</div>
|
<div class="w-2/12 text-end">Quantity</div>
|
||||||
|
<div class="w-3/12 text-end" v-if="printObject.displayBatchNumber">
|
||||||
|
Batch No
|
||||||
|
</div>
|
||||||
<div class="w-3/12 text-end">Rate</div>
|
<div class="w-3/12 text-end">Rate</div>
|
||||||
<div class="w-3/12 text-end">Amount</div>
|
<div class="w-3/12 text-end">Amount</div>
|
||||||
</div>
|
</div>
|
||||||
@ -125,6 +128,9 @@
|
|||||||
{{ row.hsnCode }}
|
{{ row.hsnCode }}
|
||||||
</div>
|
</div>
|
||||||
<div class="w-2/12 text-end">{{ row.quantity }}</div>
|
<div class="w-2/12 text-end">{{ row.quantity }}</div>
|
||||||
|
<div class="w-3/12 text-end" v-if="printObject.displayBatchNumber">
|
||||||
|
{{ row.batchNumber }}
|
||||||
|
</div>
|
||||||
<div class="w-3/12 text-end">{{ row.rate }}</div>
|
<div class="w-3/12 text-end">{{ row.rate }}</div>
|
||||||
<div class="w-3/12 text-end">{{ row.amount }}</div>
|
<div class="w-3/12 text-end">{{ row.amount }}</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -95,7 +95,7 @@ async function getInventorySidebar(): Promise<SidebarRoot[]> {
|
|||||||
label: t`Stock Balance`,
|
label: t`Stock Balance`,
|
||||||
name: 'stock-balance',
|
name: 'stock-balance',
|
||||||
route: '/report/StockBalance',
|
route: '/report/StockBalance',
|
||||||
},
|
}
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
Loading…
Reference in New Issue
Block a user