1 #=====================================================================
2 # SQL-Ledger, accounting project
5 # Author: Dieter Simader
6 # Email: dsimader@sql-ledger.org
7 # Web: http://www.sql-ledger.org
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2 of the License, or
14 # (at your option) any later version.
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write to the Free Software
22 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #======================================================================
27 #======================================================================
34 require "$form->{path}/arap.pl";
35 require "$form->{path}/arapprn.pl";
41 # this is for our long dates
42 # $locale->text('January')
43 # $locale->text('February')
44 # $locale->text('March')
45 # $locale->text('April')
46 # $locale->text('May ')
47 # $locale->text('June')
48 # $locale->text('July')
49 # $locale->text('August')
50 # $locale->text('September')
51 # $locale->text('October')
52 # $locale->text('November')
53 # $locale->text('December')
55 # this is for our short month
56 # $locale->text('Jan')
57 # $locale->text('Feb')
58 # $locale->text('Mar')
59 # $locale->text('Apr')
60 # $locale->text('May')
61 # $locale->text('Jun')
62 # $locale->text('Jul')
63 # $locale->text('Aug')
64 # $locale->text('Sep')
65 # $locale->text('Oct')
66 # $locale->text('Nov')
67 # $locale->text('Dec')
72 $form->{title} = "Add";
74 $form->{callback} = "$form->{script}?action=add&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}" unless $form->{callback};
84 $form->{title} = "Edit";
102 $form->create_links("AP", \%myconfig, "vendor");
104 $duedate = $form->{duedate};
106 $form->{formname} = "transaction";
107 $form->{format} = "postscript" if $myconfig{printer};
108 $form->{media} = $myconfig{printer};
111 @curr = split /:/, $form->{currencies};
113 $form->{defaultcurrency} = $curr[0];
115 map { $form->{selectcurrency} .= "<option>$_\n" } @curr;
117 IR->get_vendor(\%myconfig, \%$form);
119 $form->{duedate} = $duedate if $duedate;
120 $form->{notes} = $form->{intnotes} if !$form->{id};
122 $form->{oldvendor} = "$form->{vendor}--$form->{vendor_id}";
123 $form->{oldtransdate} = $form->{transdate};
126 if (@{ $form->{all_vendor} }) {
127 $form->{vendor} = qq|$form->{vendor}--$form->{vendor_id}|;
128 map { $form->{selectvendor} .= qq|<option value="$_->{name}--$_->{id}">$_->{name}\n| } (@{ $form->{all_vendor} });
132 if (@{ $form->{all_departments} }) {
133 $form->{selectdepartment} = "<option>\n";
134 $form->{department} = "$form->{department}--$form->{department_id}";
136 map { $form->{selectdepartment} .= qq|<option value="$_->{description}--$_->{id}">$_->{description}\n| } (@{ $form->{all_departments} });
139 $form->{employee} = "$form->{employee}--$form->{employee_id}";
142 if (@{ $form->{all_projects} }) {
143 $form->{selectprojectnumber} = "<option>\n";
144 map { $form->{selectprojectnumber} .= qq|<option value="$_->{projectnumber}--$_->{id}">$_->{projectnumber}\n| } (@{ $form->{all_projects} });
147 if (@{ $form->{all_languages} }) {
148 $form->{selectlanguage} = "<option>\n";
149 map { $form->{selectlanguage} .= qq|<option value="$_->{code}">$_->{description}\n| } @{ $form->{all_languages} };
153 $form->{forex} = $form->{exchangerate};
154 $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
156 foreach $key (keys %{ $form->{AP_links} }) {
158 foreach $ref (@{ $form->{AP_links}{$key} }) {
159 if ($key eq "AP_tax") {
160 $form->{"selectAP_tax_$ref->{accno}"} = "<option>$ref->{accno}--$ref->{description}\n";
161 $form->{"calctax_$ref->{accno}"} = 1;
164 $form->{"select$key"} .= "<option>$ref->{accno}--$ref->{description}\n";
167 # if there is a value we have an old entry
168 for $i (1 .. scalar @{ $form->{acc_trans}{$key} }) {
170 if ($key eq "AP_paid") {
171 $form->{"AP_paid_$i"} = "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
172 $form->{"paid_$i"} = $form->{acc_trans}{$key}->[$i-1]->{amount};
173 $form->{"datepaid_$i"} = $form->{acc_trans}{$key}->[$i-1]->{transdate};
174 $form->{"source_$i"} = $form->{acc_trans}{$key}->[$i-1]->{source};
175 $form->{"memo_$i"} = $form->{acc_trans}{$key}->[$i-1]->{memo};
177 $form->{"forex_$i"} = $form->{"exchangerate_$i"} = $form->{acc_trans}{$key}->[$i-1]->{exchangerate};
179 $form->{paidaccounts}++;
185 if ($key eq "AP_tax") {
186 $form->{"${key}_$form->{acc_trans}{$key}->[$i-1]->{accno}"} = "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
187 $form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"} = $form->round_amount($form->{acc_trans}{$key}->[$i-1]->{amount} / $exchangerate * -1, 2);
188 if ($form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"} > 0) {
189 $totaltax += $form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"};
190 $taxrate += $form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"};
192 $totalwithholding += $form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"};
193 $withholdingrate += $form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"};
197 $form->{"${akey}_$i"} = $form->round_amount($form->{acc_trans}{$key}->[$i-1]->{amount} / $exchangerate, 2);
198 if ($akey eq 'amount') {
199 $form->{"${akey}_$i"} *= -1;
200 $totalamount += $form->{"${akey}_$i"};
203 $form->{"projectnumber_$i"} = "$form->{acc_trans}{$key}->[$i-1]->{projectnumber}--$form->{acc_trans}{$key}->[$i-1]->{project_id}";
205 $form->{"${key}_$i"} = "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
211 $form->{paidaccounts} = 1 if not defined $form->{paidaccounts};
213 if ($form->{taxincluded} && $totalamount) {
214 # add tax to amounts and invtotal
215 for $i (1 .. $form->{rowcount}) {
216 $taxamount = ($totaltax + $totalwithholding) * $form->{"amount_$i"} / $totalamount;
217 $tax = $form->round_amount($taxamount, 2);
218 $diff += ($taxamount - $tax);
219 $form->{"amount_$i"} += $tax;
221 $form->{amount_1} += $form->round_amount($diff, 2);
224 # check if calculated is equal to stored
225 foreach $item (split / /, $form->{taxaccounts}) {
226 if ($form->{taxincluded}) {
227 if ($form->{"${item}_rate"} > 0) {
229 $taxamount = $form->round_amount(($totalamount + $totaltax + $totalwithholding) * $taxrate / (1 + $taxrate), 2) * $form->{"${item}_rate"} / $taxrate;
232 if ($withholdingrate) {
233 $taxamount = $form->round_amount(($totalamount + $totaltax + $totalwithholding) * $withholdingrate / (1 - $withholdingrate), 2) * $form->{"${item}_rate"} / $withholdingrate;
237 $taxamount = $totalamount * $form->{"${item}_rate"};
239 $taxamount = $form->round_amount($taxamount, 2);
241 $form->{"calctax_$item"} = 0;
242 if ($form->{"tax_$item"} == $taxamount) {
243 $form->{"calctax_$item"} = 1;
247 $form->{invtotal} = $totalamount + $totaltax + $totalwithholding;
248 $form->{rowcount}++ if $form->{id};
250 $form->{AP} = $form->{AP_1};
251 $form->{rowcount} = 1 unless $form->{AP_amount_1};
253 $form->{locked} = ($form->{revtrans}) ? '1' : ($form->datetonum($form->{transdate}, \%myconfig) <= $form->datetonum($form->{closedto}, \%myconfig));
256 $form->{readonly} = 1 if $myconfig{acs} =~ /AP--Add Transaction/;
263 $title = $form->{title};
264 $form->{title} = $locale->text("$title AP Transaction");
266 $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
268 # type=submit $locale->text('Add AP Transaction')
269 # type=submit $locale->text('Edit AP Transaction')
271 # set option selected
272 foreach $item (qw(AP currency)) {
273 $form->{"select$item"} =~ s/ selected//;
274 $form->{"select$item"} =~ s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
277 foreach $item (qw(vendor department)) {
278 $form->{"select$item"} = $form->unescape($form->{"select$item"});
279 $form->{"select$item"} =~ s/ selected//;
280 $form->{"select$item"} =~ s/(<option value="\Q$form->{$item}\E")/$1 selected/;
283 $form->{selectprojectnumber} = $form->unescape($form->{selectprojectnumber});
286 $form->{exchangerate} = $form->format_amount(\%myconfig, $form->{exchangerate});
289 <input type=hidden name=forex value=$form->{forex}>
291 if ($form->{currency} ne $form->{defaultcurrency}) {
292 if ($form->{forex}) {
294 <th align=right>|.$locale->text('Exchange Rate').qq|</th>
295 <td><input type=hidden name=exchangerate value=$form->{exchangerate}>$form->{exchangerate}</td>
299 <th align=right>|.$locale->text('Exchange Rate').qq|</th>
300 <td><input name=exchangerate size=10 value=$form->{exchangerate}></td>
306 if ($form->{taxaccounts}) {
309 <td align=right><input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}></td>
310 <th align=left nowrap>|.$locale->text('Tax Included').qq|</th>
316 if (($rows = $form->numtextrows($form->{notes}, 50)) < 2) {
319 $notes = qq|<textarea name=notes rows=$rows cols=50 wrap=soft>$form->{notes}</textarea>|;
323 <th align="right" nowrap>|.$locale->text('Department').qq|</th>
324 <td colspan=3><select name=department>$form->{selectdepartment}</select>
325 <input type=hidden name=selectdepartment value="|.$form->escape($form->{selectdepartment},1).qq|">
328 | if $form->{selectdepartment};
330 $n = ($form->{creditremaining} < 0) ? "0" : "1";
332 $vendor = ($form->{selectvendor}) ? qq|<select name=vendor>$form->{selectvendor}</select>| : qq|<input name=vendor value="$form->{vendor}" size=35>|;
340 <form method=post action=$form->{script}>
342 <input type=hidden name=id value=$form->{id}>
344 <input type=hidden name=type value="transaction">
345 <input type=hidden name=vc value="vendor">
347 <input type=hidden name=queued value="$form->{queued}">
348 <input type=hidden name=printed value="$form->{printed}">
349 <input type=hidden name=emailed value="$form->{emailed}">
351 <input type=hidden name=sort value=$form->{sort}>
353 <input type=hidden name=closedto value=$form->{closedto}>
354 <input type=hidden name=locked value=$form->{locked}>
356 <input type=hidden name=title value="$title">
358 <input type=hidden name=employee value="$form->{employee}">
360 <input type=hidden name=oldtransdate value=$form->{oldtransdate}>
361 <input type=hidden name=audittrail value="$form->{audittrail}">
365 <th class=listtop>$form->{title}</th>
375 <th align=right nowrap>|.$locale->text('Vendor').qq|</th>
376 <td colspan=3>$vendor</td>
377 <input type=hidden name=selectvendor value="|.$form->escape($form->{selectvendor},1).qq|">
378 <input type=hidden name=oldvendor value="$form->{oldvendor}">
379 <input type=hidden name=vendor_id value="$form->{vendor_id}">
380 <input type=hidden name=terms value=$form->{terms}>
387 <th align=left nowrap>|.$locale->text('Credit Limit').qq|</th>
388 <td>$form->{creditlimit}</td>
389 <th align=left nowrap>|.$locale->text('Remaining').qq|</th>
390 <td class="plus$n">|.$form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0").qq|</td>
391 <input type=hidden name=creditlimit value=$form->{creditlimit}>
392 <input type=hidden name=creditremaining value=$form->{creditremaining}>
397 <th align=right nowrap>|.$locale->text('Currency').qq|</th>
398 <td><select name=currency>$form->{selectcurrency}</select></td>
399 <input type=hidden name=selectcurrency value="$form->{selectcurrency}">
400 <input type=hidden name=defaultcurrency value=$form->{defaultcurrency}>
401 <input type=hidden name=fxgain_accno value=$form->{fxgain_accno}>
402 <input type=hidden name=fxloss_accno value=$form->{fxloss_accno}>
412 <th align=right nowrap>|.$locale->text('Invoice Number').qq|</th>
413 <td><input name=invnumber size=20 value="$form->{invnumber}"></td>
416 <th align=right nowrap>|.$locale->text('Order Number').qq|</th>
417 <td><input name=ordnumber size=20 value="$form->{ordnumber}"></td>
420 <th align=right nowrap>|.$locale->text('Invoice Date').qq|</th>
421 <td><input name=transdate size=11 title="$myconfig{'dateformat'}" value=$form->{transdate}></td>
424 <th align=right nowrap>|.$locale->text('Due Date').qq|</th>
425 <td><input name=duedate size=11 title="$myconfig{'dateformat'}" value=$form->{duedate}></td>
433 <input type=hidden name=selectAP_amount value="$form->{selectAP_amount}">
434 <input type=hidden name=selectprojectnumber value="|.$form->escape($form->{selectprojectnumber},1).qq|">
435 <input type=hidden name=rowcount value=$form->{rowcount}>
441 $amount = $locale->text('Amount');
443 for $i (1 .. $form->{rowcount}) {
445 $selectAP_amount = $form->{selectAP_amount};
446 $selectAP_amount =~ s/option>\Q$form->{"AP_amount_$i"}\E/option selected>$form->{"AP_amount_$i"}/;
448 $selectprojectnumber = $form->{selectprojectnumber};
449 $selectprojectnumber =~ s/(<option value="\Q$form->{"projectnumber_$i"}\E")/$1 selected/;
452 $form->{"amount_$i"} = $form->format_amount(\%myconfig, $form->{"amount_$i"}, 2);
455 <td align=right><select name="projectnumber_$i">$selectprojectnumber</select></td>
456 | if $form->{selectprojectnumber};
460 <th align=right nowrap>$amount</th>
461 <td><input name="amount_$i" size=10 value=$form->{"amount_$i"}></td>
463 <td><select name="AP_amount_$i">$selectAP_amount</select></td>
470 $taxlabel = ($form->{taxincluded}) ? $locale->text('Tax Included') : $locale->text('Tax');
472 foreach $item (split / /, $form->{taxaccounts}) {
474 $form->{"calctax_$item"} = ($form->{"calctax_$item"}) ? "checked" : "";
476 # format and reverse tax
477 $form->{"tax_$item"} = $form->format_amount(\%myconfig, $form->{"tax_$item"}, 2);
481 <th align=right nowrap>${taxlabel}</th>
482 <td><input name="tax_$item" size=10 value=$form->{"tax_$item"}></td>
483 <td align=right><input name="calctax_$item" class=checkbox type=checkbox value=1 $form->{"calctax_$item"}></td>
484 <td><select name=AP_tax_$item>$form->{"selectAP_tax_$item"}</select></td>
486 <input type=hidden name="${item}_rate" value="$form->{"${item}_rate"}">
487 <input type=hidden name="${item}_description" value="$form->{"${item}_description"}">
488 <input type=hidden name="${item}_taxnumber" value="$form->{"${item}_taxnumber"}">
489 <input type=hidden name="selectAP_tax_$item" value="$form->{"selectAP_tax_$item"}">
493 $form->{invtotal} = $form->format_amount(\%myconfig, $form->{invtotal}, 2);
497 <th align=right nowrap>|.$locale->text('Total').qq|</th>
498 <td>$form->{invtotal}</td>
501 <input type=hidden name=oldinvtotal value=$form->{oldinvtotal}>
502 <input type=hidden name=oldtotalpaid value=$form->{oldtotalpaid}>
504 <input type=hidden name=taxaccounts value="$form->{taxaccounts}">
506 <td><select name=AP>$form->{selectAP}</select></td>
507 <input type=hidden name=selectAP value="$form->{selectAP}">
511 <th align=right nowrap>|.$locale->text('Notes').qq|</th>
512 <td colspan=5>$notes</td>
520 <tr class=listheading>
521 <th class=listheading colspan=6>|.$locale->text('Payments').qq|</th>
526 if ($form->{currency} eq $form->{defaultcurrency}) {
527 @column_index = qw(datepaid source memo paid AP_paid);
529 @column_index = qw(datepaid source memo paid exchangerate AP_paid);
532 $column_data{datepaid} = "<th>".$locale->text('Date')."</th>";
533 $column_data{paid} = "<th>".$locale->text('Amount')."</th>";
534 $column_data{exchangerate} = "<th>".$locale->text('Exch')."</th>";
535 $column_data{AP_paid} = "<th>".$locale->text('Account')."</th>";
536 $column_data{source} = "<th>".$locale->text('Source')."</th>";
537 $column_data{memo} = "<th>".$locale->text('Memo')."</th>";
542 map { print "$column_data{$_}\n" } @column_index;
547 $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
548 for $i (1 .. $form->{paidaccounts}) {
553 $form->{"selectAP_paid_$i"} = $form->{selectAP_paid};
554 $form->{"selectAP_paid_$i"} =~ s/option>\Q$form->{"AP_paid_$i"}\E/option selected>$form->{"AP_paid_$i"}/;
557 $form->{"paid_$i"} = $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2);
558 $form->{"exchangerate_$i"} = $form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
560 $exchangerate = qq| |;
561 if ($form->{currency} ne $form->{defaultcurrency}) {
562 if ($form->{"forex_$i"}) {
563 $exchangerate = qq|<input type=hidden name="exchangerate_$i" value=$form->{"exchangerate_$i"}>$form->{"exchangerate_$i"}|;
565 $exchangerate = qq|<input name="exchangerate_$i" size=10 value=$form->{"exchangerate_$i"}>|;
570 <input type=hidden name="forex_$i" value=$form->{"forex_$i"}>
573 $column_data{"paid_$i"} = qq|<td align=center><input name="paid_$i" size=11 value=$form->{"paid_$i"}></td>|;
574 $column_data{"AP_paid_$i"} = qq|<td align=center><select name="AP_paid_$i">$form->{"selectAP_paid_$i"}</select></td>|;
575 $column_data{"exchangerate_$i"} = qq|<td align=center>$exchangerate</td>|;
576 $column_data{"datepaid_$i"} = qq|<td align=center><input name="datepaid_$i" size=11 title="($myconfig{'dateformat'})" value=$form->{"datepaid_$i"}></td>|;
577 $column_data{"source_$i"} = qq|<td align=center><input name="source_$i" size=11 value="$form->{"source_$i"}"></td>|;
578 $column_data{"memo_$i"} = qq|<td align=center><input name="memo_$i" size=11 value="$form->{"memo_$i"}"></td>|;
580 map { print qq|$column_data{"${_}_$i"}\n| } @column_index;
588 <input type=hidden name=paidaccounts value=$form->{paidaccounts}>
589 <input type=hidden name=selectAP_paid value="$form->{selectAP_paid}">
595 <td><hr size=3 noshade></td>
609 <input name=callback type=hidden value="$form->{callback}">
611 <input type=hidden name=path value=$form->{path}>
612 <input type=hidden name=login value=$form->{login}>
613 <input type=hidden name=sessionid value=$form->{sessionid}>
619 $transdate = $form->datetonum($form->{transdate}, \%myconfig);
620 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
622 if (! $form->{readonly}) {
625 print qq|<input class=submit type=submit name=action value="|.$locale->text('Update').qq|">
628 if (!$form->{locked}) {
630 <input class=submit type=submit name=action value="|.$locale->text('Post').qq|">
631 <input class=submit type=submit name=action value="|.$locale->text('Print').qq|">
632 <input class=submit type=submit name=action value="|.$locale->text('Print and Post').qq|">
633 <input class=submit type=submit name=action value="|.$locale->text('Delete').qq|">
638 <input class=submit type=submit name=action value="|.$locale->text('Post as new').qq|">
642 if ($transdate > $closedto) {
643 print qq|<input class=submit type=submit name=action value="|.$locale->text('Update').qq|">
644 <input class=submit type=submit name=action value="|.$locale->text('Print').qq|">
645 <input class=submit type=submit name=action value="|.$locale->text('Post').qq|">
646 <input class=submit type=submit name=action value="|.$locale->text('Print and Post').qq|">|;
651 if ($form->{menubar}) {
652 require "$form->{path}/menu.pl";
673 $form->{invtotal} = 0;
675 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } qw(exchangerate);
677 @flds = qw(amount AP_amount projectnumber);
679 for $i (1 .. $form->{rowcount}) {
680 $form->{"amount_$i"} = $form->parse_amount(\%myconfig, $form->{"amount_$i"});
681 if ($form->{"amount_$i"}) {
684 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
688 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
689 $form->{rowcount} = $count + 1;
691 map { $form->{invtotal} += $form->{"amount_$_"} } (1 .. $form->{rowcount});
693 $form->{exchangerate} = $exchangerate if ($form->{forex} = ($exchangerate = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{transdate}, 'sell')));
695 if (&check_name(vendor)) {
696 $form->{notes} = $form->{intnotes} unless $form->{id};
699 if ($form->{transdate} ne $form->{oldtransdate}) {
700 $form->{duedate} = $form->current_date(\%myconfig, $form->{transdate}, $form->{terms} * 1);
701 $form->{oldtransdate} = $form->{transdate};
709 @taxaccounts = split / /, $form->{taxaccounts};
711 map { $form->{"tax_$_"} = $form->parse_amount(\%myconfig, $form->{"tax_$_"}) } @taxaccounts;
713 if ($form->{taxincluded}) {
715 $withholdingrate = 0;
717 foreach $item (@taxaccounts) {
718 $form->{"calctax_$item"} = 1 if $form->{calctax};
720 if ($form->{"calctax_$item"}) {
721 if ($form->{"${item}_rate"} > 0) {
722 $taxrate += $form->{"${item}_rate"};
724 $withholdingrate += $form->{"${item}_rate"};
729 foreach $item (@taxaccounts) {
730 if ($form->{"calctax_$item"}) {
731 if ($form->{"${item}_rate"} > 0) {
733 $amount = $form->round_amount($form->{invtotal} * $taxrate / (1 + $taxrate), 2) * $form->{"${item}_rate"} / $taxrate;
734 $form->{"tax_$item"} = $form->round_amount($amount, 2);
735 $taxdiff += ($amount - $form->{"tax_$item"});
738 if ($withholdingrate) {
739 $amount = $form->round_amount($form->{invtotal} * $withholdingrate / (1 - $withholdingrate), 2) * $form->{"${item}_rate"} / $withholdingrate;
740 $form->{"tax_$item"} = $form->round_amount($amount, 2);
741 $taxdiff += ($amount - $form->{"tax_$item"});
745 if (abs $taxdiff >= 0.005) {
746 $form->{"tax_$item"} += $form->round_amount($taxdiff, 2);
750 $form->{"selectAP_tax_$item"} = qq|<option>$item--$form->{"${item}_description"}|;
751 $totaltax += $form->{"tax_$item"};
754 foreach $item (@taxaccounts) {
755 $form->{"calctax_$item"} = 1 if $form->{calctax};
757 if ($form->{"calctax_$item"}) {
758 $form->{"tax_$item"} = $form->round_amount($form->{invtotal} * $form->{"${item}_rate"}, 2);
760 $form->{"selectAP_tax_$item"} = qq|<option>$item--$form->{"${item}_description"}|;
761 $totaltax += $form->{"tax_$item"};
765 $form->{invtotal} = ($form->{taxincluded}) ? $form->{invtotal} : $form->{invtotal} + $totaltax;
767 for $i (1 .. $form->{paidaccounts}) {
768 if ($form->{"paid_$i"}) {
769 map { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } qw(paid exchangerate);
771 $totalpaid += $form->{"paid_$i"};
773 $form->{"exchangerate_$i"} = $exchangerate if ($form->{"forex_$i"} = ($exchangerate = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'sell')));
777 $form->{creditremaining} -= ($form->{invtotal} - $totalpaid + $form->{oldtotalpaid} - $form->{oldinvtotal});
778 $form->{oldinvtotal} = $form->{invtotal};
779 $form->{oldtotalpaid} = $totalpaid;
788 # check if there is a vendor, invoice and due date
789 $form->isblank("transdate", $locale->text("Invoice Date missing!"));
790 $form->isblank("duedate", $locale->text("Due Date missing!"));
791 $form->isblank("vendor", $locale->text('Vendor missing!'));
794 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
795 $transdate = $form->datetonum($form->{transdate}, \%myconfig);
797 $form->error($locale->text('Cannot post transaction for a closed period!')) if ($transdate <= $closedto);
799 $form->isblank("exchangerate", $locale->text('Exchange rate missing!')) if ($form->{currency} ne $form->{defaultcurrency});
801 for $i (1 .. $form->{paidaccounts}) {
802 if ($form->{"paid_$i"}) {
803 $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
805 $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
807 $form->error($locale->text('Cannot post payment for a closed period!')) if ($datepaid <= $closedto);
809 if ($form->{currency} ne $form->{defaultcurrency}) {
810 $form->{"exchangerate_$i"} = $form->{exchangerate} if ($transdate == $datepaid);
811 $form->isblank("exchangerate_$i", $locale->text('Exchange rate for payment missing!'));
818 # if old vendor ne vendor redo form
819 ($vendor) = split /--/, $form->{vendor};
820 if ($form->{oldvendor} ne "$vendor--$form->{vendor_id}") {
825 $form->{invnumber} = $form->update_defaults(\%myconfig, "vinumber") unless $form->{invnumber};
827 $form->{id} = 0 if $form->{postasnew};
829 $form->redirect($locale->text('Transaction posted!')) if (AP->post_transaction(\%myconfig, \%$form));
830 $form->error($locale->text('Cannot post transaction!'));
837 $form->{postasnew} = 1;
845 $form->{title} = $locale->text('Confirm!');
849 delete $form->{header};
854 <form method=post action=$form->{script}>
860 <h2 class=confirm>$form->{title}</h2>
862 <h4>|.$locale->text('Are you sure you want to delete Transaction').qq| $form->{invnumber}</h4>
864 <input name=action class=submit type=submit value="|.$locale->text('Yes').qq|">
877 $form->redirect($locale->text('Transaction deleted!')) if (AP->delete_transaction(\%myconfig, \%$form, $spool));
878 $form->error($locale->text('Cannot delete transaction!'));
885 $form->create_links("AP", \%myconfig, "vendor");
887 $form->{selectAP} = "<option>\n";
888 map { $form->{selectAP} .= "<option>$_->{accno}--$_->{description}\n" } @{ $form->{AP_links}{AP} };
891 if (@{ $form->{all_vendor} }) {
892 map { $vendor .= qq|<option value="$_->{name}--$_->{id}">$_->{name}\n| } @{ $form->{all_vendor} };
893 $vendor = qq|<select name=vendor><option>\n$vendor\n</select>|;
895 $vendor = qq|<input name=vendor size=35>|;
899 if (@{ $form->{all_departments} }) {
900 $form->{selectdepartment} = "<option>\n";
902 map { $form->{selectdepartment} .= qq|<option value="$_->{description}--$_->{id}">$_->{description}\n| } (@{ $form->{all_departments} });
907 <th align=right nowrap>|.$locale->text('Department').qq|</th>
908 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
910 | if $form->{selectdepartment};
912 $form->{title} = $locale->text('AP Transactions');
916 <th align=right nowrap>|.$locale->text('Invoice Number').qq|</th>
917 <td colspan=3><input name=invnumber size=20></td>
920 <th align=right nowrap>|.$locale->text('Order Number').qq|</th>
921 <td colspan=3><input name=ordnumber size=20></td>
924 <th align=right nowrap>|.$locale->text('Notes').qq|</th>
925 <td colspan=3><input name=notes size=40></td>
931 <td align=right><input name=open class=checkbox type=checkbox value=Y checked></td>
932 <td nowrap>|.$locale->text('Open').qq|</td>
933 <td align=right><input name=closed class=checkbox type=checkbox value=Y></td>
934 <td nowrap>|.$locale->text('Closed').qq|</td>
938 if ($form->{outstanding}) {
939 $form->{title} = $locale->text('AP Outstanding');
945 $form->{selectaccountingyear} = "<option>\n";
946 map { $form->{selectaccountingyear} .= qq|<option>$_\n| } @{ $form->{all_years} };
947 $form->{selectaccountingmonth} = "<option>\n";
948 map { $form->{selectaccountingmonth} .= qq|<option value=$_>|.$locale->text($form->{all_month}{$_}).qq|\n| } sort keys %{ $form->{all_month} };
952 <th align=right>|.$locale->text('Period').qq|</th>
954 <select name=month>$form->{selectaccountingmonth}</select>
955 <select name=year>$form->{selectaccountingyear}</select>
956 <input name=interval class=radio type=radio value=0 checked>|.$locale->text('Current').qq|
957 <input name=interval class=radio type=radio value=1>|.$locale->text('Month').qq|
958 <input name=interval class=radio type=radio value=3>|.$locale->text('Quarter').qq|
959 <input name=interval class=radio type=radio value=12>|.$locale->text('Year').qq|
969 <form method=post action=$form->{script}>
971 <input type=hidden name=title value="$form->{title}">
972 <input type=hidden name=outstanding value=$form->{outstanding}>
976 <th class=listtop>$form->{title}</th>
983 <th align=right>|.$locale->text('Account').qq|</th>
984 <td colspan=3><select name=AP>$form->{selectAP}</select></td>
987 <th align=right>|.$locale->text('Vendor').qq|</th>
988 <td colspan=3>$vendor</td>
993 <th align=right nowrap>|.$locale->text('From').qq|</th>
994 <td><input name=transdatefrom size=11 title="$myconfig{dateformat}"></td>
995 <th align=right>|.$locale->text('To').qq|</th>
996 <td><input name=transdateto size=11 title="$myconfig{dateformat}"></td>
998 <input type=hidden name=sort value=transdate>
1007 <th align=right nowrap>|.$locale->text('Include in Report').qq|</th>
1012 <td align=right><input name="l_id" class=checkbox type=checkbox value=Y></td>
1013 <td nowrap>|.$locale->text('ID').qq|</td>
1014 <td align=right><input name="l_invnumber" class=checkbox type=checkbox value=Y checked></td>
1015 <td nowrap>|.$locale->text('Invoice Number').qq|</td>
1016 <td align=right><input name="l_ordnumber" class=checkbox type=checkbox value=Y></td>
1017 <td nowrap>|.$locale->text('Order Number').qq|</td>
1020 <td align=right><input name="l_name" class=checkbox type=checkbox value=Y checked></td>
1021 <td nowrap>|.$locale->text('Vendor').qq|</td>
1022 <td align=right><input name="l_transdate" class=checkbox type=checkbox value=Y checked></td>
1023 <td nowrap>|.$locale->text('Invoice Date').qq|</td>
1026 <td align=right><input name="l_netamount" class=checkbox type=checkbox value=Y></td>
1027 <td nowrap>|.$locale->text('Amount').qq|</td>
1028 <td align=right><input name="l_tax" class=checkbox type=checkbox value=Y></td>
1029 <td nowrap>|.$locale->text('Tax').qq|</td>
1030 <td align=right><input name="l_amount" class=checkbox type=checkbox value=Y checked></td>
1031 <td nowrap>|.$locale->text('Total').qq|</td>
1032 <td align=right><input name="l_curr" class=checkbox type=checkbox value=Y></td>
1033 <td nowrap>|.$locale->text('Currency').qq|</td>
1036 <td align=right><input name="l_datepaid" class=checkbox type=checkbox value=Y></td>
1037 <td nowrap>|.$locale->text('Date Paid').qq|</td>
1038 <td align=right><input name="l_paid" class=checkbox type=checkbox value=Y checked></td>
1039 <td nowrap>|.$locale->text('Paid').qq|</td>
1040 <td align=right><input name="l_duedate" class=checkbox type=checkbox value=Y></td>
1041 <td nowrap>|.$locale->text('Due Date').qq|</td>
1042 <td align=right><input name="l_due" class=checkbox type=checkbox value=Y></td>
1043 <td nowrap>|.$locale->text('Amount Due').qq|</td>
1046 <td align=right><input name="l_notes" class=checkbox type=checkbox value=Y></td>
1047 <td nowrap>|.$locale->text('Notes').qq|</td>
1048 <td align=right><input name="l_employee" class=checkbox type=checkbox value=Y></td>
1049 <td nowrap>|.$locale->text('Employee').qq|</td>
1050 <td align=right><input name="l_manager" class=checkbox type=checkbox value=Y></td>
1051 <td nowrap>|.$locale->text('Manager').qq|</td>
1054 <td align=right><input name="l_subtotal" class=checkbox type=checkbox value=Y></td>
1055 <td nowrap>|.$locale->text('Subtotal').qq|</td>
1064 <td><hr size=3 noshade></td>
1069 <input type=hidden name=nextsub value=$form->{nextsub}>
1071 <input type=hidden name=path value=$form->{path}>
1072 <input type=hidden name=login value=$form->{login}>
1073 <input type=hidden name=sessionid value=$form->{sessionid}>
1075 <input class=submit type=submit name=action value="|.$locale->text('Continue').qq|">
1085 sub ap_transactions {
1087 if ($form->{vendor}) {
1088 $form->{vendor} = $form->unescape($form->{vendor});
1089 ($form->{vendor}, $form->{vendor_id}) = split(/--/, $form->{vendor});
1092 AP->ap_transactions(\%myconfig, \%$form);
1094 $href = "$form->{script}?action=ap_transactions&direction=$form->{direction}&oldsort=$form->{oldsort}&outstanding=$form->{outstanding}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}";
1096 $form->sort_order();
1098 $callback = "$form->{script}?action=ap_transactions&direction=$form->{direction}&oldsort=$form->{oldsort}&outstanding=$form->{outstanding}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}";
1100 $callback .= "&title=".$form->escape($form->{title},1);
1101 $href .= "&title=".$form->escape($form->{title});
1104 $callback .= "&AP=".$form->escape($form->{AP},1);
1105 $href .= "&AP=".$form->escape($form->{AP});
1106 $form->{AP} =~ s/--/ /;
1107 $option = $locale->text('Account')." : $form->{AP}";
1110 if ($form->{vendor}) {
1111 $callback .= "&vendor=".$form->escape($form->{vendor},1)."--$form->{vendor_id}";
1112 $href .= "&vendor=".$form->escape($form->{vendor})."--$form->{vendor_id}";
1113 $option .= "\n<br>" if ($option);
1114 $option .= $locale->text('Vendor')." : $form->{vendor}";
1116 if ($form->{department}) {
1117 $callback .= "&department=".$form->escape($form->{department},1);
1118 $href .= "&department=".$form->escape($form->{department});
1119 ($department) = split /--/, $form->{department};
1120 $option .= "\n<br>" if ($option);
1121 $option .= $locale->text('Department')." : $department";
1123 if ($form->{invnumber}) {
1124 $callback .= "&invnumber=".$form->escape($form->{invnumber},1);
1125 $href .= "&invnumber=".$form->escape($form->{invnumber});
1126 $option .= "\n<br>" if ($option);
1127 $option .= $locale->text('Invoice Number')." : $form->{invnumber}";
1129 if ($form->{ordnumber}) {
1130 $callback .= "&ordnumber=".$form->escape($form->{ordnumber},1);
1131 $href .= "&ordnumber=".$form->escape($form->{ordnumber});
1132 $option .= "\n<br>" if ($option);
1133 $option .= $locale->text('Order Number')." : $form->{ordnumber}";
1135 if ($form->{notes}) {
1136 $callback .= "¬es=".$form->escape($form->{notes},1);
1137 $href .= "¬es=".$form->escape($form->{notes});
1138 $option .= "\n<br>" if $option;
1139 $option .= $locale->text('Notes')." : $form->{notes}";
1142 if ($form->{transdatefrom}) {
1143 $callback .= "&transdatefrom=$form->{transdatefrom}";
1144 $href .= "&transdatefrom=$form->{transdatefrom}";
1145 $option .= "\n<br>" if ($option);
1146 $option .= $locale->text('From')." ".$locale->date(\%myconfig, $form->{transdatefrom}, 1);
1148 if ($form->{transdateto}) {
1149 $callback .= "&transdateto=$form->{transdateto}";
1150 $href .= "&transdateto=$form->{transdateto}";
1151 $option .= "\n<br>" if ($option);
1152 $option .= $locale->text('To')." ".$locale->date(\%myconfig, $form->{transdateto}, 1);
1154 if ($form->{open}) {
1155 $callback .= "&open=$form->{open}";
1156 $href .= "&open=$form->{open}";
1157 $option .= "\n<br>" if ($option);
1158 $option .= $locale->text('Open');
1160 if ($form->{closed}) {
1161 $callback .= "&closed=$form->{closed}";
1162 $href .= "&closed=$form->{closed}";
1163 $option .= "\n<br>" if ($option);
1164 $option .= $locale->text('Closed');
1167 @columns = $form->sort_columns(qw(transdate id invnumber ordnumber name netamount tax amount paid due curr datepaid duedate notes employee manager));
1169 foreach $item (@columns) {
1170 if ($form->{"l_$item"} eq "Y") {
1171 push @column_index, $item;
1173 if ($form->{l_curr} && $item =~ /(amount|tax|paid|due)/) {
1174 push @column_index, "fx_$item";
1177 # add column to href and callback
1178 $callback .= "&l_$item=Y";
1179 $href .= "&l_$item=Y";
1183 if ($form->{l_subtotal} eq 'Y') {
1184 $callback .= "&l_subtotal=Y";
1185 $href .= "&l_subtotal=Y";
1189 $column_header{id} = qq|<th><a class=listheading href=$href&sort=id>|.$locale->text('ID').qq|</a></th>|;
1190 $column_header{transdate} = qq|<th><a class=listheading href=$href&sort=transdate>|.$locale->text('Date').qq|</a></th>|;
1191 $column_header{duedate} = qq|<th><a class=listheading href=$href&sort=duedate>|.$locale->text('Due Date').qq|</a></th>|;
1192 $column_header{due} = qq|<th class=listheading>|.$locale->text('Amount Due').qq|</th>|;
1193 $column_header{invnumber} = qq|<th><a class=listheading href=$href&sort=invnumber>|.$locale->text('Invoice').qq|</a></th>|;
1194 $column_header{ordnumber} = qq|<th><a class=listheading href=$href&sort=ordnumber>|.$locale->text('Order').qq|</a></th>|;
1195 $column_header{name} = qq|<th><a class=listheading href=$href&sort=name>|.$locale->text('Vendor').qq|</a></th>|;
1196 $column_header{netamount} = qq|<th class=listheading>|.$locale->text('Amount').qq|</th>|;
1197 $column_header{tax} = qq|<th class=listheading>|.$locale->text('Tax').qq|</th>|;
1198 $column_header{amount} = qq|<th class=listheading>|.$locale->text('Total').qq|</th>|;
1199 $column_header{paid} = qq|<th class=listheading>|.$locale->text('Paid').qq|</th>|;
1200 $column_header{datepaid} = qq|<th><a class=listheading href=$href&sort=datepaid>|.$locale->text('Date Paid').qq|</a></th>|;
1201 $column_header{notes} = qq|<th class=listheading>|.$locale->text('Notes').qq|</th>|;
1202 $column_header{employee} = "<th><a class=listheading href=$href&sort=employee>".$locale->text('Employee')."</th>";
1203 $column_header{manager} = "<th><a class=listheading href=$href&sort=manager>".$locale->text('Manager')."</th>";
1205 $column_header{curr} = "<th><a class=listheading href=$href&sort=curr>" . $locale->text('Curr') . "</a></th>";
1206 map { $column_header{"fx_$_"} = "<th> </th>" } qw(amount tax netamount paid due);
1208 $form->{title} = ($form->{title}) ? $form->{title} : $locale->text('AP Transactions');
1217 <th class=listtop>$form->{title}</th>
1219 <tr height="5"></tr>
1226 <tr class=listheading>
1229 map { print "\n$column_header{$_}" } @column_index;
1235 # add sort and escape callback
1236 $form->{callback} = "$callback&sort=$form->{sort}";
1237 $callback = $form->escape($form->{callback});
1240 $direction = ($form->{direction} eq 'ASC') ? "ASC" : "DESC";
1241 $href =~ s/&direction=(\w+)&/&direction=$direction&/;
1243 if (@{ $form->{transactions} }) {
1244 $sameitem = $form->{transactions}->[0]->{$form->{sort}};
1247 # sums and tax on reports by Antonio Gallardo
1249 foreach $ap (@{ $form->{transactions} }) {
1251 if ($form->{l_subtotal} eq 'Y') {
1252 if ($sameitem ne $ap->{$form->{sort}}) {
1254 $sameitem = $ap->{$form->{sort}};
1258 if ($form->{l_curr}) {
1259 map { $ap->{"fx_$_"} = $ap->{$_}/$ap->{exchangerate} } qw(netamount amount paid);
1261 map { $column_data{"fx_$_"} = "<td align=right>".$form->format_amount(\%myconfig, $ap->{"fx_$_"}, 2, " ")."</td>" } qw(netamount amount paid);
1263 $column_data{fx_tax} = "<td align=right>".$form->format_amount(\%myconfig, $ap->{fx_amount} - $ap->{fx_netamount}, 2, " ")."</td>";
1264 $column_data{fx_due} = "<td align=right>".$form->format_amount(\%myconfig, $ap->{fx_amount} - $ap->{fx_paid}, 2, " ")."</td>";
1266 $subtotalfxnetamount += $ap->{fx_netamount};
1267 $subtotalfxamount += $ap->{fx_amount};
1268 $subtotalfxpaid += $ap->{fx_paid};
1270 $totalfxnetamount += $ap->{fx_netamount};
1271 $totalfxamount += $ap->{fx_amount};
1272 $totalfxpaid += $ap->{fx_paid};
1276 map { $column_data{$_} = "<td align=right>".$form->format_amount(\%myconfig, $ap->{$_}, 2, " ")."</td>" } qw(netamount amount paid);
1278 $column_data{tax} = "<td align=right>".$form->format_amount(\%myconfig, $ap->{amount} - $ap->{netamount}, 2, " ") . "</td>";
1279 $column_data{due} = "<td align=right>".$form->format_amount(\%myconfig, $ap->{amount} - $ap->{paid}, 2, " ")."</td>";
1281 $totalnetamount += $ap->{netamount};
1282 $totalamount += $ap->{amount};
1283 $totalpaid += $ap->{paid};
1285 $subtotalnetamount += $ap->{netamount};
1286 $subtotalamount += $ap->{amount};
1287 $subtotalpaid += $ap->{paid};
1289 $column_data{transdate} = "<td>$ap->{transdate} </td>";
1290 $column_data{duedate} = "<td>$ap->{duedate} </td>";
1291 $column_data{datepaid} = "<td>$ap->{datepaid} </td>";
1293 $module = ($ap->{invoice}) ? "ir.pl" : $form->{script};
1295 $column_data{invnumber} = qq|<td><a href="$module?action=edit&path=$form->{path}&id=$ap->{id}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback">$ap->{invnumber}</a></td>|;
1296 $column_data{id} = "<td>$ap->{id}</td>";
1297 $column_data{ordnumber} = "<td>$ap->{ordnumber} </td>";
1299 $name = $form->escape($ap->{name});
1300 $column_data{name} = "<td><a href=$href&vendor=$name--$ap->{vendor_id}&sort=$form->{sort}>$ap->{name}</a></td>";
1302 $ap->{notes} =~ s/\r\n/<br>/g;
1303 $column_data{notes} = "<td>$ap->{notes} </td>";
1304 $column_data{employee} = "<td>$ap->{employee} </td>";
1305 $column_data{manager} = "<td>$ap->{manager} </td>";
1306 $column_data{curr} = "<td>$ap->{curr}</td>";
1311 <tr class=listrow$i >
1314 map { print "\n$column_data{$_}" } @column_index;
1322 if ($form->{l_subtotal} eq 'Y') {
1328 <tr class=listtotal>
1331 map { $column_data{$_} = "<td> </td>" } @column_index;
1333 $column_data{netamount} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalnetamount, 2, " ")."</th>";
1334 $column_data{tax} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalamount - $totalnetamount, 2, " ")."</th>";
1335 $column_data{amount} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalamount, 2, " ")."</th>";
1336 $column_data{paid} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalpaid, 2, " ")."</th>";
1337 $column_data{due} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalamount - $totalpaid, 2, " ")."</th>";
1339 if ($form->{l_curr} && $form->{sort} eq 'curr' && $form->{l_subtotal}) {
1340 $column_data{fx_netamount} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalfxnetamount, 2, " ")."</th>";
1341 $column_data{fx_tax} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalfxamount - $totalnetfxamount, 2, " ")."</th>";
1342 $column_data{fx_amount} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalfxamount, 2, " ")."</th>";
1343 $column_data{fx_paid} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalfxpaid, 2, " ")."</th>";
1344 $column_data{fx_due} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalfxamount - $totalfxpaid, 2, " ")."</th>";
1347 map { print "$column_data{$_}\n" } @column_index;
1349 if ($myconfig{acs} !~ /AP--AP/) {
1351 $button{'AP--Add Transaction'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('AP Transaction').qq|"> |;
1352 $button{'AP--Add Transaction'}{order} = $i++;
1353 $button{'AP--Vendor Invoice'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('Vendor Invoice.').qq|"> |;
1354 $button{'AP--Vendor Invoice'}{order} = $i++;
1356 foreach $item (split /;/, $myconfig{acs}) {
1357 delete $button{$item};
1367 <td><hr size=3 noshade></td>
1372 <form method=post action=$form->{script}>
1374 <input type=hidden name=vendor value="$form->{vendor}">
1375 <input type=hidden name=vendor_id value=$form->{vendor_id}>
1376 <input type=hidden name=vc value=vendor>
1378 <input name=callback type=hidden value="$form->{callback}">
1380 <input type=hidden name=path value=$form->{path}>
1381 <input type=hidden name=login value=$form->{login}>
1382 <input type=hidden name=sessionid value=$form->{sessionid}>
1385 foreach $item (sort { $a->{order} <=> $b->{order} } %button) {
1386 print $item->{code};
1389 if ($form->{menubar}) {
1390 require "$form->{path}/menu.pl";
1406 map { $column_data{$_} = "<td> </td>" } @column_index;
1408 $column_data{netamount} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotalnetamount, 2, " ")."</th>";
1409 $column_data{tax} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotalamount - $subtotalnetamount, 2, " ")."</th>";
1410 $column_data{amount} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotalamount, 2, " ")."</th>";
1411 $column_data{paid} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotalpaid, 2, " ")."</th>";
1412 $column_data{due} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotalamount - $subtotalpaid, 2, " ")."</th>";
1414 if ($form->{l_curr} && $form->{sort} eq 'curr' && $form->{l_subtotal}) {
1415 $column_data{fx_tax} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotalfxamount - $subtotalfxnetamount, 2, " ")."</th>";
1416 $column_data{fx_amount} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotalfxamount, 2, " ")."</th>";
1417 $column_data{fx_paid} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotalfxpaid, 2, " ")."</th>";
1418 $column_data{fx_due} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotalfxamount - $subtotalfxpaid, 2, " ")."</th>";
1421 $subtotalnetamount = 0;
1422 $subtotalamount = 0;
1425 $subtotalfxnetamount = 0;
1426 $subtotalfxamount = 0;
1427 $subtotalfxpaid = 0;
1429 print "<tr class=listsubtotal>";
1431 map { print "\n$column_data{$_}" } @column_index;