summaryrefslogtreecommitdiff
path: root/scripts/payment.pl
blob: d50eb15b29fcfa9c62ede0467d562972bafc55ac (plain)
  1. =pod
  2. =head1 NAME
  3. LedgerSMB::Scripts::payment - LedgerSMB class defining the Controller functions for payment handling.
  4. =head1 SYNOPSIS
  5. Defines the controller functions and workflow logic for payment processing.
  6. =head1 COPYRIGHT
  7. Copyright (c) 2007, David Mora R and Christian Ceballos B.
  8. Licensed to the public under the terms of the GNU GPL version 2 or later.
  9. Original copyright notice below.
  10. #=====================================================================
  11. # PLAXIS
  12. # Copyright (c) 2007
  13. #
  14. # Author: David Mora R
  15. # Christian Ceballos B
  16. #
  17. #
  18. #
  19. #
  20. #
  21. # This program is free software; you can redistribute it and/or modify
  22. # it under the terms of the GNU General Public License as published by
  23. # the Free Software Foundation; either version 2 of the License, or
  24. # (at your option) any later version.
  25. #
  26. # This program is distributed in the hope that it will be useful,
  27. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  28. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  29. # GNU General Public License for more details.
  30. # You should have received a copy of the GNU General Public License
  31. # along with this program; if not, write to the Free Software
  32. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  33. =head1 METHODS
  34. =cut
  35. package LedgerSMB::Scripts::payment;
  36. use LedgerSMB::Template;
  37. use LedgerSMB::DBObject::Payment;
  38. use LedgerSMB::DBObject::Date;
  39. use strict;
  40. # CT: A few notes for future refactoring of this code:
  41. # 1: I don't think it is a good idea to make the UI too dependant on internal
  42. # code structures but I don't see a good alternative at the moment.
  43. # 2: CamelCasing: -1
  44. =pod
  45. =item payment
  46. This method is used to set the filter screen and prints it, using the
  47. TT2 system.
  48. =back
  49. =cut
  50. sub payments {
  51. my ($request) = @_;
  52. my $payment = LedgerSMB::DBObject::Payment->new({'base' => $request});
  53. $payment->get_metadata();
  54. my $template = LedgerSMB::Template->new(
  55. user => $request->{_user},
  56. locale => $request->{_locale},
  57. path => 'UI/payments',
  58. template => 'payments_filter',
  59. format => 'HTML',
  60. );
  61. $template->render($payment);
  62. }
  63. sub get_search_criteria {
  64. my ($request) = @_;
  65. my $payment = LedgerSMB::DBObject::Payment->new({'base' => $request});
  66. $payment->get_metadata();
  67. if ($payment->{batch_id} && $payment->{batch_date}){
  68. $payment->{date_reversed} = $payment->{batch_date};
  69. }
  70. my $template = LedgerSMB::Template->new(
  71. user => $request->{_user},
  72. locale => $request->{_locale},
  73. path => 'UI/payments',
  74. template => 'search',
  75. format => 'HTML',
  76. );
  77. $template->render($payment);
  78. }
  79. sub get_search_results {
  80. my ($request) = @_;
  81. my $rows = [];
  82. my $payment = LedgerSMB::DBObject::Payment->new({'base' => $request});
  83. my @search_results = $payment->search;
  84. my $template = LedgerSMB::Template->new(
  85. user => $request->{_user},
  86. locale => $request->{_locale},
  87. path => 'UI',
  88. template => 'form-dynatable',
  89. format => ($payment->{format}) ? $payment->{format} : 'HTML',
  90. );
  91. my $base_url = "payment.pl?";
  92. my $search_url = "$base_url";
  93. for my $key (keys %{$request->take_top_level}){
  94. if ($base_url =~ /\?$/){
  95. $base_url .= "$key=$request->{key}";
  96. } else {
  97. $base_url .= "&$key=$request->{key}";
  98. }
  99. }
  100. my @columns = qw(selected meta_number date_paid amount source company_paid);
  101. my $contact_type = ($payment->{account_class} == 1) ? 'Vendor' : 'Customer';
  102. # CT: Locale strings for gettext:
  103. # $request->{_locale}->text("Vendor Number");
  104. # $request->{_locale}->text("Customer Number");
  105. my $heading = {
  106. selected => $request->{_locale}->text('Selected'),
  107. company_paid => {
  108. text => $request->{_locale}->text('Company Name'),
  109. href => "$search_url&orderby=company_paid",
  110. },
  111. meta_number => {
  112. text => $request->{_locale}->text(
  113. "$contact_type Number"
  114. ),
  115. href => "$search_url&orderby=meta_number",
  116. },
  117. date_paid => {
  118. text => $request->{_locale}->text('Date Paid'),
  119. href => "$search_url&orderby=date_paid",
  120. },
  121. amount => {
  122. text => $request->{_locale}->text('Total Paid'),
  123. href => "$search_url&orderby=amount",
  124. },
  125. source => {
  126. text => $request->{_locale}->text('Source'),
  127. href => "$search_url&orderby=source",
  128. },
  129. };
  130. my $classcount;
  131. $classcount = 0;
  132. my $rowcount;
  133. $rowcount = 1;
  134. for my $line (@search_results){
  135. $classcount ||= 0;
  136. $rowcount += 1;
  137. push(@$rows, {
  138. company_paid => $line->{company_paid},
  139. amount => $request->format_amount(amount => $line->{amount}),
  140. i => "$classcount",
  141. date_paid => $line->{date_paid},
  142. source => $line->{source},
  143. meta_number => $line->{meta_number},
  144. selected => {
  145. input => {
  146. type => "checkbox",
  147. name => "payment_$rowcount",
  148. value => "1",
  149. },
  150. }
  151. });
  152. $payment->{"credit_id_$rowcount"} = $line->{credit_id};
  153. $payment->{"date_paid_$rowcount"} = $line->{date_paid};
  154. $payment->{"source_$rowcount"} = $line->{source};
  155. $classcount = ($classcount + 1) % 2;
  156. ++$rowcount;
  157. }
  158. $payment->{rowcount} = $rowcount;
  159. $payment->{script} = 'payment.pl';
  160. $payment->{title} = $request->{_locale}->text("Payment Results");
  161. my $hiddens = $payment->take_top_level;
  162. $template->render({
  163. form => $payment,
  164. columns => \@columns,
  165. heading => $heading,
  166. hiddens => $payment->take_top_level,
  167. rows => $rows,
  168. buttons => [{
  169. value => 'reverse_payments',
  170. name => 'action',
  171. class => 'submit',
  172. type => 'submit',
  173. text => $request->{_locale}->text('Reverse Payments'),
  174. }]
  175. });
  176. }
  177. sub get_search_results_reverse_payments {
  178. my ($request) = @_;
  179. my $payment = LedgerSMB::DBObject::Payment->new({base => $request});
  180. for my $count (1 .. $payment->{rowcount}){
  181. if ($payment->{"payment_$count"}){
  182. $payment->{credit_id} = $payment->{"credit_id_$count"};
  183. $payment->{date_paid} = $payment->{"date_paid_$count"};
  184. $payment->{source} = $payment->{"source_$count"};
  185. $payment->reverse;
  186. }
  187. }
  188. get_search_criteria($payment);
  189. }
  190. sub check_job {
  191. my ($request) = @_;
  192. my $payment = LedgerSMB::DBObject::Payment->new({'base' => $request});
  193. $payment->check_job;
  194. my $template = LedgerSMB::Template->new(
  195. user => $request->{_user},
  196. locale => $request->{_locale},
  197. path => 'UI/payments',
  198. template => 'check_job',
  199. format => 'HTML',
  200. );
  201. $template->render($payment);
  202. }
  203. sub post_payments_bulk {
  204. my ($request) = @_;
  205. my $payment = LedgerSMB::DBObject::Payment->new({'base' => $request});
  206. $payment->post_bulk();
  207. my $template;
  208. if ($payment->{queue_payments}){
  209. $payment->{job_label} = 'Payments';
  210. $template = LedgerSMB::Template->new(
  211. user => $request->{_user},
  212. locale => $request->{_locale},
  213. path => 'UI/payments',
  214. template => 'check_job',
  215. format => 'HTML',
  216. );
  217. } else {
  218. payments($request);
  219. }
  220. $template->render($payment);
  221. }
  222. sub display_payments {
  223. my ($request) = @_;
  224. my $payment = LedgerSMB::DBObject::Payment->new({'base' => $request});
  225. $payment->get_payment_detail_data();
  226. $payment->debug({file => '/tmp/delme'});
  227. for (@{$payment->{contact_invoices}}){
  228. $_->{total_due} = $payment->format_amount(amount => $_->{total_due});
  229. }
  230. my $template = LedgerSMB::Template->new(
  231. user => $request->{_user},
  232. locale => $request->{_locale},
  233. path => 'UI/payments',
  234. template => 'payments_detail',
  235. format => 'HTML',
  236. );
  237. $template->render($payment);
  238. }
  239. =item payment
  240. This method is used to set the filter screen and prints it, using the
  241. TT2 system. (hopefully it will... )
  242. =back
  243. =cut
  244. sub payment {
  245. my ($request) = @_;
  246. my $locale = $request->{_locale};
  247. my $dbPayment = LedgerSMB::DBObject::Payment->new({'base' => $request});
  248. # Lets get the project data...
  249. my @projectOptions;
  250. my @arrayOptions = $dbPayment->list_open_projects();
  251. push @projectOptions, {}; #A blank field on the select box
  252. for my $ref (0 .. $#arrayOptions) {
  253. push @projectOptions, { value => $arrayOptions[$ref]->{id}."--".$arrayOptions[$ref]->{projectnumber}."--".$arrayOptions[$ref]->{description},
  254. text => $arrayOptions[$ref]->{projectnumber}."--".$arrayOptions[$ref]->{description}};
  255. }
  256. # Lets get the departments data...
  257. my @departmentOptions;
  258. my $role = $request->{type} eq 'receipt' ? 'P' : 'C';
  259. @arrayOptions = $dbPayment->list_departments($role);
  260. push @departmentOptions, {}; # A blank field on the select box
  261. for my $ref (0 .. $#arrayOptions) {
  262. push @departmentOptions, { value => $arrayOptions[$ref]->{id}."--".$arrayOptions[$ref]->{description},
  263. text => $arrayOptions[$ref]->{description}};
  264. }
  265. # Lets get the customer or vendor :)
  266. my @vcOptions;
  267. @arrayOptions = $dbPayment->get_open_accounts();
  268. for my $ref (0 .. $#arrayOptions) {
  269. push @vcOptions, { value => $arrayOptions[$ref]->{id}.'--'.$arrayOptions[$ref]->{name},
  270. text => $arrayOptions[$ref]->{name}};
  271. }
  272. # Lets get the open currencies (this uses the $dbPayment->{account_class} property)
  273. my @currOptions;
  274. @arrayOptions = $dbPayment->get_open_currencies();
  275. for my $ref (0 .. $#arrayOptions) {
  276. push @currOptions, { value => $arrayOptions[$ref]->{payments_get_open_currencies},
  277. text => $arrayOptions[$ref]->{payments_get_open_currencies} };
  278. }
  279. # Lets build filter by period
  280. my $date = LedgerSMB::DBObject::Date->new({base => $request});
  281. $date->build_filter_by_period($locale);
  282. # Lets set the data in a hash for the template system. :)
  283. my $select = {
  284. stylesheet => $request->{_user}->{stylesheet},
  285. login => { name => 'login',
  286. value => $request->{_user}->{login} },
  287. projects => {
  288. name => 'projects',
  289. options => \@projectOptions
  290. },
  291. department => {
  292. name => 'department',
  293. options => \@departmentOptions
  294. },
  295. vendor_customer => {
  296. name => 'vendor-customer',
  297. options => \@vcOptions
  298. },
  299. curr => {
  300. name => 'curr',
  301. options => \@currOptions
  302. },
  303. month => {
  304. name => 'month',
  305. options => $date->{monthsOptions}
  306. },
  307. year => {
  308. name => 'year',
  309. options => $date->{yearsOptions}
  310. },
  311. interval_radios => $date->{radioOptions},
  312. amountfrom => {
  313. name => 'amountfrom',
  314. },
  315. amountto => {
  316. name => 'amountto',
  317. },
  318. accountclass => {
  319. name => 'account_class',
  320. value => $dbPayment->{account_class}
  321. },
  322. type => {
  323. name => 'type',
  324. value => $request->{type}
  325. },
  326. action => {
  327. name => 'action',
  328. value => 'payment2',
  329. text => $locale->text("Continue"),
  330. },
  331. };
  332. # Lets call upon the template system
  333. my $template;
  334. $template = LedgerSMB::Template->new(
  335. user => $request->{_user},
  336. locale => $request->{_locale},
  337. path => 'UI/payments',
  338. template => 'payment1',
  339. format => 'HTML', );
  340. $template->render($select);# And finally, Lets print the screen :)
  341. }
  342. =pod
  343. =item payment2
  344. This method is used for the payment module, it is a consecuence of the payment sub,
  345. and its used for all the mechanics of an invoices payment module.
  346. =back
  347. =cut
  348. sub payment2 {
  349. my ($request) = @_;
  350. my $locale = $request->{_locale};
  351. my $Payment = LedgerSMB::DBObject::Payment->new({'base' => $request});
  352. # VARIABLES
  353. my ($project_id, $project_number, $project_name, $department_id, $department_name );
  354. my @array_options;
  355. my @project;
  356. my @selected_checkboxes;
  357. my @department;
  358. my @array_options;
  359. my @currency_options;
  360. my $exchangerate;
  361. # LETS GET THE CUSTOMER/VENDOR INFORMATION
  362. # TODO TODO TODO TODO TODO TODO TODO
  363. ($Payment->{entity_id}, $Payment->{company_name}) = split /--/ , $request->{'vendor-customer'};
  364. # WE NEED TO RETRIEVE A BILLING LOCATION, THIS IS HARDCODED FOR NOW... Should we change it?
  365. $Payment->{location_class_id} = '1';
  366. #$request->error($Payment->{entity_id});
  367. my @vc_options;
  368. @vc_options = $Payment->get_vc_info();
  369. # TODO TODO TODO TODO TODO TODO TODO
  370. # LETS BUILD THE PROJECTS INFO
  371. # I DONT KNOW IF I NEED ALL THIS, BUT AS IT IS AVAILABLE I'LL STORE IT FOR LATER USAGE.
  372. if ($request->{projects}) {
  373. ($project_id, $project_number, $project_name) = split /--/ , $request->{projects} ;
  374. @project = { name => 'projects', text => $project_number.' '.$project_name, value => $request->{projects}};
  375. }
  376. # LETS GET THE DEPARTMENT INFO
  377. # WE HAVE TO SET $dbPayment->{department_id} NOW, THIS DATA WILL BE USED LATER WHEN WE
  378. # CALL FOR payment_get_open_invoices. :)
  379. if ($request->{department}) {
  380. ($Payment->{department_id}, $department_name) = split /--/, $request->{department};
  381. @department = { name => 'department', text => $department_name, value => $request->{department}};
  382. }
  383. # LETS GET ALL THE ACCOUNTS
  384. my @account_options = $Payment->list_accounting();
  385. # LETS GET THE POSSIBLE SOURCES
  386. my @sources_options = $Payment->get_sources(\%$locale);
  387. # WE MUST PREPARE THE ENTITY INFORMATION
  388. @array_options = $Payment->get_vc_info();
  389. # LETS BUILD THE CURRENCIES INFORMATION
  390. # FIRST, WE NEED TO KNOW THE DEFAULT CURRENCY
  391. my $default_currency = $Payment->get_default_currency();
  392. # LETS BUILD THE COLUMN HEADERS WE ALWAYS NEED
  393. # THE OTHER HEADERS WILL BE BUILT IF THE RIGHT CONDITIONS ARE MET.
  394. # -----------------------------------------------
  395. # SOME USERS WONT USE MULTIPLE CURRENCIES, AND WONT LIKE THE FACT CURRENCY BEING
  396. # ON THE SCREEN ALL THE TIME, SO IF THEY ARE USING THE DEFAULT CURRENCY WE WONT PRINT IT
  397. my $currency_text = $request->{curr} eq $default_currency ? '' : '('.$request->{curr}.')';
  398. my $default_currency_text = $currency_text ? '('.$default_currency.')' : '';
  399. my @column_headers = ({text => $locale->text('Invoice')},
  400. {text => $locale->text('Date')},
  401. {text => $locale->text('Total').$default_currency_text},
  402. {text => $locale->text('Paid').$default_currency_text},
  403. {text => $locale->text('Amount Due').$default_currency_text},
  404. {text => $locale->text('To pay').$default_currency_text}
  405. );
  406. # WE NEED TO KNOW IF WE ARE USING A CURRENCY THAT NEEDS AN EXCHANGERATE
  407. if ($default_currency ne $request->{curr} ) {
  408. # FIRST WE PUSH THE OTHER COLUMN HEADERS WE NEED
  409. push @column_headers, {text => $locale->text('Exchange Rate')},
  410. {text => $locale->text('Amount Due').$currency_text},
  411. {text => $locale->text('To pay').$currency_text};
  412. # WE SET THEM IN THE RIGHT ORDER FOR THE TABLE INSIDE THE UI
  413. @column_headers[5,6,7] = @column_headers[6,7,5];
  414. # DOES THE CURRENCY IN USE HAS AN EXCHANGE RATE?, IF SO
  415. # WE MUST SET THE VALUE, OTHERWISE THE UI WILL HANDLE IT
  416. $exchangerate = $request->{exrate} ?
  417. $request->{exrate} :
  418. $Payment->get_exchange_rate($request->{curr},
  419. $request->{datepaid} ? $request->{datepaid} : $Payment->{current_date});
  420. if ($exchangerate) {
  421. @currency_options = {
  422. name => 'exrate',
  423. value => "$exchangerate", #THERE IS A STRANGE BEHAVIOUR WITH THIS,
  424. text => "$exchangerate" #IF I DONT USE THE DOUBLE QUOTES, IT WILL PRINT THE ADDRESS
  425. #THERE MUST BE A REASON FOR THIS, I MUST RETURN TO IT LATER
  426. };
  427. } else {
  428. @currency_options = {
  429. name => 'exrate'};
  430. }
  431. } else {
  432. # WE MUST SET EXCHANGERATE TO 1 FOR THE MATHS SINCE WE
  433. # ARE USING THE DEFAULT CURRENCY
  434. $exchangerate = 1;
  435. @currency_options = {
  436. name => 'exrate',
  437. value => 1,
  438. text => 1
  439. };
  440. }
  441. # FINALLY WE ADD TO THE COLUMN HEADERS A LAST FIELD TO PRINT THE CLOSE INVOICE CHECKBOX TRICK :)
  442. push @column_headers, {text => 'X'};
  443. # WE NEED TO QUERY THE DATABASE TO CHECK FOR OPEN INVOICES
  444. # WE WONT DO ANYTHING IF WE DONT FIND ANY INVOICES, THE USER CAN STILL POST A PREPAYMENT
  445. my @invoice_data;
  446. my @topay_state; # WE WILL USE THIS TO HELP UI TO DETERMINE WHAT IS VISIBLE
  447. @array_options = $Payment->get_open_invoices();
  448. for my $ref (0 .. $#array_options) {
  449. if ( !$request->{"checkbox_$array_options[$ref]->{invoice_id}"}) {
  450. # LETS SET THE EXCHANGERATE VALUES
  451. my $due_fx; my $topay_fx_value;
  452. if ("$exchangerate") {
  453. $topay_fx_value = $due_fx = "$array_options[$ref]->{due}"/"$exchangerate";
  454. } else {
  455. $topay_fx_value = $due_fx = "N/A";
  456. }
  457. push @invoice_data, { invoice => { number => $array_options[$ref]->{invnumber},
  458. id => $array_options[$ref]->{invoice_id},
  459. href => 'ar.pl?id='."$array_options[$ref]->{invoice_id}"
  460. },
  461. invoice_date => "$array_options[$ref]->{invoice_date}",
  462. amount => "$array_options[$ref]->{amount}",
  463. due => "$array_options[$ref]->{due}",
  464. paid => "$array_options[$ref]->{amount}" - "$array_options[$ref]->{due}",
  465. exchange_rate => "$exchangerate",
  466. due_fx => $due_fx, # This was set at the begining of the for statement
  467. topay => "$array_options[$ref]->{due}",
  468. source_text => $request->{"source_text_$array_options[$ref]->{invoice_id}"},
  469. optional => $request->{"optional_pay_$array_options[$ref]->{invoice_id}"},
  470. selected_account => $request->{"account_$array_options[$ref]->{invoice_id}"},
  471. selected_source => $request->{"source_$array_options[$ref]->{invoice_id}"},
  472. topay_fx => { name => "topay_fx_$array_options[$ref]->{invoice_id}",
  473. value => $request->{"topay_fx_$array_options[$ref]->{invoice_id}"} ?
  474. $request->{"topay_fx_$array_options[$ref]->{invoice_id}"} eq 'N/A' ?
  475. $topay_fx_value :
  476. $request->{"topay_fx_$array_options[$ref]->{invoice_id}"} :
  477. $topay_fx_value
  478. # Ugly hack, but works ;) ...
  479. }#END HASH
  480. };# END PUSH
  481. push @topay_state, {
  482. id => "topaystate_$array_options[$ref]->{invoice_id}",
  483. value => $request->{"topaystate_$array_options[$ref]->{invoice_id}"}
  484. }; #END PUSH
  485. }
  486. else {
  487. push @selected_checkboxes, {name => "checkbox_$array_options[$ref]->{invoice_id}",
  488. value => "checked"} ;
  489. } #END IF
  490. }# END FOR
  491. # And finally, we are going to store the information for the overpayment / prepayment / advanced payment
  492. # and all the stuff, this is only needed for the update function.
  493. my @overpayment;
  494. my @overpayment_account;
  495. # Got to build the account selection box first.
  496. my @overpayment_account = $Payment->list_overpayment_accounting();
  497. # Now we build the structure for the UI
  498. for (my $i=1 ; $i <= $request->{overpayment_qty}; $i++) {
  499. if (!$request->{"overpayment_checkbox_$i"}) {
  500. if ( $request->{"overpayment_topay_$i"} ) {
  501. # Now we split the account selected options
  502. my ($id, $accno, $description) = split(/--/, $request->{"overpayment_account_$i"});
  503. push @overpayment, {amount => $request->{"overpayment_topay_$i"},
  504. source1 => $request->{"overpayment_source1_$i"},
  505. source2 => $request->{"overpayment_source2_$i"},
  506. account => { id => $id,
  507. accno => $accno,
  508. description => $description
  509. }
  510. };
  511. } else {
  512. $i = $request->{overpayment_qty} + 1;
  513. }
  514. }
  515. }
  516. # LETS BUILD THE SELECTION FOR THE UI
  517. my $select = {
  518. stylesheet => $request->{_user}->{stylesheet},
  519. header => { text => $request->{type} eq 'receipt' ? $locale->text('Receipt') : $locale->text('Payment') },
  520. login => { name => 'login',
  521. value => $request->{_user}->{login} },
  522. accountclass => {
  523. name => 'account_class',
  524. value => $Payment->{account_class}
  525. },
  526. project => @project ? @project : '' , # WE NEED TO VERIFY THAT THE ARRAY EXISTS, IF IT DOESNT,
  527. department => @department ? @department : '', # WE WILL PASS A NULL STRING, THIS FIXES THE ISSUES
  528. # I WAS HAVING WITH THE NULL ARRAYS, STILL UGLY :P
  529. account => \@account_options,
  530. selected_account => $request->{account},
  531. datepaid => {
  532. name => 'datepaid',
  533. value => $request->{datepaid} ? $request->{datepaid} : $Payment->{current_date}
  534. },
  535. source => \@sources_options,
  536. selected_source => $request->{source},
  537. source_value => $request->{source_value},
  538. defaultcurrency => {
  539. text => $default_currency
  540. },
  541. curr => { name => 'curr',
  542. value => $request->{curr},
  543. },
  544. column_headers => \@column_headers,
  545. rows => \@invoice_data,
  546. topay_state => \@topay_state,
  547. vendorcustomer => { name => 'vendor-customer',
  548. value => $request->{'vendor-customer'}
  549. },
  550. vc => { name => $Payment->{company_name}, # We will assume that the first Billing Information as default
  551. address => [ {text => $vc_options[0]->{'line_one'}},
  552. {text => $vc_options[0]->{'line_two'}},
  553. {text => $vc_options[0]->{'line_three'}},
  554. {text => $vc_options[0]->{city}},
  555. {text => $vc_options[0]->{state}},
  556. {text => $vc_options[0]->{country}}]
  557. },
  558. format => {
  559. name => 'FORMAT',
  560. options => [
  561. {value => 1, text => "HTML" },
  562. {value => 2, text => "PDF" },
  563. {value => 3, text => "POSTSCRIPT" }
  564. ],
  565. },
  566. media => {
  567. name => 'MEDIA',
  568. options => [
  569. {value => 1, text => "Screen" },
  570. {value => 2, text => "PRINTER" },
  571. {value => 3, text => "EMAIL" }
  572. ],
  573. },
  574. exrate => @currency_options,
  575. selectedcheckboxes => @selected_checkboxes ? \@selected_checkboxes : '',
  576. notes => $request->{notes},
  577. overpayment => \@overpayment,
  578. overpayment_account => \@overpayment_account
  579. };
  580. my $template = LedgerSMB::Template->new(
  581. user => $request->{_user},
  582. locale => $request->{_locale},
  583. path => 'UI/payments',
  584. template => 'payment2',
  585. format => 'HTML' );
  586. eval {$template->render($select) };
  587. if ($@) { $request->error("$@"); } # PRINT ERRORS ON THE UI
  588. }
  589. eval { do "scripts/custom/payment.pl"};
  590. 1;