feat: [계좌내역] 취급점(trans_office) override 수정 기능 추가
This commit is contained in:
@@ -642,10 +642,12 @@ private function parseTransactionLogs($resultData, string $defaultBankName = '',
|
||||
// 원본 적요/내용 (remark2를 합산하지 않음 - 상대계좌예금주명 컬럼에서 별도 표시)
|
||||
$originalSummary = $cleanSummary;
|
||||
$originalCast = $savedItem?->cast ?? $remark2;
|
||||
$originalTransOffice = $log->TransOffice ?? '';
|
||||
|
||||
// 오버라이드 적용 (수정된 값이 있으면 사용)
|
||||
$displaySummary = $override?->modified_summary ?? $originalSummary;
|
||||
$displayCast = $override?->modified_cast ?? $originalCast;
|
||||
$displayTransOffice = $override?->modified_trans_office ?? $originalTransOffice;
|
||||
|
||||
$logItem = [
|
||||
'transDate' => $transDate,
|
||||
@@ -664,7 +666,8 @@ private function parseTransactionLogs($resultData, string $defaultBankName = '',
|
||||
'cast' => $displayCast,
|
||||
'originalCast' => $originalCast,
|
||||
'memo' => $log->Memo ?? '',
|
||||
'transOffice' => $log->TransOffice ?? '',
|
||||
'transOffice' => $displayTransOffice,
|
||||
'originalTransOffice' => $originalTransOffice,
|
||||
// 저장된 계정과목 정보 병합
|
||||
'accountCode' => $savedItem?->account_code ?? '',
|
||||
'accountName' => $savedItem?->account_name ?? '',
|
||||
@@ -1505,13 +1508,15 @@ public function saveOverride(Request $request): JsonResponse
|
||||
'uniqueKey' => 'required|string|max:100',
|
||||
'modifiedSummary' => 'nullable|string|max:200',
|
||||
'modifiedCast' => 'nullable|string|max:200',
|
||||
'modifiedTransOffice' => 'nullable|string|max:200',
|
||||
]);
|
||||
|
||||
$result = BankTransactionOverride::saveOverride(
|
||||
$tenantId,
|
||||
$validated['uniqueKey'],
|
||||
$validated['modifiedSummary'] ?? null,
|
||||
$validated['modifiedCast'] ?? null
|
||||
$validated['modifiedCast'] ?? null,
|
||||
$validated['modifiedTransOffice'] ?? null
|
||||
);
|
||||
|
||||
if ($result === null) {
|
||||
@@ -1529,6 +1534,7 @@ public function saveOverride(Request $request): JsonResponse
|
||||
'id' => $result->id,
|
||||
'modifiedSummary' => $result->modified_summary,
|
||||
'modifiedCast' => $result->modified_cast,
|
||||
'modifiedTransOffice' => $result->modified_trans_office,
|
||||
],
|
||||
]);
|
||||
} catch (\Throwable $e) {
|
||||
|
||||
@@ -17,6 +17,7 @@ class BankTransactionOverride extends Model
|
||||
'unique_key',
|
||||
'modified_summary',
|
||||
'modified_cast',
|
||||
'modified_trans_office',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -76,10 +77,11 @@ public static function saveOverride(
|
||||
int $tenantId,
|
||||
string $uniqueKey,
|
||||
?string $modifiedSummary,
|
||||
?string $modifiedCast
|
||||
?string $modifiedCast,
|
||||
?string $modifiedTransOffice = null
|
||||
): ?self {
|
||||
// 둘 다 null이거나 빈 문자열이면 기존 레코드 삭제
|
||||
if (empty($modifiedSummary) && empty($modifiedCast)) {
|
||||
// 모두 null이거나 빈 문자열이면 기존 레코드 삭제
|
||||
if (empty($modifiedSummary) && empty($modifiedCast) && empty($modifiedTransOffice)) {
|
||||
static::forTenant($tenantId)->byUniqueKey($uniqueKey)->delete();
|
||||
|
||||
return null;
|
||||
@@ -93,6 +95,7 @@ public static function saveOverride(
|
||||
[
|
||||
'modified_summary' => $modifiedSummary ?: null,
|
||||
'modified_cast' => $modifiedCast ?: null,
|
||||
'modified_trans_office' => $modifiedTransOffice ?: null,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -744,6 +744,7 @@ className="px-6 py-2 bg-stone-600 text-white rounded-lg hover:bg-stone-700 font-
|
||||
const TransactionEditModal = ({ isOpen, onClose, log, onSave }) => {
|
||||
const [modifiedSummary, setModifiedSummary] = useState('');
|
||||
const [modifiedCast, setModifiedCast] = useState('');
|
||||
const [modifiedTransOffice, setModifiedTransOffice] = useState('');
|
||||
const [saving, setSaving] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -751,6 +752,7 @@ className="px-6 py-2 bg-stone-600 text-white rounded-lg hover:bg-stone-700 font-
|
||||
// 현재 표시되는 값으로 초기화 (수정된 값이 있으면 그 값, 없으면 원본)
|
||||
setModifiedSummary(log.summary || '');
|
||||
setModifiedCast(log.cast || '');
|
||||
setModifiedTransOffice(log.transOffice || '');
|
||||
}
|
||||
}, [isOpen, log]);
|
||||
|
||||
@@ -772,13 +774,14 @@ className="px-6 py-2 bg-stone-600 text-white rounded-lg hover:bg-stone-700 font-
|
||||
uniqueKey: log.uniqueKey,
|
||||
modifiedSummary: modifiedSummary !== log.originalSummary ? modifiedSummary : null,
|
||||
modifiedCast: modifiedCast !== log.originalCast ? modifiedCast : null,
|
||||
modifiedTransOffice: modifiedTransOffice !== log.originalTransOffice ? modifiedTransOffice : null,
|
||||
}),
|
||||
});
|
||||
|
||||
const data = await res.json();
|
||||
if (data.success) {
|
||||
notify(data.message, 'success');
|
||||
onSave(modifiedSummary, modifiedCast);
|
||||
onSave(modifiedSummary, modifiedCast, modifiedTransOffice);
|
||||
onClose();
|
||||
} else {
|
||||
notify(data.error || '저장 실패', 'error');
|
||||
@@ -805,13 +808,14 @@ className="px-6 py-2 bg-stone-600 text-white rounded-lg hover:bg-stone-700 font-
|
||||
uniqueKey: log.uniqueKey,
|
||||
modifiedSummary: null,
|
||||
modifiedCast: null,
|
||||
modifiedTransOffice: null,
|
||||
}),
|
||||
});
|
||||
|
||||
const data = await res.json();
|
||||
if (data.success) {
|
||||
notify('원본으로 복원되었습니다.', 'success');
|
||||
onSave(log.originalSummary, log.originalCast);
|
||||
onSave(log.originalSummary, log.originalCast, log.originalTransOffice);
|
||||
onClose();
|
||||
} else {
|
||||
notify(data.error || '복원 실패', 'error');
|
||||
@@ -895,6 +899,25 @@ className="w-full px-3 py-2 border border-stone-200 rounded-lg text-sm focus:rin
|
||||
<p className="mt-1 text-xs text-stone-400">원본: {log.originalCast}</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-stone-700 mb-1">
|
||||
취급점
|
||||
{log.isOverridden && log.originalTransOffice !== modifiedTransOffice && (
|
||||
<span className="ml-2 text-xs text-amber-600">(수정됨)</span>
|
||||
)}
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
value={modifiedTransOffice}
|
||||
onChange={(e) => setModifiedTransOffice(e.target.value)}
|
||||
className="w-full px-3 py-2 border border-stone-200 rounded-lg text-sm focus:ring-2 focus:ring-emerald-500 outline-none"
|
||||
placeholder="취급점 입력"
|
||||
/>
|
||||
{log.originalTransOffice && modifiedTransOffice !== log.originalTransOffice && (
|
||||
<p className="mt-1 text-xs text-stone-400">원본: {log.originalTransOffice}</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Footer */}
|
||||
@@ -2101,7 +2124,7 @@ className="p-1 text-red-500 hover:bg-red-50 rounded transition-colors"
|
||||
}, []);
|
||||
|
||||
// 오버라이드 저장 후 로그 업데이트
|
||||
const handleSaveOverride = useCallback((newSummary, newCast) => {
|
||||
const handleSaveOverride = useCallback((newSummary, newCast, newTransOffice) => {
|
||||
if (editingLogIndex !== null) {
|
||||
setLogs(prevLogs => {
|
||||
const newLogs = [...prevLogs];
|
||||
@@ -2109,6 +2132,7 @@ className="p-1 text-red-500 hover:bg-red-50 rounded transition-colors"
|
||||
...newLogs[editingLogIndex],
|
||||
summary: newSummary,
|
||||
cast: newCast,
|
||||
transOffice: newTransOffice !== undefined ? newTransOffice : newLogs[editingLogIndex].transOffice,
|
||||
isOverridden: true
|
||||
};
|
||||
return newLogs;
|
||||
|
||||
Reference in New Issue
Block a user