Developer Doc: Auto-Creation of Sales Order from Service Orders
Auto-Creation of Sales Order from Service Orders
Purpose
This method enables automated Sales Order generation from one or more submitted Service Orders in a container logistics workflow using the make_sales_order() function.
Key Functions
create_sales_order(data)
- Parses JSON input (
m_bl_no) - Ensures all Service Orders are submitted
- Calls
make_sales_order()if valid
make_sales_order(doc_type, doc_name, m_bl_no, manifest)
- Aggregates Service Orders by BL No & Manifest
- Collects customer, consignee, and charge details
- Creates Sales Order with computed line items
get_container_days_to_be_billed()
- Determines billable storage days from container based on destination and ICD settings
- Differentiates between single and double chargeable days
get_items()
- Maps services to storage items
- Calculates qty as billable days
- Skips invoiced days
- Generates item list for Sales Order
Customization Points
ICD TZ Settings: Definestorage_item_single_20ft,storage_item_double_40ft, charge rangesContainer.container_dates: Must includeis_billable,sales_invoice, etc.
DocTypes Used
- Service Order
- Sales Order
- Container
- ICD TZ Settings
Notes
- Ensure
qty > 0before inserting Sales Order items. - Update link-back for traceability to the Service Order.
- Use
@frappe.whitelist()to allow function triggering via JS or button.
Last updated 1 week ago
Was this helpful?