Skip to content

Add native accounting operations and enhance API error handling#89

Merged
jfrench9 merged 3 commits intomainfrom
feature/native-accounting-ops
Apr 16, 2026
Merged

Add native accounting operations and enhance API error handling#89
jfrench9 merged 3 commits intomainfrom
feature/native-accounting-ops

Conversation

@jfrench9
Copy link
Copy Markdown
Member

Summary

This PR introduces a comprehensive set of native accounting (RoboLedger) CRUD operations and significantly enhances error handling and response parsing across all RoboInvestor and GraphQL API operations in the robosystems_client.

Key Accomplishments

New RoboLedger Operations (16 new endpoint modules)

  • Elements: Create, update, and delete accounting elements with full support for balance types, classifications, element types, period types, and source enums
  • Journal Entries: Create, update, delete, and reverse journal entries with line item support
  • Associations: Bulk create, update, and delete associations (including bulk association items with typed association types)
  • Schedules: Delete, update, and manage schedules (including truncation)
  • Structures: Delete and update organizational structures
  • Taxonomies: Delete and update taxonomy definitions

New Models (30+ new model files)

  • Request models for all new operations (CreateElementRequest, CreateJournalEntryRequest, BulkCreateAssociationsRequest, etc.)
  • Supporting enum models for typed fields (CreateElementRequestBalanceType, CreateJournalEntryRequestType, UpdateElementRequestClassificationType0, etc.)
  • JournalEntryLineItemInput for structured journal entry line items
  • OperationError and OperationErrorDetailType1 for standardized error representation
  • OperationEnvelope updates to support the new error structure

Enhanced Error Handling & Response Parsing

  • All existing RoboInvestor operations (9 modules: create/update/delete for portfolio, position, security) updated with improved error handling and richer response parsing
  • All existing RoboLedger operations (20+ modules) updated with consistent error handling patterns
  • GraphQL operations (GET and POST handlers) enhanced with better response parsing
  • Ledger client (ledger_client.py) updated to integrate with new operations

Breaking Changes

  • OperationEnvelope model has been updated — consumers relying on the previous error field structure should update to use the new OperationError model
  • New operations may introduce additional required dependencies or import paths in the models/__init__.py module

Testing Notes

  • Verify all new CRUD operations for elements, journal entries, associations, schedules, structures, and taxonomies against the API
  • Test error scenarios to validate the enhanced error handling produces correctly structured OperationError responses across all modules
  • Confirm backward compatibility of existing RoboInvestor and GraphQL operations after the error handling refactor
  • Validate enum models serialize/deserialize correctly for all typed request fields (balance types, classifications, period types, etc.)
  • Test the reverse journal entry flow end-to-end as it represents a new business operation

Infrastructure Considerations

  • The significant number of new model and operation files (85 files changed) suggests this was likely generated or scaffolded from an updated API specification — ensure the code generation tooling and API spec are version-tracked accordingly
  • The models/__init__.py module has been updated to export all new models; downstream consumers pulling from this package will pick up the new types automatically
  • No new external dependencies appear to be introduced; changes are additive within the existing client architecture

🤖 Generated with Claude Code

Branch Info:

  • Source: feature/native-accounting-ops
  • Target: main
  • Type: feature

Co-Authored-By: Claude noreply@anthropic.com

…QL API operations

- Added handling for additional HTTP status codes (401, 403, 429, 400, 404, 409, 500) across various operations in the RoboInvestor API, improving robustness in error management.
- Updated response parsing functions to return appropriate error models (OperationError) for specific status codes, ensuring clearer communication of issues to clients.
- Enhanced documentation in method docstrings to clarify authentication requirements and error code handling, improving user guidance on API usage.

These changes improve the overall reliability and user experience of the API by providing more informative error responses and clearer documentation.
- Modified the `CreateJournalEntryRequest` to default to `status='draft'` for ongoing entries, with an option to set `status='posted'` for historical data imports.
- Enhanced documentation to clarify the workflow for creating journal entries and the implications of different statuses.
- Added `CreateJournalEntryRequestStatus` model to manage entry statuses, improving code organization and clarity.
- Updated imports in `__init__.py` to include the new status model.

These changes improve the flexibility and clarity of journal entry creation in the API.
- Introduced a new test class `TestJournalEntries` to cover various scenarios for creating, updating, deleting, and reversing journal entries, ensuring proper handling of entry statuses and idempotency keys.
- Added a test class `TestLinkEntityTaxonomy` to validate the linking of entity taxonomies, including error handling for missing entities.
- Implemented additional tests in `TestLedgerReadsAdditional` to verify the summary retrieval functionality, enhancing overall test coverage for ledger operations.

These additions improve the reliability and robustness of the ledger client by ensuring comprehensive testing of key functionalities.
@jfrench9 jfrench9 merged commit e91b25e into main Apr 16, 2026
1 check passed
@jfrench9 jfrench9 deleted the feature/native-accounting-ops branch April 16, 2026 04:18
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