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};
92 AR->get_transdate(\%myconfig, $form);
93 $form->{initial_transdate} = $form->{transdate};
95 $form->{transdate} = $form->{initial_transdate};
97 $lxdebug->leave_sub();
101 $lxdebug->enter_sub();
102 # show history button
103 $form->{javascript} = qq|<script type="text/javascript" src="js/show_history.js"></script>|;
104 #/show hhistory button
106 $form->{title} = "Edit";
111 $lxdebug->leave_sub();
115 $lxdebug->enter_sub();
120 $lxdebug->leave_sub();
124 $lxdebug->enter_sub();
126 $form->create_links("AR", \%myconfig, "customer");
127 $duedate = $form->{duedate};
129 $taxincluded = $form->{taxincluded};
130 my $id = $form->{id};
131 IS->get_customer(\%myconfig, \%$form);
132 $form->{taxincluded} = $taxincluded;
135 $form->{duedate} = $duedate if $duedate;
136 $form->{oldcustomer} = "$form->{customer}--$form->{customer_id}";
137 $form->{rowcount} = 1;
140 @curr = split(/:/, $form->{currencies});
142 $form->{defaultcurrency} = $curr[0];
144 map { $form->{selectcurrency} .= "<option>$_\n" } @curr;
147 if (@{ $form->{all_customer} }) {
148 $form->{customer} = "$form->{customer}--$form->{customer_id}";
149 map { $form->{selectcustomer} .= "<option>$_->{name}--$_->{id}\n" }
150 (@{ $form->{all_customer} });
154 if (@{ $form->{all_departments} }) {
155 $form->{selectdepartment} = "<option>\n";
156 $form->{department} = "$form->{department}--$form->{department_id}";
159 $form->{selectdepartment} .=
160 "<option>$_->{description}--$_->{id}\n"
161 } (@{ $form->{all_departments} });
164 $form->{employee} = "$form->{employee}--$form->{employee_id}";
167 if (@{ $form->{all_employees} }) {
168 $form->{selectemployee} = "";
169 map { $form->{selectemployee} .= "<option>$_->{name}--$_->{id}\n" }
170 (@{ $form->{all_employees} });
173 # build the popup menus
174 $form->{taxincluded} = ($form->{id}) ? $form->{taxincluded} : "checked";
177 $form->{forex} = $form->{exchangerate};
178 $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
179 foreach $key (keys %{ $form->{AR_links} }) {
180 # if there is a value we have an old entry
184 for $i (1 .. scalar @{ $form->{acc_trans}{$key} }) {
185 if ($key eq "AR_paid") {
187 $form->{"AR_paid_$j"} = $form->{acc_trans}{$key}->[$i-1]->{accno};
190 $form->{"paid_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{amount} * -1;
191 $form->{"datepaid_$j"} =
192 $form->{acc_trans}{$key}->[$i - 1]->{transdate};
193 $form->{"source_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{source};
194 $form->{"memo_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{memo};
196 $form->{"forex_$j"} = $form->{"exchangerate_$i"} =
197 $form->{acc_trans}{$key}->[$i - 1]->{exchangerate};
198 $form->{"paid_project_id_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{project_id};
199 $form->{paidaccounts}++;
206 if ($key eq "AR_tax" || $key eq "AP_tax") {
207 $form->{"${key}_$form->{acc_trans}{$key}->[$i-1]->{accno}"} =
208 "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
209 $form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"} =
211 $form->{acc_trans}{$key}->[$i - 1]->{amount} / $exchangerate,
214 if ($form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"} > 0) {
216 $form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"};
218 $form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"};
221 $form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"};
223 $form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"};
225 $index = $form->{acc_trans}{$key}->[$i - 1]->{index};
226 $form->{"tax_$index"} = $form->{acc_trans}{$key}->[$i - 1]->{amount};
227 $totaltax += $form->{"tax_$index"};
231 $form->{"${akey}_$k"} =
233 $form->{acc_trans}{$key}->[$i - 1]->{amount} / $exchangerate,
235 if ($akey eq 'amount') {
237 $totalamount += $form->{"${akey}_$i"};
239 $form->{"oldprojectnumber_$k"} = $form->{"projectnumber_$k"} =
240 "$form->{acc_trans}{$key}->[$i-1]->{projectnumber}";
241 $form->{taxrate} = $form->{acc_trans}{$key}->[$i - 1]->{rate};
242 $form->{"project_id_$k"} =
243 "$form->{acc_trans}{$key}->[$i-1]->{project_id}";
245 $form->{"${key}_$i"} =
246 "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
249 $form->{ARselected} = $form->{acc_trans}{$key}->[$i-1]->{accno};
251 } elsif ($akey eq "amount") {
252 $form->{"${key}_$k"} = $form->{acc_trans}{$key}->[$i-1]->{accno} .
253 "--" . $form->{acc_trans}{$key}->[$i-1]->{id};
254 $form->{"taxchart_$k"} = $form->{acc_trans}{$key}->[$i-1]->{id} .
255 "--" . $form->{acc_trans}{$key}->[$i-1]->{rate};
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>
364 <td align=right><input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}></td>
365 <th align=left nowrap>| . $locale->text('Tax Included') . qq|</th>
369 if (($rows = $form->numtextrows($form->{notes}, 50)) < 2) {
373 qq|<textarea name=notes rows=$rows cols=50 wrap=soft>$form->{notes}</textarea>|;
377 <th align="right" nowrap>| . $locale->text('Department') . qq|</th>
378 <td colspan=3><select name=department>$form->{selectdepartment}</select>
379 <input type=hidden name=selectdepartment value="$form->{selectdepartment}">
382 | if $form->{selectdepartment};
384 $n = ($form->{creditremaining} =~ /-/) ? "0" : "1";
387 ($form->{selectcustomer})
388 ? qq|<select name=customer>$form->{selectcustomer}</select>|
389 : qq|<input name=customer value="$form->{customer}" size=35>|;
392 <input type=hidden name=employee value="$form->{employee}">
395 if ($form->{selectemployee}) {
398 <th align=right nowrap>| . $locale->text('Salesperson') . qq|</th>
399 <td colspan=2><select name=employee>$form->{selectemployee}</select></td>
400 <input type=hidden name=selectemployee value="$form->{selectemployee}">
405 my @old_project_ids = ();
406 map({ push(@old_project_ids, $form->{"project_id_$_"})
407 if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
409 $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
411 "old_id" => \@old_project_ids },
412 "charts" => { "key" => "ALL_CHARTS",
413 "transdate" => $form->{transdate} },
414 "taxcharts" => "ALL_TAXCHARTS");
416 map({ $_->{link_split} = [ split(/:/, $_->{link}) ]; }
417 @{ $form->{ALL_CHARTS} });
419 my %project_labels = ();
420 my @project_values = ("");
421 foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
422 push(@project_values, $item->{"id"});
423 $project_labels{$item->{"id"}} = $item->{"projectnumber"};
426 my (%AR_amount_labels, @AR_amount_values);
427 my (%AR_labels, @AR_values);
428 my (%AR_paid_labels, @AR_paid_values);
432 foreach my $item (@{ $form->{ALL_CHARTS} }) {
433 if (grep({ $_ eq "AR_amount" } @{ $item->{link_split} })) {
434 $taxchart_init = $item->{tax_id} if ($taxchart_init eq "");
435 my $key = "$item->{accno}--$item->{tax_id}";
436 push(@AR_amount_values, $key);
437 $AR_amount_labels{$key} =
438 "$item->{accno}--$item->{description}";
440 } elsif (grep({ $_ eq "AR" } @{ $item->{link_split} })) {
441 push(@AR_values, $item->{accno});
442 $AR_labels{$item->{accno}} = "$item->{accno}--$item->{description}";
444 } elsif (grep({ $_ eq "AR_paid" } @{ $item->{link_split} })) {
445 push(@AR_paid_values, $item->{accno});
446 $AR_paid_labels{$item->{accno}} =
447 "$item->{accno}--$item->{description}";
450 $charts{$item->{accno}} = $item;
453 my %taxchart_labels = ();
454 my @taxchart_values = ();
456 foreach my $item (@{ $form->{ALL_TAXCHARTS} }) {
457 my $key = "$item->{id}--$item->{rate}";
458 $taxchart_init = $key if ($taxchart_init eq $item->{id});
459 push(@taxchart_values, $key);
460 $taxchart_labels{$key} =
461 "$item->{taxdescription} " . ($item->{rate} * 100) . ' %';
462 $taxcharts{$item->{id}} = $item;
465 $form->{fokus} = "arledger.customer";
467 # use JavaScript Calendar or not
468 $form->{jsscript} = $jscalendar;
470 if ($form->{jsscript}) {
472 # with JavaScript Calendar
474 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>
475 <td><input type=button name=transdate id="trigger1" value=|
476 . $locale->text('button') . qq|></td>
479 <td><input name=duedate id=duedate size=11 title="$myconfig{dateformat}" value=$form->{duedate}></td>
480 <td><input type=button name=duedate id="trigger2" value=|
481 . $locale->text('button') . qq|></td></td>
486 Form->write_trigger(\%myconfig, "2", "transdate", "BL", "trigger1",
487 "duedate", "BL", "trigger2");
490 # without JavaScript Calendar
492 qq|<td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>|;
494 qq|<td><input name=duedate id=duedate size=11 title="$myconfig{dateformat}" value=$form->{duedate}></td>|;
500 <body onLoad="fokus()">
502 <form method=post name="arledger" action=$form->{script}>
504 <input type=hidden name=id value=$form->{id}>
505 <input type=hidden name=sort value=$form->{sort}>
506 <input type=hidden name=closedto value=$form->{closedto}>
507 <input type=hidden name=locked value=$form->{locked}>
508 <input type=hidden name=title value="$title">
510 | . ($form->{saved_message} ? qq|<p>$form->{saved_message}</p>| : "") . qq|
514 <th class=listtop>$form->{title}</th>
524 <th align="right" nowrap>| . $locale->text('Customer') . qq|</th>
525 <td colspan=3>$customer</td>
526 <input type=hidden name=selectcustomer value="$form->{selectcustomer}">
527 <input type=hidden name=oldcustomer value="$form->{oldcustomer}">
528 <input type=hidden name=customer_id value="$form->{customer_id}">
529 <input type=hidden name=terms value=$form->{terms}>
536 <th align=left nowrap>| . $locale->text('Credit Limit') . qq|</th>
537 <td>$form->{creditlimit}</td>
538 <th align=left nowrap>| . $locale->text('Remaining') . qq|</th>
539 <td class="plus$n">$form->{creditremaining}</td>
540 <input type=hidden name=creditlimit value=$form->{creditlimit}>
541 <input type=hidden name=creditremaining value=$form->{creditremaining}>
547 <th align=right>| . $locale->text('Currency') . qq|</th>
548 <td><select name=currency>$form->{selectcurrency}</select></td>
549 <input type=hidden name=selectcurrency value="$form->{selectcurrency}">
550 <input type=hidden name=defaultcurrency value=$form->{defaultcurrency}>
551 <input type=hidden name=fxgain_accno value=$form->{fxgain_accno}>
552 <input type=hidden name=fxloss_accno value=$form->{fxloss_accno}>
563 <th align=right nowrap>| . $locale->text('Invoice Number') . qq|</th>
564 <td><input name=invnumber size=11 value="$form->{invnumber}"></td>
567 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
568 <td><input name=ordnumber size=11 value="$form->{ordnumber}"></td>
571 <th align=right nowrap>| . $locale->text('Invoice Date') . qq|</th>
575 <th align=right nowrap>| . $locale->text('Due Date') . qq|</th>
586 <input type=hidden name=rowcount value=$form->{rowcount}>
590 <tr class=listheading>
591 <th class=listheading style="width:15%">|
592 . $locale->text('Account') . qq|</th>
593 <th class=listheading style="width:10%">|
594 . $locale->text('Amount') . qq|</th>
595 <th class=listheading style="width:10%">|
596 . $locale->text('Tax') . qq|</th>
597 <th class=listheading style="width:5%">|
598 . $locale->text('Korrektur') . qq|</th>
599 <th class=listheading style="width:10%">|
600 . $locale->text('Taxkey') . qq|</th>
601 <th class=listheading style="width:10%">|
602 . $locale->text('Project') . qq|</th>
606 $amount = $locale->text('Amount');
607 $project = $locale->text('Project');
609 for $i (1 .. $form->{rowcount}) {
612 $form->{"amount_$i"} =
613 $form->format_amount(\%myconfig, $form->{"amount_$i"}, 2);
614 $form->{"tax_$i"} = $form->format_amount(\%myconfig, $form->{"tax_$i"}, 2);
616 my $selected_accno_full;
617 my ($accno_row) = split(/--/, $form->{"AR_amount_$i"});
618 my $item = $charts{$accno_row};
619 $selected_accno_full = "$item->{accno}--$item->{tax_id}";
621 my $selected_taxchart = $form->{"taxchart_$i"};
622 my ($selected_accno, $selected_tax_id) = split(/--/, $selected_accno_full);
623 my ($previous_accno, $previous_tax_id) = split(/--/, $form->{"previous_AR_amount_$i"});
625 if ($previous_accno &&
626 ($previous_accno eq $selected_accno) &&
627 ($previous_tax_id ne $selected_tax_id)) {
628 my $item = $taxcharts{$selected_tax_id};
629 $selected_taxchart = "$item->{id}--$item->{rate}";
632 $selected_taxchart = $taxchart_init unless ($form->{"taxchart_$i"});
635 NTI($cgi->popup_menu('-name' => "AR_amount_$i",
636 '-id' => "AR_amount_$i",
637 '-style' => 'width:400px',
638 '-onChange' => "setTaxkey(this, $i)",
639 '-values' => \@AR_amount_values,
640 '-labels' => \%AR_amount_labels,
641 '-default' => $selected_accno_full))
642 . $cgi->hidden('-name' => "previous_AR_amount_$i",
643 '-default' => $selected_accno_full);
646 NTI($cgi->popup_menu('-name' => "taxchart_$i",
647 '-id' => "taxchart_$i",
648 '-style' => 'width:200px',
649 '-values' => \@taxchart_values,
650 '-labels' => \%taxchart_labels,
651 '-default' => $selected_taxchart))
654 $korrektur_checked = ($form->{"korrektur_$i"} ? 'checked' : '');
657 NTI($cgi->popup_menu('-name' => "project_id_$i",
658 '-values' => \@project_values,
659 '-labels' => \%project_labels,
660 '-default' => $form->{"project_id_$i"} ));
664 <td>$selectAR_amount</td>
665 <td><input name="amount_$i" size=10 value=$form->{"amount_$i"}></td>
666 <td><input name="tax_$i" size=10 value=$form->{"tax_$i"}></td>
667 <td><input type="checkbox" name="korrektur_$i" value="1" $korrektur_checked></td>
669 <td>$projectnumber</td>
676 $form->{invtotal} = $form->format_amount(\%myconfig, $form->{invtotal}, 2);
679 NTI($cgi->popup_menu('-name' => "ARselected", '-id' => "ARselected",
680 '-style' => 'width:400px',
681 '-values' => \@AR_values, '-labels' => \%AR_labels,
682 '-default' => $form->{ARselected}));
691 <td>${ARselected}</td>
692 <th align=left>$form->{invtotal}</th>
694 <input type=hidden name=oldinvtotal value=$form->{oldinvtotal}>
695 <input type=hidden name=oldtotalpaid value=$form->{oldtotalpaid}>
697 <input type=hidden name=taxaccounts value="$form->{taxaccounts}">
710 <th align=left width=1%>| . $locale->text('Notes') . qq|</th>
711 <td align=left>$notes</td>
719 <tr class=listheading>
720 <th colspan=7 class=listheading>|
721 . $locale->text('Incoming Payments') . qq|</th>
725 if ($form->{currency} eq $form->{defaultcurrency}) {
726 @column_index = qw(datepaid source memo paid AR_paid paid_project_id);
728 @column_index = qw(datepaid source memo paid exchangerate AR_paid paid_project_id);
731 $column_data{datepaid} = "<th>" . $locale->text('Date') . "</th>";
732 $column_data{paid} = "<th>" . $locale->text('Amount') . "</th>";
733 $column_data{exchangerate} = "<th>" . $locale->text('Exch') . "</th>";
734 $column_data{AR_paid} = "<th>" . $locale->text('Account') . "</th>";
735 $column_data{source} = "<th>" . $locale->text('Source') . "</th>";
736 $column_data{memo} = "<th>" . $locale->text('Memo') . "</th>";
737 $column_data{paid_project_id} = "<th>" . $locale->text('Project Number') . "</th>";
742 map { print "$column_data{$_}\n" } @column_index;
748 $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
749 for $i (1 .. $form->{paidaccounts}) {
755 NTI($cgi->popup_menu('-name' => "AR_paid_$i",
756 '-id' => "AR_paid_$i",
757 '-values' => \@AR_paid_values,
758 '-labels' => \%AR_paid_labels,
759 '-default' => $form->{"AR_paid_$i"}));
762 if ($form->{"paid_$i"}) {
764 $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2);
766 $form->{"exchangerate_$i"} =
767 $form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
769 $exchangerate = qq| |;
770 if ($form->{currency} ne $form->{defaultcurrency}) {
771 if ($form->{"forex_$i"}) {
773 qq|<input type=hidden name="exchangerate_$i" value=$form->{"exchangerate_$i"}>$form->{"exchangerate_$i"}|;
776 qq|<input name="exchangerate_$i" size=10 value=$form->{"exchangerate_$i"}>|;
781 <input type=hidden name="forex_$i" value=$form->{"forex_$i"}>
785 qq|<td align=center><input name="paid_$i" size=11 value=$form->{"paid_$i"}></td>|;
786 $column_data{AR_paid} =
787 qq|<td align=center>${selectAR_paid}</td>|;
788 $column_data{exchangerate} = qq|<td align=center>$exchangerate</td>|;
789 $column_data{datepaid} =
790 qq|<td align=center><input name="datepaid_$i" id="datepaid_$i" size=11 value=$form->{"datepaid_$i"}>
791 <input type="button" name="datepaid_$i" id="trigger_datepaid_$i" value="?"></td>|;
792 $column_data{source} =
793 qq|<td align=center><input name="source_$i" size=11 value="$form->{"source_$i"}"></td>|;
795 qq|<td align=center><input name="memo_$i" size=11 value="$form->{"memo_$i"}"></td>|;
797 $column_data{paid_project_id} =
799 . NTI($cgi->popup_menu('-name' => "paid_project_id_$i",
800 '-values' => \@project_values,
801 '-labels' => \%project_labels,
802 '-default' => $form->{"paid_project_id_$i"} ))
805 map { print qq|$column_data{$_}\n| } @column_index;
810 push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i");
813 print $form->write_trigger(\%myconfig, scalar(@triggers) / 3, @triggers) .
815 <input type=hidden name=paidaccounts value=$form->{paidaccounts}>
821 <td><hr size=3 noshade></td>
826 $lxdebug->leave_sub();
830 $lxdebug->enter_sub();
834 <input name=gldate type=hidden value="| . Q($form->{gldate}) . qq|">
836 <input name=callback type=hidden value="$form->{callback}">
838 <input type=hidden name=path value=$form->{path}>
839 <input type=hidden name=login value=$form->{login}>
840 <input type=hidden name=password value=$form->{password}>
842 . $cgi->hidden('-name' => 'draft_id', '-default' => [$form->{draft_id}])
843 . $cgi->hidden('-name' => 'draft_description', '-default' => [$form->{draft_description}])
849 $transdate = $form->datetonum($form->{transdate}, \%myconfig);
850 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
852 print qq|<input class=submit type=submit name=action value="|
853 . $locale->text('Update') . qq|">
856 if ($form->{radier}) {
858 <input class=submit type=submit name=action value="|
859 . $locale->text('Post') . qq|">
860 <input class=submit type=submit name=action value="|
861 . $locale->text('Delete') . qq|">
864 if ($transdate > $closedto) {
866 <input class=submit type=submit name=action value="|
867 . $locale->text('Use As Template') . qq|">
871 <input class=submit type=submit name=action value="|
872 . $locale->text('Post Payment') . qq|">
876 if ($transdate > $closedto) {
877 print qq|<input class=submit type=submit name=action value="|
878 . $locale->text('Post') . qq|"> | .
879 NTI($cgi->submit('-name' => 'action', '-value' => $locale->text('Save draft'),
880 '-class' => 'submit'));
884 if ($form->{menubar}) {
885 require "$form->{path}/menu.pl";
888 # button for saving history
889 if($form->{id} ne "") {
891 <input type=button class=submit onclick=set_history_window(|
893 . qq|); name=history id=history value=|
894 . $locale->text('history')
897 # /button for saving history
905 $lxdebug->leave_sub();
909 $lxdebug->enter_sub();
913 $form->{invtotal} = 0;
915 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
916 qw(exchangerate creditlimit creditremaining);
918 @flds = qw(amount AR_amount projectnumber oldprojectnumber project_id);
922 for $i (1 .. $form->{rowcount}) {
923 $form->{"amount_$i"} =
924 $form->parse_amount(\%myconfig, $form->{"amount_$i"});
925 $form->{"tax_$i"} = $form->parse_amount(\%myconfig, $form->{"tax_$i"});
926 if ($form->{"amount_$i"}) {
929 if (!$form->{"korrektur_$i"}) {
930 ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
932 if ($form->{taxincluded}) {
933 $form->{"tax_$i"} = $form->{"amount_$i"} / ($rate + 1) * $rate;
935 $form->{"tax_$i"} = $form->{"amount_$i"} * $rate;
938 $form->{"tax_$i"} = 0;
941 $form->{"tax_$i"} = $form->round_amount($form->{"tax_$i"}, 2);
943 $totaltax += $form->{"tax_$i"};
944 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
949 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
950 $form->{rowcount} = $count + 1;
951 map { $form->{invtotal} += $form->{"amount_$_"} } (1 .. $form->{rowcount});
953 $form->{exchangerate} = $exchangerate
957 $form->check_exchangerate(
958 \%myconfig, $form->{currency}, $form->{transdate}, 'buy'
961 $form->{invdate} = $form->{transdate};
962 $save_AR = $form->{AR};
963 &check_name(customer);
964 $form->{AR} = $save_AR;
967 ($form->{taxincluded}) ? $form->{invtotal} : $form->{invtotal} + $totaltax;
969 for $i (1 .. $form->{paidaccounts}) {
970 if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
973 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
974 } qw(paid exchangerate);
976 $totalpaid += $form->{"paid_$i"};
978 $form->{"exchangerate_$i"} = $exchangerate
980 $form->{"forex_$i"} = (
982 $form->check_exchangerate(
983 \%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'buy'
988 $form->{creditremaining} -=
989 ($form->{invtotal} - $totalpaid + $form->{oldtotalpaid} -
990 $form->{oldinvtotal});
991 $form->{oldinvtotal} = $form->{invtotal};
992 $form->{oldtotalpaid} = $totalpaid;
996 $lxdebug->leave_sub();
1000 $lxdebug->enter_sub();
1001 for $i (1 .. $form->{paidaccounts}) {
1002 if ($form->{"paid_$i"}) {
1003 $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
1005 $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
1007 $form->error($locale->text('Cannot post payment for a closed period!'))
1008 if ($datepaid <= $closedto);
1010 if ($form->{currency} ne $form->{defaultcurrency}) {
1011 $form->{"exchangerate_$i"} = $form->{exchangerate}
1012 if ($invdate == $datepaid);
1013 $form->isblank("exchangerate_$i",
1014 $locale->text('Exchangerate for payment missing!'));
1019 ($form->{AR}) = split /--/, $form->{AR};
1020 ($form->{AR_paid}) = split /--/, $form->{AR_paid};
1021 $form->redirect($locale->text(' Payment posted!'))
1022 if (AR->post_payment(\%myconfig, \%$form));
1023 $form->error($locale->text('Cannot post payment!'));
1026 $lxdebug->leave_sub();
1030 $lxdebug->enter_sub();
1032 # check if there is an invoice number, invoice and due date
1033 $form->isblank("transdate", $locale->text('Invoice Date missing!'));
1034 $form->isblank("duedate", $locale->text('Due Date missing!'));
1035 $form->isblank("customer", $locale->text('Customer missing!'));
1037 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
1038 $transdate = $form->datetonum($form->{transdate}, \%myconfig);
1040 $form->error($locale->text('Cannot post transaction for a closed period!'))
1041 if ($transdate <= $closedto);
1043 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
1044 if ($form->{currency} ne $form->{defaultcurrency});
1046 delete($form->{AR});
1048 for $i (1 .. $form->{paidaccounts}) {
1049 if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
1050 $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
1052 $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
1054 $form->error($locale->text('Cannot post payment for a closed period!'))
1055 if ($datepaid <= $closedto);
1057 if ($form->{currency} ne $form->{defaultcurrency}) {
1058 $form->{"exchangerate_$i"} = $form->{exchangerate}
1059 if ($transdate == $datepaid);
1060 $form->isblank("exchangerate_$i",
1061 $locale->text('Exchangerate for payment missing!'));
1066 # if oldcustomer ne customer redo form
1067 ($customer) = split /--/, $form->{customer};
1068 if ($form->{oldcustomer} ne "$customer--$form->{customer_id}") {
1073 $form->{AR}{receivables} = $form->{ARselected};
1075 $form->{id} = 0 if $form->{postasnew};
1076 if (AR->post_transaction(\%myconfig, \%$form)) {
1077 # saving the history
1078 if(!exists $form->{addition} && $form->{id} ne "") {
1079 $form->{addition} = "POSTED";
1080 $form->save_history($form->dbconnect(\%myconfig));
1082 # /saving the history
1083 remove_draft() if $form->{remove_draft};
1084 $form->redirect($locale->text('Transaction posted!'));
1086 $form->error($locale->text('Cannot post transaction!'));
1088 $lxdebug->leave_sub();
1092 $lxdebug->enter_sub();
1094 $form->{postasnew} = 1;
1095 # saving the history
1096 if(!exists $form->{addition} && $form->{id} ne "") {
1097 $form->{addition} = "POSTED AS NEW";
1098 $form->save_history($form->dbconnect(\%myconfig));
1100 # /saving the history
1103 $lxdebug->leave_sub();
1106 sub use_as_template {
1107 $lxdebug->enter_sub();
1109 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);
1110 $form->{paidaccounts} = 1;
1111 $form->{rowcount}--;
1112 $form->{invdate} = $form->current_date(\%myconfig);
1115 $lxdebug->leave_sub();
1119 $lxdebug->enter_sub();
1121 $form->{title} = $locale->text('Confirm!');
1125 delete $form->{header};
1130 <form method=post action=$form->{script}>
1133 foreach $key (keys %$form) {
1134 $form->{$key} =~ s/\"/"/g;
1135 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
1139 <h2 class=confirm>$form->{title}</h2>
1142 . $locale->text('Are you sure you want to delete Transaction')
1143 . qq| $form->{invnumber}</h4>
1145 <input name=action class=submit type=submit value="|
1146 . $locale->text('Yes') . qq|">
1153 $lxdebug->leave_sub();
1157 $lxdebug->enter_sub();
1158 if (AR->delete_transaction(\%myconfig, \%$form, $spool)) {
1159 # saving the history
1160 if(!exists $form->{addition}) {
1161 $form->{addition} = "DELETED";
1162 $form->save_history($form->dbconnect(\%myconfig));
1164 # /saving the history
1165 $form->redirect($locale->text('Transaction deleted!'));
1167 $form->error($locale->text('Cannot delete transaction!'));
1169 $lxdebug->leave_sub();
1173 $lxdebug->enter_sub();
1175 # setup customer selection
1176 $form->all_vc(\%myconfig, "customer", "AR");
1178 if (@{ $form->{all_customer} }) {
1179 map { $customer .= "<option>$_->{name}--$_->{id}\n" }
1180 @{ $form->{all_customer} };
1181 $customer = qq|<select name=customer><option>\n$customer</select>|;
1183 $customer = qq|<input name=customer size=35>|;
1187 if (@{ $form->{all_departments} }) {
1188 $form->{selectdepartment} = "<option>\n";
1191 $form->{selectdepartment} .=
1192 "<option>$_->{description}--$_->{id}\n"
1193 } (@{ $form->{all_departments} });
1198 <th align=right nowrap>| . $locale->text('Department') . qq|</th>
1199 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
1201 | if $form->{selectdepartment};
1203 $form->{title} = $locale->text('AR Transactions');
1205 # use JavaScript Calendar or not
1206 $form->{jsscript} = $jscalendar;
1208 if ($form->{jsscript}) {
1210 # with JavaScript Calendar
1212 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}">
1213 <input type=button name=transdatefrom id="trigger1" value=|
1214 . $locale->text('button') . qq|></td>
1217 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}">
1218 <input type=button name=transdateto name=transdateto id="trigger2" value=|
1219 . $locale->text('button') . qq|></td>
1224 Form->write_trigger(\%myconfig, "2", "transdatefrom", "BR", "trigger1",
1225 "transdateto", "BL", "trigger2");
1228 # without JavaScript Calendar
1230 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>|;
1232 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}"></td>|;
1235 $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
1240 foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
1241 push(@values, $item->{"id"});
1242 $labels{$item->{"id"}} = $item->{"projectnumber"};
1245 NTI($cgi->popup_menu('-name' => 'project_id', '-values' => \@values,
1246 '-labels' => \%labels));
1248 $form->{fokus} = "search.customer";
1252 <body onLoad="fokus()">
1254 <form method=post name="search" action=$form->{script}>
1257 <tr><th class=listtop>$form->{title}</th></tr>
1258 <tr height="5"></tr>
1263 <th align=right>| . $locale->text('Customer') . qq|</th>
1264 <td colspan=3>$customer</td>
1268 <th align=right nowrap>| . $locale->text('Invoice Number') . qq|</th>
1269 <td colspan=3><input name=invnumber size=20></td>
1272 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
1273 <td colspan=3><input name=ordnumber size=20></td>
1276 <th align=right nowrap>| . $locale->text('Notes') . qq|</th>
1277 <td colspan=3><input name=notes size=40></td>
1280 <th align="right">| . $locale->text("Project Number") . qq|</th>
1281 <td colspan="3">$projectnumber</td>
1284 <th align=right nowrap>| . $locale->text('From') . qq|</th>
1286 <th align=right>| . $locale->text('Bis') . qq|</th>
1289 <input type=hidden name=sort value=transdate>
1297 <th align=right nowrap>| . $locale->text('Include in Report') . qq|</th>
1301 <td align=right><input name=open class=checkbox type=checkbox value=Y checked></td>
1302 <td nowrap>| . $locale->text('Open') . qq|</td>
1303 <td align=right><input name=closed class=checkbox type=checkbox value=Y></td>
1304 <td nowrap>| . $locale->text('Closed') . qq|</td>
1307 <td align=right><input name="l_id" class=checkbox type=checkbox value=Y></td>
1308 <td nowrap>| . $locale->text('ID') . qq|</td>
1309 <td align=right><input name="l_invnumber" class=checkbox type=checkbox value=Y checked></td>
1310 <td nowrap>| . $locale->text('Invoice Number') . qq|</td>
1311 <td align=right><input name="l_ordnumber" class=checkbox type=checkbox value=Y></td>
1312 <td nowrap>| . $locale->text('Order Number') . qq|</td>
1313 <td align=right><input name="l_transdate" class=checkbox type=checkbox value=Y checked></td>
1314 <td nowrap>| . $locale->text('Invoice Date') . qq|</td>
1317 <td align=right><input name="l_name" class=checkbox type=checkbox value=Y checked></td>
1318 <td nowrap>| . $locale->text('Customer') . qq|</td>
1319 <td align=right><input name="l_netamount" class=checkbox type=checkbox value=Y></td>
1320 <td nowrap>| . $locale->text('Amount') . qq|</td>
1321 <td align=right><input name="l_tax" class=checkbox type=checkbox value=Y></td>
1322 <td nowrap>| . $locale->text('Tax') . qq|</td>
1323 <td align=right><input name="l_amount" class=checkbox type=checkbox value=Y checked></td>
1324 <td nowrap>| . $locale->text('Total') . qq|</td>
1327 <td align=right><input name="l_datepaid" class=checkbox type=checkbox value=Y></td>
1328 <td nowrap>| . $locale->text('Date Paid') . qq|</td>
1329 <td align=right><input name="l_paid" class=checkbox type=checkbox value=Y checked></td>
1330 <td nowrap>| . $locale->text('Paid') . qq|</td>
1331 <td align=right><input name="l_duedate" class=checkbox type=checkbox value=Y></td>
1332 <td nowrap>| . $locale->text('Due Date') . qq|</td>
1333 <td align=right><input name="l_due" class=checkbox type=checkbox value=Y></td>
1334 <td nowrap>| . $locale->text('Amount Due') . qq|</td>
1337 <td align=right><input name="l_notes" class=checkbox type=checkbox value=Y></td>
1338 <td nowrap>| . $locale->text('Notes') . qq|</td>
1339 <td align=right><input name="l_employee" class=checkbox type=checkbox value=Y></td>
1340 <td nowrap>| . $locale->text('Salesperson') . qq|</td>
1341 <td align=right><input name="l_shippingpoint" class=checkbox type=checkbox value=Y></td>
1342 <td nowrap>| . $locale->text('Shipping Point') . qq|</td>
1343 <td align=right><input name="l_shipvia" class=checkbox type=checkbox value=Y></td>
1344 <td nowrap>| . $locale->text('Ship via') . qq|</td>
1347 <td align=right><input name="l_subtotal" class=checkbox type=checkbox value=Y></td>
1348 <td nowrap>| . $locale->text('Subtotal') . qq|</td>
1349 <td align=right><input name="l_globalprojectnumber" class=checkbox type=checkbox value=Y></td>
1350 <td nowrap>| . $locale->text('Project Number') . qq|</td>
1359 <td><hr size=3 noshade></td>
1363 <input type=hidden name=nextsub value=$form->{nextsub}>
1365 <input type=hidden name=path value=$form->{path}>
1366 <input type=hidden name=login value=$form->{login}>
1367 <input type=hidden name=password value=$form->{password}>
1370 <input class=submit type=submit name=action value="|
1371 . $locale->text('Continue') . qq|">
1382 $lxdebug->leave_sub();
1385 sub ar_transactions {
1386 $lxdebug->enter_sub();
1388 $form->{customer} = $form->unescape($form->{customer});
1389 ($form->{customer}, $form->{customer_id}) = split(/--/, $form->{customer});
1391 AR->ar_transactions(\%myconfig, \%$form);
1394 "$form->{script}?action=ar_transactions&path=$form->{path}&login=$form->{login}&password=$form->{password}";
1397 if ($form->{customer}) {
1398 $callback .= "&customer=" . $form->escape($form->{customer}, 1);
1399 $href .= "&customer=" . $form->escape($form->{customer});
1400 $option = $locale->text('Customer') . " : $form->{customer}";
1402 if ($form->{department}) {
1403 $callback .= "&department=" . $form->escape($form->{department}, 1);
1404 $href .= "&department=" . $form->escape($form->{department});
1405 ($department) = split /--/, $form->{department};
1406 $option .= "\n<br>" if ($option);
1407 $option .= $locale->text('Department') . " : $department";
1409 if ($form->{invnumber}) {
1410 $callback .= "&invnumber=" . $form->escape($form->{invnumber}, 1);
1411 $href .= "&invnumber=" . $form->escape($form->{invnumber});
1412 $option .= "\n<br>" if ($option);
1413 $option .= $locale->text('Invoice Number') . " : $form->{invnumber}";
1415 if ($form->{ordnumber}) {
1416 $callback .= "&ordnumber=" . $form->escape($form->{ordnumber}, 1);
1417 $href .= "&ordnumber=" . $form->escape($form->{ordnumber});
1418 $option .= "\n<br>" if ($option);
1419 $option .= $locale->text('Order Number') . " : $form->{ordnumber}";
1421 if ($form->{notes}) {
1422 $callback .= "¬es=" . $form->escape($form->{notes}, 1);
1423 $href .= "¬es=" . $form->escape($form->{notes});
1424 $option .= "\n<br>" if $option;
1425 $option .= $locale->text('Notes') . " : $form->{notes}";
1428 if ($form->{transdatefrom}) {
1429 $callback .= "&transdatefrom=$form->{transdatefrom}";
1430 $href .= "&transdatefrom=$form->{transdatefrom}";
1431 $option .= "\n<br>" if ($option);
1433 $locale->text('From') . " "
1434 . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
1436 if ($form->{transdateto}) {
1437 $callback .= "&transdateto=$form->{transdateto}";
1438 $href .= "&transdateto=$form->{transdateto}";
1439 $option .= "\n<br>" if ($option);
1441 $locale->text('Bis') . " "
1442 . $locale->date(\%myconfig, $form->{transdateto}, 1);
1444 if ($form->{open}) {
1445 $callback .= "&open=$form->{open}";
1446 $href .= "&open=$form->{open}";
1447 $option .= "\n<br>" if ($option);
1448 $option .= $locale->text('Open');
1450 if ($form->{closed}) {
1451 $callback .= "&closed=$form->{closed}";
1452 $href .= "&closed=$form->{closed}";
1453 $option .= "\n<br>" if ($option);
1454 $option .= $locale->text('Closed');
1456 if ($form->{globalproject_id}) {
1457 $callback .= "&globalproject_id=" . E($form->{globalproject_id});
1458 $href .= "&globalproject_id=" . E($form->{globalproject_id});
1462 qw(transdate id type invnumber ordnumber name netamount tax amount paid
1463 datepaid due duedate notes employee shippingpoint shipvia
1464 globalprojectnumber);
1466 $form->{"l_type"} = "Y";
1468 foreach $item (@columns) {
1469 if ($form->{"l_$item"} eq "Y") {
1470 push @column_index, $item;
1472 # add column to href and callback
1473 $callback .= "&l_$item=Y";
1474 $href .= "&l_$item=Y";
1478 if ($form->{l_subtotal} eq 'Y') {
1479 $callback .= "&l_subtotal=Y";
1480 $href .= "&l_subtotal=Y";
1483 $column_header{id} =
1484 "<th><a class=listheading href=$href&sort=id>"
1485 . $locale->text('ID')
1487 $column_header{transdate} =
1488 "<th><a class=listheading href=$href&sort=transdate>"
1489 . $locale->text('Date')
1491 $column_header{duedate} =
1492 "<th><a class=listheading href=$href&sort=duedate>"
1493 . $locale->text('Due Date')
1495 $column_header{type} =
1496 "<th class=\"listheading\">" . $locale->text('Type') . "</th>";
1497 $column_header{invnumber} =
1498 "<th><a class=listheading href=$href&sort=invnumber>"
1499 . $locale->text('Invoice')
1501 $column_header{ordnumber} =
1502 "<th><a class=listheading href=$href&sort=ordnumber>"
1503 . $locale->text('Order')
1505 $column_header{name} =
1506 "<th><a class=listheading href=$href&sort=name>"
1507 . $locale->text('Customer')
1509 $column_header{netamount} =
1510 "<th class=listheading>" . $locale->text('Amount') . "</th>";
1511 $column_header{tax} =
1512 "<th class=listheading>" . $locale->text('Tax') . "</th>";
1513 $column_header{amount} =
1514 "<th class=listheading>" . $locale->text('Total') . "</th>";
1515 $column_header{paid} =
1516 "<th class=listheading>" . $locale->text('Paid') . "</th>";
1517 $column_header{datepaid} =
1518 "<th><a class=listheading href=$href&sort=datepaid>"
1519 . $locale->text('Date Paid')
1521 $column_header{due} =
1522 "<th class=listheading>" . $locale->text('Amount Due') . "</th>";
1523 $column_header{notes} =
1524 "<th class=listheading>" . $locale->text('Notes') . "</th>";
1525 $column_header{employee} =
1526 "<th><a class=listheading href=$href&sort=employee>"
1527 . $locale->text('Salesperson') . "</th>";
1529 $column_header{shippingpoint} =
1530 "<th><a class=listheading href=$href&sort=shippingpoint>"
1531 . $locale->text('Shipping Point')
1533 $column_header{shipvia} =
1534 "<th><a class=listheading href=$href&sort=shipvia>"
1535 . $locale->text('Ship via')
1537 $column_header{globalprojectnumber} =
1538 qq|<th class="listheading">| . $locale->text('Project Number') . qq|</th>|;
1540 $form->{title} = $locale->text('AR Transactions');
1549 <th class=listtop>$form->{title}</th>
1551 <tr height="5"></tr>
1558 <tr class=listheading>
1561 map { print "\n$column_header{$_}" } @column_index;
1567 # add sort and escape callback, this one we use for the add sub
1568 $form->{callback} = $callback .= "&sort=$form->{sort}";
1570 # escape callback for href
1571 $callback = $form->escape($callback);
1573 if (@{ $form->{AR} }) {
1574 $sameitem = $form->{AR}->[0]->{ $form->{sort} };
1577 # sums and tax on reports by Antonio Gallardo
1579 foreach $ar (@{ $form->{AR} }) {
1581 if ($form->{l_subtotal} eq 'Y') {
1582 if ($sameitem ne $ar->{ $form->{sort} }) {
1587 $column_data{netamount} =
1589 . $form->format_amount(\%myconfig, $ar->{netamount}, 2, " ")
1591 $column_data{tax} = "<td align=right>"
1592 . $form->format_amount(\%myconfig, $ar->{amount} - $ar->{netamount},
1595 $column_data{amount} =
1597 . $form->format_amount(\%myconfig, $ar->{amount}, 2, " ") . "</td>";
1598 $column_data{paid} =
1600 . $form->format_amount(\%myconfig, $ar->{paid}, 2, " ") . "</td>";
1601 $column_data{due} = "<td align=right>"
1602 . $form->format_amount(\%myconfig, $ar->{amount} - $ar->{paid},
1606 $subtotalnetamount += $ar->{netamount};
1607 $subtotalamount += $ar->{amount};
1608 $subtotalpaid += $ar->{paid};
1609 $subtotaldue += $ar->{amount} - $ar->{paid};
1611 $totalnetamount += $ar->{netamount};
1612 $totalamount += $ar->{amount};
1613 $totalpaid += $ar->{paid};
1614 $totaldue += ($ar->{amount} - $ar->{paid});
1616 $column_data{transdate} = "<td>$ar->{transdate} </td>";
1617 $column_data{id} = "<td>$ar->{id}</td>";
1618 $column_data{datepaid} = "<td>$ar->{datepaid} </td>";
1619 $column_data{duedate} = "<td>$ar->{duedate} </td>";
1621 $module = ($ar->{invoice}) ? "is.pl" : $form->{script};
1623 $column_data{invnumber} =
1624 "<td><a href=$module?action=edit&id=$ar->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ar->{invnumber}</a></td>";
1625 $column_data{type} = "<td>" .
1626 ($ar->{storno} ? $locale->text("Storno (one letter abbreviation)") :
1628 $locale->text("Credit note (one letter abbreviation)") :
1629 $locale->text("Invoice (one letter abbreviation)")) . "</td>";
1630 $column_data{ordnumber} = "<td>$ar->{ordnumber} </td>";
1631 $column_data{name} = "<td>$ar->{name}</td>";
1632 $ar->{notes} =~ s/\r\n/<br>/g;
1633 $column_data{notes} = "<td>$ar->{notes} </td>";
1634 $column_data{shippingpoint} = "<td>$ar->{shippingpoint} </td>";
1635 $column_data{shipvia} = "<td>$ar->{shipvia} </td>";
1636 $column_data{employee} = "<td>$ar->{employee} </td>";
1637 $column_data{globalprojectnumber} =
1638 "<td>" . H($ar->{globalprojectnumber}) . "</td>";
1643 <tr class=listrow$i>
1646 map { print "\n$column_data{$_}" } @column_index;
1654 if ($form->{l_subtotal} eq 'Y') {
1660 <tr class=listtotal>
1663 map { $column_data{$_} = "<td> </td>" } @column_index;
1665 $column_data{netamount} =
1666 "<th class=listtotal align=right>"
1667 . $form->format_amount(\%myconfig, $totalnetamount, 2, " ") . "</th>";
1668 $column_data{tax} = "<th class=listtotal align=right>"
1669 . $form->format_amount(\%myconfig, $totalamount - $totalnetamount,
1672 $column_data{amount} =
1673 "<th class=listtotal align=right>"
1674 . $form->format_amount(\%myconfig, $totalamount, 2, " ") . "</th>";
1675 $column_data{paid} =
1676 "<th class=listtotal align=right>"
1677 . $form->format_amount(\%myconfig, $totalpaid, 2, " ") . "</th>";
1679 "<th class=listtotal align=right>"
1680 . $form->format_amount(\%myconfig, $totaldue, 2, " ") . "</th>";
1682 map { print "\n$column_data{$_}" } @column_index;
1690 <td><hr size=3 noshade></td>
1695 <form method=post action=$form->{script}>
1697 <input name=callback type=hidden value="$form->{callback}">
1699 <input type=hidden name=path value=$form->{path}>
1700 <input type=hidden name=login value=$form->{login}>
1701 <input type=hidden name=password value=$form->{password}>
1703 <input class=submit type=submit name=action value="|
1704 . $locale->text('AR Transaction') . qq|">
1705 <input class=submit type=submit name=action value="|
1706 . $locale->text('Sales Invoice') . qq|">
1714 $lxdebug->leave_sub();
1718 $lxdebug->enter_sub();
1720 map { $column_data{$_} = "<td> </td>" } @column_index;
1722 $column_data{tax} = "<th class=listsubtotal align=right>"
1723 . $form->format_amount(\%myconfig, $subtotalamount - $subtotalnetamount,
1726 $column_data{amount} =
1727 "<th class=listsubtotal align=right>"
1728 . $form->format_amount(\%myconfig, $subtotalamount, 2, " ") . "</th>";
1729 $column_data{paid} =
1730 "<th class=listsubtotal align=right>"
1731 . $form->format_amount(\%myconfig, $subtotalpaid, 2, " ") . "</th>";
1733 "<th class=listsubtotal align=right>"
1734 . $form->format_amount(\%myconfig, $subtotaldue, 2, " ") . "</th>";
1736 $subtotalnetamount = 0;
1737 $subtotalamount = 0;
1741 $sameitem = $ar->{ $form->{sort} };
1743 print "<tr class=listsubtotal>";
1745 map { print "\n$column_data{$_}" } @column_index;
1751 $lxdebug->leave_sub();