Fix government leasehold income routing and refund decimal-place rejection#17
Merged
Merged
Conversation
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>
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.
This branch carries two related
TreasuryEconomyProviderfixes.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.resolveRecipientAccountpreferred 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:
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 adoublewith arbitrary precision (e.g.12.3456).transferpassed that straight through viaBigDecimal.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
BigDecimalfor Treasury β so refunds and any other arithmetically-derived amount (e.g. prorated tax) are covered in one place:Tests
legacyGovernment_withPersonalAndGovernmentAccount_routesToGovernmentβ owner with both PERSONAL + GOVERNMENT routes to GOVERNMENT.landlordWithFirm_routesToPersonalNotBusinessstill passes (no government account β PERSONAL).50.0vs the provider's normalised50.00), which was failing all four cases../gradlew :realty-paper:test --tests "*TreasuryEconomyProviderTest"β 4 passed, 0 failed.π€ Generated with Claude Code