From d9d01c2aaf8794fd33a215d6f808f62f3e1e621d Mon Sep 17 00:00:00 2001 From: hskwon Date: Mon, 28 Jul 2025 18:47:00 +0900 Subject: [PATCH] =?UTF-8?q?feat=20:=20=EC=9E=90=EC=9E=AC=EA=B4=80=EB=A6=AC?= =?UTF-8?q?,=20=EC=88=98=EC=9E=85=EA=B4=80=EB=A6=AC,=20=EB=A1=9C=ED=8A=B8?= =?UTF-8?q?=EA=B4=80=EB=A6=AC=20=EB=AA=A8=EB=8D=B8=EB=A7=81=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/Lot.php | 23 ++++++++++ app/Models/LotSale.php | 18 ++++++++ app/Models/Material.php | 35 +++++++++++++++ app/Models/MaterialInspection.php | 23 ++++++++++ app/Models/MaterialInspectionItem.php | 17 +++++++ app/Models/MaterialReceipt.php | 29 ++++++++++++ ...25_07_28_183746_create_materials_table.php | 28 ++++++++++++ ...25_07_28_183747_create_lot_sales_table.php | 27 +++++++++++ .../2025_07_28_183747_create_lots_table.php | 31 +++++++++++++ ...create_material_inspection_items_table.php | 25 +++++++++++ ...3747_create_material_inspections_table.php | 30 +++++++++++++ ..._183747_create_material_receipts_table.php | 35 +++++++++++++++ ..._add_foreign_keys_to_material_receipts.php | 45 +++++++++++++++++++ 13 files changed, 366 insertions(+) create mode 100644 app/Models/Lot.php create mode 100644 app/Models/LotSale.php create mode 100644 app/Models/Material.php create mode 100644 app/Models/MaterialInspection.php create mode 100644 app/Models/MaterialInspectionItem.php create mode 100644 app/Models/MaterialReceipt.php create mode 100644 database/migrations/2025_07_28_183746_create_materials_table.php create mode 100644 database/migrations/2025_07_28_183747_create_lot_sales_table.php create mode 100644 database/migrations/2025_07_28_183747_create_lots_table.php create mode 100644 database/migrations/2025_07_28_183747_create_material_inspection_items_table.php create mode 100644 database/migrations/2025_07_28_183747_create_material_inspections_table.php create mode 100644 database/migrations/2025_07_28_183747_create_material_receipts_table.php create mode 100644 database/migrations/2025_07_28_183748_add_foreign_keys_to_material_receipts.php diff --git a/app/Models/Lot.php b/app/Models/Lot.php new file mode 100644 index 0000000..b509c3b --- /dev/null +++ b/app/Models/Lot.php @@ -0,0 +1,23 @@ +belongsTo(Material::class, 'material_id'); + } + + // 판매 기록 + public function sales() + { + return $this->hasMany(LotSale::class, 'lot_id'); + } +} diff --git a/app/Models/LotSale.php b/app/Models/LotSale.php new file mode 100644 index 0000000..6369713 --- /dev/null +++ b/app/Models/LotSale.php @@ -0,0 +1,18 @@ +belongsTo(Lot::class, 'lot_id'); + } +} diff --git a/app/Models/Material.php b/app/Models/Material.php new file mode 100644 index 0000000..b5f272d --- /dev/null +++ b/app/Models/Material.php @@ -0,0 +1,35 @@ +hasMany(MaterialReceipt::class, 'material_id'); + } + + // 로트 관리 + public function lots() + { + return $this->hasMany(Lot::class, 'material_id'); + } +} diff --git a/app/Models/MaterialInspection.php b/app/Models/MaterialInspection.php new file mode 100644 index 0000000..8426d8b --- /dev/null +++ b/app/Models/MaterialInspection.php @@ -0,0 +1,23 @@ +belongsTo(MaterialReceipt::class, 'receipt_id'); + } + + // 검사 항목 + public function items() + { + return $this->hasMany(MaterialInspectionItem::class, 'inspection_id'); + } +} diff --git a/app/Models/MaterialInspectionItem.php b/app/Models/MaterialInspectionItem.php new file mode 100644 index 0000000..43162bc --- /dev/null +++ b/app/Models/MaterialInspectionItem.php @@ -0,0 +1,17 @@ +belongsTo(MaterialInspection::class, 'inspection_id'); + } +} diff --git a/app/Models/MaterialReceipt.php b/app/Models/MaterialReceipt.php new file mode 100644 index 0000000..17c1b49 --- /dev/null +++ b/app/Models/MaterialReceipt.php @@ -0,0 +1,29 @@ +belongsTo(Material::class, 'material_id'); + } + + // 수입검사 내역 + public function inspections() + { + return $this->hasMany(MaterialInspection::class, 'receipt_id'); + } +} diff --git a/database/migrations/2025_07_28_183746_create_materials_table.php b/database/migrations/2025_07_28_183746_create_materials_table.php new file mode 100644 index 0000000..7d27903 --- /dev/null +++ b/database/migrations/2025_07_28_183746_create_materials_table.php @@ -0,0 +1,28 @@ +id()->comment('자재 PK'); + $table->string('name', 100)->comment('자재명(품명)'); + $table->string('specification', 100)->nullable()->comment('규격'); + $table->string('material_code', 50)->unique()->comment('자재코드'); + $table->string('unit', 10)->comment('단위'); + $table->char('is_inspection', 1)->default('N')->comment('검사대상 여부(Y/N)'); + $table->text('search_tag')->nullable()->comment('검색 태그'); + $table->text('remarks')->nullable()->comment('비고'); + $table->timestamps(); + $table->softDeletes(); + }); + } + public function down(): void + { + Schema::dropIfExists('materials'); + } +}; diff --git a/database/migrations/2025_07_28_183747_create_lot_sales_table.php b/database/migrations/2025_07_28_183747_create_lot_sales_table.php new file mode 100644 index 0000000..a8903e1 --- /dev/null +++ b/database/migrations/2025_07_28_183747_create_lot_sales_table.php @@ -0,0 +1,27 @@ +id()->comment('로트별 판매기록 PK'); + $table->unsignedBigInteger('lot_id')->comment('로트ID'); + $table->date('sale_date')->comment('판매일'); + $table->string('author', 50)->nullable()->comment('등록자'); + $table->string('workplace_name', 60)->nullable()->comment('작업장명'); + $table->text('remarks')->nullable()->comment('비고'); + $table->timestamps(); + $table->softDeletes(); + $table->index('lot_id', 'idx_sales_lot_id'); + }); + } + public function down(): void + { + Schema::dropIfExists('lot_sales'); + } +}; diff --git a/database/migrations/2025_07_28_183747_create_lots_table.php b/database/migrations/2025_07_28_183747_create_lots_table.php new file mode 100644 index 0000000..9ac9f43 --- /dev/null +++ b/database/migrations/2025_07_28_183747_create_lots_table.php @@ -0,0 +1,31 @@ +id()->comment('로트관리 PK'); + $table->string('lot_number', 30)->unique()->comment('로트번호'); + $table->unsignedBigInteger('material_id')->comment('자재ID'); + $table->string('specification', 100)->nullable()->comment('규격'); + $table->string('length', 20)->nullable()->comment('길이'); + $table->integer('quantity')->comment('수량'); + $table->string('raw_lot_number', 30)->nullable()->comment('원자재 로트번호'); + $table->string('fabric_lot', 30)->nullable()->comment('원단 로트'); + $table->string('author', 50)->nullable()->comment('작성자'); + $table->text('remarks')->nullable()->comment('비고'); + $table->timestamps(); + $table->softDeletes(); + $table->index('material_id', 'idx_lots_material_id'); + }); + } + public function down(): void + { + Schema::dropIfExists('lots'); + } +}; diff --git a/database/migrations/2025_07_28_183747_create_material_inspection_items_table.php b/database/migrations/2025_07_28_183747_create_material_inspection_items_table.php new file mode 100644 index 0000000..b02428a --- /dev/null +++ b/database/migrations/2025_07_28_183747_create_material_inspection_items_table.php @@ -0,0 +1,25 @@ +id()->comment('검사항목 PK'); + $table->unsignedBigInteger('inspection_id')->comment('수입검사ID'); + $table->string('item_name', 100)->comment('검사항목명'); + $table->char('is_checked', 1)->default('N')->comment('체크여부(Y/N)'); + $table->timestamps(); + $table->softDeletes(); + $table->index('inspection_id', 'idx_items_inspection_id'); + }); + } + public function down(): void + { + Schema::dropIfExists('material_inspection_items'); + } +}; diff --git a/database/migrations/2025_07_28_183747_create_material_inspections_table.php b/database/migrations/2025_07_28_183747_create_material_inspections_table.php new file mode 100644 index 0000000..70407bb --- /dev/null +++ b/database/migrations/2025_07_28_183747_create_material_inspections_table.php @@ -0,0 +1,30 @@ +id()->comment('수입검사 PK'); + $table->unsignedBigInteger('receipt_id')->comment('자재입고ID'); + $table->date('inspection_date')->comment('검사일자'); + $table->string('inspector_name', 50)->nullable()->comment('검사자'); + $table->string('approver_name', 50)->nullable()->comment('결재자'); + $table->string('judgment_code', 30)->comment('종합판정(common_codes)'); + $table->string('status_code', 30)->comment('상태코드(common_codes)'); + $table->text('result_file_path')->nullable()->comment('성적서 PDF 경로'); + $table->text('remarks')->nullable()->comment('비고'); + $table->timestamps(); + $table->softDeletes(); + $table->index('receipt_id', 'idx_inspections_receipt_id'); + }); + } + public function down(): void + { + Schema::dropIfExists('material_inspections'); + } +}; diff --git a/database/migrations/2025_07_28_183747_create_material_receipts_table.php b/database/migrations/2025_07_28_183747_create_material_receipts_table.php new file mode 100644 index 0000000..a09ea50 --- /dev/null +++ b/database/migrations/2025_07_28_183747_create_material_receipts_table.php @@ -0,0 +1,35 @@ +id()->comment('자재입고 PK'); + $table->unsignedBigInteger('material_id')->comment('자재ID'); + $table->date('receipt_date')->comment('입고일'); + $table->string('lot_number', 30)->comment('로트번호'); + $table->decimal('received_qty', 12, 2)->comment('입고수량'); + $table->string('unit', 10)->comment('단위'); + $table->string('supplier_name', 100)->nullable()->comment('납품업체'); + $table->string('manufacturer_name', 100)->nullable()->comment('제조사'); + $table->decimal('purchase_price_excl_vat', 12, 2)->nullable()->comment('구매단가(부가세 제외)'); + $table->decimal('weight_kg', 12, 2)->nullable()->comment('총 무게(kg)'); + $table->string('status_code', 30)->comment('상태코드(common_codes)'); + $table->char('is_inspection', 1)->default('N')->comment('검사대상 여부(Y/N)'); + $table->date('inspection_date')->nullable()->comment('검사일자'); + $table->text('remarks')->nullable()->comment('비고'); + $table->timestamps(); + $table->softDeletes(); + $table->index('material_id', 'idx_receipts_material_id'); + }); + } + public function down(): void + { + Schema::dropIfExists('material_receipts'); + } +}; diff --git a/database/migrations/2025_07_28_183748_add_foreign_keys_to_material_receipts.php b/database/migrations/2025_07_28_183748_add_foreign_keys_to_material_receipts.php new file mode 100644 index 0000000..84bf02a --- /dev/null +++ b/database/migrations/2025_07_28_183748_add_foreign_keys_to_material_receipts.php @@ -0,0 +1,45 @@ +foreign('material_id', 'fk_receipts_material_id')->references('id')->on('materials'); + }); + Schema::table('material_inspections', function (Blueprint $table) { + $table->foreign('receipt_id', 'fk_inspections_receipt_id')->references('id')->on('material_receipts')->onDelete('cascade'); + }); + Schema::table('material_inspection_items', function (Blueprint $table) { + $table->foreign('inspection_id', 'fk_items_inspection_id')->references('id')->on('material_inspections')->onDelete('cascade'); + }); + Schema::table('lots', function (Blueprint $table) { + $table->foreign('material_id', 'fk_lots_material_id')->references('id')->on('materials'); + }); + Schema::table('lot_sales', function (Blueprint $table) { + $table->foreign('lot_id', 'fk_sales_lot_id')->references('id')->on('lots'); + }); + } + public function down(): void + { + Schema::table('material_receipts', function (Blueprint $table) { + $table->dropForeign('fk_receipts_material_id'); + }); + Schema::table('material_inspections', function (Blueprint $table) { + $table->dropForeign('fk_inspections_receipt_id'); + }); + Schema::table('material_inspection_items', function (Blueprint $table) { + $table->dropForeign('fk_items_inspection_id'); + }); + Schema::table('lots', function (Blueprint $table) { + $table->dropForeign('fk_lots_material_id'); + }); + Schema::table('lot_sales', function (Blueprint $table) { + $table->dropForeign('fk_sales_lot_id'); + }); + } +};