Fix new services implementation 3

This commit is contained in:
Urtzi Alfaro
2025-08-14 16:47:34 +02:00
parent 0951547e92
commit 03737430ee
51 changed files with 657 additions and 982 deletions

View File

@@ -33,7 +33,8 @@ interface PurchaseOrderFormProps {
interface OrderItem {
ingredient_id: string;
product_code: string;
product_name: string;
inventory_product_id: string; // Reference to inventory service product
product_name: string; // For backward compatibility and display
ordered_quantity: number;
unit_of_measure: string;
unit_price: number;
@@ -80,6 +81,7 @@ const initialFormData: FormData = {
const initialOrderItem: OrderItem = {
ingredient_id: '',
product_code: '',
inventory_product_id: '',
product_name: '',
ordered_quantity: 0,
unit_of_measure: '',
@@ -123,7 +125,8 @@ const PurchaseOrderForm: React.FC<PurchaseOrderFormProps> = ({
items: order.items?.map(item => ({
ingredient_id: item.ingredient_id,
product_code: item.product_code || '',
product_name: item.product_name,
inventory_product_id: item.inventory_product_id,
product_name: item.product_name || '',
ordered_quantity: item.ordered_quantity,
unit_of_measure: item.unit_of_measure,
unit_price: item.unit_price,
@@ -193,6 +196,7 @@ const PurchaseOrderForm: React.FC<PurchaseOrderFormProps> = ({
const ingredient = ingredients.find(ing => ing.id === ingredientId);
if (ingredient) {
handleItemChange(index, 'ingredient_id', ingredientId);
handleItemChange(index, 'inventory_product_id', ingredient.id);
handleItemChange(index, 'product_name', ingredient.name);
handleItemChange(index, 'unit_of_measure', ingredient.unit_of_measure);
handleItemChange(index, 'product_code', ingredient.sku || '');
@@ -279,6 +283,7 @@ const PurchaseOrderForm: React.FC<PurchaseOrderFormProps> = ({
items: formData.items.map(item => ({
ingredient_id: item.ingredient_id,
product_code: item.product_code || undefined,
inventory_product_id: item.inventory_product_id,
product_name: item.product_name,
ordered_quantity: item.ordered_quantity,
unit_of_measure: item.unit_of_measure,