feat(stats): 예상 지출 10일부터 노출 — 초반 표본부족 튐 방지
Deploy / deploy (push) Failing after 13m52s

경과일 < 10 이면 값 대신 '10일부터 표시돼요' 안내. 초반 소표본+일회성으로 과대 추정되던 문제 완화.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
sb
2026-07-06 02:17:38 +09:00
parent 5b46ba93f3
commit d5b4c46163
+13 -1
View File
@@ -28,6 +28,8 @@ const aiBullets = ref([]) // AI 재무 코멘트(현황 관찰)
const aiTips = ref([]) // AI 절약 가이드(실행 제안) const aiTips = ref([]) // AI 절약 가이드(실행 제안)
const forecast = ref(null) // 월말 예상 지출(결정적 계산, 일회성 큰 지출 제외) const forecast = ref(null) // 월말 예상 지출(결정적 계산, 일회성 큰 지출 제외)
const forecastNote = ref('') // 예상 지출 근거 문장 const forecastNote = ref('') // 예상 지출 근거 문장
const forecastHint = ref('') // 초반(표본 부족)엔 값 대신 안내
const FORECAST_MIN_DAYS = 10 // 이 날짜(경과일)부터 예상 지출 노출(초반 표본 부족·튐 방지)
const forecastLoading = ref(false) const forecastLoading = ref(false)
const aiLoading = ref(false) const aiLoading = ref(false)
@@ -97,11 +99,17 @@ function robustDailyRate(days) {
async function loadForecast() { async function loadForecast() {
forecast.value = null forecast.value = null
forecastNote.value = '' forecastNote.value = ''
forecastHint.value = ''
const isCurrent = year.value === now.getFullYear() && month.value === now.getMonth() + 1 const isCurrent = year.value === now.getFullYear() && month.value === now.getMonth() + 1
if (!isCurrent) return // 과거/미래 달은 추정 불필요 if (!isCurrent) return // 과거/미래 달은 추정 불필요
const totalDays = daysInMonth(year.value, month.value) const totalDays = daysInMonth(year.value, month.value)
const elapsed = now.getDate() const elapsed = now.getDate()
if (elapsed < 1) return if (elapsed < 1) return
// 초반엔 표본이 적어 추정이 크게 튀므로 일정 경과일 전에는 값 대신 안내만 표시
if (elapsed < FORECAST_MIN_DAYS) {
forecastHint.value = `${FORECAST_MIN_DAYS}일부터 표시돼요`
return
}
forecastLoading.value = true forecastLoading.value = true
try { try {
const daily = await accountApi.budgetPeriod({ unit: 'DAY', year: year.value, month: month.value }) const daily = await accountApi.budgetPeriod({ unit: 'DAY', year: year.value, month: month.value })
@@ -468,7 +476,11 @@ onMounted(async () => {
{{ expenseDelta.diff >= 0 ? '+' : '' }}{{ won(expenseDelta.diff) }}<template v-if="expenseDelta.pct !== null"> ({{ expenseDelta.pct >= 0 ? '+' : '' }}{{ expenseDelta.pct }}%)</template> {{ expenseDelta.diff >= 0 ? '+' : '' }}{{ won(expenseDelta.diff) }}<template v-if="expenseDelta.pct !== null"> ({{ expenseDelta.pct >= 0 ? '+' : '' }}{{ expenseDelta.pct }}%)</template>
</b> </b>
</div> </div>
<div v-if="forecastLoading && !forecast" class="ie-row forecast"> <div v-if="forecastHint" class="ie-row forecast">
<span>예상 지출 <small>{{ forecastHint }}</small></span>
<b class="pending"></b>
</div>
<div v-else-if="forecastLoading && !forecast" class="ie-row forecast">
<span>예상 지출 <small>계산 </small></span> <span>예상 지출 <small>계산 </small></span>
<b class="pending">···</b> <b class="pending">···</b>
</div> </div>