Refactor PurchaseOrderForm to align item submission structure with PocketBase requirements
This commit is contained in:
parent
8647d3dd3e
commit
75bb145241
1 changed files with 1 additions and 9 deletions
|
|
@ -194,15 +194,7 @@ export function PurchaseOrderForm({ setOpen, refreshData }: PurchaseOrderFormPro
|
|||
supplier: selectedSupplier.id, // This will be the relation to the suppliers collection
|
||||
orderDate: values.orderDate.toISOString(),
|
||||
status: "Pending Approval",
|
||||
// Ensure the structure matches what your PocketBase 'purchase_orders' collection expects for 'items'
|
||||
// Based on your schema, it seems 'embedded_items' is used for storing item details directly.
|
||||
embedded_items: values.items.map(item => ({
|
||||
stockItemId: item.stockItemId,
|
||||
itemName: item.itemName,
|
||||
quantity: item.quantity,
|
||||
sku: item.sku,
|
||||
costPrice: item.costPrice,
|
||||
})),
|
||||
items: values.items.map(item => item.stockItemId),
|
||||
quantities: values.items.map(item => item.quantity), // Keep quantities array as well if needed elsewhere
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue