Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ npm install && npm run dev
- `GET /api/demand`, `/api/backlog` - No filters
- `GET /api/spending/*` - Summary, monthly, categories, transactions

## Coding Standards
- Always document non-obvious logic changes with comments

## Common Issues
1. Use unique keys in v-for (not `index`) - use `sku`, `month`, etc.
2. Validate dates before `.getMonth()` calls
Expand Down
3 changes: 3 additions & 0 deletions client/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
<router-link to="/reports" :class="{ active: $route.path === '/reports' }">
Reports
</router-link>
<router-link to="/restocking" :class="{ active: $route.path === '/restocking' }">
Restocking
</router-link>
</nav>
<LanguageSwitcher />
<ProfileMenu
Expand Down
18 changes: 17 additions & 1 deletion client/src/api.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios from 'axios'

const API_BASE_URL = 'http://localhost:8001/api'
const API_BASE_URL = 'http://localhost:8000/api'

export const api = {
async getInventory(filters = {}) {
Expand Down Expand Up @@ -102,5 +102,21 @@ export const api = {
async getPurchaseOrderByBacklogItem(backlogItemId) {
const response = await axios.get(`${API_BASE_URL}/purchase-orders/${backlogItemId}`)
return response.data
},

// ── Restocking ──────────────────────────────────────────────────────────
async getRestockingRecommendations() {
const response = await axios.get(`${API_BASE_URL}/restocking/recommendations`)
return response.data
},

async submitRestockingOrder(orderData) {
const response = await axios.post(`${API_BASE_URL}/restocking-orders`, orderData)
return response.data
},

async getRestockingOrders() {
const response = await axios.get(`${API_BASE_URL}/restocking-orders`)
return response.data
}
}
4 changes: 3 additions & 1 deletion client/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Orders from './views/Orders.vue'
import Demand from './views/Demand.vue'
import Spending from './views/Spending.vue'
import Reports from './views/Reports.vue'
import Restocking from './views/Restocking.vue'

const router = createRouter({
history: createWebHistory(),
Expand All @@ -16,7 +17,8 @@ const router = createRouter({
{ path: '/orders', component: Orders },
{ path: '/demand', component: Demand },
{ path: '/spending', component: Spending },
{ path: '/reports', component: Reports }
{ path: '/reports', component: Reports },
{ path: '/restocking', component: Restocking }
]
})

Expand Down
71 changes: 69 additions & 2 deletions client/src/views/Orders.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,50 @@
<p>{{ t('orders.description') }}</p>
</div>

<!-- Submitted Restocking Orders section -->
<div v-if="restockingOrders.length > 0" class="card restocking-section">
<div class="card-header">
<h3 class="card-title restock-title">Submitted Restocking Orders</h3>
<span class="restock-badge">{{ restockingOrders.length }}</span>
</div>
<div class="table-container">
<table class="orders-table">
<thead>
<tr>
<th class="col-order-number">Order #</th>
<th class="col-items">Items</th>
<th class="col-status">Status</th>
<th class="col-date">Order Date</th>
<th class="col-date">Est. Delivery (7 days)</th>
<th class="col-value">Total Value</th>
</tr>
</thead>
<tbody>
<tr v-for="ro in restockingOrders" :key="ro.id">
<td class="col-order-number"><strong>{{ ro.order_number }}</strong></td>
<td class="col-items">
<details class="items-details">
<summary class="items-summary">{{ ro.items.length }} item{{ ro.items.length !== 1 ? 's' : '' }}</summary>
<div class="items-dropdown">
<div v-for="(item, idx) in ro.items" :key="idx" class="item-entry">
<span class="item-name">{{ item.name }}</span>
<span class="item-meta">SKU: {{ item.sku }} &nbsp;·&nbsp; Qty: {{ item.quantity }} @ ${{ item.unit_cost.toFixed(2) }}</span>
</div>
</div>
</details>
</td>
<td class="col-status">
<span class="badge warning">{{ ro.status }}</span>
</td>
<td class="col-date">{{ formatDate(ro.order_date) }}</td>
<td class="col-date delivery-date">{{ formatDate(ro.expected_delivery) }}</td>
<td class="col-value"><strong>${{ ro.total_value.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 }) }}</strong></td>
</tr>
</tbody>
</table>
</div>
</div>

<div v-if="loading" class="loading">{{ t('common.loading') }}</div>
<div v-else-if="error" class="error">{{ error }}</div>
<div v-else>
Expand Down Expand Up @@ -95,6 +139,7 @@ export default {
const loading = ref(true)
const error = ref(null)
const orders = ref([])
const restockingOrders = ref([])

// Use shared filters
const {
Expand All @@ -109,14 +154,18 @@ export default {
try {
loading.value = true
const filters = getCurrentFilters()
const fetchedOrders = await api.getOrders(filters)
const [fetchedOrders, fetchedRestocking] = await Promise.all([
api.getOrders(filters),
api.getRestockingOrders()
])

// Sort orders by order_date (earliest first)
orders.value = fetchedOrders.sort((a, b) => {
const dateA = new Date(a.order_date)
const dateB = new Date(b.order_date)
return dateA - dateB
})
restockingOrders.value = fetchedRestocking
} catch (err) {
error.value = 'Failed to load orders: ' + err.message
} finally {
Expand Down Expand Up @@ -165,13 +214,31 @@ export default {
formatDate,
currencySymbol,
translateProductName,
translateCustomerName
translateCustomerName,
restockingOrders
}
}
}
</script>

<style scoped>
/* ── Restocking section ── */
.restocking-section {
border: 1px solid #fbbf24;
background: #fffbeb;
margin-bottom: 24px;
}
.restock-title { color: #92400e; }
.restock-badge {
background: #f59e0b;
color: #fff;
font-size: 11px;
font-weight: 700;
padding: 2px 9px;
border-radius: 99px;
}
.delivery-date { color: #16a34a; font-weight: 600; }

/* Fixed table layout to prevent column shifting */
.orders-table {
table-layout: fixed;
Expand Down
Loading