From 3ae3a1dcdab628136f6ccdb963918ebfb0d03b84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B3=B4=EA=B3=A4?= Date: Sat, 21 Feb 2026 08:43:11 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20[tax-invoice]=20=EA=B3=B5=EA=B8=89?= =?UTF-8?q?=EC=9E=90=20=EC=84=A4=EC=A0=95=20Tenant=20Fallback=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- app/Services/TaxInvoiceService.php | 58 ++++++++++++++++++++++++------ 1 file changed, 47 insertions(+), 11 deletions(-) diff --git a/app/Services/TaxInvoiceService.php b/app/Services/TaxInvoiceService.php index 862a46b..796cba6 100644 --- a/app/Services/TaxInvoiceService.php +++ b/app/Services/TaxInvoiceService.php @@ -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'] ?? '', ]; }