mirror of
https://github.com/frappe/books.git
synced 2024-11-08 14:50:56 +00:00
chore: refactor sinv validations
This commit is contained in:
parent
8d1e0ca8c8
commit
df6c472ca4
@ -89,15 +89,19 @@ export async function getItem(item: string): Promise<Item | undefined> {
|
||||
return itemDoc;
|
||||
}
|
||||
|
||||
export function validateSinv(
|
||||
items: SalesInvoiceItem[],
|
||||
itemQtyMap: ItemQtyMap
|
||||
) {
|
||||
if (!items) {
|
||||
export function validateSinv(sinvDoc: SalesInvoice, itemQtyMap: ItemQtyMap) {
|
||||
if (!sinvDoc) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const item of items) {
|
||||
validateSinvItems(sinvDoc.items as SalesInvoiceItem[], itemQtyMap);
|
||||
}
|
||||
|
||||
function validateSinvItems(
|
||||
sinvItems: SalesInvoiceItem[],
|
||||
itemQtyMap: ItemQtyMap
|
||||
) {
|
||||
for (const item of sinvItems) {
|
||||
if (!item.quantity || item.quantity < 1) {
|
||||
throw new ValidationError(
|
||||
t`Invalid Quantity for Item ${item.item as string}`
|
||||
|
Loading…
Reference in New Issue
Block a user