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 #======================================================================
34 use POSIX qw(strftime);
40 use SL::ReportGenerator;
42 require "bin/mozilla/arap.pl";
43 require "bin/mozilla/common.pl";
44 require "bin/mozilla/drafts.pl";
45 require "bin/mozilla/reportgenerator.pl";
51 # this is for our long dates
52 # $locale->text('January')
53 # $locale->text('February')
54 # $locale->text('March')
55 # $locale->text('April')
56 # $locale->text('May ')
57 # $locale->text('June')
58 # $locale->text('July')
59 # $locale->text('August')
60 # $locale->text('September')
61 # $locale->text('October')
62 # $locale->text('November')
63 # $locale->text('December')
65 # this is for our short month
66 # $locale->text('Jan')
67 # $locale->text('Feb')
68 # $locale->text('Mar')
69 # $locale->text('Apr')
70 # $locale->text('May')
71 # $locale->text('Jun')
72 # $locale->text('Jul')
73 # $locale->text('Aug')
74 # $locale->text('Sep')
75 # $locale->text('Oct')
76 # $locale->text('Nov')
77 # $locale->text('Dec')
80 $lxdebug->enter_sub();
82 $auth->assert('general_ledger');
84 return $lxdebug->leave_sub() if (load_draft_maybe());
86 $form->{title} = "Add";
88 $form->{callback} = "ap.pl?action=add" unless $form->{callback};
90 AP->get_transdate(\%myconfig, $form);
91 $form->{initial_transdate} = $form->{transdate};
93 $form->{transdate} = $form->{initial_transdate};
96 $lxdebug->leave_sub();
100 $lxdebug->enter_sub();
102 $auth->assert('general_ledger');
104 $form->{title} = "Edit";
109 $lxdebug->leave_sub();
113 $lxdebug->enter_sub();
115 $auth->assert('general_ledger');
120 $lxdebug->leave_sub();
124 $lxdebug->enter_sub();
126 $auth->assert('general_ledger');
128 $form->create_links("AP", \%myconfig, "vendor");
129 $taxincluded = $form->{taxincluded};
130 $duedate = $form->{duedate};
132 IR->get_vendor(\%myconfig, \%$form);
133 $form->{taxincluded} = $taxincluded;
134 $form->{duedate} = $duedate if $duedate;
135 $form->{oldvendor} = "$form->{vendor}--$form->{vendor_id}";
136 $form->{rowcount} = 1;
138 # build the popup menus
139 $form->{taxincluded} = ($form->{id}) ? $form->{taxincluded} : "checked";
142 $form->{notes} = $form->{intnotes} unless $form->{notes};
145 @curr = split(/:/, $form->{currencies});
147 $form->{defaultcurrency} = $curr[0];
149 map { $form->{selectcurrency} .= "<option>$_\n" } @curr;
152 if (@{ $form->{all_vendor} }) {
153 $form->{vendor} = qq|$form->{vendor}--$form->{vendor_id}|;
154 map { $form->{selectvendor} .= "<option>$_->{name}--$_->{id}\n" }
155 (@{ $form->{all_vendor} });
159 if (@{ $form->{all_departments} }) {
160 $form->{selectdepartment} = "<option>\n";
161 $form->{department} = "$form->{department}--$form->{department_id}";
164 $form->{selectdepartment} .=
165 "<option>$_->{description}--$_->{id}\n"
166 } (@{ $form->{all_departments} });
169 $form->{employee} = "$form->{employee}--$form->{employee_id}";
171 AP->setup_form($form);
174 ($form->datetonum($form->{transdate}, \%myconfig) <=
175 $form->datetonum($form->{closedto}, \%myconfig));
177 $lxdebug->leave_sub();
181 $lxdebug->enter_sub();
183 $auth->assert('general_ledger');
185 $title = $form->{title};
186 $form->{title} = $locale->text("$title Accounts Payables Transaction");
188 $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
190 # type=submit $locale->text('Add Accounts Payables Transaction')
191 # type=submit $locale->text('Edit Accounts Payables Transaction')
193 $form->{javascript} = qq|<script type="text/javascript">
195 function setTaxkey(accno, row) {
196 var taxkey = accno.options[accno.selectedIndex].value;
197 var reg = /--([0-9]*)/;
198 var found = reg.exec(taxkey);
199 var index = found[1];
200 index = parseInt(index);
201 var tax = 'taxchart_' + row;
202 for (var i = 0; i < document.getElementById(tax).options.length; ++i) {
203 var reg2 = new RegExp("^"+ index, "");
204 if (reg2.exec(document.getElementById(tax).options[i].value)) {
205 document.getElementById(tax).options[i].selected = true;
212 # show history button
213 $form->{javascript} .= qq|<script type="text/javascript" src="js/show_history.js"></script>|;
214 #/show hhistory button
216 # set option selected
217 foreach $item (qw(vendor currency department)) {
218 $form->{"select$item"} =~ s/ selected//;
219 $form->{"select$item"} =~
220 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
222 $readonly = ($form->{id}) ? "readonly" : "";
225 ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0;
226 $readonly = ($form->{radier}) ? "" : $readonly;
228 $form->{exchangerate} = $exchangerate
232 $form->check_exchangerate(
233 \%myconfig, $form->{currency}, $form->{transdate}, 'sell'
238 $form->{exchangerate} =
239 $form->format_amount(\%myconfig, $form->{exchangerate});
240 if ($form->{exchangerate} == 0) {
241 $form->{exchangerate} = "";
243 $form->{creditlimit} =
244 $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
245 $form->{creditremaining} =
246 $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
249 <input type=hidden name=forex value=$form->{forex}>
251 if ($form->{currency} ne $form->{defaultcurrency}) {
252 if ($form->{forex}) {
255 <th align=right>| . $locale->text('Exchangerate') . qq|</th>
256 <td><input type=hidden name=exchangerate value=$form->{exchangerate}>$form->{exchangerate}</td>
261 <th align=right>| . $locale->text('Exchangerate') . qq|</th>
262 <td><input name=exchangerate size=10 value=$form->{exchangerate}></td>
271 <td align=right><input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}></td>
272 <th align=left nowrap>|
273 . $locale->text('Tax Included') . qq|</th>
277 if (($rows = $form->numtextrows($form->{notes}, 50)) < 2) {
281 qq|<textarea name=notes rows=$rows cols=50 wrap=soft $readonly>$form->{notes}</textarea>|;
285 <th align="right" nowrap>| . $locale->text('Department') . qq|</th>
286 <td colspan=3><select name=department>$form->{selectdepartment}</select>
287 <input type=hidden name=selectdepartment value="$form->{selectdepartment}">
290 | if $form->{selectdepartment};
292 $n = ($form->{creditremaining} =~ /-/) ? "0" : "1";
295 ($form->{selectvendor})
296 ? qq|<select name="vendor"
297 onchange="document.getElementById('update_button').click();">$form->{
298 selectvendor } </select>|
299 : qq|<input name=vendor value="$form->{vendor}" size=35>|;
301 my @old_project_ids = ();
302 map({ push(@old_project_ids, $form->{"project_id_$_"})
303 if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
305 $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
307 "old_id" => \@old_project_ids },
308 "charts" => { "key" => "ALL_CHARTS",
309 "transdate" => $form->{transdate} },
310 "taxcharts" => "ALL_TAXCHARTS");
312 map({ $_->{link_split} = [ split(/:/, $_->{link}) ]; }
313 @{ $form->{ALL_CHARTS} });
315 my %project_labels = ();
316 my @project_values = ("");
317 foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
318 push(@project_values, $item->{"id"});
319 $project_labels{$item->{"id"}} = $item->{"projectnumber"};
322 my (%AP_amount_labels, @AP_amount_values);
323 my (%AP_labels, @AP_values);
324 my (%AP_paid_labels, @AP_paid_values);
328 foreach my $item (@{ $form->{ALL_CHARTS} }) {
329 if (grep({ $_ eq "AP_amount" } @{ $item->{link_split} })) {
330 $taxchart_init = $item->{tax_id} if ($taxchart_init eq "");
331 my $key = "$item->{accno}--$item->{tax_id}";
332 push(@AP_amount_values, $key);
333 $AP_amount_labels{$key} =
334 "$item->{accno}--$item->{description}";
336 } elsif (grep({ $_ eq "AP" } @{ $item->{link_split} })) {
337 push(@AP_values, $item->{accno});
338 $AP_labels{$item->{accno}} = "$item->{accno}--$item->{description}";
340 } elsif (grep({ $_ eq "AP_paid" } @{ $item->{link_split} })) {
341 push(@AP_paid_values, $item->{accno});
342 $AP_paid_labels{$item->{accno}} =
343 "$item->{accno}--$item->{description}";
346 $charts{$item->{accno}} = $item;
349 my %taxchart_labels = ();
350 my @taxchart_values = ();
352 foreach my $item (@{ $form->{ALL_TAXCHARTS} }) {
353 my $key = "$item->{id}--$item->{rate}";
354 $taxchart_init = $key if ($taxchart_init eq $item->{id});
355 push(@taxchart_values, $key);
356 $taxchart_labels{$key} =
357 "$item->{taxdescription} " . ($item->{rate} * 100) . ' %';
358 $taxcharts{$item->{id}} = $item;
361 # use JavaScript Calendar or not
362 $form->{jsscript} = 1;
364 if ($form->{jsscript}) {
366 # with JavaScript Calendar
368 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value="$form->{transdate}" onBlur=\"check_right_date_format(this)\"> $readonly</td>
369 <td><input type=button name=transdate id="trigger1" value=|
370 . $locale->text('button') . qq|></td>
373 <td><input name=duedate id=duedate size=11 title="$myconfig{dateformat}" value="$form->{duedate}" onBlur=\"check_right_date_format(this)\"> $readonly</td>
374 <td><input type=button name=duedate id="trigger2" value=|
375 . $locale->text('button') . qq|></td></td>
380 Form->write_trigger(\%myconfig, "2", "transdate", "BL", "trigger1",
381 "duedate", "BL", "trigger2");
384 # without JavaScript Calendar
386 qq|<td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value="$form->{transdate}" onBlur=\"check_right_date_format(this)\"> $readonly</td>|;
388 qq|<td><input name=duedate id=duedate size=11 title="$myconfig{dateformat}" value="$form->{duedate}" onBlur=\"check_right_date_format(this)\"> $readonly</td>|;
390 $form->{javascript} .= qq|<script type="text/javascript" src="js/common.js"></script>|;
391 $form->{javascript} .= qq|<script type="text/javascript" src="js/show_vc_details.js"></script>|;
394 $onload = qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
395 $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
397 <body onLoad="$onload">
399 <form method=post action=$form->{script}>
401 <input type=hidden name=id value=$form->{id}>
402 <input type=hidden name=sort value=$form->{sort}>
403 <input type=hidden name=closedto value=$form->{closedto}>
404 <input type=hidden name=locked value=$form->{locked}>
405 <input type=hidden name=title value="$title">
407 | . ($form->{saved_message} ? qq|<p>$form->{saved_message}</p>| : "") . qq|
411 <th class=listtop>$form->{title}</th>
421 <th align=right nowrap>| . $locale->text('Vendor') . qq|</th>
422 <td colspan=3>$vendor <input type="button" value="?" onclick="show_vc_details('vendor')"></td>
423 <input type=hidden name=selectvendor value="$form->{selectvendor}">
424 <input type=hidden name=oldvendor value="$form->{oldvendor}">
425 <input type=hidden name=vendor_id value="$form->{vendor_id}">
426 <input type=hidden name=terms value=$form->{terms}>
433 <th align=left nowrap>| . $locale->text('Credit Limit') . qq|</th>
434 <td>$form->{creditlimit}</td>
435 <th align=left nowrap>| . $locale->text('Remaining') . qq|</th>
436 <td class="plus$n">$form->{creditremaining}</td>
437 <input type=hidden name=creditlimit value=$form->{creditlimit}>
438 <input type=hidden name=creditremaining value=$form->{creditremaining}>
443 <th align=right nowrap>| . $locale->text('Currency') . qq|</th>
444 <td><select name=currency>$form->{selectcurrency}</select></td>
445 <input type=hidden name=selectcurrency value="$form->{selectcurrency}">
446 <input type=hidden name=defaultcurrency value=$form->{defaultcurrency}>
447 <input type=hidden name=fxgain_accno value=$form->{fxgain_accno}>
448 <input type=hidden name=fxloss_accno value=$form->{fxloss_accno}>
458 <th align=right nowrap>| . $locale->text('Invoice Number') . qq|</th>
459 <td><input name=invnumber size=11 value="$form->{invnumber}" $readonly></td>
462 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
463 <td><input name=ordnumber size=11 value="$form->{ordnumber}" $readonly></td>
466 <th align=right nowrap>| . $locale->text('Invoice Date') . qq|</th>
470 <th align=right nowrap>| . $locale->text('Due Date') . qq|</th>
483 <input type=hidden name=rowcount value=$form->{rowcount}>
487 <tr class=listheading>
488 <th class=listheading style="width:15%">|
489 . $locale->text('Account') . qq|</th>
490 <th class=listheading style="width:10%">|
491 . $locale->text('Amount') . qq|</th>
492 <th class=listheading style="width:10%">|
493 . $locale->text('Tax') . qq|</th>
494 <th class=listheading style="width:5%">|
495 . $locale->text('Korrektur') . qq|</th>
496 <th class=listheading style="width:10%">|
497 . $locale->text('Taxkey') . qq|</th>
498 <th class=listheading style="width:10%">|
499 . $locale->text('Project') . qq|</th>
503 $amount = $locale->text('Amount');
504 $project = $locale->text('Project');
506 for $i (1 .. $form->{rowcount}) {
509 $form->{"amount_$i"} =
510 $form->format_amount(\%myconfig, $form->{"amount_$i"}, 2);
511 $form->{"tax_$i"} = $form->format_amount(\%myconfig, $form->{"tax_$i"}, 2);
513 my $selected_accno_full;
514 my ($accno_row) = split(/--/, $form->{"AP_amount_$i"});
515 my $item = $charts{$accno_row};
516 $selected_accno_full = "$item->{accno}--$item->{tax_id}";
518 my $selected_taxchart = $form->{"taxchart_$i"};
519 my ($selected_accno, $selected_tax_id) = split(/--/, $selected_accno_full);
520 my ($previous_accno, $previous_tax_id) = split(/--/, $form->{"previous_AP_amount_$i"});
522 if ($previous_accno &&
523 ($previous_accno eq $selected_accno) &&
524 ($previous_tax_id ne $selected_tax_id)) {
525 my $item = $taxcharts{$selected_tax_id};
526 $selected_taxchart = "$item->{id}--$item->{rate}";
529 $selected_taxchart = $taxchart_init unless ($form->{"taxchart_$i"});
532 NTI($cgi->popup_menu('-name' => "AP_amount_$i",
533 '-id' => "AP_amount_$i",
534 '-style' => 'width:400px',
535 '-onChange' => "setTaxkey(this, $i)",
536 '-values' => \@AP_amount_values,
537 '-labels' => \%AP_amount_labels,
538 '-default' => $selected_accno_full))
539 . $cgi->hidden('-name' => "previous_AP_amount_$i",
540 '-default' => $selected_accno_full);
543 NTI($cgi->popup_menu('-name' => "taxchart_$i",
544 '-id' => "taxchart_$i",
545 '-style' => 'width:200px',
546 '-values' => \@taxchart_values,
547 '-labels' => \%taxchart_labels,
548 '-default' => $selected_taxchart))
551 my $korrektur = $form->{"korrektur_$i"} ? 'checked' : '';
554 NTI($cgi->popup_menu('-name' => "project_id_$i",
555 '-values' => \@project_values,
556 '-labels' => \%project_labels,
557 '-default' => $form->{"project_id_$i"} ));
561 <td>$selectAP_amount</td>
562 <td><input name="amount_$i" size=10 value=$form->{"amount_$i"}></td>
563 <td><input name="tax_$i" size=10 value=$form->{"tax_$i"}></td>
564 <td><input type="checkbox" name="korrektur_$i" value="1" "$korrektur"></td>
566 <td>$projectnumber</td>
574 ($form->{taxincluded})
575 ? $locale->text('Tax Included')
576 : $locale->text('Tax');
578 $form->{invtotal_unformatted} = $form->{invtotal};
579 $form->{invtotal} = $form->format_amount(\%myconfig, $form->{invtotal}, 2);
582 NTI($cgi->popup_menu('-name' => "APselected", '-id' => "APselected",
583 '-style' => 'width:400px',
584 '-values' => \@AP_values, '-labels' => \%AP_labels,
585 '-default' => $form->{APselected}));
593 <td>${APselected}</td>
594 <th align=left>$form->{invtotal}</th>
596 <input type=hidden name=oldinvtotal value=$form->{oldinvtotal}>
597 <input type=hidden name=oldtotalpaid value=$form->{oldtotalpaid}>
599 <input type=hidden name=taxaccounts value="$form->{taxaccounts}">
612 <th align=left width=1%>| . $locale->text('Notes') . qq|</th>
613 <td align=left>$notes</td>
621 <tr class=listheading>
622 <th class=listheading colspan=7>| . $locale->text('Payments') . qq|</th>
626 if ($form->{currency} eq $form->{defaultcurrency}) {
627 @column_index = qw(datepaid source memo paid AP_paid paid_project_id);
629 @column_index = qw(datepaid source memo paid exchangerate AP_paid paid_project_id);
632 $column_data{datepaid} = "<th>" . $locale->text('Date') . "</th>";
633 $column_data{paid} = "<th>" . $locale->text('Amount') . "</th>";
634 $column_data{exchangerate} = "<th>" . $locale->text('Exch') . "</th>";
635 $column_data{AP_paid} = "<th>" . $locale->text('Account') . "</th>";
636 $column_data{source} = "<th>" . $locale->text('Source') . "</th>";
637 $column_data{memo} = "<th>" . $locale->text('Memo') . "</th>";
638 $column_data{paid_project_id} = "<th>" . $locale->text('Project Number') . "</th>";
643 map { print "$column_data{$_}\n" } @column_index;
651 $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
652 for $i (1 .. $form->{paidaccounts}) {
658 NTI($cgi->popup_menu('-name' => "AP_paid_$i",
659 '-id' => "AP_paid_$i",
660 '-values' => \@AP_paid_values,
661 '-labels' => \%AP_paid_labels,
662 '-default' => $form->{"AP_paid_$i"}));
664 $totalpaid += $form->{"paid_$i"};
667 if ($form->{"paid_$i"}) {
669 $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2);
671 $form->{"exchangerate_$i"} =
672 $form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
673 if ($form->{"exchangerate_$i"} == 0) {
674 $form->{"exchangerate_$i"} = "";
677 $exchangerate = qq| |;
678 if ($form->{currency} ne $form->{defaultcurrency}) {
679 if ($form->{"forex_$i"}) {
681 qq|<input type=hidden name="exchangerate_$i" value=$form->{"exchangerate_$i"}>$form->{"exchangerate_$i"}|;
684 qq|<input name="exchangerate_$i" size=10 value=$form->{"exchangerate_$i"}>|;
689 <input type=hidden name="forex_$i" value=$form->{"forex_$i"}>
692 $column_data{"paid_$i"} =
693 qq|<td align=center><input name="paid_$i" size=11 value="$form->{"paid_$i"}" onBlur=\"check_right_number_format(this)\"></td>|;
694 $column_data{"AP_paid_$i"} =
695 qq|<td align=center>${selectAP_paid}</td>|;
696 $column_data{"exchangerate_$i"} = qq|<td align=center>$exchangerate</td>|;
697 $column_data{"datepaid_$i"} =
698 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)\">
699 <input type="button" name="datepaid_$i" id="trigger_datepaid_$i" value="?"></td>|;
700 $column_data{"source_$i"} =
701 qq|<td align=center><input name="source_$i" size=11 value="$form->{"source_$i"}"></td>|;
702 $column_data{"memo_$i"} =
703 qq|<td align=center><input name="memo_$i" size=11 value="$form->{"memo_$i"}"></td>|;
704 $column_data{"paid_project_id_$i"} =
706 . NTI($cgi->popup_menu('-name' => "paid_project_id_$i",
707 '-values' => \@project_values,
708 '-labels' => \%project_labels,
709 '-default' => $form->{"paid_project_id_$i"} ))
712 map { print qq|$column_data{"${_}_$i"}\n| } @column_index;
717 push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i");
720 my $paid_missing = $form->{invtotal_unformatted} - $totalpaid;
726 <td align="center">| . $locale->text('Total') . qq|</td>
727 <td align="center">| . H($form->format_amount(\%myconfig, $totalpaid, 2)) . qq|</td>
732 <td align="center">| . $locale->text('Missing amount') . qq|</td>
733 <td align="center">| . H($form->format_amount(\%myconfig, $paid_missing, 2)) . qq|</td>
735 | . $form->write_trigger(\%myconfig, scalar(@triggers) / 3, @triggers) .
737 <input type=hidden name=paidaccounts value=$form->{paidaccounts}>
743 <td><hr size=3 noshade></td>
748 $lxdebug->leave_sub();
752 $lxdebug->enter_sub();
754 $auth->assert('general_ledger');
758 <input name=callback type=hidden value="$form->{callback}">
759 <input name="gldate" type="hidden" value="| . Q($form->{gldate}) . qq|">
761 . $cgi->hidden('-name' => 'draft_id', '-default' => [$form->{draft_id}])
762 . $cgi->hidden('-name' => 'draft_description', '-default' => [$form->{draft_description}])
768 if (!$form->{id} && $form->{draft_id}) {
769 print(NTI($cgi->checkbox('-name' => 'remove_draft', '-id' => 'remove_draft',
770 '-value' => 1, '-checked' => $form->{remove_draft},
772 qq| <label for="remove_draft">| .
773 $locale->text("Remove draft when posting") .
777 $transdate = $form->datetonum($form->{transdate}, \%myconfig);
778 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
780 print qq|<input class="submit" type="submit" name="action" id="update_button" value="| . $locale->text('Update') . qq|">|;
783 if ($form->{radier}) {
784 print qq| <input class=submit type=submit name=action value="| . $locale->text('Post') . qq|">
785 <input class=submit type=submit name=action value="| . $locale->text('Delete') . qq|">
789 # ToDO: - insert a global check for stornos, so that a storno is only possible a limited time after saving it
790 print qq| <input class=submit type=submit name=action value="| . $locale->text('Storno') . qq|"> |
791 if ($form->{id} && !IS->has_storno(\%myconfig, $form, 'ap') && !IS->is_storno(\%myconfig, $form, 'ap', $form->{id}));
793 print qq| <input class=submit type=submit name=action value="| . $locale->text('Post Payment') . qq|">
794 <input class=submit type=submit name=action value="| . $locale->text('Use As Template') . qq|">
796 } elsif (($transdate > $closedto) && !$form->{id}) {
798 <input class=submit type=submit name=action value="| . $locale->text('Post') . qq|"> | .
799 NTI($cgi->submit('-name' => 'action', '-value' => $locale->text('Save draft'), '-class' => 'submit'));
801 # button for saving history
802 if($form->{id} ne "") {
803 print qq| <input type="button" class="submit" onclick="set_history_window($form->{id});" name="history" id="history" value="| . $locale->text('history') . qq|"> |;
805 # /button for saving history
806 # mark_as_paid button
807 if($form->{id} ne "") {
808 print qq| <input type="submit" class="submit" name="action" value="| . $locale->text('mark as paid') . qq|"> |;
810 # /mark_as_paid button
818 $lxdebug->leave_sub();
822 $lxdebug->enter_sub();
824 $auth->assert('general_ledger');
826 &mark_as_paid_common(\%myconfig,"ap");
828 $lxdebug->leave_sub();
832 $lxdebug->enter_sub();
834 $auth->assert('general_ledger');
838 $form->{invtotal} = 0;
840 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
841 qw(exchangerate creditlimit creditremaining);
843 @flds = qw(amount AP_amount projectnumber oldprojectnumber project_id);
845 for $i (1 .. $form->{rowcount}) {
846 $form->{"amount_$i"} =
847 $form->parse_amount(\%myconfig, $form->{"amount_$i"});
848 $form->{"tax_$i"} = $form->parse_amount(\%myconfig, $form->{"tax_$i"});
849 if ($form->{"amount_$i"}) {
852 if (!$form->{"korrektur_$i"}) {
853 ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
855 if ($form->{taxincluded}) {
856 $form->{"tax_$i"} = $form->{"amount_$i"} / ($rate + 1) * $rate;
858 $form->{"tax_$i"} = $form->{"amount_$i"} * $rate;
861 $form->{"tax_$i"} = 0;
864 $form->{"tax_$i"} = $form->round_amount($form->{"tax_$i"}, 2);
866 $totaltax += $form->{"tax_$i"};
867 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
871 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
873 map { $form->{invtotal} += $form->{"amount_$_"} } (1 .. $form->{rowcount});
875 $form->{exchangerate} = $exchangerate
879 $form->check_exchangerate(
880 \%myconfig, $form->{currency}, $form->{transdate}, 'sell'
883 $form->{invdate} = $form->{transdate};
884 $save_AP = $form->{AP};
886 $form->{AP} = $save_AP;
888 $form->{rowcount} = $count + 1;
891 ($form->{taxincluded}) ? $form->{invtotal} : $form->{invtotal} + $totaltax;
893 for $i (1 .. $form->{paidaccounts}) {
894 if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
897 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
898 } qw(paid exchangerate);
900 $totalpaid += $form->{"paid_$i"};
902 $form->{"exchangerate_$i"} = $exchangerate
904 $form->{"forex_$i"} = (
906 $form->check_exchangerate(
907 \%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'sell'
912 $form->{creditremaining} -=
913 ($form->{invtotal} - $totalpaid + $form->{oldtotalpaid} -
914 $form->{oldinvtotal});
915 $form->{oldinvtotal} = $form->{invtotal};
916 $form->{oldtotalpaid} = $totalpaid;
920 $lxdebug->leave_sub();
925 $lxdebug->enter_sub();
927 $auth->assert('general_ledger');
929 $form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
931 for $i (1 .. $form->{paidaccounts}) {
932 if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
933 $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
935 $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
937 $form->error($locale->text('Cannot post payment for a closed period!'))
938 if ($datepaid <= $closedto);
940 if ($form->{currency} ne $form->{defaultcurrency}) {
941 $form->{"exchangerate_$i"} = $form->{exchangerate}
942 if ($invdate == $datepaid);
943 $form->isblank("exchangerate_$i",
944 $locale->text('Exchangerate for payment missing!'));
949 ($form->{AP}) = split /--/, $form->{AP};
950 ($form->{AP_paid}) = split /--/, $form->{AP_paid};
951 $form->redirect($locale->text('Payment posted!'))
952 if (AP->post_payment(\%myconfig, \%$form));
953 $form->error($locale->text('Cannot post payment!'));
956 $lxdebug->leave_sub();
961 $lxdebug->enter_sub();
963 $auth->assert('general_ledger');
965 # check if there is a vendor, invoice and due date
966 $form->isblank("transdate", $locale->text("Invoice Date missing!"));
967 $form->isblank("duedate", $locale->text("Due Date missing!"));
968 $form->isblank("vendor", $locale->text('Vendor missing!'));
970 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
971 $transdate = $form->datetonum($form->{transdate}, \%myconfig);
972 $form->error($locale->text('Cannot post transaction for a closed period!')) if ($transdate <= $closedto);
974 my $zero_amount_posting = 1;
975 for $i (1 .. $form->{rowcount}) {
976 if ($form->parse_amount(\%myconfig, $form->{"amount_$i"})) {
977 $zero_amount_posting = 0;
982 $form->error($locale->text('Zero amount posting!')) if $zero_amount_posting;
984 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
985 if ($form->{currency} ne $form->{defaultcurrency});
988 for $i (1 .. $form->{paidaccounts}) {
989 if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
990 $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
992 $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
994 $form->error($locale->text('Cannot post payment for a closed period!'))
995 if ($datepaid <= $closedto);
997 if ($form->{currency} ne $form->{defaultcurrency}) {
998 $form->{"exchangerate_$i"} = $form->{exchangerate}
999 if ($transdate == $datepaid);
1000 $form->isblank("exchangerate_$i",
1001 $locale->text('Exchangerate for payment missing!'));
1007 # if old vendor ne vendor redo form
1008 ($vendor) = split /--/, $form->{vendor};
1009 if ($form->{oldvendor} ne "$vendor--$form->{vendor_id}") {
1013 ($debitaccno, $debittaxkey) = split /--/, $form->{AP_amountselected};
1014 ($taxkey, $NULL) = split /--/, $form->{taxchartselected};
1015 ($payablesaccno, $payablestaxkey) = split /--/, $form->{APselected};
1016 $form->{AP}{amount_1} = $debitaccno;
1017 $form->{AP}{payables} = $payablesaccno;
1018 $form->{taxkey} = $taxkey;
1019 $form->{storno} = 0;
1021 $form->{id} = 0 if $form->{postasnew};
1023 if (AP->post_transaction(\%myconfig, \%$form)) {
1024 # saving the history
1025 if(!exists $form->{addition} && $form->{id} ne "") {
1026 $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
1027 $form->{addition} = "POSTED";
1028 $form->save_history($form->dbconnect(\%myconfig));
1030 # /saving the history
1031 remove_draft() if $form->{remove_draft};
1032 $form->redirect($locale->text('Transaction posted!'));
1034 $form->error($locale->text('Cannot post transaction!'));
1036 $lxdebug->leave_sub();
1040 $lxdebug->enter_sub();
1042 $auth->assert('general_ledger');
1044 $form->{postasnew} = 1;
1045 # saving the history
1046 if(!exists $form->{addition} && $form->{id} ne "") {
1047 $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
1048 $form->{addition} = "POSTED AS NEW";
1049 $form->save_history($form->dbconnect(\%myconfig));
1051 # /saving the history
1054 $lxdebug->leave_sub();
1057 sub use_as_template {
1058 $lxdebug->enter_sub();
1060 $auth->assert('general_ledger');
1062 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);
1063 $form->{paidaccounts} = 1;
1064 $form->{rowcount}--;
1065 $form->{invdate} = $form->current_date(\%myconfig);
1068 $lxdebug->leave_sub();
1072 $lxdebug->enter_sub();
1074 $auth->assert('general_ledger');
1076 $form->{title} = $locale->text('Confirm!');
1080 delete $form->{header};
1085 <form method=post action=$form->{script}>
1088 foreach $key (keys %$form) {
1089 next if (($key eq 'login') || ($key eq 'password') || ('' ne ref $form->{$key}));
1090 $form->{$key} =~ s/\"/"/g;
1091 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
1095 <h2 class=confirm>$form->{title}</h2>
1098 . $locale->text('Are you sure you want to delete Transaction')
1099 . qq| $form->{invnumber}</h4>
1101 <input name=action class=submit type=submit value="|
1102 . $locale->text('Yes') . qq|">
1109 $lxdebug->leave_sub();
1113 $lxdebug->enter_sub();
1115 $auth->assert('general_ledger');
1117 if (AP->delete_transaction(\%myconfig, \%$form, $spool)) {
1118 # saving the history
1119 if(!exists $form->{addition}) {
1120 $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
1121 $form->{addition} = "DELETED";
1122 $form->save_history($form->dbconnect(\%myconfig));
1124 # /saving the history
1125 $form->redirect($locale->text('Transaction deleted!'));
1127 $form->error($locale->text('Cannot delete transaction!'));
1129 $lxdebug->leave_sub();
1133 $lxdebug->enter_sub();
1135 $auth->assert('general_ledger | vendor_invoice_edit');
1137 # setup vendor selection
1138 $form->all_vc(\%myconfig, "vendor", "AP");
1140 if (@{ $form->{all_vendor} }) {
1141 map { $vendor .= "<option>$_->{name}--$_->{id}\n" }
1142 @{ $form->{all_vendor} };
1143 $vendor = qq|<select name=vendor><option>\n$vendor\n</select>|;
1145 $vendor = qq|<input name=vendor size=35>|;
1149 if (@{ $form->{all_departments} }) {
1150 $form->{selectdepartment} = "<option>\n";
1153 $form->{selectdepartment} .=
1154 "<option>$_->{description}--$_->{id}\n"
1155 } (@{ $form->{all_departments} });
1160 <th align=right nowrap>| . $locale->text('Department') . qq|</th>
1161 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
1163 | if $form->{selectdepartment};
1165 $form->{title} = $locale->text('AP Transactions');
1167 # use JavaScript Calendar or not
1168 $form->{jsscript} = 1;
1170 if ($form->{jsscript}) {
1172 # with JavaScript Calendar
1174 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\">
1175 <input type=button name=transdatefrom id="trigger1" value=|
1176 . $locale->text('button') . qq|></td>
1179 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\">
1180 <input type=button name=transdateto name=transdateto id="trigger2" value=|
1181 . $locale->text('button') . qq|></td>
1186 Form->write_trigger(\%myconfig, "2", "transdatefrom", "BR", "trigger1",
1187 "transdateto", "BL", "trigger2");
1190 # without JavaScript Calendar
1192 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\"></td>|;
1194 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\"></td>|;
1197 $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
1202 foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
1203 push(@values, $item->{"id"});
1204 $labels{$item->{"id"}} = $item->{"projectnumber"};
1207 NTI($cgi->popup_menu('-name' => 'project_id', '-values' => \@values,
1208 '-labels' => \%labels));
1209 $form->{javascript} .= qq|<script type="text/javascript" src="js/common.js"></script>|;
1211 $onload = qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
1212 $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
1214 <body onLoad="$onload">
1216 <form method=post action=$form->{script}>
1220 <th class=listtop>$form->{title}</th>
1222 <tr height="5"></tr>
1227 <th align=right>| . $locale->text('Vendor') . qq|</th>
1228 <td colspan=3>$vendor</td>
1232 <th align=right nowrap>| . $locale->text('Invoice Number') . qq|</th>
1233 <td colspan=3><input name=invnumber size=20></td>
1236 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
1237 <td colspan=3><input name=ordnumber size=20></td>
1240 <th align=right nowrap>| . $locale->text('Notes') . qq|</th>
1241 <td colspan=3><input name=notes size=40></td>
1244 <th align="right">| . $locale->text("Project Number") . qq|</th>
1245 <td colspan="3">$projectnumber</td>
1248 <th align=right nowrap>| . $locale->text('From') . qq|</th>
1250 <th align=right>| . $locale->text('Bis') . qq|</th>
1253 <input type=hidden name=sort value=transdate>
1261 <th align=right nowrap>| . $locale->text('Include in Report') . qq|</th>
1265 <td align=right><input name=open class=checkbox type=checkbox value=Y checked></td>
1266 <td nowrap>| . $locale->text('Open') . qq|</td>
1267 <td align=right><input name=closed class=checkbox type=checkbox value=Y></td>
1268 <td nowrap>| . $locale->text('Closed') . qq|</td>
1271 <td align=right><input name="l_id" class=checkbox type=checkbox value=Y></td>
1272 <td nowrap>| . $locale->text('ID') . qq|</td>
1273 <td align=right><input name="l_invnumber" class=checkbox type=checkbox value=Y checked></td>
1274 <td nowrap>| . $locale->text('Invoice Number') . qq|</td>
1275 <td align=right><input name="l_ordnumber" class=checkbox type=checkbox value=Y></td>
1276 <td nowrap>| . $locale->text('Order Number') . qq|</td>
1279 <td align=right><input name="l_name" class=checkbox type=checkbox value=Y checked></td>
1280 <td nowrap>| . $locale->text('Vendor') . qq|</td>
1281 <td align=right><input name="l_transdate" class=checkbox type=checkbox value=Y checked></td>
1282 <td nowrap>| . $locale->text('Invoice Date') . qq|</td>
1283 <td align=right><input name="l_netamount" class=checkbox type=checkbox value=Y></td>
1284 <td nowrap>| . $locale->text('Amount') . qq|</td>
1287 <td align=right><input name="l_tax" class=checkbox type=checkbox value=Y></td>
1288 <td nowrap>| . $locale->text('Tax') . qq|</td>
1289 <td align=right><input name="l_amount" class=checkbox type=checkbox value=Y checked></td>
1290 <td nowrap>| . $locale->text('Total') . qq|</td>
1291 <td align=right><input name="l_datepaid" class=checkbox type=checkbox value=Y></td>
1292 <td nowrap>| . $locale->text('Date Paid') . qq|</td>
1295 <td align=right><input name="l_paid" class=checkbox type=checkbox value=Y checked></td>
1296 <td nowrap>| . $locale->text('Paid') . qq|</td>
1297 <td align=right><input name="l_duedate" class=checkbox type=checkbox value=Y></td>
1298 <td nowrap>| . $locale->text('Due Date') . qq|</td>
1299 <td align=right><input name="l_due" class=checkbox type=checkbox value=Y></td>
1300 <td nowrap>| . $locale->text('Amount Due') . qq|</td>
1303 <td align=right><input name="l_notes" class=checkbox type=checkbox value=Y></td>
1304 <td nowrap>| . $locale->text('Notes') . qq|</td>
1305 <td align=right><input name="l_employee" class=checkbox type=checkbox value=Y></td>
1306 <td nowrap>| . $locale->text('Employee') . qq|</td>
1309 <td align=right><input name="l_subtotal" class=checkbox type=checkbox value=Y></td>
1310 <td nowrap>| . $locale->text('Subtotal') . qq|</td>
1311 <td align=right><input name="l_globalprojectnumber" class=checkbox type=checkbox value=Y></td>
1312 <td nowrap>| . $locale->text('Project Number') . qq|</td>
1321 <td><hr size=3 noshade></td>
1328 <input type=hidden name=nextsub value=$form->{nextsub}>
1330 <input class=submit type=submit name=action value="|
1331 . $locale->text('Continue') . qq|">
1338 $lxdebug->leave_sub();
1341 sub create_subtotal_row {
1342 $lxdebug->enter_sub();
1344 my ($totals, $columns, $column_alignment, $subtotal_columns, $class) = @_;
1346 my $row = { map { $_ => { 'data' => '', 'class' => $class, 'align' => $column_alignment->{$_}, } } @{ $columns } };
1348 map { $row->{$_}->{data} = $form->format_amount(\%myconfig, $totals->{$_}, 2) } @{ $subtotal_columns };
1350 $row->{tax}->{data} = $form->format_amount(\%myconfig, $totals->{amount} - $totals->{netamount}, 2);
1352 map { $totals->{$_} = 0 } @{ $subtotal_columns };
1354 $lxdebug->leave_sub();
1359 sub ap_transactions {
1360 $lxdebug->enter_sub();
1362 $auth->assert('general_ledger | vendor_invoice_edit');
1364 ($form->{vendor}, $form->{vendor_id}) = split(/--/, $form->{vendor});
1366 $form->{sort} ||= 'transdate';
1368 AP->ap_transactions(\%myconfig, \%$form);
1370 $form->{title} = $locale->text('AP Transactions');
1372 my $report = SL::ReportGenerator->new(\%myconfig, $form);
1375 qw(transdate id type invnumber ordnumber name netamount tax amount paid datepaid
1376 due duedate transaction_description notes employee globalprojectnumber);
1378 my @hidden_variables = map { "l_${_}" } @columns;
1379 push @hidden_variables, "l_subtotal", qw(open closed vendor invnumber ordnumber transaction_description notes project_id transdatefrom transdateto);
1381 my $href = build_std_url('action=ap_transactions', grep { $form->{$_} } @hidden_variables);
1384 'transdate' => { 'text' => $locale->text('Date'), },
1385 'id' => { 'text' => $locale->text('ID'), },
1386 'type' => { 'text' => $locale->text('Type'), },
1387 'invnumber' => { 'text' => $locale->text('Invoice'), },
1388 'ordnumber' => { 'text' => $locale->text('Order'), },
1389 'name' => { 'text' => $locale->text('Vendor'), },
1390 'netamount' => { 'text' => $locale->text('Amount'), },
1391 'tax' => { 'text' => $locale->text('Tax'), },
1392 'amount' => { 'text' => $locale->text('Total'), },
1393 'paid' => { 'text' => $locale->text('Paid'), },
1394 'datepaid' => { 'text' => $locale->text('Date Paid'), },
1395 'due' => { 'text' => $locale->text('Amount Due'), },
1396 'duedate' => { 'text' => $locale->text('Due Date'), },
1397 'transaction_description' => { 'text' => $locale->text('Transaction description'), },
1398 'notes' => { 'text' => $locale->text('Notes'), },
1399 'employee' => { 'text' => $locale->text('Salesperson'), },
1400 'globalprojectnumber' => { 'text' => $locale->text('Project Number'), },
1403 foreach my $name (qw(id transdate duedate invnumber ordnumber name datepaid
1404 employee shippingpoint shipvia)) {
1405 $column_defs{$name}->{link} = $href . "&sort=$name";
1408 my %column_alignment = map { $_ => 'right' } qw(netamount tax amount paid due);
1410 $form->{"l_type"} = "Y";
1411 map { $column_defs{$_}->{visible} = $form->{"l_${_}"} ? 1 : 0 } @columns;
1413 $report->set_columns(%column_defs);
1414 $report->set_column_order(@columns);
1416 $report->set_export_options('ap_transactions', @hidden_variables);
1418 $report->set_sort_indicator($form->{sort}, 1);
1421 if ($form->{vendor}) {
1422 push @options, $locale->text('Vendor') . " : $form->{vendor}";
1424 if ($form->{department}) {
1425 ($department) = split /--/, $form->{department};
1426 push @options, $locale->text('Department') . " : $department";
1428 if ($form->{invnumber}) {
1429 push @options, $locale->text('Invoice Number') . " : $form->{invnumber}";
1431 if ($form->{ordnumber}) {
1432 push @options, $locale->text('Order Number') . " : $form->{ordnumber}";
1434 if ($form->{notes}) {
1435 push @options, $locale->text('Notes') . " : $form->{notes}";
1437 if ($form->{transaction_description}) {
1438 push @options, $locale->text('Transaction description') . " : $form->{transaction_description}";
1440 if ($form->{transdatefrom}) {
1441 push @options, $locale->text('From') . " " . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
1443 if ($form->{transdateto}) {
1444 push @options, $locale->text('Bis') . " " . $locale->date(\%myconfig, $form->{transdateto}, 1);
1446 if ($form->{open}) {
1447 push @options, $locale->text('Open');
1449 if ($form->{closed}) {
1450 push @options, $locale->text('Closed');
1453 $report->set_options('top_info_text' => join("\n", @options),
1454 'raw_bottom_info_text' => $form->parse_html_template('ap/ap_transactions_bottom'),
1455 'output_format' => 'HTML',
1456 'title' => $form->{title},
1457 'attachment_basename' => $locale->text('invoice_list') . strftime('_%Y%m%d', localtime time),
1459 $report->set_options_from_form();
1461 # add sort and escape callback, this one we use for the add sub
1462 $form->{callback} = $href .= "&sort=$form->{sort}";
1464 # escape callback for href
1465 $callback = $form->escape($href);
1467 my @subtotal_columns = qw(netamount amount paid due);
1469 my %totals = map { $_ => 0 } @subtotal_columns;
1470 my %subtotals = map { $_ => 0 } @subtotal_columns;
1474 foreach $ap (@{ $form->{AP} }) {
1475 $ap->{tax} = $ap->{amount} - $ap->{netamount};
1476 $ap->{due} = $ap->{amount} - $ap->{paid};
1478 map { $subtotals{$_} += $ap->{$_};
1479 $totals{$_} += $ap->{$_} } @subtotal_columns;
1481 map { $ap->{$_} = $form->format_amount(\%myconfig, $ap->{$_}, 2) } qw(netamount tax amount paid due);
1484 $ap->{invoice} ? $locale->text("Invoice (one letter abbreviation)") :
1485 $locale->text("AP Transaction (abbreviation)");
1489 foreach my $column (@columns) {
1491 'data' => $ap->{$column},
1492 'align' => $column_alignment{$column},
1496 $row->{invnumber}->{link} = build_std_url("script=" . ($ap->{invoice} ? 'ir.pl' : 'ap.pl'), 'action=edit')
1497 . "&id=" . E($ap->{id}) . "&callback=${callback}";
1499 my $row_set = [ $row ];
1501 if (($form->{l_subtotal} eq 'Y')
1502 && (($idx == (scalar @{ $form->{AP} } - 1))
1503 || ($ap->{ $form->{sort} } ne $form->{AP}->[$idx + 1]->{ $form->{sort} }))) {
1504 push @{ $row_set }, create_subtotal_row(\%subtotals, \@columns, \%column_alignment, \@subtotal_columns, 'listsubtotal');
1507 $report->add_data($row_set);
1512 $report->add_separator();
1513 $report->add_data(create_subtotal_row(\%totals, \@columns, \%column_alignment, \@subtotal_columns, 'listtotal'));
1515 $report->generate_with_headers();
1517 $lxdebug->leave_sub();
1521 $lxdebug->enter_sub();
1523 $auth->assert('general_ledger');
1525 if (IS->has_storno(\%myconfig, $form, 'ap')) {
1526 $form->{title} = $locale->text("Cancel Accounts Payables Transaction");
1527 $form->error($locale->text("Transaction has already been cancelled!"));
1530 AP->storno($form, \%myconfig, $form->{id});
1532 # saving the history
1533 if(!exists $form->{addition} && $form->{id} ne "") {
1534 $form->{snumbers} = "ordnumber_$form->{ordnumber}";
1535 $form->{addition} = "STORNO";
1536 $form->save_history($form->dbconnect(\%myconfig));
1538 # /saving the history
1540 $form->redirect(sprintf $locale->text("Transaction %d cancelled."), $form->{storno_id});
1542 $lxdebug->leave_sub();