fix: [finance] 계정별원장 분리 카드거래 원본 전표 중복 제외

This commit is contained in:
김보곤
2026-03-19 22:43:16 +09:00
parent 740c2d4a9d
commit 53b54593cb

View File

@@ -76,6 +76,24 @@ public function list(Request $request): JsonResponse
->orderBy('je.entry_date')
->get();
// 분리 전표가 있는 원본 카드 전표 제외 (중복 방지)
$splitBaseKeys = $allLines
->filter(fn ($l) => $l->source_type === 'ecard_transaction' && $l->source_key && str_contains($l->source_key, '|split:'))
->map(fn ($l) => explode('|split:', $l->source_key)[0])
->unique()
->all();
if (! empty($splitBaseKeys)) {
$allLines = $allLines->filter(function ($l) use ($splitBaseKeys) {
if ($l->source_type !== 'ecard_transaction' || ! $l->source_key) {
return true;
}
// 분리 전표가 존재하면 원본(non-split) 전표는 제외
return str_contains($l->source_key, '|split:') || ! in_array($l->source_key, $splitBaseKeys);
})->values();
}
// 카드거래 상세 조회
$cardTxMap = $this->fetchCardTransactions($tenantId, $allLines);