feat(WEB): 작업지시/출근부 기능 개선 및 마이그레이션 추가
- 작업지시 우선순위 필드 추가 (priority 마이그레이션) - 수주-작업지시 품목 연동 source_order_item_id 컬럼 추가 - 수주 테이블에 account_code 필드 추가 - 작업지시 StoreRequest/UpdateRequest 우선순위 검증 추가 - WorkOrder 모델 priority fillable 추가 - 출근부 StoreRequest/UpdateRequest 검증 규칙 개선 - Employee Request 검증 규칙 수정 - SaleService/ItemService 수정 - WorkResultService 결과 처리 개선 - BankTransactionService 수정 - routes/api.php 엔드포인트 업데이트 - error.php 에러 메시지 추가 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -27,6 +27,7 @@ public function index(Request $request)
|
||||
'q' => $request->input('q') ?? $request->input('search'),
|
||||
'category_id' => $request->input('category_id'),
|
||||
'item_type' => $request->input('type') ?? $request->input('item_type'),
|
||||
'item_category' => $request->input('item_category'),
|
||||
'group_id' => $request->input('group_id'),
|
||||
'active' => $request->input('is_active') ?? $request->input('active'),
|
||||
];
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use App\Helpers\ApiResponse;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\V1\Common\BulkUpdateAccountCodeRequest;
|
||||
use App\Http\Requests\V1\Sale\SendStatementRequest;
|
||||
use App\Http\Requests\V1\Sale\StoreSaleRequest;
|
||||
use App\Http\Requests\V1\Sale\UpdateSaleRequest;
|
||||
@@ -88,6 +89,22 @@ public function confirm(int $id)
|
||||
return ApiResponse::success($sale, __('message.sale.confirmed'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 계정과목 일괄 변경
|
||||
*/
|
||||
public function bulkUpdateAccountCode(BulkUpdateAccountCodeRequest $request)
|
||||
{
|
||||
$updatedCount = $this->service->bulkUpdateAccountCode(
|
||||
$request->getIds(),
|
||||
$request->getAccountCode()
|
||||
);
|
||||
|
||||
return ApiResponse::success(
|
||||
['updated_count' => $updatedCount],
|
||||
__('message.bulk_updated')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 매출 요약 (기간별 합계)
|
||||
*/
|
||||
|
||||
@@ -19,7 +19,20 @@ public function rules(): array
|
||||
'status' => 'nullable|in:onTime,late,absent,vacation,businessTrip,fieldWork,overtime,remote',
|
||||
'remarks' => 'nullable|string|max:500',
|
||||
|
||||
// json_details 필드
|
||||
// json_details 객체로 전달되는 경우 (프론트엔드 기본 형식)
|
||||
'json_details' => 'nullable|array',
|
||||
'json_details.check_in' => 'nullable|date_format:H:i:s',
|
||||
'json_details.check_out' => 'nullable|date_format:H:i:s',
|
||||
'json_details.gps_data' => 'nullable|array',
|
||||
'json_details.work_minutes' => 'nullable|integer|min:0',
|
||||
'json_details.overtime_minutes' => 'nullable|integer|min:0',
|
||||
'json_details.late_minutes' => 'nullable|integer|min:0',
|
||||
'json_details.early_leave_minutes' => 'nullable|integer|min:0',
|
||||
'json_details.vacation_type' => 'nullable|string|max:50',
|
||||
'json_details.reason' => 'nullable|string|max:500',
|
||||
'json_details.break_time' => 'nullable|string|max:50',
|
||||
|
||||
// 최상위 레벨 필드 (호환성 유지)
|
||||
'check_in' => 'nullable|date_format:H:i:s',
|
||||
'check_out' => 'nullable|date_format:H:i:s',
|
||||
'gps_data' => 'nullable|array',
|
||||
|
||||
@@ -17,7 +17,20 @@ public function rules(): array
|
||||
'status' => 'nullable|in:onTime,late,absent,vacation,businessTrip,fieldWork,overtime,remote',
|
||||
'remarks' => 'nullable|string|max:500',
|
||||
|
||||
// json_details 필드
|
||||
// json_details 객체로 전달되는 경우 (프론트엔드 기본 형식)
|
||||
'json_details' => 'nullable|array',
|
||||
'json_details.check_in' => 'nullable|date_format:H:i:s',
|
||||
'json_details.check_out' => 'nullable|date_format:H:i:s',
|
||||
'json_details.gps_data' => 'nullable|array',
|
||||
'json_details.work_minutes' => 'nullable|integer|min:0',
|
||||
'json_details.overtime_minutes' => 'nullable|integer|min:0',
|
||||
'json_details.late_minutes' => 'nullable|integer|min:0',
|
||||
'json_details.early_leave_minutes' => 'nullable|integer|min:0',
|
||||
'json_details.vacation_type' => 'nullable|string|max:50',
|
||||
'json_details.reason' => 'nullable|string|max:500',
|
||||
'json_details.break_time' => 'nullable|string|max:50',
|
||||
|
||||
// 최상위 레벨 필드 (호환성 유지)
|
||||
'check_in' => 'nullable|date_format:H:i:s',
|
||||
'check_out' => 'nullable|date_format:H:i:s',
|
||||
'gps_data' => 'nullable|array',
|
||||
|
||||
@@ -38,21 +38,27 @@ public function rules(): array
|
||||
'resident_number' => 'nullable|string|max:255',
|
||||
'gender' => 'nullable|in:male,female',
|
||||
'address' => 'nullable|array',
|
||||
'address.zipCode' => 'nullable|string|max:10',
|
||||
'address.zip_code' => 'nullable|string|max:10',
|
||||
'address.address1' => 'nullable|string|max:255',
|
||||
'address.address2' => 'nullable|string|max:255',
|
||||
'salary' => 'nullable|numeric|min:0',
|
||||
'hire_date' => 'nullable|date',
|
||||
'rank' => 'nullable|string|max:50',
|
||||
'bank_account' => 'nullable|array',
|
||||
'bank_account.bankName' => 'nullable|string|max:50',
|
||||
'bank_account.accountNumber' => 'nullable|string|max:50',
|
||||
'bank_account.accountHolder' => 'nullable|string|max:50',
|
||||
'bank_account.bank_name' => 'nullable|string|max:50',
|
||||
'bank_account.account_number' => 'nullable|string|max:50',
|
||||
'bank_account.account_holder' => 'nullable|string|max:50',
|
||||
'work_type' => 'nullable|in:regular,contract,parttime,intern',
|
||||
'contract_info' => 'nullable|array',
|
||||
'contract_info.start_date' => 'nullable|date',
|
||||
'contract_info.end_date' => 'nullable|date',
|
||||
'contract_info.external_company' => 'nullable|string|max:100',
|
||||
|
||||
// 추가 json_extra 필드 (프론트엔드에서 전송)
|
||||
'resignation_date' => 'nullable|date',
|
||||
'resignation_reason' => 'nullable|string|max:500',
|
||||
'clock_in_location' => 'nullable|string|max:255',
|
||||
'clock_out_location' => 'nullable|string|max:255',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -44,21 +44,27 @@ public function rules(): array
|
||||
'resident_number' => 'nullable|string|max:255',
|
||||
'gender' => 'nullable|in:male,female',
|
||||
'address' => 'nullable|array',
|
||||
'address.zipCode' => 'nullable|string|max:10',
|
||||
'address.zip_code' => 'nullable|string|max:10',
|
||||
'address.address1' => 'nullable|string|max:255',
|
||||
'address.address2' => 'nullable|string|max:255',
|
||||
'salary' => 'nullable|numeric|min:0',
|
||||
'hire_date' => 'nullable|date',
|
||||
'rank' => 'nullable|string|max:50',
|
||||
'bank_account' => 'nullable|array',
|
||||
'bank_account.bankName' => 'nullable|string|max:50',
|
||||
'bank_account.accountNumber' => 'nullable|string|max:50',
|
||||
'bank_account.accountHolder' => 'nullable|string|max:50',
|
||||
'bank_account.bank_name' => 'nullable|string|max:50',
|
||||
'bank_account.account_number' => 'nullable|string|max:50',
|
||||
'bank_account.account_holder' => 'nullable|string|max:50',
|
||||
'work_type' => 'nullable|in:regular,contract,parttime,intern',
|
||||
'contract_info' => 'nullable|array',
|
||||
'contract_info.start_date' => 'nullable|date',
|
||||
'contract_info.end_date' => 'nullable|date',
|
||||
'contract_info.external_company' => 'nullable|string|max:100',
|
||||
|
||||
// 추가 json_extra 필드 (프론트엔드에서 전송)
|
||||
'resignation_date' => 'nullable|date',
|
||||
'resignation_reason' => 'nullable|string|max:500',
|
||||
'clock_in_location' => 'nullable|string|max:255',
|
||||
'clock_out_location' => 'nullable|string|max:255',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,9 @@ public function authorize(): bool
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
// 수주 연동 등록 시 담당자 필수
|
||||
$assigneeRequired = $this->filled('sales_order_id') ? 'required' : 'nullable';
|
||||
|
||||
return [
|
||||
// 기본 정보
|
||||
'sales_order_id' => 'nullable|integer|exists:orders,id',
|
||||
@@ -21,6 +24,8 @@ public function rules(): array
|
||||
'process_id' => 'required|integer|exists:processes,id',
|
||||
'status' => ['nullable', 'in:'.implode(',', WorkOrder::STATUSES)],
|
||||
'assignee_id' => 'nullable|integer|exists:users,id',
|
||||
'assignee_ids' => [$assigneeRequired, 'array'],
|
||||
'assignee_ids.*' => 'integer|exists:users,id',
|
||||
'team_id' => 'nullable|integer|exists:departments,id',
|
||||
'scheduled_date' => 'nullable|date',
|
||||
'memo' => 'nullable|string',
|
||||
@@ -53,6 +58,7 @@ public function messages(): array
|
||||
return [
|
||||
'process_id.required' => __('validation.required', ['attribute' => '공정']),
|
||||
'process_id.exists' => __('validation.exists', ['attribute' => '공정']),
|
||||
'assignee_ids.required' => __('error.work_order.assignee_required_for_linked'),
|
||||
'items.*.item_name.required' => __('validation.required', ['attribute' => '품목명']),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -21,8 +21,11 @@ public function rules(): array
|
||||
'process_id' => 'nullable|integer|exists:processes,id',
|
||||
'status' => ['nullable', 'in:'.implode(',', WorkOrder::STATUSES)],
|
||||
'assignee_id' => 'nullable|integer|exists:users,id',
|
||||
'assignee_ids' => 'nullable|array',
|
||||
'assignee_ids.*' => 'integer|exists:users,id',
|
||||
'team_id' => 'nullable|integer|exists:departments,id',
|
||||
'scheduled_date' => 'nullable|date',
|
||||
'priority' => 'nullable|integer|min:1|max:9',
|
||||
'memo' => 'nullable|string',
|
||||
'is_active' => 'nullable|boolean',
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ class WorkOrder extends Model
|
||||
'process_id',
|
||||
'project_name',
|
||||
'status',
|
||||
'priority',
|
||||
'assignee_id',
|
||||
'team_id',
|
||||
'scheduled_date',
|
||||
|
||||
@@ -21,6 +21,7 @@ class Sale extends Model
|
||||
'total_amount',
|
||||
'description',
|
||||
'status',
|
||||
'account_code',
|
||||
'tax_invoice_issued',
|
||||
'transaction_statement_issued',
|
||||
'tax_invoice_id',
|
||||
|
||||
@@ -32,7 +32,7 @@ public function index(array $params): LengthAwarePaginator
|
||||
|
||||
// 입금 쿼리 (payment_method = 'transfer')
|
||||
$depositsQuery = DB::table('deposits')
|
||||
->join('bank_accounts', 'deposits.bank_account_id', '=', 'bank_accounts.id')
|
||||
->leftJoin('bank_accounts', 'deposits.bank_account_id', '=', 'bank_accounts.id')
|
||||
->leftJoin('clients', 'deposits.client_id', '=', 'clients.id')
|
||||
->where('deposits.tenant_id', $tenantId)
|
||||
->where('deposits.payment_method', 'transfer')
|
||||
@@ -58,7 +58,7 @@ public function index(array $params): LengthAwarePaginator
|
||||
|
||||
// 출금 쿼리 (payment_method = 'transfer')
|
||||
$withdrawalsQuery = DB::table('withdrawals')
|
||||
->join('bank_accounts', 'withdrawals.bank_account_id', '=', 'bank_accounts.id')
|
||||
->leftJoin('bank_accounts', 'withdrawals.bank_account_id', '=', 'bank_accounts.id')
|
||||
->leftJoin('clients', 'withdrawals.client_id', '=', 'clients.id')
|
||||
->where('withdrawals.tenant_id', $tenantId)
|
||||
->where('withdrawals.payment_method', 'transfer')
|
||||
|
||||
@@ -352,6 +352,7 @@ public function index(array $params): LengthAwarePaginator
|
||||
$q = trim((string) ($params['q'] ?? $params['search'] ?? ''));
|
||||
$categoryId = $params['category_id'] ?? null;
|
||||
$itemType = $params['item_type'] ?? null;
|
||||
$itemCategory = $params['item_category'] ?? null;
|
||||
$groupId = $params['group_id'] ?? null;
|
||||
$active = $params['active'] ?? null;
|
||||
|
||||
@@ -398,6 +399,11 @@ public function index(array $params): LengthAwarePaginator
|
||||
$query->where('category_id', (int) $categoryId);
|
||||
}
|
||||
|
||||
// 품목 카테고리 (SCREEN, STEEL, BENDING 등)
|
||||
if ($itemCategory) {
|
||||
$query->where('item_category', $itemCategory);
|
||||
}
|
||||
|
||||
// 활성 상태
|
||||
if ($active !== null && $active !== '') {
|
||||
$query->where('is_active', (bool) $active);
|
||||
|
||||
@@ -212,6 +212,27 @@ public function confirm(int $id): Sale
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 매출 계정과목 일괄 변경
|
||||
*
|
||||
* @param array $ids 대상 ID 배열
|
||||
* @param string $accountCode 변경할 계정과목 코드
|
||||
* @return int 변경된 레코드 수
|
||||
*/
|
||||
public function bulkUpdateAccountCode(array $ids, string $accountCode): int
|
||||
{
|
||||
$tenantId = $this->tenantId();
|
||||
$userId = $this->apiUserId();
|
||||
|
||||
return Sale::query()
|
||||
->where('tenant_id', $tenantId)
|
||||
->whereIn('id', $ids)
|
||||
->update([
|
||||
'account_code' => $accountCode,
|
||||
'updated_by' => $userId,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 매출 요약 (기간별 합계)
|
||||
*/
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Members\User;
|
||||
use App\Models\Production\WorkOrderItem;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
@@ -81,7 +82,32 @@ public function index(array $params)
|
||||
// 최신 완료순 정렬
|
||||
$query->orderByDesc('options->result->completed_at')->orderByDesc('id');
|
||||
|
||||
return $query->paginate($size, ['*'], 'page', $page);
|
||||
$paginated = $query->paginate($size, ['*'], 'page', $page);
|
||||
|
||||
// worker_id로 작업자 이름 조회하여 추가
|
||||
$workerIds = $paginated->getCollection()
|
||||
->map(fn ($item) => $item->options['result']['worker_id'] ?? null)
|
||||
->filter()
|
||||
->unique()
|
||||
->values()
|
||||
->toArray();
|
||||
|
||||
$workers = [];
|
||||
if (! empty($workerIds)) {
|
||||
$workers = User::whereIn('id', $workerIds)
|
||||
->pluck('name', 'id')
|
||||
->toArray();
|
||||
}
|
||||
|
||||
// 각 아이템에 worker_name 추가
|
||||
$paginated->getCollection()->transform(function ($item) use ($workers) {
|
||||
$workerId = $item->options['result']['worker_id'] ?? null;
|
||||
$item->worker_name = $workerId ? ($workers[$workerId] ?? null) : null;
|
||||
|
||||
return $item;
|
||||
});
|
||||
|
||||
return $paginated;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -155,6 +181,14 @@ public function show(int $id)
|
||||
throw new NotFoundHttpException(__('error.not_found'));
|
||||
}
|
||||
|
||||
// worker_name 추가
|
||||
$workerId = $item->options['result']['worker_id'] ?? null;
|
||||
if ($workerId) {
|
||||
$item->worker_name = User::where('id', $workerId)->value('name');
|
||||
} else {
|
||||
$item->worker_name = null;
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user