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
2 changes: 1 addition & 1 deletion .mcp.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@modelcontextprotocol/server-github"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_PERSONAL_ACCESS_TOKEN}"
"GITHUB_PERSONAL_ACCESS_TOKEN": "${GHTOKEN}"
}
}
}
Expand Down
1 change: 1 addition & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,4 @@ npm install && npm run dev
- Status: green/blue/yellow/red
- Charts: Custom SVG, CSS Grid for layouts
- No emojis in UI
- Always document non-obvious logic changes with comments
3 changes: 3 additions & 0 deletions client/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
<router-link to="/demand" :class="{ active: $route.path === '/demand' }">
{{ t('nav.demandForecast') }}
</router-link>
<router-link to="/restocking" :class="{ active: $route.path === '/restocking' }">
Restocking
</router-link>
<router-link to="/reports" :class="{ active: $route.path === '/reports' }">
Reports
</router-link>
Expand Down
37 changes: 37 additions & 0 deletions client/src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,42 @@ export const api = {
async getPurchaseOrderByBacklogItem(backlogItemId) {
const response = await axios.get(`${API_BASE_URL}/purchase-orders/${backlogItemId}`)
return response.data
},

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

async createRestockingOrder(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
},

async getQuarterlyReports(filters = {}) {
const params = new URLSearchParams()
if (filters.warehouse && filters.warehouse !== 'all') params.append('warehouse', filters.warehouse)
if (filters.category && filters.category !== 'all') params.append('category', filters.category)
if (filters.status && filters.status !== 'all') params.append('status', filters.status)
if (filters.month && filters.month !== 'all') params.append('month', filters.month)

const response = await axios.get(`${API_BASE_URL}/reports/quarterly?${params.toString()}`)
return response.data
},

async getMonthlyTrends(filters = {}) {
const params = new URLSearchParams()
if (filters.warehouse && filters.warehouse !== 'all') params.append('warehouse', filters.warehouse)
if (filters.category && filters.category !== 'all') params.append('category', filters.category)
if (filters.status && filters.status !== 'all') params.append('status', filters.status)
if (filters.month && filters.month !== 'all') params.append('month', filters.month)

const response = await axios.get(`${API_BASE_URL}/reports/monthly-trends?${params.toString()}`)
return response.data
}
}
23 changes: 23 additions & 0 deletions client/src/locales/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,29 @@ export default {
}
},

// Reports
reports: {
title: 'Performance Reports',
description: 'View quarterly performance metrics and monthly trends',
quarterlyPerformance: 'Quarterly Performance',
monthlyRevenueTrend: 'Monthly Revenue Trend',
monthOverMonthAnalysis: 'Month-over-Month Analysis',
quarter: 'Quarter',
totalOrders: 'Total Orders',
totalRevenue: 'Total Revenue',
avgOrderValue: 'Avg Order Value',
fulfillmentRate: 'Fulfillment Rate',
month: 'Month',
orders: 'Orders',
revenue: 'Revenue',
change: 'Change',
growthRate: 'Growth Rate',
totalRevenueYTD: 'Total Revenue (YTD)',
avgMonthlyRevenue: 'Avg Monthly Revenue',
totalOrdersYTD: 'Total Orders (YTD)',
bestPerformingQuarter: 'Best Performing Quarter'
},

// Filters
filters: {
timePeriod: 'Time Period',
Expand Down
23 changes: 23 additions & 0 deletions client/src/locales/ja.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,29 @@ export default {
}
},

// Reports
reports: {
title: 'パフォーマンスレポート',
description: '四半期業績と月別トレンドの表示',
quarterlyPerformance: '四半期業績',
monthlyRevenueTrend: '月別売上トレンド',
monthOverMonthAnalysis: '前月比分析',
quarter: '四半期',
totalOrders: '総注文数',
totalRevenue: '総売上',
avgOrderValue: '平均注文額',
fulfillmentRate: '達成率',
month: '月',
orders: '注文',
revenue: '売上',
change: '変化',
growthRate: '成長率',
totalRevenueYTD: '総売上(年累計)',
avgMonthlyRevenue: '平均月間売上',
totalOrdersYTD: '総注文数(年累計)',
bestPerformingQuarter: '最高業績四半期'
},

