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 #======================================================================
30 # Accounts Receivables
32 #======================================================================
39 require "$form->{path}/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());
81 if(!exists $form->{addition} && ($form->{id} ne "")) {
82 $form->{addition} = "ADDED";
83 $form->save_history($form->dbconnect(\%myconfig));
87 $form->{title} = "Add";
89 "$form->{script}?action=add&path=$form->{path}&login=$form->{login}&password=$form->{password}"
90 unless $form->{callback};
93 AR->get_transdate(\%myconfig, $form);
95 $lxdebug->leave_sub();
99 $lxdebug->enter_sub();
100 # show history button
101 $form->{javascript} = qq|<script type="text/javascript" src="js/show_history.js"></script>|;
102 #/show hhistory button
104 $form->{title} = "Edit";
109 $lxdebug->leave_sub();
113 $lxdebug->enter_sub();
118 $lxdebug->leave_sub();
122 $lxdebug->enter_sub();
124 $form->create_links("AR", \%myconfig, "customer");
125 $duedate = $form->{duedate};
127 $taxincluded = $form->{taxincluded};
128 my $id = $form->{id};
129 IS->get_customer(\%myconfig, \%$form);
130 $form->{taxincluded} = $taxincluded;
133 $form->{duedate} = $duedate if $duedate;
134 $form->{oldcustomer} = "$form->{customer}--$form->{customer_id}";
135 $form->{rowcount} = 1;
138 @curr = split(/:/, $form->{currencies});
140 $form->{defaultcurrency} = $curr[0];
142 map { $form->{selectcurrency} .= "<option>$_\n" } @curr;
145 if (@{ $form->{all_customer} }) {
146 $form->{customer} = "$form->{customer}--$form->{customer_id}";
147 map { $form->{selectcustomer} .= "<option>$_->{name}--$_->{id}\n" }
148 (@{ $form->{all_customer} });
152 if (@{ $form->{all_departments} }) {
153 $form->{selectdepartment} = "<option>\n";
154 $form->{department} = "$form->{department}--$form->{department_id}";
157 $form->{selectdepartment} .=
158 "<option>$_->{description}--$_->{id}\n"
159 } (@{ $form->{all_departments} });
162 $form->{employee} = "$form->{employee}--$form->{employee_id}";
165 if (@{ $form->{all_employees} }) {
166 $form->{selectemployee} = "";
167 map { $form->{selectemployee} .= "<option>$_->{name}--$_->{id}\n" }
168 (@{ $form->{all_employees} });
171 # build the popup menus
172 $form->{taxincluded} = ($form->{id}) ? $form->{taxincluded} : "checked";
175 $form->{forex} = $form->{exchangerate};
176 $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
177 foreach $key (keys %{ $form->{AR_links} }) {
179 foreach $ref (@{ $form->{AR_links}{$key} }) {
180 if ($key eq "AR_paid") {
181 $form->{"select$key"} .=
182 "<option value=\"$ref->{accno}\">$ref->{accno}--$ref->{description}</option>\n";
184 $form->{"select$key"} .=
185 "<option value=\"$ref->{accno}--$ref->{tax_id}\">$ref->{accno}--$ref->{description}</option>\n";
189 $form->{$key} = $form->{"select$key"};
191 # if there is a value we have an old entry
195 for $i (1 .. scalar @{ $form->{acc_trans}{$key} }) {
196 if ($key eq "AR_paid") {
198 $form->{"AR_paid_$j"} =
199 "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
202 $form->{"paid_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{amount} * -1;
203 $form->{"datepaid_$j"} =
204 $form->{acc_trans}{$key}->[$i - 1]->{transdate};
205 $form->{"source_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{source};
206 $form->{"memo_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{memo};
208 $form->{"forex_$j"} = $form->{"exchangerate_$i"} =
209 $form->{acc_trans}{$key}->[$i - 1]->{exchangerate};
210 $form->{"AR_paid_$j"} = "$form->{acc_trans}{$key}->[$i-1]->{accno}";
211 $form->{"paid_project_id_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{project_id};
212 $form->{paidaccounts}++;
218 if ($key eq "AR_tax" || $key eq "AP_tax") {
219 $form->{"${key}_$form->{acc_trans}{$key}->[$i-1]->{accno}"} =
220 "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
221 $form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"} =
223 $form->{acc_trans}{$key}->[$i - 1]->{amount} / $exchangerate,
226 if ($form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"} > 0) {
228 $form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"};
230 $form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"};
233 $form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"};
235 $form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"};
237 $index = $form->{acc_trans}{$key}->[$i - 1]->{index};
238 $form->{"tax_$index"} = $form->{acc_trans}{$key}->[$i - 1]->{amount};
239 $totaltax += $form->{"tax_$index"};
243 $form->{"${akey}_$k"} =
245 $form->{acc_trans}{$key}->[$i - 1]->{amount} / $exchangerate,
247 if ($akey eq 'amount') {
249 $totalamount += $form->{"${akey}_$i"};
251 $form->{"oldprojectnumber_$k"} = $form->{"projectnumber_$k"} =
252 "$form->{acc_trans}{$key}->[$i-1]->{projectnumber}";
253 $form->{taxrate} = $form->{acc_trans}{$key}->[$i - 1]->{rate};
254 $form->{"project_id_$k"} =
255 "$form->{acc_trans}{$key}->[$i-1]->{project_id}";
257 $form->{"${key}_$k"} =
258 "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
259 $form->{"${key}_$i"} =
260 "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
261 my $q_description = quotemeta($form->{acc_trans}{$key}->[$i-1]->{description});
262 $form->{"select${key}"} =~
263 /<option value=\"($form->{acc_trans}{$key}->[$i-1]->{accno}--[^\"]*)\">$form->{acc_trans}{$key}->[$i-1]->{accno}--${q_description}<\/option>\n/;
264 $form->{"${key}_$k"} = $1;
265 if ($akey eq 'amount') {
266 $form->{"taxchart_$k"} = $form->{acc_trans}{$key}->[$i-1]->{id} .
267 "--" . $form->{acc_trans}{$key}->[$i-1]->{rate};
274 $form->{taxincluded} = $taxincluded if ($form->{id});
275 $form->{paidaccounts} = 1 if not defined $form->{paidaccounts};
277 if ($form->{taxincluded} && $form->{taxrate} && $totalamount) {
279 # add tax to amounts and invtotal
280 for $i (1 .. $form->{rowcount}) {
282 ($totaltax + $totalwithholding) * $form->{"amount_$i"} / $totalamount;
283 $tax = $form->round_amount($taxamount, 2);
284 $diff += ($taxamount - $tax);
285 $form->{"amount_$i"} += $form->{"tax_$i"};
287 $form->{amount_1} += $form->round_amount($diff, 2);
290 $taxamount = $form->round_amount($taxamount, 2);
291 $form->{tax} = $taxamount;
293 $form->{invtotal} = $totalamount + $totaltax;
296 ($form->datetonum($form->{transdate}, \%myconfig) <=
297 $form->datetonum($form->{closedto}, \%myconfig));
299 $form->{"ARselected"} = $form->{"AR_1"};
301 $lxdebug->leave_sub();
305 $lxdebug->enter_sub();
307 $title = $form->{title};
308 $form->{title} = $locale->text("$title Accounts Receivables Transaction");
310 $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
312 # $locale->text('Add Accounts Receivables Transaction')
313 # $locale->text('Edit Accounts Receivables Transaction')
314 $form->{javascript} = qq|<script type="text/javascript">
316 function setTaxkey(accno, row) {
317 var taxkey = accno.options[accno.selectedIndex].value;
318 var reg = /--([0-9]*)/;
319 var found = reg.exec(taxkey);
320 var index = found[1];
321 index = parseInt(index);
322 var tax = 'taxchart_' + row;
323 for (var i = 0; i < document.getElementById(tax).options.length; ++i) {
324 var reg2 = new RegExp("^"+ index, "");
325 if (reg2.exec(document.getElementById(tax).options[i].value)) {
326 document.getElementById(tax).options[i].selected = true;
333 # show history button js
334 $form->{javascript} .= qq|<script type="text/javascript" src="js/show_history.js"></script>|;
335 #/show history button js
337 $readonly = ($form->{id}) ? "readonly" : "";
340 ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0;
341 $readonly = ($form->{radier}) ? "" : $readonly;
343 my $ARselected_quoted = quotemeta($form->{"ARselected"});
344 $form->{selectAR} = $form->{AR};
346 s/value=\"${ARselected_quoted}\"/value=\"$form->{ARselected}\" selected/;
348 # set option selected
349 foreach $item (qw(customer currency department employee)) {
350 $form->{"select$item"} =~ s/ selected//;
351 $form->{"select$item"} =~
352 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
354 $selectAR_amount_unquoted = $form->{selectAR_amount};
355 map { $form->{$_} =~ s/\"/"/g }
356 qw(AR_amount selectAR_amount AR);
359 $form->{exchangerate} =
360 $form->format_amount(\%myconfig, $form->{exchangerate});
362 $form->{creditlimit} =
363 $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
364 $form->{creditremaining} =
365 $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
368 <input type=hidden name=forex value=$form->{forex}>
370 if ($form->{currency} ne $form->{defaultcurrency}) {
371 if ($form->{forex}) {
373 <th align=right>| . $locale->text('Exchangerate') . qq|</th>
374 <td><input type=hidden name=exchangerate value=$form->{exchangerate}>$form->{exchangerate}</td>
378 <th align=right>| . $locale->text('Exchangerate') . qq|</th>
379 <td><input name=exchangerate size=10 value=$form->{exchangerate}></td>
388 <td align=right><input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}></td>
389 <th align=left nowrap>| . $locale->text('Tax Included') . qq|</th>
393 if (($rows = $form->numtextrows($form->{notes}, 50)) < 2) {
397 qq|<textarea name=notes rows=$rows cols=50 wrap=soft>$form->{notes}</textarea>|;
401 <th align="right" nowrap>| . $locale->text('Department') . qq|</th>
402 <td colspan=3><select name=department>$form->{selectdepartment}</select>
403 <input type=hidden name=selectdepartment value="$form->{selectdepartment}">
406 | if $form->{selectdepartment};
408 $n = ($form->{creditremaining} =~ /-/) ? "0" : "1";
411 ($form->{selectcustomer})
412 ? qq|<select name=customer>$form->{selectcustomer}</select>|
413 : qq|<input name=customer value="$form->{customer}" size=35>|;
416 <input type=hidden name=employee value="$form->{employee}">
419 if ($form->{selectemployee}) {
422 <th align=right nowrap>| . $locale->text('Salesperson') . qq|</th>
423 <td colspan=2><select name=employee>$form->{selectemployee}</select></td>
424 <input type=hidden name=selectemployee value="$form->{selectemployee}">
429 my @old_project_ids = ();
430 map({ push(@old_project_ids, $form->{"project_id_$_"})
431 if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
433 $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
435 "old_id" => \@old_project_ids },
436 "taxcharts" => "ALL_TAXCHARTS");
438 my %project_labels = ();
439 my @project_values = ("");
440 foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
441 push(@project_values, $item->{"id"});
442 $project_labels{$item->{"id"}} = $item->{"projectnumber"};
445 my %taxchart_labels = ();
446 my @taxchart_values = ();
447 foreach my $item (@{ $form->{ALL_TAXCHARTS} }) {
448 my $key = Q($item->{id}) . "--" . Q($item->{rate});
449 $taxchart_init = $key if ($taxchart_init eq $item->{taxkey});
450 push(@taxchart_values, $key);
451 $taxchart_labels{$key} = H($item->{taxdescription}) . " " .
452 H($item->{rate} * 100) . ' %';
455 $form->{fokus} = "arledger.customer";
457 # use JavaScript Calendar or not
458 $form->{jsscript} = $jscalendar;
460 if ($form->{jsscript}) {
462 # with JavaScript Calendar
464 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>
465 <td><input type=button name=transdate id="trigger1" value=|
466 . $locale->text('button') . qq|></td>
469 <td><input name=duedate id=duedate size=11 title="$myconfig{dateformat}" value=$form->{duedate}></td>
470 <td><input type=button name=duedate id="trigger2" value=|
471 . $locale->text('button') . qq|></td></td>
476 Form->write_trigger(\%myconfig, "2", "transdate", "BL", "trigger1",
477 "duedate", "BL", "trigger2");
480 # without JavaScript Calendar
482 qq|<td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>|;
484 qq|<td><input name=duedate id=duedate size=11 title="$myconfig{dateformat}" value=$form->{duedate}></td>|;
490 <body onLoad="fokus()">
492 <form method=post name="arledger" action=$form->{script}>
494 <input type=hidden name=id value=$form->{id}>
495 <input type=hidden name=sort value=$form->{sort}>
496 <input type=hidden name=closedto value=$form->{closedto}>
497 <input type=hidden name=locked value=$form->{locked}>
498 <input type=hidden name=title value="$title">
500 | . ($form->{saved_message} ? qq|<p>$form->{saved_message}</p>| : "") . qq|
504 <th class=listtop>$form->{title}</th>
514 <th align="right" nowrap>| . $locale->text('Customer') . qq|</th>
515 <td colspan=3>$customer</td>
516 <input type=hidden name=selectcustomer value="$form->{selectcustomer}">
517 <input type=hidden name=oldcustomer value="$form->{oldcustomer}">
518 <input type=hidden name=customer_id value="$form->{customer_id}">
519 <input type=hidden name=terms value=$form->{terms}>
526 <th align=left nowrap>| . $locale->text('Credit Limit') . qq|</th>
527 <td>$form->{creditlimit}</td>
528 <th align=left nowrap>| . $locale->text('Remaining') . qq|</th>
529 <td class="plus$n">$form->{creditremaining}</td>
530 <input type=hidden name=creditlimit value=$form->{creditlimit}>
531 <input type=hidden name=creditremaining value=$form->{creditremaining}>
537 <th align=right>| . $locale->text('Currency') . qq|</th>
538 <td><select name=currency>$form->{selectcurrency}</select></td>
539 <input type=hidden name=selectcurrency value="$form->{selectcurrency}">
540 <input type=hidden name=defaultcurrency value=$form->{defaultcurrency}>
541 <input type=hidden name=fxgain_accno value=$form->{fxgain_accno}>
542 <input type=hidden name=fxloss_accno value=$form->{fxloss_accno}>
553 <th align=right nowrap>| . $locale->text('Invoice Number') . qq|</th>
554 <td><input name=invnumber size=11 value="$form->{invnumber}"></td>
557 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
558 <td><input name=ordnumber size=11 value="$form->{ordnumber}"></td>
561 <th align=right nowrap>| . $locale->text('Invoice Date') . qq|</th>
565 <th align=right nowrap>| . $locale->text('Due Date') . qq|</th>
576 <input type=hidden name=selectAR_amount value="$form->{selectAR_amount}">
577 <input type=hidden name=AR_amount value="$form->{AR_amount}">
578 <input type=hidden name=rowcount value=$form->{rowcount}>
582 <tr class=listheading>
583 <th class=listheading style="width:15%">|
584 . $locale->text('Account') . qq|</th>
585 <th class=listheading style="width:10%">|
586 . $locale->text('Amount') . qq|</th>
587 <th class=listheading style="width:10%">|
588 . $locale->text('Tax') . qq|</th>
589 <th class=listheading style="width:5%">|
590 . $locale->text('Korrektur') . qq|</th>
591 <th class=listheading style="width:10%">|
592 . $locale->text('Taxkey') . qq|</th>
593 <th class=listheading style="width:10%">|
594 . $locale->text('Project') . qq|</th>
598 $amount = $locale->text('Amount');
599 $project = $locale->text('Project');
601 for $i (1 .. $form->{rowcount}) {
604 $form->{"amount_$i"} =
605 $form->format_amount(\%myconfig, $form->{"amount_$i"}, 2);
606 $form->{"tax_$i"} = $form->format_amount(\%myconfig, $form->{"tax_$i"}, 2);
607 $selectAR_amount = $selectAR_amount_unquoted;
609 s/option value=\"$form->{"AR_amount_$i"}\"/option value=\"$form->{"AR_amount_$i"}\" selected/;
612 $cgi->popup_menu('-name' => "taxchart_$i",
613 '-id' => "taxchart_$i",
614 '-style' => 'width:200px',
615 '-tabindex' => ($i + 10 + (($i - 1) * 8)),
616 '-values' => \@taxchart_values,
617 '-labels' => \%taxchart_labels,
618 '-default' => $form->{"taxchart_$i"})
621 $korrektur_checked = ($form->{"korrektur_$i"} ? 'checked' : '');
624 NTI($cgi->popup_menu('-name' => "project_id_$i",
625 '-values' => \@project_values,
626 '-labels' => \%project_labels,
627 '-default' => $form->{"project_id_$i"} ));
631 <td width=50%><select name="AR_amount_$i" onChange="setTaxkey(this, $i)" style="width:100%">$selectAR_amount</select></td>
632 <td><input name="amount_$i" size=10 value=$form->{"amount_$i"}></td>
633 <td><input name="tax_$i" size=10 value=$form->{"tax_$i"}></td>
634 <td><input type="checkbox" name="korrektur_$i" value="1" $korrektur_checked></td>
636 <td>$projectnumber</td>
643 $form->{invtotal} = $form->format_amount(\%myconfig, $form->{invtotal}, 2);
652 <td><select name=ARselected>$form->{selectAR}</select></td>
653 <input type=hidden name=AR value="$form->{AR}">
654 <th align=left>$form->{invtotal}</th>
656 <input type=hidden name=oldinvtotal value=$form->{oldinvtotal}>
657 <input type=hidden name=oldtotalpaid value=$form->{oldtotalpaid}>
659 <input type=hidden name=taxaccounts value="$form->{taxaccounts}">
672 <th align=left width=1%>| . $locale->text('Notes') . qq|</th>
673 <td align=left>$notes</td>
681 <tr class=listheading>
682 <th colspan=7 class=listheading>|
683 . $locale->text('Incoming Payments') . qq|</th>
687 if ($form->{currency} eq $form->{defaultcurrency}) {
688 @column_index = qw(datepaid source memo paid AR_paid paid_project_id);
690 @column_index = qw(datepaid source memo paid exchangerate AR_paid paid_project_id);
693 $column_data{datepaid} = "<th>" . $locale->text('Date') . "</th>";
694 $column_data{paid} = "<th>" . $locale->text('Amount') . "</th>";
695 $column_data{exchangerate} = "<th>" . $locale->text('Exch') . "</th>";
696 $column_data{AR_paid} = "<th>" . $locale->text('Account') . "</th>";
697 $column_data{source} = "<th>" . $locale->text('Source') . "</th>";
698 $column_data{memo} = "<th>" . $locale->text('Memo') . "</th>";
699 $column_data{paid_project_id} = "<th>" . $locale->text('Project Number') . "</th>";
704 map { print "$column_data{$_}\n" } @column_index;
710 $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
711 for $i (1 .. $form->{paidaccounts}) {
716 $form->{"selectAR_paid_$i"} = $form->{selectAR_paid};
717 $form->{"selectAR_paid_$i"} =~
718 s/option value=\"$form->{"AR_paid_$i"}\">/option value=\"$form->{"AR_paid_$i"}\" selected>/;
721 if ($form->{"paid_$i"}) {
723 $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2);
725 $form->{"exchangerate_$i"} =
726 $form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
728 $exchangerate = qq| |;
729 if ($form->{currency} ne $form->{defaultcurrency}) {
730 if ($form->{"forex_$i"}) {
732 qq|<input type=hidden name="exchangerate_$i" value=$form->{"exchangerate_$i"}>$form->{"exchangerate_$i"}|;
735 qq|<input name="exchangerate_$i" size=10 value=$form->{"exchangerate_$i"}>|;
740 <input type=hidden name="forex_$i" value=$form->{"forex_$i"}>
744 qq|<td align=center><input name="paid_$i" size=11 value=$form->{"paid_$i"}></td>|;
745 $column_data{AR_paid} =
746 qq|<td align=center><select name="AR_paid_$i">$form->{"selectAR_paid_$i"}</select></td>|;
747 $column_data{exchangerate} = qq|<td align=center>$exchangerate</td>|;
748 $column_data{datepaid} =
749 qq|<td align=center><input name="datepaid_$i" id="datepaid_$i" size=11 value=$form->{"datepaid_$i"}>
750 <input type="button" name="datepaid_$i" id="trigger_datepaid_$i" value="?"></td>|;
751 $column_data{source} =
752 qq|<td align=center><input name="source_$i" size=11 value="$form->{"source_$i"}"></td>|;
754 qq|<td align=center><input name="memo_$i" size=11 value="$form->{"memo_$i"}"></td>|;
756 $column_data{paid_project_id} =
758 . NTI($cgi->popup_menu('-name' => "paid_project_id_$i",
759 '-values' => \@project_values,
760 '-labels' => \%project_labels,
761 '-default' => $form->{"paid_project_id_$i"} ))
764 map { print qq|$column_data{$_}\n| } @column_index;
769 push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i");
771 map { $form->{$_} =~ s/\"/"/g } qw(selectAR_paid);
773 print $form->write_trigger(\%myconfig, scalar(@triggers) / 3, @triggers) .
775 <input type=hidden name=paidaccounts value=$form->{paidaccounts}>
776 <input type=hidden name=selectAR_paid value="$form->{selectAR_paid}">
782 <td><hr size=3 noshade></td>
787 $lxdebug->leave_sub();
791 $lxdebug->enter_sub();
795 <input name=gldate type=hidden value="| . Q($form->{gldate}) . qq|">
797 <input name=callback type=hidden value="$form->{callback}">
799 <input type=hidden name=path value=$form->{path}>
800 <input type=hidden name=login value=$form->{login}>
801 <input type=hidden name=password value=$form->{password}>
803 . $cgi->hidden('-name' => 'draft_id', '-default' => [$form->{draft_id}])
804 . $cgi->hidden('-name' => 'draft_description', '-default' => [$form->{draft_description}])
810 $transdate = $form->datetonum($form->{transdate}, \%myconfig);
811 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
813 print qq|<input class=submit type=submit name=action value="|
814 . $locale->text('Update') . qq|">
817 if ($form->{radier}) {
819 <input class=submit type=submit name=action value="|
820 . $locale->text('Post') . qq|">
821 <input class=submit type=submit name=action value="|
822 . $locale->text('Delete') . qq|">
825 if ($transdate > $closedto) {
827 <input class=submit type=submit name=action value="|
828 . $locale->text('Use As Template') . qq|">
832 <input class=submit type=submit name=action value="|
833 . $locale->text('Post Payment') . qq|">
837 if ($transdate > $closedto) {
838 print qq|<input class=submit type=submit name=action value="|
839 . $locale->text('Post') . qq|"> | .
840 NTI($cgi->submit('-name' => 'action', '-value' => $locale->text('Save draft'),
841 '-class' => 'submit'));
845 if ($form->{menubar}) {
846 require "$form->{path}/menu.pl";
849 # button for saving history
850 if($form->{id} ne "") {
852 <input type=button class=submit onclick=set_history_window(|
854 . qq|); name=history id=history value=|
855 . $locale->text('history')
858 # /button for saving history
866 $lxdebug->leave_sub();
870 $lxdebug->enter_sub();
874 $form->{invtotal} = 0;
876 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
877 qw(exchangerate creditlimit creditremaining);
879 @flds = qw(amount AR_amount projectnumber oldprojectnumber project_id);
883 for $i (1 .. $form->{rowcount}) {
884 $form->{"amount_$i"} =
885 $form->parse_amount(\%myconfig, $form->{"amount_$i"});
886 $form->{"tax_$i"} = $form->parse_amount(\%myconfig, $form->{"tax_$i"});
887 if ($form->{"amount_$i"}) {
890 if (!$form->{"korrektur_$i"}) {
891 ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
893 if ($form->{taxincluded}) {
894 $form->{"tax_$i"} = $form->{"amount_$i"} / ($rate + 1) * $rate;
896 $form->{"tax_$i"} = $form->{"amount_$i"} * $rate;
899 $form->{"tax_$i"} = 0;
902 $form->{"tax_$i"} = $form->round_amount($form->{"tax_$i"}, 2);
904 $totaltax += $form->{"tax_$i"};
905 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
910 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
911 $form->{rowcount} = $count + 1;
912 map { $form->{invtotal} += $form->{"amount_$_"} } (1 .. $form->{rowcount});
914 $form->{exchangerate} = $exchangerate
918 $form->check_exchangerate(
919 \%myconfig, $form->{currency}, $form->{transdate}, 'buy'
922 $form->{invdate} = $form->{transdate};
923 $save_AR = $form->{AR};
924 &check_name(customer);
925 $form->{AR} = $save_AR;
928 ($form->{taxincluded}) ? $form->{invtotal} : $form->{invtotal} + $totaltax;
930 for $i (1 .. $form->{paidaccounts}) {
931 if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
934 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
935 } qw(paid exchangerate);
937 $totalpaid += $form->{"paid_$i"};
939 $form->{"exchangerate_$i"} = $exchangerate
941 $form->{"forex_$i"} = (
943 $form->check_exchangerate(
944 \%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'buy'
949 $form->{creditremaining} -=
950 ($form->{invtotal} - $totalpaid + $form->{oldtotalpaid} -
951 $form->{oldinvtotal});
952 $form->{oldinvtotal} = $form->{invtotal};
953 $form->{oldtotalpaid} = $totalpaid;
957 $lxdebug->leave_sub();
961 $lxdebug->enter_sub();
962 for $i (1 .. $form->{paidaccounts}) {
963 if ($form->{"paid_$i"}) {
964 $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
966 $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
968 $form->error($locale->text('Cannot post payment for a closed period!'))
969 if ($datepaid <= $closedto);
971 if ($form->{currency} ne $form->{defaultcurrency}) {
972 $form->{"exchangerate_$i"} = $form->{exchangerate}
973 if ($invdate == $datepaid);
974 $form->isblank("exchangerate_$i",
975 $locale->text('Exchangerate for payment missing!'));
980 ($form->{AR}) = split /--/, $form->{AR};
981 ($form->{AR_paid}) = split /--/, $form->{AR_paid};
982 $form->redirect($locale->text(' Payment posted!'))
983 if (AR->post_payment(\%myconfig, \%$form));
984 $form->error($locale->text('Cannot post payment!'));
987 $lxdebug->leave_sub();
991 $lxdebug->enter_sub();
993 # check if there is an invoice number, invoice and due date
994 $form->isblank("transdate", $locale->text('Invoice Date missing!'));
995 $form->isblank("duedate", $locale->text('Due Date missing!'));
996 $form->isblank("customer", $locale->text('Customer missing!'));
998 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
999 $transdate = $form->datetonum($form->{transdate}, \%myconfig);
1001 $form->error($locale->text('Cannot post transaction for a closed period!'))
1002 if ($transdate <= $closedto);
1004 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
1005 if ($form->{currency} ne $form->{defaultcurrency});
1007 delete($form->{AR});
1009 for $i (1 .. $form->{paidaccounts}) {
1010 if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
1011 $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
1013 $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
1015 $form->error($locale->text('Cannot post payment for a closed period!'))
1016 if ($datepaid <= $closedto);
1018 if ($form->{currency} ne $form->{defaultcurrency}) {
1019 $form->{"exchangerate_$i"} = $form->{exchangerate}
1020 if ($transdate == $datepaid);
1021 $form->isblank("exchangerate_$i",
1022 $locale->text('Exchangerate for payment missing!'));
1027 # if oldcustomer ne customer redo form
1028 ($customer) = split /--/, $form->{customer};
1029 if ($form->{oldcustomer} ne "$customer--$form->{customer_id}") {
1034 my ($creditaccno, $credittaxkey) = split /--/, $form->{AR_amountselected};
1035 my ($receivablesaccno, $payablestaxkey) = split /--/, $form->{ARselected};
1036 $form->{AR}{amount_1} = $creditaccno;
1037 $form->{AR}{receivables} = $receivablesaccno;
1039 $form->{invnumber} = $form->update_defaults(\%myconfig, "invnumber")
1040 unless $form->{invnumber};
1042 $form->{id} = 0 if $form->{postasnew};
1043 if (AR->post_transaction(\%myconfig, \%$form)) {
1044 # saving the history
1045 if(!exists $form->{addition} && $form->{id} ne "") {
1046 $form->{addition} = "POSTED";
1047 $form->save_history($form->dbconnect(\%myconfig));
1049 # /saving the history
1050 remove_draft() if $form->{remove_draft};
1051 $form->redirect($locale->text('Transaction posted!'));
1053 $form->error($locale->text('Cannot post transaction!'));
1055 $lxdebug->leave_sub();
1059 $lxdebug->enter_sub();
1061 $form->{postasnew} = 1;
1062 # saving the history
1063 if(!exists $form->{addition} && $form->{id} ne "") {
1064 $form->{addition} = "POSTED AS NEW";
1065 $form->save_history($form->dbconnect(\%myconfig));
1067 # /saving the history
1070 $lxdebug->leave_sub();
1073 sub use_as_template {
1074 $lxdebug->enter_sub();
1076 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);
1077 $form->{paidaccounts} = 1;
1078 $form->{rowcount}--;
1079 $form->{invdate} = $form->current_date(\%myconfig);
1082 $lxdebug->leave_sub();
1086 $lxdebug->enter_sub();
1088 $form->{title} = $locale->text('Confirm!');
1092 delete $form->{header};
1097 <form method=post action=$form->{script}>
1100 foreach $key (keys %$form) {
1101 $form->{$key} =~ s/\"/"/g;
1102 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
1106 <h2 class=confirm>$form->{title}</h2>
1109 . $locale->text('Are you sure you want to delete Transaction')
1110 . qq| $form->{invnumber}</h4>
1112 <input name=action class=submit type=submit value="|
1113 . $locale->text('Yes') . qq|">
1120 $lxdebug->leave_sub();
1124 $lxdebug->enter_sub();
1125 if (AR->delete_transaction(\%myconfig, \%$form, $spool)) {
1126 # saving the history
1127 if(!exists $form->{addition}) {
1128 $form->{addition} = "DELETED";
1129 $form->save_history($form->dbconnect(\%myconfig));
1131 # /saving the history
1132 $form->redirect($locale->text('Transaction deleted!'));
1134 $form->error($locale->text('Cannot delete transaction!'));
1136 $lxdebug->leave_sub();
1140 $lxdebug->enter_sub();
1142 # setup customer selection
1143 $form->all_vc(\%myconfig, "customer", "AR");
1145 if (@{ $form->{all_customer} }) {
1146 map { $customer .= "<option>$_->{name}--$_->{id}\n" }
1147 @{ $form->{all_customer} };
1148 $customer = qq|<select name=customer><option>\n$customer</select>|;
1150 $customer = qq|<input name=customer size=35>|;
1154 if (@{ $form->{all_departments} }) {
1155 $form->{selectdepartment} = "<option>\n";
1158 $form->{selectdepartment} .=
1159 "<option>$_->{description}--$_->{id}\n"
1160 } (@{ $form->{all_departments} });
1165 <th align=right nowrap>| . $locale->text('Department') . qq|</th>
1166 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
1168 | if $form->{selectdepartment};
1170 $form->{title} = $locale->text('AR Transactions');
1172 # use JavaScript Calendar or not
1173 $form->{jsscript} = $jscalendar;
1175 if ($form->{jsscript}) {
1177 # with JavaScript Calendar
1179 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}">
1180 <input type=button name=transdatefrom id="trigger1" value=|
1181 . $locale->text('button') . qq|></td>
1184 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}">
1185 <input type=button name=transdateto name=transdateto id="trigger2" value=|
1186 . $locale->text('button') . qq|></td>
1191 Form->write_trigger(\%myconfig, "2", "transdatefrom", "BR", "trigger1",
1192 "transdateto", "BL", "trigger2");
1195 # without JavaScript Calendar
1197 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>|;
1199 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}"></td>|;
1202 $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
1207 foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
1208 push(@values, $item->{"id"});
1209 $labels{$item->{"id"}} = $item->{"projectnumber"};
1212 NTI($cgi->popup_menu('-name' => 'project_id', '-values' => \@values,
1213 '-labels' => \%labels));
1215 $form->{fokus} = "search.customer";
1219 <body onLoad="fokus()">
1221 <form method=post name="search" action=$form->{script}>
1224 <tr><th class=listtop>$form->{title}</th></tr>
1225 <tr height="5"></tr>
1230 <th align=right>| . $locale->text('Customer') . qq|</th>
1231 <td colspan=3>$customer</td>
1235 <th align=right nowrap>| . $locale->text('Invoice Number') . qq|</th>
1236 <td colspan=3><input name=invnumber size=20></td>
1239 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
1240 <td colspan=3><input name=ordnumber size=20></td>
1243 <th align=right nowrap>| . $locale->text('Notes') . qq|</th>
1244 <td colspan=3><input name=notes size=40></td>
1247 <th align="right">| . $locale->text("Project Number") . qq|</th>
1248 <td colspan="3">$projectnumber</td>
1251 <th align=right nowrap>| . $locale->text('From') . qq|</th>
1253 <th align=right>| . $locale->text('Bis') . qq|</th>
1256 <input type=hidden name=sort value=transdate>
1264 <th align=right nowrap>| . $locale->text('Include in Report') . qq|</th>
1268 <td align=right><input name=open class=checkbox type=checkbox value=Y checked></td>
1269 <td nowrap>| . $locale->text('Open') . qq|</td>
1270 <td align=right><input name=closed class=checkbox type=checkbox value=Y></td>
1271 <td nowrap>| . $locale->text('Closed') . qq|</td>
1274 <td align=right><input name="l_id" class=checkbox type=checkbox value=Y></td>
1275 <td nowrap>| . $locale->text('ID') . qq|</td>
1276 <td align=right><input name="l_invnumber" class=checkbox type=checkbox value=Y checked></td>
1277 <td nowrap>| . $locale->text('Invoice Number') . qq|</td>
1278 <td align=right><input name="l_ordnumber" class=checkbox type=checkbox value=Y></td>
1279 <td nowrap>| . $locale->text('Order Number') . qq|</td>
1280 <td align=right><input name="l_transdate" class=checkbox type=checkbox value=Y checked></td>
1281 <td nowrap>| . $locale->text('Invoice Date') . qq|</td>
1284 <td align=right><input name="l_name" class=checkbox type=checkbox value=Y checked></td>
1285 <td nowrap>| . $locale->text('Customer') . qq|</td>
1286 <td align=right><input name="l_netamount" class=checkbox type=checkbox value=Y></td>
1287 <td nowrap>| . $locale->text('Amount') . qq|</td>
1288 <td align=right><input name="l_tax" class=checkbox type=checkbox value=Y></td>
1289 <td nowrap>| . $locale->text('Tax') . qq|</td>
1290 <td align=right><input name="l_amount" class=checkbox type=checkbox value=Y checked></td>
1291 <td nowrap>| . $locale->text('Total') . qq|</td>
1294 <td align=right><input name="l_datepaid" class=checkbox type=checkbox value=Y></td>
1295 <td nowrap>| . $locale->text('Date Paid') . qq|</td>
1296 <td align=right><input name="l_paid" class=checkbox type=checkbox value=Y checked></td>
1297 <td nowrap>| . $locale->text('Paid') . qq|</td>
1298 <td align=right><input name="l_duedate" class=checkbox type=checkbox value=Y></td>
1299 <td nowrap>| . $locale->text('Due Date') . qq|</td>
1300 <td align=right><input name="l_due" class=checkbox type=checkbox value=Y></td>
1301 <td nowrap>| . $locale->text('Amount Due') . qq|</td>
1304 <td align=right><input name="l_notes" class=checkbox type=checkbox value=Y></td>
1305 <td nowrap>| . $locale->text('Notes') . qq|</td>
1306 <td align=right><input name="l_employee" class=checkbox type=checkbox value=Y></td>
1307 <td nowrap>| . $locale->text('Salesperson') . qq|</td>
1308 <td align=right><input name="l_shippingpoint" class=checkbox type=checkbox value=Y></td>
1309 <td nowrap>| . $locale->text('Shipping Point') . qq|</td>
1310 <td align=right><input name="l_shipvia" class=checkbox type=checkbox value=Y></td>
1311 <td nowrap>| . $locale->text('Ship via') . qq|</td>
1314 <td align=right><input name="l_subtotal" class=checkbox type=checkbox value=Y></td>
1315 <td nowrap>| . $locale->text('Subtotal') . qq|</td>
1316 <td align=right><input name="l_globalprojectnumber" class=checkbox type=checkbox value=Y></td>
1317 <td nowrap>| . $locale->text('Project Number') . qq|</td>
1326 <td><hr size=3 noshade></td>
1330 <input type=hidden name=nextsub value=$form->{nextsub}>
1332 <input type=hidden name=path value=$form->{path}>
1333 <input type=hidden name=login value=$form->{login}>
1334 <input type=hidden name=password value=$form->{password}>
1337 <input class=submit type=submit name=action value="|
1338 . $locale->text('Continue') . qq|">
1349 $lxdebug->leave_sub();
1352 sub ar_transactions {
1353 $lxdebug->enter_sub();
1355 $form->{customer} = $form->unescape($form->{customer});
1356 ($form->{customer}, $form->{customer_id}) = split(/--/, $form->{customer});
1358 AR->ar_transactions(\%myconfig, \%$form);
1361 "$form->{script}?action=ar_transactions&path=$form->{path}&login=$form->{login}&password=$form->{password}";
1364 if ($form->{customer}) {
1365 $callback .= "&customer=" . $form->escape($form->{customer}, 1);
1366 $href .= "&customer=" . $form->escape($form->{customer});
1367 $option = $locale->text('Customer') . " : $form->{customer}";
1369 if ($form->{department}) {
1370 $callback .= "&department=" . $form->escape($form->{department}, 1);
1371 $href .= "&department=" . $form->escape($form->{department});
1372 ($department) = split /--/, $form->{department};
1373 $option .= "\n<br>" if ($option);
1374 $option .= $locale->text('Department') . " : $department";
1376 if ($form->{invnumber}) {
1377 $callback .= "&invnumber=" . $form->escape($form->{invnumber}, 1);
1378 $href .= "&invnumber=" . $form->escape($form->{invnumber});
1379 $option .= "\n<br>" if ($option);
1380 $option .= $locale->text('Invoice Number') . " : $form->{invnumber}";
1382 if ($form->{ordnumber}) {
1383 $callback .= "&ordnumber=" . $form->escape($form->{ordnumber}, 1);
1384 $href .= "&ordnumber=" . $form->escape($form->{ordnumber});
1385 $option .= "\n<br>" if ($option);
1386 $option .= $locale->text('Order Number') . " : $form->{ordnumber}";
1388 if ($form->{notes}) {
1389 $callback .= "¬es=" . $form->escape($form->{notes}, 1);
1390 $href .= "¬es=" . $form->escape($form->{notes});
1391 $option .= "\n<br>" if $option;
1392 $option .= $locale->text('Notes') . " : $form->{notes}";
1395 if ($form->{transdatefrom}) {
1396 $callback .= "&transdatefrom=$form->{transdatefrom}";
1397 $href .= "&transdatefrom=$form->{transdatefrom}";
1398 $option .= "\n<br>" if ($option);
1400 $locale->text('From') . " "
1401 . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
1403 if ($form->{transdateto}) {
1404 $callback .= "&transdateto=$form->{transdateto}";
1405 $href .= "&transdateto=$form->{transdateto}";
1406 $option .= "\n<br>" if ($option);
1408 $locale->text('Bis') . " "
1409 . $locale->date(\%myconfig, $form->{transdateto}, 1);
1411 if ($form->{open}) {
1412 $callback .= "&open=$form->{open}";
1413 $href .= "&open=$form->{open}";
1414 $option .= "\n<br>" if ($option);
1415 $option .= $locale->text('Open');
1417 if ($form->{closed}) {
1418 $callback .= "&closed=$form->{closed}";
1419 $href .= "&closed=$form->{closed}";
1420 $option .= "\n<br>" if ($option);
1421 $option .= $locale->text('Closed');
1423 if ($form->{globalproject_id}) {
1424 $callback .= "&globalproject_id=" . E($form->{globalproject_id});
1425 $href .= "&globalproject_id=" . E($form->{globalproject_id});
1429 qw(transdate id type invnumber ordnumber name netamount tax amount paid
1430 datepaid due duedate notes employee shippingpoint shipvia
1431 globalprojectnumber);
1433 $form->{"l_type"} = "Y";
1435 foreach $item (@columns) {
1436 if ($form->{"l_$item"} eq "Y") {
1437 push @column_index, $item;
1439 # add column to href and callback
1440 $callback .= "&l_$item=Y";
1441 $href .= "&l_$item=Y";
1445 if ($form->{l_subtotal} eq 'Y') {
1446 $callback .= "&l_subtotal=Y";
1447 $href .= "&l_subtotal=Y";
1450 $column_header{id} =
1451 "<th><a class=listheading href=$href&sort=id>"
1452 . $locale->text('ID')
1454 $column_header{transdate} =
1455 "<th><a class=listheading href=$href&sort=transdate>"
1456 . $locale->text('Date')
1458 $column_header{duedate} =
1459 "<th><a class=listheading href=$href&sort=duedate>"
1460 . $locale->text('Due Date')
1462 $column_header{type} =
1463 "<th class=\"listheading\">" . $locale->text('Type') . "</th>";
1464 $column_header{invnumber} =
1465 "<th><a class=listheading href=$href&sort=invnumber>"
1466 . $locale->text('Invoice')
1468 $column_header{ordnumber} =
1469 "<th><a class=listheading href=$href&sort=ordnumber>"
1470 . $locale->text('Order')
1472 $column_header{name} =
1473 "<th><a class=listheading href=$href&sort=name>"
1474 . $locale->text('Customer')
1476 $column_header{netamount} =
1477 "<th class=listheading>" . $locale->text('Amount') . "</th>";
1478 $column_header{tax} =
1479 "<th class=listheading>" . $locale->text('Tax') . "</th>";
1480 $column_header{amount} =
1481 "<th class=listheading>" . $locale->text('Total') . "</th>";
1482 $column_header{paid} =
1483 "<th class=listheading>" . $locale->text('Paid') . "</th>";
1484 $column_header{datepaid} =
1485 "<th><a class=listheading href=$href&sort=datepaid>"
1486 . $locale->text('Date Paid')
1488 $column_header{due} =
1489 "<th class=listheading>" . $locale->text('Amount Due') . "</th>";
1490 $column_header{notes} =
1491 "<th class=listheading>" . $locale->text('Notes') . "</th>";
1492 $column_header{employee} =
1493 "<th><a class=listheading href=$href&sort=employee>"
1494 . $locale->text('Salesperson') . "</th>";
1496 $column_header{shippingpoint} =
1497 "<th><a class=listheading href=$href&sort=shippingpoint>"
1498 . $locale->text('Shipping Point')
1500 $column_header{shipvia} =
1501 "<th><a class=listheading href=$href&sort=shipvia>"
1502 . $locale->text('Ship via')
1504 $column_header{globalprojectnumber} =
1505 qq|<th class="listheading">| . $locale->text('Project Number') . qq|</th>|;
1507 $form->{title} = $locale->text('AR Transactions');
1516 <th class=listtop>$form->{title}</th>
1518 <tr height="5"></tr>
1525 <tr class=listheading>
1528 map { print "\n$column_header{$_}" } @column_index;
1534 # add sort and escape callback, this one we use for the add sub
1535 $form->{callback} = $callback .= "&sort=$form->{sort}";
1537 # escape callback for href
1538 $callback = $form->escape($callback);
1540 if (@{ $form->{AR} }) {
1541 $sameitem = $form->{AR}->[0]->{ $form->{sort} };
1544 # sums and tax on reports by Antonio Gallardo
1546 foreach $ar (@{ $form->{AR} }) {
1548 if ($form->{l_subtotal} eq 'Y') {
1549 if ($sameitem ne $ar->{ $form->{sort} }) {
1554 $column_data{netamount} =
1556 . $form->format_amount(\%myconfig, $ar->{netamount}, 2, " ")
1558 $column_data{tax} = "<td align=right>"
1559 . $form->format_amount(\%myconfig, $ar->{amount} - $ar->{netamount},
1562 $column_data{amount} =
1564 . $form->format_amount(\%myconfig, $ar->{amount}, 2, " ") . "</td>";
1565 $column_data{paid} =
1567 . $form->format_amount(\%myconfig, $ar->{paid}, 2, " ") . "</td>";
1568 $column_data{due} = "<td align=right>"
1569 . $form->format_amount(\%myconfig, $ar->{amount} - $ar->{paid},
1573 $subtotalnetamount += $ar->{netamount};
1574 $subtotalamount += $ar->{amount};
1575 $subtotalpaid += $ar->{paid};
1576 $subtotaldue += $ar->{amount} - $ar->{paid};
1578 $totalnetamount += $ar->{netamount};
1579 $totalamount += $ar->{amount};
1580 $totalpaid += $ar->{paid};
1581 $totaldue += ($ar->{amount} - $ar->{paid});
1583 $column_data{transdate} = "<td>$ar->{transdate} </td>";
1584 $column_data{id} = "<td>$ar->{id}</td>";
1585 $column_data{datepaid} = "<td>$ar->{datepaid} </td>";
1586 $column_data{duedate} = "<td>$ar->{duedate} </td>";
1588 $module = ($ar->{invoice}) ? "is.pl" : $form->{script};
1590 $column_data{invnumber} =
1591 "<td><a href=$module?action=edit&id=$ar->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ar->{invnumber}</a></td>";
1592 $column_data{type} = "<td>" .
1593 ($ar->{storno} ? $locale->text("Storno (one letter abbreviation)") :
1595 $locale->text("Credit note (one letter abbreviation)") :
1596 $locale->text("Invoice (one letter abbreviation)")) . "</td>";
1597 $column_data{ordnumber} = "<td>$ar->{ordnumber} </td>";
1598 $column_data{name} = "<td>$ar->{name}</td>";
1599 $ar->{notes} =~ s/\r\n/<br>/g;
1600 $column_data{notes} = "<td>$ar->{notes} </td>";
1601 $column_data{shippingpoint} = "<td>$ar->{shippingpoint} </td>";
1602 $column_data{shipvia} = "<td>$ar->{shipvia} </td>";
1603 $column_data{employee} = "<td>$ar->{employee} </td>";
1604 $column_data{globalprojectnumber} =
1605 "<td>" . H($ar->{globalprojectnumber}) . "</td>";
1610 <tr class=listrow$i>
1613 map { print "\n$column_data{$_}" } @column_index;
1621 if ($form->{l_subtotal} eq 'Y') {
1627 <tr class=listtotal>
1630 map { $column_data{$_} = "<td> </td>" } @column_index;
1632 $column_data{netamount} =
1633 "<th class=listtotal align=right>"
1634 . $form->format_amount(\%myconfig, $totalnetamount, 2, " ") . "</th>";
1635 $column_data{tax} = "<th class=listtotal align=right>"
1636 . $form->format_amount(\%myconfig, $totalamount - $totalnetamount,
1639 $column_data{amount} =
1640 "<th class=listtotal align=right>"
1641 . $form->format_amount(\%myconfig, $totalamount, 2, " ") . "</th>";
1642 $column_data{paid} =
1643 "<th class=listtotal align=right>"
1644 . $form->format_amount(\%myconfig, $totalpaid, 2, " ") . "</th>";
1646 "<th class=listtotal align=right>"
1647 . $form->format_amount(\%myconfig, $totaldue, 2, " ") . "</th>";
1649 map { print "\n$column_data{$_}" } @column_index;
1657 <td><hr size=3 noshade></td>
1662 <form method=post action=$form->{script}>
1664 <input name=callback type=hidden value="$form->{callback}">
1666 <input type=hidden name=path value=$form->{path}>
1667 <input type=hidden name=login value=$form->{login}>
1668 <input type=hidden name=password value=$form->{password}>
1670 <input class=submit type=submit name=action value="|
1671 . $locale->text('AR Transaction') . qq|">
1672 <input class=submit type=submit name=action value="|
1673 . $locale->text('Sales Invoice') . qq|">
1681 $lxdebug->leave_sub();
1685 $lxdebug->enter_sub();
1687 map { $column_data{$_} = "<td> </td>" } @column_index;
1689 $column_data{tax} = "<th class=listsubtotal align=right>"
1690 . $form->format_amount(\%myconfig, $subtotalamount - $subtotalnetamount,
1693 $column_data{amount} =
1694 "<th class=listsubtotal align=right>"
1695 . $form->format_amount(\%myconfig, $subtotalamount, 2, " ") . "</th>";
1696 $column_data{paid} =
1697 "<th class=listsubtotal align=right>"
1698 . $form->format_amount(\%myconfig, $subtotalpaid, 2, " ") . "</th>";
1700 "<th class=listsubtotal align=right>"
1701 . $form->format_amount(\%myconfig, $subtotaldue, 2, " ") . "</th>";
1703 $subtotalnetamount = 0;
1704 $subtotalamount = 0;
1708 $sameitem = $ar->{ $form->{sort} };
1710 print "<tr class=listsubtotal>";
1712 map { print "\n$column_data{$_}" } @column_index;
1718 $lxdebug->leave_sub();