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 if (!$form->{id} && $form->{draft_id}) {
850 print(NTI($cgi->checkbox('-name' => 'remove_draft', '-id' => 'remove_draft',
851 '-value' => 1, '-checked' => $form->{remove_draft},
853 qq| <label for="remove_draft">| .
854 $locale->text("Remove draft when posting") .
858 $transdate = $form->datetonum($form->{transdate}, \%myconfig);
859 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
861 print qq|<input class=submit type=submit name=action value="|
862 . $locale->text('Update') . qq|">
865 if ($form->{radier}) {
867 <input class=submit type=submit name=action value="|
868 . $locale->text('Post') . qq|">
869 <input class=submit type=submit name=action value="|
870 . $locale->text('Delete') . qq|">
873 if ($transdate > $closedto) {
875 <input class=submit type=submit name=action value="|
876 . $locale->text('Use As Template') . qq|">
880 <input class=submit type=submit name=action value="|
881 . $locale->text('Post Payment') . qq|">
885 if ($transdate > $closedto) {
886 print qq|<input class=submit type=submit name=action value="|
887 . $locale->text('Post') . qq|"> | .
888 NTI($cgi->submit('-name' => 'action', '-value' => $locale->text('Save draft'),
889 '-class' => 'submit'));
893 if ($form->{menubar}) {
894 require "$form->{path}/menu.pl";
897 # button for saving history
898 if($form->{id} ne "") {
900 <input type=button class=submit onclick=set_history_window(|
902 . qq|); name=history id=history value=|
903 . $locale->text('history')
906 # /button for saving history
914 $lxdebug->leave_sub();
918 $lxdebug->enter_sub();
922 $form->{invtotal} = 0;
924 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
925 qw(exchangerate creditlimit creditremaining);
927 @flds = qw(amount AR_amount projectnumber oldprojectnumber project_id);
931 for $i (1 .. $form->{rowcount}) {
932 $form->{"amount_$i"} =
933 $form->parse_amount(\%myconfig, $form->{"amount_$i"});
934 $form->{"tax_$i"} = $form->parse_amount(\%myconfig, $form->{"tax_$i"});
935 if ($form->{"amount_$i"}) {
938 if (!$form->{"korrektur_$i"}) {
939 ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
941 if ($form->{taxincluded}) {
942 $form->{"tax_$i"} = $form->{"amount_$i"} / ($rate + 1) * $rate;
944 $form->{"tax_$i"} = $form->{"amount_$i"} * $rate;
947 $form->{"tax_$i"} = 0;
950 $form->{"tax_$i"} = $form->round_amount($form->{"tax_$i"}, 2);
952 $totaltax += $form->{"tax_$i"};
953 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
958 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
959 $form->{rowcount} = $count + 1;
960 map { $form->{invtotal} += $form->{"amount_$_"} } (1 .. $form->{rowcount});
962 $form->{exchangerate} = $exchangerate
966 $form->check_exchangerate(
967 \%myconfig, $form->{currency}, $form->{transdate}, 'buy'
970 $form->{invdate} = $form->{transdate};
971 $save_AR = $form->{AR};
972 &check_name(customer);
973 $form->{AR} = $save_AR;
976 ($form->{taxincluded}) ? $form->{invtotal} : $form->{invtotal} + $totaltax;
978 for $i (1 .. $form->{paidaccounts}) {
979 if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
982 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
983 } qw(paid exchangerate);
985 $totalpaid += $form->{"paid_$i"};
987 $form->{"exchangerate_$i"} = $exchangerate
989 $form->{"forex_$i"} = (
991 $form->check_exchangerate(
992 \%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'buy'
997 $form->{creditremaining} -=
998 ($form->{invtotal} - $totalpaid + $form->{oldtotalpaid} -
999 $form->{oldinvtotal});
1000 $form->{oldinvtotal} = $form->{invtotal};
1001 $form->{oldtotalpaid} = $totalpaid;
1005 $lxdebug->leave_sub();
1009 $lxdebug->enter_sub();
1010 for $i (1 .. $form->{paidaccounts}) {
1011 if ($form->{"paid_$i"}) {
1012 $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
1014 $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
1016 $form->error($locale->text('Cannot post payment for a closed period!'))
1017 if ($datepaid <= $closedto);
1019 if ($form->{currency} ne $form->{defaultcurrency}) {
1020 $form->{"exchangerate_$i"} = $form->{exchangerate}
1021 if ($invdate == $datepaid);
1022 $form->isblank("exchangerate_$i",
1023 $locale->text('Exchangerate for payment missing!'));
1028 ($form->{AR}) = split /--/, $form->{AR};
1029 ($form->{AR_paid}) = split /--/, $form->{AR_paid};
1030 $form->redirect($locale->text(' Payment posted!'))
1031 if (AR->post_payment(\%myconfig, \%$form));
1032 $form->error($locale->text('Cannot post payment!'));
1035 $lxdebug->leave_sub();
1039 $lxdebug->enter_sub();
1041 # check if there is an invoice number, invoice and due date
1042 $form->isblank("transdate", $locale->text('Invoice Date missing!'));
1043 $form->isblank("duedate", $locale->text('Due Date missing!'));
1044 $form->isblank("customer", $locale->text('Customer missing!'));
1046 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
1047 $transdate = $form->datetonum($form->{transdate}, \%myconfig);
1049 $form->error($locale->text('Cannot post transaction for a closed period!'))
1050 if ($transdate <= $closedto);
1052 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
1053 if ($form->{currency} ne $form->{defaultcurrency});
1055 delete($form->{AR});
1057 for $i (1 .. $form->{paidaccounts}) {
1058 if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
1059 $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
1061 $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
1063 $form->error($locale->text('Cannot post payment for a closed period!'))
1064 if ($datepaid <= $closedto);
1066 if ($form->{currency} ne $form->{defaultcurrency}) {
1067 $form->{"exchangerate_$i"} = $form->{exchangerate}
1068 if ($transdate == $datepaid);
1069 $form->isblank("exchangerate_$i",
1070 $locale->text('Exchangerate for payment missing!'));
1075 # if oldcustomer ne customer redo form
1076 ($customer) = split /--/, $form->{customer};
1077 if ($form->{oldcustomer} ne "$customer--$form->{customer_id}") {
1082 $form->{AR}{receivables} = $form->{ARselected};
1084 $form->{id} = 0 if $form->{postasnew};
1085 if (AR->post_transaction(\%myconfig, \%$form)) {
1086 # saving the history
1087 if(!exists $form->{addition} && $form->{id} ne "") {
1088 $form->{addition} = "POSTED";
1089 $form->save_history($form->dbconnect(\%myconfig));
1091 # /saving the history
1092 remove_draft() if $form->{remove_draft};
1093 $form->redirect($locale->text('Transaction posted!'));
1095 $form->error($locale->text('Cannot post transaction!'));
1097 $lxdebug->leave_sub();
1101 $lxdebug->enter_sub();
1103 $form->{postasnew} = 1;
1104 # saving the history
1105 if(!exists $form->{addition} && $form->{id} ne "") {
1106 $form->{addition} = "POSTED AS NEW";
1107 $form->save_history($form->dbconnect(\%myconfig));
1109 # /saving the history
1112 $lxdebug->leave_sub();
1115 sub use_as_template {
1116 $lxdebug->enter_sub();
1118 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);
1119 $form->{paidaccounts} = 1;
1120 $form->{rowcount}--;
1121 $form->{invdate} = $form->current_date(\%myconfig);
1124 $lxdebug->leave_sub();
1128 $lxdebug->enter_sub();
1130 $form->{title} = $locale->text('Confirm!');
1134 delete $form->{header};
1139 <form method=post action=$form->{script}>
1142 foreach $key (keys %$form) {
1143 $form->{$key} =~ s/\"/"/g;
1144 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
1148 <h2 class=confirm>$form->{title}</h2>
1151 . $locale->text('Are you sure you want to delete Transaction')
1152 . qq| $form->{invnumber}</h4>
1154 <input name=action class=submit type=submit value="|
1155 . $locale->text('Yes') . qq|">
1162 $lxdebug->leave_sub();
1166 $lxdebug->enter_sub();
1167 if (AR->delete_transaction(\%myconfig, \%$form, $spool)) {
1168 # saving the history
1169 if(!exists $form->{addition}) {
1170 $form->{addition} = "DELETED";
1171 $form->save_history($form->dbconnect(\%myconfig));
1173 # /saving the history
1174 $form->redirect($locale->text('Transaction deleted!'));
1176 $form->error($locale->text('Cannot delete transaction!'));
1178 $lxdebug->leave_sub();
1182 $lxdebug->enter_sub();
1184 # setup customer selection
1185 $form->all_vc(\%myconfig, "customer", "AR");
1187 if (@{ $form->{all_customer} }) {
1188 map { $customer .= "<option>$_->{name}--$_->{id}\n" }
1189 @{ $form->{all_customer} };
1190 $customer = qq|<select name=customer><option>\n$customer</select>|;
1192 $customer = qq|<input name=customer size=35>|;
1196 if (@{ $form->{all_departments} }) {
1197 $form->{selectdepartment} = "<option>\n";
1200 $form->{selectdepartment} .=
1201 "<option>$_->{description}--$_->{id}\n"
1202 } (@{ $form->{all_departments} });
1207 <th align=right nowrap>| . $locale->text('Department') . qq|</th>
1208 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
1210 | if $form->{selectdepartment};
1212 $form->{title} = $locale->text('AR Transactions');
1214 # use JavaScript Calendar or not
1215 $form->{jsscript} = $jscalendar;
1217 if ($form->{jsscript}) {
1219 # with JavaScript Calendar
1221 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}">
1222 <input type=button name=transdatefrom id="trigger1" value=|
1223 . $locale->text('button') . qq|></td>
1226 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}">
1227 <input type=button name=transdateto name=transdateto id="trigger2" value=|
1228 . $locale->text('button') . qq|></td>
1233 Form->write_trigger(\%myconfig, "2", "transdatefrom", "BR", "trigger1",
1234 "transdateto", "BL", "trigger2");
1237 # without JavaScript Calendar
1239 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>|;
1241 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}"></td>|;
1244 $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
1249 foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
1250 push(@values, $item->{"id"});
1251 $labels{$item->{"id"}} = $item->{"projectnumber"};
1254 NTI($cgi->popup_menu('-name' => 'project_id', '-values' => \@values,
1255 '-labels' => \%labels));
1257 $form->{fokus} = "search.customer";
1261 <body onLoad="fokus()">
1263 <form method=post name="search" action=$form->{script}>
1266 <tr><th class=listtop>$form->{title}</th></tr>
1267 <tr height="5"></tr>
1272 <th align=right>| . $locale->text('Customer') . qq|</th>
1273 <td colspan=3>$customer</td>
1277 <th align=right nowrap>| . $locale->text('Invoice Number') . qq|</th>
1278 <td colspan=3><input name=invnumber size=20></td>
1281 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
1282 <td colspan=3><input name=ordnumber size=20></td>
1285 <th align=right nowrap>| . $locale->text('Notes') . qq|</th>
1286 <td colspan=3><input name=notes size=40></td>
1289 <th align="right">| . $locale->text("Project Number") . qq|</th>
1290 <td colspan="3">$projectnumber</td>
1293 <th align=right nowrap>| . $locale->text('From') . qq|</th>
1295 <th align=right>| . $locale->text('Bis') . qq|</th>
1298 <input type=hidden name=sort value=transdate>
1306 <th align=right nowrap>| . $locale->text('Include in Report') . qq|</th>
1310 <td align=right><input name=open class=checkbox type=checkbox value=Y checked></td>
1311 <td nowrap>| . $locale->text('Open') . qq|</td>
1312 <td align=right><input name=closed class=checkbox type=checkbox value=Y></td>
1313 <td nowrap>| . $locale->text('Closed') . qq|</td>
1316 <td align=right><input name="l_id" class=checkbox type=checkbox value=Y></td>
1317 <td nowrap>| . $locale->text('ID') . qq|</td>
1318 <td align=right><input name="l_invnumber" class=checkbox type=checkbox value=Y checked></td>
1319 <td nowrap>| . $locale->text('Invoice Number') . qq|</td>
1320 <td align=right><input name="l_ordnumber" class=checkbox type=checkbox value=Y></td>
1321 <td nowrap>| . $locale->text('Order Number') . qq|</td>
1322 <td align=right><input name="l_transdate" class=checkbox type=checkbox value=Y checked></td>
1323 <td nowrap>| . $locale->text('Invoice Date') . qq|</td>
1326 <td align=right><input name="l_name" class=checkbox type=checkbox value=Y checked></td>
1327 <td nowrap>| . $locale->text('Customer') . qq|</td>
1328 <td align=right><input name="l_netamount" class=checkbox type=checkbox value=Y></td>
1329 <td nowrap>| . $locale->text('Amount') . qq|</td>
1330 <td align=right><input name="l_tax" class=checkbox type=checkbox value=Y></td>
1331 <td nowrap>| . $locale->text('Tax') . qq|</td>
1332 <td align=right><input name="l_amount" class=checkbox type=checkbox value=Y checked></td>
1333 <td nowrap>| . $locale->text('Total') . qq|</td>
1336 <td align=right><input name="l_datepaid" class=checkbox type=checkbox value=Y></td>
1337 <td nowrap>| . $locale->text('Date Paid') . qq|</td>
1338 <td align=right><input name="l_paid" class=checkbox type=checkbox value=Y checked></td>
1339 <td nowrap>| . $locale->text('Paid') . qq|</td>
1340 <td align=right><input name="l_duedate" class=checkbox type=checkbox value=Y></td>
1341 <td nowrap>| . $locale->text('Due Date') . qq|</td>
1342 <td align=right><input name="l_due" class=checkbox type=checkbox value=Y></td>
1343 <td nowrap>| . $locale->text('Amount Due') . qq|</td>
1346 <td align=right><input name="l_notes" class=checkbox type=checkbox value=Y></td>
1347 <td nowrap>| . $locale->text('Notes') . qq|</td>
1348 <td align=right><input name="l_employee" class=checkbox type=checkbox value=Y></td>
1349 <td nowrap>| . $locale->text('Salesperson') . qq|</td>
1350 <td align=right><input name="l_shippingpoint" class=checkbox type=checkbox value=Y></td>
1351 <td nowrap>| . $locale->text('Shipping Point') . qq|</td>
1352 <td align=right><input name="l_shipvia" class=checkbox type=checkbox value=Y></td>
1353 <td nowrap>| . $locale->text('Ship via') . qq|</td>
1356 <td align=right><input name="l_subtotal" class=checkbox type=checkbox value=Y></td>
1357 <td nowrap>| . $locale->text('Subtotal') . qq|</td>
1358 <td align=right><input name="l_globalprojectnumber" class=checkbox type=checkbox value=Y></td>
1359 <td nowrap>| . $locale->text('Project Number') . qq|</td>
1368 <td><hr size=3 noshade></td>
1372 <input type=hidden name=nextsub value=$form->{nextsub}>
1374 <input type=hidden name=path value=$form->{path}>
1375 <input type=hidden name=login value=$form->{login}>
1376 <input type=hidden name=password value=$form->{password}>
1379 <input class=submit type=submit name=action value="|
1380 . $locale->text('Continue') . qq|">
1391 $lxdebug->leave_sub();
1394 sub ar_transactions {
1395 $lxdebug->enter_sub();
1397 $form->{customer} = $form->unescape($form->{customer});
1398 ($form->{customer}, $form->{customer_id}) = split(/--/, $form->{customer});
1400 AR->ar_transactions(\%myconfig, \%$form);
1403 "$form->{script}?action=ar_transactions&path=$form->{path}&login=$form->{login}&password=$form->{password}";
1406 if ($form->{customer}) {
1407 $callback .= "&customer=" . $form->escape($form->{customer}, 1);
1408 $href .= "&customer=" . $form->escape($form->{customer});
1409 $option = $locale->text('Customer') . " : $form->{customer}";
1411 if ($form->{department}) {
1412 $callback .= "&department=" . $form->escape($form->{department}, 1);
1413 $href .= "&department=" . $form->escape($form->{department});
1414 ($department) = split /--/, $form->{department};
1415 $option .= "\n<br>" if ($option);
1416 $option .= $locale->text('Department') . " : $department";
1418 if ($form->{invnumber}) {
1419 $callback .= "&invnumber=" . $form->escape($form->{invnumber}, 1);
1420 $href .= "&invnumber=" . $form->escape($form->{invnumber});
1421 $option .= "\n<br>" if ($option);
1422 $option .= $locale->text('Invoice Number') . " : $form->{invnumber}";
1424 if ($form->{ordnumber}) {
1425 $callback .= "&ordnumber=" . $form->escape($form->{ordnumber}, 1);
1426 $href .= "&ordnumber=" . $form->escape($form->{ordnumber});
1427 $option .= "\n<br>" if ($option);
1428 $option .= $locale->text('Order Number') . " : $form->{ordnumber}";
1430 if ($form->{notes}) {
1431 $callback .= "¬es=" . $form->escape($form->{notes}, 1);
1432 $href .= "¬es=" . $form->escape($form->{notes});
1433 $option .= "\n<br>" if $option;
1434 $option .= $locale->text('Notes') . " : $form->{notes}";
1437 if ($form->{transdatefrom}) {
1438 $callback .= "&transdatefrom=$form->{transdatefrom}";
1439 $href .= "&transdatefrom=$form->{transdatefrom}";
1440 $option .= "\n<br>" if ($option);
1442 $locale->text('From') . " "
1443 . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
1445 if ($form->{transdateto}) {
1446 $callback .= "&transdateto=$form->{transdateto}";
1447 $href .= "&transdateto=$form->{transdateto}";
1448 $option .= "\n<br>" if ($option);
1450 $locale->text('Bis') . " "
1451 . $locale->date(\%myconfig, $form->{transdateto}, 1);
1453 if ($form->{open}) {
1454 $callback .= "&open=$form->{open}";
1455 $href .= "&open=$form->{open}";
1456 $option .= "\n<br>" if ($option);
1457 $option .= $locale->text('Open');
1459 if ($form->{closed}) {
1460 $callback .= "&closed=$form->{closed}";
1461 $href .= "&closed=$form->{closed}";
1462 $option .= "\n<br>" if ($option);
1463 $option .= $locale->text('Closed');
1465 if ($form->{globalproject_id}) {
1466 $callback .= "&globalproject_id=" . E($form->{globalproject_id});
1467 $href .= "&globalproject_id=" . E($form->{globalproject_id});
1471 qw(transdate id type invnumber ordnumber name netamount tax amount paid
1472 datepaid due duedate notes employee shippingpoint shipvia
1473 globalprojectnumber);
1475 $form->{"l_type"} = "Y";
1477 foreach $item (@columns) {
1478 if ($form->{"l_$item"} eq "Y") {
1479 push @column_index, $item;
1481 # add column to href and callback
1482 $callback .= "&l_$item=Y";
1483 $href .= "&l_$item=Y";
1487 if ($form->{l_subtotal} eq 'Y') {
1488 $callback .= "&l_subtotal=Y";
1489 $href .= "&l_subtotal=Y";
1492 $column_header{id} =
1493 "<th><a class=listheading href=$href&sort=id>"
1494 . $locale->text('ID')
1496 $column_header{transdate} =
1497 "<th><a class=listheading href=$href&sort=transdate>"
1498 . $locale->text('Date')
1500 $column_header{duedate} =
1501 "<th><a class=listheading href=$href&sort=duedate>"
1502 . $locale->text('Due Date')
1504 $column_header{type} =
1505 "<th class=\"listheading\">" . $locale->text('Type') . "</th>";
1506 $column_header{invnumber} =
1507 "<th><a class=listheading href=$href&sort=invnumber>"
1508 . $locale->text('Invoice')
1510 $column_header{ordnumber} =
1511 "<th><a class=listheading href=$href&sort=ordnumber>"
1512 . $locale->text('Order')
1514 $column_header{name} =
1515 "<th><a class=listheading href=$href&sort=name>"
1516 . $locale->text('Customer')
1518 $column_header{netamount} =
1519 "<th class=listheading>" . $locale->text('Amount') . "</th>";
1520 $column_header{tax} =
1521 "<th class=listheading>" . $locale->text('Tax') . "</th>";
1522 $column_header{amount} =
1523 "<th class=listheading>" . $locale->text('Total') . "</th>";
1524 $column_header{paid} =
1525 "<th class=listheading>" . $locale->text('Paid') . "</th>";
1526 $column_header{datepaid} =
1527 "<th><a class=listheading href=$href&sort=datepaid>"
1528 . $locale->text('Date Paid')
1530 $column_header{due} =
1531 "<th class=listheading>" . $locale->text('Amount Due') . "</th>";
1532 $column_header{notes} =
1533 "<th class=listheading>" . $locale->text('Notes') . "</th>";
1534 $column_header{employee} =
1535 "<th><a class=listheading href=$href&sort=employee>"
1536 . $locale->text('Salesperson') . "</th>";
1538 $column_header{shippingpoint} =
1539 "<th><a class=listheading href=$href&sort=shippingpoint>"
1540 . $locale->text('Shipping Point')
1542 $column_header{shipvia} =
1543 "<th><a class=listheading href=$href&sort=shipvia>"
1544 . $locale->text('Ship via')
1546 $column_header{globalprojectnumber} =
1547 qq|<th class="listheading">| . $locale->text('Project Number') . qq|</th>|;
1549 $form->{title} = $locale->text('AR Transactions');
1558 <th class=listtop>$form->{title}</th>
1560 <tr height="5"></tr>
1567 <tr class=listheading>
1570 map { print "\n$column_header{$_}" } @column_index;
1576 # add sort and escape callback, this one we use for the add sub
1577 $form->{callback} = $callback .= "&sort=$form->{sort}";
1579 # escape callback for href
1580 $callback = $form->escape($callback);
1582 if (@{ $form->{AR} }) {
1583 $sameitem = $form->{AR}->[0]->{ $form->{sort} };
1586 # sums and tax on reports by Antonio Gallardo
1588 foreach $ar (@{ $form->{AR} }) {
1590 if ($form->{l_subtotal} eq 'Y') {
1591 if ($sameitem ne $ar->{ $form->{sort} }) {
1596 $column_data{netamount} =
1598 . $form->format_amount(\%myconfig, $ar->{netamount}, 2, " ")
1600 $column_data{tax} = "<td align=right>"
1601 . $form->format_amount(\%myconfig, $ar->{amount} - $ar->{netamount},
1604 $column_data{amount} =
1606 . $form->format_amount(\%myconfig, $ar->{amount}, 2, " ") . "</td>";
1607 $column_data{paid} =
1609 . $form->format_amount(\%myconfig, $ar->{paid}, 2, " ") . "</td>";
1610 $column_data{due} = "<td align=right>"
1611 . $form->format_amount(\%myconfig, $ar->{amount} - $ar->{paid},
1615 $subtotalnetamount += $ar->{netamount};
1616 $subtotalamount += $ar->{amount};
1617 $subtotalpaid += $ar->{paid};
1618 $subtotaldue += $ar->{amount} - $ar->{paid};
1620 $totalnetamount += $ar->{netamount};
1621 $totalamount += $ar->{amount};
1622 $totalpaid += $ar->{paid};
1623 $totaldue += ($ar->{amount} - $ar->{paid});
1625 $column_data{transdate} = "<td>$ar->{transdate} </td>";
1626 $column_data{id} = "<td>$ar->{id}</td>";
1627 $column_data{datepaid} = "<td>$ar->{datepaid} </td>";
1628 $column_data{duedate} = "<td>$ar->{duedate} </td>";
1630 $module = ($ar->{invoice}) ? "is.pl" : $form->{script};
1632 $column_data{invnumber} =
1633 "<td><a href=$module?action=edit&id=$ar->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ar->{invnumber}</a></td>";
1634 $column_data{type} = "<td>" .
1635 ($ar->{storno} ? $locale->text("Storno (one letter abbreviation)") :
1637 $locale->text("Credit note (one letter abbreviation)") :
1638 $locale->text("Invoice (one letter abbreviation)")) . "</td>";
1639 $column_data{ordnumber} = "<td>$ar->{ordnumber} </td>";
1640 $column_data{name} = "<td>$ar->{name}</td>";
1641 $ar->{notes} =~ s/\r\n/<br>/g;
1642 $column_data{notes} = "<td>$ar->{notes} </td>";
1643 $column_data{shippingpoint} = "<td>$ar->{shippingpoint} </td>";
1644 $column_data{shipvia} = "<td>$ar->{shipvia} </td>";
1645 $column_data{employee} = "<td>$ar->{employee} </td>";
1646 $column_data{globalprojectnumber} =
1647 "<td>" . H($ar->{globalprojectnumber}) . "</td>";
1652 <tr class=listrow$i>
1655 map { print "\n$column_data{$_}" } @column_index;
1663 if ($form->{l_subtotal} eq 'Y') {
1669 <tr class=listtotal>
1672 map { $column_data{$_} = "<td> </td>" } @column_index;
1674 $column_data{netamount} =
1675 "<th class=listtotal align=right>"
1676 . $form->format_amount(\%myconfig, $totalnetamount, 2, " ") . "</th>";
1677 $column_data{tax} = "<th class=listtotal align=right>"
1678 . $form->format_amount(\%myconfig, $totalamount - $totalnetamount,
1681 $column_data{amount} =
1682 "<th class=listtotal align=right>"
1683 . $form->format_amount(\%myconfig, $totalamount, 2, " ") . "</th>";
1684 $column_data{paid} =
1685 "<th class=listtotal align=right>"
1686 . $form->format_amount(\%myconfig, $totalpaid, 2, " ") . "</th>";
1688 "<th class=listtotal align=right>"
1689 . $form->format_amount(\%myconfig, $totaldue, 2, " ") . "</th>";
1691 map { print "\n$column_data{$_}" } @column_index;
1699 <td><hr size=3 noshade></td>
1704 <form method=post action=$form->{script}>
1706 <input name=callback type=hidden value="$form->{callback}">
1708 <input type=hidden name=path value=$form->{path}>
1709 <input type=hidden name=login value=$form->{login}>
1710 <input type=hidden name=password value=$form->{password}>
1712 <input class=submit type=submit name=action value="|
1713 . $locale->text('AR Transaction') . qq|">
1714 <input class=submit type=submit name=action value="|
1715 . $locale->text('Sales Invoice') . qq|">
1723 $lxdebug->leave_sub();
1727 $lxdebug->enter_sub();
1729 map { $column_data{$_} = "<td> </td>" } @column_index;
1731 $column_data{tax} = "<th class=listsubtotal align=right>"
1732 . $form->format_amount(\%myconfig, $subtotalamount - $subtotalnetamount,
1735 $column_data{amount} =
1736 "<th class=listsubtotal align=right>"
1737 . $form->format_amount(\%myconfig, $subtotalamount, 2, " ") . "</th>";
1738 $column_data{paid} =
1739 "<th class=listsubtotal align=right>"
1740 . $form->format_amount(\%myconfig, $subtotalpaid, 2, " ") . "</th>";
1742 "<th class=listsubtotal align=right>"
1743 . $form->format_amount(\%myconfig, $subtotaldue, 2, " ") . "</th>";
1745 $subtotalnetamount = 0;
1746 $subtotalamount = 0;
1750 $sameitem = $ar->{ $form->{sort} };
1752 print "<tr class=listsubtotal>";
1754 map { print "\n$column_data{$_}" } @column_index;
1760 $lxdebug->leave_sub();