- BankTransactionOverride 모델 추가 (오버라이드 데이터 관리) - EaccountController에 saveOverride 엔드포인트 추가 - parseTransactionLogs에서 오버라이드 데이터 병합 로직 추가 - 프론트엔드에 TransactionEditModal 컴포넌트 추가 - 적요 셀 클릭 시 수정 모달 표시 - 오버라이드된 항목 시각적 표시 (배경색, 수정 배지) - 원본 복원 기능 포함 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
81 lines
2.0 KiB
PHP
81 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Barobill;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Support\Collection;
|
|
|
|
/**
|
|
* 바로빌 계좌 거래내역 적요/내용 수정 오버라이드 모델
|
|
*/
|
|
class BankTransactionOverride extends Model
|
|
{
|
|
protected $table = 'barobill_bank_transaction_overrides';
|
|
|
|
protected $fillable = [
|
|
'tenant_id',
|
|
'unique_key',
|
|
'modified_summary',
|
|
'modified_cast',
|
|
];
|
|
|
|
/**
|
|
* 테넌트별 조회 스코프
|
|
*/
|
|
public function scopeForTenant($query, int $tenantId)
|
|
{
|
|
return $query->where('tenant_id', $tenantId);
|
|
}
|
|
|
|
/**
|
|
* 고유키로 조회
|
|
*/
|
|
public function scopeByUniqueKey($query, string $uniqueKey)
|
|
{
|
|
return $query->where('unique_key', $uniqueKey);
|
|
}
|
|
|
|
/**
|
|
* 여러 고유키에 대한 오버라이드 조회
|
|
* @return Collection<string, self> key가 unique_key인 컬렉션
|
|
*/
|
|
public static function getByUniqueKeys(int $tenantId, array $uniqueKeys): Collection
|
|
{
|
|
if (empty($uniqueKeys)) {
|
|
return collect();
|
|
}
|
|
|
|
return static::forTenant($tenantId)
|
|
->whereIn('unique_key', $uniqueKeys)
|
|
->get()
|
|
->keyBy('unique_key');
|
|
}
|
|
|
|
/**
|
|
* 오버라이드 저장 또는 업데이트
|
|
*/
|
|
public static function saveOverride(
|
|
int $tenantId,
|
|
string $uniqueKey,
|
|
?string $modifiedSummary,
|
|
?string $modifiedCast
|
|
): ?self {
|
|
// 둘 다 null이거나 빈 문자열이면 기존 레코드 삭제
|
|
if (empty($modifiedSummary) && empty($modifiedCast)) {
|
|
static::forTenant($tenantId)->byUniqueKey($uniqueKey)->delete();
|
|
return null;
|
|
}
|
|
|
|
return static::updateOrCreate(
|
|
[
|
|
'tenant_id' => $tenantId,
|
|
'unique_key' => $uniqueKey,
|
|
],
|
|
[
|
|
'modified_summary' => $modifiedSummary ?: null,
|
|
'modified_cast' => $modifiedCast ?: null,
|
|
]
|
|
);
|
|
}
|
|
}
|