 
     removeLineWithUnselectedItems: (modal, displayedItemIds, event) ->
       for id in displayedItemIds
-
         $checkbox = $(modal).find("input[type='checkbox'][data-id=#{id}]")
-        continue if $checkbox.prop('checked')
-
-        $('.item-form__btn .btn').first().trigger('click')
+        if $checkbox.length && !$checkbox.prop('checked')
+          $container = $(".nested-fields .nested-item-form[data-item-id='#{id}'").closest('tbody')
+          if $container.length
+            $container.find('a.remove-item').click()
+
+      0
 
 
     _createNewItemLine: (itemCheckbox) ->

  $(document).on 'click', '#purchase_process_reconciliation .valid-modal', (event) ->
    modal = $(event.target).closest('#purchase_process_reconciliation')

    displayedItemIds = $('.nested-item-form[data-item-id]').map(-> $(this).attr('data-item-id')).toArray()

    if $(this).attr('data-item-reconciliation') != undefined
      # Reconciliation on line

      $('.reconcile-state').addClass('hidden')

  refresh_state = ->
    $displayComplianceStates = $(".nested-fields .nested-item-form[data-non-compliant='true']")

    set_reconciliation_state !!$('.nested-fields .nested-item-form[data-item-id]').length

    if !$displayComplianceStates.length
      $('.compliance-title').addClass('hidden')
    else
      $('.compliance-title').removeClass('hidden')

  $(document).on 'cocoon:after-remove', '#new_reception, #new_purchase_invoice, .edit_reception, .edit_purchase_invoice', refresh_state


  $(document).on 'change', '#purchase_invoice_accepted_state', (event) ->
