feat: 倉庫業務屬性、庫存成本追蹤與採購單功能更新
1. 倉庫管理:新增業務類型 (Owned/External/Customer) 與車牌資訊與司機欄位。 2. 庫存管理:實作成本追蹤 (unit_cost, total_value),更新列表與撥補單顯示。 3. 採購單:新增採購日期 (order_date),調整欄位名稱與順序。 4. 前端優化:更新相關 TS Type 定義與 UI 顯示。
This commit is contained in:
@@ -23,6 +23,7 @@ import { Textarea } from "@/Components/ui/textarea";
|
||||
import { toast } from "sonner";
|
||||
import { Warehouse, TransferOrder, TransferOrderStatus } from "@/types/warehouse";
|
||||
import { validateTransferOrder, validateTransferQuantity } from "@/utils/validation";
|
||||
import { usePermission } from "@/hooks/usePermission";
|
||||
|
||||
export type { TransferOrder };
|
||||
|
||||
@@ -42,6 +43,8 @@ interface AvailableProduct {
|
||||
availableQty: number;
|
||||
unit: string;
|
||||
expiryDate: string | null;
|
||||
unitCost: number; // 新增
|
||||
totalValue: number; // 新增
|
||||
}
|
||||
|
||||
export default function TransferOrderDialog({
|
||||
@@ -52,6 +55,9 @@ export default function TransferOrderDialog({
|
||||
// inventories,
|
||||
onSave,
|
||||
}: TransferOrderDialogProps) {
|
||||
const { can } = usePermission();
|
||||
const canViewCost = can('inventory.view_cost');
|
||||
|
||||
const [formData, setFormData] = useState({
|
||||
sourceWarehouseId: "",
|
||||
targetWarehouseId: "",
|
||||
@@ -106,7 +112,9 @@ export default function TransferOrderDialog({
|
||||
batchNumber: item.batch_number,
|
||||
availableQty: item.quantity,
|
||||
unit: item.unit_name,
|
||||
expiryDate: item.expiry_date
|
||||
expiryDate: item.expiry_date,
|
||||
unitCost: item.unit_cost, // 映射
|
||||
totalValue: item.total_value, // 映射
|
||||
}));
|
||||
setAvailableProducts(mappedData);
|
||||
})
|
||||
@@ -249,7 +257,7 @@ export default function TransferOrderDialog({
|
||||
onValueChange={handleProductChange}
|
||||
disabled={!formData.sourceWarehouseId || !!order}
|
||||
options={availableProducts.map((product) => ({
|
||||
label: `${product.productName} | 批號: ${product.batchNumber || '-'} | 效期: ${product.expiryDate || '-'} (庫存: ${product.availableQty} ${product.unit})`,
|
||||
label: `${product.productName} | 批號: ${product.batchNumber || '-'} | 效期: ${product.expiryDate || '-'} (庫存: ${product.availableQty} ${product.unit})${canViewCost ? ` | 成本: $${product.unitCost?.toLocaleString()}` : ''}`,
|
||||
value: `${product.productId}|||${product.batchNumber}`,
|
||||
}))}
|
||||
placeholder="選擇商品與批號"
|
||||
|
||||
Reference in New Issue
Block a user