feat(payroll-scheduler): wire scheduler UI to a real backend cron pip… - #51
Open
Mrwicks00 wants to merge 1 commit into
Open
feat(payroll-scheduler): wire scheduler UI to a real backend cron pip…#51Mrwicks00 wants to merge 1 commit into
Mrwicks00 wants to merge 1 commit into
Conversation
…eline Adds the missing /api/schedules backend (migration, service, controller, routes) plus a BullMQ-driven dispatcher that fires bulk_payment.execute_batch on-chain via a new server-side Soroban invocation utility, signed by a service keypair (mirroring the existing ORGUSD_DISTRIBUTION_SECRET pattern). Connects the previously orphaned SchedulingWizard/CountdownTimer components and a new PayrollScheduler page to this API, with live countdowns and immediate cancellation.
Mrwicks00
force-pushed
the
feat/43-payroll-scheduler-backend-wiring
branch
from
July 29, 2026 22:50
22b715b to
77d45c2
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.
Title:
feat(payroll-scheduler): wire scheduler UI to a real backend cron pipeline (#081)
Body:
Summary
/api/schedulesbackend from scratch: migration (payroll_schedules+payroll_schedule_runs), service (PayrollScheduleService), controller, and routes (POST /api/schedules,GET /api/schedules,DELETE /api/schedules/:id), all scoped by the JWT-derivedorganizationId(unlike a couple of sibling payroll routes in this codebase, this one actually wiresauthenticateJWT).sorobanContractService.ts— a server-side Soroban simulate/sign/submit utility (there was previously no backend code anywhere that invoked a Soroban contract; the existing payroll worker only signs classic StellarOperation.payments).payrollScheduleQueueService.ts+payrollScheduleWorker.ts, ticking every 60s) that finds due schedules and firesbulk_payment.execute_batchon-chain, signed by a service keypair read from a newBULK_PAYMENT_SENDER_SECRETenv var — mirroring the existingORGUSD_DISTRIBUTION_SECRETpattern already in production use for classic payments (per your call on the signing-custody question).SchedulingWizard.tsx/CountdownTimer.tsxcomponents (zero API calls, not rendered anywhere) and a brand-newsrc/pages/PayrollScheduler.tsx(no such page existed — only an unrelated, unusedupstream_PayrollScheduler.tsxscaffold at the repo root) into a real flow: create → persists viaPOST /api/schedules→ listed with a liveCountdownTimerdriven by the server'snext_run_at→ cancel callsDELETE /api/schedules/:idand removes it from the list immediately.SchedulingWizardgained a required "Token Contract Address" field and a per-recipient wallet-address input (previously mockname/amount/currencyonly) sincebulk_payment.execute_batchneeds real addresses and a token contract to execute.Acceptance criteria
POST /api/schedulesand persists config.DELETE /api/schedules/:idand updates UI immediately.next_run_attimestamp.bulk_paymentcontract invocation at the scheduled time.Known limitations (called out explicitly, not silently glossed over)
execute_batchbatch limit) — schedules with more recipients fail loudly with a clear error rather than attempting fragile multi-call sequence chaining. Documented as a scope limit, not a bug.DECIMAL(20, 7)convention for payroll amounts elsewhere.BULK_PAYMENT_SENDER_SECRETaccount, a reachable Redis instance for BullMQ, and thebulk_paymentcontract registered in the contract registry for the target network. None of that could be exercised here — correctness is covered by unit/controller tests instead (see below), plus a manual dev-server pass with the backend unavailable (graceful error states, no crashes).Test plan
payrollScheduleService.test.ts(6 cases coveringcomputeNextRunAtfor weekly/biweekly/monthly, including rollover-when-already-passed and default-day edge cases) andpayrollScheduleController.test.ts(7 cases: create/list/cancel happy paths, invalid frequency, empty recipients, cross-org 404, missing schedule 404) — 13/13 pass.paymentSchedule.test.ts(5 cases: create/list/cancel, auth header attachment, server-error propagation) andPayrollScheduler.test.tsx(4 cases: renders schedules with countdown, error state, cancel removes a row immediately, wizard create flow) — 9/9 pass; full suite 15/15.npx tsc -b(frontend) andnpx tsc --noEmit(backend) — clean; confirmed viagit stashthat the backend's pre-existing ~56 type errors are unrelated to this change (they exist onmaintoo, in files this PR never touches).npx eslinton all changed frontend files — clean (backend'snpm run lintis broken pre-existing onmain, ignoring every file including untouched ones — not something this PR introduced or fixes)./payroll-schedulerin the dev server (headless Chrome + screenshots): nav link renders and highlights correctly, page shows a graceful "Failed to fetch"/empty state with no backend running, wizard opens with the new Token Contract Address field, no console page errors.Closes #43