Design for AP Autoextract(Documents AI)-Intake requirements for Fluxx Intake service
High‑Level Activity Summaries (from workflow_intake.py and intake_activities.py that I inspected)
Activities in the Intake Workflow execution order:
- initialize_workflow (from workflow_activities)
- Creates a workflow record (links document hash/invoiceID, client, pdf path/prefix). Pure side‑effect; no branching logic.
- check_duplicate_document (intake version)
- Updates substatus to “Duplicate Check”.
- Builds a Cosmos query from client-config ingest_config.unique_identifier_fields (supports dotted paths by flattening invoice document).
- If >1 matching result found: marks workflow_status=failed, substatus=‘Duplicate Document Found’ and stores duplicate_invoice.
- Otherwise succeeded.
- handle_sales_tax
- Substatus “Handling Sales Tax”.
- Reads feature flag negate_sales_tax (FeatureFlagService).
- If enabled and invoiceTax > 0, appends a negative “Sales Tax” line item to neutralize tax at header level and updates invoice.
- Always succeeds unless exception.
- validate_invoice
- Substatus “Validating Invoice”.
- Builds Validator object (struct of potential issues).
- Sets workflow_status failed if subtotal, total, line item, or (optionally) missing PO number when intake_config.verify_po_number is true.
- Records validator + includes_rounding flag.
- complete_workflow / fail_workflow
- Marks child workflow status accordingly (completed or failed) after prior steps.
(Other available but not called here: run_change_stage.)
Configuration JSON (enable/disable, ordering, skip logic)
Notes:
- skip_if / trigger_if expressions mirror earlier pattern.
- fail_workflow acts as a conditional terminal path; orchestrator chooses complete_workflow vs fail_workflow.
- feature_flag() expression corresponds to existing FeatureFlagService.
- failure_behavior=continue lets you accept validation errors but still mark workflow completed (optional toggle).