mirror of
https://github.com/frappe/books.git
synced 2024-11-09 15:20:56 +00:00
fix: hasBatchNumber checkbox validation
This commit is contained in:
parent
9b1cd31ba3
commit
622a4cccd3
@ -145,7 +145,7 @@ export class BespokeQueries {
|
|||||||
|
|
||||||
const value = (await query) as Record<string, string | null>[];
|
const value = (await query) as Record<string, string | null>[];
|
||||||
|
|
||||||
if (!value) return false;
|
if (!value || value.length == 0) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
* allowing users to change the value of Has Batch No of the items which already did
|
||||||
transactions will result in incorect SLEs
|
transactions will result in incorect SLEs
|
||||||
*/
|
*/
|
||||||
const ifItemHasBatchNumber = await Boolean(
|
const ifItemHasBatchNumber = await this.fyo.db.get(
|
||||||
this.fyo.db.get('Item', this.name! || '', 'hasBatchNumber')
|
'Item',
|
||||||
|
this.name!,
|
||||||
|
'hasBatchNumber'
|
||||||
);
|
);
|
||||||
|
|
||||||
if (this.hasBatchNumber == ifItemHasBatchNumber) {
|
if (this.hasBatchNumber == ifItemHasBatchNumber.hasBatchNumber) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const isItemExistsInSLE = await this.fyo.db.itemHasTransactions(this.name!);
|
const isItemExistsInSLE = await this.fyo.db.itemHasTransactions(this.name!);
|
||||||
|
|
||||||
if (ifItemHasBatchNumber && isItemExistsInSLE) {
|
if (isItemExistsInSLE) {
|
||||||
throw new ValidationError(
|
throw new ValidationError(
|
||||||
this.fyo.t`Cannot change value of Has Batch No as ${this
|
this.fyo.t`Cannot change value of Has Batch No as ${this
|
||||||
.name!} already has transactions against it. `
|
.name!} already has transactions against it. `
|
||||||
|
Loading…
Reference in New Issue
Block a user