// Filters
filters: {
timePeriod: '期間',
Expand Down
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
144 changes: 137 additions & 7 deletions client/src/views/Orders.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,65 @@
<div v-if="loading" class="loading">{{ t('common.loading') }}</div>
<div v-else-if="error" class="error">{{ error }}</div>
<div v-else>
<!-- Submitted Restocking Orders Section -->
<div v-if="restockingOrders.length > 0" class="card submitted-orders-section">
<div class="card-header">
<h3 class="card-title">Submitted Orders ({{ restockingOrders.length }})</h3>
<p class="section-description">Recently submitted restocking orders with delivery lead times</p>
</div>
<div class="table-container">
<table class="orders-table">
<thead>
<tr>
<th class="col-order-number">{{ t('orders.table.orderNumber') }}</th>
<th class="col-customer">Type</th>
<th class="col-items">{{ t('orders.table.items') }}</th>
<th class="col-status">{{ t('orders.table.status') }}</th>
<th class="col-date">{{ t('orders.table.orderDate') }}</th>
<th class="col-date">{{ t('orders.table.expectedDelivery') }}</th>
<th class="col-lead-time">Lead Time</th>
<th class="col-value">{{ t('orders.table.totalValue') }}</th>
</tr>
</thead>
<tbody>
<tr v-for="order in restockingOrders" :key="order.id" class="restocking-order-row">
<td class="col-order-number">
<strong>{{ order.order_number }}</strong>
<span class="new-badge">NEW</span>
</td>
<td class="col-customer">
<span class="badge info">{{ order.customer }}</span>
</td>
<td class="col-items">
<details class="items-details">
<summary class="items-summary">
{{ t('orders.itemsCount', { count: order.items.length }) }}
</summary>
<div class="items-dropdown">
<div v-for="(item, idx) in order.items" :key="idx" class="item-entry">
<span class="item-name">{{ translateProductName(item.name) }}</span>
<span class="item-meta">{{ t('orders.quantity') }}: {{ item.quantity }} @ {{ currencySymbol }}{{ item.unit_cost }}</span>
</div>
</div>
</details>
</td>
<td class="col-status">
<span :class="['badge', getOrderStatusClass(order.status)]">
{{ t(`status.${order.status.toLowerCase()}`) }}
</span>
</td>
<td class="col-date">{{ formatDate(order.order_date) }}</td>
<td class="col-date">{{ formatDate(order.expected_delivery) }}</td>
<td class="col-lead-time">
<span class="lead-time-badge">{{ calculateLeadTime(order.order_date, order.expected_delivery) }} days</span>
</td>
<td class="col-value"><strong>{{ currencySymbol }}{{ order.total_value.toLocaleString() }}</strong></td>
</tr>
</tbody>
</table>
</div>
</div>

<div class="stats-grid">
<div class="stat-card success">
<div class="stat-label">{{ t('status.delivered') }}</div>
Expand Down Expand Up @@ -95,6 +154,7 @@ export default {
const loading = ref(true)
const error = ref(null)
const orders = ref([])
const restockingOrders = ref([])

// Use shared filters
const {
Expand Down Expand Up @@ -124,6 +184,20 @@ export default {
}
}

const loadRestockingOrders = async () => {
try {
const fetchedRestockingOrders = await api.getRestockingOrders()
// Sort by order date (most recent first)
restockingOrders.value = fetchedRestockingOrders.sort((a, b) => {
const dateA = new Date(a.order_date)
const dateB = new Date(b.order_date)
return dateB - dateA
})
} catch (err) {
console.error('Failed to load restocking orders:', err)
}
}

// Watch for filter changes and reload data
watch([selectedPeriod, selectedLocation, selectedCategory, selectedStatus], () => {
loadOrders()
Expand Down Expand Up @@ -153,16 +227,30 @@ export default {
})
}

onMounted(loadOrders)
// Calculate lead time in days between two dates
const calculateLeadTime = (orderDate, expectedDelivery) => {
const startDate = new Date(orderDate)
const endDate = new Date(expectedDelivery)
const diffTime = Math.abs(endDate - startDate)
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24))
return diffDays
}

onMounted(() => {
loadOrders()
loadRestockingOrders()
})

return {
t,
loading,
error,
orders,
restockingOrders,
getOrdersByStatus,
getOrderStatusClass,
formatDate,
calculateLeadTime,
currencySymbol,
translateProductName,
translateCustomerName
Expand All @@ -172,6 +260,48 @@ export default {
</script>

<style scoped>
/* Submitted Orders Section */
.submitted-orders-section {
margin-bottom: 2rem;
border-left: 4px solid #3b82f6;
}

.section-description {
color: #64748b;
font-size: 0.875rem;
margin-top: 0.25rem;
}

.restocking-order-row {
background-color: #f0f9ff;
}

.new-badge {
display: inline-block;
margin-left: 0.5rem;
padding: 0.125rem 0.5rem;
background: #3b82f6;
color: white;
font-size: 0.625rem;
font-weight: 600;
border-radius: 4px;
vertical-align: middle;
}

.col-lead-time {
width: 100px;
}

.lead-time-badge {
display: inline-block;
padding: 0.25rem 0.625rem;
background: #e0e7ff;
color: #3730a3;
font-size: 0.813rem;
font-weight: 500;
border-radius: 4px;
}

/* Fixed table layout to prevent column shifting */
.orders-table {
table-layout: fixed;
Expand All @@ -180,27 +310,27 @@ export default {

/* Column widths */
.col-order-number {
width: 130px;
width: 140px;
}

.col-customer {
width: 180px;
width: 160px;
}

.col-items {
width: 200px;
width: 180px;
}

.col-status {
width: 130px;
width: 120px;
}

.col-date {
width: 140px;
width: 120px;
}

.col-value {
width: 120px;
width: 110px;
}

/* Items details styling */
Expand Down
Loading