store: Fix: dynamic roster type detection in /trade add-player (major-domo-v2 #29)

This commit is contained in:
Cal Corum 2026-03-03 00:08:11 -06:00
parent 26dcbe7df4
commit e394a40d70

View File

@ -0,0 +1,29 @@
---
id: a272cc2a-d5c8-42a5-924a-dc6009bc5c3b
type: fix
title: "Fix: dynamic roster type detection in /trade add-player (major-domo-v2 #29)"
tags: [major-domo, discord-bot, python, fix, roster-type, trade, rostertype]
importance: 0.6
confidence: 0.8
created: "2026-03-03T06:08:10.984609+00:00"
updated: "2026-03-03T06:08:10.984609+00:00"
---
## Problem
`commands/transactions/trade.py` hardcoded `RosterType.MAJOR_LEAGUE` for both `from_roster` and `to_roster` in `/trade add-player`, making it impossible to trade players from/to Minor League rosters.
## Root Cause
Lines 310311 had placeholder comments acknowledging the limitation but never implemented dynamic detection.
## Solution
- `from_roster`: use `player.team.roster_type()` if team object is populated; otherwise fetch via `team_service.get_team(player.team_id)` (search endpoint returns team as int, not nested object); fallback to MAJOR_LEAGUE for free agents.
- `to_roster`: use `dest_team.roster_type()` — dest_team is already a full Team object from `get_team_by_abbrev_with_validation()`.
## Key Pattern
`Team.roster_type()` detects roster type from abbreviation suffix: `MIL` = MINOR_LEAGUE, `IL` = INJURED_LIST, ≤3 chars = MAJOR_LEAGUE. Has special handling for ambiguous `MIL` suffix (e.g. `BHMIL` = BHM+IL not BH+MIL).
## Files Changed
- `commands/transactions/trade.py`: added `team_service` import; replaced hardcoded defaults
## PR
https://git.manticorum.com/cal/major-domo-v2/pulls/61