feat: 투자 소수점 매매 + 카드 할부(installment_months)
CI / build (push) Failing after 13m58s

- invest_trade.quantity BIGINT→DECIMAL(18,6): 평단·원가·평가/실현손익 계산을 BigDecimal로 전환 (금액은 원단위 정수 유지)
- account_entry.installment_months 추가: 카드 지출 2~24개월 할부 기록(일시불 null), 응답에 포함

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
ByungCheol
2026-06-03 16:41:58 +09:00
parent f5e9b78a14
commit bd0a0f7776
11 changed files with 79 additions and 28 deletions
+6 -1
View File
@@ -39,6 +39,7 @@ CREATE TABLE IF NOT EXISTS account_entry (
memo VARCHAR(255) NULL,
wallet_id BIGINT NULL COMMENT '발생/출금 계좌(wallet.id)',
to_wallet_id BIGINT NULL COMMENT '이체 입금 계좌(TRANSFER)',
installment_months INT NULL COMMENT '카드 할부 개월수(2~24, 일시불은 NULL)',
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (id),
@@ -48,6 +49,7 @@ CREATE TABLE IF NOT EXISTS account_entry (
-- 기존 account_entry 컬럼 추가 (멱등)
ALTER TABLE account_entry ADD COLUMN IF NOT EXISTS wallet_id BIGINT NULL;
ALTER TABLE account_entry ADD COLUMN IF NOT EXISTS to_wallet_id BIGINT NULL;
ALTER TABLE account_entry ADD COLUMN IF NOT EXISTS installment_months INT NULL;
-- 가계부 태그 (사용자별 관리 — 게시판 태그와 분리)
CREATE TABLE IF NOT EXISTS account_tag (
@@ -155,7 +157,7 @@ CREATE TABLE IF NOT EXISTS invest_trade (
holding_id BIGINT NOT NULL COMMENT 'invest_holding.id',
trade_type VARCHAR(10) NOT NULL COMMENT 'BUY / SELL',
trade_date DATE NOT NULL,
quantity BIGINT NOT NULL COMMENT '수량(주)',
quantity DECIMAL(18,6) NOT NULL COMMENT '수량(주, 소수점 매매 지원)',
price BIGINT NOT NULL COMMENT '단가(원)',
fee BIGINT NOT NULL DEFAULT 0 COMMENT '수수료/세금(원)',
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
@@ -163,3 +165,6 @@ CREATE TABLE IF NOT EXISTS invest_trade (
KEY idx_trade_member_holding (member_id, holding_id),
KEY idx_trade_date (holding_id, trade_date, id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- 소수점 매매(예: 해외주식 소수점 매수) 지원: 기존 BIGINT → DECIMAL
ALTER TABLE invest_trade MODIFY COLUMN quantity DECIMAL(18,6) NOT NULL COMMENT '수량(주, 소수점 매매 지원)';
@@ -15,6 +15,7 @@
<result property="walletName" column="wallet_name"/>
<result property="toWalletId" column="to_wallet_id"/>
<result property="toWalletName" column="to_wallet_name"/>
<result property="installmentMonths" column="installment_months"/>
<result property="createdAt" column="created_at"/>
<result property="updatedAt" column="updated_at"/>
</resultMap>
@@ -28,6 +29,7 @@
e.id, e.member_id, e.entry_date, e.type, e.category, e.amount, e.memo,
e.wallet_id, w.name AS wallet_name,
e.to_wallet_id, tw.name AS to_wallet_name,
e.installment_months,
e.created_at, e.updated_at
</sql>
<sql id="entryJoins">
@@ -125,15 +127,16 @@
<insert id="insert" parameterType="com.sb.web.account.domain.AccountEntry"
useGeneratedKeys="true" keyProperty="id">
INSERT INTO account_entry (member_id, entry_date, type, category, amount, memo,
wallet_id, to_wallet_id, created_at, updated_at)
wallet_id, to_wallet_id, installment_months, created_at, updated_at)
VALUES (#{memberId}, #{entryDate}, #{type}, #{category}, #{amount}, #{memo},
#{walletId}, #{toWalletId}, NOW(), NOW())
#{walletId}, #{toWalletId}, #{installmentMonths}, NOW(), NOW())
</insert>
<update id="update" parameterType="com.sb.web.account.domain.AccountEntry">
UPDATE account_entry
SET entry_date = #{entryDate}, type = #{type}, category = #{category},
amount = #{amount}, memo = #{memo}, wallet_id = #{walletId}, to_wallet_id = #{toWalletId}
amount = #{amount}, memo = #{memo}, wallet_id = #{walletId}, to_wallet_id = #{toWalletId},
installment_months = #{installmentMonths}
WHERE id = #{id} AND member_id = #{memberId}
</update>