# Draft preview · validation will run on save
domain: accounts-payable
entity: Invoice

events:
  - invoice_received
  - approval_granted
  - payment_completed

states:
  - received
  - approved
  - paid
  - rejected

transitions:
  - on: approval_granted
    from: received
    to: approved
  - on: payment_completed
    from: approved
    to: paid

actions:
  - name: PAY_INVOICE
    allowed_states: [approved]
    required_parameters: [amount, currency]
    required_permissions: [accounts-payable.pay_invoice]
    risk: high
    approval: never
    executor: erp.pay_invoice
  - name: REQUEST_APPROVAL
    allowed_states: [received]
    required_parameters: []
    required_permissions: []
    risk: medium
    approval: never
    executor: workflow.request_approval
  - name: REJECT_INVOICE
    allowed_states: [received, approved]
    required_parameters: []
    required_permissions: []
    risk: medium
    approval: never
    executor: erp.reject_invoice

permissions:
  roles:
    finance_manager:
      - accounts-payable.pay_invoice
