2
0
mirror of https://github.com/frappe/books.git synced 2024-11-08 23:00:56 +00:00

chore: refactor sinv validations

This commit is contained in:
akshayitzme 2023-11-07 15:51:53 +05:30
parent 8d1e0ca8c8
commit df6c472ca4

View File

@ -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}`