<%= select_tag "bundles", options_for_select([ "" ] + @bundle_names.values.sort, @selected_bundle || 'all') %>
<%= select_tag "event_types", options_for_select(''.html_safe) %>
Billing timezone:
<%= @account.timezone %>

<% if @account.present? && @timeline.present? %> <% @timeline.invoices.each do |invoice_stub| %> <% if invoice_stub.bundle_keys.present? %> <% bundles = invoice_stub.bundle_keys.split(",").map {|bundle_key| @bundle_names[bundle_key] }.join(",") %> <% end %> <% if invoice_stub.invoice_id.present? && @invoices_by_id.has_key?(invoice_stub.invoice_id) %> <% invoice = @invoices_by_id[invoice_stub.invoice_id] %> <% else %> <% invoice = invoice_stub %> <% end %> <% end %> <% @timeline.payments.each do |payment| %> <% payment.refunds.each do |refund| %> <% bundles = payment.bundle_keys.split(",").map {|bundle_key| @bundle_names[bundle_key] }.join(",") %> <% end %> <% end %> <% @timeline.payments.each do |payment| %> <% payment.chargebacks.each do |chargeback| %> <% bundles = payment.bundle_keys.split(",").map {|bundle_key| @bundle_names[bundle_key] }.join(",") %> <% end %> <% end %> <% @timeline.payments.each do |payment| %> <% if payment.bundle_keys.present? %> <% bundles = payment.bundle_keys.split(",").map {|bundle_key| @bundle_names[bundle_key] }.join(",") %> <% end %> <% if payment.invoice_id.present? %> <% invoice = @invoices_by_id[payment.invoice_id] %> <% else %> <% invoice = nil %> <% end %> <% end %> <% @timeline.bundles.each do |bundle| %> <% bundle.subscriptions.each do |sub| %> <% sub.events.each do |event| %> <% next if event.event_type == 'SERVICE_STATE_CHANGE' %> <% end %> <% end %> <% end %> <% end %>
Requested Date Effective Date Bundle Name Event Type Details Reason Code / Comments Actions
<% if invoice.invoice_date.present? %> <%= invoice.invoice_date %> <% else %> [unknown] <% end %> <% if invoice.target_date.present? %> <%= invoice.target_date %> <% else %> [unknown] <% end %> <% if invoice_stub.bundle_keys.present? %> <% invoice_stub.bundle_keys.split(",").each do |bundle_key| %> <%= link_to @bundle_names[bundle_key], Kaui.bundle_home_path.call(bundle_key) %>
<% end %> <% end %>
<%= "INVOICE" %> <%= "Amount:" %> <%= humanized_money_with_symbol Kaui::Base.to_money(invoice.amount, @account.currency) %> (<%= @account.currency %>)
<%= "Balance:" %> <%= humanized_money_with_symbol Kaui::Base.to_money(invoice.balance, @account.currency) %> (<%= @account.currency %>)
<% if invoice.credit_adj.present? && invoice.credit_adj > 0 %> <%= "Credit adjustment:" %> <%= humanized_money_with_symbol Kaui::Base.to_money(invoice.credit_adj, @account.currency) %> (<%= @account.currency %>)
<% end %> <% if invoice.credits.present? && invoice.credits > 0 %> <%= "Credit balance adjustment:" %> <%= humanized_money_with_symbol Kaui::Base.to_money(invoice.credits, @account.currency) %> (<%= @account.currency %>)
<% end %> <% if invoice.refund_adj.present? && invoice.refund_adj < 0 %> <%= "Refund adjustment:" %> <%= humanized_money_with_symbol Kaui::Base.to_money(invoice.refund_adj, @account.currency) %> (<%= @account.currency %>)
<% end %> <%= "Invoice #" %> <%= link_to invoice.invoice_number, invoice_path(:id => invoice.invoice_id) %>
<% if invoice_stub.audit_logs.present? %> <% invoice_stub.audit_logs.each do |entry| %> <%= Kaui::AuditLog.description(entry) unless entry.changed_by == 'Transition' %>
<% end %> <% end %>
<%= link_to "Payment", kaui_engine.new_payment_path(:params => { :account_id => invoice.account_id, :invoice_id => invoice.invoice_id }), :class => "btn btn-mini #{"disabled" unless invoice.balance > 0}" %> <% if can? :credit, Kaui::Invoice %> <%= link_to "Credit", kaui_engine.new_credit_path(:params => { :account_id => invoice.account_id, :invoice_id => invoice.invoice_id }), :class => "btn btn-mini" %> <% end %> <% if can? :charge, Kaui::Invoice %> <%= link_to "Charge", kaui_engine.new_charge_path(:params => { :account_id => invoice.account_id, :invoice_id => invoice.invoice_id }), :class => "btn btn-mini" %> <% end %>
<% if refund.requested_date.present? %> <%= format_date(refund.requested_date, @account.timezone).html_safe %> <% else %> [unknown] <% end %> <% if refund.effective_date.present? %> <%= format_date(refund.effective_date, @account.timezone).html_safe %> <% else %> [unknown] <% end %> <% payment.bundle_keys.split(",").each do |bundle_key| %> <%= link_to @bundle_names[bundle_key], Kaui.bundle_home_path.call(bundle_key) %>
<% end %>
<%= "REFUND" %> <%= "Adjusted:" %> <% if refund.adjusted %>yes<% else %>no<% end %>
<%= "Payment id:" %> <%= refund.payment_id %>
<%= "Refund Amount:" %> <%= humanized_money_with_symbol Kaui::Base.to_money(refund.amount, refund.currency) %> (<%= refund.currency %>)
<% if refund.audit_logs.present? %> <%= Kaui::AuditLog.description(refund.audit_logs[0])%>
<% end %>
<% if chargeback.effective_date.present? %> <%= format_date(chargeback.effective_date, @account.timezone).html_safe %> <% else %> [unknown] <% end %> <% if chargeback.effective_date.present? %> <%= format_date(chargeback.effective_date, @account.timezone).html_safe %> <% else %> [unknown] <% end %> <% payment.bundle_keys.split(",").each do |bundle_key| %> <%= link_to @bundle_names[bundle_key], Kaui.bundle_home_path.call(bundle_key) %>
<% end %>
<%= "CHARGEBACK" %> <%= "Payment id:" %> <%= chargeback.payment_id %>
<%= "Chargeback Amount:" %> <%= humanized_money_with_symbol Kaui::Base.to_money(chargeback.amount, payment.currency) %> (<%= payment.currency %>)
<% if chargeback.audit_logs.present? %> <%= Kaui::AuditLog.description(chargeback.audit_logs[0]) %>
<% end %>
<% if payment.requested_date.present? %> <%= format_date(payment.requested_date, @account.timezone).html_safe %> <% else %> [unknown] <% end %> <% if payment.effective_date.present? %> <%= format_date(payment.effective_date, @account.timezone).html_safe %> <% else %> [unknown] <% end %> <% payment.bundle_keys.split(",").each do |bundle_key| %> <%= link_to @bundle_names[bundle_key], Kaui.bundle_home_path.call(bundle_key) %>
<% end %>
<%= "PAYMENT" %> <%= "Payment id:" %> <%= payment.payment_id %>
<%= "Total amount:" %> <%= humanized_money_with_symbol Kaui::Base.to_money(payment.amount, payment.currency) %> (<%= payment.currency %>)
<%= "Paid amount:" %> <%= humanized_money_with_symbol Kaui::Base.to_money(payment.paid_amount, payment.currency) %> (<%= payment.currency %>)
class="alert-error" <% elsif payment.status == 'SUCCESS' %>class="alert-success" <% end %>> <%= payment.status %>
<%= "Invoice #" %> <%= link_to invoice.invoice_number, invoice_path(:id => invoice.invoice_id) %>
<% if payment.audit_logs.present? %> <% payment.audit_logs.each do |entry| %> <%= Kaui::AuditLog.description(entry) unless entry.changed_by == 'PaymentRequestProcessor' %>
<% end %> <% end %>
<% if can? :refund, Kaui::Payment %> <%= link_to 'Refund', kaui_engine.new_refund_path(:params => { :payment_id => payment.payment_id, :account_id => @account.account_id, :invoice_id => payment.invoice_id }), :class => "btn btn-mini #{"disabled" unless payment.payment_id.present? and payment.status == 'SUCCESS' and payment.paid_amount != 0}" %> <% end %> <% if can? :chargeback, Kaui::Payment %> <%= link_to 'Chargeback', kaui_engine.new_chargeback_path(:params => { :payment_id => payment.payment_id, :account_id => @account.account_id, :invoice_id => payment.invoice_id }), :class => "btn btn-mini #{"disabled" unless payment.payment_id.present? and payment.status == 'SUCCESS'}" %> <% end %>
<% if event.requested_date.present? %> <%= format_date(event.requested_date, @account.timezone).html_safe %> <% else %> [unknown] <% end %> <% if event.effective_date.present? %> <%= format_date(event.effective_date, @account.timezone).html_safe %> <% else %> [unknown] <% end %> <%= link_to @bundle_names[bundle.external_key], Kaui.bundle_home_path.call(bundle.external_key) %>
<%= event.event_type %> <%= event.product %> <%= event.billing_period == 'NO_BILLING_PERIOD' || event.billing_period.nil? ? "" : event.billing_period.downcase.capitalize %> <%= event.phase.downcase.capitalize if event.phase.present? %> <% if event.audit_logs.present? %> <% event.audit_logs.each do |entry| %> <%= Kaui::AuditLog.description(entry) %>
<% end %> <% end %>
<%= link_to 'Back', :back, :class => 'btn' %>
<%= javascript_tag do %> function disableLinks() { $('a.btn.disabled').click(function (e) { e.preventDefault(); }); } eventsOrder = ["START_ENTITLEMENT", "START_BILLING", "PAUSE_ENTITLEMENT", "PAUSE_BILLING", "RESUME_ENTITLEMENT", "RESUME_BILLING", "PHASE", "CHANGE", , "STOP_ENTITLEMENT", "STOP_BILLING", "INVOICE", "PAYMENT", "REFUND", "CHARGEBACK"]; jQuery.fn.dataTableExt.oSort['timeline-event-asc'] = function(e1,e2) { var x = eventsOrder.indexOf(e1); var y = eventsOrder.indexOf(e2); return ((x < y) ? -1 : ((x > y) ? 1 : 0)); }; jQuery.fn.dataTableExt.oSort['timeline-event-desc'] = function(e1,e2) { var x = eventsOrder.indexOf(e1); var y = eventsOrder.indexOf(e2); return ((x < y) ? 1 : ((x > y) ? -1 : 0)); }; function extractTitleAttributeFromText(txt) { // Ugly - better way of doing this? var matches = txt.match(/title="\w+"/g); if (matches == null || matches.size == 0) { return null; } return matches[0].split('=')[1]; } jQuery.fn.dataTableExt.oSort['timeline-details-asc'] = function(e1,e2) { var x = extractTitleAttributeFromText(e1); var y = extractTitleAttributeFromText(e2); return ((x < y) ? -1 : ((x > y) ? 1 : 0)); }; jQuery.fn.dataTableExt.oSort['timeline-details-desc'] = function(e1,e2) { var x = extractTitleAttributeFromText(e1); var y = extractTitleAttributeFromText(e2); return ((x < y) ? 1 : ((x > y) ? -1 : 0)); }; function initTable() { return $("#timeline-table").dataTable({ "sDom": "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>", "sPaginationType": "bootstrap", "oLanguage": { "sLengthMenu": "_MENU_ records per page" }, "iDisplayLength": 100, "bRetrieve": true, // Force a predictive order for event types, invoices and payments "aaSorting": [[1, 'desc'], [4, 'desc'], [3, 'desc']], "aoColumns": [ { "sType": 'date' }, { "sType": 'date' }, null, { "sType": 'timeline-event' }, { "sType": 'timeline-details' }, null, null ] }); } function filterEachNode(rows) { var bundle = $("#bundles").val(); var event_to_filter = $('#event_types').val().toUpperCase(); for (i = 0; i < rows.length; i++) { tr = $(rows[i]); //filter bundles if (bundle == "" || tr.attr("title").split(",").indexOf(bundle) >= 0) { //first level filtering, so can remove hide tr.removeClass("hide"); } else { //remove tr's not under this filter mode tr.addClass("hide"); } //filter events if ("ALL" != event_to_filter) filterEvents(tr, event_to_filter); //add more filters here //do not unhide any rows } } function filterEvents(tr, event_to_filter) { tr_event_type = tr.data().event_type; core_events = ["INVOICE", "PAYMENT", "REFUND", "CHARGEBACK"]; //events which are not entitlements //is tr event not an event in question tr_event_does_not_match_filter = ("ENTITLEMENT" != event_to_filter && tr_event_type != event_to_filter); //tr event is not an entitlement tr_event_is_not_entitlement = ("ENTITLEMENT" == event_to_filter && core_events.indexOf(tr_event_type) >= 0); if ( tr_event_does_not_match_filter || tr_event_is_not_entitlement ) { //add hide to all who dont deserve the filter tr.addClass("hide"); } } function filterTable() { var dataTable = initTable(); var all_nodes = dataTable.fnGetNodes(); filterEachNode(all_nodes); //my rows are filtered, draw table dataTable.fnDraw(); } $(document).ready(function() { disableLinks(); // When going through the pages of the table, disable links as needed $('#timeline-table').bind('draw', function (e) { disableLinks(); }); initTable(); $("#bundles, #event_types").change(filterTable); filterTable(); }); <% end %>