ForSURE.orders_data.orders
Orders Module
Overview
The orders module provides comprehensive functionality for managing order data in the ForSURE SaaS platform. It handles the complete lifecycle of orders, from adding individual orders via API to bulk uploading from files, with robust validation and error handling.
Features
Order Management Capabilities
Add Orders Programmatically
- Add orders via JSON API with structured data
- Support for flexible duplicate handling strategies
- Automatic validation of required fields
- Support for both B2B and B2C orders
Retrieve and Query Orders
- Paginated order retrieval with configurable page sizes
- Advanced filtering by date range, search terms, and data source
- Results grouped by order ID for easy navigation
- Free-text search across all string columns
Bulk Upload from Files
- Upload orders from CSV or Excel files
- Background processing for large file uploads
- Profile-based column mapping for flexible file formats
- Support for multiple file uploads in a single operation
File Validation
- Pre-upload validation to catch errors early
- Column mapping verification against configured profiles
- Data format checking and validation
- Detailed error reporting for troubleshooting
Data Model
Order Fields
Required Fields:
sku(str): Product SKU identifiertitle(str): Product title/nameorderid(str): Unique order identifierquantity(int): Number of items ordereddate(datetime): Order date in ISO formatcountry(str): Country code (e.g., "NL")postal_code(str): Postal/ZIP codeb2b(bool): Whether this is a business-to-business order
Optional Fields:
company_name(str): Company name for B2B orderstotal_weight(float): Total weight of the orderpackaging_weight(float): Weight of packaging
Error Handling
The module supports flexible error handling strategies:
- SKIP: Silently ignore duplicates/errors
- WARN_AND_SKIP: Report issues but continue (default)
- RAISE: Stop processing and raise an error
Usage Examples
Adding Orders via API
Orders can be added programmatically using a JSON payload with order details. The API supports batch operations and configurable duplicate handling.
{
"orders": [
{
"sku": "481769825",
"title": "Example Product",
"orderid": "FS1234",
"quantity": 1,
"date": "2024-01-27T22:16:25.365Z",
"country": "NL",
"postal_code": "1234AB",
"b2b": false
}
],
"duplicates": "WARN_AND_SKIP"
}
Querying Orders
Orders can be retrieved with pagination and filtering options including date ranges, search terms, and source filtering. Results are grouped by order ID for easy navigation.
Uploading Orders from Files
Bulk uploads support CSV and Excel formats with profile-based column mapping. Multiple files can be uploaded simultaneously, each with its own profile and source identifier.
Permissions
- ORDERS_VIEW: Required to retrieve orders
- ORDERS_ADD: Required to add or upload orders
Best Practices
- Always validate files using the validation endpoint before uploading
- Use appropriate duplicate handling based on your use case
- Set up profiles correctly to ensure proper column mapping
- Monitor background tasks for large file uploads
- Use date filters when querying to improve performance
- Track sources using fileId to maintain data lineage
Integration
The orders module integrates with:
- Volumes: Automatic volume refresh after upload
- Manual Changes: Supports manual corrections via the changes module
- Reports: Provides data for reporting and analytics
- Categorylist: Links orders to product catalog
File Upload Process
- Validation: Files are validated synchronously
- Processing: Valid files are processed in the background
- Volume Refresh: Order volumes are automatically refreshed
- Error Handling: Errors are reported per file
Response Format
Successful Order Addition
{
"status": "success",
"duplicates": []
}
Paginated Order Response
{
"items": [...],
"source_names": ["source1", "source2"],
"total": 150,
"limit": 50,
"offset": 0,
"next_offset": 50,
"prev_offset": null
}