# Implementation Plan - Enhanced Cost Calculator & Currency System

## Summary of Changes Requested

### 1. Currency Logic Changes
- **Purchase Cost**: EUR (euros)
- **Processing Cost**: RON (lei)
- **Transport Cost**: RON (lei) - with option to input in EUR or RON in calculator
- **Final Price**: RON (lei)

### 2. Transport Cost Allocation
- Allocate total transport cost proportionally by **weight**
- Formula: `product_transport = (product_weight / total_weight) × total_transport_cost`

### 3. Excel-Style Cost Calculator
- Grid interface like bulk editor
- Copy/paste support from Excel
- Columns:
  - Product Name
  - Weight (kg)
  - Quantity
  - Purchase Cost (EUR/unit)
  - Total Weight (auto-calc)
  - Proportional Weight %
  - Allocated Transport (RON)
  - Processing Cost (RON/kg)
  - Total Cost (RON)
  - Markup %
  - Final Price (RON)
  - Bulk/Piece indicator
  - Min Order Qty
  - Package Size

### 4. Product Features
- **Bulk/Piece Column**: Show if product sold by bulk or piece
- **Minimum Order Quantity**: e.g., must order 40 pieces
- **Package Size**: e.g., 4 kg/box, 40 pieces/box
- **Package Unit**: Specify if kg or pieces

### 5. Database Changes
Added columns to `products` table:
- `base_purchase_cost_currency` TEXT DEFAULT 'EUR'
- `processing_cost_currency` TEXT DEFAULT 'RON'
- `transport_cost_currency` TEXT DEFAULT 'RON'
- `final_price_currency` TEXT DEFAULT 'RON'
- `min_order_quantity` INTEGER DEFAULT 1
- `package_size` REAL DEFAULT NULL
- `package_unit` TEXT DEFAULT NULL (kg/pieces)

## Implementation Status

✅ Database schema updated
✅ Calculator UI updated with currency selector
⏳ Excel-style grid for calculator
⏳ Weight-based transport allocation
⏳ Multi-currency price calculation
⏳ Package/minimum order constraints in customer portal

## Next Steps

1. Replace cost calculator JavaScript with Excel-style grid
2. Implement weight-based transport allocation
3. Update price calculation to handle EUR→RON conversion
4. Add package constraints to customer ordering
5. Update product display to show bulk/piece indicator
6. Test end-to-end workflow

## Files to Modify

- ✅ `database.js` - Schema updated
- ✅ `views/admin-dashboard.html` - Calculator UI updated
- ⏳ `public/js/admin.js` - Calculator logic (lines 239-438)
- ⏳ `routes/pricing.js` - Update calculation endpoint
- ⏳ `public/js/customer.js` - Package constraints
- ⏳ `routes/products.js` - Include new fields in responses

## Current Server Status

Server running on: http://localhost:3000
Ready for implementation of remaining features.
