<workflow class="LedgerSMB::Workflow">
  <type>GL</type>
  <persister>JournalEntry</persister>
  <description>Manage the life cycle of a GL document (excluding year-end, inventory adjustment and fixed assets transactions)</description>

  <state name="INITIAL">
    <action name="update" resulting_state="NOCHANGE" />
    <action name="post" resulting_state="SAVED">
      <condition name="!reversing" />
      <condition name="!period-closed" />
      <condition name="complete" />
    </action>
    <action name="post_and_approve" resulting_state="POSTED">
      <condition name="!reversing" />
      <condition name="!separate-duties" />
      <condition name="!period-closed" />
      <condition name="!is-batch-member" />
      <condition name="complete" />
    </action>
    <action name="post_reversing" resulting_state="POSTED">
      <condition name="reversing" />
      <condition name="!period-closed" />
      <condition name="acl-draft-post" />
      <condition name="!is-batch-member" />
    </action>
  </state>

  <state name="SAVED">
    <action name="save_as_template" resulting_state="NOCHANGE" />
    <!-- action name="save_info" resulting_state="NOCHANGE" / -->
    <action name="edit_and_save" resulting_state="NOCHANGE">
      <condition name="acl-draft-modify" />
    </action>
    <action name="copy_to_new" resulting_state="NOCHANGE" />
    <action name="new" resulting_state="NOCHANGE" />
    <action name="update" resulting_state="NOCHANGE" />
    <action name="schedule" resulting_state="NOCHANGE">
      <condition name="!is-batch-member" />
    </action>
    <action name="approve" resulting_state="POSTED">
      <condition name="complete" />
      <condition name="!period-closed" />
      <condition name="acl-draft-post" />
      <condition name="!is-batch-member" />
    </action>
    <action name="batch-approve" resulting_state="POSTED">
      <condition name="complete" />
      <condition name="!period-closed" />
      <condition name="is-batch-member"/>
    </action>
    <action name="del" resulting_state="DELETED">
      <condition name="!is-batch-member" />
    </action>
    <action name="batch-delete" resulting_state="DELETED">
      <condition name="is-batch-member" />
    </action>
  </state>

  <state name="POSTED">
    <action name="save_info" resulting_state="NOCHANGE" />
    <action name="copy_to_new" resulting_state="NOCHANGE">
      <condition name="!reversing" />
    </action>
    <action name="new" resulting_state="NOCHANGE" />
    <action name="reverse" resulting_state="REVERSED">
      <condition name="!reversing" />
    </action>
    <action name="schedule" resulting_state="NOCHANGE">
      <condition name="!reversing" />
    </action>
    <action name="print" resulting_state="NOCHANGE" />
  </state>

  <state name="REVERSED">
    <action name="save_info" resulting_state="NOCHANGE" />
    <action name="copy_to_new" resulting_state="NOCHANGE" />
  </state>

  <state name="DELETED" />
</workflow>
