2
0
mirror of https://github.com/frappe/books.git synced 2024-09-19 11:09:01 +00:00

fix: hasBatchNumber checkbox validation

This commit is contained in:
akshayitzme 2023-01-27 16:06:04 +05:30
parent 9b1cd31ba3
commit 622a4cccd3
2 changed files with 7 additions and 5 deletions

View File

@ -145,7 +145,7 @@ export class BespokeQueries {
const value = (await query) as Record<string, string | null>[];
if (!value) return false;
if (!value || value.length == 0) return false;
return true;
}

View File

@ -27,17 +27,19 @@ export class Item extends Doc {
* allowing users to change the value of Has Batch No of the items which already did
transactions will result in incorect SLEs
*/
const ifItemHasBatchNumber = await Boolean(
this.fyo.db.get('Item', this.name! || '', 'hasBatchNumber')
const ifItemHasBatchNumber = await this.fyo.db.get(
'Item',
this.name!,
'hasBatchNumber'
);
if (this.hasBatchNumber == ifItemHasBatchNumber) {
if (this.hasBatchNumber == ifItemHasBatchNumber.hasBatchNumber) {
return;
}
const isItemExistsInSLE = await this.fyo.db.itemHasTransactions(this.name!);
if (ifItemHasBatchNumber && isItemExistsInSLE) {
if (isItemExistsInSLE) {
throw new ValidationError(
this.fyo.t`Cannot change value of Has Batch No as ${this
.name!} already has transactions against it. `