- account_entry에 currency/original_amount/exchange_rate 컬럼 추가(멱등 ALTER)
amount는 환산 원화(표준값) 유지 → 통계·예산 무변경
- AccountEntry/Request/Response·매퍼·서비스에 외화 필드 전달
- FxService(open.er-api.com 무료·무인증, 통화별 일자 캐시) + FxController
GET /api/fx/rate?from=USD&to=KRW → { from, to, rate }
- WebConfig: /api/fx/** 인증 보호
- (.gitignore: 로컬 시드 스크립트 제외 규칙)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -59,6 +59,10 @@ ALTER TABLE account_entry ADD COLUMN IF NOT EXISTS installment_months INT NULL;
|
||||
ALTER TABLE account_entry ADD COLUMN IF NOT EXISTS pending TINYINT(1) NOT NULL DEFAULT 0 COMMENT '확인 필요(미확정) 여부';
|
||||
ALTER TABLE account_entry ADD COLUMN IF NOT EXISTS notif_key VARCHAR(160) NULL COMMENT '알림 자동인식 중복방지 키';
|
||||
ALTER TABLE account_entry ADD INDEX IF NOT EXISTS idx_entry_notif (member_id, notif_key);
|
||||
-- 외화 결제: amount 는 환산된 원화(표준값, 통계·예산은 이 값 사용). 아래는 외화 원본 보존용.
|
||||
ALTER TABLE account_entry ADD COLUMN IF NOT EXISTS currency VARCHAR(3) NULL COMMENT '통화코드(USD/JPY 등). NULL/KRW=원화';
|
||||
ALTER TABLE account_entry ADD COLUMN IF NOT EXISTS original_amount DECIMAL(18,2) NULL COMMENT '외화 원본 금액';
|
||||
ALTER TABLE account_entry ADD COLUMN IF NOT EXISTS exchange_rate DECIMAL(18,6) NULL COMMENT '적용 환율(외화 1단위→원화)';
|
||||
|
||||
-- 가계부 태그 (사용자별 관리 — 게시판 태그와 분리)
|
||||
CREATE TABLE IF NOT EXISTS account_tag (
|
||||
|
||||
@@ -18,6 +18,9 @@
|
||||
<result property="installmentMonths" column="installment_months"/>
|
||||
<result property="pending" column="pending"/>
|
||||
<result property="notifKey" column="notif_key"/>
|
||||
<result property="currency" column="currency"/>
|
||||
<result property="originalAmount" column="original_amount"/>
|
||||
<result property="exchangeRate" column="exchange_rate"/>
|
||||
<result property="createdAt" column="created_at"/>
|
||||
<result property="updatedAt" column="updated_at"/>
|
||||
</resultMap>
|
||||
@@ -32,6 +35,7 @@
|
||||
e.wallet_id, w.name AS wallet_name,
|
||||
e.to_wallet_id, tw.name AS to_wallet_name,
|
||||
e.installment_months, e.pending, e.notif_key,
|
||||
e.currency, e.original_amount, e.exchange_rate,
|
||||
e.created_at, e.updated_at
|
||||
</sql>
|
||||
<sql id="entryJoins">
|
||||
@@ -141,17 +145,20 @@
|
||||
useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO account_entry (member_id, entry_date, type, category, amount, memo,
|
||||
wallet_id, to_wallet_id, installment_months, pending, notif_key,
|
||||
currency, original_amount, exchange_rate,
|
||||
created_at, updated_at)
|
||||
VALUES (#{memberId}, #{entryDate}, #{type}, #{category}, #{amount}, #{memo},
|
||||
#{walletId}, #{toWalletId}, #{installmentMonths},
|
||||
COALESCE(#{pending}, 0), #{notifKey}, NOW(), NOW())
|
||||
COALESCE(#{pending}, 0), #{notifKey},
|
||||
#{currency}, #{originalAmount}, #{exchangeRate}, 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},
|
||||
installment_months = #{installmentMonths}
|
||||
installment_months = #{installmentMonths},
|
||||
currency = #{currency}, original_amount = #{originalAmount}, exchange_rate = #{exchangeRate}
|
||||
WHERE id = #{id} AND member_id = #{memberId}
|
||||
</update>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user