feat: [결재] 테넌트 부트스트랩에 기본 결재 양식 자동 시딩 추가
- ApprovalFormsStep 신규 생성 (proposal, expenseReport, expenseEstimate, attendance_request, reason_report) - RecipeRegistry STANDARD 레시피에 등록 - 테넌트 생성 시 TenantObserver → TenantBootstrapper로 자동 실행 - 기존 테넌트는 php artisan tenants:bootstrap --all로 적용 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user