Skip to content

Fix government leasehold income routing and refund decimal-place rejection#17

Merged
ParadauxIO merged 1 commit into
mainfrom
feature/government-leasehold-income-routing
May 31, 2026
Merged

Fix government leasehold income routing and refund decimal-place rejection#17
ParadauxIO merged 1 commit into
mainfrom
feature/government-leasehold-income-routing

Conversation

@ParadauxIO
Copy link
Copy Markdown
Contributor

@ParadauxIO ParadauxIO commented May 30, 2026

This branch carries two related TreasuryEconomyProvider fixes.


1. Route government leasehold income to the government account

Problem

The legacy plugin used real Minecraft accounts for government entities (e.g. DCGovernment). Those UUIDs own both a PERSONAL account (the original player) and the GOVERNMENT treasury account.

TreasuryEconomyProvider.resolveRecipientAccount preferred PERSONAL, so rent / sale income from government-owned leaseholds was paid into the player's personal balance instead of the government treasury. The same affected any government account with leaseholds.

Fix

Reorder recipient resolution to GOVERNMENT > PERSONAL > BUSINESS > first-available:

  • Government landlords (own a GOVERNMENT account) β†’ income routes to the government treasury.
  • Ordinary landlords have no government account β†’ still resolve to PERSONAL, so the earlier fix (rent must not leak into a firm BUSINESS account they own) is preserved.
  • No accounts β†’ resolve-or-create personal, unchanged.

2. Fix "Amount cannot have more than 2 decimal places" on refunds

Problem

Players ending a lease early hit "Failed to process refund, Amount cannot have more than 2 decimal places."

The pro-rata refund is computed as lease.price() * remainingSeconds / totalSeconds (RealtyBackendImpl), which yields a double with arbitrary precision (e.g. 12.3456). transfer passed that straight through via BigDecimal.valueOf(amount), and Treasury rejects any amount with more than 2 decimal places.

Fix

Normalise the amount to 2 decimals at the transfer boundary β€” the single choke point where every realty amount becomes a BigDecimal for Treasury β€” so refunds and any other arithmetically-derived amount (e.g. prorated tax) are covered in one place:

BigDecimal normalisedAmount = BigDecimal.valueOf(amount).setScale(2, RoundingMode.HALF_UP);

Tests

  • Added legacyGovernment_withPersonalAndGovernmentAccount_routesToGovernment β€” owner with both PERSONAL + GOVERNMENT routes to GOVERNMENT.
  • Existing landlordWithFirm_routesToPersonalNotBusiness still passes (no government account β†’ PERSONAL).
  • Fixed a pre-existing scale-sensitive amount assertion in the shared test helper (50.0 vs the provider's normalised 50.00), which was failing all four cases.

./gradlew :realty-paper:test --tests "*TreasuryEconomyProviderTest" β†’ 4 passed, 0 failed.

πŸ€– Generated with Claude Code

Legacy government entities (e.g. DCGovernment) are real Minecraft
accounts whose UUID owns both a PERSONAL account (the original player)
and the GOVERNMENT treasury account. The recipient resolver preferred
PERSONAL, so rent/sale income from government-owned leaseholds landed
in the player's personal balance instead of the government treasury.

Reorder recipient resolution to GOVERNMENT > PERSONAL > BUSINESS:
- government landlords now route income to their government account;
- ordinary landlords still get PERSONAL (no firm BUSINESS leak), since
  they have no government account.

Also fix the pre-existing scale-sensitive amount assertion in the test
helper (50.0 vs normalised 50.00) and add a regression test for the
legacy government case.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ParadauxIO ParadauxIO merged commit 8df54a2 into main May 31, 2026
1 check passed
@ParadauxIO ParadauxIO changed the title Route government leasehold income to the government account Fix government leasehold income routing and refund decimal-place rejection May 31, 2026
@ParadauxIO ParadauxIO deleted the feature/government-leasehold-income-routing branch May 31, 2026 14:26
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.

1 participant