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} }) {
178 # if there is a value we have an old entry
182 for $i (1 .. scalar @{ $form->{acc_trans}{$key} }) {
183 if ($key eq "AR_paid") {
185 $form->{"AR_paid_$j"} = $form->{acc_trans}{$key}->[$i-1]->{accno};
188 $form->{"paid_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{amount} * -1;
189 $form->{"datepaid_$j"} =
190 $form->{acc_trans}{$key}->[$i - 1]->{transdate};
191 $form->{"source_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{source};
192 $form->{"memo_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{memo};
194 $form->{"forex_$j"} = $form->{"exchangerate_$i"} =
195 $form->{acc_trans}{$key}->[$i - 1]->{exchangerate};
196 $form->{"paid_project_id_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{project_id};
197 $form->{paidaccounts}++;
204 if ($key eq "AR_tax" || $key eq "AP_tax") {
205 $form->{"${key}_$form->{acc_trans}{$key}->[$i-1]->{accno}"} =
206 "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
207 $form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"} =
209 $form->{acc_trans}{$key}->[$i - 1]->{amount} / $exchangerate,
212 if ($form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"} > 0) {
214 $form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"};
216 $form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"};
219 $form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"};
221 $form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"};
223 $index = $form->{acc_trans}{$key}->[$i - 1]->{index};
224 $form->{"tax_$index"} = $form->{acc_trans}{$key}->[$i - 1]->{amount};
225 $totaltax += $form->{"tax_$index"};
229 $form->{"${akey}_$k"} =
231 $form->{acc_trans}{$key}->[$i - 1]->{amount} / $exchangerate,
233 if ($akey eq 'amount') {
235 $totalamount += $form->{"${akey}_$i"};
237 $form->{"oldprojectnumber_$k"} = $form->{"projectnumber_$k"} =
238 "$form->{acc_trans}{$key}->[$i-1]->{projectnumber}";
239 $form->{taxrate} = $form->{acc_trans}{$key}->[$i - 1]->{rate};
240 $form->{"project_id_$k"} =
241 "$form->{acc_trans}{$key}->[$i-1]->{project_id}";
243 $form->{"${key}_$i"} =
244 "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
247 $form->{ARselected} = $form->{acc_trans}{$key}->[$i-1]->{accno};
249 } elsif ($akey eq "amount") {
250 $form->{"${key}_$k"} = $form->{acc_trans}{$key}->[$i-1]->{accno} .
251 "--" . $form->{acc_trans}{$key}->[$i-1]->{id};
252 $form->{"taxchart_$k"} = $form->{acc_trans}{$key}->[$i-1]->{id} .
253 "--" . $form->{acc_trans}{$key}->[$i-1]->{rate};
260 $lxdebug->message(0, "1 ARselected $form->{ARselected}");
262 $form->{taxincluded} = $taxincluded if ($form->{id});
263 $form->{paidaccounts} = 1 if not defined $form->{paidaccounts};
265 if ($form->{taxincluded} && $form->{taxrate} && $totalamount) {
267 # add tax to amounts and invtotal
268 for $i (1 .. $form->{rowcount}) {
270 ($totaltax + $totalwithholding) * $form->{"amount_$i"} / $totalamount;
271 $tax = $form->round_amount($taxamount, 2);
272 $diff += ($taxamount - $tax);
273 $form->{"amount_$i"} += $form->{"tax_$i"};
275 $form->{amount_1} += $form->round_amount($diff, 2);
278 $taxamount = $form->round_amount($taxamount, 2);
279 $form->{tax} = $taxamount;
281 $form->{invtotal} = $totalamount + $totaltax;
284 ($form->datetonum($form->{transdate}, \%myconfig) <=
285 $form->datetonum($form->{closedto}, \%myconfig));
287 $lxdebug->leave_sub();
291 $lxdebug->enter_sub();
293 $title = $form->{title};
294 $form->{title} = $locale->text("$title Accounts Receivables Transaction");
296 $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
298 # $locale->text('Add Accounts Receivables Transaction')
299 # $locale->text('Edit Accounts Receivables Transaction')
300 $form->{javascript} = qq|<script type="text/javascript">
302 function setTaxkey(accno, row) {
303 var taxkey = accno.options[accno.selectedIndex].value;
304 var reg = /--([0-9]*)/;
305 var found = reg.exec(taxkey);
306 var index = found[1];
307 index = parseInt(index);
308 var tax = 'taxchart_' + row;
309 for (var i = 0; i < document.getElementById(tax).options.length; ++i) {
310 var reg2 = new RegExp("^"+ index, "");
311 if (reg2.exec(document.getElementById(tax).options[i].value)) {
312 document.getElementById(tax).options[i].selected = true;
319 # show history button js
320 $form->{javascript} .= qq|<script type="text/javascript" src="js/show_history.js"></script>|;
321 #/show history button js
323 $readonly = ($form->{id}) ? "readonly" : "";
326 ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0;
327 $readonly = ($form->{radier}) ? "" : $readonly;
329 # set option selected
330 foreach $item (qw(customer currency department employee)) {
331 $form->{"select$item"} =~ s/ selected//;
332 $form->{"select$item"} =~
333 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
337 $form->{exchangerate} =
338 $form->format_amount(\%myconfig, $form->{exchangerate});
340 $form->{creditlimit} =
341 $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
342 $form->{creditremaining} =
343 $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
346 <input type=hidden name=forex value=$form->{forex}>
348 if ($form->{currency} ne $form->{defaultcurrency}) {
349 if ($form->{forex}) {
351 <th align=right>| . $locale->text('Exchangerate') . qq|</th>
352 <td><input type=hidden name=exchangerate value=$form->{exchangerate}>$form->{exchangerate}</td>
356 <th align=right>| . $locale->text('Exchangerate') . qq|</th>
357 <td><input name=exchangerate size=10 value=$form->{exchangerate}></td>
366 <td align=right><input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}></td>
367 <th align=left nowrap>| . $locale->text('Tax Included') . qq|</th>
371 if (($rows = $form->numtextrows($form->{notes}, 50)) < 2) {
375 qq|<textarea name=notes rows=$rows cols=50 wrap=soft>$form->{notes}</textarea>|;
379 <th align="right" nowrap>| . $locale->text('Department') . qq|</th>
380 <td colspan=3><select name=department>$form->{selectdepartment}</select>
381 <input type=hidden name=selectdepartment value="$form->{selectdepartment}">
384 | if $form->{selectdepartment};
386 $n = ($form->{creditremaining} =~ /-/) ? "0" : "1";
389 ($form->{selectcustomer})
390 ? qq|<select name=customer>$form->{selectcustomer}</select>|
391 : qq|<input name=customer value="$form->{customer}" size=35>|;
394 <input type=hidden name=employee value="$form->{employee}">
397 if ($form->{selectemployee}) {
400 <th align=right nowrap>| . $locale->text('Salesperson') . qq|</th>
401 <td colspan=2><select name=employee>$form->{selectemployee}</select></td>
402 <input type=hidden name=selectemployee value="$form->{selectemployee}">
407 my @old_project_ids = ();
408 map({ push(@old_project_ids, $form->{"project_id_$_"})
409 if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
411 $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
413 "old_id" => \@old_project_ids },
414 "charts" => { "key" => "ALL_CHARTS",
415 "transdate" => $form->{transdate} },
416 "taxcharts" => "ALL_TAXCHARTS");
418 map({ $_->{link_split} = [ split(/:/, $_->{link}) ]; }
419 @{ $form->{ALL_CHARTS} });
421 my %project_labels = ();
422 my @project_values = ("");
423 foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
424 push(@project_values, $item->{"id"});
425 $project_labels{$item->{"id"}} = $item->{"projectnumber"};
428 my (%AR_amount_labels, @AR_amount_values);
429 my (%AR_labels, @AR_values);
430 my (%AR_paid_labels, @AR_paid_values);
434 foreach my $item (@{ $form->{ALL_CHARTS} }) {
435 if (grep({ $_ eq "AR_amount" } @{ $item->{link_split} })) {
436 $taxchart_init = $item->{tax_id} if ($taxchart_init eq "");
437 my $key = "$item->{accno}--$item->{tax_id}";
438 push(@AR_amount_values, $key);
439 $AR_amount_labels{$key} =
440 "$item->{accno}--$item->{description}";
442 } elsif (grep({ $_ eq "AR" } @{ $item->{link_split} })) {
443 push(@AR_values, $item->{accno});
444 $AR_labels{$item->{accno}} = "$item->{accno}--$item->{description}";
446 } elsif (grep({ $_ eq "AR_paid" } @{ $item->{link_split} })) {
447 push(@AR_paid_values, $item->{accno});
448 $AR_paid_labels{$item->{accno}} =
449 "$item->{accno}--$item->{description}";
452 $charts{$item->{accno}} = $item;
455 my %taxchart_labels = ();
456 my @taxchart_values = ();
458 foreach my $item (@{ $form->{ALL_TAXCHARTS} }) {
459 my $key = "$item->{id}--$item->{rate}";
460 $taxchart_init = $key if ($taxchart_init eq $item->{id});
461 push(@taxchart_values, $key);
462 $taxchart_labels{$key} =
463 "$item->{taxdescription} " . ($item->{rate} * 100) . ' %';
464 $taxcharts{$item->{id}} = $item;
467 $form->{fokus} = "arledger.customer";
469 # use JavaScript Calendar or not
470 $form->{jsscript} = $jscalendar;
472 if ($form->{jsscript}) {
474 # with JavaScript Calendar
476 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>
477 <td><input type=button name=transdate id="trigger1" value=|
478 . $locale->text('button') . qq|></td>
481 <td><input name=duedate id=duedate size=11 title="$myconfig{dateformat}" value=$form->{duedate}></td>
482 <td><input type=button name=duedate id="trigger2" value=|
483 . $locale->text('button') . qq|></td></td>
488 Form->write_trigger(\%myconfig, "2", "transdate", "BL", "trigger1",
489 "duedate", "BL", "trigger2");
492 # without JavaScript Calendar
494 qq|<td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>|;
496 qq|<td><input name=duedate id=duedate size=11 title="$myconfig{dateformat}" value=$form->{duedate}></td>|;
502 <body onLoad="fokus()">
504 <form method=post name="arledger" action=$form->{script}>
506 <input type=hidden name=id value=$form->{id}>
507 <input type=hidden name=sort value=$form->{sort}>
508 <input type=hidden name=closedto value=$form->{closedto}>
509 <input type=hidden name=locked value=$form->{locked}>
510 <input type=hidden name=title value="$title">
512 | . ($form->{saved_message} ? qq|<p>$form->{saved_message}</p>| : "") . qq|
516 <th class=listtop>$form->{title}</th>
526 <th align="right" nowrap>| . $locale->text('Customer') . qq|</th>
527 <td colspan=3>$customer</td>
528 <input type=hidden name=selectcustomer value="$form->{selectcustomer}">
529 <input type=hidden name=oldcustomer value="$form->{oldcustomer}">
530 <input type=hidden name=customer_id value="$form->{customer_id}">
531 <input type=hidden name=terms value=$form->{terms}>
538 <th align=left nowrap>| . $locale->text('Credit Limit') . qq|</th>
539 <td>$form->{creditlimit}</td>
540 <th align=left nowrap>| . $locale->text('Remaining') . qq|</th>
541 <td class="plus$n">$form->{creditremaining}</td>
542 <input type=hidden name=creditlimit value=$form->{creditlimit}>
543 <input type=hidden name=creditremaining value=$form->{creditremaining}>
549 <th align=right>| . $locale->text('Currency') . qq|</th>
550 <td><select name=currency>$form->{selectcurrency}</select></td>
551 <input type=hidden name=selectcurrency value="$form->{selectcurrency}">
552 <input type=hidden name=defaultcurrency value=$form->{defaultcurrency}>
553 <input type=hidden name=fxgain_accno value=$form->{fxgain_accno}>
554 <input type=hidden name=fxloss_accno value=$form->{fxloss_accno}>
565 <th align=right nowrap>| . $locale->text('Invoice Number') . qq|</th>
566 <td><input name=invnumber size=11 value="$form->{invnumber}"></td>
569 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
570 <td><input name=ordnumber size=11 value="$form->{ordnumber}"></td>
573 <th align=right nowrap>| . $locale->text('Invoice Date') . qq|</th>
577 <th align=right nowrap>| . $locale->text('Due Date') . qq|</th>
588 <input type=hidden name=rowcount value=$form->{rowcount}>
592 <tr class=listheading>
593 <th class=listheading style="width:15%">|
594 . $locale->text('Account') . qq|</th>
595 <th class=listheading style="width:10%">|
596 . $locale->text('Amount') . qq|</th>
597 <th class=listheading style="width:10%">|
598 . $locale->text('Tax') . qq|</th>
599 <th class=listheading style="width:5%">|
600 . $locale->text('Korrektur') . qq|</th>
601 <th class=listheading style="width:10%">|
602 . $locale->text('Taxkey') . qq|</th>
603 <th class=listheading style="width:10%">|
604 . $locale->text('Project') . qq|</th>
608 $amount = $locale->text('Amount');
609 $project = $locale->text('Project');
611 for $i (1 .. $form->{rowcount}) {
614 $form->{"amount_$i"} =
615 $form->format_amount(\%myconfig, $form->{"amount_$i"}, 2);
616 $form->{"tax_$i"} = $form->format_amount(\%myconfig, $form->{"tax_$i"}, 2);
618 my $selected_accno_full;
619 my ($accno_row) = split(/--/, $form->{"AR_amount_$i"});
620 my $item = $charts{$accno_row};
621 $selected_accno_full = "$item->{accno}--$item->{tax_id}";
623 my $selected_taxchart = $form->{"taxchart_$i"};
624 my ($selected_accno, $selected_tax_id) = split(/--/, $selected_accno_full);
625 my ($previous_accno, $previous_tax_id) = split(/--/, $form->{"previous_AR_amount_$i"});
627 if ($previous_accno &&
628 ($previous_accno eq $selected_accno) &&
629 ($previous_tax_id ne $selected_tax_id)) {
630 $lxdebug->message(0, "yeah");
631 my $item = $taxcharts{$selected_tax_id};
632 $selected_taxchart = "$item->{id}--$item->{rate}";
635 $selected_taxchart = $taxchart_init unless ($form->{"taxchart_$i"});
638 NTI($cgi->popup_menu('-name' => "AR_amount_$i",
639 '-id' => "AR_amount_$i",
640 '-style' => 'width:400px',
641 '-onChange' => "setTaxkey(this, $i)",
642 '-values' => \@AR_amount_values,
643 '-labels' => \%AR_amount_labels,
644 '-default' => $selected_accno_full))
645 . $cgi->hidden('-name' => "previous_AR_amount_$i",
646 '-default' => $selected_accno_full);
649 NTI($cgi->popup_menu('-name' => "taxchart_$i",
650 '-id' => "taxchart_$i",
651 '-style' => 'width:200px',
652 '-values' => \@taxchart_values,
653 '-labels' => \%taxchart_labels,
654 '-default' => $selected_taxchart))
657 $korrektur_checked = ($form->{"korrektur_$i"} ? 'checked' : '');
660 NTI($cgi->popup_menu('-name' => "project_id_$i",
661 '-values' => \@project_values,
662 '-labels' => \%project_labels,
663 '-default' => $form->{"project_id_$i"} ));
667 <td>$selectAR_amount</td>
668 <td><input name="amount_$i" size=10 value=$form->{"amount_$i"}></td>
669 <td><input name="tax_$i" size=10 value=$form->{"tax_$i"}></td>
670 <td><input type="checkbox" name="korrektur_$i" value="1" $korrektur_checked></td>
672 <td>$projectnumber</td>
679 $form->{invtotal} = $form->format_amount(\%myconfig, $form->{invtotal}, 2);
682 NTI($cgi->popup_menu('-name' => "ARselected", '-id' => "ARselected",
683 '-style' => 'width:400px',
684 '-values' => \@AR_values, '-labels' => \%AR_labels,
685 '-default' => $form->{ARselected}));
694 <td>${ARselected}</td>
695 <th align=left>$form->{invtotal}</th>
697 <input type=hidden name=oldinvtotal value=$form->{oldinvtotal}>
698 <input type=hidden name=oldtotalpaid value=$form->{oldtotalpaid}>
700 <input type=hidden name=taxaccounts value="$form->{taxaccounts}">
713 <th align=left width=1%>| . $locale->text('Notes') . qq|</th>
714 <td align=left>$notes</td>
722 <tr class=listheading>
723 <th colspan=7 class=listheading>|
724 . $locale->text('Incoming Payments') . qq|</th>
728 if ($form->{currency} eq $form->{defaultcurrency}) {
729 @column_index = qw(datepaid source memo paid AR_paid paid_project_id);
731 @column_index = qw(datepaid source memo paid exchangerate AR_paid paid_project_id);
734 $column_data{datepaid} = "<th>" . $locale->text('Date') . "</th>";
735 $column_data{paid} = "<th>" . $locale->text('Amount') . "</th>";
736 $column_data{exchangerate} = "<th>" . $locale->text('Exch') . "</th>";
737 $column_data{AR_paid} = "<th>" . $locale->text('Account') . "</th>";
738 $column_data{source} = "<th>" . $locale->text('Source') . "</th>";
739 $column_data{memo} = "<th>" . $locale->text('Memo') . "</th>";
740 $column_data{paid_project_id} = "<th>" . $locale->text('Project Number') . "</th>";
745 map { print "$column_data{$_}\n" } @column_index;
751 $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
752 for $i (1 .. $form->{paidaccounts}) {
758 NTI($cgi->popup_menu('-name' => "AR_paid_$i",
759 '-id' => "AR_paid_$i",
760 '-values' => \@AR_paid_values,
761 '-labels' => \%AR_paid_labels,
762 '-default' => $form->{"AR_paid_$i"}));
765 if ($form->{"paid_$i"}) {
767 $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2);
769 $form->{"exchangerate_$i"} =
770 $form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
772 $exchangerate = qq| |;
773 if ($form->{currency} ne $form->{defaultcurrency}) {
774 if ($form->{"forex_$i"}) {
776 qq|<input type=hidden name="exchangerate_$i" value=$form->{"exchangerate_$i"}>$form->{"exchangerate_$i"}|;
779 qq|<input name="exchangerate_$i" size=10 value=$form->{"exchangerate_$i"}>|;
784 <input type=hidden name="forex_$i" value=$form->{"forex_$i"}>
788 qq|<td align=center><input name="paid_$i" size=11 value=$form->{"paid_$i"}></td>|;
789 $column_data{AR_paid} =
790 qq|<td align=center>${selectAR_paid}</td>|;
791 $column_data{exchangerate} = qq|<td align=center>$exchangerate</td>|;
792 $column_data{datepaid} =
793 qq|<td align=center><input name="datepaid_$i" id="datepaid_$i" size=11 value=$form->{"datepaid_$i"}>
794 <input type="button" name="datepaid_$i" id="trigger_datepaid_$i" value="?"></td>|;
795 $column_data{source} =
796 qq|<td align=center><input name="source_$i" size=11 value="$form->{"source_$i"}"></td>|;
798 qq|<td align=center><input name="memo_$i" size=11 value="$form->{"memo_$i"}"></td>|;
800 $column_data{paid_project_id} =
802 . NTI($cgi->popup_menu('-name' => "paid_project_id_$i",
803 '-values' => \@project_values,
804 '-labels' => \%project_labels,
805 '-default' => $form->{"paid_project_id_$i"} ))
808 map { print qq|$column_data{$_}\n| } @column_index;
813 push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i");
816 print $form->write_trigger(\%myconfig, scalar(@triggers) / 3, @triggers) .
818 <input type=hidden name=paidaccounts value=$form->{paidaccounts}>
824 <td><hr size=3 noshade></td>
829 $lxdebug->leave_sub();
833 $lxdebug->enter_sub();
837 <input name=gldate type=hidden value="| . Q($form->{gldate}) . qq|">
839 <input name=callback type=hidden value="$form->{callback}">
841 <input type=hidden name=path value=$form->{path}>
842 <input type=hidden name=login value=$form->{login}>
843 <input type=hidden name=password value=$form->{password}>
845 . $cgi->hidden('-name' => 'draft_id', '-default' => [$form->{draft_id}])
846 . $cgi->hidden('-name' => 'draft_description', '-default' => [$form->{draft_description}])
852 $transdate = $form->datetonum($form->{transdate}, \%myconfig);
853 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
855 print qq|<input class=submit type=submit name=action value="|
856 . $locale->text('Update') . qq|">
859 if ($form->{radier}) {
861 <input class=submit type=submit name=action value="|
862 . $locale->text('Post') . qq|">
863 <input class=submit type=submit name=action value="|
864 . $locale->text('Delete') . qq|">
867 if ($transdate > $closedto) {
869 <input class=submit type=submit name=action value="|
870 . $locale->text('Use As Template') . qq|">
874 <input class=submit type=submit name=action value="|
875 . $locale->text('Post Payment') . qq|">
879 if ($transdate > $closedto) {
880 print qq|<input class=submit type=submit name=action value="|
881 . $locale->text('Post') . qq|"> | .
882 NTI($cgi->submit('-name' => 'action', '-value' => $locale->text('Save draft'),
883 '-class' => 'submit'));
887 if ($form->{menubar}) {
888 require "$form->{path}/menu.pl";
891 # button for saving history
892 if($form->{id} ne "") {
894 <input type=button class=submit onclick=set_history_window(|
896 . qq|); name=history id=history value=|
897 . $locale->text('history')
900 # /button for saving history
908 $lxdebug->leave_sub();
912 $lxdebug->enter_sub();
916 $form->{invtotal} = 0;
918 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
919 qw(exchangerate creditlimit creditremaining);
921 @flds = qw(amount AR_amount projectnumber oldprojectnumber project_id);
925 for $i (1 .. $form->{rowcount}) {
926 $form->{"amount_$i"} =
927 $form->parse_amount(\%myconfig, $form->{"amount_$i"});
928 $form->{"tax_$i"} = $form->parse_amount(\%myconfig, $form->{"tax_$i"});
929 if ($form->{"amount_$i"}) {
932 if (!$form->{"korrektur_$i"}) {
933 ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
935 if ($form->{taxincluded}) {
936 $form->{"tax_$i"} = $form->{"amount_$i"} / ($rate + 1) * $rate;
938 $form->{"tax_$i"} = $form->{"amount_$i"} * $rate;
941 $form->{"tax_$i"} = 0;
944 $form->{"tax_$i"} = $form->round_amount($form->{"tax_$i"}, 2);
946 $totaltax += $form->{"tax_$i"};
947 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
952 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
953 $form->{rowcount} = $count + 1;
954 map { $form->{invtotal} += $form->{"amount_$_"} } (1 .. $form->{rowcount});
956 $form->{exchangerate} = $exchangerate
960 $form->check_exchangerate(
961 \%myconfig, $form->{currency}, $form->{transdate}, 'buy'
964 $form->{invdate} = $form->{transdate};
965 $save_AR = $form->{AR};
966 &check_name(customer);
967 $form->{AR} = $save_AR;
970 ($form->{taxincluded}) ? $form->{invtotal} : $form->{invtotal} + $totaltax;
972 for $i (1 .. $form->{paidaccounts}) {
973 if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
976 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
977 } qw(paid exchangerate);
979 $totalpaid += $form->{"paid_$i"};
981 $form->{"exchangerate_$i"} = $exchangerate
983 $form->{"forex_$i"} = (
985 $form->check_exchangerate(
986 \%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'buy'
991 $form->{creditremaining} -=
992 ($form->{invtotal} - $totalpaid + $form->{oldtotalpaid} -
993 $form->{oldinvtotal});
994 $form->{oldinvtotal} = $form->{invtotal};
995 $form->{oldtotalpaid} = $totalpaid;
999 $lxdebug->leave_sub();
1003 $lxdebug->enter_sub();
1004 for $i (1 .. $form->{paidaccounts}) {
1005 if ($form->{"paid_$i"}) {
1006 $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
1008 $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
1010 $form->error($locale->text('Cannot post payment for a closed period!'))
1011 if ($datepaid <= $closedto);
1013 if ($form->{currency} ne $form->{defaultcurrency}) {
1014 $form->{"exchangerate_$i"} = $form->{exchangerate}
1015 if ($invdate == $datepaid);
1016 $form->isblank("exchangerate_$i",
1017 $locale->text('Exchangerate for payment missing!'));
1022 ($form->{AR}) = split /--/, $form->{AR};
1023 ($form->{AR_paid}) = split /--/, $form->{AR_paid};
1024 $form->redirect($locale->text(' Payment posted!'))
1025 if (AR->post_payment(\%myconfig, \%$form));
1026 $form->error($locale->text('Cannot post payment!'));
1029 $lxdebug->leave_sub();
1033 $lxdebug->enter_sub();
1035 # check if there is an invoice number, invoice and due date
1036 $form->isblank("transdate", $locale->text('Invoice Date missing!'));
1037 $form->isblank("duedate", $locale->text('Due Date missing!'));
1038 $form->isblank("customer", $locale->text('Customer missing!'));
1040 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
1041 $transdate = $form->datetonum($form->{transdate}, \%myconfig);
1043 $form->error($locale->text('Cannot post transaction for a closed period!'))
1044 if ($transdate <= $closedto);
1046 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
1047 if ($form->{currency} ne $form->{defaultcurrency});
1049 delete($form->{AR});
1051 for $i (1 .. $form->{paidaccounts}) {
1052 if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
1053 $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
1055 $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
1057 $form->error($locale->text('Cannot post payment for a closed period!'))
1058 if ($datepaid <= $closedto);
1060 if ($form->{currency} ne $form->{defaultcurrency}) {
1061 $form->{"exchangerate_$i"} = $form->{exchangerate}
1062 if ($transdate == $datepaid);
1063 $form->isblank("exchangerate_$i",
1064 $locale->text('Exchangerate for payment missing!'));
1069 # if oldcustomer ne customer redo form
1070 ($customer) = split /--/, $form->{customer};
1071 if ($form->{oldcustomer} ne "$customer--$form->{customer_id}") {
1076 $form->{AR}{receivables} = $form->{ARselected};
1078 $form->{id} = 0 if $form->{postasnew};
1079 if (AR->post_transaction(\%myconfig, \%$form)) {
1080 # saving the history
1081 if(!exists $form->{addition} && $form->{id} ne "") {
1082 $form->{addition} = "POSTED";
1083 $form->save_history($form->dbconnect(\%myconfig));
1085 # /saving the history
1086 remove_draft() if $form->{remove_draft};
1087 $form->redirect($locale->text('Transaction posted!'));
1089 $form->error($locale->text('Cannot post transaction!'));
1091 $lxdebug->leave_sub();
1095 $lxdebug->enter_sub();
1097 $form->{postasnew} = 1;
1098 # saving the history
1099 if(!exists $form->{addition} && $form->{id} ne "") {
1100 $form->{addition} = "POSTED AS NEW";
1101 $form->save_history($form->dbconnect(\%myconfig));
1103 # /saving the history
1106 $lxdebug->leave_sub();
1109 sub use_as_template {
1110 $lxdebug->enter_sub();
1112 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);
1113 $form->{paidaccounts} = 1;
1114 $form->{rowcount}--;
1115 $form->{invdate} = $form->current_date(\%myconfig);
1118 $lxdebug->leave_sub();
1122 $lxdebug->enter_sub();
1124 $form->{title} = $locale->text('Confirm!');
1128 delete $form->{header};
1133 <form method=post action=$form->{script}>
1136 foreach $key (keys %$form) {
1137 $form->{$key} =~ s/\"/"/g;
1138 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
1142 <h2 class=confirm>$form->{title}</h2>
1145 . $locale->text('Are you sure you want to delete Transaction')
1146 . qq| $form->{invnumber}</h4>
1148 <input name=action class=submit type=submit value="|
1149 . $locale->text('Yes') . qq|">
1156 $lxdebug->leave_sub();
1160 $lxdebug->enter_sub();
1161 if (AR->delete_transaction(\%myconfig, \%$form, $spool)) {
1162 # saving the history
1163 if(!exists $form->{addition}) {
1164 $form->{addition} = "DELETED";
1165 $form->save_history($form->dbconnect(\%myconfig));
1167 # /saving the history
1168 $form->redirect($locale->text('Transaction deleted!'));
1170 $form->error($locale->text('Cannot delete transaction!'));
1172 $lxdebug->leave_sub();
1176 $lxdebug->enter_sub();
1178 # setup customer selection
1179 $form->all_vc(\%myconfig, "customer", "AR");
1181 if (@{ $form->{all_customer} }) {
1182 map { $customer .= "<option>$_->{name}--$_->{id}\n" }
1183 @{ $form->{all_customer} };
1184 $customer = qq|<select name=customer><option>\n$customer</select>|;
1186 $customer = qq|<input name=customer size=35>|;
1190 if (@{ $form->{all_departments} }) {
1191 $form->{selectdepartment} = "<option>\n";
1194 $form->{selectdepartment} .=
1195 "<option>$_->{description}--$_->{id}\n"
1196 } (@{ $form->{all_departments} });
1201 <th align=right nowrap>| . $locale->text('Department') . qq|</th>
1202 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
1204 | if $form->{selectdepartment};
1206 $form->{title} = $locale->text('AR Transactions');
1208 # use JavaScript Calendar or not
1209 $form->{jsscript} = $jscalendar;
1211 if ($form->{jsscript}) {
1213 # with JavaScript Calendar
1215 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}">
1216 <input type=button name=transdatefrom id="trigger1" value=|
1217 . $locale->text('button') . qq|></td>
1220 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}">
1221 <input type=button name=transdateto name=transdateto id="trigger2" value=|
1222 . $locale->text('button') . qq|></td>
1227 Form->write_trigger(\%myconfig, "2", "transdatefrom", "BR", "trigger1",
1228 "transdateto", "BL", "trigger2");
1231 # without JavaScript Calendar
1233 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>|;
1235 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}"></td>|;
1238 $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
1243 foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
1244 push(@values, $item->{"id"});
1245 $labels{$item->{"id"}} = $item->{"projectnumber"};
1248 NTI($cgi->popup_menu('-name' => 'project_id', '-values' => \@values,
1249 '-labels' => \%labels));
1251 $form->{fokus} = "search.customer";
1255 <body onLoad="fokus()">
1257 <form method=post name="search" action=$form->{script}>
1260 <tr><th class=listtop>$form->{title}</th></tr>
1261 <tr height="5"></tr>
1266 <th align=right>| . $locale->text('Customer') . qq|</th>
1267 <td colspan=3>$customer</td>
1271 <th align=right nowrap>| . $locale->text('Invoice Number') . qq|</th>
1272 <td colspan=3><input name=invnumber size=20></td>
1275 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
1276 <td colspan=3><input name=ordnumber size=20></td>
1279 <th align=right nowrap>| . $locale->text('Notes') . qq|</th>
1280 <td colspan=3><input name=notes size=40></td>
1283 <th align="right">| . $locale->text("Project Number") . qq|</th>
1284 <td colspan="3">$projectnumber</td>
1287 <th align=right nowrap>| . $locale->text('From') . qq|</th>
1289 <th align=right>| . $locale->text('Bis') . qq|</th>
1292 <input type=hidden name=sort value=transdate>
1300 <th align=right nowrap>| . $locale->text('Include in Report') . qq|</th>
1304 <td align=right><input name=open class=checkbox type=checkbox value=Y checked></td>
1305 <td nowrap>| . $locale->text('Open') . qq|</td>
1306 <td align=right><input name=closed class=checkbox type=checkbox value=Y></td>
1307 <td nowrap>| . $locale->text('Closed') . qq|</td>
1310 <td align=right><input name="l_id" class=checkbox type=checkbox value=Y></td>
1311 <td nowrap>| . $locale->text('ID') . qq|</td>
1312 <td align=right><input name="l_invnumber" class=checkbox type=checkbox value=Y checked></td>
1313 <td nowrap>| . $locale->text('Invoice Number') . qq|</td>
1314 <td align=right><input name="l_ordnumber" class=checkbox type=checkbox value=Y></td>
1315 <td nowrap>| . $locale->text('Order Number') . qq|</td>
1316 <td align=right><input name="l_transdate" class=checkbox type=checkbox value=Y checked></td>
1317 <td nowrap>| . $locale->text('Invoice Date') . qq|</td>
1320 <td align=right><input name="l_name" class=checkbox type=checkbox value=Y checked></td>
1321 <td nowrap>| . $locale->text('Customer') . qq|</td>
1322 <td align=right><input name="l_netamount" class=checkbox type=checkbox value=Y></td>
1323 <td nowrap>| . $locale->text('Amount') . qq|</td>
1324 <td align=right><input name="l_tax" class=checkbox type=checkbox value=Y></td>
1325 <td nowrap>| . $locale->text('Tax') . qq|</td>
1326 <td align=right><input name="l_amount" class=checkbox type=checkbox value=Y checked></td>
1327 <td nowrap>| . $locale->text('Total') . qq|</td>
1330 <td align=right><input name="l_datepaid" class=checkbox type=checkbox value=Y></td>
1331 <td nowrap>| . $locale->text('Date Paid') . qq|</td>
1332 <td align=right><input name="l_paid" class=checkbox type=checkbox value=Y checked></td>
1333 <td nowrap>| . $locale->text('Paid') . qq|</td>
1334 <td align=right><input name="l_duedate" class=checkbox type=checkbox value=Y></td>
1335 <td nowrap>| . $locale->text('Due Date') . qq|</td>
1336 <td align=right><input name="l_due" class=checkbox type=checkbox value=Y></td>
1337 <td nowrap>| . $locale->text('Amount Due') . qq|</td>
1340 <td align=right><input name="l_notes" class=checkbox type=checkbox value=Y></td>
1341 <td nowrap>| . $locale->text('Notes') . qq|</td>
1342 <td align=right><input name="l_employee" class=checkbox type=checkbox value=Y></td>
1343 <td nowrap>| . $locale->text('Salesperson') . qq|</td>
1344 <td align=right><input name="l_shippingpoint" class=checkbox type=checkbox value=Y></td>
1345 <td nowrap>| . $locale->text('Shipping Point') . qq|</td>
1346 <td align=right><input name="l_shipvia" class=checkbox type=checkbox value=Y></td>
1347 <td nowrap>| . $locale->text('Ship via') . qq|</td>
1350 <td align=right><input name="l_subtotal" class=checkbox type=checkbox value=Y></td>
1351 <td nowrap>| . $locale->text('Subtotal') . qq|</td>
1352 <td align=right><input name="l_globalprojectnumber" class=checkbox type=checkbox value=Y></td>
1353 <td nowrap>| . $locale->text('Project Number') . qq|</td>
1362 <td><hr size=3 noshade></td>
1366 <input type=hidden name=nextsub value=$form->{nextsub}>
1368 <input type=hidden name=path value=$form->{path}>
1369 <input type=hidden name=login value=$form->{login}>
1370 <input type=hidden name=password value=$form->{password}>
1373 <input class=submit type=submit name=action value="|
1374 . $locale->text('Continue') . qq|">
1385 $lxdebug->leave_sub();
1388 sub ar_transactions {
1389 $lxdebug->enter_sub();
1391 $form->{customer} = $form->unescape($form->{customer});
1392 ($form->{customer}, $form->{customer_id}) = split(/--/, $form->{customer});
1394 AR->ar_transactions(\%myconfig, \%$form);
1397 "$form->{script}?action=ar_transactions&path=$form->{path}&login=$form->{login}&password=$form->{password}";
1400 if ($form->{customer}) {
1401 $callback .= "&customer=" . $form->escape($form->{customer}, 1);
1402 $href .= "&customer=" . $form->escape($form->{customer});
1403 $option = $locale->text('Customer') . " : $form->{customer}";
1405 if ($form->{department}) {
1406 $callback .= "&department=" . $form->escape($form->{department}, 1);
1407 $href .= "&department=" . $form->escape($form->{department});
1408 ($department) = split /--/, $form->{department};
1409 $option .= "\n<br>" if ($option);
1410 $option .= $locale->text('Department') . " : $department";
1412 if ($form->{invnumber}) {
1413 $callback .= "&invnumber=" . $form->escape($form->{invnumber}, 1);
1414 $href .= "&invnumber=" . $form->escape($form->{invnumber});
1415 $option .= "\n<br>" if ($option);
1416 $option .= $locale->text('Invoice Number') . " : $form->{invnumber}";
1418 if ($form->{ordnumber}) {
1419 $callback .= "&ordnumber=" . $form->escape($form->{ordnumber}, 1);
1420 $href .= "&ordnumber=" . $form->escape($form->{ordnumber});
1421 $option .= "\n<br>" if ($option);
1422 $option .= $locale->text('Order Number') . " : $form->{ordnumber}";
1424 if ($form->{notes}) {
1425 $callback .= "¬es=" . $form->escape($form->{notes}, 1);
1426 $href .= "¬es=" . $form->escape($form->{notes});
1427 $option .= "\n<br>" if $option;
1428 $option .= $locale->text('Notes') . " : $form->{notes}";
1431 if ($form->{transdatefrom}) {
1432 $callback .= "&transdatefrom=$form->{transdatefrom}";
1433 $href .= "&transdatefrom=$form->{transdatefrom}";
1434 $option .= "\n<br>" if ($option);
1436 $locale->text('From') . " "
1437 . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
1439 if ($form->{transdateto}) {
1440 $callback .= "&transdateto=$form->{transdateto}";
1441 $href .= "&transdateto=$form->{transdateto}";
1442 $option .= "\n<br>" if ($option);
1444 $locale->text('Bis') . " "
1445 . $locale->date(\%myconfig, $form->{transdateto}, 1);
1447 if ($form->{open}) {
1448 $callback .= "&open=$form->{open}";
1449 $href .= "&open=$form->{open}";
1450 $option .= "\n<br>" if ($option);
1451 $option .= $locale->text('Open');
1453 if ($form->{closed}) {
1454 $callback .= "&closed=$form->{closed}";
1455 $href .= "&closed=$form->{closed}";
1456 $option .= "\n<br>" if ($option);
1457 $option .= $locale->text('Closed');
1459 if ($form->{globalproject_id}) {
1460 $callback .= "&globalproject_id=" . E($form->{globalproject_id});
1461 $href .= "&globalproject_id=" . E($form->{globalproject_id});
1465 qw(transdate id type invnumber ordnumber name netamount tax amount paid
1466 datepaid due duedate notes employee shippingpoint shipvia
1467 globalprojectnumber);
1469 $form->{"l_type"} = "Y";
1471 foreach $item (@columns) {
1472 if ($form->{"l_$item"} eq "Y") {
1473 push @column_index, $item;
1475 # add column to href and callback
1476 $callback .= "&l_$item=Y";
1477 $href .= "&l_$item=Y";
1481 if ($form->{l_subtotal} eq 'Y') {
1482 $callback .= "&l_subtotal=Y";
1483 $href .= "&l_subtotal=Y";
1486 $column_header{id} =
1487 "<th><a class=listheading href=$href&sort=id>"
1488 . $locale->text('ID')
1490 $column_header{transdate} =
1491 "<th><a class=listheading href=$href&sort=transdate>"
1492 . $locale->text('Date')
1494 $column_header{duedate} =
1495 "<th><a class=listheading href=$href&sort=duedate>"
1496 . $locale->text('Due Date')
1498 $column_header{type} =
1499 "<th class=\"listheading\">" . $locale->text('Type') . "</th>";
1500 $column_header{invnumber} =
1501 "<th><a class=listheading href=$href&sort=invnumber>"
1502 . $locale->text('Invoice')
1504 $column_header{ordnumber} =
1505 "<th><a class=listheading href=$href&sort=ordnumber>"
1506 . $locale->text('Order')
1508 $column_header{name} =
1509 "<th><a class=listheading href=$href&sort=name>"
1510 . $locale->text('Customer')
1512 $column_header{netamount} =
1513 "<th class=listheading>" . $locale->text('Amount') . "</th>";
1514 $column_header{tax} =
1515 "<th class=listheading>" . $locale->text('Tax') . "</th>";
1516 $column_header{amount} =
1517 "<th class=listheading>" . $locale->text('Total') . "</th>";
1518 $column_header{paid} =
1519 "<th class=listheading>" . $locale->text('Paid') . "</th>";
1520 $column_header{datepaid} =
1521 "<th><a class=listheading href=$href&sort=datepaid>"
1522 . $locale->text('Date Paid')
1524 $column_header{due} =
1525 "<th class=listheading>" . $locale->text('Amount Due') . "</th>";
1526 $column_header{notes} =
1527 "<th class=listheading>" . $locale->text('Notes') . "</th>";
1528 $column_header{employee} =
1529 "<th><a class=listheading href=$href&sort=employee>"
1530 . $locale->text('Salesperson') . "</th>";
1532 $column_header{shippingpoint} =
1533 "<th><a class=listheading href=$href&sort=shippingpoint>"
1534 . $locale->text('Shipping Point')
1536 $column_header{shipvia} =
1537 "<th><a class=listheading href=$href&sort=shipvia>"
1538 . $locale->text('Ship via')
1540 $column_header{globalprojectnumber} =
1541 qq|<th class="listheading">| . $locale->text('Project Number') . qq|</th>|;
1543 $form->{title} = $locale->text('AR Transactions');
1552 <th class=listtop>$form->{title}</th>
1554 <tr height="5"></tr>
1561 <tr class=listheading>
1564 map { print "\n$column_header{$_}" } @column_index;
1570 # add sort and escape callback, this one we use for the add sub
1571 $form->{callback} = $callback .= "&sort=$form->{sort}";
1573 # escape callback for href
1574 $callback = $form->escape($callback);
1576 if (@{ $form->{AR} }) {
1577 $sameitem = $form->{AR}->[0]->{ $form->{sort} };
1580 # sums and tax on reports by Antonio Gallardo
1582 foreach $ar (@{ $form->{AR} }) {
1584 if ($form->{l_subtotal} eq 'Y') {
1585 if ($sameitem ne $ar->{ $form->{sort} }) {
1590 $column_data{netamount} =
1592 . $form->format_amount(\%myconfig, $ar->{netamount}, 2, " ")
1594 $column_data{tax} = "<td align=right>"
1595 . $form->format_amount(\%myconfig, $ar->{amount} - $ar->{netamount},
1598 $column_data{amount} =
1600 . $form->format_amount(\%myconfig, $ar->{amount}, 2, " ") . "</td>";
1601 $column_data{paid} =
1603 . $form->format_amount(\%myconfig, $ar->{paid}, 2, " ") . "</td>";
1604 $column_data{due} = "<td align=right>"
1605 . $form->format_amount(\%myconfig, $ar->{amount} - $ar->{paid},
1609 $subtotalnetamount += $ar->{netamount};
1610 $subtotalamount += $ar->{amount};
1611 $subtotalpaid += $ar->{paid};
1612 $subtotaldue += $ar->{amount} - $ar->{paid};
1614 $totalnetamount += $ar->{netamount};
1615 $totalamount += $ar->{amount};
1616 $totalpaid += $ar->{paid};
1617 $totaldue += ($ar->{amount} - $ar->{paid});
1619 $column_data{transdate} = "<td>$ar->{transdate} </td>";
1620 $column_data{id} = "<td>$ar->{id}</td>";
1621 $column_data{datepaid} = "<td>$ar->{datepaid} </td>";
1622 $column_data{duedate} = "<td>$ar->{duedate} </td>";
1624 $module = ($ar->{invoice}) ? "is.pl" : $form->{script};
1626 $column_data{invnumber} =
1627 "<td><a href=$module?action=edit&id=$ar->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ar->{invnumber}</a></td>";
1628 $column_data{type} = "<td>" .
1629 ($ar->{storno} ? $locale->text("Storno (one letter abbreviation)") :
1631 $locale->text("Credit note (one letter abbreviation)") :
1632 $locale->text("Invoice (one letter abbreviation)")) . "</td>";
1633 $column_data{ordnumber} = "<td>$ar->{ordnumber} </td>";
1634 $column_data{name} = "<td>$ar->{name}</td>";
1635 $ar->{notes} =~ s/\r\n/<br>/g;
1636 $column_data{notes} = "<td>$ar->{notes} </td>";
1637 $column_data{shippingpoint} = "<td>$ar->{shippingpoint} </td>";
1638 $column_data{shipvia} = "<td>$ar->{shipvia} </td>";
1639 $column_data{employee} = "<td>$ar->{employee} </td>";
1640 $column_data{globalprojectnumber} =
1641 "<td>" . H($ar->{globalprojectnumber}) . "</td>";
1646 <tr class=listrow$i>
1649 map { print "\n$column_data{$_}" } @column_index;
1657 if ($form->{l_subtotal} eq 'Y') {
1663 <tr class=listtotal>
1666 map { $column_data{$_} = "<td> </td>" } @column_index;
1668 $column_data{netamount} =
1669 "<th class=listtotal align=right>"
1670 . $form->format_amount(\%myconfig, $totalnetamount, 2, " ") . "</th>";
1671 $column_data{tax} = "<th class=listtotal align=right>"
1672 . $form->format_amount(\%myconfig, $totalamount - $totalnetamount,
1675 $column_data{amount} =
1676 "<th class=listtotal align=right>"
1677 . $form->format_amount(\%myconfig, $totalamount, 2, " ") . "</th>";
1678 $column_data{paid} =
1679 "<th class=listtotal align=right>"
1680 . $form->format_amount(\%myconfig, $totalpaid, 2, " ") . "</th>";
1682 "<th class=listtotal align=right>"
1683 . $form->format_amount(\%myconfig, $totaldue, 2, " ") . "</th>";
1685 map { print "\n$column_data{$_}" } @column_index;
1693 <td><hr size=3 noshade></td>
1698 <form method=post action=$form->{script}>
1700 <input name=callback type=hidden value="$form->{callback}">
1702 <input type=hidden name=path value=$form->{path}>
1703 <input type=hidden name=login value=$form->{login}>
1704 <input type=hidden name=password value=$form->{password}>
1706 <input class=submit type=submit name=action value="|
1707 . $locale->text('AR Transaction') . qq|">
1708 <input class=submit type=submit name=action value="|
1709 . $locale->text('Sales Invoice') . qq|">
1717 $lxdebug->leave_sub();
1721 $lxdebug->enter_sub();
1723 map { $column_data{$_} = "<td> </td>" } @column_index;
1725 $column_data{tax} = "<th class=listsubtotal align=right>"
1726 . $form->format_amount(\%myconfig, $subtotalamount - $subtotalnetamount,
1729 $column_data{amount} =
1730 "<th class=listsubtotal align=right>"
1731 . $form->format_amount(\%myconfig, $subtotalamount, 2, " ") . "</th>";
1732 $column_data{paid} =
1733 "<th class=listsubtotal align=right>"
1734 . $form->format_amount(\%myconfig, $subtotalpaid, 2, " ") . "</th>";
1736 "<th class=listsubtotal align=right>"
1737 . $form->format_amount(\%myconfig, $subtotaldue, 2, " ") . "</th>";
1739 $subtotalnetamount = 0;
1740 $subtotalamount = 0;
1744 $sameitem = $ar->{ $form->{sort} };
1746 print "<tr class=listsubtotal>";
1748 map { print "\n$column_data{$_}" } @column_index;
1754 $lxdebug->leave_sub();