feat: API調整訂單與販賣機訂單同步強制使用warehouse_code,更新API對接文件,及優化生產與配方模組UI顯示
All checks were successful
ERP-Deploy-Demo / deploy-demo (push) Successful in 55s
All checks were successful
ERP-Deploy-Demo / deploy-demo (push) Successful in 55s
This commit is contained in:
@@ -36,6 +36,7 @@ interface ProductionOrderItem {
|
||||
origin_country: string | null;
|
||||
product: { id: number; name: string; code: string } | null;
|
||||
warehouse?: { id: number; name: string } | null;
|
||||
unit_cost?: number;
|
||||
source_purchase_order?: {
|
||||
id: number;
|
||||
code: string;
|
||||
@@ -109,6 +110,13 @@ export default function ProductionShow({ productionOrder, warehouses, auth }: Pr
|
||||
const canCancel = hasPermission('production_orders.cancel');
|
||||
const canEdit = hasPermission('production_orders.edit');
|
||||
|
||||
// 計算總預估成本
|
||||
const totalEstimatedCost = productionOrder.items.reduce((sum, item) => {
|
||||
const qty = Number(item.quantity_used) || 0;
|
||||
const cost = Number(item.inventory?.unit_cost) || 0;
|
||||
return sum + (qty * cost);
|
||||
}, 0);
|
||||
|
||||
return (
|
||||
<AuthenticatedLayout breadcrumbs={getBreadcrumbs("productionOrdersShow")}>
|
||||
<Head title={`生產單 ${productionOrder.code}`} />
|
||||
@@ -368,6 +376,8 @@ export default function ProductionShow({ productionOrder, warehouses, auth }: Pr
|
||||
<TableHead className="px-6 py-4 text-xs font-bold text-grey-2 uppercase tracking-widest leading-none">使用批號</TableHead>
|
||||
<TableHead className="px-6 py-4 text-xs font-bold text-grey-2 uppercase tracking-widest leading-none text-center">來源國家</TableHead>
|
||||
<TableHead className="px-6 py-4 text-xs font-bold text-grey-2 uppercase tracking-widest leading-none">使用數量</TableHead>
|
||||
<TableHead className="px-6 py-4 text-xs font-bold text-grey-2 uppercase tracking-widest leading-none text-right">預估單價</TableHead>
|
||||
<TableHead className="px-6 py-4 text-xs font-bold text-grey-2 uppercase tracking-widest leading-none text-right">成本小計</TableHead>
|
||||
<TableHead className="px-6 py-4 text-xs font-bold text-grey-2 uppercase tracking-widest leading-none">來源單據</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
@@ -404,6 +414,16 @@ export default function ProductionShow({ productionOrder, warehouses, auth }: Pr
|
||||
)}
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCell className="px-6 py-5 text-right">
|
||||
<div className="text-grey-0 font-medium">
|
||||
{Number(item.inventory?.unit_cost || 0).toLocaleString(undefined, { maximumFractionDigits: 2 })} 元
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCell className="px-6 py-5 text-right">
|
||||
<div className="font-bold text-grey-900">
|
||||
{(Number(item.quantity_used) * Number(item.inventory?.unit_cost || 0)).toLocaleString(undefined, { maximumFractionDigits: 2 })} 元
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCell className="px-6 py-5">
|
||||
{item.inventory?.source_purchase_order ? (
|
||||
<div className="group flex flex-col">
|
||||
@@ -428,6 +448,22 @@ export default function ProductionShow({ productionOrder, warehouses, auth }: Pr
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
<div className="bg-gray-50 p-6 border-t border-grey-4 flex justify-end">
|
||||
<div className="min-w-[300px]">
|
||||
<div className="flex justify-between items-center mb-2">
|
||||
<span className="text-sm text-gray-600">生產單總預估成本</span>
|
||||
<span className="text-lg font-bold text-gray-900">{totalEstimatedCost.toLocaleString(undefined, { maximumFractionDigits: 2 })} 元</span>
|
||||
</div>
|
||||
<div className="flex justify-between items-center pt-2 border-t border-gray-200">
|
||||
<span className="text-sm font-medium text-gray-700">預估單位生產成本
|
||||
<span className="text-xs text-gray-500 ml-1">(共 {Number(productionOrder.output_quantity || 0).toLocaleString(undefined, { maximumFractionDigits: 4 })} 份)</span>
|
||||
</span>
|
||||
<span className="text-md font-bold text-primary-main">
|
||||
{(productionOrder.output_quantity > 0 ? totalEstimatedCost / productionOrder.output_quantity : 0).toLocaleString(undefined, { maximumFractionDigits: 2 })} 元
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user