Skip to content

feat(billing): billing-day shifter (closes #2252) - #2320

Merged
github-actions[bot] merged 1 commit into
Smartdevs17:mainfrom
IVANLI2412:fix/issue-2252-billing-shift
Nov 24, 2026
Merged

github-actions[bot] merged 1 commit into
Smartdevs17:mainfrom
IVANLI2412:fix/issue-2252-billing-shift

Conversation

@IVANLI2412

Copy link
Copy Markdown
Contributor

Closes #2252

Summary

Builds a billing-day shifter that consolidates subscription charges onto a chosen weekday (Monday by default). Two fresh, zero-dependency modules:

  • backend/src/services/billingShift.ts — pure canonical shifter: typed BillingShiftError surface (INVALID_CONFIG/INVALID_INPUT/INVALID_DATE/INVALID_WEEKDAY/SHIFT_EXCEEDED/INVALID_SUBSCRIPTION), config validation (targetWeekday, maxShiftDays, timezoneOffsetMinutes, allowBackward), forward/backward weekday alignment, bounded shifts, daysBetween, nextBillingDate, and a createBillingShifter factory that plans batches with metrics/logger hooks.
  • workers/src/jobs/billingShift.ts — job adapter that groups shifted charges into deterministic per-day batches (billing-shift:YYYY-MM-DD), sorts by id, and freezes results.

Tests

  • backend/src/services/__tests__/billingShift.test.ts — 16 jest tests (weekday/config validation, shift same/forward/backward, SHIFT_EXCEEDED, invalid dates, daysBetween, nextBillingDate, metrics + plan/rejection).
  • workers/src/jobs/__tests__/billingShift.test.ts — 5 jest tests (batch key determinism, grouping/sorting, full job run, empty list).

Verification

  • Node-26 type-stripping harness against the real source: 21 passed, 0 failed.
  • tools/check_secrets.py: [OK] — SECRETS_EXIT=0.

Payouts

  • Base Mainnet (USDC/ETH): 0xC5dD2Ea54FF138bb3f71D3466092eA31eF115868
  • Solana (USDC/SOL): DN3pfYEvdkoTBP4oaEVvemsr98fZPhDSAbfVfmewRGQ5
  • PayPal: ivanzenteno3@gmail.com

@github-actions
github-actions Bot merged commit 091a123 into Smartdevs17:main Nov 24, 2026
7 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build billing-day shifter to consolidate charges on a chosen weekday

1 participant