Add fiscal calendar management and period closing operations#85
Merged
Add fiscal calendar management and period closing operations#85
Conversation
- Introduced new methods in the LedgerClient for managing fiscal periods, including `initialize_ledger`, `get_fiscal_calendar`, `set_close_target`, `close_period`, `reopen_period`, and `list_period_drafts`. - Added corresponding request and response models to support these operations, enhancing the client’s capabilities for fiscal management. - Updated imports to include new API endpoints related to fiscal calendar operations. These changes improve the LedgerClient's functionality for handling fiscal periods and streamline the workflow for closing and reopening periods.
- Updated the documentation for the `sync_detailed`, `sync`, `asyncio_detailed`, and `asyncio` functions to clarify that all mechanics are handled by `PeriodCloseService.close()`. - Removed detailed step-by-step descriptions of the closing process to streamline the documentation and focus on the endpoint's role in authentication and exception handling. These changes improve the clarity and conciseness of the API documentation related to closing fiscal periods.
…ference - Modified the documentation for the `sync_detailed`, `sync`, `asyncio_detailed`, and `asyncio` functions to reflect the removal of "cash_flow_statement" from the `structure_type` argument, replacing it with "equity_statement". - Removed the "CASH_FLOW_STATEMENT" constant from the `CreateStructureRequestStructureType` enum to align with the updated documentation. These changes ensure consistency between the API documentation and the underlying model definitions.
- Introduced a new test suite for the LedgerFiscalCalendar class, covering methods for initializing the ledger, getting the fiscal calendar, setting close targets, closing and reopening fiscal periods. - Implemented tests to validate success and error scenarios, ensuring proper handling of HTTP responses and optional parameters. - Enhanced test coverage for fiscal calendar functionalities, improving the reliability of the LedgerClient's fiscal management capabilities.
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.
Summary
Enhances the
LedgerClientwith comprehensive fiscal calendar and period closing functionalities. This feature introduces new API endpoints, request/response models, and high-level client methods to manage the full lifecycle of fiscal periods — from ledger initialization and schedule management through period closing, reopening, and manual closing entry creation.Key Accomplishments
New API Endpoints (8 added)
initialize_ledger— Bootstrap a ledger with initial entity data and fiscal calendar configurationget_fiscal_calendar— Retrieve the full fiscal calendar with period summariesclose_fiscal_period— Close a specific fiscal period, finalizing its entriesreopen_fiscal_period— Reopen a previously closed fiscal period for correctionsset_close_target— Set the target period for the next closing cyclelist_period_drafts— List draft entries pending within a fiscal periodcreate_manual_closing_entry— Create manual closing/adjusting journal entriestruncate_schedule— Truncate the fiscal schedule at a given pointNew Models (18 added)
ClosePeriodRequest,ReopenPeriodRequest,SetCloseTargetRequest,InitializeLedgerRequest,CreateManualClosingEntryRequest,TruncateScheduleRequest,ManualLineItemRequestClosePeriodResponse,FiscalCalendarResponse,FiscalPeriodSummary,InitializeLedgerResponse,DraftEntryResponse,DraftLineItem,PeriodDraftsResponse,TruncateScheduleResponseCreateManualClosingEntryRequestEntryType,EntryTemplateRequestEntryTypeModified Models & Endpoints
ClosingEntryResponse— Expanded with additional fields to support richer closing entry dataEntryTemplateRequest— Added entry type supportCreateScheduleRequest/InitialEntityData— Extended with new optional fieldsget_statement— Minor update (removed cash flow statement reference from structure type)CreateStructureRequestStructureType— Removed deprecated cash flow statement variantClient Extension
LedgerClientextended with convenient high-level methods wrapping all new endpoints, providing a clean interface for fiscal calendar operationsBreaking Changes
CreateStructureRequestStructureType: The cash flow statement enum variant has been removed. Any consumers referencing this value will need to be updated.ClosingEntryResponsemodel has been significantly refactored with new/changed fields — consumers deserializing this model should verify compatibility.Testing
tests/test_ledger_client.py(446 lines) covering all newLedgerClientfiscal calendar operations including initialization, calendar retrieval, period close/reopen, draft listing, manual entry creation, close target setting, and schedule truncation.Infrastructure Considerations
models/__init__.py) has been updated to export all new types.🤖 Generated with Claude Code
Branch Info:
feature/improved-fiscal-closemainCo-Authored-By: Claude noreply@anthropic.com