1 #=====================================================================
4 # Based on SQL-Ledger Version 2.1.9
5 # Web http://www.lx-office.org
7 #=====================================================================
8 # SQL-Ledger Accounting
11 # Author: Dieter Simader
12 # Email: dsimader@sql-ledger.org
13 # Web: http://www.sql-ledger.org
16 # This program is free software; you can redistribute it and/or modify
17 # it under the terms of the GNU General Public License as published by
18 # the Free Software Foundation; either version 2 of the License, or
19 # (at your option) any later version.
21 # This program is distributed in the hope that it will be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 # GNU General Public License for more details.
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write to the Free Software
27 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #======================================================================
32 #======================================================================
38 require "$form->{path}/arap.pl";
39 require "bin/mozilla/common.pl";
40 require "bin/mozilla/drafts.pl";
46 # this is for our long dates
47 # $locale->text('January')
48 # $locale->text('February')
49 # $locale->text('March')
50 # $locale->text('April')
51 # $locale->text('May ')
52 # $locale->text('June')
53 # $locale->text('July')
54 # $locale->text('August')
55 # $locale->text('September')
56 # $locale->text('October')
57 # $locale->text('November')
58 # $locale->text('December')
60 # this is for our short month
61 # $locale->text('Jan')
62 # $locale->text('Feb')
63 # $locale->text('Mar')
64 # $locale->text('Apr')
65 # $locale->text('May')
66 # $locale->text('Jun')
67 # $locale->text('Jul')
68 # $locale->text('Aug')
69 # $locale->text('Sep')
70 # $locale->text('Oct')
71 # $locale->text('Nov')
72 # $locale->text('Dec')
75 $lxdebug->enter_sub();
77 return $lxdebug->leave_sub() if (load_draft_maybe());
79 $form->{title} = "Add";
82 "$form->{script}?action=add&path=$form->{path}&login=$form->{login}&password=$form->{password}"
83 unless $form->{callback};
86 AP->get_transdate(\%myconfig, $form);
89 $lxdebug->leave_sub();
93 $lxdebug->enter_sub();
95 $form->{javascript} = qq|<script type="text/javascript" src="js/show_history.js"></script>|;
96 #/show hhistory button
98 $form->{title} = "Edit";
103 $lxdebug->leave_sub();
107 $lxdebug->enter_sub();
112 $lxdebug->leave_sub();
116 $lxdebug->enter_sub();
118 $form->create_links("AP", \%myconfig, "vendor");
119 $taxincluded = $form->{taxincluded};
120 $duedate = $form->{duedate};
122 IR->get_vendor(\%myconfig, \%$form);
123 $form->{taxincluded} = $taxincluded;
124 $form->{duedate} = $duedate if $duedate;
125 $form->{oldvendor} = "$form->{vendor}--$form->{vendor_id}";
126 $form->{rowcount} = 1;
128 # build the popup menus
129 $form->{taxincluded} = ($form->{id}) ? $form->{taxincluded} : "checked";
133 qq|<option value=\"$_->{id}--$_->{rate}\">$_->{taxdescription} |
134 . ($_->{rate} * 100) . qq| %|
136 $form->{taxchart} = $tax;
137 $form->{selecttaxchart} = $tax;
140 @curr = split(/:/, $form->{currencies});
142 $form->{defaultcurrency} = $curr[0];
144 map { $form->{selectcurrency} .= "<option>$_\n" } @curr;
147 if (@{ $form->{all_vendor} }) {
148 $form->{vendor} = qq|$form->{vendor}--$form->{vendor_id}|;
149 map { $form->{selectvendor} .= "<option>$_->{name}--$_->{id}\n" }
150 (@{ $form->{all_vendor} });
154 if (@{ $form->{all_departments} }) {
155 $form->{selectdepartment} = "<option>\n";
156 $form->{department} = "$form->{department}--$form->{department_id}";
159 $form->{selectdepartment} .=
160 "<option>$_->{description}--$_->{id}\n"
161 } (@{ $form->{all_departments} });
164 $form->{employee} = "$form->{employee}--$form->{employee_id}";
167 $form->{forex} = $form->{exchangerate};
168 $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
170 foreach $key (keys %{ $form->{AP_links} }) {
171 foreach $ref (@{ $form->{AP_links}{$key} }) {
172 if ($key eq "AP_paid") {
173 $form->{"select$key"} .=
174 "<option value=\"$ref->{accno}\">$ref->{accno}--$ref->{description}</option>\n";
176 $form->{"select$key"} .=
177 "<option value=\"$ref->{accno}--$ref->{tax_id}\">$ref->{accno}--$ref->{description}</option>\n";
181 $form->{$key} = $form->{"select$key"};
183 # if there is a value we have an old entry
187 for $i (1 .. scalar @{ $form->{acc_trans}{$key} }) {
189 if ($key eq "AP_paid") {
191 $form->{"AP_paid_$j"} =
192 "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
193 $form->{"paid_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{amount};
194 $form->{"datepaid_$j"} =
195 $form->{acc_trans}{$key}->[$i - 1]->{transdate};
196 $form->{"source_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{source};
197 $form->{"memo_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{memo};
199 $form->{"forex_$j"} = $form->{"exchangerate_$i"} =
200 $form->{acc_trans}{$key}->[$i - 1]->{exchangerate};
201 $form->{"AP_paid_$j"} = "$form->{acc_trans}{$key}->[$i-1]->{accno}";
202 $form->{"paid_project_id_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{project_id};
203 $form->{paidaccounts}++;
209 if (($key eq "AP_tax") || ($key eq "AR_tax")) {
210 $form->{"${key}_$form->{acc_trans}{$key}->[$i-1]->{accno}"} =
211 "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
212 $form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"} =
214 $form->{acc_trans}{$key}->[$i - 1]->{amount} / $exchangerate,
217 if ($form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"} > 0) {
219 $form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"};
221 $form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"};
224 $form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"};
226 $form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"};
228 $index = $form->{acc_trans}{$key}->[$i - 1]->{index};
229 $form->{"tax_$index"} =
230 $form->{acc_trans}{$key}->[$i - 1]->{amount} * -1;
231 $totaltax += $form->{"tax_$index"};
235 $form->{"${akey}_$k"} =
237 $form->{acc_trans}{$key}->[$i - 1]->{amount} / $exchangerate,
239 if ($akey eq 'amount') {
241 $form->{"${akey}_$i"} *= -1;
242 $totalamount += $form->{"${akey}_$i"};
243 $form->{taxrate} = $form->{acc_trans}{$key}->[$i - 1]->{rate};
244 $form->{"oldprojectnumber_$k"} = $form->{"projectnumber_$k"} =
245 "$form->{acc_trans}{$key}->[$i-1]->{projectnumber}";
246 $form->{"project_id_$k"} =
247 "$form->{acc_trans}{$key}->[$i-1]->{project_id}";
249 $form->{"${key}_$k"} =
250 "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
251 my $q_description = quotemeta($form->{acc_trans}{$key}->[$i-1]->{description});
252 $form->{"select${key}"} =~
253 /<option value=\"($form->{acc_trans}{$key}->[$i-1]->{accno}--[^\"]*)\">$form->{acc_trans}{$key}->[$i-1]->{accno}--${q_description}<\/option>\n/;
254 $form->{"${key}_$k"} = $1;
255 if ($akey eq 'amount') {
256 $form->{"taxchart_$k"} = $form->{taxchart};
257 $form->{"taxchart_$k"} =~
258 /<option value=\"($form->{acc_trans}{$key}->[$i-1]->{id}--[^\"]*)/;
259 $form->{"taxchart_$k"} = $1;
266 $form->{taxincluded} = $taxincluded if ($form->{id});
267 $form->{paidaccounts} = 1 if not defined $form->{paidaccounts};
269 if ($form->{taxincluded} && $form->{taxrate} && $totalamount) {
271 # add tax to amounts and invtotal
272 for $i (1 .. $form->{rowcount}) {
274 ($totaltax + $totalwithholding) * $form->{"amount_$i"} / $totalamount;
275 $tax = $form->round_amount($taxamount, 2);
276 $diff += ($taxamount - $tax);
277 $form->{"amount_$i"} += $form->{"tax_$i"};
279 $form->{amount_1} += $form->round_amount($diff, 2);
282 $taxamount = $form->round_amount($taxamount, 2);
284 $form->{invtotal} = $totalamount + $totaltax;
287 ($form->datetonum($form->{transdate}, \%myconfig) <=
288 $form->datetonum($form->{closedto}, \%myconfig));
290 $form->{"APselected"} = $form->{"AP_1"};
292 $lxdebug->leave_sub();
296 $lxdebug->enter_sub();
298 $title = $form->{title};
299 $form->{title} = $locale->text("$title Accounts Payables Transaction");
301 $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
303 # type=submit $locale->text('Add Accounts Payables Transaction')
304 # type=submit $locale->text('Edit Accounts Payables Transaction')
306 $form->{javascript} = qq|<script type="text/javascript">
308 function setTaxkey(accno, row) {
309 var taxkey = accno.options[accno.selectedIndex].value;
310 var reg = /--([0-9]*)/;
311 var found = reg.exec(taxkey);
312 var index = found[1];
313 index = parseInt(index);
314 var tax = 'taxchart_' + row;
315 for (var i = 0; i < document.getElementById(tax).options.length; ++i) {
316 var reg2 = new RegExp("^"+ index, "");
317 if (reg2.exec(document.getElementById(tax).options[i].value)) {
318 document.getElementById(tax).options[i].selected = true;
326 # set option selected
327 foreach $item (qw(vendor currency department)) {
328 $form->{"select$item"} =~ s/ selected//;
329 $form->{"select$item"} =~
330 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
332 $readonly = ($form->{id}) ? "readonly" : "";
334 my $APselected_quoted = quotemeta($form->{"APselected"});
335 $form->{selectAP} = $form->{AP};
337 s/value=\"${APselected_quoted}\"/value=\"$form->{APselected}\" selected/;
340 ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0;
341 $readonly = ($form->{radier}) ? "" : $readonly;
342 $selectAP_amount_unquoted = $form->{selectAP_amount};
343 $taxchart = $form->{taxchart};
344 map { $form->{$_} =~ s/\"/"/g }
345 qw(AP_amount selectAP_amount AP taxchart);
348 $form->{exchangerate} =
349 $form->format_amount(\%myconfig, $form->{exchangerate});
351 $form->{creditlimit} =
352 $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
353 $form->{creditremaining} =
354 $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
357 <input type=hidden name=forex value=$form->{forex}>
359 if ($form->{currency} ne $form->{defaultcurrency}) {
360 if ($form->{forex}) {
363 <th align=right>| . $locale->text('Exchangerate') . qq|</th>
364 <td><input type=hidden name=exchangerate value=$form->{exchangerate}>$form->{exchangerate}</td>
369 <th align=right>| . $locale->text('Exchangerate') . qq|</th>
370 <td><input name=exchangerate size=10 value=$form->{exchangerate}></td>
379 <td align=right><input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}></td>
380 <th align=left nowrap>|
381 . $locale->text('Tax Included') . qq|</th>
385 if (($rows = $form->numtextrows($form->{notes}, 50)) < 2) {
389 qq|<textarea name=notes rows=$rows cols=50 wrap=soft $readonly>$form->{notes}</textarea>|;
393 <th align="right" nowrap>| . $locale->text('Department') . qq|</th>
394 <td colspan=3><select name=department>$form->{selectdepartment}</select>
395 <input type=hidden name=selectdepartment value="$form->{selectdepartment}">
398 | if $form->{selectdepartment};
400 $n = ($form->{creditremaining} =~ /-/) ? "0" : "1";
403 ($form->{selectvendor})
404 ? qq|<select name=vendor>$form->{selectvendor}</select>|
405 : qq|<input name=vendor value="$form->{vendor}" size=35>|;
407 my @old_project_ids = ();
408 map({ push(@old_project_ids, $form->{"project_id_$_"})
409 if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
411 $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
413 "old_id" => \@old_project_ids });
415 my %project_labels = ();
416 my @project_values = ("");
417 foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
418 push(@project_values, $item->{"id"});
419 $project_labels{$item->{"id"}} = $item->{"projectnumber"};
422 # use JavaScript Calendar or not
423 $form->{jsscript} = $jscalendar;
425 if ($form->{jsscript}) {
427 # with JavaScript Calendar
429 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}> $readonly</td>
430 <td><input type=button name=transdate id="trigger1" value=|
431 . $locale->text('button') . qq|></td>
434 <td><input name=duedate id=duedate size=11 title="$myconfig{dateformat}" value=$form->{duedate}> $readonly</td>
435 <td><input type=button name=duedate id="trigger2" value=|
436 . $locale->text('button') . qq|></td></td>
441 Form->write_trigger(\%myconfig, "2", "transdate", "BL", "trigger1",
442 "duedate", "BL", "trigger2");
445 # without JavaScript Calendar
447 qq|<td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}> $readonly</td>|;
449 qq|<td><input name=duedate id=duedate size=11 title="$myconfig{dateformat}" value=$form->{duedate}> $readonly</td>|;
457 <form method=post action=$form->{script}>
459 <input type=hidden name=id value=$form->{id}>
460 <input type=hidden name=sort value=$form->{sort}>
461 <input type=hidden name=closedto value=$form->{closedto}>
462 <input type=hidden name=locked value=$form->{locked}>
463 <input type=hidden name=title value="$title">
465 | . ($form->{saved_message} ? qq|<p>$form->{saved_message}</p>| : "") . qq|
469 <th class=listtop>$form->{title}</th>
479 <th align=right nowrap>| . $locale->text('Vendor') . qq|</th>
480 <td colspan=3>$vendor</td>
481 <input type=hidden name=selectvendor value="$form->{selectvendor}">
482 <input type=hidden name=oldvendor value="$form->{oldvendor}">
483 <input type=hidden name=vendor_id value="$form->{vendor_id}">
484 <input type=hidden name=terms value=$form->{terms}>
491 <th align=left nowrap>| . $locale->text('Credit Limit') . qq|</th>
492 <td>$form->{creditlimit}</td>
493 <th align=left nowrap>| . $locale->text('Remaining') . qq|</th>
494 <td class="plus$n">$form->{creditremaining}</td>
495 <input type=hidden name=creditlimit value=$form->{creditlimit}>
496 <input type=hidden name=creditremaining value=$form->{creditremaining}>
501 <th align=right nowrap>| . $locale->text('Currency') . qq|</th>
502 <td><select name=currency>$form->{selectcurrency}</select></td>
503 <input type=hidden name=selectcurrency value="$form->{selectcurrency}">
504 <input type=hidden name=defaultcurrency value=$form->{defaultcurrency}>
505 <input type=hidden name=fxgain_accno value=$form->{fxgain_accno}>
506 <input type=hidden name=fxloss_accno value=$form->{fxloss_accno}>
516 <th align=right nowrap>| . $locale->text('Invoice Number') . qq|</th>
517 <td><input name=invnumber size=11 value="$form->{invnumber}" $readonly></td>
520 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
521 <td><input name=ordnumber size=11 value="$form->{ordnumber}" $readonly></td>
524 <th align=right nowrap>| . $locale->text('Invoice Date') . qq|</th>
528 <th align=right nowrap>| . $locale->text('Due Date') . qq|</th>
541 <input type=hidden name=selectAP_amount value="$form->{selectAP_amount}">
542 <input type=hidden name=AP_amount value="$form->{AP_amount}">
543 <input type=hidden name=taxchart value="$form->{taxchart}">
544 <input type=hidden name=rowcount value=$form->{rowcount}>
548 <tr class=listheading>
549 <th class=listheading style="width:15%">|
550 . $locale->text('Account') . qq|</th>
551 <th class=listheading style="width:10%">|
552 . $locale->text('Amount') . qq|</th>
553 <th class=listheading style="width:10%">|
554 . $locale->text('Tax') . qq|</th>
555 <th class=listheading style="width:5%">|
556 . $locale->text('Korrektur') . qq|</th>
557 <th class=listheading style="width:10%">|
558 . $locale->text('Taxkey') . qq|</th>
559 <th class=listheading style="width:10%">|
560 . $locale->text('Project') . qq|</th>
564 $amount = $locale->text('Amount');
565 $project = $locale->text('Project');
567 for $i (1 .. $form->{rowcount}) {
570 $form->{"amount_$i"} =
571 $form->format_amount(\%myconfig, $form->{"amount_$i"}, 2);
572 $form->{"tax_$i"} = $form->format_amount(\%myconfig, $form->{"tax_$i"}, 2);
573 $selectAP_amount = $selectAP_amount_unquoted;
574 $re_amount = quotemeta($form->{"AP_amount_$i"});
576 s/option value=\"${re_amount}\"/option value=\"$form->{"AP_amount_$i"}\" selected/;
578 $tax_selected = $form->{"taxchart_$i"};
579 $tax =~ s/value=\"$tax_selected\"/value=\"$tax_selected\" selected/;
581 qq|<td><select id="taxchart_$i" name="taxchart_$i" style="width:200px">$tax</select></td>|;
583 my $korrektur = $form->{"korrektur_$i"} ? 'checked' : '';
586 NTI($cgi->popup_menu('-name' => "project_id_$i",
587 '-values' => \@project_values,
588 '-labels' => \%project_labels,
589 '-default' => $form->{"project_id_$i"} ));
593 <td width=50%><select name="AP_amount_$i" onChange="setTaxkey(this, $i)" style="width:100%">$selectAP_amount</select></td>
594 <td><input name="amount_$i" size=10 value=$form->{"amount_$i"}></td>
595 <td><input name="tax_$i" size=10 value=$form->{"tax_$i"}></td>
596 <td><input type="checkbox" name="korrektur_$i" value="1" "$korrektur"></td>
598 <td>$projectnumber</td>
606 ($form->{taxincluded})
607 ? $locale->text('Tax Included')
608 : $locale->text('Tax');
610 $form->{invtotal} = $form->format_amount(\%myconfig, $form->{invtotal}, 2);
619 <td><select name=APselected>$form->{selectAP}</select></td>
620 <input type=hidden name=AP value="$form->{AP}">
621 <th align=left>$form->{invtotal}</th>
623 <input type=hidden name=oldinvtotal value=$form->{oldinvtotal}>
624 <input type=hidden name=oldtotalpaid value=$form->{oldtotalpaid}>
626 <input type=hidden name=taxaccounts value="$form->{taxaccounts}">
639 <th align=left width=1%>| . $locale->text('Notes') . qq|</th>
640 <td align=left>$notes</td>
648 <tr class=listheading>
649 <th class=listheading colspan=7>| . $locale->text('Payments') . qq|</th>
653 if ($form->{currency} eq $form->{defaultcurrency}) {
654 @column_index = qw(datepaid source memo paid AP_paid paid_project_id);
656 @column_index = qw(datepaid source memo paid exchangerate AP_paid paid_project_id);
659 $column_data{datepaid} = "<th>" . $locale->text('Date') . "</th>";
660 $column_data{paid} = "<th>" . $locale->text('Amount') . "</th>";
661 $column_data{exchangerate} = "<th>" . $locale->text('Exch') . "</th>";
662 $column_data{AP_paid} = "<th>" . $locale->text('Account') . "</th>";
663 $column_data{source} = "<th>" . $locale->text('Source') . "</th>";
664 $column_data{memo} = "<th>" . $locale->text('Memo') . "</th>";
665 $column_data{paid_project_id} = "<th>" . $locale->text('Project Number') . "</th>";
670 map { print "$column_data{$_}\n" } @column_index;
676 $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
677 for $i (1 .. $form->{paidaccounts}) {
682 $form->{"selectAP_paid_$i"} = $form->{selectAP_paid};
683 $form->{"selectAP_paid_$i"} =~
684 s/option value=\"$form->{"AP_paid_$i"}\">/option value=\"$form->{"AP_paid_$i"}\" selected>/;
687 if ($form->{"paid_$i"}) {
689 $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2);
691 $form->{"exchangerate_$i"} =
692 $form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
694 $exchangerate = qq| |;
695 if ($form->{currency} ne $form->{defaultcurrency}) {
696 if ($form->{"forex_$i"}) {
698 qq|<input type=hidden name="exchangerate_$i" value=$form->{"exchangerate_$i"}>$form->{"exchangerate_$i"}|;
701 qq|<input name="exchangerate_$i" size=10 value=$form->{"exchangerate_$i"}>|;
706 <input type=hidden name="forex_$i" value=$form->{"forex_$i"}>
709 $column_data{"paid_$i"} =
710 qq|<td align=center><input name="paid_$i" size=11 value=$form->{"paid_$i"}></td>|;
711 $column_data{"AP_paid_$i"} =
712 qq|<td align=center><select name="AP_paid_$i">$form->{"selectAP_paid_$i"}</select></td>|;
713 $column_data{"exchangerate_$i"} = qq|<td align=center>$exchangerate</td>|;
714 $column_data{"datepaid_$i"} =
715 qq|<td align=center><input name="datepaid_$i" id="datepaid_$i" size=11 title="($myconfig{'dateformat'})" value=$form->{"datepaid_$i"}>
716 <input type="button" name="datepaid_$i" id="trigger_datepaid_$i" value="?"></td>|;
717 $column_data{"source_$i"} =
718 qq|<td align=center><input name="source_$i" size=11 value="$form->{"source_$i"}"></td>|;
719 $column_data{"memo_$i"} =
720 qq|<td align=center><input name="memo_$i" size=11 value="$form->{"memo_$i"}"></td>|;
721 $column_data{"paid_project_id_$i"} =
723 . NTI($cgi->popup_menu('-name' => "paid_project_id_$i",
724 '-values' => \@project_values,
725 '-labels' => \%project_labels,
726 '-default' => $form->{"paid_project_id_$i"} ))
729 map { print qq|$column_data{"${_}_$i"}\n| } @column_index;
734 push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i");
736 map { $form->{$_} =~ s/\"/"/g } qw(selectAP_paid);
737 print $form->write_trigger(\%myconfig, scalar(@triggers) / 3, @triggers) .
739 <input type=hidden name=paidaccounts value=$form->{paidaccounts}>
740 <input type=hidden name=selectAP_paid value="$form->{selectAP_paid}">
746 <td><hr size=3 noshade></td>
751 $lxdebug->leave_sub();
755 $lxdebug->enter_sub();
759 <input name=callback type=hidden value="$form->{callback}">
760 <input name="gldate" type="hidden" value="| . Q($form->{gldate}) . qq|">
762 <input type=hidden name=path value=$form->{path}>
763 <input type=hidden name=login value=$form->{login}>
764 <input type=hidden name=password value=$form->{password}>
766 . $cgi->hidden('-name' => 'draft_id', '-default' => [$form->{draft_id}])
767 . $cgi->hidden('-name' => 'draft_description', '-default' => [$form->{draft_description}])
773 $transdate = $form->datetonum($form->{transdate}, \%myconfig);
774 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
776 print qq|<input class=submit type=submit name=action value="|
777 . $locale->text('Update') . qq|">|;
781 # print qq|<input class=submit type=submit name=action value="|.$locale->text('Update').qq|">
783 if ($form->{radier}) {
785 <input class=submit type=submit name=action value="|
786 . $locale->text('Post') . qq|">
787 <input class=submit type=submit name=action value="|
788 . $locale->text('Delete') . qq|">
793 <input class=submit type=submit name=action value="|
794 . $locale->text('Use As Template') . qq|">
795 <input class=submit type=submit name=action value="|
796 . $locale->text('Post Payment') . qq|">
798 } elsif (($transdate > $closedto) && !$form->{id}) {
800 <input class=submit type=submit name=action value="|
801 . $locale->text('Post') . qq|"> | .
802 NTI($cgi->submit('-name' => 'action', '-value' => $locale->text('Save draft'),
803 '-class' => 'submit'));
805 # button for saving history
806 if($form->{id} ne "") {
808 <input type=button class=submit onclick=set_history_window(|
810 . qq|); name=history id=history value=|
811 . $locale->text('history')
814 # /button for saving history
822 $lxdebug->leave_sub();
826 $lxdebug->enter_sub();
834 $form->{invtotal} = 0;
836 # $form->{selectAP_amount} = $form->{AP_amount};
837 # $form->{selectAP_amount} =~
838 # s/value=\"$form->{AP_amountselected}\"/value=\"$form->{AP_amountselected}\" selected/;
840 ($AP_amountaccno, $AP_amounttaxkey) =
841 split(/--/, $form->{AP_amountselected});
842 $form->{selecttaxchart} = $form->{taxchart};
843 $form->{selecttaxchart} =~
844 s/value=\"$AP_amounttaxkey--([^\"]*)\"/value=\"$AP_amounttaxkey--$1\" selected/;
848 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
849 qw(exchangerate creditlimit creditremaining);
851 @flds = qw(amount AP_amount projectnumber oldprojectnumber project_id);
853 for $i (1 .. $form->{rowcount}) {
854 $form->{"amount_$i"} =
855 $form->parse_amount(\%myconfig, $form->{"amount_$i"});
856 $form->{"tax_$i"} = $form->parse_amount(\%myconfig, $form->{"tax_$i"});
857 if ($form->{"amount_$i"}) {
860 if (!$form->{"korrektur_$i"}) {
861 ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
863 if ($form->{taxincluded}) {
864 $form->{"tax_$i"} = $form->{"amount_$i"} / ($rate + 1) * $rate;
866 $form->{"tax_$i"} = $form->{"amount_$i"} * $rate;
869 $form->{"tax_$i"} = 0;
872 $form->{"tax_$i"} = $form->round_amount($form->{"tax_$i"}, 2);
874 $totaltax += $form->{"tax_$i"};
875 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
879 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
881 map { $form->{invtotal} += $form->{"amount_$_"} } (1 .. $form->{rowcount});
883 $form->{exchangerate} = $exchangerate
887 $form->check_exchangerate(
888 \%myconfig, $form->{currency}, $form->{transdate}, 'sell'
891 $form->{invdate} = $form->{transdate};
892 $save_AP = $form->{AP};
894 $form->{AP} = $save_AP;
896 $form->{rowcount} = $count + 1;
899 ($form->{taxincluded}) ? $form->{invtotal} : $form->{invtotal} + $totaltax;
901 for $i (1 .. $form->{paidaccounts}) {
902 if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
905 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
906 } qw(paid exchangerate);
908 $totalpaid += $form->{"paid_$i"};
910 $form->{"exchangerate_$i"} = $exchangerate
912 $form->{"forex_$i"} = (
914 $form->check_exchangerate(
915 \%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'sell'
920 $form->{creditremaining} -=
921 ($form->{invtotal} - $totalpaid + $form->{oldtotalpaid} -
922 $form->{oldinvtotal});
923 $form->{oldinvtotal} = $form->{invtotal};
924 $form->{oldtotalpaid} = $totalpaid;
928 $lxdebug->leave_sub();
933 $lxdebug->enter_sub();
934 for $i (1 .. $form->{paidaccounts}) {
935 if ($form->{"paid_$i"}) {
936 $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
938 $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
940 $form->error($locale->text('Cannot post payment for a closed period!'))
941 if ($datepaid <= $closedto);
943 if ($form->{currency} ne $form->{defaultcurrency}) {
944 $form->{"exchangerate_$i"} = $form->{exchangerate}
945 if ($invdate == $datepaid);
946 $form->isblank("exchangerate_$i",
947 $locale->text('Exchangerate for payment missing!'));
952 ($form->{AP}) = split /--/, $form->{AP};
953 ($form->{AP_paid}) = split /--/, $form->{AP_paid};
954 $form->redirect($locale->text(' Payment posted!'))
955 if (AP->post_payment(\%myconfig, \%$form));
956 $form->error($locale->text('Cannot post payment!'));
959 $lxdebug->leave_sub();
964 $lxdebug->enter_sub();
966 # check if there is a vendor, invoice and due date
967 $form->isblank("transdate", $locale->text("Invoice Date missing!"));
968 $form->isblank("duedate", $locale->text("Due Date missing!"));
969 $form->isblank("vendor", $locale->text('Vendor missing!'));
971 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
972 $transdate = $form->datetonum($form->{transdate}, \%myconfig);
974 $form->error($locale->text('Cannot post transaction for a closed period!'))
975 if ($transdate <= $closedto);
977 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
978 if ($form->{currency} ne $form->{defaultcurrency});
981 for $i (1 .. $form->{paidaccounts}) {
982 if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
983 $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
985 $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
987 $form->error($locale->text('Cannot post payment for a closed period!'))
988 if ($datepaid <= $closedto);
990 if ($form->{currency} ne $form->{defaultcurrency}) {
991 $form->{"exchangerate_$i"} = $form->{exchangerate}
992 if ($transdate == $datepaid);
993 $form->isblank("exchangerate_$i",
994 $locale->text('Exchangerate for payment missing!'));
1000 # if old vendor ne vendor redo form
1001 ($vendor) = split /--/, $form->{vendor};
1002 if ($form->{oldvendor} ne "$vendor--$form->{vendor_id}") {
1006 ($debitaccno, $debittaxkey) = split /--/, $form->{AP_amountselected};
1007 ($taxkey, $NULL) = split /--/, $form->{taxchartselected};
1008 ($payablesaccno, $payablestaxkey) = split /--/, $form->{APselected};
1009 $form->{AP}{amount_1} = $debitaccno;
1010 $form->{AP}{payables} = $payablesaccno;
1011 $form->{taxkey} = $taxkey;
1013 $form->{id} = 0 if $form->{postasnew};
1015 if (AP->post_transaction(\%myconfig, \%$form)) {
1016 # saving the history
1017 if(!exists $form->{addition} && $form->{id} ne "") {
1018 $form->{addition} = "POSTED";
1019 $form->save_history($form->dbconnect(\%myconfig));
1021 # /saving the history
1022 remove_draft() if $form->{remove_draft};
1023 $form->redirect($locale->text('Transaction posted!'));
1025 $form->error($locale->text('Cannot post transaction!'));
1027 $lxdebug->leave_sub();
1031 $lxdebug->enter_sub();
1033 $form->{postasnew} = 1;
1034 # saving the history
1035 if(!exists $form->{addition} && $form->{id} ne "") {
1036 $form->{addition} = "POSTED AS NEW";
1037 $form->save_history($form->dbconnect(\%myconfig));
1039 # /saving the history
1042 $lxdebug->leave_sub();
1045 sub use_as_template {
1046 $lxdebug->enter_sub();
1048 map { delete $form->{$_} } qw(printed emailed queued invnumber invdate deliverydate id datepaid_1 source_1 memo_1 paid_1 exchangerate_1 AP_paid_1 storno);
1049 $form->{paidaccounts} = 1;
1050 $form->{rowcount}--;
1051 $form->{invdate} = $form->current_date(\%myconfig);
1054 $lxdebug->leave_sub();
1058 $lxdebug->enter_sub();
1060 $form->{title} = $locale->text('Confirm!');
1064 delete $form->{header};
1069 <form method=post action=$form->{script}>
1072 foreach $key (keys %$form) {
1073 $form->{$key} =~ s/\"/"/g;
1074 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
1078 <h2 class=confirm>$form->{title}</h2>
1081 . $locale->text('Are you sure you want to delete Transaction')
1082 . qq| $form->{invnumber}</h4>
1084 <input name=action class=submit type=submit value="|
1085 . $locale->text('Yes') . qq|">
1092 $lxdebug->leave_sub();
1096 $lxdebug->enter_sub();
1097 if (AP->delete_transaction(\%myconfig, \%$form, $spool)) {
1098 # saving the history
1099 if(!exists $form->{addition}) {
1100 $form->{addition} = "DELETED";
1101 $form->save_history($form->dbconnect(\%myconfig));
1103 # /saving the history
1104 $form->redirect($locale->text('Transaction deleted!'));
1106 $form->error($locale->text('Cannot delete transaction!'));
1108 $lxdebug->leave_sub();
1112 $lxdebug->enter_sub();
1114 # setup vendor selection
1115 $form->all_vc(\%myconfig, "vendor", "AP");
1117 if (@{ $form->{all_vendor} }) {
1118 map { $vendor .= "<option>$_->{name}--$_->{id}\n" }
1119 @{ $form->{all_vendor} };
1120 $vendor = qq|<select name=vendor><option>\n$vendor\n</select>|;
1122 $vendor = qq|<input name=vendor size=35>|;
1126 if (@{ $form->{all_departments} }) {
1127 $form->{selectdepartment} = "<option>\n";
1130 $form->{selectdepartment} .=
1131 "<option>$_->{description}--$_->{id}\n"
1132 } (@{ $form->{all_departments} });
1137 <th align=right nowrap>| . $locale->text('Department') . qq|</th>
1138 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
1140 | if $form->{selectdepartment};
1142 $form->{title} = $locale->text('AP Transactions');
1144 # use JavaScript Calendar or not
1145 $form->{jsscript} = $jscalendar;
1147 if ($form->{jsscript}) {
1149 # with JavaScript Calendar
1151 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}">
1152 <input type=button name=transdatefrom id="trigger1" value=|
1153 . $locale->text('button') . qq|></td>
1156 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}">
1157 <input type=button name=transdateto name=transdateto id="trigger2" value=|
1158 . $locale->text('button') . qq|></td>
1163 Form->write_trigger(\%myconfig, "2", "transdatefrom", "BR", "trigger1",
1164 "transdateto", "BL", "trigger2");
1167 # without JavaScript Calendar
1169 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>|;
1171 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}"></td>|;
1174 $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
1179 foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
1180 push(@values, $item->{"id"});
1181 $labels{$item->{"id"}} = $item->{"projectnumber"};
1184 NTI($cgi->popup_menu('-name' => 'project_id', '-values' => \@values,
1185 '-labels' => \%labels));
1192 <form method=post action=$form->{script}>
1196 <th class=listtop>$form->{title}</th>
1198 <tr height="5"></tr>
1203 <th align=right>| . $locale->text('Vendor') . qq|</th>
1204 <td colspan=3>$vendor</td>
1208 <th align=right nowrap>| . $locale->text('Invoice Number') . qq|</th>
1209 <td colspan=3><input name=invnumber size=20></td>
1212 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
1213 <td colspan=3><input name=ordnumber size=20></td>
1216 <th align=right nowrap>| . $locale->text('Notes') . qq|</th>
1217 <td colspan=3><input name=notes size=40></td>
1220 <th align="right">| . $locale->text("Project Number") . qq|</th>
1221 <td colspan="3">$projectnumber</td>
1224 <th align=right nowrap>| . $locale->text('From') . qq|</th>
1226 <th align=right>| . $locale->text('Bis') . qq|</th>
1229 <input type=hidden name=sort value=transdate>
1237 <th align=right nowrap>| . $locale->text('Include in Report') . qq|</th>
1241 <td align=right><input name=open class=checkbox type=checkbox value=Y checked></td>
1242 <td nowrap>| . $locale->text('Open') . qq|</td>
1243 <td align=right><input name=closed class=checkbox type=checkbox value=Y></td>
1244 <td nowrap>| . $locale->text('Closed') . qq|</td>
1247 <td align=right><input name="l_id" class=checkbox type=checkbox value=Y></td>
1248 <td nowrap>| . $locale->text('ID') . qq|</td>
1249 <td align=right><input name="l_invnumber" class=checkbox type=checkbox value=Y checked></td>
1250 <td nowrap>| . $locale->text('Invoice Number') . qq|</td>
1251 <td align=right><input name="l_ordnumber" class=checkbox type=checkbox value=Y></td>
1252 <td nowrap>| . $locale->text('Order Number') . qq|</td>
1255 <td align=right><input name="l_name" class=checkbox type=checkbox value=Y checked></td>
1256 <td nowrap>| . $locale->text('Vendor') . qq|</td>
1257 <td align=right><input name="l_transdate" class=checkbox type=checkbox value=Y checked></td>
1258 <td nowrap>| . $locale->text('Invoice Date') . qq|</td>
1259 <td align=right><input name="l_netamount" class=checkbox type=checkbox value=Y></td>
1260 <td nowrap>| . $locale->text('Amount') . qq|</td>
1263 <td align=right><input name="l_tax" class=checkbox type=checkbox value=Y></td>
1264 <td nowrap>| . $locale->text('Tax') . qq|</td>
1265 <td align=right><input name="l_amount" class=checkbox type=checkbox value=Y checked></td>
1266 <td nowrap>| . $locale->text('Total') . qq|</td>
1267 <td align=right><input name="l_datepaid" class=checkbox type=checkbox value=Y></td>
1268 <td nowrap>| . $locale->text('Date Paid') . qq|</td>
1271 <td align=right><input name="l_paid" class=checkbox type=checkbox value=Y checked></td>
1272 <td nowrap>| . $locale->text('Paid') . qq|</td>
1273 <td align=right><input name="l_duedate" class=checkbox type=checkbox value=Y></td>
1274 <td nowrap>| . $locale->text('Due Date') . qq|</td>
1275 <td align=right><input name="l_due" class=checkbox type=checkbox value=Y></td>
1276 <td nowrap>| . $locale->text('Amount Due') . qq|</td>
1279 <td align=right><input name="l_notes" class=checkbox type=checkbox value=Y></td>
1280 <td nowrap>| . $locale->text('Notes') . qq|</td>
1281 <td align=right><input name="l_employee" class=checkbox type=checkbox value=Y></td>
1282 <td nowrap>| . $locale->text('Employee') . qq|</td>
1285 <td align=right><input name="l_subtotal" class=checkbox type=checkbox value=Y></td>
1286 <td nowrap>| . $locale->text('Subtotal') . qq|</td>
1287 <td align=right><input name="l_globalprojectnumber" class=checkbox type=checkbox value=Y></td>
1288 <td nowrap>| . $locale->text('Project Number') . qq|</td>
1297 <td><hr size=3 noshade></td>
1304 <input type=hidden name=nextsub value=$form->{nextsub}>
1305 <input type=hidden name=path value=$form->{path}>
1306 <input type=hidden name=login value=$form->{login}>
1307 <input type=hidden name=password value=$form->{password}>
1309 <input class=submit type=submit name=action value="|
1310 . $locale->text('Continue') . qq|">
1317 $lxdebug->leave_sub();
1320 sub ap_transactions {
1321 $lxdebug->enter_sub();
1323 $form->{vendor} = $form->unescape($form->{vendor});
1324 ($form->{vendor}, $form->{vendor_id}) = split(/--/, $form->{vendor});
1326 AP->ap_transactions(\%myconfig, \%$form);
1329 "$form->{script}?action=ap_transactions&path=$form->{path}&login=$form->{login}&password=$form->{password}";
1332 if ($form->{vendor}) {
1333 $callback .= "&vendor=" . $form->escape($form->{vendor}, 1);
1334 $href .= "&vendor=" . $form->escape($form->{vendor});
1335 $option .= $locale->text('Vendor') . " : $form->{vendor}";
1337 if ($form->{department}) {
1338 $callback .= "&department=" . $form->escape($form->{department}, 1);
1339 $href .= "&department=" . $form->escape($form->{department});
1340 ($department) = split /--/, $form->{department};
1341 $option .= "\n<br>" if ($option);
1342 $option .= $locale->text('Department') . " : $department";
1344 if ($form->{invnumber}) {
1345 $callback .= "&invnumber=" . $form->escape($form->{invnumber}, 1);
1346 $href .= "&invnumber=" . $form->escape($form->{invnumber});
1347 $option .= "\n<br>" if ($option);
1348 $option .= $locale->text('Invoice Number') . " : $form->{invnumber}";
1350 if ($form->{ordnumber}) {
1351 $callback .= "&ordnumber=" . $form->escape($form->{ordnumber}, 1);
1352 $href .= "&ordnumber=" . $form->escape($form->{ordnumber});
1353 $option .= "\n<br>" if ($option);
1354 $option .= $locale->text('Order Number') . " : $form->{ordnumber}";
1356 if ($form->{notes}) {
1357 $callback .= "¬es=" . $form->escape($form->{notes}, 1);
1358 $href .= "¬es=" . $form->escape($form->{notes});
1359 $option .= "\n<br>" if $option;
1360 $option .= $locale->text('Notes') . " : $form->{notes}";
1363 if ($form->{transdatefrom}) {
1364 $callback .= "&transdatefrom=$form->{transdatefrom}";
1365 $href .= "&transdatefrom=$form->{transdatefrom}";
1366 $option .= "\n<br>" if ($option);
1368 $locale->text('From') . " "
1369 . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
1371 if ($form->{transdateto}) {
1372 $callback .= "&transdateto=$form->{transdateto}";
1373 $href .= "&transdateto=$form->{transdateto}";
1374 $option .= "\n<br>" if ($option);
1376 $locale->text('Bis') . " "
1377 . $locale->date(\%myconfig, $form->{transdateto}, 1);
1379 if ($form->{open}) {
1380 $callback .= "&open=$form->{open}";
1381 $href .= "&open=$form->{open}";
1382 $option .= "\n<br>" if ($option);
1383 $option .= $locale->text('Open');
1385 if ($form->{closed}) {
1386 $callback .= "&closed=$form->{closed}";
1387 $href .= "&closed=$form->{closed}";
1388 $option .= "\n<br>" if ($option);
1389 $option .= $locale->text('Closed');
1391 if ($form->{globalproject_id}) {
1392 $callback .= "&globalproject_id=" . E($form->{globalproject_id});
1393 $href .= "&globalproject_id=" . E($form->{globalproject_id});
1397 qw(transdate id invnumber ordnumber name netamount tax amount paid datepaid
1398 due duedate notes employee globalprojectnumber);
1400 foreach $item (@columns) {
1401 if ($form->{"l_$item"} eq "Y") {
1402 push @column_index, $item;
1404 # add column to href and callback
1405 $callback .= "&l_$item=Y";
1406 $href .= "&l_$item=Y";
1410 if ($form->{l_subtotal} eq 'Y') {
1411 $callback .= "&l_subtotal=Y";
1412 $href .= "&l_subtotal=Y";
1415 $column_header{id} =
1416 qq|<th><a class=listheading href=$href&sort=id>|
1417 . $locale->text('ID')
1419 $column_header{transdate} =
1420 qq|<th><a class=listheading href=$href&sort=transdate>|
1421 . $locale->text('Date')
1423 $column_header{duedate} =
1424 qq|<th><a class=listheading href=$href&sort=duedate>|
1425 . $locale->text('Due Date')
1427 $column_header{due} =
1428 qq|<th class=listheading>| . $locale->text('Amount Due') . qq|</th>|;
1429 $column_header{invnumber} =
1430 qq|<th><a class=listheading href=$href&sort=invnumber>|
1431 . $locale->text('Invoice')
1433 $column_header{ordnumber} =
1434 qq|<th><a class=listheading href=$href&sort=ordnumber>|
1435 . $locale->text('Order')
1437 $column_header{name} =
1438 qq|<th><a class=listheading href=$href&sort=name>|
1439 . $locale->text('Vendor')
1441 $column_header{netamount} =
1442 qq|<th class=listheading>| . $locale->text('Amount') . qq|</th>|;
1443 $column_header{tax} =
1444 qq|<th class=listheading>| . $locale->text('Tax') . qq|</th>|;
1445 $column_header{amount} =
1446 qq|<th class=listheading>| . $locale->text('Total') . qq|</th>|;
1447 $column_header{paid} =
1448 qq|<th class=listheading>| . $locale->text('Paid') . qq|</th>|;
1449 $column_header{datepaid} =
1450 qq|<th><a class=listheading href=$href&sort=datepaid>|
1451 . $locale->text('Date Paid')
1453 $column_header{notes} =
1454 qq|<th class=listheading>| . $locale->text('Notes') . qq|</th>|;
1455 $column_header{employee} =
1456 "<th><a class=listheading href=$href&sort=employee>"
1457 . $locale->text('Employee') . "</th>";
1458 $column_header{globalprojectnumber} =
1459 qq|<th class="listheading">| . $locale->text('Project Number') . qq|</th>|;
1461 $form->{title} = $locale->text('AP Transactions');
1470 <th class=listtop>$form->{title}</th>
1472 <tr height="5"></tr>
1479 <tr class=listheading>
1482 map { print "\n$column_header{$_}" } @column_index;
1488 # add sort and escape callback
1489 $form->{callback} = "$callback&sort=$form->{sort}";
1490 $callback = $form->escape($form->{callback});
1492 if (@{ $form->{AP} }) {
1493 $sameitem = $form->{AP}->[0]->{ $form->{sort} };
1496 # sums and tax on reports by Antonio Gallardo
1498 foreach $ap (@{ $form->{AP} }) {
1500 if ($form->{l_subtotal} eq 'Y') {
1501 if ($sameitem ne $ap->{ $form->{sort} }) {
1503 $sameitem = $ap->{ $form->{sort} };
1507 $column_data{netamount} =
1509 . $form->format_amount(\%myconfig, $ap->{netamount}, 2, " ")
1511 $column_data{tax} = "<td align=right>"
1512 . $form->format_amount(\%myconfig, $ap->{amount} - $ap->{netamount},
1515 $column_data{amount} =
1517 . $form->format_amount(\%myconfig, $ap->{amount}, 2, " ") . "</td>";
1518 $column_data{paid} =
1520 . $form->format_amount(\%myconfig, $ap->{paid}, 2, " ") . "</td>";
1521 $column_data{due} = "<td align=right>"
1522 . $form->format_amount(\%myconfig, $ap->{amount} - $ap->{paid},
1526 $totalnetamount += $ap->{netamount};
1527 $totalamount += $ap->{amount};
1528 $totalpaid += $ap->{paid};
1529 $totaldue += ($ap->{amount} - $ap->{paid});
1531 $subtotalnetamount += $ap->{netamount};
1532 $subtotalamount += $ap->{amount};
1533 $subtotalpaid += $ap->{paid};
1534 $subtotaldue += ($ap->{amount} - $ap->{paid});
1536 $column_data{transdate} = "<td>$ap->{transdate} </td>";
1537 $column_data{duedate} = "<td>$ap->{duedate} </td>";
1538 $column_data{datepaid} = "<td>$ap->{datepaid} </td>";
1540 $module = ($ap->{invoice}) ? "ir.pl" : $form->{script};
1542 $column_data{invnumber} =
1543 qq|<td><a href="$module?action=edit&path=$form->{path}&id=$ap->{id}&login=$form->{login}&password=$form->{password}&callback=$callback">$ap->{invnumber}</a></td>|;
1544 $column_data{id} = "<td>$ap->{id}</td>";
1545 $column_data{ordnumber} = "<td>$ap->{ordnumber} </td>";
1546 $column_data{name} = "<td>$ap->{name}</td>";
1547 $ap->{notes} =~ s/\r\n/<br>/g;
1548 $column_data{notes} = "<td>$ap->{notes} </td>";
1549 $column_data{employee} = "<td>$ap->{employee} </td>";
1550 $column_data{globalprojectnumber} =
1551 "<td>" . H($ap->{globalprojectnumber}) . "</td>";
1556 <tr class=listrow$i >
1559 map { print "\n$column_data{$_}" } @column_index;
1567 if ($form->{l_subtotal} eq 'Y') {
1573 <tr class=listtotal>
1576 map { $column_data{$_} = "<td> </td>" } @column_index;
1578 $column_data{netamount} =
1579 "<th class=listtotal align=right>"
1580 . $form->format_amount(\%myconfig, $totalnetamount, 2, " ") . "</th>";
1581 $column_data{tax} = "<th class=listtotal align=right>"
1582 . $form->format_amount(\%myconfig, $totalamount - $totalnetamount,
1585 $column_data{amount} =
1586 "<th class=listtotal align=right>"
1587 . $form->format_amount(\%myconfig, $totalamount, 2, " ") . "</th>";
1588 $column_data{paid} =
1589 "<th class=listtotal align=right>"
1590 . $form->format_amount(\%myconfig, $totalpaid, 2, " ") . "</th>";
1592 "<th class=listtotal align=right>"
1593 . $form->format_amount(\%myconfig, $totaldue, 2, " ") . "</th>";
1595 map { print "$column_data{$_}\n" } @column_index;
1603 <td><hr size=3 noshade></td>
1608 <form method=post action=$form->{script}>
1610 <input name=callback type=hidden value="$form->{callback}">
1612 <input type=hidden name=path value=$form->{path}>
1613 <input type=hidden name=login value=$form->{login}>
1614 <input type=hidden name=password value=$form->{password}>
1616 <input class=submit type=submit name=action value="|
1617 . $locale->text('AP Transaction') . qq|">
1619 <input class=submit type=submit name=action value="|
1620 . $locale->text('Vendor Invoice') . qq|">
1628 $lxdebug->leave_sub();
1632 $lxdebug->enter_sub();
1634 map { $column_data{$_} = "<td> </td>" } @column_index;
1636 $column_data{netamount} =
1637 "<th class=listsubtotal align=right>"
1638 . $form->format_amount(\%myconfig, $subtotalnetamount, 2, " ")
1640 $column_data{tax} = "<th class=listsubtotal align=right>"
1641 . $form->format_amount(\%myconfig, $subtotalamount - $subtotalnetamount,
1644 $column_data{amount} =
1645 "<th class=listsubtotal align=right>"
1646 . $form->format_amount(\%myconfig, $subtotalamount, 2, " ") . "</th>";
1647 $column_data{paid} =
1648 "<th class=listsubtotal align=right>"
1649 . $form->format_amount(\%myconfig, $subtotalpaid, 2, " ") . "</th>";
1651 "<th class=listsubtotal align=right>"
1652 . $form->format_amount(\%myconfig, $subtotaldue, 2, " ") . "</th>";
1654 $subtotalnetamount = 0;
1655 $subtotalamount = 0;
1659 print "<tr class=listsubtotal>";
1661 map { print "\n$column_data{$_}" } @column_index;
1667 $lxdebug->leave_sub();