Compare commits
29 Commits
ad93743bdc
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d8f2361c88 | ||
| 74e3c21ee0 | |||
| 45a207d4a8 | |||
| 3fc5f511bc | |||
|
|
ee9f4d0b8f | ||
|
|
ca259ccb18 | ||
|
|
3929c5fd1e | ||
|
|
56c60ec3df | ||
|
|
60c4256bd0 | ||
|
|
1861f4daf2 | ||
|
|
c62e59ad17 | ||
|
|
e6f13e3870 | ||
|
|
1d5d161e05 | ||
|
|
0044779eb4 | ||
| 3ac64d5b76 | |||
| 2231c9a48f | |||
| ff8553055c | |||
| f2eede6e3a | |||
| c5d5b5d076 | |||
| 5ebf940873 | |||
| 293330c418 | |||
| a845f52fc0 | |||
| 0f26ea546a | |||
| 3600c7b12b | |||
| a6e29bc1f3 | |||
| 0aa0a8592d | |||
| 38c2402771 | |||
| 59d13eeb9f | |||
| 2df8ecf765 |
@@ -54,4 +54,4 @@ ## 관련 파일
|
||||
|
||||
- `api/app/Services/ComprehensiveAnalysisService.php`
|
||||
- `api/database/seeders/ComprehensiveAnalysisSeeder.php`
|
||||
- `docs/plans/react-mock-remaining-tasks.md`
|
||||
- `docs/dev/dev_plans/react-mock-remaining-tasks.md`
|
||||
|
||||
@@ -15,7 +15,7 @@ ## Phase 구성
|
||||
- Phase 5: MNG 관리자 패널 (4항목) — mng/ /system/alerts
|
||||
|
||||
## 핵심 파일
|
||||
- 계획 문서: docs/plans/db-backup-system-plan.md
|
||||
- 계획 문서: docs/dev/dev_plans/db-backup-system-plan.md
|
||||
- 개발서버: 114.203.209.83 (SSH: hskwon)
|
||||
- DB: sam (메인) + sam_stat (통계)
|
||||
- Slack 웹훅: api/.env → LOG_SLACK_WEBHOOK_URL (이미 설정됨)
|
||||
|
||||
@@ -16,7 +16,7 @@ ### 생성된 파일
|
||||
| 파일 | 설명 |
|
||||
|------|------|
|
||||
| `app/Http/Requests/Quote/QuoteBomBulkCalculateRequest.php` | 다건 BOM 산출 FormRequest |
|
||||
| `api/docs/changes/20260102_1300_quote_bom_bulk_calculation.md` | 변경 내용 문서 |
|
||||
| `api/docs/dev/changes/20260102_1300_quote_bom_bulk_calculation.md` | 변경 내용 문서 |
|
||||
|
||||
### 수정된 파일
|
||||
| 파일 | 설명 |
|
||||
@@ -93,9 +93,9 @@ ### QuoteCalculationService::calculateBomBulk()
|
||||
- 개별 품목 실패가 전체에 영향 없음 (예외 처리)
|
||||
|
||||
## 관련 문서
|
||||
- 계획 문서: `docs/plans/quote-calculation-api-plan.md`
|
||||
- Phase 1.1 문서: `docs/changes/20260102_quote_bom_calculation_api.md`
|
||||
- Phase 1.2 문서: `docs/changes/20260102_1300_quote_bom_bulk_calculation.md`
|
||||
- 계획 문서: `docs/dev/dev_plans/quote-calculation-api-plan.md`
|
||||
- Phase 1.1 문서: `docs/dev/changes/20260102_quote_bom_calculation_api.md`
|
||||
- Phase 1.2 문서: `docs/dev/changes/20260102_1300_quote_bom_bulk_calculation.md`
|
||||
|
||||
## 다음 단계
|
||||
- React 프론트엔드에서 `/calculate/bom/bulk` API 연동
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# 논리적 데이터베이스 관계 문서
|
||||
|
||||
> **자동 생성**: 2026-03-04 22:33:37
|
||||
> **자동 생성**: 2026-03-06 21:25:05
|
||||
> **소스**: Eloquent 모델 관계 분석
|
||||
|
||||
## 📊 모델별 관계 현황
|
||||
@@ -753,6 +753,38 @@ ### lot_sales
|
||||
|
||||
- **lot()**: belongsTo → `lots`
|
||||
|
||||
### performance_reports
|
||||
**모델**: `App\Models\Qualitys\PerformanceReport`
|
||||
|
||||
- **qualityDocument()**: belongsTo → `quality_documents`
|
||||
- **confirmer()**: belongsTo → `users`
|
||||
- **creator()**: belongsTo → `users`
|
||||
|
||||
### quality_documents
|
||||
**모델**: `App\Models\Qualitys\QualityDocument`
|
||||
|
||||
- **client()**: belongsTo → `clients`
|
||||
- **inspector()**: belongsTo → `users`
|
||||
- **creator()**: belongsTo → `users`
|
||||
- **documentOrders()**: hasMany → `quality_document_orders`
|
||||
- **locations()**: hasMany → `quality_document_locations`
|
||||
- **performanceReport()**: hasOne → `performance_reports`
|
||||
|
||||
### quality_document_locations
|
||||
**모델**: `App\Models\Qualitys\QualityDocumentLocation`
|
||||
|
||||
- **qualityDocument()**: belongsTo → `quality_documents`
|
||||
- **qualityDocumentOrder()**: belongsTo → `quality_document_orders`
|
||||
- **orderItem()**: belongsTo → `order_items`
|
||||
- **document()**: belongsTo → `documents`
|
||||
|
||||
### quality_document_orders
|
||||
**모델**: `App\Models\Qualitys\QualityDocumentOrder`
|
||||
|
||||
- **qualityDocument()**: belongsTo → `quality_documents`
|
||||
- **order()**: belongsTo → `orders`
|
||||
- **locations()**: hasMany → `quality_document_locations`
|
||||
|
||||
### quotes
|
||||
**모델**: `App\Models\Quote\Quote`
|
||||
|
||||
@@ -929,6 +961,16 @@ ### expense_accounts
|
||||
|
||||
- **vendor()**: belongsTo → `clients`
|
||||
|
||||
### journal_entrys
|
||||
**모델**: `App\Models\Tenants\JournalEntry`
|
||||
|
||||
- **lines()**: hasMany → `journal_entry_lines`
|
||||
|
||||
### journal_entry_lines
|
||||
**모델**: `App\Models\Tenants\JournalEntryLine`
|
||||
|
||||
- **journalEntry()**: belongsTo → `journal_entries`
|
||||
|
||||
### leaves
|
||||
**모델**: `App\Models\Tenants\Leave`
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* - 두께 매핑 (normalizeThickness)
|
||||
* - 면적 계산 (calculateArea)
|
||||
*
|
||||
* @see docs/plans/5130-sam-data-migration-plan.md 섹션 4.5
|
||||
* @see docs/dev_plans/5130-sam-data-migration-plan.md 섹션 4.5
|
||||
*/
|
||||
class Legacy5130Calculator
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
use App\Helpers\ApiResponse;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\V1\AccountSubject\StoreAccountSubjectRequest;
|
||||
use App\Http\Requests\V1\AccountSubject\UpdateAccountSubjectRequest;
|
||||
use App\Services\AccountCodeService;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -19,7 +20,10 @@ public function __construct(
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$params = $request->only(['search', 'category']);
|
||||
$params = $request->only([
|
||||
'search', 'category', 'sub_category',
|
||||
'department_type', 'depth', 'is_active', 'selectable',
|
||||
]);
|
||||
|
||||
$subjects = $this->service->index($params);
|
||||
|
||||
@@ -36,6 +40,16 @@ public function store(StoreAccountSubjectRequest $request)
|
||||
return ApiResponse::success($subject, __('message.created'), [], 201);
|
||||
}
|
||||
|
||||
/**
|
||||
* 계정과목 수정
|
||||
*/
|
||||
public function update(int $id, UpdateAccountSubjectRequest $request)
|
||||
{
|
||||
$subject = $this->service->update($id, $request->validated());
|
||||
|
||||
return ApiResponse::success($subject, __('message.updated'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 계정과목 활성/비활성 토글
|
||||
*/
|
||||
@@ -57,4 +71,17 @@ public function destroy(int $id)
|
||||
|
||||
return ApiResponse::success(null, __('message.deleted'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 기본 계정과목표 일괄 생성 (더존 표준)
|
||||
*/
|
||||
public function seedDefaults()
|
||||
{
|
||||
$count = $this->service->seedDefaults();
|
||||
|
||||
return ApiResponse::success(
|
||||
['inserted_count' => $count],
|
||||
__('message.created')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,12 +18,9 @@ public function __construct(
|
||||
*/
|
||||
public function show()
|
||||
{
|
||||
$setting = $this->barobillService->getSetting();
|
||||
|
||||
return ApiResponse::handle(
|
||||
data: $setting,
|
||||
message: __('message.fetched')
|
||||
);
|
||||
return ApiResponse::handle(function () {
|
||||
return $this->barobillService->getSetting();
|
||||
}, __('message.fetched'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -31,12 +28,9 @@ public function show()
|
||||
*/
|
||||
public function save(SaveBarobillSettingRequest $request)
|
||||
{
|
||||
$setting = $this->barobillService->saveSetting($request->validated());
|
||||
|
||||
return ApiResponse::handle(
|
||||
data: $setting,
|
||||
message: __('message.saved')
|
||||
);
|
||||
return ApiResponse::handle(function () use ($request) {
|
||||
return $this->barobillService->saveSetting($request->validated());
|
||||
}, __('message.saved'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,11 +38,8 @@ public function save(SaveBarobillSettingRequest $request)
|
||||
*/
|
||||
public function testConnection()
|
||||
{
|
||||
$result = $this->barobillService->testConnection();
|
||||
|
||||
return ApiResponse::handle(
|
||||
data: $result,
|
||||
message: __('message.barobill.connection_success')
|
||||
);
|
||||
return ApiResponse::handle(function () {
|
||||
return $this->barobillService->testConnection();
|
||||
}, __('message.barobill.connection_success'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
|
||||
use App\Helpers\ApiResponse;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Tenants\JournalEntry;
|
||||
use App\Services\CardTransactionService;
|
||||
use App\Services\JournalSyncService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -14,7 +16,8 @@
|
||||
class CardTransactionController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
protected CardTransactionService $service
|
||||
protected CardTransactionService $service,
|
||||
protected JournalSyncService $journalSyncService,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -148,4 +151,105 @@ public function destroy(int $id): JsonResponse
|
||||
return $this->service->destroy($id);
|
||||
}, __('message.deleted'));
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// 분개 (Journal Entries)
|
||||
// =========================================================================
|
||||
|
||||
/**
|
||||
* 카드 거래 분개 조회
|
||||
*/
|
||||
public function getJournalEntries(int $id): JsonResponse
|
||||
{
|
||||
return ApiResponse::handle(function () use ($id) {
|
||||
$sourceKey = "card_{$id}";
|
||||
$data = $this->journalSyncService->getForSource(
|
||||
JournalEntry::SOURCE_CARD_TRANSACTION,
|
||||
$sourceKey
|
||||
);
|
||||
|
||||
if (! $data) {
|
||||
return ['items' => []];
|
||||
}
|
||||
|
||||
// 프론트엔드가 기대하는 items 형식으로 변환
|
||||
$items = array_map(fn ($row) => [
|
||||
'id' => $row['id'],
|
||||
'supply_amount' => $row['debit_amount'],
|
||||
'tax_amount' => 0,
|
||||
'account_code' => $row['account_code'],
|
||||
'deduction_type' => 'deductible',
|
||||
'vendor_name' => $row['vendor_name'],
|
||||
'description' => $row['memo'],
|
||||
'memo' => '',
|
||||
], $data['rows']);
|
||||
|
||||
return ['items' => $items];
|
||||
}, __('message.fetched'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 카드 거래 분개 저장
|
||||
*/
|
||||
public function storeJournalEntries(Request $request, int $id): JsonResponse
|
||||
{
|
||||
return ApiResponse::handle(function () use ($request, $id) {
|
||||
$validated = $request->validate([
|
||||
'items' => 'required|array|min:1',
|
||||
'items.*.supply_amount' => 'required|integer|min:0',
|
||||
'items.*.tax_amount' => 'required|integer|min:0',
|
||||
'items.*.account_code' => 'required|string|max:20',
|
||||
'items.*.deduction_type' => 'nullable|string|max:20',
|
||||
'items.*.vendor_name' => 'nullable|string|max:200',
|
||||
'items.*.description' => 'nullable|string|max:500',
|
||||
'items.*.memo' => 'nullable|string|max:500',
|
||||
]);
|
||||
|
||||
// 카드 거래 정보 조회 (날짜용)
|
||||
$transaction = $this->service->show($id);
|
||||
if (! $transaction) {
|
||||
throw new \Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
}
|
||||
|
||||
$entryDate = $transaction->used_at
|
||||
? $transaction->used_at->format('Y-m-d')
|
||||
: ($transaction->withdrawal_date?->format('Y-m-d') ?? now()->format('Y-m-d'));
|
||||
|
||||
// items → journal rows 변환 (각 item을 차변 행으로)
|
||||
$rows = [];
|
||||
foreach ($validated['items'] as $item) {
|
||||
$amount = ($item['supply_amount'] ?? 0) + ($item['tax_amount'] ?? 0);
|
||||
$rows[] = [
|
||||
'side' => 'debit',
|
||||
'account_code' => $item['account_code'],
|
||||
'debit_amount' => $amount,
|
||||
'credit_amount' => 0,
|
||||
'vendor_name' => $item['vendor_name'] ?? '',
|
||||
'memo' => $item['description'] ?? $item['memo'] ?? '',
|
||||
];
|
||||
}
|
||||
|
||||
// 대변 합계 행 (카드미지급금)
|
||||
$totalAmount = array_sum(array_column($rows, 'debit_amount'));
|
||||
$rows[] = [
|
||||
'side' => 'credit',
|
||||
'account_code' => '25300', // 미지급금 (표준 코드)
|
||||
'account_name' => '미지급금',
|
||||
'debit_amount' => 0,
|
||||
'credit_amount' => $totalAmount,
|
||||
'vendor_name' => $transaction->merchant_name ?? '',
|
||||
'memo' => '카드결제',
|
||||
];
|
||||
|
||||
$sourceKey = "card_{$id}";
|
||||
|
||||
return $this->journalSyncService->saveForSource(
|
||||
JournalEntry::SOURCE_CARD_TRANSACTION,
|
||||
$sourceKey,
|
||||
$entryDate,
|
||||
"카드거래 분개 (#{$id})",
|
||||
$rows,
|
||||
);
|
||||
}, __('message.created'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,6 +74,22 @@ public function destroy(int $id): JsonResponse
|
||||
}, __('message.deleted'));
|
||||
}
|
||||
|
||||
/**
|
||||
* rendered_html 스냅샷 저장 (Lazy Snapshot)
|
||||
* PATCH /v1/documents/{id}/snapshot
|
||||
*/
|
||||
public function patchSnapshot(int $id, UpdateRequest $request): JsonResponse
|
||||
{
|
||||
return ApiResponse::handle(function () use ($id, $request) {
|
||||
$renderedHtml = $request->validated()['rendered_html'] ?? null;
|
||||
if (! $renderedHtml) {
|
||||
throw new \Symfony\Component\HttpKernel\Exception\BadRequestHttpException('rendered_html is required');
|
||||
}
|
||||
|
||||
return $this->service->patchSnapshot($id, $renderedHtml);
|
||||
}, __('message.updated'));
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// FQC 일괄생성 (제품검사)
|
||||
// =========================================================================
|
||||
|
||||
59
app/Http/Controllers/Api/V1/PerformanceReportController.php
Normal file
59
app/Http/Controllers/Api/V1/PerformanceReportController.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\V1;
|
||||
|
||||
use App\Helpers\ApiResponse;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Quality\PerformanceReportConfirmRequest;
|
||||
use App\Http\Requests\Quality\PerformanceReportMemoRequest;
|
||||
use App\Services\PerformanceReportService;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PerformanceReportController extends Controller
|
||||
{
|
||||
public function __construct(private PerformanceReportService $service) {}
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($request) {
|
||||
return $this->service->index($request->all());
|
||||
}, __('message.fetched'));
|
||||
}
|
||||
|
||||
public function stats(Request $request)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($request) {
|
||||
return $this->service->stats($request->all());
|
||||
}, __('message.fetched'));
|
||||
}
|
||||
|
||||
public function confirm(PerformanceReportConfirmRequest $request)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($request) {
|
||||
return $this->service->confirm($request->validated()['ids']);
|
||||
}, __('message.updated'));
|
||||
}
|
||||
|
||||
public function unconfirm(PerformanceReportConfirmRequest $request)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($request) {
|
||||
return $this->service->unconfirm($request->validated()['ids']);
|
||||
}, __('message.updated'));
|
||||
}
|
||||
|
||||
public function updateMemo(PerformanceReportMemoRequest $request)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($request) {
|
||||
$data = $request->validated();
|
||||
|
||||
return $this->service->updateMemo($data['ids'], $data['memo']);
|
||||
}, __('message.updated'));
|
||||
}
|
||||
|
||||
public function missing(Request $request)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($request) {
|
||||
return $this->service->missing($request->all());
|
||||
}, __('message.fetched'));
|
||||
}
|
||||
}
|
||||
50
app/Http/Controllers/Api/V1/ProductionOrderController.php
Normal file
50
app/Http/Controllers/Api/V1/ProductionOrderController.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\V1;
|
||||
|
||||
use App\Helpers\ApiResponse;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\ProductionOrder\ProductionOrderIndexRequest;
|
||||
use App\Services\ProductionOrderService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
class ProductionOrderController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ProductionOrderService $service
|
||||
) {}
|
||||
|
||||
/**
|
||||
* 생산지시 목록 조회
|
||||
*/
|
||||
public function index(ProductionOrderIndexRequest $request): JsonResponse
|
||||
{
|
||||
$result = $this->service->index($request->validated());
|
||||
|
||||
return ApiResponse::success($result, __('message.fetched'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 생산지시 상태별 통계
|
||||
*/
|
||||
public function stats(): JsonResponse
|
||||
{
|
||||
$stats = $this->service->stats();
|
||||
|
||||
return ApiResponse::success($stats, __('message.fetched'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 생산지시 상세 조회
|
||||
*/
|
||||
public function show(int $orderId): JsonResponse
|
||||
{
|
||||
try {
|
||||
$detail = $this->service->show($orderId);
|
||||
|
||||
return ApiResponse::success($detail, __('message.fetched'));
|
||||
} catch (\Illuminate\Database\Eloquent\ModelNotFoundException $e) {
|
||||
return ApiResponse::error(__('error.order.not_found'), 404);
|
||||
}
|
||||
}
|
||||
}
|
||||
127
app/Http/Controllers/Api/V1/QualityDocumentController.php
Normal file
127
app/Http/Controllers/Api/V1/QualityDocumentController.php
Normal file
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\V1;
|
||||
|
||||
use App\Helpers\ApiResponse;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Quality\QualityDocumentStoreRequest;
|
||||
use App\Http\Requests\Quality\QualityDocumentUpdateRequest;
|
||||
use App\Services\QualityDocumentService;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class QualityDocumentController extends Controller
|
||||
{
|
||||
public function __construct(private QualityDocumentService $service) {}
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($request) {
|
||||
return $this->service->index($request->all());
|
||||
}, __('message.fetched'));
|
||||
}
|
||||
|
||||
public function stats(Request $request)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($request) {
|
||||
return $this->service->stats($request->all());
|
||||
}, __('message.fetched'));
|
||||
}
|
||||
|
||||
public function calendar(Request $request)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($request) {
|
||||
return $this->service->calendar($request->all());
|
||||
}, __('message.fetched'));
|
||||
}
|
||||
|
||||
public function availableOrders(Request $request)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($request) {
|
||||
return $this->service->availableOrders($request->all());
|
||||
}, __('message.fetched'));
|
||||
}
|
||||
|
||||
public function show(int $id)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($id) {
|
||||
return $this->service->show($id);
|
||||
}, __('message.fetched'));
|
||||
}
|
||||
|
||||
public function store(QualityDocumentStoreRequest $request)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($request) {
|
||||
return $this->service->store($request->validated());
|
||||
}, __('message.created'));
|
||||
}
|
||||
|
||||
public function update(QualityDocumentUpdateRequest $request, int $id)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($request, $id) {
|
||||
return $this->service->update($id, $request->validated());
|
||||
}, __('message.updated'));
|
||||
}
|
||||
|
||||
public function destroy(int $id)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($id) {
|
||||
$this->service->destroy($id);
|
||||
|
||||
return 'success';
|
||||
}, __('message.deleted'));
|
||||
}
|
||||
|
||||
public function complete(int $id)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($id) {
|
||||
return $this->service->complete($id);
|
||||
}, __('message.updated'));
|
||||
}
|
||||
|
||||
public function attachOrders(Request $request, int $id)
|
||||
{
|
||||
$request->validate([
|
||||
'order_ids' => ['required', 'array', 'min:1'],
|
||||
'order_ids.*' => ['required', 'integer'],
|
||||
]);
|
||||
|
||||
return ApiResponse::handle(function () use ($request, $id) {
|
||||
return $this->service->attachOrders($id, $request->input('order_ids'));
|
||||
}, __('message.updated'));
|
||||
}
|
||||
|
||||
public function detachOrder(int $id, int $orderId)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($id, $orderId) {
|
||||
return $this->service->detachOrder($id, $orderId);
|
||||
}, __('message.updated'));
|
||||
}
|
||||
|
||||
public function inspectLocation(Request $request, int $id, int $locId)
|
||||
{
|
||||
$request->validate([
|
||||
'post_width' => ['nullable', 'integer'],
|
||||
'post_height' => ['nullable', 'integer'],
|
||||
'change_reason' => ['nullable', 'string', 'max:500'],
|
||||
'inspection_status' => ['nullable', 'string', 'in:pending,completed'],
|
||||
]);
|
||||
|
||||
return ApiResponse::handle(function () use ($request, $id, $locId) {
|
||||
return $this->service->inspectLocation($id, $locId, $request->all());
|
||||
}, __('message.updated'));
|
||||
}
|
||||
|
||||
public function requestDocument(int $id)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($id) {
|
||||
return $this->service->requestDocument($id);
|
||||
}, __('message.fetched'));
|
||||
}
|
||||
|
||||
public function resultDocument(int $id)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($id) {
|
||||
return $this->service->resultDocument($id);
|
||||
}, __('message.fetched'));
|
||||
}
|
||||
}
|
||||
@@ -10,12 +10,17 @@
|
||||
use App\Http\Requests\TaxInvoice\TaxInvoiceSummaryRequest;
|
||||
use App\Http\Requests\TaxInvoice\UpdateTaxInvoiceRequest;
|
||||
use App\Http\Requests\V1\TaxInvoice\BulkIssueRequest;
|
||||
use App\Models\Tenants\JournalEntry;
|
||||
use App\Services\JournalSyncService;
|
||||
use App\Services\TaxInvoiceService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TaxInvoiceController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private TaxInvoiceService $taxInvoiceService
|
||||
private TaxInvoiceService $taxInvoiceService,
|
||||
private JournalSyncService $journalSyncService,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -23,12 +28,9 @@ public function __construct(
|
||||
*/
|
||||
public function index(TaxInvoiceListRequest $request)
|
||||
{
|
||||
$taxInvoices = $this->taxInvoiceService->list($request->validated());
|
||||
|
||||
return ApiResponse::handle(
|
||||
data: $taxInvoices,
|
||||
message: __('message.fetched')
|
||||
);
|
||||
return ApiResponse::handle(function () use ($request) {
|
||||
return $this->taxInvoiceService->list($request->validated());
|
||||
}, __('message.fetched'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -36,12 +38,9 @@ public function index(TaxInvoiceListRequest $request)
|
||||
*/
|
||||
public function show(int $id)
|
||||
{
|
||||
$taxInvoice = $this->taxInvoiceService->show($id);
|
||||
|
||||
return ApiResponse::handle(
|
||||
data: $taxInvoice,
|
||||
message: __('message.fetched')
|
||||
);
|
||||
return ApiResponse::handle(function () use ($id) {
|
||||
return $this->taxInvoiceService->show($id);
|
||||
}, __('message.fetched'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -49,13 +48,9 @@ public function show(int $id)
|
||||
*/
|
||||
public function store(CreateTaxInvoiceRequest $request)
|
||||
{
|
||||
$taxInvoice = $this->taxInvoiceService->create($request->validated());
|
||||
|
||||
return ApiResponse::handle(
|
||||
data: $taxInvoice,
|
||||
message: __('message.created'),
|
||||
status: 201
|
||||
);
|
||||
return ApiResponse::handle(function () use ($request) {
|
||||
return $this->taxInvoiceService->create($request->validated());
|
||||
}, __('message.created'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,12 +58,9 @@ public function store(CreateTaxInvoiceRequest $request)
|
||||
*/
|
||||
public function update(UpdateTaxInvoiceRequest $request, int $id)
|
||||
{
|
||||
$taxInvoice = $this->taxInvoiceService->update($id, $request->validated());
|
||||
|
||||
return ApiResponse::handle(
|
||||
data: $taxInvoice,
|
||||
message: __('message.updated')
|
||||
);
|
||||
return ApiResponse::handle(function () use ($request, $id) {
|
||||
return $this->taxInvoiceService->update($id, $request->validated());
|
||||
}, __('message.updated'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,12 +68,11 @@ public function update(UpdateTaxInvoiceRequest $request, int $id)
|
||||
*/
|
||||
public function destroy(int $id)
|
||||
{
|
||||
$this->taxInvoiceService->delete($id);
|
||||
return ApiResponse::handle(function () use ($id) {
|
||||
$this->taxInvoiceService->delete($id);
|
||||
|
||||
return ApiResponse::handle(
|
||||
data: null,
|
||||
message: __('message.deleted')
|
||||
);
|
||||
return null;
|
||||
}, __('message.deleted'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,12 +80,9 @@ public function destroy(int $id)
|
||||
*/
|
||||
public function issue(int $id)
|
||||
{
|
||||
$taxInvoice = $this->taxInvoiceService->issue($id);
|
||||
|
||||
return ApiResponse::handle(
|
||||
data: $taxInvoice,
|
||||
message: __('message.tax_invoice.issued')
|
||||
);
|
||||
return ApiResponse::handle(function () use ($id) {
|
||||
return $this->taxInvoiceService->issue($id);
|
||||
}, __('message.tax_invoice.issued'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,12 +90,9 @@ public function issue(int $id)
|
||||
*/
|
||||
public function bulkIssue(BulkIssueRequest $request)
|
||||
{
|
||||
$result = $this->taxInvoiceService->bulkIssue($request->getIds());
|
||||
|
||||
return ApiResponse::handle(
|
||||
data: $result,
|
||||
message: __('message.tax_invoice.bulk_issued')
|
||||
);
|
||||
return ApiResponse::handle(function () use ($request) {
|
||||
return $this->taxInvoiceService->bulkIssue($request->getIds());
|
||||
}, __('message.tax_invoice.bulk_issued'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,12 +100,9 @@ public function bulkIssue(BulkIssueRequest $request)
|
||||
*/
|
||||
public function cancel(CancelTaxInvoiceRequest $request, int $id)
|
||||
{
|
||||
$taxInvoice = $this->taxInvoiceService->cancel($id, $request->validated()['reason']);
|
||||
|
||||
return ApiResponse::handle(
|
||||
data: $taxInvoice,
|
||||
message: __('message.tax_invoice.cancelled')
|
||||
);
|
||||
return ApiResponse::handle(function () use ($request, $id) {
|
||||
return $this->taxInvoiceService->cancel($id, $request->validated()['reason']);
|
||||
}, __('message.tax_invoice.cancelled'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,12 +110,9 @@ public function cancel(CancelTaxInvoiceRequest $request, int $id)
|
||||
*/
|
||||
public function checkStatus(int $id)
|
||||
{
|
||||
$taxInvoice = $this->taxInvoiceService->checkStatus($id);
|
||||
|
||||
return ApiResponse::handle(
|
||||
data: $taxInvoice,
|
||||
message: __('message.fetched')
|
||||
);
|
||||
return ApiResponse::handle(function () use ($id) {
|
||||
return $this->taxInvoiceService->checkStatus($id);
|
||||
}, __('message.fetched'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -141,11 +120,79 @@ public function checkStatus(int $id)
|
||||
*/
|
||||
public function summary(TaxInvoiceSummaryRequest $request)
|
||||
{
|
||||
$summary = $this->taxInvoiceService->summary($request->validated());
|
||||
return ApiResponse::handle(function () use ($request) {
|
||||
return $this->taxInvoiceService->summary($request->validated());
|
||||
}, __('message.fetched'));
|
||||
}
|
||||
|
||||
return ApiResponse::handle(
|
||||
data: $summary,
|
||||
message: __('message.fetched')
|
||||
);
|
||||
// =========================================================================
|
||||
// 분개 (Journal Entries)
|
||||
// =========================================================================
|
||||
|
||||
/**
|
||||
* 세금계산서 분개 조회
|
||||
*/
|
||||
public function getJournalEntries(int $id): JsonResponse
|
||||
{
|
||||
return ApiResponse::handle(function () use ($id) {
|
||||
$sourceKey = "tax_invoice_{$id}";
|
||||
$data = $this->journalSyncService->getForSource(
|
||||
JournalEntry::SOURCE_TAX_INVOICE,
|
||||
$sourceKey
|
||||
);
|
||||
|
||||
return $data ?? ['rows' => []];
|
||||
}, __('message.fetched'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 세금계산서 분개 저장/수정
|
||||
*/
|
||||
public function storeJournalEntries(Request $request, int $id): JsonResponse
|
||||
{
|
||||
return ApiResponse::handle(function () use ($request, $id) {
|
||||
$validated = $request->validate([
|
||||
'rows' => 'required|array|min:1',
|
||||
'rows.*.side' => 'required|in:debit,credit',
|
||||
'rows.*.account_subject' => 'required|string|max:20',
|
||||
'rows.*.debit_amount' => 'required|integer|min:0',
|
||||
'rows.*.credit_amount' => 'required|integer|min:0',
|
||||
]);
|
||||
|
||||
// 세금계산서 정보 조회 (entry_date용)
|
||||
$taxInvoice = $this->taxInvoiceService->show($id);
|
||||
|
||||
$rows = array_map(fn ($row) => [
|
||||
'side' => $row['side'],
|
||||
'account_code' => $row['account_subject'],
|
||||
'debit_amount' => $row['debit_amount'],
|
||||
'credit_amount' => $row['credit_amount'],
|
||||
], $validated['rows']);
|
||||
|
||||
$sourceKey = "tax_invoice_{$id}";
|
||||
|
||||
return $this->journalSyncService->saveForSource(
|
||||
JournalEntry::SOURCE_TAX_INVOICE,
|
||||
$sourceKey,
|
||||
$taxInvoice->issue_date?->format('Y-m-d') ?? now()->format('Y-m-d'),
|
||||
"세금계산서 분개 (#{$id})",
|
||||
$rows,
|
||||
);
|
||||
}, __('message.created'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 세금계산서 분개 삭제
|
||||
*/
|
||||
public function deleteJournalEntries(int $id): JsonResponse
|
||||
{
|
||||
return ApiResponse::handle(function () use ($id) {
|
||||
$sourceKey = "tax_invoice_{$id}";
|
||||
|
||||
return $this->journalSyncService->deleteForSource(
|
||||
JournalEntry::SOURCE_TAX_INVOICE,
|
||||
$sourceKey
|
||||
);
|
||||
}, __('message.deleted'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,14 +61,18 @@ public function detail(Request $request): JsonResponse
|
||||
: 0.05;
|
||||
$year = $request->query('year') ? (int) $request->query('year') : null;
|
||||
$quarter = $request->query('quarter') ? (int) $request->query('quarter') : null;
|
||||
$startDate = $request->query('start_date');
|
||||
$endDate = $request->query('end_date');
|
||||
|
||||
return ApiResponse::handle(function () use ($calculationType, $fixedAmountPerMonth, $ratio, $year, $quarter) {
|
||||
return ApiResponse::handle(function () use ($calculationType, $fixedAmountPerMonth, $ratio, $year, $quarter, $startDate, $endDate) {
|
||||
return $this->welfareService->getDetail(
|
||||
$calculationType,
|
||||
$fixedAmountPerMonth,
|
||||
$ratio,
|
||||
$year,
|
||||
$quarter
|
||||
$quarter,
|
||||
$startDate,
|
||||
$endDate
|
||||
);
|
||||
}, __('message.fetched'));
|
||||
}
|
||||
|
||||
@@ -28,6 +28,9 @@ public function rules(): array
|
||||
'approvers.*.user_id' => 'required_with:approvers|integer|exists:users,id',
|
||||
'approvers.*.role' => 'nullable|string|max:50',
|
||||
|
||||
// HTML 스냅샷
|
||||
'rendered_html' => 'nullable|string',
|
||||
|
||||
// 문서 데이터 (EAV)
|
||||
'data' => 'nullable|array',
|
||||
'data.*.section_id' => 'nullable|integer',
|
||||
|
||||
@@ -27,6 +27,9 @@ public function rules(): array
|
||||
'approvers.*.user_id' => 'required_with:approvers|integer|exists:users,id',
|
||||
'approvers.*.role' => 'nullable|string|max:50',
|
||||
|
||||
// HTML 스냅샷
|
||||
'rendered_html' => 'nullable|string',
|
||||
|
||||
// 문서 데이터 (EAV)
|
||||
'data' => 'nullable|array',
|
||||
'data.*.section_id' => 'nullable|integer',
|
||||
|
||||
@@ -30,6 +30,9 @@ public function rules(): array
|
||||
'data.*.field_key' => 'required_with:data|string|max:100',
|
||||
'data.*.field_value' => 'nullable|string',
|
||||
|
||||
// HTML 스냅샷
|
||||
'rendered_html' => 'nullable|string',
|
||||
|
||||
// 첨부파일
|
||||
'attachments' => 'nullable|array',
|
||||
'attachments.*.file_id' => 'required_with:attachments|integer|exists:files,id',
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\ProductionOrder;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ProductionOrderIndexRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'search' => 'nullable|string|max:100',
|
||||
'production_status' => 'nullable|in:waiting,in_production,completed',
|
||||
'sort_by' => 'nullable|in:created_at,delivery_date,order_no',
|
||||
'sort_dir' => 'nullable|in:asc,desc',
|
||||
'page' => 'nullable|integer|min:1',
|
||||
'per_page' => 'nullable|integer|min:1|max:100',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Quality;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class PerformanceReportConfirmRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'ids' => ['required', 'array', 'min:1'],
|
||||
'ids.*' => ['required', 'integer', 'exists:performance_reports,id'],
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'ids.required' => __('validation.required', ['attribute' => '실적신고 ID']),
|
||||
'ids.min' => __('validation.min.array', ['attribute' => '실적신고 ID', 'min' => 1]),
|
||||
];
|
||||
}
|
||||
}
|
||||
30
app/Http/Requests/Quality/PerformanceReportMemoRequest.php
Normal file
30
app/Http/Requests/Quality/PerformanceReportMemoRequest.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Quality;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class PerformanceReportMemoRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'ids' => ['required', 'array', 'min:1'],
|
||||
'ids.*' => ['required', 'integer', 'exists:performance_reports,id'],
|
||||
'memo' => ['required', 'string', 'max:1000'],
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'ids.required' => __('validation.required', ['attribute' => '실적신고 ID']),
|
||||
'memo.required' => __('validation.required', ['attribute' => '메모']),
|
||||
];
|
||||
}
|
||||
}
|
||||
45
app/Http/Requests/Quality/QualityDocumentStoreRequest.php
Normal file
45
app/Http/Requests/Quality/QualityDocumentStoreRequest.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Quality;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class QualityDocumentStoreRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'site_name' => ['required', 'string', 'max:200'],
|
||||
'client_id' => ['nullable', 'integer', 'exists:clients,id'],
|
||||
'inspector_id' => ['nullable', 'integer', 'exists:users,id'],
|
||||
'received_date' => ['nullable', 'date'],
|
||||
'options' => ['nullable', 'array'],
|
||||
'options.manager' => ['nullable', 'array'],
|
||||
'options.manager.name' => ['nullable', 'string', 'max:50'],
|
||||
'options.manager.phone' => ['nullable', 'string', 'max:30'],
|
||||
'options.inspection' => ['nullable', 'array'],
|
||||
'options.inspection.request_date' => ['nullable', 'date'],
|
||||
'options.inspection.start_date' => ['nullable', 'date'],
|
||||
'options.inspection.end_date' => ['nullable', 'date'],
|
||||
'options.site_address' => ['nullable', 'array'],
|
||||
'options.construction_site' => ['nullable', 'array'],
|
||||
'options.material_distributor' => ['nullable', 'array'],
|
||||
'options.contractor' => ['nullable', 'array'],
|
||||
'options.supervisor' => ['nullable', 'array'],
|
||||
'order_ids' => ['nullable', 'array'],
|
||||
'order_ids.*' => ['integer', 'exists:orders,id'],
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'site_name.required' => __('validation.required', ['attribute' => '현장명']),
|
||||
];
|
||||
}
|
||||
}
|
||||
44
app/Http/Requests/Quality/QualityDocumentUpdateRequest.php
Normal file
44
app/Http/Requests/Quality/QualityDocumentUpdateRequest.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Quality;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class QualityDocumentUpdateRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'site_name' => ['sometimes', 'string', 'max:200'],
|
||||
'client_id' => ['nullable', 'integer', 'exists:clients,id'],
|
||||
'inspector_id' => ['nullable', 'integer', 'exists:users,id'],
|
||||
'received_date' => ['nullable', 'date'],
|
||||
'options' => ['nullable', 'array'],
|
||||
'options.manager' => ['nullable', 'array'],
|
||||
'options.manager.name' => ['nullable', 'string', 'max:50'],
|
||||
'options.manager.phone' => ['nullable', 'string', 'max:30'],
|
||||
'options.inspection' => ['nullable', 'array'],
|
||||
'options.inspection.request_date' => ['nullable', 'date'],
|
||||
'options.inspection.start_date' => ['nullable', 'date'],
|
||||
'options.inspection.end_date' => ['nullable', 'date'],
|
||||
'options.site_address' => ['nullable', 'array'],
|
||||
'options.construction_site' => ['nullable', 'array'],
|
||||
'options.material_distributor' => ['nullable', 'array'],
|
||||
'options.contractor' => ['nullable', 'array'],
|
||||
'options.supervisor' => ['nullable', 'array'],
|
||||
'order_ids' => ['nullable', 'array'],
|
||||
'order_ids.*' => ['integer', 'exists:orders,id'],
|
||||
'locations' => ['nullable', 'array'],
|
||||
'locations.*.id' => ['required', 'integer'],
|
||||
'locations.*.post_width' => ['nullable', 'integer'],
|
||||
'locations.*.post_height' => ['nullable', 'integer'],
|
||||
'locations.*.change_reason' => ['nullable', 'string', 'max:500'],
|
||||
'locations.*.inspection_data' => ['nullable', 'array'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -20,18 +20,18 @@ public function rules(): array
|
||||
'issue_type' => ['required', 'string', Rule::in(TaxInvoice::ISSUE_TYPES)],
|
||||
'direction' => ['required', 'string', Rule::in(TaxInvoice::DIRECTIONS)],
|
||||
|
||||
// 공급자 정보
|
||||
'supplier_corp_num' => ['required', 'string', 'max:20'],
|
||||
'supplier_corp_name' => ['required', 'string', 'max:100'],
|
||||
// 공급자 정보 (매입 시 필수, 매출 시 선택)
|
||||
'supplier_corp_num' => ['required_if:direction,purchases', 'nullable', 'string', 'max:20'],
|
||||
'supplier_corp_name' => ['required_if:direction,purchases', 'nullable', 'string', 'max:100'],
|
||||
'supplier_ceo_name' => ['nullable', 'string', 'max:50'],
|
||||
'supplier_addr' => ['nullable', 'string', 'max:200'],
|
||||
'supplier_biz_type' => ['nullable', 'string', 'max:100'],
|
||||
'supplier_biz_class' => ['nullable', 'string', 'max:100'],
|
||||
'supplier_contact_id' => ['nullable', 'string', 'email', 'max:100'],
|
||||
|
||||
// 공급받는자 정보
|
||||
'buyer_corp_num' => ['required', 'string', 'max:20'],
|
||||
'buyer_corp_name' => ['required', 'string', 'max:100'],
|
||||
// 공급받는자 정보 (매출 시 필수, 매입 시 선택)
|
||||
'buyer_corp_num' => ['required_if:direction,sales', 'nullable', 'string', 'max:20'],
|
||||
'buyer_corp_name' => ['required_if:direction,sales', 'nullable', 'string', 'max:100'],
|
||||
'buyer_ceo_name' => ['nullable', 'string', 'max:50'],
|
||||
'buyer_addr' => ['nullable', 'string', 'max:200'],
|
||||
'buyer_biz_type' => ['nullable', 'string', 'max:100'],
|
||||
|
||||
@@ -17,6 +17,12 @@ public function rules(): array
|
||||
'code' => ['required', 'string', 'max:10'],
|
||||
'name' => ['required', 'string', 'max:100'],
|
||||
'category' => ['nullable', 'string', 'in:asset,liability,capital,revenue,expense'],
|
||||
'sub_category' => ['nullable', 'string', 'max:50'],
|
||||
'parent_code' => ['nullable', 'string', 'max:10'],
|
||||
'depth' => ['nullable', 'integer', 'in:1,2,3'],
|
||||
'department_type' => ['nullable', 'string', 'in:common,manufacturing,admin'],
|
||||
'description' => ['nullable', 'string', 'max:500'],
|
||||
'sort_order' => ['nullable', 'integer'],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -26,6 +32,8 @@ public function messages(): array
|
||||
'code.required' => '계정과목 코드를 입력하세요.',
|
||||
'name.required' => '계정과목명을 입력하세요.',
|
||||
'category.in' => '유효한 분류를 선택하세요.',
|
||||
'depth.in' => '계층은 1(대), 2(중), 3(소) 중 하나여야 합니다.',
|
||||
'department_type.in' => '부문은 common, manufacturing, admin 중 하나여야 합니다.',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V1\AccountSubject;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateAccountSubjectRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['sometimes', 'string', 'max:100'],
|
||||
'category' => ['nullable', 'string', 'in:asset,liability,capital,revenue,expense'],
|
||||
'sub_category' => ['nullable', 'string', 'max:50'],
|
||||
'parent_code' => ['nullable', 'string', 'max:10'],
|
||||
'depth' => ['nullable', 'integer', 'in:1,2,3'],
|
||||
'department_type' => ['nullable', 'string', 'in:common,manufacturing,admin'],
|
||||
'description' => ['nullable', 'string', 'max:500'],
|
||||
'sort_order' => ['nullable', 'integer'],
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'category.in' => '유효한 분류를 선택하세요.',
|
||||
'depth.in' => '계층은 1(대), 2(중), 3(소) 중 하나여야 합니다.',
|
||||
'department_type.in' => '부문은 common, manufacturing, admin 중 하나여야 합니다.',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -73,6 +73,7 @@ class Document extends Model
|
||||
'linkable_id',
|
||||
'submitted_at',
|
||||
'completed_at',
|
||||
'rendered_html',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'deleted_by',
|
||||
|
||||
@@ -22,6 +22,7 @@ class DocumentTemplateSection extends Model
|
||||
protected $fillable = [
|
||||
'template_id',
|
||||
'title',
|
||||
'description',
|
||||
'image_path',
|
||||
'sort_order',
|
||||
];
|
||||
|
||||
76
app/Models/Qualitys/PerformanceReport.php
Normal file
76
app/Models/Qualitys/PerformanceReport.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Qualitys;
|
||||
|
||||
use App\Models\Members\User;
|
||||
use App\Traits\Auditable;
|
||||
use App\Traits\BelongsToTenant;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class PerformanceReport extends Model
|
||||
{
|
||||
use Auditable, BelongsToTenant, SoftDeletes;
|
||||
|
||||
protected $table = 'performance_reports';
|
||||
|
||||
const STATUS_UNCONFIRMED = 'unconfirmed';
|
||||
|
||||
const STATUS_CONFIRMED = 'confirmed';
|
||||
|
||||
const STATUS_REPORTED = 'reported';
|
||||
|
||||
protected $fillable = [
|
||||
'tenant_id',
|
||||
'quality_document_id',
|
||||
'year',
|
||||
'quarter',
|
||||
'confirmation_status',
|
||||
'confirmed_date',
|
||||
'confirmed_by',
|
||||
'memo',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'deleted_by',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'confirmed_date' => 'date',
|
||||
'year' => 'integer',
|
||||
'quarter' => 'integer',
|
||||
];
|
||||
|
||||
// ===== Relationships =====
|
||||
|
||||
public function qualityDocument()
|
||||
{
|
||||
return $this->belongsTo(QualityDocument::class);
|
||||
}
|
||||
|
||||
public function confirmer()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'confirmed_by');
|
||||
}
|
||||
|
||||
public function creator()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'created_by');
|
||||
}
|
||||
|
||||
// ===== Status Helpers =====
|
||||
|
||||
public function isUnconfirmed(): bool
|
||||
{
|
||||
return $this->confirmation_status === self::STATUS_UNCONFIRMED;
|
||||
}
|
||||
|
||||
public function isConfirmed(): bool
|
||||
{
|
||||
return $this->confirmation_status === self::STATUS_CONFIRMED;
|
||||
}
|
||||
|
||||
public function isReported(): bool
|
||||
{
|
||||
return $this->confirmation_status === self::STATUS_REPORTED;
|
||||
}
|
||||
}
|
||||
131
app/Models/Qualitys/QualityDocument.php
Normal file
131
app/Models/Qualitys/QualityDocument.php
Normal file
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Qualitys;
|
||||
|
||||
use App\Models\Members\User;
|
||||
use App\Models\Orders\Client;
|
||||
use App\Traits\Auditable;
|
||||
use App\Traits\BelongsToTenant;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class QualityDocument extends Model
|
||||
{
|
||||
use Auditable, BelongsToTenant, SoftDeletes;
|
||||
|
||||
protected $table = 'quality_documents';
|
||||
|
||||
const STATUS_RECEIVED = 'received';
|
||||
|
||||
const STATUS_IN_PROGRESS = 'in_progress';
|
||||
|
||||
const STATUS_COMPLETED = 'completed';
|
||||
|
||||
protected $fillable = [
|
||||
'tenant_id',
|
||||
'quality_doc_number',
|
||||
'site_name',
|
||||
'status',
|
||||
'client_id',
|
||||
'inspector_id',
|
||||
'received_date',
|
||||
'options',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'deleted_by',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'options' => 'array',
|
||||
'received_date' => 'date',
|
||||
];
|
||||
|
||||
// ===== Relationships =====
|
||||
|
||||
public function client()
|
||||
{
|
||||
return $this->belongsTo(Client::class, 'client_id');
|
||||
}
|
||||
|
||||
public function inspector()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'inspector_id');
|
||||
}
|
||||
|
||||
public function creator()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'created_by');
|
||||
}
|
||||
|
||||
public function documentOrders()
|
||||
{
|
||||
return $this->hasMany(QualityDocumentOrder::class);
|
||||
}
|
||||
|
||||
public function locations()
|
||||
{
|
||||
return $this->hasMany(QualityDocumentLocation::class);
|
||||
}
|
||||
|
||||
public function performanceReport()
|
||||
{
|
||||
return $this->hasOne(PerformanceReport::class);
|
||||
}
|
||||
|
||||
// ===== 채번 =====
|
||||
|
||||
public static function generateDocNumber(int $tenantId): string
|
||||
{
|
||||
$prefix = 'KD-QD';
|
||||
$yearMonth = now()->format('Ym');
|
||||
|
||||
$lastNo = static::withoutGlobalScopes()
|
||||
->where('tenant_id', $tenantId)
|
||||
->where('quality_doc_number', 'like', "{$prefix}-{$yearMonth}-%")
|
||||
->orderByDesc('quality_doc_number')
|
||||
->value('quality_doc_number');
|
||||
|
||||
if ($lastNo) {
|
||||
$seq = (int) substr($lastNo, -4) + 1;
|
||||
} else {
|
||||
$seq = 1;
|
||||
}
|
||||
|
||||
return sprintf('%s-%s-%04d', $prefix, $yearMonth, $seq);
|
||||
}
|
||||
|
||||
// ===== Status Helpers =====
|
||||
|
||||
public function isReceived(): bool
|
||||
{
|
||||
return $this->status === self::STATUS_RECEIVED;
|
||||
}
|
||||
|
||||
public function isInProgress(): bool
|
||||
{
|
||||
return $this->status === self::STATUS_IN_PROGRESS;
|
||||
}
|
||||
|
||||
public function isCompleted(): bool
|
||||
{
|
||||
return $this->status === self::STATUS_COMPLETED;
|
||||
}
|
||||
|
||||
public static function mapStatusToFrontend(string $status): string
|
||||
{
|
||||
return match ($status) {
|
||||
self::STATUS_RECEIVED => 'reception',
|
||||
self::STATUS_IN_PROGRESS => 'in_progress',
|
||||
self::STATUS_COMPLETED => 'completed',
|
||||
default => $status,
|
||||
};
|
||||
}
|
||||
|
||||
public static function mapStatusFromFrontend(string $status): string
|
||||
{
|
||||
return match ($status) {
|
||||
'reception' => self::STATUS_RECEIVED,
|
||||
default => $status,
|
||||
};
|
||||
}
|
||||
}
|
||||
64
app/Models/Qualitys/QualityDocumentLocation.php
Normal file
64
app/Models/Qualitys/QualityDocumentLocation.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Qualitys;
|
||||
|
||||
use App\Models\Documents\Document;
|
||||
use App\Models\Orders\OrderItem;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class QualityDocumentLocation extends Model
|
||||
{
|
||||
protected $table = 'quality_document_locations';
|
||||
|
||||
const STATUS_PENDING = 'pending';
|
||||
|
||||
const STATUS_IN_PROGRESS = 'in_progress';
|
||||
|
||||
const STATUS_COMPLETED = 'completed';
|
||||
|
||||
protected $fillable = [
|
||||
'quality_document_id',
|
||||
'quality_document_order_id',
|
||||
'order_item_id',
|
||||
'post_width',
|
||||
'post_height',
|
||||
'change_reason',
|
||||
'inspection_data',
|
||||
'document_id',
|
||||
'inspection_status',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'inspection_data' => 'array',
|
||||
];
|
||||
|
||||
public function qualityDocument()
|
||||
{
|
||||
return $this->belongsTo(QualityDocument::class);
|
||||
}
|
||||
|
||||
public function qualityDocumentOrder()
|
||||
{
|
||||
return $this->belongsTo(QualityDocumentOrder::class);
|
||||
}
|
||||
|
||||
public function orderItem()
|
||||
{
|
||||
return $this->belongsTo(OrderItem::class);
|
||||
}
|
||||
|
||||
public function document()
|
||||
{
|
||||
return $this->belongsTo(Document::class);
|
||||
}
|
||||
|
||||
public function isPending(): bool
|
||||
{
|
||||
return $this->inspection_status === self::STATUS_PENDING;
|
||||
}
|
||||
|
||||
public function isCompleted(): bool
|
||||
{
|
||||
return $this->inspection_status === self::STATUS_COMPLETED;
|
||||
}
|
||||
}
|
||||
31
app/Models/Qualitys/QualityDocumentOrder.php
Normal file
31
app/Models/Qualitys/QualityDocumentOrder.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Qualitys;
|
||||
|
||||
use App\Models\Orders\Order;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class QualityDocumentOrder extends Model
|
||||
{
|
||||
protected $table = 'quality_document_orders';
|
||||
|
||||
protected $fillable = [
|
||||
'quality_document_id',
|
||||
'order_id',
|
||||
];
|
||||
|
||||
public function qualityDocument()
|
||||
{
|
||||
return $this->belongsTo(QualityDocument::class);
|
||||
}
|
||||
|
||||
public function order()
|
||||
{
|
||||
return $this->belongsTo(Order::class);
|
||||
}
|
||||
|
||||
public function locations()
|
||||
{
|
||||
return $this->hasMany(QualityDocumentLocation::class);
|
||||
}
|
||||
}
|
||||
@@ -15,16 +15,22 @@ class AccountCode extends Model
|
||||
'code',
|
||||
'name',
|
||||
'category',
|
||||
'sub_category',
|
||||
'parent_code',
|
||||
'depth',
|
||||
'department_type',
|
||||
'description',
|
||||
'sort_order',
|
||||
'is_active',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'depth' => 'integer',
|
||||
'sort_order' => 'integer',
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
|
||||
// Categories
|
||||
// Categories (대분류)
|
||||
public const CATEGORY_ASSET = 'asset';
|
||||
public const CATEGORY_LIABILITY = 'liability';
|
||||
public const CATEGORY_CAPITAL = 'capital';
|
||||
@@ -39,6 +45,36 @@ class AccountCode extends Model
|
||||
self::CATEGORY_EXPENSE => '비용',
|
||||
];
|
||||
|
||||
// Sub-categories (중분류)
|
||||
public const SUB_CATEGORIES = [
|
||||
'current_asset' => '유동자산',
|
||||
'fixed_asset' => '비유동자산',
|
||||
'current_liability' => '유동부채',
|
||||
'long_term_liability' => '비유동부채',
|
||||
'capital' => '자본',
|
||||
'sales_revenue' => '매출',
|
||||
'other_revenue' => '영업외수익',
|
||||
'cogs' => '매출원가',
|
||||
'selling_admin' => '판매비와관리비',
|
||||
'other_expense' => '영업외비용',
|
||||
];
|
||||
|
||||
// Department types (부문)
|
||||
public const DEPT_COMMON = 'common';
|
||||
public const DEPT_MANUFACTURING = 'manufacturing';
|
||||
public const DEPT_ADMIN = 'admin';
|
||||
|
||||
public const DEPARTMENT_TYPES = [
|
||||
self::DEPT_COMMON => '공통',
|
||||
self::DEPT_MANUFACTURING => '제조',
|
||||
self::DEPT_ADMIN => '관리',
|
||||
];
|
||||
|
||||
// Depth levels (계층)
|
||||
public const DEPTH_MAJOR = 1;
|
||||
public const DEPTH_MIDDLE = 2;
|
||||
public const DEPTH_MINOR = 3;
|
||||
|
||||
/**
|
||||
* 활성 계정과목만 조회
|
||||
*/
|
||||
@@ -46,4 +82,21 @@ public function scopeActive(Builder $query): Builder
|
||||
{
|
||||
return $query->where('is_active', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 소분류(입력 가능 계정)만 조회
|
||||
*/
|
||||
public function scopeSelectable(Builder $query): Builder
|
||||
{
|
||||
return $query->where('depth', self::DEPTH_MINOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* 하위 계정과목 관계
|
||||
*/
|
||||
public function children()
|
||||
{
|
||||
return $this->hasMany(self::class, 'parent_code', 'code')
|
||||
->where('tenant_id', $this->tenant_id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,8 @@ class ExpenseAccount extends Model
|
||||
'payment_method',
|
||||
'card_no',
|
||||
'loan_id',
|
||||
'journal_entry_id',
|
||||
'journal_entry_line_id',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'deleted_by',
|
||||
|
||||
@@ -39,6 +39,8 @@ class JournalEntry extends Model
|
||||
// Source type
|
||||
public const SOURCE_MANUAL = 'manual';
|
||||
public const SOURCE_BANK_TRANSACTION = 'bank_transaction';
|
||||
public const SOURCE_TAX_INVOICE = 'tax_invoice';
|
||||
public const SOURCE_CARD_TRANSACTION = 'card_transaction';
|
||||
|
||||
// Entry type
|
||||
public const TYPE_GENERAL = 'general';
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use App\Models\Tenants\AccountCode;
|
||||
use App\Models\Tenants\JournalEntryLine;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
|
||||
class AccountCodeService extends Service
|
||||
@@ -27,12 +28,37 @@ public function index(array $params): array
|
||||
});
|
||||
}
|
||||
|
||||
// 분류 필터
|
||||
// 분류 필터 (대분류)
|
||||
if (! empty($params['category'])) {
|
||||
$query->where('category', $params['category']);
|
||||
}
|
||||
|
||||
return $query->orderBy('sort_order')->orderBy('code')->get()->toArray();
|
||||
// 중분류 필터
|
||||
if (! empty($params['sub_category'])) {
|
||||
$query->where('sub_category', $params['sub_category']);
|
||||
}
|
||||
|
||||
// 부문 필터
|
||||
if (! empty($params['department_type'])) {
|
||||
$query->where('department_type', $params['department_type']);
|
||||
}
|
||||
|
||||
// 계층 필터
|
||||
if (! empty($params['depth'])) {
|
||||
$query->where('depth', (int) $params['depth']);
|
||||
}
|
||||
|
||||
// 활성 상태 필터
|
||||
if (isset($params['is_active'])) {
|
||||
$query->where('is_active', filter_var($params['is_active'], FILTER_VALIDATE_BOOLEAN));
|
||||
}
|
||||
|
||||
// 선택 가능한 계정만 (소분류만 = Select용)
|
||||
if (! empty($params['selectable'])) {
|
||||
$query->selectable();
|
||||
}
|
||||
|
||||
return $query->orderBy('code')->orderBy('sort_order')->get()->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,6 +83,11 @@ public function store(array $data): AccountCode
|
||||
$accountCode->code = $data['code'];
|
||||
$accountCode->name = $data['name'];
|
||||
$accountCode->category = $data['category'] ?? null;
|
||||
$accountCode->sub_category = $data['sub_category'] ?? null;
|
||||
$accountCode->parent_code = $data['parent_code'] ?? null;
|
||||
$accountCode->depth = $data['depth'] ?? AccountCode::DEPTH_MINOR;
|
||||
$accountCode->department_type = $data['department_type'] ?? AccountCode::DEPT_COMMON;
|
||||
$accountCode->description = $data['description'] ?? null;
|
||||
$accountCode->sort_order = $data['sort_order'] ?? 0;
|
||||
$accountCode->is_active = true;
|
||||
$accountCode->save();
|
||||
@@ -64,6 +95,36 @@ public function store(array $data): AccountCode
|
||||
return $accountCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* 계정과목 수정
|
||||
*/
|
||||
public function update(int $id, array $data): AccountCode
|
||||
{
|
||||
$tenantId = $this->tenantId();
|
||||
|
||||
$accountCode = AccountCode::query()
|
||||
->where('tenant_id', $tenantId)
|
||||
->findOrFail($id);
|
||||
|
||||
// 코드 변경 시 중복 체크
|
||||
if (isset($data['code']) && $data['code'] !== $accountCode->code) {
|
||||
$exists = AccountCode::query()
|
||||
->where('tenant_id', $tenantId)
|
||||
->where('code', $data['code'])
|
||||
->where('id', '!=', $id)
|
||||
->exists();
|
||||
|
||||
if ($exists) {
|
||||
throw new BadRequestHttpException(__('error.account_subject.duplicate_code'));
|
||||
}
|
||||
}
|
||||
|
||||
$accountCode->fill($data);
|
||||
$accountCode->save();
|
||||
|
||||
return $accountCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* 계정과목 활성/비활성 토글
|
||||
*/
|
||||
@@ -106,4 +167,242 @@ public function destroy(int $id): bool
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 기본 계정과목표 일괄 생성 (초기 세팅)
|
||||
*/
|
||||
public function seedDefaults(): int
|
||||
{
|
||||
$tenantId = $this->tenantId();
|
||||
|
||||
$defaults = $this->getDefaultAccountCodes();
|
||||
$insertedCount = 0;
|
||||
|
||||
DB::transaction(function () use ($tenantId, $defaults, &$insertedCount) {
|
||||
foreach ($defaults as $item) {
|
||||
$exists = AccountCode::query()
|
||||
->where('tenant_id', $tenantId)
|
||||
->where('code', $item['code'])
|
||||
->exists();
|
||||
|
||||
if (! $exists) {
|
||||
AccountCode::create(array_merge($item, ['tenant_id' => $tenantId]));
|
||||
$insertedCount++;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return $insertedCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* 기본 계정과목표 데이터 (더존 Smart A 표준 기반)
|
||||
*
|
||||
* 코드 체계: 5자리 (10100~99900)
|
||||
* - 10100~24000: 자산
|
||||
* - 25000~31700: 부채
|
||||
* - 33100~38700: 자본
|
||||
* - 40100~41000: 매출
|
||||
* - 50100~53700: 매출원가/제조경비 (제조부문)
|
||||
* - 80100~84800: 판매비와관리비 (관리부문)
|
||||
* - 90100~99900: 영업외수익/비용
|
||||
*
|
||||
* 계층: depth 1(대분류) → depth 2(중분류) → depth 3(소분류=더존 실제코드)
|
||||
*/
|
||||
private function getDefaultAccountCodes(): array
|
||||
{
|
||||
$c = fn ($code, $name, $cat, $sub, $parent, $depth, $dept, $sort) => [
|
||||
'code' => $code, 'name' => $name, 'category' => $cat,
|
||||
'sub_category' => $sub, 'parent_code' => $parent,
|
||||
'depth' => $depth, 'department_type' => $dept, 'sort_order' => $sort,
|
||||
];
|
||||
|
||||
return [
|
||||
// ============================================================
|
||||
// 자산 (Assets)
|
||||
// ============================================================
|
||||
$c('1', '자산', 'asset', null, null, 1, 'common', 100),
|
||||
|
||||
// -- 유동자산 --
|
||||
$c('11', '유동자산', 'asset', 'current_asset', '1', 2, 'common', 110),
|
||||
$c('10100', '현금', 'asset', 'current_asset', '11', 3, 'common', 1010),
|
||||
$c('10200', '당좌예금', 'asset', 'current_asset', '11', 3, 'common', 1020),
|
||||
$c('10300', '보통예금', 'asset', 'current_asset', '11', 3, 'common', 1030),
|
||||
$c('10400', '기타제예금', 'asset', 'current_asset', '11', 3, 'common', 1040),
|
||||
$c('10500', '정기적금', 'asset', 'current_asset', '11', 3, 'common', 1050),
|
||||
$c('10800', '외상매출금', 'asset', 'current_asset', '11', 3, 'common', 1080),
|
||||
$c('10900', '대손충당금(외상매출금)', 'asset', 'current_asset', '11', 3, 'common', 1090),
|
||||
$c('11000', '받을어음', 'asset', 'current_asset', '11', 3, 'common', 1100),
|
||||
$c('11400', '단기대여금', 'asset', 'current_asset', '11', 3, 'common', 1140),
|
||||
$c('11600', '미수수익', 'asset', 'current_asset', '11', 3, 'common', 1160),
|
||||
$c('12000', '미수금', 'asset', 'current_asset', '11', 3, 'common', 1200),
|
||||
$c('12200', '소모품', 'asset', 'current_asset', '11', 3, 'common', 1220),
|
||||
$c('12500', '미환급세금', 'asset', 'current_asset', '11', 3, 'common', 1250),
|
||||
$c('13100', '선급금', 'asset', 'current_asset', '11', 3, 'common', 1310),
|
||||
$c('13300', '선급비용', 'asset', 'current_asset', '11', 3, 'common', 1330),
|
||||
$c('13400', '가지급금', 'asset', 'current_asset', '11', 3, 'common', 1340),
|
||||
$c('13500', '부가세대급금', 'asset', 'current_asset', '11', 3, 'common', 1350),
|
||||
$c('13600', '선납세금', 'asset', 'current_asset', '11', 3, 'common', 1360),
|
||||
$c('14000', '선납법인세', 'asset', 'current_asset', '11', 3, 'common', 1400),
|
||||
|
||||
// -- 재고자산 --
|
||||
$c('12', '재고자산', 'asset', 'current_asset', '1', 2, 'common', 120),
|
||||
$c('14600', '상품', 'asset', 'current_asset', '12', 3, 'common', 1460),
|
||||
$c('15000', '제품', 'asset', 'current_asset', '12', 3, 'common', 1500),
|
||||
$c('15300', '원재료', 'asset', 'current_asset', '12', 3, 'common', 1530),
|
||||
$c('16200', '부재료', 'asset', 'current_asset', '12', 3, 'common', 1620),
|
||||
$c('16700', '저장품', 'asset', 'current_asset', '12', 3, 'common', 1670),
|
||||
$c('16900', '재공품', 'asset', 'current_asset', '12', 3, 'common', 1690),
|
||||
|
||||
// -- 비유동자산 --
|
||||
$c('13', '비유동자산', 'asset', 'fixed_asset', '1', 2, 'common', 130),
|
||||
$c('17600', '장기성예금', 'asset', 'fixed_asset', '13', 3, 'common', 1760),
|
||||
$c('17900', '장기대여금', 'asset', 'fixed_asset', '13', 3, 'common', 1790),
|
||||
$c('18700', '투자부동산', 'asset', 'fixed_asset', '13', 3, 'common', 1870),
|
||||
$c('19200', '단체퇴직보험예치금', 'asset', 'fixed_asset', '13', 3, 'common', 1920),
|
||||
$c('20100', '토지', 'asset', 'fixed_asset', '13', 3, 'common', 2010),
|
||||
$c('20200', '건물', 'asset', 'fixed_asset', '13', 3, 'common', 2020),
|
||||
$c('20300', '감가상각누계액(건물)', 'asset', 'fixed_asset', '13', 3, 'common', 2030),
|
||||
$c('20400', '구축물', 'asset', 'fixed_asset', '13', 3, 'common', 2040),
|
||||
$c('20500', '감가상각누계액(구축물)', 'asset', 'fixed_asset', '13', 3, 'common', 2050),
|
||||
$c('20600', '기계장치', 'asset', 'fixed_asset', '13', 3, 'common', 2060),
|
||||
$c('20700', '감가상각누계액(기계장치)', 'asset', 'fixed_asset', '13', 3, 'common', 2070),
|
||||
$c('20800', '차량운반구', 'asset', 'fixed_asset', '13', 3, 'common', 2080),
|
||||
$c('20900', '감가상각누계액(차량운반구)', 'asset', 'fixed_asset', '13', 3, 'common', 2090),
|
||||
$c('21000', '공구와기구', 'asset', 'fixed_asset', '13', 3, 'common', 2100),
|
||||
$c('21200', '비품', 'asset', 'fixed_asset', '13', 3, 'common', 2120),
|
||||
$c('21300', '건설중인자산', 'asset', 'fixed_asset', '13', 3, 'common', 2130),
|
||||
$c('24000', '소프트웨어', 'asset', 'fixed_asset', '13', 3, 'common', 2400),
|
||||
|
||||
// ============================================================
|
||||
// 부채 (Liabilities)
|
||||
// ============================================================
|
||||
$c('2', '부채', 'liability', null, null, 1, 'common', 200),
|
||||
|
||||
// -- 유동부채 --
|
||||
$c('21', '유동부채', 'liability', 'current_liability', '2', 2, 'common', 210),
|
||||
$c('25100', '외상매입금', 'liability', 'current_liability', '21', 3, 'common', 2510),
|
||||
$c('25200', '지급어음', 'liability', 'current_liability', '21', 3, 'common', 2520),
|
||||
$c('25300', '미지급금', 'liability', 'current_liability', '21', 3, 'common', 2530),
|
||||
$c('25400', '예수금', 'liability', 'current_liability', '21', 3, 'common', 2540),
|
||||
$c('25500', '부가세예수금', 'liability', 'current_liability', '21', 3, 'common', 2550),
|
||||
$c('25900', '선수금', 'liability', 'current_liability', '21', 3, 'common', 2590),
|
||||
$c('26000', '단기차입금', 'liability', 'current_liability', '21', 3, 'common', 2600),
|
||||
$c('26100', '미지급세금', 'liability', 'current_liability', '21', 3, 'common', 2610),
|
||||
$c('26200', '미지급비용', 'liability', 'current_liability', '21', 3, 'common', 2620),
|
||||
$c('26400', '유동성장기차입금', 'liability', 'current_liability', '21', 3, 'common', 2640),
|
||||
$c('26500', '미지급배당금', 'liability', 'current_liability', '21', 3, 'common', 2650),
|
||||
|
||||
// -- 비유동부채 --
|
||||
$c('22', '비유동부채', 'liability', 'long_term_liability', '2', 2, 'common', 220),
|
||||
$c('29300', '장기차입금', 'liability', 'long_term_liability', '22', 3, 'common', 2930),
|
||||
$c('29400', '임대보증금', 'liability', 'long_term_liability', '22', 3, 'common', 2940),
|
||||
$c('29500', '퇴직급여충당부채', 'liability', 'long_term_liability', '22', 3, 'common', 2950),
|
||||
$c('30700', '장기임대보증금', 'liability', 'long_term_liability', '22', 3, 'common', 3070),
|
||||
|
||||
// ============================================================
|
||||
// 자본 (Capital)
|
||||
// ============================================================
|
||||
$c('3', '자본', 'capital', null, null, 1, 'common', 300),
|
||||
|
||||
// -- 자본금 --
|
||||
$c('31', '자본금', 'capital', 'capital', '3', 2, 'common', 310),
|
||||
$c('33100', '자본금', 'capital', 'capital', '31', 3, 'common', 3310),
|
||||
$c('33200', '우선주자본금', 'capital', 'capital', '31', 3, 'common', 3320),
|
||||
|
||||
// -- 잉여금 --
|
||||
$c('32', '잉여금', 'capital', 'capital', '3', 2, 'common', 320),
|
||||
$c('34100', '주식발행초과금', 'capital', 'capital', '32', 3, 'common', 3410),
|
||||
$c('35100', '이익준비금', 'capital', 'capital', '32', 3, 'common', 3510),
|
||||
$c('37500', '이월이익잉여금', 'capital', 'capital', '32', 3, 'common', 3750),
|
||||
$c('37900', '당기순이익', 'capital', 'capital', '32', 3, 'common', 3790),
|
||||
|
||||
// ============================================================
|
||||
// 수익 (Revenue)
|
||||
// ============================================================
|
||||
$c('4', '수익', 'revenue', null, null, 1, 'common', 400),
|
||||
|
||||
// -- 매출 --
|
||||
$c('41', '매출', 'revenue', 'sales_revenue', '4', 2, 'common', 410),
|
||||
$c('40100', '상품매출', 'revenue', 'sales_revenue', '41', 3, 'common', 4010),
|
||||
$c('40400', '제품매출', 'revenue', 'sales_revenue', '41', 3, 'common', 4040),
|
||||
$c('40700', '공사수입금', 'revenue', 'sales_revenue', '41', 3, 'common', 4070),
|
||||
$c('41000', '임대료수입', 'revenue', 'sales_revenue', '41', 3, 'common', 4100),
|
||||
|
||||
// -- 영업외수익 --
|
||||
$c('42', '영업외수익', 'revenue', 'other_revenue', '4', 2, 'common', 420),
|
||||
$c('90100', '이자수익', 'revenue', 'other_revenue', '42', 3, 'common', 9010),
|
||||
$c('90300', '배당금수익', 'revenue', 'other_revenue', '42', 3, 'common', 9030),
|
||||
$c('90400', '수입임대료', 'revenue', 'other_revenue', '42', 3, 'common', 9040),
|
||||
$c('90700', '외환차익', 'revenue', 'other_revenue', '42', 3, 'common', 9070),
|
||||
$c('93000', '잡이익', 'revenue', 'other_revenue', '42', 3, 'common', 9300),
|
||||
|
||||
// ============================================================
|
||||
// 비용 (Expenses)
|
||||
// ============================================================
|
||||
$c('5', '비용', 'expense', null, null, 1, 'common', 500),
|
||||
|
||||
// -- 매출원가/제조원가 (제조부문) --
|
||||
$c('51', '매출원가', 'expense', 'cogs', '5', 2, 'manufacturing', 510),
|
||||
$c('50100', '원재료비', 'expense', 'cogs', '51', 3, 'manufacturing', 5010),
|
||||
$c('50200', '외주가공비', 'expense', 'cogs', '51', 3, 'manufacturing', 5020),
|
||||
$c('50300', '급여(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5030),
|
||||
$c('50400', '임금', 'expense', 'cogs', '51', 3, 'manufacturing', 5040),
|
||||
$c('50500', '상여금(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5050),
|
||||
$c('50800', '퇴직급여(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5080),
|
||||
$c('51100', '복리후생비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5110),
|
||||
$c('51200', '여비교통비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5120),
|
||||
$c('51300', '접대비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5130),
|
||||
$c('51400', '통신비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5140),
|
||||
$c('51600', '전력비', 'expense', 'cogs', '51', 3, 'manufacturing', 5160),
|
||||
$c('51700', '세금과공과금(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5170),
|
||||
$c('51800', '감가상각비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5180),
|
||||
$c('51900', '지급임차료(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5190),
|
||||
$c('52000', '수선비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5200),
|
||||
$c('52100', '보험료(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5210),
|
||||
$c('52200', '차량유지비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5220),
|
||||
$c('52400', '운반비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5240),
|
||||
$c('53000', '소모품비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5300),
|
||||
$c('53100', '지급수수료(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5310),
|
||||
|
||||
// -- 판매비와관리비 (관리부문) --
|
||||
$c('52', '판매비와관리비', 'expense', 'selling_admin', '5', 2, 'admin', 520),
|
||||
$c('80100', '임원급여', 'expense', 'selling_admin', '52', 3, 'admin', 8010),
|
||||
$c('80200', '직원급여', 'expense', 'selling_admin', '52', 3, 'admin', 8020),
|
||||
$c('80300', '상여금', 'expense', 'selling_admin', '52', 3, 'admin', 8030),
|
||||
$c('80600', '퇴직급여', 'expense', 'selling_admin', '52', 3, 'admin', 8060),
|
||||
$c('81100', '복리후생비', 'expense', 'selling_admin', '52', 3, 'admin', 8110),
|
||||
$c('81200', '여비교통비', 'expense', 'selling_admin', '52', 3, 'admin', 8120),
|
||||
$c('81300', '접대비', 'expense', 'selling_admin', '52', 3, 'admin', 8130),
|
||||
$c('81400', '통신비', 'expense', 'selling_admin', '52', 3, 'admin', 8140),
|
||||
$c('81500', '수도광열비', 'expense', 'selling_admin', '52', 3, 'admin', 8150),
|
||||
$c('81700', '세금과공과금', 'expense', 'selling_admin', '52', 3, 'admin', 8170),
|
||||
$c('81800', '감가상각비', 'expense', 'selling_admin', '52', 3, 'admin', 8180),
|
||||
$c('81900', '지급임차료', 'expense', 'selling_admin', '52', 3, 'admin', 8190),
|
||||
$c('82000', '수선비', 'expense', 'selling_admin', '52', 3, 'admin', 8200),
|
||||
$c('82100', '보험료', 'expense', 'selling_admin', '52', 3, 'admin', 8210),
|
||||
$c('82200', '차량유지비', 'expense', 'selling_admin', '52', 3, 'admin', 8220),
|
||||
$c('82300', '경상연구개발비', 'expense', 'selling_admin', '52', 3, 'admin', 8230),
|
||||
$c('82400', '운반비', 'expense', 'selling_admin', '52', 3, 'admin', 8240),
|
||||
$c('82500', '교육훈련비', 'expense', 'selling_admin', '52', 3, 'admin', 8250),
|
||||
$c('82600', '도서인쇄비', 'expense', 'selling_admin', '52', 3, 'admin', 8260),
|
||||
$c('82700', '회의비', 'expense', 'selling_admin', '52', 3, 'admin', 8270),
|
||||
$c('82900', '사무용품비', 'expense', 'selling_admin', '52', 3, 'admin', 8290),
|
||||
$c('83000', '소모품비', 'expense', 'selling_admin', '52', 3, 'admin', 8300),
|
||||
$c('83100', '지급수수료', 'expense', 'selling_admin', '52', 3, 'admin', 8310),
|
||||
$c('83200', '보관료', 'expense', 'selling_admin', '52', 3, 'admin', 8320),
|
||||
$c('83300', '광고선전비', 'expense', 'selling_admin', '52', 3, 'admin', 8330),
|
||||
$c('83500', '대손상각비', 'expense', 'selling_admin', '52', 3, 'admin', 8350),
|
||||
$c('84800', '잡비', 'expense', 'selling_admin', '52', 3, 'admin', 8480),
|
||||
|
||||
// -- 영업외비용 --
|
||||
$c('53', '영업외비용', 'expense', 'other_expense', '5', 2, 'common', 530),
|
||||
$c('93100', '이자비용', 'expense', 'other_expense', '53', 3, 'common', 9310),
|
||||
$c('93200', '외환차손', 'expense', 'other_expense', '53', 3, 'common', 9320),
|
||||
$c('93300', '기부금', 'expense', 'other_expense', '53', 3, 'common', 9330),
|
||||
$c('96000', '잡손실', 'expense', 'other_expense', '53', 3, 'common', 9600),
|
||||
$c('99800', '법인세', 'expense', 'other_expense', '53', 3, 'common', 9980),
|
||||
$c('99900', '소득세등', 'expense', 'other_expense', '53', 3, 'common', 9990),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,8 +86,8 @@ public function summary(array $params = []): array
|
||||
|
||||
// is_active=true인 악성채권만 통계
|
||||
$query = BadDebt::query()
|
||||
->where('tenant_id', $tenantId)
|
||||
->where('is_active', true);
|
||||
->where('bad_debts.tenant_id', $tenantId)
|
||||
->where('bad_debts.is_active', true);
|
||||
|
||||
// 거래처 필터
|
||||
if (! empty($params['client_id'])) {
|
||||
@@ -110,6 +110,9 @@ public function summary(array $params = []): array
|
||||
->distinct('client_id')
|
||||
->count('client_id');
|
||||
|
||||
// per-card sub_label: 각 상태별 최다 금액 거래처명 + 건수
|
||||
$subLabels = $this->buildPerCardSubLabels($query);
|
||||
|
||||
return [
|
||||
'total_amount' => (float) $totalAmount,
|
||||
'collecting_amount' => (float) $collectingAmount,
|
||||
@@ -117,9 +120,56 @@ public function summary(array $params = []): array
|
||||
'recovered_amount' => (float) $recoveredAmount,
|
||||
'bad_debt_amount' => (float) $badDebtAmount,
|
||||
'client_count' => $clientCount,
|
||||
'sub_labels' => $subLabels,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 카드별 sub_label 생성 (최다 금액 거래처명 + 건수)
|
||||
*/
|
||||
private function buildPerCardSubLabels($baseQuery): array
|
||||
{
|
||||
$result = [];
|
||||
$statusScopes = [
|
||||
'dc1' => null, // 전체 (누적)
|
||||
'dc2' => 'collecting', // 추심중
|
||||
'dc3' => 'legalAction', // 법적조치
|
||||
'dc4' => 'recovered', // 회수완료
|
||||
];
|
||||
|
||||
foreach ($statusScopes as $cardId => $scope) {
|
||||
$q = clone $baseQuery;
|
||||
if ($scope) {
|
||||
$q = $q->$scope();
|
||||
}
|
||||
|
||||
$clientCount = (clone $q)->distinct('client_id')->count('client_id');
|
||||
|
||||
if ($clientCount <= 0) {
|
||||
$result[$cardId] = null;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$topClient = (clone $q)
|
||||
->join('clients', 'bad_debts.client_id', '=', 'clients.id')
|
||||
->selectRaw('clients.name, SUM(bad_debts.debt_amount) as total_amount')
|
||||
->groupBy('clients.id', 'clients.name')
|
||||
->orderByDesc('total_amount')
|
||||
->first();
|
||||
|
||||
if ($topClient) {
|
||||
$result[$cardId] = $clientCount > 1
|
||||
? $topClient->name.' 외 '.($clientCount - 1).'건'
|
||||
: $topClient->name;
|
||||
} else {
|
||||
$result[$cardId] = null;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 악성채권 상세 조회
|
||||
*/
|
||||
|
||||
@@ -122,6 +122,7 @@ public function create(array $data): Document
|
||||
'status' => Document::STATUS_DRAFT,
|
||||
'linkable_type' => $data['linkable_type'] ?? null,
|
||||
'linkable_id' => $data['linkable_id'] ?? null,
|
||||
'rendered_html' => $data['rendered_html'] ?? null,
|
||||
'created_by' => $userId,
|
||||
'updated_by' => $userId,
|
||||
]);
|
||||
@@ -170,12 +171,16 @@ public function update(int $id, array $data): Document
|
||||
}
|
||||
|
||||
// 기본 정보 수정
|
||||
$document->fill([
|
||||
$updateFields = [
|
||||
'title' => $data['title'] ?? $document->title,
|
||||
'linkable_type' => $data['linkable_type'] ?? $document->linkable_type,
|
||||
'linkable_id' => $data['linkable_id'] ?? $document->linkable_id,
|
||||
'updated_by' => $userId,
|
||||
]);
|
||||
];
|
||||
if (isset($data['rendered_html'])) {
|
||||
$updateFields['rendered_html'] = $data['rendered_html'];
|
||||
}
|
||||
$document->fill($updateFields);
|
||||
|
||||
// 반려 상태에서 수정 시 DRAFT로 변경
|
||||
if ($document->status === Document::STATUS_REJECTED) {
|
||||
@@ -658,20 +663,32 @@ public function fqcStatus(int $orderId, int $templateId): array
|
||||
$tenantId = $this->tenantId();
|
||||
|
||||
$order = \App\Models\Orders\Order::where('tenant_id', $tenantId)
|
||||
->with('items')
|
||||
->with(['rootNodes.items' => fn ($q) => $q->orderBy('sort_order')])
|
||||
->findOrFail($orderId);
|
||||
|
||||
// 해당 수주의 FQC 문서 조회
|
||||
// 개소별 대표 OrderItem ID 수집
|
||||
$representativeItemIds = $order->rootNodes
|
||||
->map(fn ($node) => $node->items->first()?->id)
|
||||
->filter()
|
||||
->values();
|
||||
|
||||
// 해당 대표 품목의 FQC 문서 조회
|
||||
$documents = Document::where('tenant_id', $tenantId)
|
||||
->where('template_id', $templateId)
|
||||
->where('linkable_type', \App\Models\Orders\OrderItem::class)
|
||||
->whereIn('linkable_id', $order->items->pluck('id'))
|
||||
->whereIn('linkable_id', $representativeItemIds)
|
||||
->with('data')
|
||||
->get()
|
||||
->keyBy('linkable_id');
|
||||
|
||||
$items = $order->items->map(function ($orderItem) use ($documents) {
|
||||
$doc = $documents->get($orderItem->id);
|
||||
// 개소(root node)별 진행현황
|
||||
$items = $order->rootNodes->map(function ($node) use ($documents) {
|
||||
$representativeItem = $node->items->first();
|
||||
if (! $representativeItem) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$doc = $documents->get($representativeItem->id);
|
||||
|
||||
// 종합판정 값 추출
|
||||
$judgement = null;
|
||||
@@ -681,17 +698,17 @@ public function fqcStatus(int $orderId, int $templateId): array
|
||||
}
|
||||
|
||||
return [
|
||||
'order_item_id' => $orderItem->id,
|
||||
'floor_code' => $orderItem->floor_code,
|
||||
'symbol_code' => $orderItem->symbol_code,
|
||||
'specification' => $orderItem->specification,
|
||||
'item_name' => $orderItem->item_name,
|
||||
'order_item_id' => $representativeItem->id,
|
||||
'floor_code' => $representativeItem->floor_code,
|
||||
'symbol_code' => $representativeItem->symbol_code,
|
||||
'specification' => $representativeItem->specification,
|
||||
'item_name' => $representativeItem->item_name,
|
||||
'document_id' => $doc?->id,
|
||||
'document_no' => $doc?->document_no,
|
||||
'status' => $doc?->status ?? 'NONE',
|
||||
'judgement' => $judgement,
|
||||
];
|
||||
});
|
||||
})->filter()->values();
|
||||
|
||||
// 통계
|
||||
$total = $items->count();
|
||||
@@ -713,6 +730,28 @@ public function fqcStatus(int $orderId, int $templateId): array
|
||||
];
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// Snapshot (Lazy Snapshot)
|
||||
// =========================================================================
|
||||
|
||||
/**
|
||||
* rendered_html만 업데이트 (상태 무관, canEdit 체크 없음)
|
||||
* Lazy Snapshot: 조회 시 rendered_html이 없으면 프론트에서 캡처 후 저장
|
||||
*/
|
||||
public function patchSnapshot(int $id, string $renderedHtml): Document
|
||||
{
|
||||
$tenantId = $this->tenantId();
|
||||
|
||||
$document = Document::query()
|
||||
->where('tenant_id', $tenantId)
|
||||
->findOrFail($id);
|
||||
|
||||
$document->rendered_html = $renderedHtml;
|
||||
$document->save();
|
||||
|
||||
return $document;
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// Resolve/Upsert (React 연동용)
|
||||
// =========================================================================
|
||||
@@ -852,24 +891,34 @@ public function upsert(array $data): Document
|
||||
|
||||
if ($existingDocument) {
|
||||
// UPDATE: 기존 update 로직 재사용
|
||||
return $this->update($existingDocument->id, [
|
||||
$updatePayload = [
|
||||
'title' => $data['title'] ?? $existingDocument->title,
|
||||
'linkable_type' => 'item',
|
||||
'linkable_id' => $itemId,
|
||||
'data' => $data['data'] ?? [],
|
||||
'attachments' => $data['attachments'] ?? [],
|
||||
]);
|
||||
];
|
||||
if (isset($data['rendered_html'])) {
|
||||
$updatePayload['rendered_html'] = $data['rendered_html'];
|
||||
}
|
||||
|
||||
return $this->update($existingDocument->id, $updatePayload);
|
||||
}
|
||||
|
||||
// CREATE: 기존 create 로직 재사용
|
||||
return $this->create([
|
||||
$createPayload = [
|
||||
'template_id' => $templateId,
|
||||
'title' => $data['title'] ?? '',
|
||||
'linkable_type' => 'item',
|
||||
'linkable_id' => $itemId,
|
||||
'data' => $data['data'] ?? [],
|
||||
'attachments' => $data['attachments'] ?? [],
|
||||
]);
|
||||
];
|
||||
if (isset($data['rendered_html'])) {
|
||||
$createPayload['rendered_html'] = $data['rendered_html'];
|
||||
}
|
||||
|
||||
return $this->create($createPayload);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -5,11 +5,13 @@
|
||||
use App\Models\Tenants\AccountCode;
|
||||
use App\Models\Tenants\JournalEntry;
|
||||
use App\Models\Tenants\JournalEntryLine;
|
||||
use App\Traits\SyncsExpenseAccounts;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
|
||||
class GeneralJournalEntryService extends Service
|
||||
{
|
||||
use SyncsExpenseAccounts;
|
||||
/**
|
||||
* 일반전표입력 통합 목록 (입금 + 출금 + 수기전표)
|
||||
* deposits/withdrawals는 계좌이체 건만, LEFT JOIN journal_entries로 분개 여부 표시
|
||||
@@ -326,6 +328,9 @@ public function store(array $data): JournalEntry
|
||||
// 분개 행 생성
|
||||
$this->createLines($entry, $data['rows'], $tenantId);
|
||||
|
||||
// expense_accounts 동기화 (복리후생비/접대비 → CEO 대시보드)
|
||||
$this->syncExpenseAccounts($entry);
|
||||
|
||||
return $entry->load('lines');
|
||||
});
|
||||
}
|
||||
@@ -373,6 +378,9 @@ public function updateJournal(int $id, array $data): JournalEntry
|
||||
|
||||
$entry->save();
|
||||
|
||||
// expense_accounts 동기화 (복리후생비/접대비 → CEO 대시보드)
|
||||
$this->syncExpenseAccounts($entry);
|
||||
|
||||
return $entry->load('lines');
|
||||
});
|
||||
}
|
||||
@@ -389,6 +397,9 @@ public function destroyJournal(int $id): bool
|
||||
->where('tenant_id', $tenantId)
|
||||
->findOrFail($id);
|
||||
|
||||
// expense_accounts 정리 (복리후생비/접대비 → CEO 대시보드)
|
||||
$this->cleanupExpenseAccounts($tenantId, $entry->id);
|
||||
|
||||
// lines 먼저 삭제 (soft delete가 아니므로 물리 삭제)
|
||||
JournalEntryLine::query()
|
||||
->where('journal_entry_id', $entry->id)
|
||||
@@ -503,6 +514,9 @@ private function resolveVendorName(?int $vendorId): string
|
||||
return $vendor ? $vendor->name : '';
|
||||
}
|
||||
|
||||
// syncExpenseAccounts, cleanupExpenseAccounts, getExpenseAccountType
|
||||
// → SyncsExpenseAccounts 트레이트로 이관
|
||||
|
||||
/**
|
||||
* 원본 거래 정보 조회 (입금/출금)
|
||||
*/
|
||||
|
||||
214
app/Services/JournalSyncService.php
Normal file
214
app/Services/JournalSyncService.php
Normal file
@@ -0,0 +1,214 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Tenants\AccountCode;
|
||||
use App\Models\Tenants\JournalEntry;
|
||||
use App\Models\Tenants\JournalEntryLine;
|
||||
use App\Traits\SyncsExpenseAccounts;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/**
|
||||
* 세금계산서/카드거래 등 외부 소스의 분개 통합 관리 서비스
|
||||
*
|
||||
* journal_entries + journal_entry_lines에 저장하고
|
||||
* 복리후생비/접대비는 expense_accounts에 동기화 (CEO 대시보드)
|
||||
*/
|
||||
class JournalSyncService extends Service
|
||||
{
|
||||
use SyncsExpenseAccounts;
|
||||
|
||||
/**
|
||||
* 소스에 대한 분개 저장 (생성 또는 교체)
|
||||
*
|
||||
* @param string $sourceType JournalEntry::SOURCE_TAX_INVOICE 등
|
||||
* @param string $sourceKey 'tax_invoice_123' 등
|
||||
* @param string $entryDate 전표일자 (Y-m-d)
|
||||
* @param string|null $description 적요
|
||||
* @param array $rows 분개 행 [{side, account_code, account_name?, debit_amount, credit_amount, vendor_id?, vendor_name?, memo?}]
|
||||
*/
|
||||
public function saveForSource(
|
||||
string $sourceType,
|
||||
string $sourceKey,
|
||||
string $entryDate,
|
||||
?string $description,
|
||||
array $rows,
|
||||
): JournalEntry {
|
||||
$tenantId = $this->tenantId();
|
||||
|
||||
return DB::transaction(function () use ($sourceType, $sourceKey, $entryDate, $description, $rows, $tenantId) {
|
||||
// 기존 전표가 있으면 삭제 후 재생성 (교체 방식)
|
||||
$existing = JournalEntry::query()
|
||||
->where('tenant_id', $tenantId)
|
||||
->where('source_type', $sourceType)
|
||||
->where('source_key', $sourceKey)
|
||||
->first();
|
||||
|
||||
if ($existing) {
|
||||
$this->cleanupExpenseAccounts($tenantId, $existing->id);
|
||||
JournalEntryLine::where('journal_entry_id', $existing->id)->delete();
|
||||
$existing->forceDelete();
|
||||
}
|
||||
|
||||
// 합계 계산
|
||||
$totalDebit = 0;
|
||||
$totalCredit = 0;
|
||||
foreach ($rows as $row) {
|
||||
$totalDebit += (int) ($row['debit_amount'] ?? 0);
|
||||
$totalCredit += (int) ($row['credit_amount'] ?? 0);
|
||||
}
|
||||
|
||||
// 전표번호 생성
|
||||
$entryNo = $this->generateEntryNo($tenantId, $entryDate);
|
||||
|
||||
// 전표 생성
|
||||
$entry = new JournalEntry;
|
||||
$entry->tenant_id = $tenantId;
|
||||
$entry->entry_no = $entryNo;
|
||||
$entry->entry_date = $entryDate;
|
||||
$entry->entry_type = JournalEntry::TYPE_GENERAL;
|
||||
$entry->description = $description;
|
||||
$entry->total_debit = $totalDebit;
|
||||
$entry->total_credit = $totalCredit;
|
||||
$entry->status = JournalEntry::STATUS_CONFIRMED;
|
||||
$entry->source_type = $sourceType;
|
||||
$entry->source_key = $sourceKey;
|
||||
$entry->save();
|
||||
|
||||
// 분개 행 생성
|
||||
foreach ($rows as $index => $row) {
|
||||
$accountCode = $row['account_code'] ?? '';
|
||||
$accountName = $row['account_name'] ?? $this->resolveAccountName($tenantId, $accountCode);
|
||||
|
||||
$line = new JournalEntryLine;
|
||||
$line->tenant_id = $tenantId;
|
||||
$line->journal_entry_id = $entry->id;
|
||||
$line->line_no = $index + 1;
|
||||
$line->dc_type = $row['side'];
|
||||
$line->account_code = $accountCode;
|
||||
$line->account_name = $accountName;
|
||||
$line->trading_partner_id = ! empty($row['vendor_id']) ? (int) $row['vendor_id'] : null;
|
||||
$line->trading_partner_name = $row['vendor_name'] ?? '';
|
||||
$line->debit_amount = (int) ($row['debit_amount'] ?? 0);
|
||||
$line->credit_amount = (int) ($row['credit_amount'] ?? 0);
|
||||
$line->description = $row['memo'] ?? null;
|
||||
$line->save();
|
||||
}
|
||||
|
||||
// expense_accounts 동기화 (복리후생비/접대비 → CEO 대시보드)
|
||||
$this->syncExpenseAccounts($entry);
|
||||
|
||||
return $entry->load('lines');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 소스에 대한 분개 조회
|
||||
*/
|
||||
public function getForSource(string $sourceType, string $sourceKey): ?array
|
||||
{
|
||||
$tenantId = $this->tenantId();
|
||||
|
||||
$entry = JournalEntry::query()
|
||||
->where('tenant_id', $tenantId)
|
||||
->where('source_type', $sourceType)
|
||||
->where('source_key', $sourceKey)
|
||||
->whereNull('deleted_at')
|
||||
->with('lines')
|
||||
->first();
|
||||
|
||||
if (! $entry) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => $entry->id,
|
||||
'entry_no' => $entry->entry_no,
|
||||
'entry_date' => $entry->entry_date->format('Y-m-d'),
|
||||
'description' => $entry->description,
|
||||
'total_debit' => $entry->total_debit,
|
||||
'total_credit' => $entry->total_credit,
|
||||
'rows' => $entry->lines->map(function ($line) {
|
||||
return [
|
||||
'id' => $line->id,
|
||||
'side' => $line->dc_type,
|
||||
'account_code' => $line->account_code,
|
||||
'account_name' => $line->account_name,
|
||||
'vendor_id' => $line->trading_partner_id,
|
||||
'vendor_name' => $line->trading_partner_name ?? '',
|
||||
'debit_amount' => (int) $line->debit_amount,
|
||||
'credit_amount' => (int) $line->credit_amount,
|
||||
'memo' => $line->description ?? '',
|
||||
];
|
||||
})->toArray(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 소스에 대한 분개 삭제
|
||||
*/
|
||||
public function deleteForSource(string $sourceType, string $sourceKey): bool
|
||||
{
|
||||
$tenantId = $this->tenantId();
|
||||
|
||||
return DB::transaction(function () use ($sourceType, $sourceKey, $tenantId) {
|
||||
$entry = JournalEntry::query()
|
||||
->where('tenant_id', $tenantId)
|
||||
->where('source_type', $sourceType)
|
||||
->where('source_key', $sourceKey)
|
||||
->first();
|
||||
|
||||
if (! $entry) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->cleanupExpenseAccounts($tenantId, $entry->id);
|
||||
JournalEntryLine::where('journal_entry_id', $entry->id)->delete();
|
||||
$entry->delete(); // soft delete
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 전표번호 생성: JE-YYYYMMDD-NNN
|
||||
*/
|
||||
private function generateEntryNo(int $tenantId, string $date): string
|
||||
{
|
||||
$dateStr = str_replace('-', '', substr($date, 0, 10));
|
||||
$prefix = "JE-{$dateStr}-";
|
||||
|
||||
$lastEntry = DB::table('journal_entries')
|
||||
->where('tenant_id', $tenantId)
|
||||
->where('entry_no', 'like', "{$prefix}%")
|
||||
->lockForUpdate()
|
||||
->orderBy('entry_no', 'desc')
|
||||
->first(['entry_no']);
|
||||
|
||||
if ($lastEntry) {
|
||||
$lastSeq = (int) substr($lastEntry->entry_no, -3);
|
||||
$nextSeq = $lastSeq + 1;
|
||||
} else {
|
||||
$nextSeq = 1;
|
||||
}
|
||||
|
||||
return $prefix . str_pad($nextSeq, 3, '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
/**
|
||||
* 계정과목 코드 → 이름 조회
|
||||
*/
|
||||
private function resolveAccountName(int $tenantId, string $code): string
|
||||
{
|
||||
if (empty($code)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$account = AccountCode::query()
|
||||
->where('tenant_id', $tenantId)
|
||||
->where('code', $code)
|
||||
->first(['name']);
|
||||
|
||||
return $account ? $account->name : $code;
|
||||
}
|
||||
}
|
||||
@@ -1325,9 +1325,13 @@ public function createProductionOrder(int $orderId, array $data)
|
||||
// 작업지시번호 생성
|
||||
$workOrderNo = $this->generateWorkOrderNo($tenantId);
|
||||
|
||||
// 절곡 공정이면 bending_info 자동 생성
|
||||
// 공정 옵션 초기화 (보조 공정 플래그 포함)
|
||||
$workOrderOptions = null;
|
||||
if ($processId) {
|
||||
$process = \App\Models\Process::find($processId);
|
||||
if ($process && ! empty($process->options['is_auxiliary'])) {
|
||||
$workOrderOptions = ['is_auxiliary' => true];
|
||||
}
|
||||
// 이 작업지시에 포함되는 노드 ID만 추출
|
||||
$nodeIds = collect($items)
|
||||
->pluck('order_node_id')
|
||||
@@ -1338,7 +1342,7 @@ public function createProductionOrder(int $orderId, array $data)
|
||||
|
||||
$buildResult = app(BendingInfoBuilder::class)->build($order, $processId, $nodeIds ?: null);
|
||||
if ($buildResult) {
|
||||
$workOrderOptions = ['bending_info' => $buildResult['bending_info']];
|
||||
$workOrderOptions = array_merge($workOrderOptions ?? [], ['bending_info' => $buildResult['bending_info']]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
258
app/Services/PerformanceReportService.php
Normal file
258
app/Services/PerformanceReportService.php
Normal file
@@ -0,0 +1,258 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Qualitys\PerformanceReport;
|
||||
use App\Services\Audit\AuditLogger;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
|
||||
class PerformanceReportService extends Service
|
||||
{
|
||||
private const AUDIT_TARGET = 'performance_report';
|
||||
|
||||
public function __construct(
|
||||
private readonly AuditLogger $auditLogger,
|
||||
private readonly QualityDocumentService $qualityDocumentService
|
||||
) {}
|
||||
|
||||
/**
|
||||
* 목록 조회
|
||||
*/
|
||||
public function index(array $params)
|
||||
{
|
||||
$tenantId = $this->tenantId();
|
||||
$perPage = (int) ($params['per_page'] ?? 20);
|
||||
$q = trim((string) ($params['q'] ?? ''));
|
||||
$year = $params['year'] ?? null;
|
||||
$quarter = $params['quarter'] ?? null;
|
||||
$confirmStatus = $params['confirm_status'] ?? null;
|
||||
|
||||
$query = PerformanceReport::query()
|
||||
->where('performance_reports.tenant_id', $tenantId)
|
||||
->with(['qualityDocument.client', 'qualityDocument.locations', 'confirmer:id,name']);
|
||||
|
||||
if ($q !== '') {
|
||||
$query->whereHas('qualityDocument', function ($qq) use ($q) {
|
||||
$qq->where('quality_doc_number', 'like', "%{$q}%")
|
||||
->orWhere('site_name', 'like', "%{$q}%");
|
||||
});
|
||||
}
|
||||
|
||||
if ($year !== null) {
|
||||
$query->where('year', $year);
|
||||
}
|
||||
if ($quarter !== null) {
|
||||
$query->where('quarter', $quarter);
|
||||
}
|
||||
if ($confirmStatus !== null) {
|
||||
$query->where('confirmation_status', $confirmStatus);
|
||||
}
|
||||
|
||||
$query->orderByDesc('performance_reports.id');
|
||||
$paginated = $query->paginate($perPage);
|
||||
|
||||
$transformedData = $paginated->getCollection()->map(fn ($report) => $this->transformToFrontend($report));
|
||||
|
||||
return [
|
||||
'items' => $transformedData,
|
||||
'current_page' => $paginated->currentPage(),
|
||||
'last_page' => $paginated->lastPage(),
|
||||
'per_page' => $paginated->perPage(),
|
||||
'total' => $paginated->total(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 통계 조회
|
||||
*/
|
||||
public function stats(array $params = []): array
|
||||
{
|
||||
$tenantId = $this->tenantId();
|
||||
|
||||
$query = PerformanceReport::where('performance_reports.tenant_id', $tenantId);
|
||||
|
||||
if (! empty($params['year'])) {
|
||||
$query->where('performance_reports.year', $params['year']);
|
||||
}
|
||||
if (! empty($params['quarter'])) {
|
||||
$query->where('performance_reports.quarter', $params['quarter']);
|
||||
}
|
||||
|
||||
$counts = (clone $query)
|
||||
->select('confirmation_status', DB::raw('count(*) as count'))
|
||||
->groupBy('confirmation_status')
|
||||
->pluck('count', 'confirmation_status')
|
||||
->toArray();
|
||||
|
||||
$totalLocations = (clone $query)
|
||||
->join('quality_documents', 'quality_documents.id', '=', 'performance_reports.quality_document_id')
|
||||
->join('quality_document_locations', 'quality_document_locations.quality_document_id', '=', 'quality_documents.id')
|
||||
->count('quality_document_locations.id');
|
||||
|
||||
return [
|
||||
'total_count' => array_sum($counts),
|
||||
'confirmed_count' => $counts[PerformanceReport::STATUS_CONFIRMED] ?? 0,
|
||||
'unconfirmed_count' => $counts[PerformanceReport::STATUS_UNCONFIRMED] ?? 0,
|
||||
'total_locations' => $totalLocations,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 일괄 확정
|
||||
*/
|
||||
public function confirm(array $ids)
|
||||
{
|
||||
$tenantId = $this->tenantId();
|
||||
$userId = $this->apiUserId();
|
||||
|
||||
return DB::transaction(function () use ($ids, $tenantId, $userId) {
|
||||
$reports = PerformanceReport::where('tenant_id', $tenantId)
|
||||
->whereIn('id', $ids)
|
||||
->with(['qualityDocument'])
|
||||
->get();
|
||||
|
||||
$errors = [];
|
||||
foreach ($reports as $report) {
|
||||
if ($report->isConfirmed() || $report->isReported()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 필수정보 검증
|
||||
$requiredInfo = $this->qualityDocumentService->calculateRequiredInfo($report->qualityDocument);
|
||||
if ($requiredInfo !== '완료') {
|
||||
$errors[] = [
|
||||
'id' => $report->id,
|
||||
'quality_doc_number' => $report->qualityDocument->quality_doc_number,
|
||||
'reason' => $requiredInfo,
|
||||
];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$report->update([
|
||||
'confirmation_status' => PerformanceReport::STATUS_CONFIRMED,
|
||||
'confirmed_date' => now()->toDateString(),
|
||||
'confirmed_by' => $userId,
|
||||
'updated_by' => $userId,
|
||||
]);
|
||||
}
|
||||
|
||||
if (! empty($errors)) {
|
||||
throw new BadRequestHttpException(json_encode([
|
||||
'message' => __('error.quality.confirm_failed'),
|
||||
'errors' => $errors,
|
||||
]));
|
||||
}
|
||||
|
||||
return ['confirmed_count' => count($ids) - count($errors)];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 일괄 확정 해제
|
||||
*/
|
||||
public function unconfirm(array $ids)
|
||||
{
|
||||
$tenantId = $this->tenantId();
|
||||
$userId = $this->apiUserId();
|
||||
|
||||
return DB::transaction(function () use ($ids, $tenantId, $userId) {
|
||||
PerformanceReport::where('tenant_id', $tenantId)
|
||||
->whereIn('id', $ids)
|
||||
->where('confirmation_status', PerformanceReport::STATUS_CONFIRMED)
|
||||
->update([
|
||||
'confirmation_status' => PerformanceReport::STATUS_UNCONFIRMED,
|
||||
'confirmed_date' => null,
|
||||
'confirmed_by' => null,
|
||||
'updated_by' => $userId,
|
||||
]);
|
||||
|
||||
return ['unconfirmed_count' => count($ids)];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 일괄 메모 업데이트
|
||||
*/
|
||||
public function updateMemo(array $ids, string $memo)
|
||||
{
|
||||
$tenantId = $this->tenantId();
|
||||
$userId = $this->apiUserId();
|
||||
|
||||
PerformanceReport::where('tenant_id', $tenantId)
|
||||
->whereIn('id', $ids)
|
||||
->update([
|
||||
'memo' => $memo,
|
||||
'updated_by' => $userId,
|
||||
]);
|
||||
|
||||
return ['updated_count' => count($ids)];
|
||||
}
|
||||
|
||||
/**
|
||||
* 누락체크 (출고완료 but 제품검사 미등록)
|
||||
*/
|
||||
public function missing(array $params): array
|
||||
{
|
||||
$tenantId = $this->tenantId();
|
||||
|
||||
// 품질관리서가 등록된 수주 ID
|
||||
$registeredOrderIds = DB::table('quality_document_orders')
|
||||
->join('quality_documents', 'quality_documents.id', '=', 'quality_document_orders.quality_document_id')
|
||||
->where('quality_documents.tenant_id', $tenantId)
|
||||
->pluck('quality_document_orders.order_id');
|
||||
|
||||
// 출고완료 상태이지만 품질관리서 미등록 수주
|
||||
$query = DB::table('orders')
|
||||
->where('tenant_id', $tenantId)
|
||||
->whereNotIn('id', $registeredOrderIds)
|
||||
->where('status_code', 'SHIPPED'); // TODO: 출고완료 상태 추가 시 상수 확인
|
||||
|
||||
if (! empty($params['year'])) {
|
||||
$query->whereYear('created_at', $params['year']);
|
||||
}
|
||||
if (! empty($params['quarter'])) {
|
||||
$quarter = (int) $params['quarter'];
|
||||
$startMonth = ($quarter - 1) * 3 + 1;
|
||||
$endMonth = $quarter * 3;
|
||||
$query->whereMonth('created_at', '>=', $startMonth)
|
||||
->whereMonth('created_at', '<=', $endMonth);
|
||||
}
|
||||
|
||||
return $query->orderByDesc('id')
|
||||
->limit(100)
|
||||
->get()
|
||||
->map(fn ($order) => [
|
||||
'id' => $order->id,
|
||||
'order_number' => $order->order_no ?? '',
|
||||
'site_name' => $order->site_name ?? '',
|
||||
'client' => '', // 별도 조인 필요
|
||||
'delivery_date' => $order->delivery_date ?? '',
|
||||
])
|
||||
->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* DB → 프론트엔드 변환
|
||||
*/
|
||||
private function transformToFrontend(PerformanceReport $report): array
|
||||
{
|
||||
$doc = $report->qualityDocument;
|
||||
|
||||
return [
|
||||
'id' => $report->id,
|
||||
'quality_doc_number' => $doc?->quality_doc_number ?? '',
|
||||
'created_date' => $report->created_at?->format('Y-m-d') ?? '',
|
||||
'site_name' => $doc?->site_name ?? '',
|
||||
'client' => $doc?->client?->name ?? '',
|
||||
'location_count' => $doc?->locations?->count() ?? 0,
|
||||
'required_info' => $doc ? $this->qualityDocumentService->calculateRequiredInfo($doc) : '',
|
||||
'confirm_status' => $report->confirmation_status === PerformanceReport::STATUS_CONFIRMED ? 'confirmed' : 'unconfirmed',
|
||||
'confirm_date' => $report->confirmed_date?->format('Y-m-d'),
|
||||
'memo' => $report->memo ?? '',
|
||||
'year' => $report->year,
|
||||
'quarter' => $report->quarter,
|
||||
];
|
||||
}
|
||||
}
|
||||
285
app/Services/ProductionOrderService.php
Normal file
285
app/Services/ProductionOrderService.php
Normal file
@@ -0,0 +1,285 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Orders\Order;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
|
||||
class ProductionOrderService extends Service
|
||||
{
|
||||
/**
|
||||
* 생산지시 대상 상태 코드
|
||||
*/
|
||||
private const PRODUCTION_STATUSES = [
|
||||
Order::STATUS_IN_PROGRESS,
|
||||
Order::STATUS_IN_PRODUCTION,
|
||||
Order::STATUS_PRODUCED,
|
||||
Order::STATUS_SHIPPING,
|
||||
Order::STATUS_SHIPPED,
|
||||
];
|
||||
|
||||
/**
|
||||
* 생산지시 목록 조회
|
||||
*/
|
||||
public function index(array $params): LengthAwarePaginator
|
||||
{
|
||||
$tenantId = $this->tenantId();
|
||||
|
||||
$query = Order::query()
|
||||
->where('tenant_id', $tenantId)
|
||||
->whereIn('status_code', self::PRODUCTION_STATUSES)
|
||||
->with(['client', 'workOrders.process', 'workOrders.assignees.user'])
|
||||
->withCount([
|
||||
'workOrders' => fn ($q) => $q->whereNotNull('process_id')
|
||||
->where(fn ($q2) => $q2->whereNull('options->is_auxiliary')
|
||||
->orWhere('options->is_auxiliary', false)),
|
||||
'nodes',
|
||||
]);
|
||||
|
||||
// 검색어 필터
|
||||
if (! empty($params['search'])) {
|
||||
$search = $params['search'];
|
||||
$query->where(function ($q) use ($search) {
|
||||
$q->where('order_no', 'like', "%{$search}%")
|
||||
->orWhere('client_name', 'like', "%{$search}%")
|
||||
->orWhere('site_name', 'like', "%{$search}%");
|
||||
});
|
||||
}
|
||||
|
||||
// 생산 상태 필터
|
||||
if (! empty($params['production_status'])) {
|
||||
switch ($params['production_status']) {
|
||||
case 'waiting':
|
||||
$query->where('status_code', Order::STATUS_IN_PROGRESS);
|
||||
break;
|
||||
case 'in_production':
|
||||
$query->where('status_code', Order::STATUS_IN_PRODUCTION);
|
||||
break;
|
||||
case 'completed':
|
||||
$query->whereIn('status_code', [
|
||||
Order::STATUS_PRODUCED,
|
||||
Order::STATUS_SHIPPING,
|
||||
Order::STATUS_SHIPPED,
|
||||
]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 정렬
|
||||
$sortBy = $params['sort_by'] ?? 'created_at';
|
||||
$sortDir = $params['sort_dir'] ?? 'desc';
|
||||
$query->orderBy($sortBy, $sortDir);
|
||||
|
||||
// 페이지네이션
|
||||
$perPage = $params['per_page'] ?? 20;
|
||||
$result = $query->paginate($perPage);
|
||||
|
||||
// 가공 필드 추가
|
||||
$result->getCollection()->transform(function (Order $order) {
|
||||
$minCreatedAt = $order->workOrders->min('created_at');
|
||||
$order->production_ordered_at = $minCreatedAt
|
||||
? $minCreatedAt->format('Y-m-d')
|
||||
: null;
|
||||
|
||||
// 개소수 (order_nodes 수)
|
||||
$order->node_count = $order->nodes_count ?? 0;
|
||||
|
||||
// 주요 생산 공정 WO만 (구매품 + 보조 공정 제외)
|
||||
$productionWOs = $this->filterMainProductionWOs($order->workOrders);
|
||||
$order->work_order_progress = [
|
||||
'total' => $productionWOs->count(),
|
||||
'completed' => $productionWOs->where('status', 'completed')->count()
|
||||
+ $productionWOs->where('status', 'shipped')->count(),
|
||||
'in_progress' => $productionWOs->where('status', 'in_progress')->count(),
|
||||
];
|
||||
|
||||
// 프론트 탭용 production_status 매핑
|
||||
$order->production_status = $this->mapProductionStatus($order->status_code);
|
||||
|
||||
return $order;
|
||||
});
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 상태별 통계
|
||||
*/
|
||||
public function stats(): array
|
||||
{
|
||||
$tenantId = $this->tenantId();
|
||||
|
||||
$waiting = Order::where('tenant_id', $tenantId)
|
||||
->where('status_code', Order::STATUS_IN_PROGRESS)
|
||||
->count();
|
||||
|
||||
$inProduction = Order::where('tenant_id', $tenantId)
|
||||
->where('status_code', Order::STATUS_IN_PRODUCTION)
|
||||
->count();
|
||||
|
||||
$completed = Order::where('tenant_id', $tenantId)
|
||||
->whereIn('status_code', [
|
||||
Order::STATUS_PRODUCED,
|
||||
Order::STATUS_SHIPPING,
|
||||
Order::STATUS_SHIPPED,
|
||||
])
|
||||
->count();
|
||||
|
||||
return [
|
||||
'total' => $waiting + $inProduction + $completed,
|
||||
'waiting' => $waiting,
|
||||
'in_production' => $inProduction,
|
||||
'completed' => $completed,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 생산지시 상세 조회
|
||||
*/
|
||||
public function show(int $orderId): array
|
||||
{
|
||||
$tenantId = $this->tenantId();
|
||||
|
||||
$order = Order::query()
|
||||
->where('tenant_id', $tenantId)
|
||||
->whereIn('status_code', self::PRODUCTION_STATUSES)
|
||||
->with([
|
||||
'client',
|
||||
'workOrders.process',
|
||||
'workOrders.items',
|
||||
'workOrders.assignees.user',
|
||||
'nodes',
|
||||
])
|
||||
->withCount('nodes')
|
||||
->findOrFail($orderId);
|
||||
|
||||
// 생산지시일 (날짜만)
|
||||
$minCreatedAt = $order->workOrders->min('created_at');
|
||||
$order->production_ordered_at = $minCreatedAt
|
||||
? $minCreatedAt->format('Y-m-d')
|
||||
: null;
|
||||
$order->production_status = $this->mapProductionStatus($order->status_code);
|
||||
|
||||
// 주요 생산 공정 WO만 필터 (구매품 + 보조 공정 제외)
|
||||
$productionWorkOrders = $this->filterMainProductionWOs($order->workOrders);
|
||||
|
||||
// WorkOrder 진행 현황 (생산 공정 기준)
|
||||
$workOrderProgress = [
|
||||
'total' => $productionWorkOrders->count(),
|
||||
'completed' => $productionWorkOrders->where('status', 'completed')->count()
|
||||
+ $productionWorkOrders->where('status', 'shipped')->count(),
|
||||
'in_progress' => $productionWorkOrders->where('status', 'in_progress')->count(),
|
||||
];
|
||||
|
||||
// WorkOrder 목록 가공 (생산 공정만)
|
||||
$workOrders = $productionWorkOrders->values()->map(function ($wo) {
|
||||
return [
|
||||
'id' => $wo->id,
|
||||
'work_order_no' => $wo->work_order_no,
|
||||
'process_name' => $wo->process?->process_name ?? '',
|
||||
'quantity' => $wo->items->count(),
|
||||
'status' => $wo->status,
|
||||
'assignees' => $wo->assignees->map(fn ($a) => $a->user?->name ?? '')->filter()->values()->toArray(),
|
||||
];
|
||||
});
|
||||
|
||||
// BOM 데이터 (order_nodes에서 추출)
|
||||
$bomProcessGroups = $this->extractBomProcessGroups($order->nodes);
|
||||
|
||||
return [
|
||||
'order' => $order->makeHidden(['workOrders', 'nodes']),
|
||||
'production_ordered_at' => $order->production_ordered_at,
|
||||
'production_status' => $order->production_status,
|
||||
'node_count' => $order->nodes_count ?? 0,
|
||||
'work_order_progress' => $workOrderProgress,
|
||||
'work_orders' => $workOrders,
|
||||
'bom_process_groups' => $bomProcessGroups,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Order status_code → 프론트 production_status 매핑
|
||||
*/
|
||||
private function mapProductionStatus(string $statusCode): string
|
||||
{
|
||||
return match ($statusCode) {
|
||||
Order::STATUS_IN_PROGRESS => 'waiting',
|
||||
Order::STATUS_IN_PRODUCTION => 'in_production',
|
||||
default => 'completed',
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* order_nodes에서 BOM 공정 분류 추출
|
||||
*
|
||||
* bom_result 구조: { items: [...], success, subtotals, ... }
|
||||
* 각 item: { item_id, item_code, item_name, process_group, specification, quantity, unit, ... }
|
||||
*/
|
||||
private function extractBomProcessGroups($nodes): array
|
||||
{
|
||||
$groups = [];
|
||||
|
||||
foreach ($nodes as $node) {
|
||||
$bomResult = $node->options['bom_result'] ?? null;
|
||||
if (! $bomResult || ! is_array($bomResult)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// bom_result.items 배열에서 추출
|
||||
$items = $bomResult['items'] ?? [];
|
||||
if (! is_array($items)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$nodeName = $node->name ?? '';
|
||||
|
||||
foreach ($items as $item) {
|
||||
if (! is_array($item)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$processGroup = $item['process_group'] ?? $item['category_group'] ?? '기타';
|
||||
|
||||
if (! isset($groups[$processGroup])) {
|
||||
$groups[$processGroup] = [
|
||||
'process_name' => $processGroup,
|
||||
'items' => [],
|
||||
];
|
||||
}
|
||||
|
||||
$groups[$processGroup]['items'][] = [
|
||||
'id' => $item['item_id'] ?? null,
|
||||
'item_code' => $item['item_code'] ?? '',
|
||||
'item_name' => $item['item_name'] ?? '',
|
||||
'spec' => $item['specification'] ?? '',
|
||||
'unit' => $item['unit'] ?? '',
|
||||
'quantity' => $item['quantity'] ?? 0,
|
||||
'unit_price' => $item['unit_price'] ?? 0,
|
||||
'total_price' => $item['total_price'] ?? 0,
|
||||
'node_name' => $nodeName,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return array_values($groups);
|
||||
}
|
||||
|
||||
/**
|
||||
* 주요 생산 공정 WO만 필터 (구매품/서비스 + 보조 공정 제외)
|
||||
*
|
||||
* 제외 대상:
|
||||
* - process_id가 null인 WO (구매품/서비스)
|
||||
* - options.is_auxiliary가 true인 WO (재고생산 등 보조 공정)
|
||||
*/
|
||||
private function filterMainProductionWOs($workOrders): \Illuminate\Support\Collection
|
||||
{
|
||||
return $workOrders->filter(function ($wo) {
|
||||
if (empty($wo->process_id)) {
|
||||
return false;
|
||||
}
|
||||
$options = is_array($wo->options) ? $wo->options : (json_decode($wo->options, true) ?? []);
|
||||
|
||||
return empty($options['is_auxiliary']);
|
||||
});
|
||||
}
|
||||
}
|
||||
1251
app/Services/QualityDocumentService.php
Normal file
1251
app/Services/QualityDocumentService.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -67,16 +67,35 @@ private function getOrdersStatus(int $tenantId, Carbon $today): array
|
||||
*/
|
||||
private function getBadDebtStatus(int $tenantId): array
|
||||
{
|
||||
$count = BadDebt::query()
|
||||
->where('tenant_id', $tenantId)
|
||||
->where('status', BadDebt::STATUS_COLLECTING) // 추심 진행 중
|
||||
->where('is_active', true) // 활성 채권만 (목록 페이지와 일치)
|
||||
->count();
|
||||
$query = BadDebt::query()
|
||||
->where('bad_debts.tenant_id', $tenantId)
|
||||
->where('bad_debts.status', BadDebt::STATUS_COLLECTING)
|
||||
->where('bad_debts.is_active', true);
|
||||
|
||||
$count = (clone $query)->count();
|
||||
|
||||
// 최다 금액 거래처명 조회
|
||||
$subLabel = null;
|
||||
if ($count > 0) {
|
||||
$topClient = (clone $query)
|
||||
->join('clients', 'bad_debts.client_id', '=', 'clients.id')
|
||||
->selectRaw('clients.name, SUM(bad_debts.debt_amount) as total_amount')
|
||||
->groupBy('clients.id', 'clients.name')
|
||||
->orderByDesc('total_amount')
|
||||
->first();
|
||||
|
||||
if ($topClient) {
|
||||
$subLabel = $count > 1
|
||||
? $topClient->name.' 외 '.($count - 1).'건'
|
||||
: $topClient->name;
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => 'bad_debts',
|
||||
'label' => __('message.status_board.bad_debts'),
|
||||
'count' => $count,
|
||||
'sub_label' => $subLabel,
|
||||
'path' => '/accounting/bad-debt-collection',
|
||||
'isHighlighted' => false,
|
||||
];
|
||||
@@ -152,15 +171,31 @@ private function getTaxDeadlineStatus(int $tenantId, Carbon $today): array
|
||||
*/
|
||||
private function getNewClientStatus(int $tenantId, Carbon $today): array
|
||||
{
|
||||
$count = Client::query()
|
||||
$query = Client::query()
|
||||
->where('tenant_id', $tenantId)
|
||||
->where('created_at', '>=', $today->copy()->subDays(7))
|
||||
->count();
|
||||
->where('created_at', '>=', $today->copy()->subDays(7));
|
||||
|
||||
$count = (clone $query)->count();
|
||||
|
||||
// 가장 최근 등록 업체명 조회
|
||||
$subLabel = null;
|
||||
if ($count > 0) {
|
||||
$latestClient = (clone $query)
|
||||
->orderByDesc('created_at')
|
||||
->first();
|
||||
|
||||
if ($latestClient) {
|
||||
$subLabel = $count > 1
|
||||
? $latestClient->name.' 외 '.($count - 1).'건'
|
||||
: $latestClient->name;
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => 'new_clients',
|
||||
'label' => __('message.status_board.new_clients'),
|
||||
'count' => $count,
|
||||
'sub_label' => $subLabel,
|
||||
'path' => '/accounting/vendors',
|
||||
'isHighlighted' => false,
|
||||
];
|
||||
@@ -211,19 +246,34 @@ private function getPurchaseStatus(int $tenantId): array
|
||||
*/
|
||||
private function getApprovalStatus(int $tenantId, int $userId): array
|
||||
{
|
||||
$count = ApprovalStep::query()
|
||||
->whereHas('approval', function ($query) use ($tenantId) {
|
||||
$query->where('tenant_id', $tenantId)
|
||||
$query = ApprovalStep::query()
|
||||
->whereHas('approval', function ($q) use ($tenantId) {
|
||||
$q->where('tenant_id', $tenantId)
|
||||
->where('status', 'pending');
|
||||
})
|
||||
->where('approver_id', $userId)
|
||||
->where('status', 'pending')
|
||||
->count();
|
||||
->approvalOnly();
|
||||
|
||||
$count = (clone $query)->count();
|
||||
|
||||
// 최근 결재 유형 조회
|
||||
$subLabel = null;
|
||||
if ($count > 0) {
|
||||
$latestStep = (clone $query)->with('approval')->latest()->first();
|
||||
if ($latestStep && $latestStep->approval) {
|
||||
$typeLabel = $latestStep->approval->title ?? '결재';
|
||||
$subLabel = $count > 1
|
||||
? $typeLabel.' 외 '.($count - 1).'건'
|
||||
: $typeLabel;
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => 'approvals',
|
||||
'label' => __('message.status_board.approvals'),
|
||||
'count' => $count,
|
||||
'sub_label' => $subLabel,
|
||||
'path' => '/approval/inbox',
|
||||
'isHighlighted' => $count > 0,
|
||||
];
|
||||
|
||||
@@ -112,6 +112,12 @@ public function create(array $data): TaxInvoice
|
||||
// 합계금액 계산
|
||||
$data['total_amount'] = ($data['supply_amount'] ?? 0) + ($data['tax_amount'] ?? 0);
|
||||
|
||||
// NOT NULL 컬럼: Laravel ConvertEmptyStringsToNull 미들웨어가 ''→null 변환하므로 보정
|
||||
$data['supplier_corp_num'] = $data['supplier_corp_num'] ?? '';
|
||||
$data['supplier_corp_name'] = $data['supplier_corp_name'] ?? '';
|
||||
$data['buyer_corp_num'] = $data['buyer_corp_num'] ?? '';
|
||||
$data['buyer_corp_name'] = $data['buyer_corp_name'] ?? '';
|
||||
|
||||
$taxInvoice = TaxInvoice::create(array_merge($data, [
|
||||
'tenant_id' => $tenantId,
|
||||
'status' => TaxInvoice::STATUS_DRAFT,
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Services\TenantBootstrap;
|
||||
|
||||
use App\Services\TenantBootstrap\Steps\ApprovalFormsStep;
|
||||
use App\Services\TenantBootstrap\Steps\CapabilityProfilesStep;
|
||||
use App\Services\TenantBootstrap\Steps\CategoriesStep;
|
||||
use App\Services\TenantBootstrap\Steps\MenusStep;
|
||||
@@ -24,6 +25,7 @@ public function steps(string $recipe = 'STANDARD'): array
|
||||
new CategoriesStep,
|
||||
// new MenusStep, // Disabled: Use MenuBootstrapService in RegisterService instead
|
||||
new SettingsStep,
|
||||
new ApprovalFormsStep,
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
105
app/Services/TenantBootstrap/Steps/ApprovalFormsStep.php
Normal file
105
app/Services/TenantBootstrap/Steps/ApprovalFormsStep.php
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\TenantBootstrap\Steps;
|
||||
|
||||
use App\Services\TenantBootstrap\Contracts\TenantBootstrapStep;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ApprovalFormsStep implements TenantBootstrapStep
|
||||
{
|
||||
public function key(): string
|
||||
{
|
||||
return 'approval_forms_seed';
|
||||
}
|
||||
|
||||
public function run(int $tenantId): void
|
||||
{
|
||||
if (! DB::getSchemaBuilder()->hasTable('approval_forms')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$now = now();
|
||||
$forms = [
|
||||
[
|
||||
'name' => '품의서',
|
||||
'code' => 'proposal',
|
||||
'category' => '일반',
|
||||
'template' => json_encode([
|
||||
'fields' => [
|
||||
['name' => 'title', 'type' => 'text', 'label' => '제목', 'required' => true],
|
||||
['name' => 'vendor', 'type' => 'text', 'label' => '거래처', 'required' => false],
|
||||
['name' => 'description', 'type' => 'textarea', 'label' => '내용', 'required' => true],
|
||||
['name' => 'reason', 'type' => 'textarea', 'label' => '사유', 'required' => true],
|
||||
['name' => 'estimatedCost', 'type' => 'number', 'label' => '예상비용', 'required' => false],
|
||||
],
|
||||
]),
|
||||
],
|
||||
[
|
||||
'name' => '지출결의서',
|
||||
'code' => 'expenseReport',
|
||||
'category' => '경비',
|
||||
'template' => json_encode([
|
||||
'fields' => [
|
||||
['name' => 'requestDate', 'type' => 'date', 'label' => '신청일', 'required' => true],
|
||||
['name' => 'paymentDate', 'type' => 'date', 'label' => '지급일', 'required' => true],
|
||||
['name' => 'items', 'type' => 'array', 'label' => '지출항목', 'required' => true],
|
||||
['name' => 'totalAmount', 'type' => 'number', 'label' => '총액', 'required' => true],
|
||||
],
|
||||
]),
|
||||
],
|
||||
[
|
||||
'name' => '비용견적서',
|
||||
'code' => 'expenseEstimate',
|
||||
'category' => '경비',
|
||||
'template' => json_encode([
|
||||
'fields' => [
|
||||
['name' => 'items', 'type' => 'array', 'label' => '비용항목', 'required' => true],
|
||||
['name' => 'totalExpense', 'type' => 'number', 'label' => '총지출', 'required' => true],
|
||||
['name' => 'accountBalance', 'type' => 'number', 'label' => '계좌잔액', 'required' => true],
|
||||
],
|
||||
]),
|
||||
],
|
||||
[
|
||||
'name' => '근태신청',
|
||||
'code' => 'attendance_request',
|
||||
'category' => '일반',
|
||||
'template' => json_encode([
|
||||
'fields' => [
|
||||
['name' => 'user_name', 'type' => 'text', 'label' => '신청자', 'required' => true],
|
||||
['name' => 'request_type', 'type' => 'select', 'label' => '신청유형', 'required' => true],
|
||||
['name' => 'period', 'type' => 'daterange', 'label' => '기간', 'required' => true],
|
||||
['name' => 'days', 'type' => 'number', 'label' => '일수', 'required' => true],
|
||||
['name' => 'reason', 'type' => 'textarea', 'label' => '사유', 'required' => true],
|
||||
],
|
||||
]),
|
||||
],
|
||||
[
|
||||
'name' => '사유서',
|
||||
'code' => 'reason_report',
|
||||
'category' => '일반',
|
||||
'template' => json_encode([
|
||||
'fields' => [
|
||||
['name' => 'user_name', 'type' => 'text', 'label' => '작성자', 'required' => true],
|
||||
['name' => 'report_type', 'type' => 'select', 'label' => '사유유형', 'required' => true],
|
||||
['name' => 'target_date', 'type' => 'date', 'label' => '대상일', 'required' => true],
|
||||
['name' => 'reason', 'type' => 'textarea', 'label' => '사유', 'required' => true],
|
||||
],
|
||||
]),
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($forms as $form) {
|
||||
DB::table('approval_forms')->updateOrInsert(
|
||||
['tenant_id' => $tenantId, 'code' => $form['code']],
|
||||
[
|
||||
'name' => $form['name'],
|
||||
'category' => $form['category'],
|
||||
'template' => $form['template'],
|
||||
'is_active' => true,
|
||||
'updated_at' => $now,
|
||||
'created_at' => $now,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -498,7 +498,9 @@ public function getDetail(
|
||||
?int $fixedAmountPerMonth = 200000,
|
||||
?float $ratio = 0.05,
|
||||
?int $year = null,
|
||||
?int $quarter = null
|
||||
?int $quarter = null,
|
||||
?string $startDate = null,
|
||||
?string $endDate = null
|
||||
): array {
|
||||
$tenantId = $this->tenantId();
|
||||
$now = Carbon::now();
|
||||
@@ -562,8 +564,10 @@ public function getDetail(
|
||||
// 3. 항목별 분포
|
||||
$categoryDistribution = $this->getCategoryDistribution($tenantId, $annualStartDate, $annualEndDate);
|
||||
|
||||
// 4. 일별 사용 내역
|
||||
$transactions = $this->getTransactions($tenantId, $quarterStartDate, $quarterEndDate);
|
||||
// 4. 일별 사용 내역 (커스텀 날짜 범위가 있으면 해당 범위, 없으면 분기 기준)
|
||||
$txStartDate = $startDate ?? $quarterStartDate;
|
||||
$txEndDate = $endDate ?? $quarterEndDate;
|
||||
$transactions = $this->getTransactions($tenantId, $txStartDate, $txEndDate);
|
||||
|
||||
// 5. 계산 정보
|
||||
$calculation = [
|
||||
|
||||
@@ -259,6 +259,17 @@ public function store(array $data)
|
||||
$salesOrderId = $data['sales_order_id'] ?? null;
|
||||
unset($data['items'], $data['bending_detail']);
|
||||
|
||||
// 공정의 is_auxiliary 플래그를 WO options에 복사
|
||||
if (! empty($data['process_id'])) {
|
||||
$process = \App\Models\Process::find($data['process_id']);
|
||||
if ($process && ! empty($process->options['is_auxiliary'])) {
|
||||
$opts = $data['options'] ?? [];
|
||||
$opts = is_array($opts) ? $opts : (json_decode($opts, true) ?? []);
|
||||
$opts['is_auxiliary'] = true;
|
||||
$data['options'] = $opts;
|
||||
}
|
||||
}
|
||||
|
||||
$workOrder = WorkOrder::create($data);
|
||||
|
||||
// process 관계 로드 (isBending 체크용)
|
||||
@@ -815,6 +826,11 @@ private function syncOrderStatus(WorkOrder $workOrder, int $tenantId): void
|
||||
return;
|
||||
}
|
||||
|
||||
// 보조 공정(재고생산 등)은 수주 상태에 영향 주지 않음
|
||||
if ($this->isAuxiliaryWorkOrder($workOrder)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$order = Order::where('tenant_id', $tenantId)->find($workOrder->sales_order_id);
|
||||
if (! $order) {
|
||||
return;
|
||||
@@ -850,6 +866,47 @@ private function syncOrderStatus(WorkOrder $workOrder, int $tenantId): void
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 자재 투입 시 작업지시가 대기 상태이면 자동으로 진행중으로 전환
|
||||
*
|
||||
* pending/waiting 상태에서 첫 자재 투입이 발생하면
|
||||
* 작업지시 → in_progress, 수주 → IN_PRODUCTION 으로 자동 전환
|
||||
*/
|
||||
private function autoStartWorkOrderOnMaterialInput(WorkOrder $workOrder, int $tenantId): void
|
||||
{
|
||||
// 보조 공정(재고생산 등)은 WO 자체는 진행중으로 전환하되, 수주 상태는 변경하지 않음
|
||||
$isAuxiliary = $this->isAuxiliaryWorkOrder($workOrder);
|
||||
|
||||
// 아직 진행 전인 상태에서만 자동 전환 (자재투입 = 실질적 작업 시작)
|
||||
if (! in_array($workOrder->status, [
|
||||
WorkOrder::STATUS_UNASSIGNED,
|
||||
WorkOrder::STATUS_PENDING,
|
||||
WorkOrder::STATUS_WAITING,
|
||||
])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$oldStatus = $workOrder->status;
|
||||
$workOrder->status = WorkOrder::STATUS_IN_PROGRESS;
|
||||
$workOrder->updated_by = $this->apiUserId();
|
||||
$workOrder->save();
|
||||
|
||||
// 감사 로그
|
||||
$this->auditLogger->log(
|
||||
$tenantId,
|
||||
self::AUDIT_TARGET,
|
||||
$workOrder->id,
|
||||
'status_auto_changed_on_material_input',
|
||||
['status' => $oldStatus],
|
||||
['status' => WorkOrder::STATUS_IN_PROGRESS]
|
||||
);
|
||||
|
||||
// 보조 공정이 아닌 경우만 수주 상태 동기화
|
||||
if (! $isAuxiliary) {
|
||||
$this->syncOrderStatus($workOrder, $tenantId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 작업지시 품목에 결과 데이터 저장
|
||||
*/
|
||||
@@ -890,6 +947,16 @@ private function saveItemResults(WorkOrder $workOrder, ?array $resultData, int $
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 보조 공정(재고생산 등) 여부 판단
|
||||
*/
|
||||
private function isAuxiliaryWorkOrder(WorkOrder $workOrder): bool
|
||||
{
|
||||
$options = is_array($workOrder->options) ? $workOrder->options : (json_decode($workOrder->options, true) ?? []);
|
||||
|
||||
return ! empty($options['is_auxiliary']);
|
||||
}
|
||||
|
||||
/**
|
||||
* LOT 번호 생성
|
||||
*/
|
||||
@@ -1458,6 +1525,9 @@ public function registerMaterialInput(int $workOrderId, array $inputs): array
|
||||
$totalCount = array_sum(array_column($delegatedResults, 'material_count'));
|
||||
$allResults = array_merge(...array_map(fn ($r) => $r['input_results'], $delegatedResults));
|
||||
|
||||
// 자재 투입 시 작업지시가 대기 상태면 자동으로 진행중으로 전환
|
||||
$this->autoStartWorkOrderOnMaterialInput($workOrder, $tenantId);
|
||||
|
||||
return [
|
||||
'work_order_id' => $workOrderId,
|
||||
'material_count' => $totalCount,
|
||||
@@ -1536,6 +1606,9 @@ public function registerMaterialInput(int $workOrderId, array $inputs): array
|
||||
$allResults = array_merge($allResults, $dr['input_results']);
|
||||
}
|
||||
|
||||
// 자재 투입 시 작업지시가 대기 상태면 자동으로 진행중으로 전환
|
||||
$this->autoStartWorkOrderOnMaterialInput($workOrder, $tenantId);
|
||||
|
||||
return [
|
||||
'work_order_id' => $workOrderId,
|
||||
'material_count' => count($allResults),
|
||||
@@ -2358,11 +2431,26 @@ public function resolveInspectionDocument(int $workOrderId, array $params = []):
|
||||
->latest()
|
||||
->first();
|
||||
|
||||
// Lazy Snapshot 대상: rendered_html이 없는 문서 (상태 무관)
|
||||
$snapshotDocumentId = null;
|
||||
$snapshotCandidate = Document::query()
|
||||
->where('tenant_id', $tenantId)
|
||||
->where('template_id', $templateId)
|
||||
->where('linkable_type', 'work_order')
|
||||
->where('linkable_id', $workOrderId)
|
||||
->whereNull('rendered_html')
|
||||
->latest()
|
||||
->value('id');
|
||||
if ($snapshotCandidate) {
|
||||
$snapshotDocumentId = $snapshotCandidate;
|
||||
}
|
||||
|
||||
return [
|
||||
'work_order_id' => $workOrderId,
|
||||
'template_id' => $templateId,
|
||||
'template' => $formattedTemplate,
|
||||
'existing_document' => $existingDocument,
|
||||
'snapshot_document_id' => $snapshotDocumentId,
|
||||
'work_order_info' => $this->buildWorkOrderInfo($workOrder),
|
||||
];
|
||||
}
|
||||
@@ -2436,10 +2524,14 @@ public function createInspectionDocument(int $workOrderId, array $inspectionData
|
||||
])
|
||||
->toArray();
|
||||
|
||||
$document = $documentService->update($existingDocument->id, [
|
||||
$updateData = [
|
||||
'title' => $inspectionData['title'] ?? $existingDocument->title,
|
||||
'data' => array_merge($existingBasicFields, $documentDataRecords),
|
||||
]);
|
||||
];
|
||||
if (isset($inspectionData['rendered_html'])) {
|
||||
$updateData['rendered_html'] = $inspectionData['rendered_html'];
|
||||
}
|
||||
$document = $documentService->update($existingDocument->id, $updateData);
|
||||
|
||||
$action = 'inspection_document_updated';
|
||||
} else {
|
||||
@@ -2451,6 +2543,9 @@ public function createInspectionDocument(int $workOrderId, array $inspectionData
|
||||
'data' => $documentDataRecords,
|
||||
'approvers' => $inspectionData['approvers'] ?? [],
|
||||
];
|
||||
if (isset($inspectionData['rendered_html'])) {
|
||||
$documentData['rendered_html'] = $inspectionData['rendered_html'];
|
||||
}
|
||||
|
||||
$document = $documentService->create($documentData);
|
||||
$action = 'inspection_document_created';
|
||||
@@ -3067,20 +3162,28 @@ public function createWorkLog(int $workOrderId, array $workLogData): array
|
||||
$documentDataRecords = $this->transformWorkLogDataToRecords($workLogData, $workOrder, $template);
|
||||
|
||||
if ($existingDocument) {
|
||||
$document = $documentService->update($existingDocument->id, [
|
||||
$updateData = [
|
||||
'title' => $workLogData['title'] ?? $existingDocument->title,
|
||||
'data' => $documentDataRecords,
|
||||
]);
|
||||
];
|
||||
if (isset($workLogData['rendered_html'])) {
|
||||
$updateData['rendered_html'] = $workLogData['rendered_html'];
|
||||
}
|
||||
$document = $documentService->update($existingDocument->id, $updateData);
|
||||
$action = 'work_log_updated';
|
||||
} else {
|
||||
$document = $documentService->create([
|
||||
$createData = [
|
||||
'template_id' => $templateId,
|
||||
'title' => $workLogData['title'] ?? "작업일지 - {$workOrder->work_order_no}",
|
||||
'linkable_type' => 'work_order',
|
||||
'linkable_id' => $workOrderId,
|
||||
'data' => $documentDataRecords,
|
||||
'approvers' => $workLogData['approvers'] ?? [],
|
||||
]);
|
||||
];
|
||||
if (isset($workLogData['rendered_html'])) {
|
||||
$createData['rendered_html'] = $workLogData['rendered_html'];
|
||||
}
|
||||
$document = $documentService->create($createData);
|
||||
$action = 'work_log_created';
|
||||
}
|
||||
|
||||
|
||||
188
app/Swagger/v1/ProductionOrderApi.php
Normal file
188
app/Swagger/v1/ProductionOrderApi.php
Normal file
@@ -0,0 +1,188 @@
|
||||
<?php
|
||||
|
||||
namespace App\Swagger\v1;
|
||||
|
||||
/**
|
||||
* @OA\Tag(name="ProductionOrders", description="생산지시 관리")
|
||||
*
|
||||
* @OA\Schema(
|
||||
* schema="ProductionOrderListItem",
|
||||
* type="object",
|
||||
* description="생산지시 목록 아이템",
|
||||
*
|
||||
* @OA\Property(property="id", type="integer", example=1, description="수주 ID"),
|
||||
* @OA\Property(property="order_no", type="string", example="ORD-20260301-0001", description="수주번호 (= 생산지시번호)"),
|
||||
* @OA\Property(property="site_name", type="string", example="서울현장", nullable=true, description="현장명"),
|
||||
* @OA\Property(property="client_name", type="string", example="(주)고객사", nullable=true, description="거래처명"),
|
||||
* @OA\Property(property="quantity", type="number", example=232, description="부품수량 합계"),
|
||||
* @OA\Property(property="node_count", type="integer", example=4, description="개소수 (order_nodes 수)"),
|
||||
* @OA\Property(property="delivery_date", type="string", format="date", example="2026-03-15", nullable=true, description="납기일"),
|
||||
* @OA\Property(property="production_ordered_at", type="string", format="date", example="2026-02-21", nullable=true, description="생산지시일 (첫 WorkOrder 생성일, Y-m-d)"),
|
||||
* @OA\Property(property="production_status", type="string", enum={"waiting","in_production","completed"}, example="waiting", description="생산 상태"),
|
||||
* @OA\Property(property="work_orders_count", type="integer", example=2, description="작업지시 수 (공정별 1건)"),
|
||||
* @OA\Property(property="work_order_progress", type="object",
|
||||
* @OA\Property(property="total", type="integer", example=3),
|
||||
* @OA\Property(property="completed", type="integer", example=1),
|
||||
* @OA\Property(property="in_progress", type="integer", example=1)
|
||||
* ),
|
||||
* @OA\Property(property="client", type="object", nullable=true,
|
||||
* @OA\Property(property="id", type="integer", example=1),
|
||||
* @OA\Property(property="name", type="string", example="(주)고객사")
|
||||
* )
|
||||
* )
|
||||
*
|
||||
* @OA\Schema(
|
||||
* schema="ProductionOrderStats",
|
||||
* type="object",
|
||||
* description="생산지시 통계",
|
||||
*
|
||||
* @OA\Property(property="total", type="integer", example=25, description="전체"),
|
||||
* @OA\Property(property="waiting", type="integer", example=10, description="생산대기"),
|
||||
* @OA\Property(property="in_production", type="integer", example=8, description="생산중"),
|
||||
* @OA\Property(property="completed", type="integer", example=7, description="생산완료")
|
||||
* )
|
||||
*
|
||||
* @OA\Schema(
|
||||
* schema="ProductionOrderDetail",
|
||||
* type="object",
|
||||
* description="생산지시 상세",
|
||||
*
|
||||
* @OA\Property(property="order", ref="#/components/schemas/ProductionOrderListItem"),
|
||||
* @OA\Property(property="production_ordered_at", type="string", format="date", example="2026-02-21", nullable=true),
|
||||
* @OA\Property(property="production_status", type="string", enum={"waiting","in_production","completed"}),
|
||||
* @OA\Property(property="node_count", type="integer", example=4, description="개소수"),
|
||||
* @OA\Property(property="work_order_progress", type="object",
|
||||
* @OA\Property(property="total", type="integer"),
|
||||
* @OA\Property(property="completed", type="integer"),
|
||||
* @OA\Property(property="in_progress", type="integer")
|
||||
* ),
|
||||
* @OA\Property(property="work_orders", type="array",
|
||||
*
|
||||
* @OA\Items(type="object",
|
||||
*
|
||||
* @OA\Property(property="id", type="integer"),
|
||||
* @OA\Property(property="work_order_no", type="string"),
|
||||
* @OA\Property(property="process_name", type="string"),
|
||||
* @OA\Property(property="quantity", type="integer"),
|
||||
* @OA\Property(property="status", type="string"),
|
||||
* @OA\Property(property="assignees", type="array", @OA\Items(type="string"))
|
||||
* )
|
||||
* ),
|
||||
* @OA\Property(property="bom_process_groups", type="array",
|
||||
*
|
||||
* @OA\Items(type="object",
|
||||
*
|
||||
* @OA\Property(property="process_name", type="string"),
|
||||
* @OA\Property(property="size_spec", type="string", nullable=true),
|
||||
* @OA\Property(property="items", type="array",
|
||||
*
|
||||
* @OA\Items(type="object",
|
||||
*
|
||||
* @OA\Property(property="id", type="integer", nullable=true),
|
||||
* @OA\Property(property="item_code", type="string"),
|
||||
* @OA\Property(property="item_name", type="string"),
|
||||
* @OA\Property(property="spec", type="string"),
|
||||
* @OA\Property(property="lot_no", type="string"),
|
||||
* @OA\Property(property="required_qty", type="number"),
|
||||
* @OA\Property(property="qty", type="number")
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
*/
|
||||
class ProductionOrderApi
|
||||
{
|
||||
/**
|
||||
* @OA\Get(
|
||||
* path="/api/v1/production-orders",
|
||||
* tags={"ProductionOrders"},
|
||||
* summary="생산지시 목록 조회",
|
||||
* security={{"ApiKeyAuth": {}}, {"BearerAuth": {}}},
|
||||
*
|
||||
* @OA\Parameter(name="search", in="query", required=false,
|
||||
*
|
||||
* @OA\Schema(type="string"), description="검색어 (수주번호, 거래처명, 현장명)"
|
||||
* ),
|
||||
*
|
||||
* @OA\Parameter(name="production_status", in="query", required=false,
|
||||
*
|
||||
* @OA\Schema(type="string", enum={"waiting","in_production","completed"}), description="생산 상태 필터"
|
||||
* ),
|
||||
*
|
||||
* @OA\Parameter(name="sort_by", in="query", required=false,
|
||||
*
|
||||
* @OA\Schema(type="string", enum={"created_at","delivery_date","order_no"}), description="정렬 기준"
|
||||
* ),
|
||||
*
|
||||
* @OA\Parameter(name="sort_dir", in="query", required=false,
|
||||
*
|
||||
* @OA\Schema(type="string", enum={"asc","desc"}), description="정렬 방향"
|
||||
* ),
|
||||
*
|
||||
* @OA\Parameter(name="page", in="query", required=false, @OA\Schema(type="integer")),
|
||||
* @OA\Parameter(name="per_page", in="query", required=false, @OA\Schema(type="integer")),
|
||||
*
|
||||
* @OA\Response(response=200, description="성공",
|
||||
*
|
||||
* @OA\JsonContent(
|
||||
*
|
||||
* @OA\Property(property="success", type="boolean", example=true),
|
||||
* @OA\Property(property="message", type="string"),
|
||||
* @OA\Property(property="data", type="object",
|
||||
* @OA\Property(property="data", type="array", @OA\Items(ref="#/components/schemas/ProductionOrderListItem")),
|
||||
* @OA\Property(property="current_page", type="integer"),
|
||||
* @OA\Property(property="last_page", type="integer"),
|
||||
* @OA\Property(property="per_page", type="integer"),
|
||||
* @OA\Property(property="total", type="integer")
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
*/
|
||||
public function index() {}
|
||||
|
||||
/**
|
||||
* @OA\Get(
|
||||
* path="/api/v1/production-orders/stats",
|
||||
* tags={"ProductionOrders"},
|
||||
* summary="생산지시 상태별 통계",
|
||||
* security={{"ApiKeyAuth": {}}, {"BearerAuth": {}}},
|
||||
*
|
||||
* @OA\Response(response=200, description="성공",
|
||||
*
|
||||
* @OA\JsonContent(
|
||||
*
|
||||
* @OA\Property(property="success", type="boolean", example=true),
|
||||
* @OA\Property(property="message", type="string"),
|
||||
* @OA\Property(property="data", ref="#/components/schemas/ProductionOrderStats")
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
*/
|
||||
public function stats() {}
|
||||
|
||||
/**
|
||||
* @OA\Get(
|
||||
* path="/api/v1/production-orders/{orderId}",
|
||||
* tags={"ProductionOrders"},
|
||||
* summary="생산지시 상세 조회",
|
||||
* security={{"ApiKeyAuth": {}}, {"BearerAuth": {}}},
|
||||
*
|
||||
* @OA\Parameter(name="orderId", in="path", required=true, @OA\Schema(type="integer"), description="수주 ID"),
|
||||
*
|
||||
* @OA\Response(response=200, description="성공",
|
||||
*
|
||||
* @OA\JsonContent(
|
||||
*
|
||||
* @OA\Property(property="success", type="boolean", example=true),
|
||||
* @OA\Property(property="message", type="string"),
|
||||
* @OA\Property(property="data", ref="#/components/schemas/ProductionOrderDetail")
|
||||
* )
|
||||
* ),
|
||||
*
|
||||
* @OA\Response(response=404, description="생산지시를 찾을 수 없음")
|
||||
* )
|
||||
*/
|
||||
public function show() {}
|
||||
}
|
||||
98
app/Traits/SyncsExpenseAccounts.php
Normal file
98
app/Traits/SyncsExpenseAccounts.php
Normal file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
namespace App\Traits;
|
||||
|
||||
use App\Models\Tenants\ExpenseAccount;
|
||||
use App\Models\Tenants\JournalEntry;
|
||||
|
||||
/**
|
||||
* 전표 저장/수정/삭제 시 expense_accounts 동기화 (복리후생비/접대비 → CEO 대시보드)
|
||||
*
|
||||
* 사용처: GeneralJournalEntryService, JournalSyncService
|
||||
*/
|
||||
trait SyncsExpenseAccounts
|
||||
{
|
||||
/**
|
||||
* 계정과목명 → expense_accounts account_type 매핑
|
||||
*/
|
||||
private static array $expenseAccountMap = [
|
||||
'복리후생비' => ExpenseAccount::TYPE_WELFARE,
|
||||
'접대비' => ExpenseAccount::TYPE_ENTERTAINMENT,
|
||||
];
|
||||
|
||||
/**
|
||||
* 전표 저장/수정 후 expense_accounts 동기화
|
||||
* 복리후생비/접대비 계정과목이 포함된 lines → expense_accounts에 반영
|
||||
*/
|
||||
protected function syncExpenseAccounts(JournalEntry $entry): void
|
||||
{
|
||||
$tenantId = $entry->tenant_id;
|
||||
|
||||
// 1. 기존 이 전표에서 생성된 expense_accounts 삭제
|
||||
ExpenseAccount::where('tenant_id', $tenantId)
|
||||
->where('journal_entry_id', $entry->id)
|
||||
->forceDelete();
|
||||
|
||||
// 2. 현재 lines 중 복리후생비/접대비 해당하는 것만 insert
|
||||
$lines = $entry->lines()->get();
|
||||
|
||||
foreach ($lines as $line) {
|
||||
$accountType = $this->getExpenseAccountType($line->account_name);
|
||||
if (! $accountType) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 차변(debit)이 대변보다 큰 경우만 비용 발생으로 처리
|
||||
$amount = $line->debit_amount - $line->credit_amount;
|
||||
if ($amount <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// source_type에 따라 payment_method 결정
|
||||
$paymentMethod = match ($entry->source_type) {
|
||||
JournalEntry::SOURCE_CARD_TRANSACTION => ExpenseAccount::PAYMENT_CARD,
|
||||
default => ExpenseAccount::PAYMENT_TRANSFER,
|
||||
};
|
||||
|
||||
ExpenseAccount::create([
|
||||
'tenant_id' => $tenantId,
|
||||
'account_type' => $accountType,
|
||||
'sub_type' => null,
|
||||
'expense_date' => $entry->entry_date,
|
||||
'amount' => $amount,
|
||||
'description' => $line->description ?? $entry->description,
|
||||
'receipt_no' => null,
|
||||
'vendor_id' => $line->trading_partner_id,
|
||||
'vendor_name' => $line->trading_partner_name,
|
||||
'payment_method' => $paymentMethod,
|
||||
'card_no' => null,
|
||||
'journal_entry_id' => $entry->id,
|
||||
'journal_entry_line_id' => $line->id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 전표 삭제 시 expense_accounts 정리
|
||||
*/
|
||||
protected function cleanupExpenseAccounts(int $tenantId, int $entryId): void
|
||||
{
|
||||
ExpenseAccount::where('tenant_id', $tenantId)
|
||||
->where('journal_entry_id', $entryId)
|
||||
->forceDelete();
|
||||
}
|
||||
|
||||
/**
|
||||
* 계정과목명에서 비용 유형 판별
|
||||
*/
|
||||
private function getExpenseAccountType(string $accountName): ?string
|
||||
{
|
||||
foreach (self::$expenseAccountMap as $keyword => $type) {
|
||||
if (str_contains($accountName, $keyword)) {
|
||||
return $type;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -67,6 +67,7 @@
|
||||
|
||||
'daily' => [
|
||||
'driver' => 'daily',
|
||||
'permission' => 0664,
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'days' => env('LOG_DAILY_DAYS', 14),
|
||||
@@ -138,6 +139,7 @@
|
||||
*/
|
||||
'api' => [
|
||||
'driver' => 'daily',
|
||||
'permission' => 0664,
|
||||
'path' => storage_path('logs/api/api.log'),
|
||||
'level' => 'info',
|
||||
'days' => env('API_LOG_DAYS', 14),
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('quality_documents', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('tenant_id')->constrained();
|
||||
$table->string('quality_doc_number', 30)->comment('품질관리서 번호');
|
||||
$table->string('site_name')->comment('현장명');
|
||||
$table->string('status', 20)->default('received')->comment('received/in_progress/completed');
|
||||
$table->foreignId('client_id')->nullable()->constrained('clients')->comment('수주처');
|
||||
$table->foreignId('inspector_id')->nullable()->constrained('users')->comment('검사자');
|
||||
$table->date('received_date')->nullable()->comment('접수일');
|
||||
$table->json('options')->nullable()->comment('관련자정보, 검사정보, 현장주소 등');
|
||||
$table->unsignedBigInteger('created_by')->nullable();
|
||||
$table->unsignedBigInteger('updated_by')->nullable();
|
||||
$table->unsignedBigInteger('deleted_by')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->unique(['tenant_id', 'quality_doc_number']);
|
||||
$table->index(['tenant_id', 'status']);
|
||||
$table->index(['tenant_id', 'client_id']);
|
||||
$table->index(['tenant_id', 'inspector_id']);
|
||||
$table->index(['tenant_id', 'received_date']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('quality_documents');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('quality_document_orders', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('quality_document_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('order_id')->constrained('orders');
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['quality_document_id', 'order_id']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('quality_document_orders');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('quality_document_locations', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('quality_document_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('quality_document_order_id')->constrained('quality_document_orders', 'id', 'qdl_qdo_id_fk')->cascadeOnDelete();
|
||||
$table->foreignId('order_item_id')->constrained('order_items');
|
||||
$table->integer('post_width')->nullable()->comment('시공후 가로');
|
||||
$table->integer('post_height')->nullable()->comment('시공후 세로');
|
||||
$table->string('change_reason')->nullable()->comment('규격 변경사유');
|
||||
$table->foreignId('document_id')->nullable()->comment('검사성적서 문서 ID');
|
||||
$table->string('inspection_status', 20)->default('pending')->comment('pending/completed');
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['quality_document_id', 'inspection_status'], 'qdl_doc_id_status_index');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('quality_document_locations');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('performance_reports', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('tenant_id')->constrained();
|
||||
$table->foreignId('quality_document_id')->constrained();
|
||||
$table->unsignedSmallInteger('year')->comment('연도');
|
||||
$table->unsignedTinyInteger('quarter')->comment('분기 1-4');
|
||||
$table->string('confirmation_status', 20)->default('unconfirmed')->comment('unconfirmed/confirmed/reported');
|
||||
$table->date('confirmed_date')->nullable();
|
||||
$table->foreignId('confirmed_by')->nullable()->constrained('users');
|
||||
$table->text('memo')->nullable();
|
||||
$table->unsignedBigInteger('created_by')->nullable();
|
||||
$table->unsignedBigInteger('updated_by')->nullable();
|
||||
$table->unsignedBigInteger('deleted_by')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->unique(['tenant_id', 'quality_document_id']);
|
||||
$table->index(['tenant_id', 'year', 'quarter']);
|
||||
$table->index(['tenant_id', 'confirmation_status']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('performance_reports');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('quality_document_locations', function (Blueprint $table) {
|
||||
$table->json('inspection_data')->nullable()->after('change_reason')->comment('검사 데이터 JSON');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('quality_document_locations', function (Blueprint $table) {
|
||||
$table->dropColumn('inspection_data');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('expense_accounts', function (Blueprint $table) {
|
||||
$table->unsignedBigInteger('journal_entry_id')->nullable()->after('loan_id');
|
||||
$table->unsignedBigInteger('journal_entry_line_id')->nullable()->after('journal_entry_id');
|
||||
|
||||
$table->index(['tenant_id', 'journal_entry_id']);
|
||||
$table->index(['journal_entry_line_id']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('expense_accounts', function (Blueprint $table) {
|
||||
$table->dropIndex(['tenant_id', 'journal_entry_id']);
|
||||
$table->dropIndex(['journal_entry_line_id']);
|
||||
$table->dropColumn(['journal_entry_id', 'journal_entry_line_id']);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('document_template_sections', function (Blueprint $table) {
|
||||
$table->text('description')->nullable()->after('title')->comment('섹션 설명/안내문');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('document_template_sections', function (Blueprint $table) {
|
||||
$table->dropColumn('description');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* 계정과목 마스터 확장
|
||||
*
|
||||
* - sub_category: 중분류 (유동자산, 판관비, 매출원가 등)
|
||||
* - parent_code: 상위 계정과목 코드 (계층 구조)
|
||||
* - depth: 계층 깊이 (1=대, 2=중, 3=소)
|
||||
* - department_type: 부문 (common=공통, manufacturing=제조, admin=관리)
|
||||
* - description: 계정과목 설명
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('account_codes', function (Blueprint $table) {
|
||||
$table->string('sub_category', 50)->nullable()->after('category')
|
||||
->comment('중분류 (current_asset, fixed_asset, selling_admin, cogs 등)');
|
||||
$table->string('parent_code', 10)->nullable()->after('sub_category')
|
||||
->comment('상위 계정과목 코드 (계층 구조)');
|
||||
$table->tinyInteger('depth')->default(3)->after('parent_code')
|
||||
->comment('계층 깊이 (1=대분류, 2=중분류, 3=소분류)');
|
||||
$table->string('department_type', 20)->default('common')->after('depth')
|
||||
->comment('부문 (common=공통, manufacturing=제조, admin=관리)');
|
||||
$table->string('description', 500)->nullable()->after('department_type')
|
||||
->comment('계정과목 설명');
|
||||
|
||||
$table->index(['tenant_id', 'category'], 'account_codes_tenant_category_idx');
|
||||
$table->index(['tenant_id', 'parent_code'], 'account_codes_tenant_parent_idx');
|
||||
$table->index(['tenant_id', 'depth'], 'account_codes_tenant_depth_idx');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('account_codes', function (Blueprint $table) {
|
||||
$table->dropIndex('account_codes_tenant_category_idx');
|
||||
$table->dropIndex('account_codes_tenant_parent_idx');
|
||||
$table->dropIndex('account_codes_tenant_depth_idx');
|
||||
|
||||
$table->dropColumn([
|
||||
'sub_category',
|
||||
'parent_code',
|
||||
'depth',
|
||||
'department_type',
|
||||
'description',
|
||||
]);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,218 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/**
|
||||
* 모든 기존 테넌트에 더존 Smart A 표준 계정과목 128건 자동 시드
|
||||
*
|
||||
* 조건: tenant_id + code 중복 시 skip (기존 데이터 보호)
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
$tenantIds = DB::table('tenants')
|
||||
->whereNull('deleted_at')
|
||||
->pluck('id');
|
||||
|
||||
$defaults = $this->getDefaultAccountCodes();
|
||||
$now = now();
|
||||
|
||||
foreach ($tenantIds as $tenantId) {
|
||||
// 이미 등록된 코드 조회
|
||||
$existingCodes = DB::table('account_codes')
|
||||
->where('tenant_id', $tenantId)
|
||||
->pluck('code')
|
||||
->toArray();
|
||||
|
||||
$inserts = [];
|
||||
foreach ($defaults as $item) {
|
||||
if (! in_array($item['code'], $existingCodes)) {
|
||||
$inserts[] = array_merge($item, [
|
||||
'tenant_id' => $tenantId,
|
||||
'is_active' => true,
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($inserts)) {
|
||||
// 500건 단위 청크 insert
|
||||
foreach (array_chunk($inserts, 500) as $chunk) {
|
||||
DB::table('account_codes')->insert($chunk);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
// 시드 데이터만 롤백 (수동 추가 데이터는 보호)
|
||||
$defaultCodes = array_column($this->getDefaultAccountCodes(), 'code');
|
||||
|
||||
DB::table('account_codes')
|
||||
->whereIn('code', $defaultCodes)
|
||||
->delete();
|
||||
}
|
||||
|
||||
private function getDefaultAccountCodes(): array
|
||||
{
|
||||
$c = fn ($code, $name, $cat, $sub, $parent, $depth, $dept, $sort) => [
|
||||
'code' => $code, 'name' => $name, 'category' => $cat,
|
||||
'sub_category' => $sub, 'parent_code' => $parent,
|
||||
'depth' => $depth, 'department_type' => $dept, 'sort_order' => $sort,
|
||||
];
|
||||
|
||||
return [
|
||||
// 자산 (Assets)
|
||||
$c('1', '자산', 'asset', null, null, 1, 'common', 100),
|
||||
$c('11', '유동자산', 'asset', 'current_asset', '1', 2, 'common', 110),
|
||||
$c('10100', '현금', 'asset', 'current_asset', '11', 3, 'common', 1010),
|
||||
$c('10200', '당좌예금', 'asset', 'current_asset', '11', 3, 'common', 1020),
|
||||
$c('10300', '보통예금', 'asset', 'current_asset', '11', 3, 'common', 1030),
|
||||
$c('10400', '기타제예금', 'asset', 'current_asset', '11', 3, 'common', 1040),
|
||||
$c('10500', '정기적금', 'asset', 'current_asset', '11', 3, 'common', 1050),
|
||||
$c('10800', '외상매출금', 'asset', 'current_asset', '11', 3, 'common', 1080),
|
||||
$c('10900', '대손충당금(외상매출금)', 'asset', 'current_asset', '11', 3, 'common', 1090),
|
||||
$c('11000', '받을어음', 'asset', 'current_asset', '11', 3, 'common', 1100),
|
||||
$c('11400', '단기대여금', 'asset', 'current_asset', '11', 3, 'common', 1140),
|
||||
$c('11600', '미수수익', 'asset', 'current_asset', '11', 3, 'common', 1160),
|
||||
$c('12000', '미수금', 'asset', 'current_asset', '11', 3, 'common', 1200),
|
||||
$c('12200', '소모품', 'asset', 'current_asset', '11', 3, 'common', 1220),
|
||||
$c('12500', '미환급세금', 'asset', 'current_asset', '11', 3, 'common', 1250),
|
||||
$c('13100', '선급금', 'asset', 'current_asset', '11', 3, 'common', 1310),
|
||||
$c('13300', '선급비용', 'asset', 'current_asset', '11', 3, 'common', 1330),
|
||||
$c('13400', '가지급금', 'asset', 'current_asset', '11', 3, 'common', 1340),
|
||||
$c('13500', '부가세대급금', 'asset', 'current_asset', '11', 3, 'common', 1350),
|
||||
$c('13600', '선납세금', 'asset', 'current_asset', '11', 3, 'common', 1360),
|
||||
$c('14000', '선납법인세', 'asset', 'current_asset', '11', 3, 'common', 1400),
|
||||
$c('12', '재고자산', 'asset', 'current_asset', '1', 2, 'common', 120),
|
||||
$c('14600', '상품', 'asset', 'current_asset', '12', 3, 'common', 1460),
|
||||
$c('15000', '제품', 'asset', 'current_asset', '12', 3, 'common', 1500),
|
||||
$c('15300', '원재료', 'asset', 'current_asset', '12', 3, 'common', 1530),
|
||||
$c('16200', '부재료', 'asset', 'current_asset', '12', 3, 'common', 1620),
|
||||
$c('16700', '저장품', 'asset', 'current_asset', '12', 3, 'common', 1670),
|
||||
$c('16900', '재공품', 'asset', 'current_asset', '12', 3, 'common', 1690),
|
||||
$c('13', '비유동자산', 'asset', 'fixed_asset', '1', 2, 'common', 130),
|
||||
$c('17600', '장기성예금', 'asset', 'fixed_asset', '13', 3, 'common', 1760),
|
||||
$c('17900', '장기대여금', 'asset', 'fixed_asset', '13', 3, 'common', 1790),
|
||||
$c('18700', '투자부동산', 'asset', 'fixed_asset', '13', 3, 'common', 1870),
|
||||
$c('19200', '단체퇴직보험예치금', 'asset', 'fixed_asset', '13', 3, 'common', 1920),
|
||||
$c('20100', '토지', 'asset', 'fixed_asset', '13', 3, 'common', 2010),
|
||||
$c('20200', '건물', 'asset', 'fixed_asset', '13', 3, 'common', 2020),
|
||||
$c('20300', '감가상각누계액(건물)', 'asset', 'fixed_asset', '13', 3, 'common', 2030),
|
||||
$c('20400', '구축물', 'asset', 'fixed_asset', '13', 3, 'common', 2040),
|
||||
$c('20500', '감가상각누계액(구축물)', 'asset', 'fixed_asset', '13', 3, 'common', 2050),
|
||||
$c('20600', '기계장치', 'asset', 'fixed_asset', '13', 3, 'common', 2060),
|
||||
$c('20700', '감가상각누계액(기계장치)', 'asset', 'fixed_asset', '13', 3, 'common', 2070),
|
||||
$c('20800', '차량운반구', 'asset', 'fixed_asset', '13', 3, 'common', 2080),
|
||||
$c('20900', '감가상각누계액(차량운반구)', 'asset', 'fixed_asset', '13', 3, 'common', 2090),
|
||||
$c('21000', '공구와기구', 'asset', 'fixed_asset', '13', 3, 'common', 2100),
|
||||
$c('21200', '비품', 'asset', 'fixed_asset', '13', 3, 'common', 2120),
|
||||
$c('21300', '건설중인자산', 'asset', 'fixed_asset', '13', 3, 'common', 2130),
|
||||
$c('24000', '소프트웨어', 'asset', 'fixed_asset', '13', 3, 'common', 2400),
|
||||
// 부채 (Liabilities)
|
||||
$c('2', '부채', 'liability', null, null, 1, 'common', 200),
|
||||
$c('21', '유동부채', 'liability', 'current_liability', '2', 2, 'common', 210),
|
||||
$c('25100', '외상매입금', 'liability', 'current_liability', '21', 3, 'common', 2510),
|
||||
$c('25200', '지급어음', 'liability', 'current_liability', '21', 3, 'common', 2520),
|
||||
$c('25300', '미지급금', 'liability', 'current_liability', '21', 3, 'common', 2530),
|
||||
$c('25400', '예수금', 'liability', 'current_liability', '21', 3, 'common', 2540),
|
||||
$c('25500', '부가세예수금', 'liability', 'current_liability', '21', 3, 'common', 2550),
|
||||
$c('25900', '선수금', 'liability', 'current_liability', '21', 3, 'common', 2590),
|
||||
$c('26000', '단기차입금', 'liability', 'current_liability', '21', 3, 'common', 2600),
|
||||
$c('26100', '미지급세금', 'liability', 'current_liability', '21', 3, 'common', 2610),
|
||||
$c('26200', '미지급비용', 'liability', 'current_liability', '21', 3, 'common', 2620),
|
||||
$c('26400', '유동성장기차입금', 'liability', 'current_liability', '21', 3, 'common', 2640),
|
||||
$c('26500', '미지급배당금', 'liability', 'current_liability', '21', 3, 'common', 2650),
|
||||
$c('22', '비유동부채', 'liability', 'long_term_liability', '2', 2, 'common', 220),
|
||||
$c('29300', '장기차입금', 'liability', 'long_term_liability', '22', 3, 'common', 2930),
|
||||
$c('29400', '임대보증금', 'liability', 'long_term_liability', '22', 3, 'common', 2940),
|
||||
$c('29500', '퇴직급여충당부채', 'liability', 'long_term_liability', '22', 3, 'common', 2950),
|
||||
$c('30700', '장기임대보증금', 'liability', 'long_term_liability', '22', 3, 'common', 3070),
|
||||
// 자본 (Capital)
|
||||
$c('3', '자본', 'capital', null, null, 1, 'common', 300),
|
||||
$c('31', '자본금', 'capital', 'capital', '3', 2, 'common', 310),
|
||||
$c('33100', '자본금', 'capital', 'capital', '31', 3, 'common', 3310),
|
||||
$c('33200', '우선주자본금', 'capital', 'capital', '31', 3, 'common', 3320),
|
||||
$c('32', '잉여금', 'capital', 'capital', '3', 2, 'common', 320),
|
||||
$c('34100', '주식발행초과금', 'capital', 'capital', '32', 3, 'common', 3410),
|
||||
$c('35100', '이익준비금', 'capital', 'capital', '32', 3, 'common', 3510),
|
||||
$c('37500', '이월이익잉여금', 'capital', 'capital', '32', 3, 'common', 3750),
|
||||
$c('37900', '당기순이익', 'capital', 'capital', '32', 3, 'common', 3790),
|
||||
// 수익 (Revenue)
|
||||
$c('4', '수익', 'revenue', null, null, 1, 'common', 400),
|
||||
$c('41', '매출', 'revenue', 'sales_revenue', '4', 2, 'common', 410),
|
||||
$c('40100', '상품매출', 'revenue', 'sales_revenue', '41', 3, 'common', 4010),
|
||||
$c('40400', '제품매출', 'revenue', 'sales_revenue', '41', 3, 'common', 4040),
|
||||
$c('40700', '공사수입금', 'revenue', 'sales_revenue', '41', 3, 'common', 4070),
|
||||
$c('41000', '임대료수입', 'revenue', 'sales_revenue', '41', 3, 'common', 4100),
|
||||
$c('42', '영업외수익', 'revenue', 'other_revenue', '4', 2, 'common', 420),
|
||||
$c('90100', '이자수익', 'revenue', 'other_revenue', '42', 3, 'common', 9010),
|
||||
$c('90300', '배당금수익', 'revenue', 'other_revenue', '42', 3, 'common', 9030),
|
||||
$c('90400', '수입임대료', 'revenue', 'other_revenue', '42', 3, 'common', 9040),
|
||||
$c('90700', '외환차익', 'revenue', 'other_revenue', '42', 3, 'common', 9070),
|
||||
$c('93000', '잡이익', 'revenue', 'other_revenue', '42', 3, 'common', 9300),
|
||||
// 비용 (Expenses)
|
||||
$c('5', '비용', 'expense', null, null, 1, 'common', 500),
|
||||
$c('51', '매출원가', 'expense', 'cogs', '5', 2, 'manufacturing', 510),
|
||||
$c('50100', '원재료비', 'expense', 'cogs', '51', 3, 'manufacturing', 5010),
|
||||
$c('50200', '외주가공비', 'expense', 'cogs', '51', 3, 'manufacturing', 5020),
|
||||
$c('50300', '급여(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5030),
|
||||
$c('50400', '임금', 'expense', 'cogs', '51', 3, 'manufacturing', 5040),
|
||||
$c('50500', '상여금(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5050),
|
||||
$c('50800', '퇴직급여(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5080),
|
||||
$c('51100', '복리후생비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5110),
|
||||
$c('51200', '여비교통비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5120),
|
||||
$c('51300', '접대비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5130),
|
||||
$c('51400', '통신비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5140),
|
||||
$c('51600', '전력비', 'expense', 'cogs', '51', 3, 'manufacturing', 5160),
|
||||
$c('51700', '세금과공과금(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5170),
|
||||
$c('51800', '감가상각비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5180),
|
||||
$c('51900', '지급임차료(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5190),
|
||||
$c('52000', '수선비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5200),
|
||||
$c('52100', '보험료(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5210),
|
||||
$c('52200', '차량유지비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5220),
|
||||
$c('52400', '운반비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5240),
|
||||
$c('53000', '소모품비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5300),
|
||||
$c('53100', '지급수수료(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5310),
|
||||
$c('52', '판매비와관리비', 'expense', 'selling_admin', '5', 2, 'admin', 520),
|
||||
$c('80100', '임원급여', 'expense', 'selling_admin', '52', 3, 'admin', 8010),
|
||||
$c('80200', '직원급여', 'expense', 'selling_admin', '52', 3, 'admin', 8020),
|
||||
$c('80300', '상여금', 'expense', 'selling_admin', '52', 3, 'admin', 8030),
|
||||
$c('80600', '퇴직급여', 'expense', 'selling_admin', '52', 3, 'admin', 8060),
|
||||
$c('81100', '복리후생비', 'expense', 'selling_admin', '52', 3, 'admin', 8110),
|
||||
$c('81200', '여비교통비', 'expense', 'selling_admin', '52', 3, 'admin', 8120),
|
||||
$c('81300', '접대비', 'expense', 'selling_admin', '52', 3, 'admin', 8130),
|
||||
$c('81400', '통신비', 'expense', 'selling_admin', '52', 3, 'admin', 8140),
|
||||
$c('81500', '수도광열비', 'expense', 'selling_admin', '52', 3, 'admin', 8150),
|
||||
$c('81700', '세금과공과금', 'expense', 'selling_admin', '52', 3, 'admin', 8170),
|
||||
$c('81800', '감가상각비', 'expense', 'selling_admin', '52', 3, 'admin', 8180),
|
||||
$c('81900', '지급임차료', 'expense', 'selling_admin', '52', 3, 'admin', 8190),
|
||||
$c('82000', '수선비', 'expense', 'selling_admin', '52', 3, 'admin', 8200),
|
||||
$c('82100', '보험료', 'expense', 'selling_admin', '52', 3, 'admin', 8210),
|
||||
$c('82200', '차량유지비', 'expense', 'selling_admin', '52', 3, 'admin', 8220),
|
||||
$c('82300', '경상연구개발비', 'expense', 'selling_admin', '52', 3, 'admin', 8230),
|
||||
$c('82400', '운반비', 'expense', 'selling_admin', '52', 3, 'admin', 8240),
|
||||
$c('82500', '교육훈련비', 'expense', 'selling_admin', '52', 3, 'admin', 8250),
|
||||
$c('82600', '도서인쇄비', 'expense', 'selling_admin', '52', 3, 'admin', 8260),
|
||||
$c('82700', '회의비', 'expense', 'selling_admin', '52', 3, 'admin', 8270),
|
||||
$c('82900', '사무용품비', 'expense', 'selling_admin', '52', 3, 'admin', 8290),
|
||||
$c('83000', '소모품비', 'expense', 'selling_admin', '52', 3, 'admin', 8300),
|
||||
$c('83100', '지급수수료', 'expense', 'selling_admin', '52', 3, 'admin', 8310),
|
||||
$c('83200', '보관료', 'expense', 'selling_admin', '52', 3, 'admin', 8320),
|
||||
$c('83300', '광고선전비', 'expense', 'selling_admin', '52', 3, 'admin', 8330),
|
||||
$c('83500', '대손상각비', 'expense', 'selling_admin', '52', 3, 'admin', 8350),
|
||||
$c('84800', '잡비', 'expense', 'selling_admin', '52', 3, 'admin', 8480),
|
||||
$c('53', '영업외비용', 'expense', 'other_expense', '5', 2, 'common', 530),
|
||||
$c('93100', '이자비용', 'expense', 'other_expense', '53', 3, 'common', 9310),
|
||||
$c('93200', '외환차손', 'expense', 'other_expense', '53', 3, 'common', 9320),
|
||||
$c('93300', '기부금', 'expense', 'other_expense', '53', 3, 'common', 9330),
|
||||
$c('96000', '잡손실', 'expense', 'other_expense', '53', 3, 'common', 9600),
|
||||
$c('99800', '법인세', 'expense', 'other_expense', '53', 3, 'common', 9980),
|
||||
$c('99900', '소득세등', 'expense', 'other_expense', '53', 3, 'common', 9990),
|
||||
];
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,467 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/**
|
||||
* 더존 Smart A 표준 계정과목 추가 시드 — 기획서 14장 기준 누락분 보완
|
||||
*
|
||||
* 조건: tenant_id + code 중복 시 skip (기존 데이터 보호)
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
$tenantIds = DB::table('tenants')
|
||||
->whereNull('deleted_at')
|
||||
->pluck('id');
|
||||
|
||||
$defaults = $this->getAdditionalAccountCodes();
|
||||
$now = now();
|
||||
|
||||
foreach ($tenantIds as $tenantId) {
|
||||
$existingCodes = DB::table('account_codes')
|
||||
->where('tenant_id', $tenantId)
|
||||
->pluck('code')
|
||||
->toArray();
|
||||
|
||||
$inserts = [];
|
||||
foreach ($defaults as $item) {
|
||||
if (! in_array($item['code'], $existingCodes)) {
|
||||
$inserts[] = array_merge($item, [
|
||||
'tenant_id' => $tenantId,
|
||||
'is_active' => true,
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($inserts)) {
|
||||
foreach (array_chunk($inserts, 500) as $chunk) {
|
||||
DB::table('account_codes')->insert($chunk);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
$codes = array_column($this->getAdditionalAccountCodes(), 'code');
|
||||
DB::table('account_codes')->whereIn('code', $codes)->delete();
|
||||
}
|
||||
|
||||
private function getAdditionalAccountCodes(): array
|
||||
{
|
||||
$c = fn ($code, $name, $cat, $sub, $parent, $depth, $dept, $sort) => [
|
||||
'code' => $code, 'name' => $name, 'category' => $cat,
|
||||
'sub_category' => $sub, 'parent_code' => $parent,
|
||||
'depth' => $depth, 'department_type' => $dept, 'sort_order' => $sort,
|
||||
];
|
||||
|
||||
return [
|
||||
// ================================================================
|
||||
// 새 depth-2 카테고리
|
||||
// ================================================================
|
||||
$c('33', '자본조정', 'capital', 'capital_adjustment', '3', 2, 'common', 330),
|
||||
$c('54', '건설원가', 'expense', 'construction_cost', '5', 2, 'construction', 540),
|
||||
|
||||
// ================================================================
|
||||
// 자산 — 유동자산 추가 (parent: '11')
|
||||
// ================================================================
|
||||
$c('10600', '기타단기금융상품예금', 'asset', 'current_asset', '11', 3, 'common', 1060),
|
||||
$c('10700', '단기투자자산', 'asset', 'current_asset', '11', 3, 'common', 1070),
|
||||
$c('11100', '대손충당금(받을어음)', 'asset', 'current_asset', '11', 3, 'common', 1110),
|
||||
$c('11200', '공사미수금', 'asset', 'current_asset', '11', 3, 'common', 1120),
|
||||
$c('11300', '대손충당금(공사미수금)', 'asset', 'current_asset', '11', 3, 'common', 1130),
|
||||
$c('11500', '대손충당금(단기대여금)', 'asset', 'current_asset', '11', 3, 'common', 1150),
|
||||
$c('11700', '대손충당금(미수수익)', 'asset', 'current_asset', '11', 3, 'common', 1170),
|
||||
$c('11800', '분양미수금', 'asset', 'current_asset', '11', 3, 'common', 1180),
|
||||
$c('11900', '대손충당금(분양미수금)', 'asset', 'current_asset', '11', 3, 'common', 1190),
|
||||
$c('12100', '대손충당금(미수금)', 'asset', 'current_asset', '11', 3, 'common', 1210),
|
||||
$c('12300', '매도가능증권', 'asset', 'current_asset', '11', 3, 'common', 1230),
|
||||
$c('12400', '만기보유증권', 'asset', 'current_asset', '11', 3, 'common', 1240),
|
||||
$c('13200', '대손충당금(선급금)', 'asset', 'current_asset', '11', 3, 'common', 1320),
|
||||
$c('13700', '주임종단기채권', 'asset', 'current_asset', '11', 3, 'common', 1370),
|
||||
$c('13800', '전도금', 'asset', 'current_asset', '11', 3, 'common', 1380),
|
||||
$c('13900', '선급공사비', 'asset', 'current_asset', '11', 3, 'common', 1390),
|
||||
|
||||
// ================================================================
|
||||
// 자산 — 재고자산 추가 (parent: '12')
|
||||
// ================================================================
|
||||
$c('14700', '매입환출및에누리(상품)', 'asset', 'current_asset', '12', 3, 'common', 1470),
|
||||
$c('14800', '매입할인(상품)', 'asset', 'current_asset', '12', 3, 'common', 1480),
|
||||
$c('14900', '관세환급금(상품)', 'asset', 'current_asset', '12', 3, 'common', 1490),
|
||||
$c('15100', '관세환급금(제품)', 'asset', 'current_asset', '12', 3, 'common', 1510),
|
||||
$c('15200', '완성건물', 'asset', 'current_asset', '12', 3, 'common', 1520),
|
||||
$c('15400', '매입환출및에누리(원재료)', 'asset', 'current_asset', '12', 3, 'common', 1540),
|
||||
$c('15500', '매입할인(원재료)', 'asset', 'current_asset', '12', 3, 'common', 1550),
|
||||
$c('15600', '원재료(도급)', 'asset', 'current_asset', '12', 3, 'common', 1560),
|
||||
$c('15700', '매입환출및에누리(원재료-도급)', 'asset', 'current_asset', '12', 3, 'common', 1570),
|
||||
$c('15800', '매입할인(원재료-도급)', 'asset', 'current_asset', '12', 3, 'common', 1580),
|
||||
$c('15900', '원재료(분양)', 'asset', 'current_asset', '12', 3, 'common', 1590),
|
||||
$c('16000', '매입환출및에누리(원재료-분양)', 'asset', 'current_asset', '12', 3, 'common', 1600),
|
||||
$c('16100', '매입할인(원재료-분양)', 'asset', 'current_asset', '12', 3, 'common', 1610),
|
||||
$c('16300', '매입환출및에누리(부재료)', 'asset', 'current_asset', '12', 3, 'common', 1630),
|
||||
$c('16400', '매입할인(부재료)', 'asset', 'current_asset', '12', 3, 'common', 1640),
|
||||
$c('16500', '건설용지', 'asset', 'current_asset', '12', 3, 'common', 1650),
|
||||
$c('16600', '가설재', 'asset', 'current_asset', '12', 3, 'common', 1660),
|
||||
$c('16800', '미착품', 'asset', 'current_asset', '12', 3, 'common', 1680),
|
||||
$c('17000', '미완성공사(도급)', 'asset', 'current_asset', '12', 3, 'common', 1700),
|
||||
$c('17100', '미완성공사(분양)', 'asset', 'current_asset', '12', 3, 'common', 1710),
|
||||
|
||||
// ================================================================
|
||||
// 자산 — 비유동자산 추가 (parent: '13')
|
||||
// ================================================================
|
||||
$c('17700', '특정현금과예금', 'asset', 'fixed_asset', '13', 3, 'common', 1770),
|
||||
$c('17800', '장기투자증권', 'asset', 'fixed_asset', '13', 3, 'common', 1780),
|
||||
$c('18000', '대손충당금(장기대여금)', 'asset', 'fixed_asset', '13', 3, 'common', 1800),
|
||||
$c('18100', '만기보유증권(장기)', 'asset', 'fixed_asset', '13', 3, 'common', 1810),
|
||||
$c('18200', '지분법적용투자주식', 'asset', 'fixed_asset', '13', 3, 'common', 1820),
|
||||
$c('19100', '출자금', 'asset', 'fixed_asset', '13', 3, 'common', 1910),
|
||||
$c('19700', '투자임대계약자산', 'asset', 'fixed_asset', '13', 3, 'common', 1970),
|
||||
$c('19800', '출자금(장기)', 'asset', 'fixed_asset', '13', 3, 'common', 1980),
|
||||
$c('19900', '퇴직보험예치금', 'asset', 'fixed_asset', '13', 3, 'common', 1990),
|
||||
$c('20000', '국민연금전환금', 'asset', 'fixed_asset', '13', 3, 'common', 2000),
|
||||
$c('21100', '감가상각누계액(공구와기구)', 'asset', 'fixed_asset', '13', 3, 'common', 2110),
|
||||
$c('21400', '건설중인자산(임대)', 'asset', 'fixed_asset', '13', 3, 'common', 2140),
|
||||
$c('21500', '미착기계', 'asset', 'fixed_asset', '13', 3, 'common', 2150),
|
||||
$c('21600', '감가상각누계액(비품)', 'asset', 'fixed_asset', '13', 3, 'common', 2160),
|
||||
// 무형자산
|
||||
$c('23100', '영업권', 'asset', 'fixed_asset', '13', 3, 'common', 2310),
|
||||
$c('23200', '특허권', 'asset', 'fixed_asset', '13', 3, 'common', 2320),
|
||||
$c('23300', '상표권', 'asset', 'fixed_asset', '13', 3, 'common', 2330),
|
||||
$c('23400', '실용신안권', 'asset', 'fixed_asset', '13', 3, 'common', 2340),
|
||||
$c('23500', '의장권', 'asset', 'fixed_asset', '13', 3, 'common', 2350),
|
||||
$c('23600', '면허권', 'asset', 'fixed_asset', '13', 3, 'common', 2360),
|
||||
$c('23700', '광업권', 'asset', 'fixed_asset', '13', 3, 'common', 2370),
|
||||
$c('23800', '창업비', 'asset', 'fixed_asset', '13', 3, 'common', 2380),
|
||||
$c('23900', '개발비', 'asset', 'fixed_asset', '13', 3, 'common', 2390),
|
||||
// 기타비유동자산 (96xxx-97xxx)
|
||||
$c('96100', '이연법인세자산', 'asset', 'fixed_asset', '13', 3, 'common', 9610),
|
||||
$c('96200', '임차보증금', 'asset', 'fixed_asset', '13', 3, 'common', 9620),
|
||||
$c('96300', '전세금', 'asset', 'fixed_asset', '13', 3, 'common', 9630),
|
||||
$c('96400', '기타보증금', 'asset', 'fixed_asset', '13', 3, 'common', 9640),
|
||||
$c('96500', '장기외상매출금', 'asset', 'fixed_asset', '13', 3, 'common', 9650),
|
||||
$c('96600', '현재가치할인차금(장기외상매출금)', 'asset', 'fixed_asset', '13', 3, 'common', 9660),
|
||||
$c('96700', '대손충당금(장기외상매출금)', 'asset', 'fixed_asset', '13', 3, 'common', 9670),
|
||||
$c('96800', '장기받을어음', 'asset', 'fixed_asset', '13', 3, 'common', 9680),
|
||||
$c('96900', '현재가치할인차금(장기받을어음)', 'asset', 'fixed_asset', '13', 3, 'common', 9690),
|
||||
$c('97000', '대손충당금(장기받을어음)', 'asset', 'fixed_asset', '13', 3, 'common', 9700),
|
||||
$c('97100', '장기미수금', 'asset', 'fixed_asset', '13', 3, 'common', 9710),
|
||||
$c('97200', '현재가치할인차금(장기미수금)', 'asset', 'fixed_asset', '13', 3, 'common', 9720),
|
||||
$c('97300', '대손충당금(장기미수금)', 'asset', 'fixed_asset', '13', 3, 'common', 9730),
|
||||
$c('97400', '장기선급비용', 'asset', 'fixed_asset', '13', 3, 'common', 9740),
|
||||
$c('97500', '장기선급금', 'asset', 'fixed_asset', '13', 3, 'common', 9750),
|
||||
$c('97600', '부도어음과수표', 'asset', 'fixed_asset', '13', 3, 'common', 9760),
|
||||
$c('97700', '대손충당금(부도어음)', 'asset', 'fixed_asset', '13', 3, 'common', 9770),
|
||||
$c('97800', '전신전화가입권', 'asset', 'fixed_asset', '13', 3, 'common', 9780),
|
||||
|
||||
// ================================================================
|
||||
// 부채 — 유동부채 추가 (parent: '21')
|
||||
// ================================================================
|
||||
$c('25600', '당좌차월', 'liability', 'current_liability', '21', 3, 'common', 2560),
|
||||
$c('25700', '가수금', 'liability', 'current_liability', '21', 3, 'common', 2570),
|
||||
$c('25800', '예수보증금', 'liability', 'current_liability', '21', 3, 'common', 2580),
|
||||
$c('26300', '수입금', 'liability', 'current_liability', '21', 3, 'common', 2630),
|
||||
$c('26600', '지급보증채무', 'liability', 'current_liability', '21', 3, 'common', 2660),
|
||||
$c('26700', '수출금융', 'liability', 'current_liability', '21', 3, 'common', 2670),
|
||||
$c('26800', '수입금융', 'liability', 'current_liability', '21', 3, 'common', 2680),
|
||||
$c('26900', '공사손실충당금', 'liability', 'current_liability', '21', 3, 'common', 2690),
|
||||
$c('27000', '하자보수충당금', 'liability', 'current_liability', '21', 3, 'common', 2700),
|
||||
$c('27100', '공사선수금', 'liability', 'current_liability', '21', 3, 'common', 2710),
|
||||
$c('27200', '분양선수금', 'liability', 'current_liability', '21', 3, 'common', 2720),
|
||||
$c('27300', '이연법인세부채', 'liability', 'current_liability', '21', 3, 'common', 2730),
|
||||
|
||||
// ================================================================
|
||||
// 부채 — 비유동부채 추가 (parent: '22')
|
||||
// ================================================================
|
||||
$c('29100', '사채', 'liability', 'long_term_liability', '22', 3, 'common', 2910),
|
||||
$c('29200', '사채할인발행차금', 'liability', 'long_term_liability', '22', 3, 'common', 2920),
|
||||
$c('29600', '퇴직보험충당부채', 'liability', 'long_term_liability', '22', 3, 'common', 2960),
|
||||
$c('29700', '중소기업투자준비금', 'liability', 'long_term_liability', '22', 3, 'common', 2970),
|
||||
$c('29800', '기술개발준비금', 'liability', 'long_term_liability', '22', 3, 'common', 2980),
|
||||
$c('29900', '해외시장개척준비금', 'liability', 'long_term_liability', '22', 3, 'common', 2990),
|
||||
$c('30100', '지방이전준비금', 'liability', 'long_term_liability', '22', 3, 'common', 3010),
|
||||
$c('30200', '수출손실준비금', 'liability', 'long_term_liability', '22', 3, 'common', 3020),
|
||||
$c('30300', '주임종장기차입금', 'liability', 'long_term_liability', '22', 3, 'common', 3030),
|
||||
$c('30400', '관계회사장기차입금', 'liability', 'long_term_liability', '22', 3, 'common', 3040),
|
||||
$c('30500', '외화장기차입금', 'liability', 'long_term_liability', '22', 3, 'common', 3050),
|
||||
$c('30600', '공사선수금(장기)', 'liability', 'long_term_liability', '22', 3, 'common', 3060),
|
||||
$c('30800', '장기성지급어음', 'liability', 'long_term_liability', '22', 3, 'common', 3080),
|
||||
$c('30900', '환율조정대', 'liability', 'long_term_liability', '22', 3, 'common', 3090),
|
||||
$c('31000', '이연법인세대', 'liability', 'long_term_liability', '22', 3, 'common', 3100),
|
||||
$c('31100', '신주인수권부사채', 'liability', 'long_term_liability', '22', 3, 'common', 3110),
|
||||
$c('31200', '전환사채', 'liability', 'long_term_liability', '22', 3, 'common', 3120),
|
||||
$c('31300', '사채할증발행차금', 'liability', 'long_term_liability', '22', 3, 'common', 3130),
|
||||
$c('31400', '장기제품보증부채', 'liability', 'long_term_liability', '22', 3, 'common', 3140),
|
||||
|
||||
// ================================================================
|
||||
// 자본 — 잉여금 추가 (parent: '32')
|
||||
// ================================================================
|
||||
$c('34200', '감자차익', 'capital', 'capital', '32', 3, 'common', 3420),
|
||||
$c('34300', '자기주식처분이익', 'capital', 'capital', '32', 3, 'common', 3430),
|
||||
$c('34900', '기타자본잉여금', 'capital', 'capital', '32', 3, 'common', 3490),
|
||||
$c('35000', '재평가적립금', 'capital', 'capital', '32', 3, 'common', 3500),
|
||||
$c('35200', '기업합리화적립금', 'capital', 'capital', '32', 3, 'common', 3520),
|
||||
$c('35300', '법정적립금', 'capital', 'capital', '32', 3, 'common', 3530),
|
||||
$c('35400', '재무구조개선적립금', 'capital', 'capital', '32', 3, 'common', 3540),
|
||||
$c('35500', '임의적립금', 'capital', 'capital', '32', 3, 'common', 3550),
|
||||
$c('35600', '사업확장적립금', 'capital', 'capital', '32', 3, 'common', 3560),
|
||||
$c('35700', '감채적립금', 'capital', 'capital', '32', 3, 'common', 3570),
|
||||
$c('35800', '배당평균적립금', 'capital', 'capital', '32', 3, 'common', 3580),
|
||||
$c('35900', '주식할인발행차손', 'capital', 'capital', '32', 3, 'common', 3590),
|
||||
$c('36000', '배당건설이자상각', 'capital', 'capital', '32', 3, 'common', 3600),
|
||||
$c('36100', '자기주식상환액', 'capital', 'capital', '32', 3, 'common', 3610),
|
||||
$c('36200', '자기주식처분차금', 'capital', 'capital', '32', 3, 'common', 3620),
|
||||
$c('36300', '중소기업투자준비금(자본)', 'capital', 'capital', '32', 3, 'common', 3630),
|
||||
$c('36400', '기술개발준비금(자본)', 'capital', 'capital', '32', 3, 'common', 3640),
|
||||
$c('36500', '해외시장개척준비금(자본)', 'capital', 'capital', '32', 3, 'common', 3650),
|
||||
$c('36600', '지방이전준비금(자본)', 'capital', 'capital', '32', 3, 'common', 3660),
|
||||
$c('36700', '수출손실준비금(자본)', 'capital', 'capital', '32', 3, 'common', 3670),
|
||||
$c('36800', '기타임의적립금', 'capital', 'capital', '32', 3, 'common', 3680),
|
||||
$c('36900', '회계변경의누적효과', 'capital', 'capital', '32', 3, 'common', 3690),
|
||||
$c('37000', '전기오류수정이익', 'capital', 'capital', '32', 3, 'common', 3700),
|
||||
$c('37100', '전기오류수정손실', 'capital', 'capital', '32', 3, 'common', 3710),
|
||||
$c('37200', '중간배당금', 'capital', 'capital', '32', 3, 'common', 3720),
|
||||
$c('37400', '기타이익잉여금', 'capital', 'capital', '32', 3, 'common', 3740),
|
||||
$c('37600', '이월결손금', 'capital', 'capital', '32', 3, 'common', 3760),
|
||||
$c('37800', '처분전이익잉여금', 'capital', 'capital', '32', 3, 'common', 3780),
|
||||
|
||||
// ================================================================
|
||||
// 자본 — 자본조정 (parent: '33')
|
||||
// ================================================================
|
||||
$c('38000', '당기순손실', 'capital', 'capital_adjustment', '33', 3, 'common', 3800),
|
||||
$c('38100', '주식할인발행차금', 'capital', 'capital_adjustment', '33', 3, 'common', 3810),
|
||||
$c('38200', '배당건설이자', 'capital', 'capital_adjustment', '33', 3, 'common', 3820),
|
||||
$c('38300', '자기주식', 'capital', 'capital_adjustment', '33', 3, 'common', 3830),
|
||||
$c('38400', '환전대가', 'capital', 'capital_adjustment', '33', 3, 'common', 3840),
|
||||
$c('38500', '신주인수권대가', 'capital', 'capital_adjustment', '33', 3, 'common', 3850),
|
||||
$c('38600', '신주발행비', 'capital', 'capital_adjustment', '33', 3, 'common', 3860),
|
||||
$c('38700', '미교부주식배당금', 'capital', 'capital_adjustment', '33', 3, 'common', 3870),
|
||||
$c('38800', '신주청약증거금', 'capital', 'capital_adjustment', '33', 3, 'common', 3880),
|
||||
$c('39200', '국고보조금', 'capital', 'capital_adjustment', '33', 3, 'common', 3920),
|
||||
$c('39300', '공사부담금', 'capital', 'capital_adjustment', '33', 3, 'common', 3930),
|
||||
$c('39400', '감자차손', 'capital', 'capital_adjustment', '33', 3, 'common', 3940),
|
||||
$c('39500', '자기주식처분손실', 'capital', 'capital_adjustment', '33', 3, 'common', 3950),
|
||||
$c('39600', '주식매입선택권', 'capital', 'capital_adjustment', '33', 3, 'common', 3960),
|
||||
// 기타포괄손익누계액
|
||||
$c('98100', '매도가능증권평가이익', 'capital', 'capital_adjustment', '33', 3, 'common', 9810),
|
||||
$c('98200', '매도가능증권평가손실', 'capital', 'capital_adjustment', '33', 3, 'common', 9820),
|
||||
$c('98300', '해외사업환산이익', 'capital', 'capital_adjustment', '33', 3, 'common', 9830),
|
||||
$c('98400', '해외사업환산손실', 'capital', 'capital_adjustment', '33', 3, 'common', 9840),
|
||||
$c('98500', '파생상품평가이익', 'capital', 'capital_adjustment', '33', 3, 'common', 9850),
|
||||
$c('98600', '파생상품평가손실', 'capital', 'capital_adjustment', '33', 3, 'common', 9860),
|
||||
|
||||
// ================================================================
|
||||
// 수익 — 매출 추가 (parent: '41')
|
||||
// ================================================================
|
||||
$c('40200', '매출환입및에누리(상품)', 'revenue', 'sales_revenue', '41', 3, 'common', 4020),
|
||||
$c('40300', '매출할인(상품)', 'revenue', 'sales_revenue', '41', 3, 'common', 4030),
|
||||
$c('40500', '매출환입및에누리(제품)', 'revenue', 'sales_revenue', '41', 3, 'common', 4050),
|
||||
$c('40600', '매출할인(제품)', 'revenue', 'sales_revenue', '41', 3, 'common', 4060),
|
||||
$c('40800', '매출할인(공사)', 'revenue', 'sales_revenue', '41', 3, 'common', 4080),
|
||||
$c('40900', '완성건물매출', 'revenue', 'sales_revenue', '41', 3, 'common', 4090),
|
||||
|
||||
// ================================================================
|
||||
// 수익 — 영업외수익 추가 (parent: '42')
|
||||
// ================================================================
|
||||
$c('90200', '만기보유증권이자', 'revenue', 'other_revenue', '42', 3, 'common', 9020),
|
||||
$c('90500', '단기투자자산평가이익', 'revenue', 'other_revenue', '42', 3, 'common', 9050),
|
||||
$c('90600', '단기투자자산처분이익', 'revenue', 'other_revenue', '42', 3, 'common', 9060),
|
||||
$c('90800', '대손충당금환입', 'revenue', 'other_revenue', '42', 3, 'common', 9080),
|
||||
$c('90900', '수입수수료', 'revenue', 'other_revenue', '42', 3, 'common', 9090),
|
||||
$c('91000', '외화환산이익', 'revenue', 'other_revenue', '42', 3, 'common', 9100),
|
||||
$c('91100', '사채상환이익', 'revenue', 'other_revenue', '42', 3, 'common', 9110),
|
||||
$c('91200', '전기오류수정이익', 'revenue', 'other_revenue', '42', 3, 'common', 9120),
|
||||
$c('91300', '하자보수충당금환입', 'revenue', 'other_revenue', '42', 3, 'common', 9130),
|
||||
$c('91400', '유형자산처분이익', 'revenue', 'other_revenue', '42', 3, 'common', 9140),
|
||||
$c('91500', '투자자산처분이익', 'revenue', 'other_revenue', '42', 3, 'common', 9150),
|
||||
$c('91600', '상각채권추심이익', 'revenue', 'other_revenue', '42', 3, 'common', 9160),
|
||||
$c('91700', '자산수증이익', 'revenue', 'other_revenue', '42', 3, 'common', 9170),
|
||||
$c('91800', '채무면제이익', 'revenue', 'other_revenue', '42', 3, 'common', 9180),
|
||||
$c('92000', '투자증권손상차환입', 'revenue', 'other_revenue', '42', 3, 'common', 9200),
|
||||
$c('92100', '지분법이익', 'revenue', 'other_revenue', '42', 3, 'common', 9210),
|
||||
$c('92400', '중소투자준비금환입', 'revenue', 'other_revenue', '42', 3, 'common', 9240),
|
||||
$c('92500', '기술개발준비금환입', 'revenue', 'other_revenue', '42', 3, 'common', 9250),
|
||||
$c('92600', '해외개척준비금환입', 'revenue', 'other_revenue', '42', 3, 'common', 9260),
|
||||
$c('92700', '지방이전준비금환입', 'revenue', 'other_revenue', '42', 3, 'common', 9270),
|
||||
$c('92800', '수출손실준비금환입', 'revenue', 'other_revenue', '42', 3, 'common', 9280),
|
||||
|
||||
// ================================================================
|
||||
// 비용 — 매출원가 추가: 45xxx (parent: '51')
|
||||
// ================================================================
|
||||
$c('45100', '상품매출원가', 'expense', 'cogs', '51', 3, 'common', 4510),
|
||||
$c('45200', '도급공사매출원가', 'expense', 'cogs', '51', 3, 'common', 4520),
|
||||
$c('45300', '분양공사매출원가', 'expense', 'cogs', '51', 3, 'common', 4530),
|
||||
$c('45500', '제품매출원가', 'expense', 'cogs', '51', 3, 'common', 4550),
|
||||
|
||||
// ================================================================
|
||||
// 비용 — 제조원가 추가: 50xxx-53xxx (parent: '51')
|
||||
// ================================================================
|
||||
$c('50600', '제수당(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5060),
|
||||
$c('50700', '잡급(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5070),
|
||||
$c('50900', '퇴직보험충당금전입(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5090),
|
||||
$c('51000', '퇴직금여(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5100),
|
||||
$c('51500', '가스수도료(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5150),
|
||||
$c('52300', '경상연구개발비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5230),
|
||||
$c('52500', '교육훈련비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5250),
|
||||
$c('52600', '도서인쇄비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5260),
|
||||
$c('52700', '회의비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5270),
|
||||
$c('52800', '포장비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5280),
|
||||
$c('52900', '사무용품비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5290),
|
||||
$c('53200', '보관료(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5320),
|
||||
$c('53300', '외주가공비(제조경비)', 'expense', 'cogs', '51', 3, 'manufacturing', 5330),
|
||||
$c('53400', '시험비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5340),
|
||||
$c('53500', '기밀비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5350),
|
||||
$c('53600', '잡비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5360),
|
||||
$c('53700', '폐기물처리비(제조)', 'expense', 'cogs', '51', 3, 'manufacturing', 5370),
|
||||
|
||||
// ================================================================
|
||||
// 비용 — 건설원가 60xxx (parent: '54')
|
||||
// ================================================================
|
||||
$c('60100', '원재료비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6010),
|
||||
$c('60200', '외주비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6020),
|
||||
$c('60300', '급여(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6030),
|
||||
$c('60400', '임금(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6040),
|
||||
$c('60500', '상여금(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6050),
|
||||
$c('60600', '잡급(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6060),
|
||||
$c('60700', '퇴직급여(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6070),
|
||||
$c('60800', '퇴직보험충당금전입(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6080),
|
||||
$c('60900', '퇴직금여(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6090),
|
||||
$c('61000', '중기및운반비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6100),
|
||||
$c('61100', '복리후생비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6110),
|
||||
$c('61200', '여비교통비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6120),
|
||||
$c('61300', '접대비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6130),
|
||||
$c('61400', '통신비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6140),
|
||||
$c('61500', '가스수도료(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6150),
|
||||
$c('61600', '전력비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6160),
|
||||
$c('61700', '세금과공과금(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6170),
|
||||
$c('61800', '감가상각비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6180),
|
||||
$c('61900', '지급임차료(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6190),
|
||||
$c('62000', '수선비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6200),
|
||||
$c('62100', '보험료(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6210),
|
||||
$c('62200', '차량유지비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6220),
|
||||
$c('62300', '운반비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6230),
|
||||
$c('62400', '잡자재대(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6240),
|
||||
$c('62500', '교육훈련비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6250),
|
||||
$c('62600', '도서인쇄비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6260),
|
||||
$c('62700', '회의비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6270),
|
||||
$c('62800', '포장비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6280),
|
||||
$c('62900', '사무용품비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6290),
|
||||
$c('63000', '소모품비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6300),
|
||||
$c('63100', '지급수수료(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6310),
|
||||
$c('63200', '보관료(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6320),
|
||||
$c('63300', '외주용역비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6330),
|
||||
$c('63400', '장비사용료(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6340),
|
||||
$c('63500', '설계용역비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6350),
|
||||
$c('63600', '광고선전비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6360),
|
||||
$c('63700', '소모공구비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6370),
|
||||
$c('63800', '외주시공비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6380),
|
||||
$c('63900', '협비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6390),
|
||||
$c('64000', '잡비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6400),
|
||||
$c('64100', '공사손실충당금전입(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6410),
|
||||
$c('64200', '공사손실충당금환입(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6420),
|
||||
$c('64300', '외주비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 6430),
|
||||
$c('64400', '유류비(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 6440),
|
||||
|
||||
// ================================================================
|
||||
// 비용 — 건설원가 70xxx (parent: '54')
|
||||
// ================================================================
|
||||
$c('70100', '원재료비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7010),
|
||||
$c('70200', '중기및운반비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7020),
|
||||
$c('70300', '급여(건설노무비)', 'expense', 'construction_cost', '54', 3, 'construction', 7030),
|
||||
$c('70400', '임금(건설노무비)', 'expense', 'construction_cost', '54', 3, 'construction', 7040),
|
||||
$c('70500', '상여금(건설노무비)', 'expense', 'construction_cost', '54', 3, 'construction', 7050),
|
||||
$c('70600', '제수당(건설노무비)', 'expense', 'construction_cost', '54', 3, 'construction', 7060),
|
||||
$c('70700', '퇴직급여(건설노무비)', 'expense', 'construction_cost', '54', 3, 'construction', 7070),
|
||||
$c('70800', '퇴직보험충당금전입(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7080),
|
||||
$c('70900', '퇴직금여(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7090),
|
||||
$c('71000', '건설용지비', 'expense', 'construction_cost', '54', 3, 'construction', 7100),
|
||||
$c('71100', '복리후생비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7110),
|
||||
$c('71200', '여비교통비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7120),
|
||||
$c('71300', '접대비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7130),
|
||||
$c('71400', '통신비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7140),
|
||||
$c('71500', '가스수도료(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7150),
|
||||
$c('71600', '전력비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7160),
|
||||
$c('71700', '세금과공과금(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7170),
|
||||
$c('71800', '감가상각비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7180),
|
||||
$c('71900', '지급임차료(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7190),
|
||||
$c('72000', '수선비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7200),
|
||||
$c('72100', '보험료(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7210),
|
||||
$c('72200', '차량유지비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7220),
|
||||
$c('72300', '경상연구개발비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7230),
|
||||
$c('72400', '잡자재대(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7240),
|
||||
$c('72500', '교육훈련비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7250),
|
||||
$c('72600', '도서인쇄비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7260),
|
||||
$c('72700', '회의비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7270),
|
||||
$c('72800', '포장비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7280),
|
||||
$c('72900', '사무용품비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7290),
|
||||
$c('73000', '소모품비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7300),
|
||||
$c('73100', '지급수수료(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7310),
|
||||
$c('73200', '보관료(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7320),
|
||||
$c('73300', '외주가공비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7330),
|
||||
$c('73400', '시험비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7340),
|
||||
$c('73500', '설계용역비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7350),
|
||||
$c('73600', '가설재손료(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7360),
|
||||
$c('73700', '잡비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7370),
|
||||
$c('73800', '폐기물처리비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7380),
|
||||
$c('73900', '장비사용료(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7390),
|
||||
$c('74100', '공사손실충당금전입(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7410),
|
||||
$c('74200', '공사손실충당금환입(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7420),
|
||||
$c('74300', '외주비(건설경비)', 'expense', 'construction_cost', '54', 3, 'construction', 7430),
|
||||
$c('74900', '명예퇴직금(건설)', 'expense', 'construction_cost', '54', 3, 'construction', 7490),
|
||||
|
||||
// ================================================================
|
||||
// 비용 — 판관비 추가 (parent: '52')
|
||||
// ================================================================
|
||||
$c('80400', '제수당', 'expense', 'selling_admin', '52', 3, 'admin', 8040),
|
||||
$c('80500', '잡급', 'expense', 'selling_admin', '52', 3, 'admin', 8050),
|
||||
$c('80700', '퇴직보험충당금전입', 'expense', 'selling_admin', '52', 3, 'admin', 8070),
|
||||
$c('80800', '퇴직금여', 'expense', 'selling_admin', '52', 3, 'admin', 8080),
|
||||
$c('81600', '전력비', 'expense', 'selling_admin', '52', 3, 'admin', 8160),
|
||||
$c('82800', '포장비', 'expense', 'selling_admin', '52', 3, 'admin', 8280),
|
||||
$c('83400', '판매촉진비', 'expense', 'selling_admin', '52', 3, 'admin', 8340),
|
||||
$c('83600', '기밀비', 'expense', 'selling_admin', '52', 3, 'admin', 8360),
|
||||
$c('83700', '건물관리비', 'expense', 'selling_admin', '52', 3, 'admin', 8370),
|
||||
$c('83800', '수출제비용', 'expense', 'selling_admin', '52', 3, 'admin', 8380),
|
||||
$c('83900', '판매수수료', 'expense', 'selling_admin', '52', 3, 'admin', 8390),
|
||||
$c('84000', '무형고정자산상각', 'expense', 'selling_admin', '52', 3, 'admin', 8400),
|
||||
$c('84100', '환가료', 'expense', 'selling_admin', '52', 3, 'admin', 8410),
|
||||
$c('84200', '견본비', 'expense', 'selling_admin', '52', 3, 'admin', 8420),
|
||||
$c('84300', '해외접대비', 'expense', 'selling_admin', '52', 3, 'admin', 8430),
|
||||
$c('84400', '해외시장개척비', 'expense', 'selling_admin', '52', 3, 'admin', 8440),
|
||||
$c('84500', '미분양주택관리비', 'expense', 'selling_admin', '52', 3, 'admin', 8450),
|
||||
$c('84600', '수주비', 'expense', 'selling_admin', '52', 3, 'admin', 8460),
|
||||
$c('84700', '하자보수충당금전입', 'expense', 'selling_admin', '52', 3, 'admin', 8470),
|
||||
$c('84900', '명예퇴직금', 'expense', 'selling_admin', '52', 3, 'admin', 8490),
|
||||
|
||||
// ================================================================
|
||||
// 비용 — 영업외비용 추가 (parent: '53')
|
||||
// ================================================================
|
||||
$c('93400', '기타의대손상각비', 'expense', 'other_expense', '53', 3, 'common', 9340),
|
||||
$c('93500', '외화환산손실', 'expense', 'other_expense', '53', 3, 'common', 9350),
|
||||
$c('93600', '매출채권처분손실', 'expense', 'other_expense', '53', 3, 'common', 9360),
|
||||
$c('93700', '단기투자자산평가손실', 'expense', 'other_expense', '53', 3, 'common', 9370),
|
||||
$c('93800', '단기투자자산처분손실', 'expense', 'other_expense', '53', 3, 'common', 9380),
|
||||
$c('93900', '재고자산감모손실', 'expense', 'other_expense', '53', 3, 'common', 9390),
|
||||
$c('94000', '재고자산평가손실', 'expense', 'other_expense', '53', 3, 'common', 9400),
|
||||
$c('94100', '재해손실', 'expense', 'other_expense', '53', 3, 'common', 9410),
|
||||
$c('94200', '전기오류수정손실', 'expense', 'other_expense', '53', 3, 'common', 9420),
|
||||
$c('94300', '투자증권손상차손', 'expense', 'other_expense', '53', 3, 'common', 9430),
|
||||
$c('94700', '사채상환손실', 'expense', 'other_expense', '53', 3, 'common', 9470),
|
||||
$c('95000', '투자자산처분손실', 'expense', 'other_expense', '53', 3, 'common', 9500),
|
||||
$c('95100', '중소투자준비금전입', 'expense', 'other_expense', '53', 3, 'common', 9510),
|
||||
$c('95200', '기술개발준비금전입', 'expense', 'other_expense', '53', 3, 'common', 9520),
|
||||
$c('95300', '해외개척준비금전입', 'expense', 'other_expense', '53', 3, 'common', 9530),
|
||||
$c('95400', '지방이전준비금전입', 'expense', 'other_expense', '53', 3, 'common', 9540),
|
||||
$c('95500', '수출손실준비금전입', 'expense', 'other_expense', '53', 3, 'common', 9550),
|
||||
$c('95700', '특별상각', 'expense', 'other_expense', '53', 3, 'common', 9570),
|
||||
// 중단사업
|
||||
$c('99100', '사업중단직접비', 'expense', 'other_expense', '53', 3, 'common', 9910),
|
||||
$c('99200', '중단사업자산손상차손', 'expense', 'other_expense', '53', 3, 'common', 9920),
|
||||
$c('99300', '중단사업손상차환입', 'expense', 'other_expense', '53', 3, 'common', 9930),
|
||||
$c('99700', '중단손익', 'expense', 'other_expense', '53', 3, 'common', 9970),
|
||||
];
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* codebridge DB로 이관 완료된 58개 테이블을 sam DB에서 삭제
|
||||
*
|
||||
* 복원: ~/backups/sam_codebridge_tables_20260309.sql
|
||||
*/
|
||||
private array $tables = [
|
||||
// Admin (9)
|
||||
'admin_api_flows',
|
||||
'admin_api_flow_runs',
|
||||
'admin_pm_daily_logs',
|
||||
'admin_pm_daily_log_entries',
|
||||
'admin_pm_issues',
|
||||
'admin_pm_projects',
|
||||
'admin_pm_tasks',
|
||||
'admin_roadmap_milestones',
|
||||
'admin_roadmap_plans',
|
||||
|
||||
// DevTools (5)
|
||||
'admin_api_bookmarks',
|
||||
'admin_api_deprecations',
|
||||
'admin_api_environments',
|
||||
'admin_api_histories',
|
||||
'admin_api_templates',
|
||||
|
||||
// Sales (17)
|
||||
'sales_partners',
|
||||
'sales_managers',
|
||||
'sales_manager_documents',
|
||||
'sales_commissions',
|
||||
'sales_commission_details',
|
||||
'sales_consultations',
|
||||
'sales_contract_products',
|
||||
'sales_products',
|
||||
'sales_product_categories',
|
||||
'sales_prospects',
|
||||
'sales_prospect_consultations',
|
||||
'sales_prospect_products',
|
||||
'sales_prospect_scenarios',
|
||||
'sales_records',
|
||||
'sales_scenario_checklists',
|
||||
'sales_tenant_managements',
|
||||
'tenant_prospects',
|
||||
|
||||
// Finance (9)
|
||||
'condolence_expenses',
|
||||
'consulting_fees',
|
||||
'corporate_cards',
|
||||
'corporate_card_prepayments',
|
||||
'customer_settlements',
|
||||
'daily_fund_memos',
|
||||
'daily_fund_transactions',
|
||||
'incomes',
|
||||
'vat_records',
|
||||
|
||||
// ESign (2)
|
||||
'esign_field_templates',
|
||||
'esign_field_template_items',
|
||||
|
||||
// Equipment (6)
|
||||
'equipments',
|
||||
'equipment_process',
|
||||
'equipment_inspections',
|
||||
'equipment_inspection_details',
|
||||
'equipment_inspection_templates',
|
||||
'equipment_repairs',
|
||||
|
||||
// HR (1)
|
||||
'business_income_payments',
|
||||
|
||||
// System (1)
|
||||
'ai_configs',
|
||||
|
||||
// 기타 (8)
|
||||
'biz_cert',
|
||||
'cm_songs',
|
||||
'construction_site_photos',
|
||||
'construction_site_photo_rows',
|
||||
'admin_meeting_logs',
|
||||
'meeting_minutes',
|
||||
'meeting_minute_segments',
|
||||
'interview_knowledge',
|
||||
];
|
||||
|
||||
public function up(): void
|
||||
{
|
||||
DB::statement('SET FOREIGN_KEY_CHECKS = 0');
|
||||
|
||||
foreach ($this->tables as $table) {
|
||||
Schema::dropIfExists($table);
|
||||
}
|
||||
|
||||
DB::statement('SET FOREIGN_KEY_CHECKS = 1');
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
// 복원은 백업 파일로 수행
|
||||
// mysql -u codebridge -p sam < ~/backups/sam_codebridge_tables_20260309.sql
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('payrolls', function (Blueprint $table) {
|
||||
$table->json('options')->nullable()->after('note');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('payrolls', function (Blueprint $table) {
|
||||
$table->dropColumn('options');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -17,7 +17,7 @@
|
||||
* Phase 3.1: chandj.price_motor → items (SM) + prices 누락 품목
|
||||
* Phase 3.2: chandj.price_raw_materials → items (RM) + prices 누락 품목
|
||||
*
|
||||
* @see docs/plans/kd-items-migration-plan.md
|
||||
* @see docs/dev_plans/kd-items-migration-plan.md
|
||||
*/
|
||||
class KyungdongItemSeeder extends Seeder
|
||||
{
|
||||
|
||||
@@ -37,7 +37,7 @@ ## 🔗 프로젝트 문서 (SAM/docs로 이동됨)
|
||||
|
||||
| 이전 위치 | 새 위치 | 설명 |
|
||||
|-----------|---------|------|
|
||||
| `analysis/` | `docs/data/analysis/` | Item DB 분석 문서 |
|
||||
| `analysis/` | `docs/dev/data/analysis/` | Item DB 분석 문서 |
|
||||
| `front/` | `docs/front/` | 프론트엔드 요청 문서 |
|
||||
| `specs/` | `docs/specs/` | 기능 스펙 문서 |
|
||||
|
||||
@@ -49,6 +49,6 @@ ## 📝 문서 추가 가이드
|
||||
|-----------|-----------|
|
||||
| Swagger 스펙 | `api/docs/swagger/` |
|
||||
| API Flow 테스트 | `api/docs/api-flows/` 또는 `flow-tests/` |
|
||||
| 프로젝트 분석 | `SAM/docs/data/` |
|
||||
| 프로젝트 분석 | `SAM/docs/dev/data/` |
|
||||
| 기능 스펙 | `SAM/docs/specs/` |
|
||||
| 프론트 요청 | `SAM/docs/front/` |
|
||||
|
||||
@@ -74,5 +74,5 @@ ## ⚠️ 배포 시 주의사항
|
||||
- 테넌트별 초기 데이터 설정 필요
|
||||
|
||||
## 🔗 관련 문서
|
||||
- `docs/plans/quote-calculation-api-plan.md`
|
||||
- `docs/dev/dev_plans/quote-calculation-api-plan.md`
|
||||
- `mng/app/Services/Quote/FormulaEvaluatorService.php` (원본)
|
||||
|
||||
@@ -2,7 +2,7 @@ # 변경 내용 요약
|
||||
|
||||
**날짜:** 2026-01-02 13:00
|
||||
**작업명:** Phase 1.2 입력 변수 처리 - React QuoteItem 매핑
|
||||
**계획 문서:** docs/plans/quote-calculation-api-plan.md
|
||||
**계획 문서:** docs/dev/dev_plans/quote-calculation-api-plan.md
|
||||
|
||||
## 변경 개요
|
||||
|
||||
@@ -151,4 +151,4 @@ ## API 사용 예시
|
||||
## 관련 문서
|
||||
|
||||
- Phase 1.1: `20251230_2339_quote_calculation_mng_logic.md` (BOM 단건 산출)
|
||||
- 계획 문서: `docs/plans/quote-calculation-api-plan.md`
|
||||
- 계획 문서: `docs/dev/dev_plans/quote-calculation-api-plan.md`
|
||||
@@ -444,6 +444,15 @@
|
||||
'already_completed' => '이미 완료된 검사입니다.',
|
||||
],
|
||||
|
||||
// 품질관리서 관련
|
||||
'quality' => [
|
||||
'cannot_delete_completed' => '완료된 품질관리서는 삭제할 수 없습니다.',
|
||||
'already_completed' => '이미 완료된 품질관리서입니다.',
|
||||
'cannot_modify_completed' => '완료된 품질관리서는 수정할 수 없습니다.',
|
||||
'pending_locations' => '미완료 개소가 :count건 있습니다.',
|
||||
'confirm_failed' => '필수정보가 누락된 건이 있어 확정할 수 없습니다.',
|
||||
],
|
||||
|
||||
// 입찰 관련
|
||||
'bidding' => [
|
||||
'not_found' => '입찰을 찾을 수 없습니다.',
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
require __DIR__.'/api/v1/app.php';
|
||||
require __DIR__.'/api/v1/audit.php';
|
||||
require __DIR__.'/api/v1/esign.php';
|
||||
require __DIR__.'/api/v1/quality.php';
|
||||
|
||||
// 공유 링크 다운로드 (인증 불필요 - auth.apikey 그룹 밖)
|
||||
Route::get('/files/share/{token}', [FileStorageController::class, 'downloadShared'])->name('v1.files.share.download');
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
Route::get('/{id}', [DocumentController::class, 'show'])->whereNumber('id')->name('v1.documents.show');
|
||||
Route::post('/', [DocumentController::class, 'store'])->name('v1.documents.store');
|
||||
Route::patch('/{id}', [DocumentController::class, 'update'])->whereNumber('id')->name('v1.documents.update');
|
||||
Route::patch('/{id}/snapshot', [DocumentController::class, 'patchSnapshot'])->whereNumber('id')->name('v1.documents.snapshot');
|
||||
Route::delete('/{id}', [DocumentController::class, 'destroy'])->whereNumber('id')->name('v1.documents.destroy');
|
||||
|
||||
// 결재 워크플로우
|
||||
|
||||
@@ -163,6 +163,8 @@
|
||||
Route::get('/{id}', [CardTransactionController::class, 'show'])->whereNumber('id')->name('v1.card-transactions.show');
|
||||
Route::put('/{id}', [CardTransactionController::class, 'update'])->whereNumber('id')->name('v1.card-transactions.update');
|
||||
Route::delete('/{id}', [CardTransactionController::class, 'destroy'])->whereNumber('id')->name('v1.card-transactions.destroy');
|
||||
Route::get('/{id}/journal-entries', [CardTransactionController::class, 'getJournalEntries'])->whereNumber('id')->name('v1.card-transactions.journal-entries.show');
|
||||
Route::post('/{id}/journal-entries', [CardTransactionController::class, 'storeJournalEntries'])->whereNumber('id')->name('v1.card-transactions.journal-entries.store');
|
||||
});
|
||||
|
||||
// Bank Transaction API (은행 거래 조회)
|
||||
@@ -287,6 +289,10 @@
|
||||
Route::post('/{id}/cancel', [TaxInvoiceController::class, 'cancel'])->whereNumber('id')->name('v1.tax-invoices.cancel');
|
||||
Route::get('/{id}/check-status', [TaxInvoiceController::class, 'checkStatus'])->whereNumber('id')->name('v1.tax-invoices.check-status');
|
||||
Route::post('/bulk-issue', [TaxInvoiceController::class, 'bulkIssue'])->name('v1.tax-invoices.bulk-issue');
|
||||
Route::get('/{id}/journal-entries', [TaxInvoiceController::class, 'getJournalEntries'])->whereNumber('id')->name('v1.tax-invoices.journal-entries.show');
|
||||
Route::post('/{id}/journal-entries', [TaxInvoiceController::class, 'storeJournalEntries'])->whereNumber('id')->name('v1.tax-invoices.journal-entries.store');
|
||||
Route::put('/{id}/journal-entries', [TaxInvoiceController::class, 'storeJournalEntries'])->whereNumber('id')->name('v1.tax-invoices.journal-entries.update');
|
||||
Route::delete('/{id}/journal-entries', [TaxInvoiceController::class, 'deleteJournalEntries'])->whereNumber('id')->name('v1.tax-invoices.journal-entries.destroy');
|
||||
});
|
||||
|
||||
// Bad Debt API (악성채권 추심관리)
|
||||
@@ -320,6 +326,8 @@
|
||||
Route::prefix('account-subjects')->group(function () {
|
||||
Route::get('', [AccountSubjectController::class, 'index'])->name('v1.account-subjects.index');
|
||||
Route::post('', [AccountSubjectController::class, 'store'])->name('v1.account-subjects.store');
|
||||
Route::post('/seed-defaults', [AccountSubjectController::class, 'seedDefaults'])->name('v1.account-subjects.seed-defaults');
|
||||
Route::put('/{id}', [AccountSubjectController::class, 'update'])->whereNumber('id')->name('v1.account-subjects.update');
|
||||
Route::patch('/{id}/status', [AccountSubjectController::class, 'toggleStatus'])->whereNumber('id')->name('v1.account-subjects.toggle-status');
|
||||
Route::delete('/{id}', [AccountSubjectController::class, 'destroy'])->whereNumber('id')->name('v1.account-subjects.destroy');
|
||||
});
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
|
||||
use App\Http\Controllers\Api\V1\InspectionController;
|
||||
use App\Http\Controllers\Api\V1\ProductionOrderController;
|
||||
use App\Http\Controllers\Api\V1\WorkOrderController;
|
||||
use App\Http\Controllers\Api\V1\WorkResultController;
|
||||
use App\Http\Controllers\V1\ProcessController;
|
||||
@@ -121,3 +122,10 @@
|
||||
Route::delete('/{id}', [InspectionController::class, 'destroy'])->whereNumber('id')->name('v1.inspections.destroy'); // 삭제
|
||||
Route::patch('/{id}/complete', [InspectionController::class, 'complete'])->whereNumber('id')->name('v1.inspections.complete'); // 완료 처리
|
||||
});
|
||||
|
||||
// Production Order API (생산지시 조회)
|
||||
Route::prefix('production-orders')->group(function () {
|
||||
Route::get('', [ProductionOrderController::class, 'index'])->name('v1.production-orders.index');
|
||||
Route::get('/stats', [ProductionOrderController::class, 'stats'])->name('v1.production-orders.stats');
|
||||
Route::get('/{orderId}', [ProductionOrderController::class, 'show'])->whereNumber('orderId')->name('v1.production-orders.show');
|
||||
});
|
||||
|
||||
40
routes/api/v1/quality.php
Normal file
40
routes/api/v1/quality.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 품질관리 API 라우트 (v1)
|
||||
*
|
||||
* - 제품검사 (품질관리서)
|
||||
* - 실적신고
|
||||
*/
|
||||
|
||||
use App\Http\Controllers\Api\V1\PerformanceReportController;
|
||||
use App\Http\Controllers\Api\V1\QualityDocumentController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
// 제품검사 (품질관리서)
|
||||
Route::prefix('quality/documents')->group(function () {
|
||||
Route::get('', [QualityDocumentController::class, 'index'])->name('v1.quality.documents.index');
|
||||
Route::get('/stats', [QualityDocumentController::class, 'stats'])->name('v1.quality.documents.stats');
|
||||
Route::get('/calendar', [QualityDocumentController::class, 'calendar'])->name('v1.quality.documents.calendar');
|
||||
Route::get('/available-orders', [QualityDocumentController::class, 'availableOrders'])->name('v1.quality.documents.available-orders');
|
||||
Route::post('', [QualityDocumentController::class, 'store'])->name('v1.quality.documents.store');
|
||||
Route::get('/{id}', [QualityDocumentController::class, 'show'])->whereNumber('id')->name('v1.quality.documents.show');
|
||||
Route::put('/{id}', [QualityDocumentController::class, 'update'])->whereNumber('id')->name('v1.quality.documents.update');
|
||||
Route::delete('/{id}', [QualityDocumentController::class, 'destroy'])->whereNumber('id')->name('v1.quality.documents.destroy');
|
||||
Route::patch('/{id}/complete', [QualityDocumentController::class, 'complete'])->whereNumber('id')->name('v1.quality.documents.complete');
|
||||
Route::post('/{id}/orders', [QualityDocumentController::class, 'attachOrders'])->whereNumber('id')->name('v1.quality.documents.attach-orders');
|
||||
Route::delete('/{id}/orders/{orderId}', [QualityDocumentController::class, 'detachOrder'])->whereNumber('id')->whereNumber('orderId')->name('v1.quality.documents.detach-order');
|
||||
Route::post('/{id}/locations/{locId}/inspect', [QualityDocumentController::class, 'inspectLocation'])->whereNumber('id')->whereNumber('locId')->name('v1.quality.documents.inspect-location');
|
||||
Route::get('/{id}/request-document', [QualityDocumentController::class, 'requestDocument'])->whereNumber('id')->name('v1.quality.documents.request-document');
|
||||
Route::get('/{id}/result-document', [QualityDocumentController::class, 'resultDocument'])->whereNumber('id')->name('v1.quality.documents.result-document');
|
||||
});
|
||||
|
||||
// 실적신고
|
||||
Route::prefix('quality/performance-reports')->group(function () {
|
||||
Route::get('', [PerformanceReportController::class, 'index'])->name('v1.quality.performance-reports.index');
|
||||
Route::get('/stats', [PerformanceReportController::class, 'stats'])->name('v1.quality.performance-reports.stats');
|
||||
Route::get('/missing', [PerformanceReportController::class, 'missing'])->name('v1.quality.performance-reports.missing');
|
||||
Route::patch('/confirm', [PerformanceReportController::class, 'confirm'])->name('v1.quality.performance-reports.confirm');
|
||||
Route::patch('/unconfirm', [PerformanceReportController::class, 'unconfirm'])->name('v1.quality.performance-reports.unconfirm');
|
||||
Route::patch('/memo', [PerformanceReportController::class, 'updateMemo'])->name('v1.quality.performance-reports.memo');
|
||||
});
|
||||
Reference in New Issue
Block a user