<% display_payment_options = (!dry_run && ((can?(:credit, Kaui::Account) && @invoice.status == 'DRAFT') || (can?(:charge, Kaui::Account) && @invoice.status == 'DRAFT') || (@invoice.balance > 0 && can?(:trigger, Kaui::Payment)))) if !(@available_invoice_tags ||= nil).blank? || !(@custom_fields ||= nil).blank? || display_payment_options %>
<% unless @available_invoice_tags.blank? %>
Tag As: <%= render :partial => 'kaui/invoice_tags/form_bar', :locals => {:account_id => @account.account_id, :invoice_id => @invoice.invoice_id, :tag_names => @invoice_tags.map { |tag| tag.tag_definition_name }, :available_tags => @available_invoice_tags} %>
<% end %> <%= render :partial => 'kaui/custom_fields/list_bar', :locals => {:custom_fields => @custom_fields} %> <% if display_payment_options %>
<% if can?(:credit, Kaui::Account) && @invoice.status == 'DRAFT' %> <%= link_to ' Add credit'.html_safe, kaui_engine.new_account_credit_path(@invoice.account_id, :currency => @invoice.currency, :invoice_id => @invoice.invoice_id) %> <% end %> <% if can?(:charge, Kaui::Account) && @invoice.status == 'DRAFT' %> <%= link_to ' Create charge'.html_safe, kaui_engine.new_account_charge_path(@invoice.account_id, :currency => @invoice.currency, :invoice_id => @invoice.invoice_id) %> <% end %> <% if @invoice.balance > 0 && can?(:trigger, Kaui::Payment) %> <%= link_to ' Make payment'.html_safe, kaui_engine.new_account_payment_path(@invoice.account_id, :invoice_id => @invoice.invoice_id) %> <% end %>
<% end %> <% if can?(:void, Kaui::Invoice) && @invoice.status != 'VOID' && @invoice_tags.find { |t| t.tag_definition_name == 'WRITTEN_OFF' }.nil? # The backend will do more comprehensive checks %>
<%= form_tag void_invoice_path(:id => @invoice.invoice_id), :method => :delete do %> <%= label_tag :comment, 'Comment', :class => 'col-sm-2 control-label' %> <%= text_area_tag :comment, nil, :rows => 3, :class => 'form-control' %> <%= submit_tag 'Void', :class => 'btn btn-default' %> <% end %>
<% end %>
<% end %> <% unless (@available_invoice_item_tags ||= nil).blank? && (@custom_fields_per_invoice_item ||= nil).blank? %> <% end %> <% @invoice.items.each do |item| %> > <% unless @available_invoice_item_tags.blank? && @custom_fields_per_invoice_item.blank? %> <% end %> <% end %>
Description Start date End date Subscription ID Amount Comments
<% unless @available_invoice_item_tags.blank? %>
Tag as: <%= render :partial => 'kaui/bundle_tags/form_bar', :locals => {:params => { :invoice_id => item.invoice_id, :account_id => item.account_id}, :tag_names => (@tags_per_invoice_item[item.invoice_item_id] || []).map { |tag| tag.tag_definition_name }, :available_tags => @available_invoice_item_tags, :update_tags_path => update_invoice_items_tags_path(item.invoice_item_id) } %>
<% end %> <%= render :partial => 'kaui/custom_fields/list_bar', :locals => {:custom_fields => @custom_fields_per_invoice_item[item.invoice_item_id] || []} %>
<%= item.pretty_plan_name.blank? || !item.item_type.in?(%w{USAGE RECURRING}) ? item.description : item.pretty_plan_name %> <%= item.start_date.html_safe if item.start_date %> <%= item.end_date.html_safe if item.end_date %> <%= item.subscription_id %> <%= humanized_money_with_symbol Kaui::InvoiceItem.amount_to_money(item) %> (<%= item.currency %>) <%= item.audit_logs.map { |log| log.comments }.compact.join('
') if item.audit_logs.present? %>
<% if can? :item_adjust, Kaui::Invoice %> <%= link_to 'Adjust', kaui_engine.edit_account_invoice_item_path(@invoice.account_id, item.invoice_item_id, :invoice_id => @invoice.invoice_id), :class => "btn btn-xs #{'disabled' unless item.amount > 0}" %> <% end %>
Invoice Total: <%= humanized_money_with_symbol @invoice.amount_to_money %> (<%= @invoice.currency %>)
Resulting available credits: <%= humanized_money_with_symbol @invoice.credit_adjustment_to_money %> (<%= @invoice.currency %>)
Refunded: <%= humanized_money_with_symbol @invoice.refund_adjustment_to_money %> (<%= @invoice.currency %>)
Balance: <%= humanized_money_with_symbol @invoice.balance_to_money %> (<%= @invoice.currency %>)