value_key => 'payment_type',
title_key => 'display' )
if @select_options;
- $html .= '<a href=# onclick="kivi.BankTransaction.delete_invoice(' . $::form->{bt_id} . ',' . $::form->{prop_id} . ');">x</a>';
- $html = SL::Presenter->html_tag('div', $html, id => $::form->{bt_id} . '.' . $::form->{prop_id});
+ $html .= SL::Presenter->html_tag('a', 'x', href => '#', onclick => "kivi.BankTransaction.delete_invoice(" . $::form->{bt_id} . ',' . $::form->{prop_id} . ")");
+ $html = SL::Presenter->html_tag('div', $html, id => $::form->{bt_id} . '.' . $::form->{prop_id}, 'data-invoice-amount' => $invoice->open_amount * 1);
$self->render(\ SL::JSON::to_json( { 'html' => $html } ), { layout => 0, type => 'json', process => 0 });
};
url: 'controller.pl?action=BankTransaction/ajax_payment_suggestion&bt_id=' + bank_transaction_id + '&prop_id=' + proposal_id,
success: function(data) {
$('#assigned_invoices_' + bank_transaction_id).append(data.html);
+ ns.update_invoice_amount(bank_transaction_id);
}
});
};
ns.delete_invoice = function(bank_transaction_id, proposal_id) {
$( "#" + bank_transaction_id + "\\." + proposal_id ).remove();
$('[data-proposal-id=' + proposal_id + ']').show();
+ ns.update_invoice_amount(bank_transaction_id);
};
ns.create_invoice = function(bank_transaction_id) {
success: function(new_html) {
$('#assigned_invoices_' + bank_transaction_id).append(new_html);
$('#assign_invoice_window').dialog('close');
+ ns.update_invoice_amount(bank_transaction_id);
}
});
}
+ ns.update_invoice_amount = function(bank_transaction_id) {
+ var $container = $('#invoice_amount_' + bank_transaction_id);
+ var amount = $container.data('invoice-amount') * 1;
+
+ $('[id^="' + bank_transaction_id + '."]').each(function(idx, elt) {
+ amount += $(elt).data('invoice-amount');
+ });
+
+ $container.html(kivi.format_amount(amount, 2));
+ };
+
ns.init_list = function(ui_tab) {
$('#check_all').checkall('INPUT[name^="proposal_ids"]');
+
$('.sort_link').each(function() {
var _href = $(this).attr("href");
$(this).attr("href", _href + "&filter.fromdate=" + $('#filter_fromdate').val() + "&filter.todate=" + $('#filter_todate').val());
[% USE L %]
[% USE T8 %]
-[% USE LxERP %]
+[% USE LxERP %][%- USE HTML -%]
[% FOREACH invoice = INVOICES %]
- <div id="[% bt_id %].[% invoice.id %]">
+ <div id="[% bt_id %].[% invoice.id %]" data-invoice-amount="[% HTML.escape(invoice.open_amount * 1) %]">
[% L.hidden_tag('invoice_ids.' _ bt_id _'[]', invoice.id) %]
[% 'Invno.' | $T8 %]: [% invoice.invnumber %]
[% 'Open amount' | $T8 %]: [% LxERP.format_amount(invoice.open_amount, 2) %]
</td>
<td align=right>[% bt.transdate_as_date %]</td>
<td align=right>[% LxERP.format_amount(bt.amount, 2) %]</td>
- <td align=right>[% LxERP.format_amount(bt.invoice_amount, 2) %]</td>
+ <td align=right id="invoice_amount_[% HTML.escape(bt.id) %]" data-invoice-amount="[% HTML.escape(bt.invoice_amount) %]">[% HTML.escape(LxERP.format_amount(bt.invoice_amount, 2)) %]</td>
<td>[% HTML.escape(bt.remote_name) %]</td>
<td>[% HTML.escape(bt.purpose) %]</td>
<td>[% HTML.escape(bt.transaction_text) %]</td>