mirror of
https://github.com/frappe/books.git
synced 2024-11-10 07:40:55 +00:00
Merge branch 'batch-wise-item' of https://github.com/wahni-green/books into batch-wise-item
This commit is contained in:
commit
1d188151e8
@ -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';
|
||||||
|
|
||||||
@ -75,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[] {
|
||||||
|
Loading…
Reference in New Issue
Block a user