Skip to content

fix(payout): keep rotation index correct when an earlier member leaves - #379

Open
oladipupox21 wants to merge 2 commits into
Rotula-Labs:mainfrom
oladipupox21:fix/issue-266-fix-payout-keep-the-rotation-index-correct-when
Open

oladipupox21 wants to merge 2 commits into
Rotula-Labs:mainfrom
oladipupox21:fix/issue-266-fix-payout-keep-the-rotation-index-correct-when

Conversation

@oladipupox21

Copy link
Copy Markdown

Overview

This PR fixes the rotation index handling in removeMemberFromOrder so that a departing member no longer causes the next-due member to be skipped. Instead of clamping the index, it now shifts the index by the departing member's position relative to the cursor, keeping the rotation correct whether the departure is before, at, or after the current index.

Related Issue

Changes

🔁 Payout Rotation Index Fix

  • [MODIFY] src/services/payout.service.ts

    • removeMemberFromOrder now tracks the departing member's index relative to the current cursor and adjusts the cursor by that difference rather than applying Math.min(currentIndex, newOrder.length - 1).
    • A departure before the cursor shifts the index down by one so the same next member stays due.
    • A departure after the cursor leaves the index unchanged, still pointing at the same member.
    • A departure at the cursor keeps the index in place (bounded to the new order length) so the following member becomes due.
  • [MODIFY] src/__tests__/payout.service.test.ts

    • Added coverage for a departure before, at, and after the cursor.
    • Added a rotation test where a departure occurs in each position and every remaining member is paid exactly once.

Verification Results

npm test
✅ payout.service tests pass (including new rotation index cases)
Acceptance Criteria Status
The member due to be paid next is unchanged by an earlier member leaving ✅ Index shifts down with the removed member
A departure after the cursor leaves the index pointing at the same member ✅ Index unchanged for later departures
A rotation with a departure in each position still pays every remaining member exactly once ✅ Covered by rotation test
A test covers all three positions ✅ Before / at / after cursor cases added
npm test passes locally ✅ Passing

Closes #266

Toyosi5566 and others added 2 commits October 16, 2026 15:32
.env is read by dotenv.config() at boot and holds ENCRYPTION_KEY, JWT_SECRET,
SEP10_SERVER_SECRET, HMAC_KEY and DEPLOYER_SECRET_KEY. None of the .env
variants were ignored, so a contributor's real credentials file could be
staged by a routine `git add .` with nothing to warn anyone. Ignore the
.env variants and keep the committed example file trackable.

No .env file is tracked at HEAD and no .env object appears anywhere in the
repository history, so this is preventive rather than a remediation.
@drips-wave

drips-wave Bot commented Oct 17, 2026

Copy link
Copy Markdown

@oladipupox21 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Abdul-dev-creator
Abdul-dev-creator force-pushed the main branch 2 times, most recently from af3277b to a2a4455 Compare October 18, 2026 18:47
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.

fix(payout): keep the rotation index correct when an earlier member leaves

2 participants