From 83f0f696431388b9f4a8a0c0053545bf4e9c5872 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B3=B4=EA=B3=A4?= Date: Tue, 3 Feb 2026 17:13:04 +0900 Subject: [PATCH] =?UTF-8?q?feat:=ED=99=88=ED=83=9D=EC=8A=A4=20=EC=84=B8?= =?UTF-8?q?=EA=B8=88=EA=B3=84=EC=82=B0=EC=84=9C=20=EB=A1=9C=EC=BB=AC=20?= =?UTF-8?q?=EC=A0=80=EC=9E=A5=20=ED=85=8C=EC=9D=B4=EB=B8=94=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 - hometax_invoices 테이블 생성 마이그레이션 - 국세청승인번호 기준 중복 방지 인덱스 - 매출/매입 구분, 금액정보, 거래처정보 저장 - 메모/분류/확인여부 등 자체 관리 필드 Co-Authored-By: Claude Opus 4.5 --- LOGICAL_RELATIONSHIPS.md | 37 ++++++++- ...3_170916_create_hometax_invoices_table.php | 77 +++++++++++++++++++ 2 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 database/migrations/2026_02_03_170916_create_hometax_invoices_table.php diff --git a/LOGICAL_RELATIONSHIPS.md b/LOGICAL_RELATIONSHIPS.md index cd1d384..2738d37 100644 --- a/LOGICAL_RELATIONSHIPS.md +++ b/LOGICAL_RELATIONSHIPS.md @@ -1,6 +1,6 @@ # 논리적 데이터베이스 관계 문서 -> **자동 생성**: 2026-01-30 19:54:12 +> **자동 생성**: 2026-02-03 17:09:34 > **소스**: Eloquent 모델 관계 분석 ## 📊 모델별 관계 현황 @@ -197,6 +197,7 @@ ### model_versions ### documents **모델**: `App\Models\Documents\Document` +- **template()**: belongsTo → `document_templates` - **creator()**: belongsTo → `users` - **updater()**: belongsTo → `users` - **approvals()**: hasMany → `document_approvals` @@ -223,6 +224,40 @@ ### document_datas - **document()**: belongsTo → `documents` +### document_templates +**모델**: `App\Models\Documents\DocumentTemplate` + +- **approvalLines()**: hasMany → `document_template_approval_lines` +- **basicFields()**: hasMany → `document_template_basic_fields` +- **sections()**: hasMany → `document_template_sections` +- **columns()**: hasMany → `document_template_columns` + +### document_template_approval_lines +**모델**: `App\Models\Documents\DocumentTemplateApprovalLine` + +- **template()**: belongsTo → `document_templates` + +### document_template_basic_fields +**모델**: `App\Models\Documents\DocumentTemplateBasicField` + +- **template()**: belongsTo → `document_templates` + +### document_template_columns +**모델**: `App\Models\Documents\DocumentTemplateColumn` + +- **template()**: belongsTo → `document_templates` + +### document_template_sections +**모델**: `App\Models\Documents\DocumentTemplateSection` + +- **template()**: belongsTo → `document_templates` +- **items()**: hasMany → `document_template_section_items` + +### document_template_section_items +**모델**: `App\Models\Documents\DocumentTemplateSectionItem` + +- **section()**: belongsTo → `document_template_sections` + ### estimates **모델**: `App\Models\Estimate\Estimate` diff --git a/database/migrations/2026_02_03_170916_create_hometax_invoices_table.php b/database/migrations/2026_02_03_170916_create_hometax_invoices_table.php new file mode 100644 index 0000000..1c2b3ab --- /dev/null +++ b/database/migrations/2026_02_03_170916_create_hometax_invoices_table.php @@ -0,0 +1,77 @@ +id(); + $table->foreignId('tenant_id')->constrained()->cascadeOnDelete(); + + // 고유 식별자 (중복 방지) + $table->string('nts_confirm_num', 50)->comment('국세청승인번호'); + $table->enum('invoice_type', ['sales', 'purchase'])->comment('매출/매입'); + + // 일자 정보 + $table->date('write_date')->comment('작성일자'); + $table->date('issue_date')->nullable()->comment('발급일자'); + $table->date('send_date')->nullable()->comment('전송일자'); + + // 공급자 정보 + $table->string('invoicer_corp_num', 20)->comment('공급자 사업자번호'); + $table->string('invoicer_corp_name', 100)->comment('공급자 상호'); + $table->string('invoicer_ceo_name', 50)->nullable()->comment('공급자 대표자'); + + // 공급받는자 정보 + $table->string('invoicee_corp_num', 20)->comment('공급받는자 사업자번호'); + $table->string('invoicee_corp_name', 100)->comment('공급받는자 상호'); + $table->string('invoicee_ceo_name', 50)->nullable()->comment('공급받는자 대표자'); + + // 금액 정보 + $table->bigInteger('supply_amount')->default(0)->comment('공급가액'); + $table->bigInteger('tax_amount')->default(0)->comment('세액'); + $table->bigInteger('total_amount')->default(0)->comment('합계'); + + // 구분 정보 + $table->tinyInteger('tax_type')->default(1)->comment('과세유형 1:과세 2:영세 3:면세'); + $table->tinyInteger('purpose_type')->default(1)->comment('영수/청구 1:영수 2:청구'); + $table->tinyInteger('issue_type')->default(1)->comment('발급유형 1:정발행 2:역발행'); + + // 기타 + $table->string('item_name', 200)->nullable()->comment('품목명'); + $table->string('remark', 500)->nullable()->comment('비고'); + + // 자체 관리 필드 + $table->string('memo', 500)->nullable()->comment('내부 메모'); + $table->string('category', 50)->nullable()->comment('분류 태그'); + $table->boolean('is_checked')->default(false)->comment('확인 여부'); + + // 동기화 정보 + $table->timestamp('synced_at')->nullable()->comment('마지막 동기화 시간'); + + $table->timestamps(); + $table->softDeletes(); + + // 인덱스 + $table->unique(['tenant_id', 'nts_confirm_num', 'invoice_type'], 'hometax_invoices_unique'); + $table->index(['tenant_id', 'invoice_type', 'write_date'], 'hometax_invoices_type_date'); + $table->index(['tenant_id', 'invoicer_corp_num'], 'hometax_invoices_invoicer'); + $table->index(['tenant_id', 'invoicee_corp_num'], 'hometax_invoices_invoicee'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('hometax_invoices'); + } +};