[% PROCESS elements.html # Include form elements helper. %] [% subtotal_inv = 0 %]

[% header.text %]

[% IF account_class == 1 -%] [% text('Vendor') -%] [% ELSE -%] [% text('Customer') -%] [% END -%] | [% vc_entity_info.legal_name -%]
[% text('Location') -%] | [% IF vc_entity_info.street1 -%]
[% vc_entity_info.street1 -%]
[% END -%] [% IF vc_entity_info.street2 -%]
[% vc_entity_info.street2 -%]
[% END -%] [% IF vc_entity_info.street3 -%]
[% vc_entity_info.street3 -%]
[% END -%] [% IF vc_entity_info.city -%]
[% vc_entity_info.city -%]
[% END -%] [% IF vc_entity_info.state -%]
[% vc_entity_info.state -%]
[% END -%] [% IF vc_entity_info.country -%]
[% vc_entity_info.country -%]
[% END -%]
[% text('Notes') %] | [% PROCESS textarea element_data = { id="notes" name="notes" cols="35" rows="3" text=notes } %]
[% # here goes an input where the date can be written, we can also use a java calendar :). We can use an ajax script to call the Exchange rate of the input date which can be called with the onChange Method %] [% text('Date')%]: | [% datepaid.class = 'date'; INCLUDE input element_data=datepaid %]
[% # here goes the selected currency in step 1 %] [% text('Currency') -%]: | [% curr -%]
[% # here goes the exchange rate of the selected currency, it can be done by the ajax script or the update button %] [% IF default_curr != curr # Only process element if one exists. %]
[% text('Exchange Rate') %]: | [% IF exrate.value -%] [% exrate.text -%] [% exrate.type='hidden'; INCLUDE input element_data=exrate -%] [% END -%] [% IF !exrate.value -%] [% exrate.size = 4 -%] [% INCLUDE input element_data=exrate -%] [% END -%]
[% ELSE -%] [% exrate.type='hidden'; INCLUDE input element_data=exrate -%] [% END -%]

[% # First we show the user how much overpayment is available for each account -%]

[% text('Available overpayments') -%]
[% text('Account Number') -%] | [% text('Account Description') -%] | [% text('Available') -%] | [% text('To be used') -%]
--- | --- | --- | ---
[% i = '0'; topay_subtotal = 0 -%] [% FOREACH data IN overpayments # Loop through columns %] [% i = i + 1; j = i % 2; alterning_style = "listrow$j" %] [% accno = data.accno -%]
[% data.accno -%] | [% data.description -%] | [% data.available -%] | [% data.touse -%]
[% END %]
[% text('Subtotal') -%] | [% avble_subtotal -%] | [% to_use_subtotal -%]

[% text('Select invoices') -%]
[% text('Invoice Number') -%] | [% text('Vendor') -%]/[% text('Customer') -%] | [% text('Invoice date') -%] | [% text('Invoice due') -%] | [% text('Overpayment Account') %] | [% text('Amount to be used') -%] | X
--- | --- | --- | --- | --- | --- | ---
[% i = 0 -%] [% subtotal_inv = 0 -%] [% FOREACH data IN selected_inv # Loop through selected and found invoices -%] [% i = i + 1; j = i % 2; alterning_style = "listrow$j" -%]
[% data.invoice.number %] [% PROCESS input element_data = { type="hidden" id="invnumber_$i" name="invnumber_$i" value=data.invoice.number } %] [% PROCESS input element_data = { type="hidden" id="invoice_id_$i" name="invoice_id_$i" value=data.invoice.id } %] | [% data.entity_name %] [% PROCESS input element_data = { type="hidden" id="entity_id_$i" name="entity_id_$i" value=data.entity_id } %] | [% data.invoice_date %] [% PROCESS input element_data = { type="hidden" id="invoice_date_$i" name="invoice_date_$i" value=data.invoice_date } %] | [% data.applied_due -%] [% PROCESS input element_data { type="hidden" id="due_$i" name="due_$i" value=data.due } %] [% IF data.repeated_invoice == 'true' -%] | [% END -%] | [% data.selected_accno.ovp_accno %] [% PROCESS input element_data = { type="hidden" id="selected_accno_$i" name="selected_accno_$i" value=data.selected_accno.id _ '--' _ data.selected_accno.ovp_accno } %] | [% PROCESS input element_data = { name="amount_$i" id="amount_$i" value=data.amount } %] [% subtotal_inv = subtotal_inv + data.amount -%] | [% PROCESS input element_data = { type="checkbox" name="checkbox_$i" } %]
[% END -%] [% FOREACH data IN avble_invoices; # Loop through selected entity invoices IF not data.amount; data.amount = 0; END; -%] [% i = i + 1; j = i % 2; alterning_style = "listrow$j" -%]
[% data.invoice.number %] [% PROCESS input element_data = { type="hidden" id="invnumber_$i" name="invnumber_$i" value=data.invoice.number } %] [% PROCESS input element_data = { type="hidden" id="invoice_id_$i" name="invoice_id_$i" value=data.invoice.id } %] | [% data.entity_name %] [% PROCESS input element_data = { type="hidden" id="entity_id_$i" name="entity_id_$i" value=data.entity_id } %] | [% data.invoice_date %] [% PROCESS input element_data = { type="hidden" id="invoice_date_$i" name="invoice_date_$i" value=data.invoice_date } %] | [% data.due %] [% PROCESS input element_data = { type="hidden" id="due_$i" name="due_$i" value=data.due } %] [% IF data.repeated_invoice == 'true' -%] | [% END -%] | [% data.selected_accno.ovp_accno %] [% PROCESS input element_data = { type="hidden" id="selected_accno_$i" name="selected_accno_$i" value=data.selected_accno.id _ '--' _ data.selected_accno.ovp_accno } %] | [% PROCESS input element_data = { name="amount_$i" id="amount_$i" value=data.amount } %] [% subtotal_inv = subtotal_inv + data.amount -%] | [% PROCESS input element_data = { type="checkbox" name="checkbox_$i" } %]
[% END -%] [% i = i + 1; j = i % 2; alterning_style = "listrow$j" -%]
[% PROCESS input element_data = { name="new_invoice" id="new_invoice" value="" } %] | [% FOREACH item in vc_list ; item.id = item.value ; item.value = item.value _ '--' _ item.name _ '--' _ item.vc_discount_accno ; IF item.id == entity_credit_id ; selected_value = item.value ; END ; END %] [% PROCESS select element_data = { name = 'new_entity_id' value_attr = 'value' text_attr = 'name' options = vc_list default_values = [ request.new_entity_id ] default_blank = 1 } %] | N/A | N/A | [% PROCESS select element_data = { id="new_accno" name="new_accno" options = overpayments value_attr = 'id' text_attr = 'accno' } %] | [% PROCESS input element_data = { name="new_amount" id="new_amount" value="" } %] | [% PROCESS input element_data = { type="checkbox" name="new_checkbox" checked=dont_search_inv } %]
[% text('Subtotal') -%] | [% subtotal_inv -%] [% PROCESS input element_data = { type="hidden" id="subtotal_inv" name="subtotal_inv" value=subtotal_inv } %] |

[% FOREACH item IN hiddens -%] [% INCLUDE input element_data=item %] [% END -%]