mirror of
https://github.com/frappe/books.git
synced 2024-11-10 07:40:55 +00:00
refactor: validateStockAvailability
This commit is contained in:
parent
4fc6c3cf1b
commit
09591703e4
@ -88,7 +88,6 @@ export class StockManager {
|
||||
this.#validateQuantity(details);
|
||||
this.#validateLocation(details);
|
||||
await this.#validateStockAvailability(details);
|
||||
await this.#validateBatchWiseStockAvailability(details);
|
||||
}
|
||||
|
||||
#validateQuantity(details: SMIDetails) {
|
||||
@ -127,26 +126,25 @@ export class StockManager {
|
||||
throw new ValidationError(t`Both From and To Location cannot be undefined`);
|
||||
}
|
||||
|
||||
async #validateBatchWiseStockAvailability(details: SMIDetails) {
|
||||
async #validateStockAvailability(details: SMIDetails) {
|
||||
if (!details.fromLocation) {
|
||||
return;
|
||||
}
|
||||
|
||||
const date = details.date.toISOString();
|
||||
const isItemHasBatchNumber = await this.fyo.getValue(
|
||||
'Item',
|
||||
details.item,
|
||||
'hasBatchNumber'
|
||||
);
|
||||
|
||||
if (!isItemHasBatchNumber) return;
|
||||
|
||||
if (isItemHasBatchNumber) {
|
||||
if (!details.batchNumber) {
|
||||
throw new ValidationError(
|
||||
t`Please enter Batch Number for ${details.item}`
|
||||
);
|
||||
}
|
||||
|
||||
const date = details.date.toISOString();
|
||||
const itemsInBatch =
|
||||
(await this.fyo.db.getStockQuantity(
|
||||
details.item,
|
||||
@ -173,12 +171,6 @@ export class StockManager {
|
||||
);
|
||||
}
|
||||
|
||||
async #validateStockAvailability(details: SMIDetails) {
|
||||
if (!details.fromLocation) {
|
||||
return;
|
||||
}
|
||||
|
||||
const date = details.date.toISOString();
|
||||
let quantityBefore =
|
||||
(await this.fyo.db.getStockQuantity(
|
||||
details.item,
|
||||
|
Loading…
Reference in New Issue
Block a user