fix: 修正总库存计算,区分在库/待交车/异动状态
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
- 总库存 = 在库 + 异动(不含待交车) - 待交车独立展示 - 库 = 纯在库数量 - 异 = 异动数量 - 验证: 运营 + 库存 + 待交 = 总资产 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -112,11 +112,12 @@ function mapInventoryRegion(region: string): string {
|
||||
|
||||
// Map rental status to frontend status
|
||||
// Actual DB values: 在库(0), 自营(1), 租赁(2), 待交车(7), 挂靠(8), 异动(12)
|
||||
function mapStatus(rentStatus: string | null): 'Operating' | 'Inventory' | 'Abnormal' {
|
||||
function mapStatus(rentStatus: string | null): 'Operating' | 'Inventory' | 'Pending' | 'Abnormal' {
|
||||
if (!rentStatus) return 'Inventory';
|
||||
const s = rentStatus.trim();
|
||||
if (s === '租赁' || s === '自营' || s === '挂靠') return 'Operating';
|
||||
if (s === '在库' || s === '待交车') return 'Inventory';
|
||||
if (s === '在库') return 'Inventory';
|
||||
if (s === '待交车') return 'Pending';
|
||||
if (s === '异动') return 'Abnormal';
|
||||
return 'Inventory';
|
||||
}
|
||||
@@ -324,7 +325,7 @@ function getStats(list: Vehicle[], weeklyIds?: WeeklyTruckIds) {
|
||||
list.filter((v) => v.status === 'Inventory'),
|
||||
REGIONS,
|
||||
),
|
||||
pending: weeklyIds ? strIds.filter((id) => weeklyIds.pending.has(id)).length : 0,
|
||||
pending: list.filter((v) => v.status === 'Pending').length,
|
||||
operating: list.filter((v) => v.status === 'Operating').length,
|
||||
weeklyDelivered: weeklyIds ? strIds.filter((id) => weeklyIds.delivered.has(id)).length : 0,
|
||||
weeklyReturned: weeklyIds ? strIds.filter((id) => weeklyIds.returned.has(id)).length : 0,
|
||||
@@ -457,11 +458,16 @@ app.get('/summary', async (c) => {
|
||||
hanging: vehicles.filter((v) => v.status === 'Operating' && v.ownership === 'Hanging').length,
|
||||
},
|
||||
inventory: {
|
||||
total: vehicles.filter((v) => v.status === 'Inventory').length,
|
||||
total: vehicles.filter((v) => v.status === 'Inventory' || v.status === 'Abnormal').length,
|
||||
inStock: vehicles.filter((v) => v.status === 'Inventory').length,
|
||||
abnormal: vehicles.filter((v) => v.status === 'Abnormal').length,
|
||||
},
|
||||
...weekly,
|
||||
pendingDelivery: vehicles.filter((v) => v.status === 'Pending').length,
|
||||
weeklyNew: weekly.weeklyNew,
|
||||
weeklyRemoved: weekly.weeklyRemoved,
|
||||
weeklyDelivered: weekly.weeklyDelivered,
|
||||
weeklyReturned: weekly.weeklyReturned,
|
||||
weeklyReplaced: weekly.weeklyReplaced,
|
||||
};
|
||||
return c.json(summary);
|
||||
});
|
||||
|
||||
@@ -36,7 +36,7 @@ export interface Vehicle {
|
||||
color: string;
|
||||
location: string;
|
||||
region: string;
|
||||
status: 'Operating' | 'Inventory' | 'Abnormal';
|
||||
status: 'Operating' | 'Inventory' | 'Pending' | 'Abnormal';
|
||||
ownership: string;
|
||||
rentCompany: string;
|
||||
contractNo: string | null;
|
||||
|
||||
Reference in New Issue
Block a user