@@ -61,6 +61,7 @@ type Transaction = {
6161 accountOutId : number | null
6262 isFixed : boolean
6363 memo : string | null
64+ counterparty : string | null
6465 installmentId : number | null
6566 createdBy : number | null
6667 createdAt : string | null
@@ -185,6 +186,7 @@ function TransactionsPage() {
185186 const [ accountInId , setAccountInId ] = useState ( '' )
186187 const [ accountOutId , setAccountOutId ] = useState ( '' )
187188 const [ memo , setMemo ] = useState ( '' )
189+ const [ counterparty , setCounterparty ] = useState ( '' )
188190 const [ isFixed , setIsFixed ] = useState ( false )
189191 const [ submitting , setSubmitting ] = useState ( false )
190192
@@ -397,6 +399,7 @@ function TransactionsPage() {
397399 setAccountInId ( '' )
398400 setAccountOutId ( '' )
399401 setMemo ( '' )
402+ setCounterparty ( '' )
400403 setIsFixed ( false )
401404 setTab ( 'EXPENSE' )
402405 setEditingTransactionId ( null )
@@ -435,6 +438,7 @@ function TransactionsPage() {
435438 setTransactionDate ( tx . transactionDate )
436439 setAmount ( String ( tx . amount ) )
437440 setMemo ( tx . memo ?? '' )
441+ setCounterparty ( tx . counterparty ?? '' )
438442 setIsFixed ( ! ! tx . isFixed )
439443
440444 if ( tx . type === 'INCOME' ) {
@@ -479,8 +483,10 @@ function TransactionsPage() {
479483
480484 if ( editingTransactionId ) {
481485 body . memo = memo . trim ( ) ? memo . trim ( ) : null
486+ body . counterparty = tab === 'EXPENSE' && counterparty . trim ( ) ? counterparty . trim ( ) : null
482487 } else {
483488 body . memo = memo . trim ( ) || undefined
489+ if ( tab === 'EXPENSE' ) body . counterparty = counterparty . trim ( ) || undefined
484490 }
485491
486492 if ( tab === 'INCOME' ) {
@@ -627,7 +633,11 @@ function TransactionsPage() {
627633 const getTransactionPreview = ( tx : Transaction ) => {
628634 const isTransfer = isTransferType ( tx . type )
629635 const typeLabel = getTransactionTypeLabel ( tx . type )
630- const memoText = tx . memo ?. trim ( ) ?? ''
636+ const rawMemo = tx . memo ?. trim ( ) ?? ''
637+ const counterpartyText = tx . counterparty ?. trim ( ) ?? ''
638+ const memoText = rawMemo && counterpartyText
639+ ? `${ rawMemo } (${ counterpartyText } )`
640+ : rawMemo || counterpartyText
631641
632642 const categoryLabel = tx . categoryId
633643 ? ( categoryNameById . get ( tx . categoryId ) ?? '알 수 없는 카테고리' )
@@ -675,9 +685,10 @@ function TransactionsPage() {
675685 const kw = debouncedKeyword . trim ( ) . toLowerCase ( )
676686 result = result . filter ( ( tx ) => {
677687 const memoMatch = tx . memo ?. toLowerCase ( ) . includes ( kw ) ?? false
688+ const counterpartyMatch = tx . counterparty ?. toLowerCase ( ) . includes ( kw ) ?? false
678689 const categoryName = tx . categoryId ? ( categoryNameById . get ( tx . categoryId ) ?? '' ) : ''
679690 const categoryMatch = categoryName . toLowerCase ( ) . includes ( kw )
680- return memoMatch || categoryMatch
691+ return memoMatch || counterpartyMatch || categoryMatch
681692 } )
682693 }
683694
@@ -1716,6 +1727,13 @@ function TransactionsPage() {
17161727 </ div >
17171728 ) : null }
17181729
1730+ { tx . counterparty ?. trim ( ) ? (
1731+ < div className = "flex items-baseline justify-between" >
1732+ < span className = "text-sm text-muted-foreground" > 거래처</ span >
1733+ < span className = "text-sm" > { tx . counterparty } </ span >
1734+ </ div >
1735+ ) : null }
1736+
17191737 { tx . createdAt ? (
17201738 < div className = "flex items-baseline justify-between" >
17211739 < span className = "text-sm text-muted-foreground" > 등록일시</ span >
@@ -1789,7 +1807,7 @@ function TransactionsPage() {
17891807 < button
17901808 key = { item }
17911809 type = "button"
1792- onClick = { ( ) => setTab ( item ) }
1810+ onClick = { ( ) => { setTab ( item ) ; if ( item !== 'EXPENSE' ) setCounterparty ( '' ) } }
17931811 aria-pressed = { tab === item }
17941812 className = { `rounded-md px-3 py-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 ${ tab === item ? 'bg-primary text-primary-foreground' : 'border' } ` }
17951813 >
@@ -1922,6 +1940,18 @@ function TransactionsPage() {
19221940 ) : null }
19231941 </ div >
19241942
1943+ { tab === 'EXPENSE' ? (
1944+ < input
1945+ value = { counterparty }
1946+ onChange = { ( e ) => setCounterparty ( e . target . value ) }
1947+ placeholder = "거래처 (선택)"
1948+ className = "h-11 w-full rounded-md border bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
1949+ aria-label = "거래처"
1950+ autoComplete = "off"
1951+ maxLength = { 100 }
1952+ />
1953+ ) : null }
1954+
19251955 < label className = "flex items-center gap-2 text-sm" >
19261956 < input type = "checkbox" checked = { isFixed } onChange = { ( e ) => setIsFixed ( e . target . checked ) } />
19271957 고정 여부
0 commit comments