anthonymidili/EasyKeep

View on GitHub
app/views/invoices/_invoiceable_form.html.haml

Summary

Maintainability
Test Coverage
= form_for @invoice, url: apply_checked_services_create_invoices_path do |f|

  = render 'shared/error_messages', object: f.object

  = render 'invoices/date_tax_fields', f: f

  .scroll_overflow-x
    %table
      %thead
        %tr
          - if current_user.is_admin?
            %th Invoice?
          %th Performed on
          %th Memo
          %th Cost
          - if current_user.is_admin?
            %th Edit
            %th Delete

      %tbody
        - @services.by_invoiceable.each do |service|
          - if service.persisted?
            %tr
              - if current_user.is_admin?
                %td= check_box_tag 'service_ids[]', service.id, service.invoice_id.nil?
              %td= service.performed_on.strftime('%Y-%b-%d')
              %td= service.memo
              %td= number_to_currency(service.cost, unit: '$')
              - if current_user.is_admin?
                %td.center_cell
                  = link_to edit_service_path(service) do
                    %i.fas.fa-edit
                %td.center_cell
                  = link_to service, class: 'red_link', method: :delete, data: { confirm: t(:confirm_delete_service) } do
                    %i.fas.fa-trash

  = f.submit 'Invoice Checked Services', class: 'tiny button radius' if current_user.is_admin?