- parseFgCode() 추가: FG 코드에서 모델/설치타입/마감타입 파싱 - calculateTenantBom() 폴백 순서: 입력값 > FG코드 파싱 > 기본값(KSS01/벽면형/SUS) - KQTS01 제품이 KSS01 가이드레일 규격(120*70)으로 잘못 산출되던 문제 해결 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
39 lines
1.1 KiB
PHP
39 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Quote;
|
|
|
|
use App\Services\Quote\Contracts\TenantFormulaHandler;
|
|
|
|
/**
|
|
* 테넌트별 수식 핸들러 팩토리 (Zero Config)
|
|
*
|
|
* tenant_id 기반 자동 발견: Handlers/Tenant{id}/FormulaHandler.php 존재 여부로 라우팅.
|
|
* 설정 파일, DB 매핑, options 없이 클래스 존재 여부만으로 핸들러를 결정한다.
|
|
*
|
|
* 새 업체 추가: Handlers/Tenant{id}/FormulaHandler.php 1개만 생성하면 자동 인식.
|
|
*/
|
|
class FormulaHandlerFactory
|
|
{
|
|
/**
|
|
* 테넌트 전용 핸들러 생성 (없으면 null → Generic DB 경로)
|
|
*/
|
|
public static function make(int $tenantId): ?TenantFormulaHandler
|
|
{
|
|
$class = "App\\Services\\Quote\\Handlers\\Tenant{$tenantId}\\FormulaHandler";
|
|
|
|
if (! class_exists($class)) {
|
|
return null;
|
|
}
|
|
|
|
$handler = new $class;
|
|
|
|
if (! $handler instanceof TenantFormulaHandler) {
|
|
throw new \RuntimeException(
|
|
"Handler [{$class}] must implement " . TenantFormulaHandler::class
|
|
);
|
|
}
|
|
|
|
return $handler;
|
|
}
|
|
}
|