   ##############################
   # Open modal on button click
   $(document).on 'click', '#showReconciliationModal', (event) =>
-    open_reconciliation_modal($(event.target))
+    $form = $(event.target).closest('form')
+    open_reconciliation_modal($form)
 
   # Validate modal
   handle_modal_validation = (modal) =>

  # Checks the parent checkbox if all children are checked. Uncheck it if not.
  # If all checked, set 'close command to true, else to false'
  # Also hide/display the close command radio
  syncState = (commandContainer) => 
    itemCheckboxes = Array.from(commandContainer.querySelectorAll('.item-checkbox'))
    allItemsCheckboxesChecked = itemCheckboxes.map((cb) => cb.checked).reduce(((acc, e) => acc && e), true)
    anyItemsCheckboxesChecked = itemCheckboxes.map((cb) => cb.checked).includes(true)
    closePurchaseOrderBlock = commandContainer.querySelector('.close-purchase-order')

    commandContainer.querySelector('.model-checkbox').checked = allItemsCheckboxesChecked
    setCloseCommand(commandContainer, allItemsCheckboxesChecked)

    if anyItemsCheckboxesChecked
      closePurchaseOrderBlock.classList.remove('hidden')
    else
      closePurchaseOrderBlock.classList.add('hidden')

  # Sets the value of the radiobutton to `value`
  setCloseCommand = (commandContainer, value) => 

    closePurchaseOrderBlock.querySelector("input[type='radio'][value=#{value}").checked = true

  # Sets all children checkboxes to 'value' and sync state
  setAllChildrenTo = (commandContainer, value, $form) =>
    commandContainer.querySelectorAll('.item-checkbox').forEach((item) => item.checked = value)
    syncState(commandContainer, $form)

  E.reconciliation =
    reconciliateItems: (modalContent) ->
