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 #======================================================================
39 require "bin/mozilla/arap.pl";
40 require "bin/mozilla/common.pl";
41 require "bin/mozilla/drafts.pl";
47 # this is for our long dates
48 # $locale->text('January')
49 # $locale->text('February')
50 # $locale->text('March')
51 # $locale->text('April')
52 # $locale->text('May ')
53 # $locale->text('June')
54 # $locale->text('July')
55 # $locale->text('August')
56 # $locale->text('September')
57 # $locale->text('October')
58 # $locale->text('November')
59 # $locale->text('December')
61 # this is for our short month
62 # $locale->text('Jan')
63 # $locale->text('Feb')
64 # $locale->text('Mar')
65 # $locale->text('Apr')
66 # $locale->text('May')
67 # $locale->text('Jun')
68 # $locale->text('Jul')
69 # $locale->text('Aug')
70 # $locale->text('Sep')
71 # $locale->text('Oct')
72 # $locale->text('Nov')
73 # $locale->text('Dec')
76 $lxdebug->enter_sub();
78 return $lxdebug->leave_sub() if (load_draft_maybe());
80 $form->{title} = "Add";
83 "$form->{script}?action=add&login=$form->{login}&password=$form->{password}"
84 unless $form->{callback};
86 AP->get_transdate(\%myconfig, $form);
87 $form->{initial_transdate} = $form->{transdate};
89 $form->{transdate} = $form->{initial_transdate};
92 $lxdebug->leave_sub();
96 $lxdebug->enter_sub();
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";
132 $form->{notes} = $form->{intnotes} unless $form->{notes};
135 @curr = split(/:/, $form->{currencies});
137 $form->{defaultcurrency} = $curr[0];
139 map { $form->{selectcurrency} .= "<option>$_\n" } @curr;
142 if (@{ $form->{all_vendor} }) {
143 $form->{vendor} = qq|$form->{vendor}--$form->{vendor_id}|;
144 map { $form->{selectvendor} .= "<option>$_->{name}--$_->{id}\n" }
145 (@{ $form->{all_vendor} });
149 if (@{ $form->{all_departments} }) {
150 $form->{selectdepartment} = "<option>\n";
151 $form->{department} = "$form->{department}--$form->{department_id}";
154 $form->{selectdepartment} .=
155 "<option>$_->{description}--$_->{id}\n"
156 } (@{ $form->{all_departments} });
159 $form->{employee} = "$form->{employee}--$form->{employee_id}";
161 AP->setup_form($form);
164 ($form->datetonum($form->{transdate}, \%myconfig) <=
165 $form->datetonum($form->{closedto}, \%myconfig));
167 $lxdebug->leave_sub();
171 $lxdebug->enter_sub();
173 $title = $form->{title};
174 $form->{title} = $locale->text("$title Accounts Payables Transaction");
176 $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
178 # type=submit $locale->text('Add Accounts Payables Transaction')
179 # type=submit $locale->text('Edit Accounts Payables Transaction')
181 $form->{javascript} = qq|<script type="text/javascript">
183 function setTaxkey(accno, row) {
184 var taxkey = accno.options[accno.selectedIndex].value;
185 var reg = /--([0-9]*)/;
186 var found = reg.exec(taxkey);
187 var index = found[1];
188 index = parseInt(index);
189 var tax = 'taxchart_' + row;
190 for (var i = 0; i < document.getElementById(tax).options.length; ++i) {
191 var reg2 = new RegExp("^"+ index, "");
192 if (reg2.exec(document.getElementById(tax).options[i].value)) {
193 document.getElementById(tax).options[i].selected = true;
200 # show history button
201 $form->{javascript} .= qq|<script type="text/javascript" src="js/show_history.js"></script>|;
202 #/show hhistory button
204 # set option selected
205 foreach $item (qw(vendor currency department)) {
206 $form->{"select$item"} =~ s/ selected//;
207 $form->{"select$item"} =~
208 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
210 $readonly = ($form->{id}) ? "readonly" : "";
213 ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0;
214 $readonly = ($form->{radier}) ? "" : $readonly;
217 $form->{exchangerate} =
218 $form->format_amount(\%myconfig, $form->{exchangerate});
220 $form->{creditlimit} =
221 $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
222 $form->{creditremaining} =
223 $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
226 <input type=hidden name=forex value=$form->{forex}>
228 if ($form->{currency} ne $form->{defaultcurrency}) {
229 if ($form->{forex}) {
232 <th align=right>| . $locale->text('Exchangerate') . qq|</th>
233 <td><input type=hidden name=exchangerate value=$form->{exchangerate}>$form->{exchangerate}</td>
238 <th align=right>| . $locale->text('Exchangerate') . qq|</th>
239 <td><input name=exchangerate size=10 value=$form->{exchangerate}></td>
248 <td align=right><input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}></td>
249 <th align=left nowrap>|
250 . $locale->text('Tax Included') . qq|</th>
254 if (($rows = $form->numtextrows($form->{notes}, 50)) < 2) {
258 qq|<textarea name=notes rows=$rows cols=50 wrap=soft $readonly>$form->{notes}</textarea>|;
262 <th align="right" nowrap>| . $locale->text('Department') . qq|</th>
263 <td colspan=3><select name=department>$form->{selectdepartment}</select>
264 <input type=hidden name=selectdepartment value="$form->{selectdepartment}">
267 | if $form->{selectdepartment};
269 $n = ($form->{creditremaining} =~ /-/) ? "0" : "1";
272 ($form->{selectvendor})
273 ? qq|<select name="vendor"
274 onchange="document.getElementById('update_button').click();">$form->{
275 selectvendor } </select>|
276 : qq|<input name=vendor value="$form->{vendor}" size=35>|;
278 my @old_project_ids = ();
279 map({ push(@old_project_ids, $form->{"project_id_$_"})
280 if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
282 $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
284 "old_id" => \@old_project_ids },
285 "charts" => { "key" => "ALL_CHARTS",
286 "transdate" => $form->{transdate} },
287 "taxcharts" => "ALL_TAXCHARTS");
289 map({ $_->{link_split} = [ split(/:/, $_->{link}) ]; }
290 @{ $form->{ALL_CHARTS} });
292 my %project_labels = ();
293 my @project_values = ("");
294 foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
295 push(@project_values, $item->{"id"});
296 $project_labels{$item->{"id"}} = $item->{"projectnumber"};
299 my (%AP_amount_labels, @AP_amount_values);
300 my (%AP_labels, @AP_values);
301 my (%AP_paid_labels, @AP_paid_values);
305 foreach my $item (@{ $form->{ALL_CHARTS} }) {
306 if (grep({ $_ eq "AP_amount" } @{ $item->{link_split} })) {
307 $taxchart_init = $item->{tax_id} if ($taxchart_init eq "");
308 my $key = "$item->{accno}--$item->{tax_id}";
309 push(@AP_amount_values, $key);
310 $AP_amount_labels{$key} =
311 "$item->{accno}--$item->{description}";
313 } elsif (grep({ $_ eq "AP" } @{ $item->{link_split} })) {
314 push(@AP_values, $item->{accno});
315 $AP_labels{$item->{accno}} = "$item->{accno}--$item->{description}";
317 } elsif (grep({ $_ eq "AP_paid" } @{ $item->{link_split} })) {
318 push(@AP_paid_values, $item->{accno});
319 $AP_paid_labels{$item->{accno}} =
320 "$item->{accno}--$item->{description}";
323 $charts{$item->{accno}} = $item;
326 my %taxchart_labels = ();
327 my @taxchart_values = ();
329 foreach my $item (@{ $form->{ALL_TAXCHARTS} }) {
330 my $key = "$item->{id}--$item->{rate}";
331 $taxchart_init = $key if ($taxchart_init eq $item->{id});
332 push(@taxchart_values, $key);
333 $taxchart_labels{$key} =
334 "$item->{taxdescription} " . ($item->{rate} * 100) . ' %';
335 $taxcharts{$item->{id}} = $item;
338 # use JavaScript Calendar or not
339 $form->{jsscript} = 1;
341 if ($form->{jsscript}) {
343 # with JavaScript Calendar
345 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value="$form->{transdate}" onBlur=\"check_right_date_format(this)\"> $readonly</td>
346 <td><input type=button name=transdate id="trigger1" value=|
347 . $locale->text('button') . qq|></td>
350 <td><input name=duedate id=duedate size=11 title="$myconfig{dateformat}" value="$form->{duedate}" onBlur=\"check_right_date_format(this)\"> $readonly</td>
351 <td><input type=button name=duedate id="trigger2" value=|
352 . $locale->text('button') . qq|></td></td>
357 Form->write_trigger(\%myconfig, "2", "transdate", "BL", "trigger1",
358 "duedate", "BL", "trigger2");
361 # without JavaScript Calendar
363 qq|<td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value="$form->{transdate}" onBlur=\"check_right_date_format(this)\"> $readonly</td>|;
365 qq|<td><input name=duedate id=duedate size=11 title="$myconfig{dateformat}" value="$form->{duedate}" onBlur=\"check_right_date_format(this)\"> $readonly</td>|;
367 $form->{javascript} .= qq|<script type="text/javascript" src="js/common.js"></script>|;
368 $form->{javascript} .= qq|<script type="text/javascript" src="js/show_vc_details.js"></script>|;
371 $onload = qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
372 $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
374 <body onLoad="$onload">
376 <form method=post action=$form->{script}>
378 <input type=hidden name=id value=$form->{id}>
379 <input type=hidden name=sort value=$form->{sort}>
380 <input type=hidden name=closedto value=$form->{closedto}>
381 <input type=hidden name=locked value=$form->{locked}>
382 <input type=hidden name=title value="$title">
384 | . ($form->{saved_message} ? qq|<p>$form->{saved_message}</p>| : "") . qq|
388 <th class=listtop>$form->{title}</th>
398 <th align=right nowrap>| . $locale->text('Vendor') . qq|</th>
399 <td colspan=3>$vendor <input type="button" value="?" onclick="show_vc_details('vendor')"></td>
400 <input type=hidden name=selectvendor value="$form->{selectvendor}">
401 <input type=hidden name=oldvendor value="$form->{oldvendor}">
402 <input type=hidden name=vendor_id value="$form->{vendor_id}">
403 <input type=hidden name=terms value=$form->{terms}>
410 <th align=left nowrap>| . $locale->text('Credit Limit') . qq|</th>
411 <td>$form->{creditlimit}</td>
412 <th align=left nowrap>| . $locale->text('Remaining') . qq|</th>
413 <td class="plus$n">$form->{creditremaining}</td>
414 <input type=hidden name=creditlimit value=$form->{creditlimit}>
415 <input type=hidden name=creditremaining value=$form->{creditremaining}>
420 <th align=right nowrap>| . $locale->text('Currency') . qq|</th>
421 <td><select name=currency>$form->{selectcurrency}</select></td>
422 <input type=hidden name=selectcurrency value="$form->{selectcurrency}">
423 <input type=hidden name=defaultcurrency value=$form->{defaultcurrency}>
424 <input type=hidden name=fxgain_accno value=$form->{fxgain_accno}>
425 <input type=hidden name=fxloss_accno value=$form->{fxloss_accno}>
435 <th align=right nowrap>| . $locale->text('Invoice Number') . qq|</th>
436 <td><input name=invnumber size=11 value="$form->{invnumber}" $readonly></td>
439 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
440 <td><input name=ordnumber size=11 value="$form->{ordnumber}" $readonly></td>
443 <th align=right nowrap>| . $locale->text('Invoice Date') . qq|</th>
447 <th align=right nowrap>| . $locale->text('Due Date') . qq|</th>
460 <input type=hidden name=rowcount value=$form->{rowcount}>
464 <tr class=listheading>
465 <th class=listheading style="width:15%">|
466 . $locale->text('Account') . qq|</th>
467 <th class=listheading style="width:10%">|
468 . $locale->text('Amount') . qq|</th>
469 <th class=listheading style="width:10%">|
470 . $locale->text('Tax') . qq|</th>
471 <th class=listheading style="width:5%">|
472 . $locale->text('Korrektur') . qq|</th>
473 <th class=listheading style="width:10%">|
474 . $locale->text('Taxkey') . qq|</th>
475 <th class=listheading style="width:10%">|
476 . $locale->text('Project') . qq|</th>
480 $amount = $locale->text('Amount');
481 $project = $locale->text('Project');
483 for $i (1 .. $form->{rowcount}) {
486 $form->{"amount_$i"} =
487 $form->format_amount(\%myconfig, $form->{"amount_$i"}, 2);
488 $form->{"tax_$i"} = $form->format_amount(\%myconfig, $form->{"tax_$i"}, 2);
490 my $selected_accno_full;
491 my ($accno_row) = split(/--/, $form->{"AP_amount_$i"});
492 my $item = $charts{$accno_row};
493 $selected_accno_full = "$item->{accno}--$item->{tax_id}";
495 my $selected_taxchart = $form->{"taxchart_$i"};
496 my ($selected_accno, $selected_tax_id) = split(/--/, $selected_accno_full);
497 my ($previous_accno, $previous_tax_id) = split(/--/, $form->{"previous_AP_amount_$i"});
499 if ($previous_accno &&
500 ($previous_accno eq $selected_accno) &&
501 ($previous_tax_id ne $selected_tax_id)) {
502 my $item = $taxcharts{$selected_tax_id};
503 $selected_taxchart = "$item->{id}--$item->{rate}";
506 $selected_taxchart = $taxchart_init unless ($form->{"taxchart_$i"});
509 NTI($cgi->popup_menu('-name' => "AP_amount_$i",
510 '-id' => "AP_amount_$i",
511 '-style' => 'width:400px',
512 '-onChange' => "setTaxkey(this, $i)",
513 '-values' => \@AP_amount_values,
514 '-labels' => \%AP_amount_labels,
515 '-default' => $selected_accno_full))
516 . $cgi->hidden('-name' => "previous_AP_amount_$i",
517 '-default' => $selected_accno_full);
520 NTI($cgi->popup_menu('-name' => "taxchart_$i",
521 '-id' => "taxchart_$i",
522 '-style' => 'width:200px',
523 '-values' => \@taxchart_values,
524 '-labels' => \%taxchart_labels,
525 '-default' => $selected_taxchart))
528 my $korrektur = $form->{"korrektur_$i"} ? 'checked' : '';
531 NTI($cgi->popup_menu('-name' => "project_id_$i",
532 '-values' => \@project_values,
533 '-labels' => \%project_labels,
534 '-default' => $form->{"project_id_$i"} ));
538 <td>$selectAP_amount</td>
539 <td><input name="amount_$i" size=10 value=$form->{"amount_$i"}></td>
540 <td><input name="tax_$i" size=10 value=$form->{"tax_$i"}></td>
541 <td><input type="checkbox" name="korrektur_$i" value="1" "$korrektur"></td>
543 <td>$projectnumber</td>
551 ($form->{taxincluded})
552 ? $locale->text('Tax Included')
553 : $locale->text('Tax');
555 $form->{invtotal_unformatted} = $form->{invtotal};
556 $form->{invtotal} = $form->format_amount(\%myconfig, $form->{invtotal}, 2);
559 NTI($cgi->popup_menu('-name' => "APselected", '-id' => "APselected",
560 '-style' => 'width:400px',
561 '-values' => \@AP_values, '-labels' => \%AP_labels,
562 '-default' => $form->{APselected}));
570 <td>${APselected}</td>
571 <th align=left>$form->{invtotal}</th>
573 <input type=hidden name=oldinvtotal value=$form->{oldinvtotal}>
574 <input type=hidden name=oldtotalpaid value=$form->{oldtotalpaid}>
576 <input type=hidden name=taxaccounts value="$form->{taxaccounts}">
589 <th align=left width=1%>| . $locale->text('Notes') . qq|</th>
590 <td align=left>$notes</td>
598 <tr class=listheading>
599 <th class=listheading colspan=7>| . $locale->text('Payments') . qq|</th>
603 if ($form->{currency} eq $form->{defaultcurrency}) {
604 @column_index = qw(datepaid source memo paid AP_paid paid_project_id);
606 @column_index = qw(datepaid source memo paid exchangerate AP_paid paid_project_id);
609 $column_data{datepaid} = "<th>" . $locale->text('Date') . "</th>";
610 $column_data{paid} = "<th>" . $locale->text('Amount') . "</th>";
611 $column_data{exchangerate} = "<th>" . $locale->text('Exch') . "</th>";
612 $column_data{AP_paid} = "<th>" . $locale->text('Account') . "</th>";
613 $column_data{source} = "<th>" . $locale->text('Source') . "</th>";
614 $column_data{memo} = "<th>" . $locale->text('Memo') . "</th>";
615 $column_data{paid_project_id} = "<th>" . $locale->text('Project Number') . "</th>";
620 map { print "$column_data{$_}\n" } @column_index;
628 $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
629 for $i (1 .. $form->{paidaccounts}) {
635 NTI($cgi->popup_menu('-name' => "AP_paid_$i",
636 '-id' => "AP_paid_$i",
637 '-values' => \@AP_paid_values,
638 '-labels' => \%AP_paid_labels,
639 '-default' => $form->{"AP_paid_$i"}));
641 $totalpaid += $form->{"paid_$i"};
644 if ($form->{"paid_$i"}) {
646 $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2);
648 $form->{"exchangerate_$i"} =
649 $form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
651 $exchangerate = qq| |;
652 if ($form->{currency} ne $form->{defaultcurrency}) {
653 if ($form->{"forex_$i"}) {
655 qq|<input type=hidden name="exchangerate_$i" value=$form->{"exchangerate_$i"}>$form->{"exchangerate_$i"}|;
658 qq|<input name="exchangerate_$i" size=10 value=$form->{"exchangerate_$i"}>|;
663 <input type=hidden name="forex_$i" value=$form->{"forex_$i"}>
666 $column_data{"paid_$i"} =
667 qq|<td align=center><input name="paid_$i" size=11 value="$form->{"paid_$i"}" onBlur=\"check_right_number_format(this)\"></td>|;
668 $column_data{"AP_paid_$i"} =
669 qq|<td align=center>${selectAP_paid}</td>|;
670 $column_data{"exchangerate_$i"} = qq|<td align=center>$exchangerate</td>|;
671 $column_data{"datepaid_$i"} =
672 qq|<td align=center><input name="datepaid_$i" id="datepaid_$i" size=11 title="($myconfig{'dateformat'})" value="$form->{"datepaid_$i"}" onBlur=\"check_right_date_format(this)\">
673 <input type="button" name="datepaid_$i" id="trigger_datepaid_$i" value="?"></td>|;
674 $column_data{"source_$i"} =
675 qq|<td align=center><input name="source_$i" size=11 value="$form->{"source_$i"}"></td>|;
676 $column_data{"memo_$i"} =
677 qq|<td align=center><input name="memo_$i" size=11 value="$form->{"memo_$i"}"></td>|;
678 $column_data{"paid_project_id_$i"} =
680 . NTI($cgi->popup_menu('-name' => "paid_project_id_$i",
681 '-values' => \@project_values,
682 '-labels' => \%project_labels,
683 '-default' => $form->{"paid_project_id_$i"} ))
686 map { print qq|$column_data{"${_}_$i"}\n| } @column_index;
691 push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i");
694 my $paid_missing = $form->{invtotal_unformatted} - $totalpaid;
700 <td align="center">| . $locale->text('Total') . qq|</td>
701 <td align="center">| . H($form->format_amount(\%myconfig, $totalpaid, 2)) . qq|</td>
706 <td align="center">| . $locale->text('Missing amount') . qq|</td>
707 <td align="center">| . H($form->format_amount(\%myconfig, $paid_missing, 2)) . qq|</td>
709 | . $form->write_trigger(\%myconfig, scalar(@triggers) / 3, @triggers) .
711 <input type=hidden name=paidaccounts value=$form->{paidaccounts}>
717 <td><hr size=3 noshade></td>
722 $lxdebug->leave_sub();
726 $lxdebug->enter_sub();
730 <input name=callback type=hidden value="$form->{callback}">
731 <input name="gldate" type="hidden" value="| . Q($form->{gldate}) . qq|">
733 <input type=hidden name=login value=$form->{login}>
734 <input type=hidden name=password value=$form->{password}>
736 . $cgi->hidden('-name' => 'draft_id', '-default' => [$form->{draft_id}])
737 . $cgi->hidden('-name' => 'draft_description', '-default' => [$form->{draft_description}])
743 if (!$form->{id} && $form->{draft_id}) {
744 print(NTI($cgi->checkbox('-name' => 'remove_draft', '-id' => 'remove_draft',
745 '-value' => 1, '-checked' => $form->{remove_draft},
747 qq| <label for="remove_draft">| .
748 $locale->text("Remove draft when posting") .
752 $transdate = $form->datetonum($form->{transdate}, \%myconfig);
753 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
755 print qq|<input class="submit" type="submit" name="action" id="update_button" value="| . $locale->text('Update') . qq|">|;
758 if ($form->{radier}) {
759 print qq| <input class=submit type=submit name=action value="| . $locale->text('Post') . qq|">
760 <input class=submit type=submit name=action value="| . $locale->text('Delete') . qq|">
764 # ToDO: - insert a global check for stornos, so that a storno is only possible a limited time after saving it
765 print qq|<input class=submit type=submit name=action value="| . $locale->text('Storno') . qq|"> |
766 if ($form->{id} && !IS->has_storno(\%myconfig, $form, 'ap') && !IS->is_storno(\%myconfig, $form, 'ap') && !$form->{paid_1});
768 print qq| <input class=submit type=submit name=action value="| . $locale->text('Post Payment') . qq|">
769 <input class=submit type=submit name=action value="| . $locale->text('Use As Template') . qq|">
771 } elsif (($transdate > $closedto) && !$form->{id}) {
773 <input class=submit type=submit name=action value="| . $locale->text('Post') . qq|"> | .
774 NTI($cgi->submit('-name' => 'action', '-value' => $locale->text('Save draft'), '-class' => 'submit'));
776 # button for saving history
777 if($form->{id} ne "") {
778 print qq| <input type="button" class="submit" onclick="set_history_window($form->{id});" name="history" id="history" value="| . $locale->text('history') . qq|">|;
780 # /button for saving history
788 $lxdebug->leave_sub();
792 $lxdebug->enter_sub();
796 $form->{invtotal} = 0;
798 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
799 qw(exchangerate creditlimit creditremaining);
801 @flds = qw(amount AP_amount projectnumber oldprojectnumber project_id);
803 for $i (1 .. $form->{rowcount}) {
804 $form->{"amount_$i"} =
805 $form->parse_amount(\%myconfig, $form->{"amount_$i"});
806 $form->{"tax_$i"} = $form->parse_amount(\%myconfig, $form->{"tax_$i"});
807 if ($form->{"amount_$i"}) {
810 if (!$form->{"korrektur_$i"}) {
811 ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
813 if ($form->{taxincluded}) {
814 $form->{"tax_$i"} = $form->{"amount_$i"} / ($rate + 1) * $rate;
816 $form->{"tax_$i"} = $form->{"amount_$i"} * $rate;
819 $form->{"tax_$i"} = 0;
822 $form->{"tax_$i"} = $form->round_amount($form->{"tax_$i"}, 2);
824 $totaltax += $form->{"tax_$i"};
825 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
829 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
831 map { $form->{invtotal} += $form->{"amount_$_"} } (1 .. $form->{rowcount});
833 $form->{exchangerate} = $exchangerate
837 $form->check_exchangerate(
838 \%myconfig, $form->{currency}, $form->{transdate}, 'sell'
841 $form->{invdate} = $form->{transdate};
842 $save_AP = $form->{AP};
844 $form->{AP} = $save_AP;
846 $form->{rowcount} = $count + 1;
849 ($form->{taxincluded}) ? $form->{invtotal} : $form->{invtotal} + $totaltax;
851 for $i (1 .. $form->{paidaccounts}) {
852 if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
855 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
856 } qw(paid exchangerate);
858 $totalpaid += $form->{"paid_$i"};
860 $form->{"exchangerate_$i"} = $exchangerate
862 $form->{"forex_$i"} = (
864 $form->check_exchangerate(
865 \%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'sell'
870 $form->{creditremaining} -=
871 ($form->{invtotal} - $totalpaid + $form->{oldtotalpaid} -
872 $form->{oldinvtotal});
873 $form->{oldinvtotal} = $form->{invtotal};
874 $form->{oldtotalpaid} = $totalpaid;
878 $lxdebug->leave_sub();
883 $lxdebug->enter_sub();
884 for $i (1 .. $form->{paidaccounts}) {
885 if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
886 $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
888 $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
890 $form->error($locale->text('Cannot post payment for a closed period!'))
891 if ($datepaid <= $closedto);
893 if ($form->{currency} ne $form->{defaultcurrency}) {
894 $form->{"exchangerate_$i"} = $form->{exchangerate}
895 if ($invdate == $datepaid);
896 $form->isblank("exchangerate_$i",
897 $locale->text('Exchangerate for payment missing!'));
902 ($form->{AP}) = split /--/, $form->{AP};
903 ($form->{AP_paid}) = split /--/, $form->{AP_paid};
904 $form->redirect($locale->text('Payment posted!'))
905 if (AP->post_payment(\%myconfig, \%$form));
906 $form->error($locale->text('Cannot post payment!'));
909 $lxdebug->leave_sub();
914 $lxdebug->enter_sub();
916 # check if there is a vendor, invoice and due date
917 $form->isblank("transdate", $locale->text("Invoice Date missing!"));
918 $form->isblank("duedate", $locale->text("Due Date missing!"));
919 $form->isblank("vendor", $locale->text('Vendor missing!'));
921 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
922 $transdate = $form->datetonum($form->{transdate}, \%myconfig);
923 $form->error($locale->text('Cannot post transaction for a closed period!')) if ($transdate <= $closedto);
925 my $zero_amount_posting = 1;
926 for $i (1 .. $form->{rowcount}) {
927 if ($form->parse_amount(\%myconfig, $form->{"amount_$i"})) {
928 $zero_amount_posting = 0;
933 $form->error($locale->text('Zero amount posting!')) if $zero_amount_posting;
935 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
936 if ($form->{currency} ne $form->{defaultcurrency});
939 for $i (1 .. $form->{paidaccounts}) {
940 if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
941 $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
943 $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
945 $form->error($locale->text('Cannot post payment for a closed period!'))
946 if ($datepaid <= $closedto);
948 if ($form->{currency} ne $form->{defaultcurrency}) {
949 $form->{"exchangerate_$i"} = $form->{exchangerate}
950 if ($transdate == $datepaid);
951 $form->isblank("exchangerate_$i",
952 $locale->text('Exchangerate for payment missing!'));
958 # if old vendor ne vendor redo form
959 ($vendor) = split /--/, $form->{vendor};
960 if ($form->{oldvendor} ne "$vendor--$form->{vendor_id}") {
964 ($debitaccno, $debittaxkey) = split /--/, $form->{AP_amountselected};
965 ($taxkey, $NULL) = split /--/, $form->{taxchartselected};
966 ($payablesaccno, $payablestaxkey) = split /--/, $form->{APselected};
967 $form->{AP}{amount_1} = $debitaccno;
968 $form->{AP}{payables} = $payablesaccno;
969 $form->{taxkey} = $taxkey;
971 $form->{id} = 0 if $form->{postasnew};
973 if (AP->post_transaction(\%myconfig, \%$form)) {
975 if(!exists $form->{addition} && $form->{id} ne "") {
976 $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
977 $form->{addition} = "POSTED";
978 $form->save_history($form->dbconnect(\%myconfig));
980 # /saving the history
981 remove_draft() if $form->{remove_draft};
982 $form->redirect($locale->text('Transaction posted!'));
984 $form->error($locale->text('Cannot post transaction!'));
986 $lxdebug->leave_sub();
990 $lxdebug->enter_sub();
992 $form->{postasnew} = 1;
994 if(!exists $form->{addition} && $form->{id} ne "") {
995 $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
996 $form->{addition} = "POSTED AS NEW";
997 $form->save_history($form->dbconnect(\%myconfig));
999 # /saving the history
1002 $lxdebug->leave_sub();
1005 sub use_as_template {
1006 $lxdebug->enter_sub();
1008 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);
1009 $form->{paidaccounts} = 1;
1010 $form->{rowcount}--;
1011 $form->{invdate} = $form->current_date(\%myconfig);
1014 $lxdebug->leave_sub();
1018 $lxdebug->enter_sub();
1020 $form->{title} = $locale->text('Confirm!');
1024 delete $form->{header};
1029 <form method=post action=$form->{script}>
1032 foreach $key (keys %$form) {
1033 $form->{$key} =~ s/\"/"/g;
1034 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
1038 <h2 class=confirm>$form->{title}</h2>
1041 . $locale->text('Are you sure you want to delete Transaction')
1042 . qq| $form->{invnumber}</h4>
1044 <input name=action class=submit type=submit value="|
1045 . $locale->text('Yes') . qq|">
1052 $lxdebug->leave_sub();
1056 $lxdebug->enter_sub();
1057 if (AP->delete_transaction(\%myconfig, \%$form, $spool)) {
1058 # saving the history
1059 if(!exists $form->{addition}) {
1060 $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
1061 $form->{addition} = "DELETED";
1062 $form->save_history($form->dbconnect(\%myconfig));
1064 # /saving the history
1065 $form->redirect($locale->text('Transaction deleted!'));
1067 $form->error($locale->text('Cannot delete transaction!'));
1069 $lxdebug->leave_sub();
1073 $lxdebug->enter_sub();
1075 # setup vendor selection
1076 $form->all_vc(\%myconfig, "vendor", "AP");
1078 if (@{ $form->{all_vendor} }) {
1079 map { $vendor .= "<option>$_->{name}--$_->{id}\n" }
1080 @{ $form->{all_vendor} };
1081 $vendor = qq|<select name=vendor><option>\n$vendor\n</select>|;
1083 $vendor = qq|<input name=vendor size=35>|;
1087 if (@{ $form->{all_departments} }) {
1088 $form->{selectdepartment} = "<option>\n";
1091 $form->{selectdepartment} .=
1092 "<option>$_->{description}--$_->{id}\n"
1093 } (@{ $form->{all_departments} });
1098 <th align=right nowrap>| . $locale->text('Department') . qq|</th>
1099 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
1101 | if $form->{selectdepartment};
1103 $form->{title} = $locale->text('AP Transactions');
1105 # use JavaScript Calendar or not
1106 $form->{jsscript} = 1;
1108 if ($form->{jsscript}) {
1110 # with JavaScript Calendar
1112 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\">
1113 <input type=button name=transdatefrom id="trigger1" value=|
1114 . $locale->text('button') . qq|></td>
1117 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\">
1118 <input type=button name=transdateto name=transdateto id="trigger2" value=|
1119 . $locale->text('button') . qq|></td>
1124 Form->write_trigger(\%myconfig, "2", "transdatefrom", "BR", "trigger1",
1125 "transdateto", "BL", "trigger2");
1128 # without JavaScript Calendar
1130 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\"></td>|;
1132 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\"></td>|;
1135 $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
1140 foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
1141 push(@values, $item->{"id"});
1142 $labels{$item->{"id"}} = $item->{"projectnumber"};
1145 NTI($cgi->popup_menu('-name' => 'project_id', '-values' => \@values,
1146 '-labels' => \%labels));
1147 $form->{javascript} .= qq|<script type="text/javascript" src="js/common.js"></script>|;
1149 $onload = qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
1150 $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
1152 <body onLoad="$onload">
1154 <form method=post action=$form->{script}>
1158 <th class=listtop>$form->{title}</th>
1160 <tr height="5"></tr>
1165 <th align=right>| . $locale->text('Vendor') . qq|</th>
1166 <td colspan=3>$vendor</td>
1170 <th align=right nowrap>| . $locale->text('Invoice Number') . qq|</th>
1171 <td colspan=3><input name=invnumber size=20></td>
1174 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
1175 <td colspan=3><input name=ordnumber size=20></td>
1178 <th align=right nowrap>| . $locale->text('Notes') . qq|</th>
1179 <td colspan=3><input name=notes size=40></td>
1182 <th align="right">| . $locale->text("Project Number") . qq|</th>
1183 <td colspan="3">$projectnumber</td>
1186 <th align=right nowrap>| . $locale->text('From') . qq|</th>
1188 <th align=right>| . $locale->text('Bis') . qq|</th>
1191 <input type=hidden name=sort value=transdate>
1199 <th align=right nowrap>| . $locale->text('Include in Report') . qq|</th>
1203 <td align=right><input name=open class=checkbox type=checkbox value=Y checked></td>
1204 <td nowrap>| . $locale->text('Open') . qq|</td>
1205 <td align=right><input name=closed class=checkbox type=checkbox value=Y></td>
1206 <td nowrap>| . $locale->text('Closed') . qq|</td>
1209 <td align=right><input name="l_id" class=checkbox type=checkbox value=Y></td>
1210 <td nowrap>| . $locale->text('ID') . qq|</td>
1211 <td align=right><input name="l_invnumber" class=checkbox type=checkbox value=Y checked></td>
1212 <td nowrap>| . $locale->text('Invoice Number') . qq|</td>
1213 <td align=right><input name="l_ordnumber" class=checkbox type=checkbox value=Y></td>
1214 <td nowrap>| . $locale->text('Order Number') . qq|</td>
1217 <td align=right><input name="l_name" class=checkbox type=checkbox value=Y checked></td>
1218 <td nowrap>| . $locale->text('Vendor') . qq|</td>
1219 <td align=right><input name="l_transdate" class=checkbox type=checkbox value=Y checked></td>
1220 <td nowrap>| . $locale->text('Invoice Date') . qq|</td>
1221 <td align=right><input name="l_netamount" class=checkbox type=checkbox value=Y></td>
1222 <td nowrap>| . $locale->text('Amount') . qq|</td>
1225 <td align=right><input name="l_tax" class=checkbox type=checkbox value=Y></td>
1226 <td nowrap>| . $locale->text('Tax') . qq|</td>
1227 <td align=right><input name="l_amount" class=checkbox type=checkbox value=Y checked></td>
1228 <td nowrap>| . $locale->text('Total') . qq|</td>
1229 <td align=right><input name="l_datepaid" class=checkbox type=checkbox value=Y></td>
1230 <td nowrap>| . $locale->text('Date Paid') . qq|</td>
1233 <td align=right><input name="l_paid" class=checkbox type=checkbox value=Y checked></td>
1234 <td nowrap>| . $locale->text('Paid') . qq|</td>
1235 <td align=right><input name="l_duedate" class=checkbox type=checkbox value=Y></td>
1236 <td nowrap>| . $locale->text('Due Date') . qq|</td>
1237 <td align=right><input name="l_due" class=checkbox type=checkbox value=Y></td>
1238 <td nowrap>| . $locale->text('Amount Due') . qq|</td>
1241 <td align=right><input name="l_notes" class=checkbox type=checkbox value=Y></td>
1242 <td nowrap>| . $locale->text('Notes') . qq|</td>
1243 <td align=right><input name="l_employee" class=checkbox type=checkbox value=Y></td>
1244 <td nowrap>| . $locale->text('Employee') . qq|</td>
1247 <td align=right><input name="l_subtotal" class=checkbox type=checkbox value=Y></td>
1248 <td nowrap>| . $locale->text('Subtotal') . qq|</td>
1249 <td align=right><input name="l_globalprojectnumber" class=checkbox type=checkbox value=Y></td>
1250 <td nowrap>| . $locale->text('Project Number') . qq|</td>
1259 <td><hr size=3 noshade></td>
1266 <input type=hidden name=nextsub value=$form->{nextsub}>
1267 <input type=hidden name=login value=$form->{login}>
1268 <input type=hidden name=password value=$form->{password}>
1270 <input class=submit type=submit name=action value="|
1271 . $locale->text('Continue') . qq|">
1278 $lxdebug->leave_sub();
1281 sub ap_transactions {
1282 $lxdebug->enter_sub();
1284 $form->{vendor} = $form->unescape($form->{vendor});
1285 ($form->{vendor}, $form->{vendor_id}) = split(/--/, $form->{vendor});
1287 AP->ap_transactions(\%myconfig, \%$form);
1290 "$form->{script}?action=ap_transactions&login=$form->{login}&password=$form->{password}";
1293 if ($form->{vendor}) {
1294 $callback .= "&vendor=" . $form->escape($form->{vendor}, 1);
1295 $href .= "&vendor=" . $form->escape($form->{vendor});
1296 $option .= $locale->text('Vendor') . " : $form->{vendor}";
1298 if ($form->{department}) {
1299 $callback .= "&department=" . $form->escape($form->{department}, 1);
1300 $href .= "&department=" . $form->escape($form->{department});
1301 ($department) = split /--/, $form->{department};
1302 $option .= "\n<br>" if ($option);
1303 $option .= $locale->text('Department') . " : $department";
1305 if ($form->{invnumber}) {
1306 $callback .= "&invnumber=" . $form->escape($form->{invnumber}, 1);
1307 $href .= "&invnumber=" . $form->escape($form->{invnumber});
1308 $option .= "\n<br>" if ($option);
1309 $option .= $locale->text('Invoice Number') . " : $form->{invnumber}";
1311 if ($form->{ordnumber}) {
1312 $callback .= "&ordnumber=" . $form->escape($form->{ordnumber}, 1);
1313 $href .= "&ordnumber=" . $form->escape($form->{ordnumber});
1314 $option .= "\n<br>" if ($option);
1315 $option .= $locale->text('Order Number') . " : $form->{ordnumber}";
1317 if ($form->{notes}) {
1318 $callback .= "¬es=" . $form->escape($form->{notes}, 1);
1319 $href .= "¬es=" . $form->escape($form->{notes});
1320 $option .= "\n<br>" if $option;
1321 $option .= $locale->text('Notes') . " : $form->{notes}";
1324 if ($form->{transdatefrom}) {
1325 $callback .= "&transdatefrom=$form->{transdatefrom}";
1326 $href .= "&transdatefrom=$form->{transdatefrom}";
1327 $option .= "\n<br>" if ($option);
1329 $locale->text('From') . " "
1330 . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
1332 if ($form->{transdateto}) {
1333 $callback .= "&transdateto=$form->{transdateto}";
1334 $href .= "&transdateto=$form->{transdateto}";
1335 $option .= "\n<br>" if ($option);
1337 $locale->text('Bis') . " "
1338 . $locale->date(\%myconfig, $form->{transdateto}, 1);
1340 if ($form->{open}) {
1341 $callback .= "&open=$form->{open}";
1342 $href .= "&open=$form->{open}";
1343 $option .= "\n<br>" if ($option);
1344 $option .= $locale->text('Open');
1346 if ($form->{closed}) {
1347 $callback .= "&closed=$form->{closed}";
1348 $href .= "&closed=$form->{closed}";
1349 $option .= "\n<br>" if ($option);
1350 $option .= $locale->text('Closed');
1352 if ($form->{globalproject_id}) {
1353 $callback .= "&globalproject_id=" . E($form->{globalproject_id});
1354 $href .= "&globalproject_id=" . E($form->{globalproject_id});
1358 qw(transdate id type invnumber ordnumber name netamount tax amount paid datepaid
1359 due duedate notes employee globalprojectnumber);
1361 $form->{"l_type"} = "Y";
1363 foreach $item (@columns) {
1364 if ($form->{"l_$item"} eq "Y") {
1365 push @column_index, $item;
1367 # add column to href and callback
1368 $callback .= "&l_$item=Y";
1369 $href .= "&l_$item=Y";
1373 if ($form->{l_subtotal} eq 'Y') {
1374 $callback .= "&l_subtotal=Y";
1375 $href .= "&l_subtotal=Y";
1378 $column_header{id} =
1379 qq|<th><a class=listheading href=$href&sort=id>|
1380 . $locale->text('ID')
1382 $column_header{transdate} =
1383 qq|<th><a class=listheading href=$href&sort=transdate>|
1384 . $locale->text('Date')
1386 $column_header{type} =
1387 "<th class=\"listheading\">" . $locale->text('Type') . "</th>";
1388 $column_header{duedate} =
1389 qq|<th><a class=listheading href=$href&sort=duedate>|
1390 . $locale->text('Due Date')
1392 $column_header{due} =
1393 qq|<th class=listheading>| . $locale->text('Amount Due') . qq|</th>|;
1394 $column_header{invnumber} =
1395 qq|<th><a class=listheading href=$href&sort=invnumber>|
1396 . $locale->text('Invoice')
1398 $column_header{ordnumber} =
1399 qq|<th><a class=listheading href=$href&sort=ordnumber>|
1400 . $locale->text('Order')
1402 $column_header{name} =
1403 qq|<th><a class=listheading href=$href&sort=name>|
1404 . $locale->text('Vendor')
1406 $column_header{netamount} =
1407 qq|<th class=listheading>| . $locale->text('Amount') . qq|</th>|;
1408 $column_header{tax} =
1409 qq|<th class=listheading>| . $locale->text('Tax') . qq|</th>|;
1410 $column_header{amount} =
1411 qq|<th class=listheading>| . $locale->text('Total') . qq|</th>|;
1412 $column_header{paid} =
1413 qq|<th class=listheading>| . $locale->text('Paid') . qq|</th>|;
1414 $column_header{datepaid} =
1415 qq|<th><a class=listheading href=$href&sort=datepaid>|
1416 . $locale->text('Date Paid')
1418 $column_header{notes} =
1419 qq|<th class=listheading>| . $locale->text('Notes') . qq|</th>|;
1420 $column_header{employee} =
1421 "<th><a class=listheading href=$href&sort=employee>"
1422 . $locale->text('Employee') . "</th>";
1423 $column_header{globalprojectnumber} =
1424 qq|<th class="listheading">| . $locale->text('Project Number') . qq|</th>|;
1426 $form->{title} = $locale->text('AP Transactions');
1435 <th class=listtop>$form->{title}</th>
1437 <tr height="5"></tr>
1444 <tr class=listheading>
1447 map { print "\n$column_header{$_}" } @column_index;
1453 # add sort and escape callback
1454 $form->{callback} = "$callback&sort=$form->{sort}";
1455 $callback = $form->escape($form->{callback});
1457 if (@{ $form->{AP} }) {
1458 $sameitem = $form->{AP}->[0]->{ $form->{sort} };
1461 # sums and tax on reports by Antonio Gallardo
1463 foreach $ap (@{ $form->{AP} }) {
1465 if ($form->{l_subtotal} eq 'Y') {
1466 if ($sameitem ne $ap->{ $form->{sort} }) {
1468 $sameitem = $ap->{ $form->{sort} };
1472 $column_data{netamount} =
1474 . $form->format_amount(\%myconfig, $ap->{netamount}, 2, " ")
1476 $column_data{tax} = "<td align=right>"
1477 . $form->format_amount(\%myconfig, $ap->{amount} - $ap->{netamount},
1480 $column_data{amount} =
1482 . $form->format_amount(\%myconfig, $ap->{amount}, 2, " ") . "</td>";
1483 $column_data{paid} =
1485 . $form->format_amount(\%myconfig, $ap->{paid}, 2, " ") . "</td>";
1486 $column_data{due} = "<td align=right>"
1487 . $form->format_amount(\%myconfig, $ap->{amount} - $ap->{paid},
1491 $totalnetamount += $ap->{netamount};
1492 $totalamount += $ap->{amount};
1493 $totalpaid += $ap->{paid};
1494 $totaldue += ($ap->{amount} - $ap->{paid});
1496 $subtotalnetamount += $ap->{netamount};
1497 $subtotalamount += $ap->{amount};
1498 $subtotalpaid += $ap->{paid};
1499 $subtotaldue += ($ap->{amount} - $ap->{paid});
1501 $column_data{transdate} = "<td>$ap->{transdate} </td>";
1502 $column_data{type} = "<td>" .
1503 ($ap->{invoice} ? $locale->text("Invoice (one letter abbreviation)") :
1504 $locale->text("AP Transaction (abbreviation)"))
1506 $column_data{duedate} = "<td>$ap->{duedate} </td>";
1507 $column_data{datepaid} = "<td>$ap->{datepaid} </td>";
1509 $module = ($ap->{invoice}) ? "ir.pl" : $form->{script};
1511 $column_data{invnumber} =
1512 qq|<td><a href="$module?action=edit&id=$ap->{id}&login=$form->{login}&password=$form->{password}&callback=$callback">$ap->{invnumber}</a></td>|;
1513 $column_data{id} = "<td>$ap->{id}</td>";
1514 $column_data{ordnumber} = "<td>$ap->{ordnumber} </td>";
1515 $column_data{name} = "<td>$ap->{name}</td>";
1516 $ap->{notes} =~ s/\r\n/<br>/g;
1517 $column_data{notes} = "<td>$ap->{notes} </td>";
1518 $column_data{employee} = "<td>$ap->{employee} </td>";
1519 $column_data{globalprojectnumber} =
1520 "<td>" . H($ap->{globalprojectnumber}) . "</td>";
1525 <tr class=listrow$i >
1528 map { print "\n$column_data{$_}" } @column_index;
1536 if ($form->{l_subtotal} eq 'Y') {
1542 <tr class=listtotal>
1545 map { $column_data{$_} = "<td> </td>" } @column_index;
1547 $column_data{netamount} =
1548 "<th class=listtotal align=right>"
1549 . $form->format_amount(\%myconfig, $totalnetamount, 2, " ") . "</th>";
1550 $column_data{tax} = "<th class=listtotal align=right>"
1551 . $form->format_amount(\%myconfig, $totalamount - $totalnetamount,
1554 $column_data{amount} =
1555 "<th class=listtotal align=right>"
1556 . $form->format_amount(\%myconfig, $totalamount, 2, " ") . "</th>";
1557 $column_data{paid} =
1558 "<th class=listtotal align=right>"
1559 . $form->format_amount(\%myconfig, $totalpaid, 2, " ") . "</th>";
1561 "<th class=listtotal align=right>"
1562 . $form->format_amount(\%myconfig, $totaldue, 2, " ") . "</th>";
1564 map { print "$column_data{$_}\n" } @column_index;
1572 <td><hr size=3 noshade></td>
1577 <form method=post action=$form->{script}>
1579 <input name=callback type=hidden value="$form->{callback}">
1581 <input type=hidden name=login value=$form->{login}>
1582 <input type=hidden name=password value=$form->{password}>
1584 <input class=submit type=submit name=action value="|
1585 . $locale->text('AP Transaction') . qq|">
1587 <input class=submit type=submit name=action value="|
1588 . $locale->text('Vendor Invoice') . qq|">
1596 $lxdebug->leave_sub();
1600 $lxdebug->enter_sub();
1602 map { $column_data{$_} = "<td> </td>" } @column_index;
1604 $column_data{netamount} =
1605 "<th class=listsubtotal align=right>"
1606 . $form->format_amount(\%myconfig, $subtotalnetamount, 2, " ")
1608 $column_data{tax} = "<th class=listsubtotal align=right>"
1609 . $form->format_amount(\%myconfig, $subtotalamount - $subtotalnetamount,
1612 $column_data{amount} =
1613 "<th class=listsubtotal align=right>"
1614 . $form->format_amount(\%myconfig, $subtotalamount, 2, " ") . "</th>";
1615 $column_data{paid} =
1616 "<th class=listsubtotal align=right>"
1617 . $form->format_amount(\%myconfig, $subtotalpaid, 2, " ") . "</th>";
1619 "<th class=listsubtotal align=right>"
1620 . $form->format_amount(\%myconfig, $subtotaldue, 2, " ") . "</th>";
1622 $subtotalnetamount = 0;
1623 $subtotalamount = 0;
1627 print "<tr class=listsubtotal>";
1629 map { print "\n$column_data{$_}" } @column_index;
1635 $lxdebug->leave_sub();
1639 $lxdebug->enter_sub();
1641 if (IS->has_storno(\%myconfig, $form, 'ap')) {
1642 $form->{title} = $locale->text("Cancel Accounts Payables Transaction");
1643 $form->error($locale->text("Transaction has already been cancelled!"));
1646 # negate amount/taxes
1647 for my $i (1 .. $form->{rowcount}) {
1648 $form->{"amount_$i"} *= -1;
1649 $form->{"tax_$i"} *= -1;
1653 for my $i (1 .. $form->{rowcount}) {
1654 for (qw(amount tax)) {
1655 $form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}, 2) if $form->{"${_}_$i"};
1659 $form->{storno} = 1;
1660 $form->{storno_id} = $form->{id};
1663 $form->{invnumber} = "Storno-" . $form->{invnumber};
1667 # saving the history
1668 if(!exists $form->{addition} && $form->{id} ne "") {
1669 $form->{snumbers} = "ordnumber_$form->{ordnumber}";
1670 $form->{addition} = "STORNO";
1671 $form->save_history($form->dbconnect(\%myconfig));
1673 # /saving the history
1675 $lxdebug->leave_sub();