From 903906c8806f55db79a931355d6010e313893283 Mon Sep 17 00:00:00 2001 From: JiWoong Sul Date: Thu, 29 Jan 2026 23:55:57 +0900 Subject: [PATCH] =?UTF-8?q?fix(billing):=20=EC=9B=94=EB=B3=84=20=EB=B9=84?= =?UTF-8?q?=EC=9A=A9=20=EA=B3=84=EC=82=B0=20=EC=8B=9C=20=EC=97=B0=EB=8F=84?= =?UTF-8?q?=20=EB=AC=B4=EC=8B=9C=20=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - hasBillingInMonth()에서 targetYear를 실제로 사용하도록 수정 - 연간 구독 수정 시 잘못된 월에 비용이 포함되던 문제 해결 - 연도+월을 포함한 개월 차이 계산으로 정확한 결제 발생 여부 판단 --- lib/utils/billing_cost_util.dart | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/utils/billing_cost_util.dart b/lib/utils/billing_cost_util.dart index 6ef26a5..25e0480 100644 --- a/lib/utils/billing_cost_util.dart +++ b/lib/utils/billing_cost_util.dart @@ -214,20 +214,20 @@ class BillingCostUtil { // 결제 주기에 따른 개월 수 final cycleMonths = _getCycleMonths(normalizedCycle); - // 결제 발생 월 계산 (nextBillingDate 기준으로 역산) - final billingMonth = nextBillingDate.month; + // 연도+월을 포함한 개월 차이 계산 + // nextBillingDate와 target 월 사이의 차이가 cycleMonths의 배수인지 확인 + final targetStart = DateTime(targetYear, targetMonth, 1); + final billingStart = + DateTime(nextBillingDate.year, nextBillingDate.month, 1); - // 대상 월이 결제 발생 월과 일치하는지 확인 - // 예: 연간 결제(1월), targetMonth = 1 → true - // 예: 연간 결제(1월), targetMonth = 2 → false - for (int i = 0; i < 12; i += cycleMonths) { - final checkMonth = ((billingMonth - 1 + i) % 12) + 1; - if (checkMonth == targetMonth) { - return true; - } - } + final monthDiff = (billingStart.year - targetStart.year) * 12 + + (billingStart.month - targetStart.month); - return false; + // monthDiff가 cycleMonths의 배수이면 해당 월에 결제 발생 + // 예: 연간 결제(2027-01), target=2026-01 → monthDiff=12, 12%12=0 → true (이전 결제) + // 예: 연간 결제(2027-01), target=2026-02 → monthDiff=11, 11%12≠0 → false + // 예: 연간 결제(2027-01), target=2027-01 → monthDiff=0, 0%12=0 → true + return monthDiff % cycleMonths == 0; } /// 결제 주기별 개월 수 반환