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
781 # mark_as_paid button
782 if($form->{id} ne "") {
783 print qq|<input type="submit" class="submit" name="action" value="|
784 . $locale->text('mark as paid') . qq|">|;
786 # /mark_as_paid button
794 $lxdebug->leave_sub();
798 $lxdebug->enter_sub();
799 &mark_as_paid_common(\%myconfig,"ap");
800 $lxdebug->leave_sub();
804 $lxdebug->enter_sub();
808 $form->{invtotal} = 0;
810 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
811 qw(exchangerate creditlimit creditremaining);
813 @flds = qw(amount AP_amount projectnumber oldprojectnumber project_id);
815 for $i (1 .. $form->{rowcount}) {
816 $form->{"amount_$i"} =
817 $form->parse_amount(\%myconfig, $form->{"amount_$i"});
818 $form->{"tax_$i"} = $form->parse_amount(\%myconfig, $form->{"tax_$i"});
819 if ($form->{"amount_$i"}) {
822 if (!$form->{"korrektur_$i"}) {
823 ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
825 if ($form->{taxincluded}) {
826 $form->{"tax_$i"} = $form->{"amount_$i"} / ($rate + 1) * $rate;
828 $form->{"tax_$i"} = $form->{"amount_$i"} * $rate;
831 $form->{"tax_$i"} = 0;
834 $form->{"tax_$i"} = $form->round_amount($form->{"tax_$i"}, 2);
836 $totaltax += $form->{"tax_$i"};
837 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
841 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
843 map { $form->{invtotal} += $form->{"amount_$_"} } (1 .. $form->{rowcount});
845 $form->{exchangerate} = $exchangerate
849 $form->check_exchangerate(
850 \%myconfig, $form->{currency}, $form->{transdate}, 'sell'
853 $form->{invdate} = $form->{transdate};
854 $save_AP = $form->{AP};
856 $form->{AP} = $save_AP;
858 $form->{rowcount} = $count + 1;
861 ($form->{taxincluded}) ? $form->{invtotal} : $form->{invtotal} + $totaltax;
863 for $i (1 .. $form->{paidaccounts}) {
864 if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
867 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
868 } qw(paid exchangerate);
870 $totalpaid += $form->{"paid_$i"};
872 $form->{"exchangerate_$i"} = $exchangerate
874 $form->{"forex_$i"} = (
876 $form->check_exchangerate(
877 \%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'sell'
882 $form->{creditremaining} -=
883 ($form->{invtotal} - $totalpaid + $form->{oldtotalpaid} -
884 $form->{oldinvtotal});
885 $form->{oldinvtotal} = $form->{invtotal};
886 $form->{oldtotalpaid} = $totalpaid;
890 $lxdebug->leave_sub();
895 $lxdebug->enter_sub();
896 for $i (1 .. $form->{paidaccounts}) {
897 if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
898 $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
900 $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
902 $form->error($locale->text('Cannot post payment for a closed period!'))
903 if ($datepaid <= $closedto);
905 if ($form->{currency} ne $form->{defaultcurrency}) {
906 $form->{"exchangerate_$i"} = $form->{exchangerate}
907 if ($invdate == $datepaid);
908 $form->isblank("exchangerate_$i",
909 $locale->text('Exchangerate for payment missing!'));
914 ($form->{AP}) = split /--/, $form->{AP};
915 ($form->{AP_paid}) = split /--/, $form->{AP_paid};
916 $form->redirect($locale->text('Payment posted!'))
917 if (AP->post_payment(\%myconfig, \%$form));
918 $form->error($locale->text('Cannot post payment!'));
921 $lxdebug->leave_sub();
926 $lxdebug->enter_sub();
928 # check if there is a vendor, invoice and due date
929 $form->isblank("transdate", $locale->text("Invoice Date missing!"));
930 $form->isblank("duedate", $locale->text("Due Date missing!"));
931 $form->isblank("vendor", $locale->text('Vendor missing!'));
933 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
934 $transdate = $form->datetonum($form->{transdate}, \%myconfig);
935 $form->error($locale->text('Cannot post transaction for a closed period!')) if ($transdate <= $closedto);
937 my $zero_amount_posting = 1;
938 for $i (1 .. $form->{rowcount}) {
939 if ($form->parse_amount(\%myconfig, $form->{"amount_$i"})) {
940 $zero_amount_posting = 0;
945 $form->error($locale->text('Zero amount posting!')) if $zero_amount_posting;
947 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
948 if ($form->{currency} ne $form->{defaultcurrency});
951 for $i (1 .. $form->{paidaccounts}) {
952 if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
953 $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
955 $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
957 $form->error($locale->text('Cannot post payment for a closed period!'))
958 if ($datepaid <= $closedto);
960 if ($form->{currency} ne $form->{defaultcurrency}) {
961 $form->{"exchangerate_$i"} = $form->{exchangerate}
962 if ($transdate == $datepaid);
963 $form->isblank("exchangerate_$i",
964 $locale->text('Exchangerate for payment missing!'));
970 # if old vendor ne vendor redo form
971 ($vendor) = split /--/, $form->{vendor};
972 if ($form->{oldvendor} ne "$vendor--$form->{vendor_id}") {
976 ($debitaccno, $debittaxkey) = split /--/, $form->{AP_amountselected};
977 ($taxkey, $NULL) = split /--/, $form->{taxchartselected};
978 ($payablesaccno, $payablestaxkey) = split /--/, $form->{APselected};
979 $form->{AP}{amount_1} = $debitaccno;
980 $form->{AP}{payables} = $payablesaccno;
981 $form->{taxkey} = $taxkey;
983 $form->{id} = 0 if $form->{postasnew};
985 if (AP->post_transaction(\%myconfig, \%$form)) {
987 if(!exists $form->{addition} && $form->{id} ne "") {
988 $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
989 $form->{addition} = "POSTED";
990 $form->save_history($form->dbconnect(\%myconfig));
992 # /saving the history
993 remove_draft() if $form->{remove_draft};
994 $form->redirect($locale->text('Transaction posted!'));
996 $form->error($locale->text('Cannot post transaction!'));
998 $lxdebug->leave_sub();
1002 $lxdebug->enter_sub();
1004 $form->{postasnew} = 1;
1005 # saving the history
1006 if(!exists $form->{addition} && $form->{id} ne "") {
1007 $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
1008 $form->{addition} = "POSTED AS NEW";
1009 $form->save_history($form->dbconnect(\%myconfig));
1011 # /saving the history
1014 $lxdebug->leave_sub();
1017 sub use_as_template {
1018 $lxdebug->enter_sub();
1020 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);
1021 $form->{paidaccounts} = 1;
1022 $form->{rowcount}--;
1023 $form->{invdate} = $form->current_date(\%myconfig);
1026 $lxdebug->leave_sub();
1030 $lxdebug->enter_sub();
1032 $form->{title} = $locale->text('Confirm!');
1036 delete $form->{header};
1041 <form method=post action=$form->{script}>
1044 foreach $key (keys %$form) {
1045 $form->{$key} =~ s/\"/"/g;
1046 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
1050 <h2 class=confirm>$form->{title}</h2>
1053 . $locale->text('Are you sure you want to delete Transaction')
1054 . qq| $form->{invnumber}</h4>
1056 <input name=action class=submit type=submit value="|
1057 . $locale->text('Yes') . qq|">
1064 $lxdebug->leave_sub();
1068 $lxdebug->enter_sub();
1069 if (AP->delete_transaction(\%myconfig, \%$form, $spool)) {
1070 # saving the history
1071 if(!exists $form->{addition}) {
1072 $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
1073 $form->{addition} = "DELETED";
1074 $form->save_history($form->dbconnect(\%myconfig));
1076 # /saving the history
1077 $form->redirect($locale->text('Transaction deleted!'));
1079 $form->error($locale->text('Cannot delete transaction!'));
1081 $lxdebug->leave_sub();
1085 $lxdebug->enter_sub();
1087 # setup vendor selection
1088 $form->all_vc(\%myconfig, "vendor", "AP");
1090 if (@{ $form->{all_vendor} }) {
1091 map { $vendor .= "<option>$_->{name}--$_->{id}\n" }
1092 @{ $form->{all_vendor} };
1093 $vendor = qq|<select name=vendor><option>\n$vendor\n</select>|;
1095 $vendor = qq|<input name=vendor size=35>|;
1099 if (@{ $form->{all_departments} }) {
1100 $form->{selectdepartment} = "<option>\n";
1103 $form->{selectdepartment} .=
1104 "<option>$_->{description}--$_->{id}\n"
1105 } (@{ $form->{all_departments} });
1110 <th align=right nowrap>| . $locale->text('Department') . qq|</th>
1111 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
1113 | if $form->{selectdepartment};
1115 $form->{title} = $locale->text('AP Transactions');
1117 # use JavaScript Calendar or not
1118 $form->{jsscript} = 1;
1120 if ($form->{jsscript}) {
1122 # with JavaScript Calendar
1124 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\">
1125 <input type=button name=transdatefrom id="trigger1" value=|
1126 . $locale->text('button') . qq|></td>
1129 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\">
1130 <input type=button name=transdateto name=transdateto id="trigger2" value=|
1131 . $locale->text('button') . qq|></td>
1136 Form->write_trigger(\%myconfig, "2", "transdatefrom", "BR", "trigger1",
1137 "transdateto", "BL", "trigger2");
1140 # without JavaScript Calendar
1142 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\"></td>|;
1144 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\"></td>|;
1147 $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
1152 foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
1153 push(@values, $item->{"id"});
1154 $labels{$item->{"id"}} = $item->{"projectnumber"};
1157 NTI($cgi->popup_menu('-name' => 'project_id', '-values' => \@values,
1158 '-labels' => \%labels));
1159 $form->{javascript} .= qq|<script type="text/javascript" src="js/common.js"></script>|;
1161 $onload = qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
1162 $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
1164 <body onLoad="$onload">
1166 <form method=post action=$form->{script}>
1170 <th class=listtop>$form->{title}</th>
1172 <tr height="5"></tr>
1177 <th align=right>| . $locale->text('Vendor') . qq|</th>
1178 <td colspan=3>$vendor</td>
1182 <th align=right nowrap>| . $locale->text('Invoice Number') . qq|</th>
1183 <td colspan=3><input name=invnumber size=20></td>
1186 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
1187 <td colspan=3><input name=ordnumber size=20></td>
1190 <th align=right nowrap>| . $locale->text('Notes') . qq|</th>
1191 <td colspan=3><input name=notes size=40></td>
1194 <th align="right">| . $locale->text("Project Number") . qq|</th>
1195 <td colspan="3">$projectnumber</td>
1198 <th align=right nowrap>| . $locale->text('From') . qq|</th>
1200 <th align=right>| . $locale->text('Bis') . qq|</th>
1203 <input type=hidden name=sort value=transdate>
1211 <th align=right nowrap>| . $locale->text('Include in Report') . qq|</th>
1215 <td align=right><input name=open class=checkbox type=checkbox value=Y checked></td>
1216 <td nowrap>| . $locale->text('Open') . qq|</td>
1217 <td align=right><input name=closed class=checkbox type=checkbox value=Y></td>
1218 <td nowrap>| . $locale->text('Closed') . qq|</td>
1221 <td align=right><input name="l_id" class=checkbox type=checkbox value=Y></td>
1222 <td nowrap>| . $locale->text('ID') . qq|</td>
1223 <td align=right><input name="l_invnumber" class=checkbox type=checkbox value=Y checked></td>
1224 <td nowrap>| . $locale->text('Invoice Number') . qq|</td>
1225 <td align=right><input name="l_ordnumber" class=checkbox type=checkbox value=Y></td>
1226 <td nowrap>| . $locale->text('Order Number') . qq|</td>
1229 <td align=right><input name="l_name" class=checkbox type=checkbox value=Y checked></td>
1230 <td nowrap>| . $locale->text('Vendor') . qq|</td>
1231 <td align=right><input name="l_transdate" class=checkbox type=checkbox value=Y checked></td>
1232 <td nowrap>| . $locale->text('Invoice Date') . qq|</td>
1233 <td align=right><input name="l_netamount" class=checkbox type=checkbox value=Y></td>
1234 <td nowrap>| . $locale->text('Amount') . qq|</td>
1237 <td align=right><input name="l_tax" class=checkbox type=checkbox value=Y></td>
1238 <td nowrap>| . $locale->text('Tax') . qq|</td>
1239 <td align=right><input name="l_amount" class=checkbox type=checkbox value=Y checked></td>
1240 <td nowrap>| . $locale->text('Total') . qq|</td>
1241 <td align=right><input name="l_datepaid" class=checkbox type=checkbox value=Y></td>
1242 <td nowrap>| . $locale->text('Date Paid') . qq|</td>
1245 <td align=right><input name="l_paid" class=checkbox type=checkbox value=Y checked></td>
1246 <td nowrap>| . $locale->text('Paid') . qq|</td>
1247 <td align=right><input name="l_duedate" class=checkbox type=checkbox value=Y></td>
1248 <td nowrap>| . $locale->text('Due Date') . qq|</td>
1249 <td align=right><input name="l_due" class=checkbox type=checkbox value=Y></td>
1250 <td nowrap>| . $locale->text('Amount Due') . qq|</td>
1253 <td align=right><input name="l_notes" class=checkbox type=checkbox value=Y></td>
1254 <td nowrap>| . $locale->text('Notes') . qq|</td>
1255 <td align=right><input name="l_employee" class=checkbox type=checkbox value=Y></td>
1256 <td nowrap>| . $locale->text('Employee') . qq|</td>
1259 <td align=right><input name="l_subtotal" class=checkbox type=checkbox value=Y></td>
1260 <td nowrap>| . $locale->text('Subtotal') . qq|</td>
1261 <td align=right><input name="l_globalprojectnumber" class=checkbox type=checkbox value=Y></td>
1262 <td nowrap>| . $locale->text('Project Number') . qq|</td>
1271 <td><hr size=3 noshade></td>
1278 <input type=hidden name=nextsub value=$form->{nextsub}>
1279 <input type=hidden name=login value=$form->{login}>
1280 <input type=hidden name=password value=$form->{password}>
1282 <input class=submit type=submit name=action value="|
1283 . $locale->text('Continue') . qq|">
1290 $lxdebug->leave_sub();
1293 sub ap_transactions {
1294 $lxdebug->enter_sub();
1296 $form->{vendor} = $form->unescape($form->{vendor});
1297 ($form->{vendor}, $form->{vendor_id}) = split(/--/, $form->{vendor});
1299 AP->ap_transactions(\%myconfig, \%$form);
1302 "$form->{script}?action=ap_transactions&login=$form->{login}&password=$form->{password}";
1305 if ($form->{vendor}) {
1306 $callback .= "&vendor=" . $form->escape($form->{vendor}, 1);
1307 $href .= "&vendor=" . $form->escape($form->{vendor});
1308 $option .= $locale->text('Vendor') . " : $form->{vendor}";
1310 if ($form->{department}) {
1311 $callback .= "&department=" . $form->escape($form->{department}, 1);
1312 $href .= "&department=" . $form->escape($form->{department});
1313 ($department) = split /--/, $form->{department};
1314 $option .= "\n<br>" if ($option);
1315 $option .= $locale->text('Department') . " : $department";
1317 if ($form->{invnumber}) {
1318 $callback .= "&invnumber=" . $form->escape($form->{invnumber}, 1);
1319 $href .= "&invnumber=" . $form->escape($form->{invnumber});
1320 $option .= "\n<br>" if ($option);
1321 $option .= $locale->text('Invoice Number') . " : $form->{invnumber}";
1323 if ($form->{ordnumber}) {
1324 $callback .= "&ordnumber=" . $form->escape($form->{ordnumber}, 1);
1325 $href .= "&ordnumber=" . $form->escape($form->{ordnumber});
1326 $option .= "\n<br>" if ($option);
1327 $option .= $locale->text('Order Number') . " : $form->{ordnumber}";
1329 if ($form->{notes}) {
1330 $callback .= "¬es=" . $form->escape($form->{notes}, 1);
1331 $href .= "¬es=" . $form->escape($form->{notes});
1332 $option .= "\n<br>" if $option;
1333 $option .= $locale->text('Notes') . " : $form->{notes}";
1336 if ($form->{transdatefrom}) {
1337 $callback .= "&transdatefrom=$form->{transdatefrom}";
1338 $href .= "&transdatefrom=$form->{transdatefrom}";
1339 $option .= "\n<br>" if ($option);
1341 $locale->text('From') . " "
1342 . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
1344 if ($form->{transdateto}) {
1345 $callback .= "&transdateto=$form->{transdateto}";
1346 $href .= "&transdateto=$form->{transdateto}";
1347 $option .= "\n<br>" if ($option);
1349 $locale->text('Bis') . " "
1350 . $locale->date(\%myconfig, $form->{transdateto}, 1);
1352 if ($form->{open}) {
1353 $callback .= "&open=$form->{open}";
1354 $href .= "&open=$form->{open}";
1355 $option .= "\n<br>" if ($option);
1356 $option .= $locale->text('Open');
1358 if ($form->{closed}) {
1359 $callback .= "&closed=$form->{closed}";
1360 $href .= "&closed=$form->{closed}";
1361 $option .= "\n<br>" if ($option);
1362 $option .= $locale->text('Closed');
1364 if ($form->{globalproject_id}) {
1365 $callback .= "&globalproject_id=" . E($form->{globalproject_id});
1366 $href .= "&globalproject_id=" . E($form->{globalproject_id});
1370 qw(transdate id type invnumber ordnumber name netamount tax amount paid datepaid
1371 due duedate notes employee globalprojectnumber);
1373 $form->{"l_type"} = "Y";
1375 foreach $item (@columns) {
1376 if ($form->{"l_$item"} eq "Y") {
1377 push @column_index, $item;
1379 # add column to href and callback
1380 $callback .= "&l_$item=Y";
1381 $href .= "&l_$item=Y";
1385 if ($form->{l_subtotal} eq 'Y') {
1386 $callback .= "&l_subtotal=Y";
1387 $href .= "&l_subtotal=Y";
1390 $column_header{id} =
1391 qq|<th><a class=listheading href=$href&sort=id>|
1392 . $locale->text('ID')
1394 $column_header{transdate} =
1395 qq|<th><a class=listheading href=$href&sort=transdate>|
1396 . $locale->text('Date')
1398 $column_header{type} =
1399 "<th class=\"listheading\">" . $locale->text('Type') . "</th>";
1400 $column_header{duedate} =
1401 qq|<th><a class=listheading href=$href&sort=duedate>|
1402 . $locale->text('Due Date')
1404 $column_header{due} =
1405 qq|<th class=listheading>| . $locale->text('Amount Due') . qq|</th>|;
1406 $column_header{invnumber} =
1407 qq|<th><a class=listheading href=$href&sort=invnumber>|
1408 . $locale->text('Invoice')
1410 $column_header{ordnumber} =
1411 qq|<th><a class=listheading href=$href&sort=ordnumber>|
1412 . $locale->text('Order')
1414 $column_header{name} =
1415 qq|<th><a class=listheading href=$href&sort=name>|
1416 . $locale->text('Vendor')
1418 $column_header{netamount} =
1419 qq|<th class=listheading>| . $locale->text('Amount') . qq|</th>|;
1420 $column_header{tax} =
1421 qq|<th class=listheading>| . $locale->text('Tax') . qq|</th>|;
1422 $column_header{amount} =
1423 qq|<th class=listheading>| . $locale->text('Total') . qq|</th>|;
1424 $column_header{paid} =
1425 qq|<th class=listheading>| . $locale->text('Paid') . qq|</th>|;
1426 $column_header{datepaid} =
1427 qq|<th><a class=listheading href=$href&sort=datepaid>|
1428 . $locale->text('Date Paid')
1430 $column_header{notes} =
1431 qq|<th class=listheading>| . $locale->text('Notes') . qq|</th>|;
1432 $column_header{employee} =
1433 "<th><a class=listheading href=$href&sort=employee>"
1434 . $locale->text('Employee') . "</th>";
1435 $column_header{globalprojectnumber} =
1436 qq|<th class="listheading">| . $locale->text('Project Number') . qq|</th>|;
1438 $form->{title} = $locale->text('AP Transactions');
1447 <th class=listtop>$form->{title}</th>
1449 <tr height="5"></tr>
1456 <tr class=listheading>
1459 map { print "\n$column_header{$_}" } @column_index;
1465 # add sort and escape callback
1466 $form->{callback} = "$callback&sort=$form->{sort}";
1467 $callback = $form->escape($form->{callback});
1469 if (@{ $form->{AP} }) {
1470 $sameitem = $form->{AP}->[0]->{ $form->{sort} };
1473 # sums and tax on reports by Antonio Gallardo
1475 foreach $ap (@{ $form->{AP} }) {
1477 if ($form->{l_subtotal} eq 'Y') {
1478 if ($sameitem ne $ap->{ $form->{sort} }) {
1480 $sameitem = $ap->{ $form->{sort} };
1484 $column_data{netamount} =
1486 . $form->format_amount(\%myconfig, $ap->{netamount}, 2, " ")
1488 $column_data{tax} = "<td align=right>"
1489 . $form->format_amount(\%myconfig, $ap->{amount} - $ap->{netamount},
1492 $column_data{amount} =
1494 . $form->format_amount(\%myconfig, $ap->{amount}, 2, " ") . "</td>";
1495 $column_data{paid} =
1497 . $form->format_amount(\%myconfig, $ap->{paid}, 2, " ") . "</td>";
1498 $column_data{due} = "<td align=right>"
1499 . $form->format_amount(\%myconfig, $ap->{amount} - $ap->{paid},
1503 $totalnetamount += $ap->{netamount};
1504 $totalamount += $ap->{amount};
1505 $totalpaid += $ap->{paid};
1506 $totaldue += ($ap->{amount} - $ap->{paid});
1508 $subtotalnetamount += $ap->{netamount};
1509 $subtotalamount += $ap->{amount};
1510 $subtotalpaid += $ap->{paid};
1511 $subtotaldue += ($ap->{amount} - $ap->{paid});
1513 $column_data{transdate} = "<td>$ap->{transdate} </td>";
1514 $column_data{type} = "<td>" .
1515 ($ap->{invoice} ? $locale->text("Invoice (one letter abbreviation)") :
1516 $locale->text("AP Transaction (abbreviation)"))
1518 $column_data{duedate} = "<td>$ap->{duedate} </td>";
1519 $column_data{datepaid} = "<td>$ap->{datepaid} </td>";
1521 $module = ($ap->{invoice}) ? "ir.pl" : $form->{script};
1523 $column_data{invnumber} =
1524 qq|<td><a href="$module?action=edit&id=$ap->{id}&login=$form->{login}&password=$form->{password}&callback=$callback">$ap->{invnumber}</a></td>|;
1525 $column_data{id} = "<td>$ap->{id}</td>";
1526 $column_data{ordnumber} = "<td>$ap->{ordnumber} </td>";
1527 $column_data{name} = "<td>$ap->{name}</td>";
1528 $ap->{notes} =~ s/\r\n/<br>/g;
1529 $column_data{notes} = "<td>$ap->{notes} </td>";
1530 $column_data{employee} = "<td>$ap->{employee} </td>";
1531 $column_data{globalprojectnumber} =
1532 "<td>" . H($ap->{globalprojectnumber}) . "</td>";
1537 <tr class=listrow$i >
1540 map { print "\n$column_data{$_}" } @column_index;
1548 if ($form->{l_subtotal} eq 'Y') {
1554 <tr class=listtotal>
1557 map { $column_data{$_} = "<td> </td>" } @column_index;
1559 $column_data{netamount} =
1560 "<th class=listtotal align=right>"
1561 . $form->format_amount(\%myconfig, $totalnetamount, 2, " ") . "</th>";
1562 $column_data{tax} = "<th class=listtotal align=right>"
1563 . $form->format_amount(\%myconfig, $totalamount - $totalnetamount,
1566 $column_data{amount} =
1567 "<th class=listtotal align=right>"
1568 . $form->format_amount(\%myconfig, $totalamount, 2, " ") . "</th>";
1569 $column_data{paid} =
1570 "<th class=listtotal align=right>"
1571 . $form->format_amount(\%myconfig, $totalpaid, 2, " ") . "</th>";
1573 "<th class=listtotal align=right>"
1574 . $form->format_amount(\%myconfig, $totaldue, 2, " ") . "</th>";
1576 map { print "$column_data{$_}\n" } @column_index;
1584 <td><hr size=3 noshade></td>
1589 <form method=post action=$form->{script}>
1591 <input name=callback type=hidden value="$form->{callback}">
1593 <input type=hidden name=login value=$form->{login}>
1594 <input type=hidden name=password value=$form->{password}>
1596 <input class=submit type=submit name=action value="|
1597 . $locale->text('AP Transaction') . qq|">
1599 <input class=submit type=submit name=action value="|
1600 . $locale->text('Vendor Invoice') . qq|">
1608 $lxdebug->leave_sub();
1612 $lxdebug->enter_sub();
1614 map { $column_data{$_} = "<td> </td>" } @column_index;
1616 $column_data{netamount} =
1617 "<th class=listsubtotal align=right>"
1618 . $form->format_amount(\%myconfig, $subtotalnetamount, 2, " ")
1620 $column_data{tax} = "<th class=listsubtotal align=right>"
1621 . $form->format_amount(\%myconfig, $subtotalamount - $subtotalnetamount,
1624 $column_data{amount} =
1625 "<th class=listsubtotal align=right>"
1626 . $form->format_amount(\%myconfig, $subtotalamount, 2, " ") . "</th>";
1627 $column_data{paid} =
1628 "<th class=listsubtotal align=right>"
1629 . $form->format_amount(\%myconfig, $subtotalpaid, 2, " ") . "</th>";
1631 "<th class=listsubtotal align=right>"
1632 . $form->format_amount(\%myconfig, $subtotaldue, 2, " ") . "</th>";
1634 $subtotalnetamount = 0;
1635 $subtotalamount = 0;
1639 print "<tr class=listsubtotal>";
1641 map { print "\n$column_data{$_}" } @column_index;
1647 $lxdebug->leave_sub();
1651 $lxdebug->enter_sub();
1653 if (IS->has_storno(\%myconfig, $form, 'ap')) {
1654 $form->{title} = $locale->text("Cancel Accounts Payables Transaction");
1655 $form->error($locale->text("Transaction has already been cancelled!"));
1658 # negate amount/taxes
1659 for my $i (1 .. $form->{rowcount}) {
1660 $form->{"amount_$i"} *= -1;
1661 $form->{"tax_$i"} *= -1;
1665 for my $i (1 .. $form->{rowcount}) {
1666 for (qw(amount tax)) {
1667 $form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}, 2) if $form->{"${_}_$i"};
1671 $form->{storno} = 1;
1672 $form->{storno_id} = $form->{id};
1675 $form->{invnumber} = "Storno-" . $form->{invnumber};
1679 # saving the history
1680 if(!exists $form->{addition} && $form->{id} ne "") {
1681 $form->{snumbers} = "ordnumber_$form->{ordnumber}";
1682 $form->{addition} = "STORNO";
1683 $form->save_history($form->dbconnect(\%myconfig));
1685 # /saving the history
1687 $lxdebug->leave_sub();