mirror of
https://github.com/frappe/books.git
synced 2026-08-24 10:04:45 -05:00
fix: item-batch validation
This commit is contained in:
@@ -132,6 +132,26 @@ export class BespokeQueries {
|
||||
`);
|
||||
}
|
||||
|
||||
static async itemHasTransactions(
|
||||
db: DatabaseCore,
|
||||
item: string
|
||||
): Promise<boolean> {
|
||||
/*
|
||||
* to check if an item of given name is present in the SLE
|
||||
* taking the count of items from SLE which has the given item name
|
||||
* if the count is greater than 0 considers item exists in SLE, returns true
|
||||
* if the count is lesser than 0 considers item does not exist in SLE, returns false
|
||||
*/
|
||||
const query = db.knex!(ModelNameEnum.StockLedgerEntry)
|
||||
.select('item')
|
||||
.where('item', item);
|
||||
|
||||
const value = (await query) as Record<string, string | null>[];
|
||||
|
||||
if (!value) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
static async getStockQuantity(
|
||||
db: DatabaseCore,
|
||||
item: string,
|
||||
@@ -167,6 +187,4 @@ export class BespokeQueries {
|
||||
|
||||
return value[0][Object.keys(value[0])[0]];
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
}
|
||||
Reference in New Issue
Block a user