diff --git a/.gitignore b/.gitignore index d9535c5..8549ccb 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ Thumbs.db /docs/pptx_build /docs/presentation docs/Monthly_Report_2026_01.pptx +docs/f6_1770350984272.xlsx diff --git a/app/Modules/Integration/Controllers/ProductSyncController.php b/app/Modules/Integration/Controllers/ProductSyncController.php index af939ff..8cd1bf6 100644 --- a/app/Modules/Integration/Controllers/ProductSyncController.php +++ b/app/Modules/Integration/Controllers/ProductSyncController.php @@ -22,7 +22,6 @@ class ProductSyncController extends Controller 'external_pos_id' => 'required|string', 'name' => 'required|string', 'price' => 'nullable|numeric', - 'sku' => 'nullable|string', 'barcode' => 'nullable|string', 'category' => 'nullable|string', 'unit' => 'nullable|string', diff --git a/app/Modules/Inventory/Models/Product.php b/app/Modules/Inventory/Models/Product.php index 771eba5..29bb27d 100644 --- a/app/Modules/Inventory/Models/Product.php +++ b/app/Modules/Inventory/Models/Product.php @@ -18,7 +18,6 @@ class Product extends Model protected $fillable = [ 'code', 'barcode', - 'sku', 'name', 'external_pos_id', 'category_id', diff --git a/app/Modules/Inventory/Services/ProductService.php b/app/Modules/Inventory/Services/ProductService.php index 26b4bac..3df7832 100644 --- a/app/Modules/Inventory/Services/ProductService.php +++ b/app/Modules/Inventory/Services/ProductService.php @@ -38,12 +38,11 @@ class ProductService // Map allowed fields $product->name = $data['name']; $product->barcode = $data['barcode'] ?? $product->barcode; - $product->sku = $data['sku'] ?? $product->sku; // Maybe allow SKU update? $product->price = $data['price'] ?? 0; - // Generate Code if missing (use sku or external_id) + // Generate Code if missing (use code or external_id) if (empty($product->code)) { - $product->code = $data['code'] ?? ($product->sku ?? $product->external_pos_id); + $product->code = $data['code'] ?? $product->external_pos_id; } // Handle Category (Default: 未分類) diff --git a/database/migrations/tenant/2026_02_09_110739_drop_sku_from_products_table.php b/database/migrations/tenant/2026_02_09_110739_drop_sku_from_products_table.php new file mode 100644 index 0000000..8106b0a --- /dev/null +++ b/database/migrations/tenant/2026_02_09_110739_drop_sku_from_products_table.php @@ -0,0 +1,28 @@ +dropColumn('sku'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('products', function (Blueprint $table) { + // + }); + } +}; diff --git a/resources/js/Pages/Inventory/GoodsReceipt/Create.tsx b/resources/js/Pages/Inventory/GoodsReceipt/Create.tsx index 30e3637..5fdd967 100644 --- a/resources/js/Pages/Inventory/GoodsReceipt/Create.tsx +++ b/resources/js/Pages/Inventory/GoodsReceipt/Create.tsx @@ -123,7 +123,7 @@ export default function GoodsReceiptCreate({ warehouses, pendingPurchaseOrders, product_id: item.product_id, purchase_order_item_id: item.id, product_name: item.product_name, - sku: item.product_code, + product_code: item.product_code, unit: item.unit, quantity_ordered: item.quantity, quantity_received_so_far: item.received_quantity, @@ -157,7 +157,7 @@ export default function GoodsReceiptCreate({ warehouses, pendingPurchaseOrders, const newItem = { product_id: product.id, product_name: product.name, - sku: product.code, + product_code: product.code, quantity_received: 0, unit_price: product.price || 0, batch_number: '', @@ -266,7 +266,7 @@ export default function GoodsReceiptCreate({ warehouses, pendingPurchaseOrders, // Note: fetch might not have returned yet, so seq might be default 001 until fetch updates nextSequences const datePart = dateStr.replace(/-/g, ''); - const generatedBatch = `${item.sku}-${country}-${datePart}-${seq}`; + const generatedBatch = `${item.product_code}-${country}-${datePart}-${seq}`; if (item.batch_number !== generatedBatch) { // Update WITHOUT triggering re-render loop @@ -278,7 +278,7 @@ export default function GoodsReceiptCreate({ warehouses, pendingPurchaseOrders, } } }); - }, [nextSequences, JSON.stringify(data.items.map(i => ({ m: i.batchMode, c: i.originCountry, s: i.sku, p: i.product_id }))), data.received_date]); + }, [nextSequences, JSON.stringify(data.items.map(i => ({ m: i.batchMode, c: i.originCountry, s: i.product_code, p: i.product_id }))), data.received_date]); const submit = (e: React.FormEvent) => { e.preventDefault(); @@ -610,7 +610,7 @@ export default function GoodsReceiptCreate({ warehouses, pendingPurchaseOrders,
{item.product_name} - {item.sku} + {item.product_code}
@@ -654,7 +654,7 @@ export default function GoodsReceiptCreate({ warehouses, pendingPurchaseOrders, className="w-16 text-center px-1" />
- {getBatchPreview(item.product_id, item.sku, item.originCountry || 'TW', data.received_date)} + {getBatchPreview(item.product_id, item.product_code, item.originCountry || 'TW', data.received_date)}