feat: [tax-invoice] 공급자 설정 Tenant Fallback 로직 추가
- BarobillSetting 미설정 시 Tenant 정보를 기본값으로 반환 - corp_num/corp_name이 비어있으면 Fallback 동작 - Tenant 필드 매핑: business_num, company_name, ceo_name, address, phone - Tenant options 매핑: business_type, business_category, tax_invoice_contact, tax_invoice_email
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Tenants\TaxInvoice;
|
||||
use App\Models\Tenants\Tenant;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
@@ -276,26 +277,61 @@ public function checkStatus(int $id): TaxInvoice
|
||||
// =========================================================================
|
||||
|
||||
/**
|
||||
* 공급자 설정 조회 (BarobillSetting 기반)
|
||||
* 공급자 설정 조회 (BarobillSetting 기반, 미설정 시 Tenant 정보 Fallback)
|
||||
*/
|
||||
public function getSupplierSettings(): array
|
||||
{
|
||||
$setting = $this->barobillService->getSetting();
|
||||
|
||||
if (! $setting) {
|
||||
if ($setting && $this->hasSupplierData($setting)) {
|
||||
return [
|
||||
'business_number' => $setting->corp_num,
|
||||
'company_name' => $setting->corp_name,
|
||||
'representative_name' => $setting->ceo_name,
|
||||
'address' => $setting->addr,
|
||||
'business_type' => $setting->biz_type,
|
||||
'business_item' => $setting->biz_class,
|
||||
'contact_name' => $setting->contact_name,
|
||||
'contact_phone' => $setting->contact_tel,
|
||||
'contact_email' => $setting->contact_id,
|
||||
];
|
||||
}
|
||||
|
||||
// BarobillSetting 미설정 시 Tenant 정보를 기본값으로 반환
|
||||
return $this->getSupplierSettingsFromTenant();
|
||||
}
|
||||
|
||||
/**
|
||||
* BarobillSetting에 공급자 정보가 입력되어 있는지 확인
|
||||
*/
|
||||
private function hasSupplierData($setting): bool
|
||||
{
|
||||
return ! empty($setting->corp_num) || ! empty($setting->corp_name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tenant 정보에서 공급자 설정 기본값 조회
|
||||
*/
|
||||
private function getSupplierSettingsFromTenant(): array
|
||||
{
|
||||
$tenant = Tenant::find($this->tenantId());
|
||||
|
||||
if (! $tenant) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$options = $tenant->options ?? [];
|
||||
|
||||
return [
|
||||
'business_number' => $setting->corp_num,
|
||||
'company_name' => $setting->corp_name,
|
||||
'representative_name' => $setting->ceo_name,
|
||||
'address' => $setting->addr,
|
||||
'business_type' => $setting->biz_type,
|
||||
'business_item' => $setting->biz_class,
|
||||
'contact_name' => $setting->contact_name,
|
||||
'contact_phone' => $setting->contact_tel,
|
||||
'contact_email' => $setting->contact_id,
|
||||
'business_number' => $tenant->business_num ?? '',
|
||||
'company_name' => $tenant->company_name ?? '',
|
||||
'representative_name' => $tenant->ceo_name ?? '',
|
||||
'address' => $tenant->address ?? '',
|
||||
'business_type' => $options['business_type'] ?? '',
|
||||
'business_item' => $options['business_category'] ?? '',
|
||||
'contact_name' => $options['tax_invoice_contact'] ?? '',
|
||||
'contact_phone' => $tenant->phone ?? '',
|
||||
'contact_email' => $options['tax_invoice_email'] ?? '',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user