Repository navigation
fix: 訂閱改回啟用中時,當期已開繳就立刻補開帳單 - #60
Merged
Merged
Conversation
實際案例(2026-10):已取消的訂閱在月中被後台改回 active,但編輯不會開帳單; 整個月沒有這張單,催繳自然找不到。直到成員按「繳費」,ensureCurrentPeriodRows 才補開當期帳單,管理員這時才發現。 - 新增 ensureReactivatedPeriodPayment:只補「目前收款期」(與 Discord 繳費流程同一套 periodForBillingDay),且該期已開繳才補;未開繳交給發起繳費 - 後台編輯 cancelled/paused → active 時呼叫,回傳 reactivated_bill,後台顯示提示 - 匯入名單重新啟用 paused 訂閱時也呼叫(同類問題) - 編輯時改用訂閱自己的 workspace_id
poterpan
force-pushed
the
fix/reactivate-opens-bill
branch
from
November 24, 2026 05:28
35e0d0e to
ab0abc3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
問題
自架使用者回報:10 月中把一筆已取消的訂閱在後台改回啟用中,系統整個 10 月都沒有催繳;直到 10/31 成員按了 Discord「繳費」,10 月的帳單才突然出現。
根因:
updateSubscription)只改狀態,不會開帳單,所以這段期間根本沒有帳單,催繳當然找不到。ensureCurrentPeriodRows補開,或者管理員按「重新同步此期帳單」。修法
ensureReactivatedPeriodPayment:只補目前收款期的帳單,用的是跟 Discord 繳費流程相同的periodForBillingDay。而且只有在該期已開繳時才補,還沒開繳的期別交給「發起繳費」處理。帳單沿用ensurePeriodPayment,重複執行不會多開。reactivated_bill,後台會顯示「已恢復訂閱,並補開 YYYY-MM 帳單」。workspace_id。不會補開訂閱原本起算月的帳單,避免在早已結束的期別開出新帳單。這條規則原本的測試還在。
驗證
test/core/reactivate-bill.test.ts是新加的。涵蓋:已開繳時補當期、未開繳時不補、重複切換不會多開、本來就是啟用中的編輯不會開單、匯入重新啟用時補當期。跟 #59 的關係
兩個 PR 都改到
updateSubscription,後合併的那個要 rebase。