Add user delete process 2
This commit is contained in:
@@ -26,6 +26,7 @@ export interface PurchaseOrderItem {
|
||||
id: string;
|
||||
inventory_product_id: string;
|
||||
product_code?: string;
|
||||
product_name?: string;
|
||||
ordered_quantity: number;
|
||||
unit_of_measure: string;
|
||||
unit_price: string; // Decimal as string
|
||||
|
||||
@@ -390,12 +390,12 @@ const ProcurementPage: React.FC = () => {
|
||||
},
|
||||
{
|
||||
label: 'Email',
|
||||
value: po.supplier?.contact_email || 'N/A',
|
||||
value: po.supplier?.email || 'N/A',
|
||||
type: 'text' as const
|
||||
},
|
||||
{
|
||||
label: 'Teléfono',
|
||||
value: po.supplier?.contact_phone || 'N/A',
|
||||
value: po.supplier?.phone || 'N/A',
|
||||
type: 'text' as const
|
||||
}
|
||||
]
|
||||
@@ -557,7 +557,18 @@ const ProcurementPage: React.FC = () => {
|
||||
|
||||
const totalAmount = items.reduce((sum, item) => {
|
||||
const price = typeof item.unit_price === 'string' ? parseFloat(item.unit_price) : typeof item.unit_price === 'number' ? item.unit_price : 0;
|
||||
const quantity = typeof item.ordered_quantity === 'number' ? item.ordered_quantity : 0;
|
||||
const quantity = (() => {
|
||||
if (typeof item.ordered_quantity === 'number') {
|
||||
return item.ordered_quantity;
|
||||
} else if (typeof item.ordered_quantity === 'string') {
|
||||
const parsed = parseFloat(item.ordered_quantity);
|
||||
return isNaN(parsed) ? 0 : parsed;
|
||||
} else if (typeof item.ordered_quantity === 'object' && item.ordered_quantity !== null) {
|
||||
// Handle if it's a decimal object or similar
|
||||
return parseFloat(item.ordered_quantity.toString()) || 0;
|
||||
}
|
||||
return 0;
|
||||
})();
|
||||
return sum + (price * quantity);
|
||||
}, 0);
|
||||
|
||||
@@ -566,9 +577,20 @@ const ProcurementPage: React.FC = () => {
|
||||
{/* Items as cards */}
|
||||
{items.map((item, index) => {
|
||||
const unitPrice = typeof item.unit_price === 'string' ? parseFloat(item.unit_price) : typeof item.unit_price === 'number' ? item.unit_price : 0;
|
||||
const quantity = typeof item.ordered_quantity === 'number' ? item.ordered_quantity : 0;
|
||||
const quantity = (() => {
|
||||
if (typeof item.ordered_quantity === 'number') {
|
||||
return item.ordered_quantity;
|
||||
} else if (typeof item.ordered_quantity === 'string') {
|
||||
const parsed = parseFloat(item.ordered_quantity);
|
||||
return isNaN(parsed) ? 0 : parsed;
|
||||
} else if (typeof item.ordered_quantity === 'object' && item.ordered_quantity !== null) {
|
||||
// Handle if it's a decimal object or similar
|
||||
return parseFloat(item.ordered_quantity.toString()) || 0;
|
||||
}
|
||||
return 0;
|
||||
})();
|
||||
const itemTotal = unitPrice * quantity;
|
||||
const productName = item.product_name || `Producto ${index + 1}`;
|
||||
const productName = item.product_name || item.ingredient_name || `Producto ${index + 1}`;
|
||||
|
||||
return (
|
||||
<div
|
||||
|
||||
Reference in New Issue
Block a user