feat: [finance] vendors 및 supplier-settings API 추가
- GET /api/v1/vendors: 거래처 간단 목록 (id, name) 반환 - GET /api/v1/tax-invoices/supplier-settings: 공급자 설정 조회 - PUT /api/v1/tax-invoices/supplier-settings: 공급자 설정 저장
This commit is contained in:
@@ -20,6 +20,16 @@ public function index(Request $request)
|
||||
}, __('message.client.fetched'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 거래처 간단 목록 (id, name만 반환) - vendors 엔드포인트용
|
||||
*/
|
||||
public function vendors(Request $request)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($request) {
|
||||
return $this->service->vendors($request->all());
|
||||
}, __('message.client.fetched'));
|
||||
}
|
||||
|
||||
public function show(int $id)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($id) {
|
||||
|
||||
@@ -13,14 +13,30 @@
|
||||
use App\Models\Tenants\JournalEntry;
|
||||
use App\Services\JournalSyncService;
|
||||
use App\Services\TaxInvoiceService;
|
||||
use App\Services\TenantSettingService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TaxInvoiceController extends Controller
|
||||
{
|
||||
private const SUPPLIER_GROUP = 'supplier';
|
||||
|
||||
private const SUPPLIER_KEYS = [
|
||||
'business_number',
|
||||
'company_name',
|
||||
'representative_name',
|
||||
'address',
|
||||
'business_type',
|
||||
'business_item',
|
||||
'contact_name',
|
||||
'contact_phone',
|
||||
'contact_email',
|
||||
];
|
||||
|
||||
public function __construct(
|
||||
private TaxInvoiceService $taxInvoiceService,
|
||||
private JournalSyncService $journalSyncService,
|
||||
private TenantSettingService $tenantSettingService,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -125,6 +141,48 @@ public function summary(TaxInvoiceSummaryRequest $request)
|
||||
}, __('message.fetched'));
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// 공급자 설정 (Supplier Settings)
|
||||
// =========================================================================
|
||||
|
||||
/**
|
||||
* 공급자 설정 조회
|
||||
*/
|
||||
public function getSupplierSettings(): JsonResponse
|
||||
{
|
||||
return ApiResponse::handle(function () {
|
||||
$settings = $this->tenantSettingService->getByGroup(self::SUPPLIER_GROUP);
|
||||
|
||||
$result = [];
|
||||
foreach (self::SUPPLIER_KEYS as $key) {
|
||||
$result[$key] = $settings[$key] ?? null;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}, __('message.fetched'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 공급자 설정 저장
|
||||
*/
|
||||
public function saveSupplierSettings(Request $request): JsonResponse
|
||||
{
|
||||
return ApiResponse::handle(function () use ($request) {
|
||||
$data = $request->only(self::SUPPLIER_KEYS);
|
||||
|
||||
$settings = [];
|
||||
foreach ($data as $key => $value) {
|
||||
if (in_array($key, self::SUPPLIER_KEYS)) {
|
||||
$settings[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$this->tenantSettingService->setMany(self::SUPPLIER_GROUP, $settings);
|
||||
|
||||
return $settings;
|
||||
}, __('message.updated'));
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// 분개 (Journal Entries)
|
||||
// =========================================================================
|
||||
|
||||
@@ -113,6 +113,22 @@ public function index(array $params)
|
||||
return $paginator;
|
||||
}
|
||||
|
||||
/**
|
||||
* 거래처 간단 목록 (id, name만 반환) - vendors 엔드포인트용
|
||||
*/
|
||||
public function vendors(array $params): array
|
||||
{
|
||||
$tenantId = $this->tenantId();
|
||||
$perPage = (int) ($params['per_page'] ?? 9999);
|
||||
|
||||
return Client::where('tenant_id', $tenantId)
|
||||
->where('is_active', true)
|
||||
->orderBy('name')
|
||||
->limit($perPage)
|
||||
->get(['id', 'name'])
|
||||
->toArray();
|
||||
}
|
||||
|
||||
/** 단건 */
|
||||
public function show(int $id)
|
||||
{
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
*/
|
||||
|
||||
use App\Http\Controllers\Api\V1\AccountSubjectController;
|
||||
use App\Http\Controllers\Api\V1\ClientController;
|
||||
use App\Http\Controllers\Api\V1\BadDebtController;
|
||||
use App\Http\Controllers\Api\V1\BankAccountController;
|
||||
use App\Http\Controllers\Api\V1\BankTransactionController;
|
||||
@@ -158,6 +159,9 @@
|
||||
Route::post('/{id}/settle', [LoanController::class, 'settle'])->whereNumber('id')->name('v1.loans.settle');
|
||||
});
|
||||
|
||||
// Vendors API (거래처 간단 목록 - 분개 등에서 사용)
|
||||
Route::get('vendors', [ClientController::class, 'vendors'])->name('v1.vendors.index');
|
||||
|
||||
// Vendor Ledger API (거래처원장)
|
||||
Route::prefix('vendor-ledger')->group(function () {
|
||||
Route::get('', [VendorLedgerController::class, 'index'])->name('v1.vendor-ledger.index');
|
||||
@@ -364,6 +368,8 @@
|
||||
Route::get('', [TaxInvoiceController::class, 'index'])->name('v1.tax-invoices.index');
|
||||
Route::post('', [TaxInvoiceController::class, 'store'])->name('v1.tax-invoices.store');
|
||||
Route::get('/summary', [TaxInvoiceController::class, 'summary'])->name('v1.tax-invoices.summary');
|
||||
Route::get('/supplier-settings', [TaxInvoiceController::class, 'getSupplierSettings'])->name('v1.tax-invoices.supplier-settings.show');
|
||||
Route::put('/supplier-settings', [TaxInvoiceController::class, 'saveSupplierSettings'])->name('v1.tax-invoices.supplier-settings.update');
|
||||
Route::get('/{id}', [TaxInvoiceController::class, 'show'])->whereNumber('id')->name('v1.tax-invoices.show');
|
||||
Route::put('/{id}', [TaxInvoiceController::class, 'update'])->whereNumber('id')->name('v1.tax-invoices.update');
|
||||
Route::delete('/{id}', [TaxInvoiceController::class, 'destroy'])->whereNumber('id')->name('v1.tax-invoices.destroy');
|
||||
|
||||
Reference in New Issue
Block a user