Closed
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a comprehensive cart tax calculation feature with automatic origin/destination sourcing to the ZipTax Python SDK. The feature enables calculating sales tax for shopping carts with multiple line items while automatically determining whether to use origin-based or destination-based tax rates according to state-specific sourcing rules. The implementation includes 9 new Pydantic models, 122 tests achieving 96% code coverage, extensive documentation updates, and a version bump to 0.2.1-beta.
Changes:
- Added
CalculateCart()function with automatic origin/destination sourcing that looks up both addresses via the V60 API, determines interstate vs. intrastate status, and applies state-specific sourcing rules before calculating taxes - Introduced 9 new Pydantic models (CalculateCartRequest, CartItem, CartAddress, CartCurrency, CartLineItem, CalculateCartResponse, CartItemResponse, CartLineItemResponse, CartTax) with strict validation constraints for cart tax calculation
- Comprehensive documentation including README usage guide, OpenAPI specification updates, and actual API request/response examples
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/ziptax/resources/functions.py | Implements CalculateCart() function with _extract_state_from_normalized_address() and _resolve_sourcing_address() helpers for automatic sourcing resolution |
| src/ziptax/models/responses.py | Defines 9 new Pydantic models for cart tax calculation with validation constraints (positive prices/quantities, USD currency, item count limits) |
| src/ziptax/models/init.py | Exports new cart calculation models to module API |
| src/ziptax/init.py | Exports new models at package level and updates version to 0.2.1-beta |
| tests/test_functions.py | Adds 25 new tests across 3 test classes covering state extraction, sourcing resolution, cart calculation, API integration, and Pydantic validation |
| tests/conftest.py | Adds sample_calculate_cart_response fixture and _build_v60_response helper with 4 state-specific fixtures for testing |
| README.md | Adds cart tax calculation usage guide with code examples and origin/destination sourcing explanation |
| CHANGELOG.md | Documents all changes for version 0.2.1-beta release |
| CLAUDE.md | Updates internal documentation with cart calculation patterns and version |
| docs/spec.yaml | Adds comprehensive CalculateCart endpoint specification including validation rules, sourcing logic, and example responses |
| pyproject.toml | Updates package version to 0.2.1-beta |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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 pull request introduces a major new feature to the SDK: cart tax calculation with automatic origin/destination sourcing, along with comprehensive documentation, new Pydantic models, and test coverage. The update also bumps the SDK version to
0.2.1-beta. The most important changes are grouped below.Cart Tax Calculation Feature:
CalculateCart()function, which calculates sales tax for a shopping cart by sending aCalculateCartRequestto the newPOST /calculate/cartendpoint on the ZipTax API. The function returns per-item tax rates and amounts viaCalculateCartResponse. [1] [2] [3]CalculateCart(). The SDK looks up both addresses, determines interstate/intrastate status, and applies state-specific sourcing rules before sending the request. [1] [2] [3]Data Modeling and Validation:
CalculateCartRequest,CartItem,CartLineItem,CartCurrency, etc.) with strict validation constraints (e.g., positive price/quantity, USD currency, item count limits). [1] [2]Documentation and Examples:
docs/spec.yaml) with the new endpoint, request/response models, validation rules, and sourcing logic. [1] [2]Testing and Quality:
Versioning and Miscellaneous:
0.2.0-betato0.2.1-betain all relevant files and documentation. [1] [2] [3]These changes provide a robust foundation for cart-based tax calculation in the SDK, with strict validation, clear documentation, and strong test coverage.