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 $form->{notes} = $form->{intnotes} unless $form->{notes};
143 @curr = split(/:/, $form->{currencies});
145 $form->{defaultcurrency} = $curr[0];
147 map { $form->{selectcurrency} .= "<option>$_\n" } @curr;
150 if (@{ $form->{all_customer} }) {
151 $form->{customer} = "$form->{customer}--$form->{customer_id}";
152 map { $form->{selectcustomer} .= "<option>$_->{name}--$_->{id}\n" }
153 (@{ $form->{all_customer} });
157 if (@{ $form->{all_departments} }) {
158 $form->{selectdepartment} = "<option>\n";
159 $form->{department} = "$form->{department}--$form->{department_id}";
162 $form->{selectdepartment} .=
163 "<option>$_->{description}--$_->{id}\n"
164 } (@{ $form->{all_departments} });
167 $form->{employee} = "$form->{employee}--$form->{employee_id}";
170 if (@{ $form->{all_employees} }) {
171 $form->{selectemployee} = "";
172 map { $form->{selectemployee} .= "<option>$_->{name}--$_->{id}\n" }
173 (@{ $form->{all_employees} });
176 # build the popup menus
177 $form->{taxincluded} = ($form->{id}) ? $form->{taxincluded} : "checked";
180 $form->{forex} = $form->{exchangerate};
181 $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
182 foreach $key (keys %{ $form->{AR_links} }) {
183 # if there is a value we have an old entry
187 for $i (1 .. scalar @{ $form->{acc_trans}{$key} }) {
188 if ($key eq "AR_paid") {
190 $form->{"AR_paid_$j"} = $form->{acc_trans}{$key}->[$i-1]->{accno};
193 $form->{"paid_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{amount} * -1;
194 $form->{"datepaid_$j"} =
195 $form->{acc_trans}{$key}->[$i - 1]->{transdate};
196 $form->{"source_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{source};
197 $form->{"memo_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{memo};
199 $form->{"forex_$j"} = $form->{"exchangerate_$i"} =
200 $form->{acc_trans}{$key}->[$i - 1]->{exchangerate};
201 $form->{"paid_project_id_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{project_id};
202 $form->{paidaccounts}++;
209 if ($key eq "AR_tax" || $key eq "AP_tax") {
210 $form->{"${key}_$form->{acc_trans}{$key}->[$i-1]->{accno}"} =
211 "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
212 $form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"} =
214 $form->{acc_trans}{$key}->[$i - 1]->{amount} / $exchangerate,
217 if ($form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"} > 0) {
219 $form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"};
221 $form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"};
224 $form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"};
226 $form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"};
228 $index = $form->{acc_trans}{$key}->[$i - 1]->{index};
229 $form->{"tax_$index"} = $form->{acc_trans}{$key}->[$i - 1]->{amount};
230 $totaltax += $form->{"tax_$index"};
234 $form->{"${akey}_$k"} =
236 $form->{acc_trans}{$key}->[$i - 1]->{amount} / $exchangerate,
238 if ($akey eq 'amount') {
240 $totalamount += $form->{"${akey}_$i"};
242 $form->{"oldprojectnumber_$k"} = $form->{"projectnumber_$k"} =
243 "$form->{acc_trans}{$key}->[$i-1]->{projectnumber}";
244 $form->{taxrate} = $form->{acc_trans}{$key}->[$i - 1]->{rate};
245 $form->{"project_id_$k"} =
246 "$form->{acc_trans}{$key}->[$i-1]->{project_id}";
248 $form->{"${key}_$i"} =
249 "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
252 $form->{ARselected} = $form->{acc_trans}{$key}->[$i-1]->{accno};
254 } elsif ($akey eq "amount") {
255 $form->{"${key}_$k"} = $form->{acc_trans}{$key}->[$i-1]->{accno} .
256 "--" . $form->{acc_trans}{$key}->[$i-1]->{id};
257 $form->{"taxchart_$k"} = $form->{acc_trans}{$key}->[$i-1]->{id} .
258 "--" . $form->{acc_trans}{$key}->[$i-1]->{rate};
265 $form->{taxincluded} = $taxincluded if ($form->{id});
266 $form->{paidaccounts} = 1 if not defined $form->{paidaccounts};
268 if ($form->{taxincluded} && $form->{taxrate} && $totalamount) {
270 # add tax to amounts and invtotal
271 for $i (1 .. $form->{rowcount}) {
273 ($totaltax + $totalwithholding) * $form->{"amount_$i"} / $totalamount;
274 $tax = $form->round_amount($taxamount, 2);
275 $diff += ($taxamount - $tax);
276 $form->{"amount_$i"} += $form->{"tax_$i"};
278 $form->{amount_1} += $form->round_amount($diff, 2);
281 $taxamount = $form->round_amount($taxamount, 2);
282 $form->{tax} = $taxamount;
284 $form->{invtotal} = $totalamount + $totaltax;
287 ($form->datetonum($form->{transdate}, \%myconfig) <=
288 $form->datetonum($form->{closedto}, \%myconfig));
290 $lxdebug->leave_sub();
294 $lxdebug->enter_sub();
296 $title = $form->{title};
297 $form->{title} = $locale->text("$title Accounts Receivables Transaction");
299 $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
301 # $locale->text('Add Accounts Receivables Transaction')
302 # $locale->text('Edit Accounts Receivables Transaction')
303 $form->{javascript} = qq|<script type="text/javascript">
305 function setTaxkey(accno, row) {
306 var taxkey = accno.options[accno.selectedIndex].value;
307 var reg = /--([0-9]*)/;
308 var found = reg.exec(taxkey);
309 var index = found[1];
310 index = parseInt(index);
311 var tax = 'taxchart_' + row;
312 for (var i = 0; i < document.getElementById(tax).options.length; ++i) {
313 var reg2 = new RegExp("^"+ index, "");
314 if (reg2.exec(document.getElementById(tax).options[i].value)) {
315 document.getElementById(tax).options[i].selected = true;
322 # show history button js
323 $form->{javascript} .= qq|<script type="text/javascript" src="js/show_history.js"></script>|;
324 #/show history button js
326 $readonly = ($form->{id}) ? "readonly" : "";
329 ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0;
330 $readonly = ($form->{radier}) ? "" : $readonly;
332 # set option selected
333 foreach $item (qw(customer currency department employee)) {
334 $form->{"select$item"} =~ s/ selected//;
335 $form->{"select$item"} =~
336 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
340 $form->{exchangerate} =
341 $form->format_amount(\%myconfig, $form->{exchangerate});
343 $form->{creditlimit} =
344 $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
345 $form->{creditremaining} =
346 $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
349 <input type=hidden name=forex value=$form->{forex}>
351 if ($form->{currency} ne $form->{defaultcurrency}) {
352 if ($form->{forex}) {
354 <th align=right>| . $locale->text('Exchangerate') . qq|</th>
355 <td><input type=hidden name=exchangerate value=$form->{exchangerate}>$form->{exchangerate}</td>
359 <th align=right>| . $locale->text('Exchangerate') . qq|</th>
360 <td><input name=exchangerate size=10 value=$form->{exchangerate}></td>
367 <td align=right><input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}></td>
368 <th align=left nowrap>| . $locale->text('Tax Included') . qq|</th>
372 if (($rows = $form->numtextrows($form->{notes}, 50)) < 2) {
376 qq|<textarea name=notes rows=$rows cols=50 wrap=soft>$form->{notes}</textarea>|;
380 <th align="right" nowrap>| . $locale->text('Department') . qq|</th>
381 <td colspan=3><select name=department>$form->{selectdepartment}</select>
382 <input type=hidden name=selectdepartment value="$form->{selectdepartment}">
385 | if $form->{selectdepartment};
387 $n = ($form->{creditremaining} =~ /-/) ? "0" : "1";
390 ($form->{selectcustomer})
391 ? qq|<select name="customer"
392 onchange="document.getElementById('update_button').click();">$form->{
393 selectcustomer}</select>|
394 : qq|<input name=customer value="$form->{customer}" size=35>|;
397 <input type=hidden name=employee value="$form->{employee}">
400 if ($form->{selectemployee}) {
403 <th align=right nowrap>| . $locale->text('Salesperson') . qq|</th>
404 <td colspan=2><select name=employee>$form->{selectemployee}</select></td>
405 <input type=hidden name=selectemployee value="$form->{selectemployee}">
410 my @old_project_ids = ();
411 map({ push(@old_project_ids, $form->{"project_id_$_"})
412 if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
414 $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
416 "old_id" => \@old_project_ids },
417 "charts" => { "key" => "ALL_CHARTS",
418 "transdate" => $form->{transdate} },
419 "taxcharts" => "ALL_TAXCHARTS");
421 map({ $_->{link_split} = [ split(/:/, $_->{link}) ]; }
422 @{ $form->{ALL_CHARTS} });
424 my %project_labels = ();
425 my @project_values = ("");
426 foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
427 push(@project_values, $item->{"id"});
428 $project_labels{$item->{"id"}} = $item->{"projectnumber"};
431 my (%AR_amount_labels, @AR_amount_values);
432 my (%AR_labels, @AR_values);
433 my (%AR_paid_labels, @AR_paid_values);
437 foreach my $item (@{ $form->{ALL_CHARTS} }) {
438 if (grep({ $_ eq "AR_amount" } @{ $item->{link_split} })) {
439 $taxchart_init = $item->{tax_id} if ($taxchart_init eq "");
440 my $key = "$item->{accno}--$item->{tax_id}";
441 push(@AR_amount_values, $key);
442 $AR_amount_labels{$key} =
443 "$item->{accno}--$item->{description}";
445 } elsif (grep({ $_ eq "AR" } @{ $item->{link_split} })) {
446 push(@AR_values, $item->{accno});
447 $AR_labels{$item->{accno}} = "$item->{accno}--$item->{description}";
449 } elsif (grep({ $_ eq "AR_paid" } @{ $item->{link_split} })) {
450 push(@AR_paid_values, $item->{accno});
451 $AR_paid_labels{$item->{accno}} =
452 "$item->{accno}--$item->{description}";
455 $charts{$item->{accno}} = $item;
458 my %taxchart_labels = ();
459 my @taxchart_values = ();
461 foreach my $item (@{ $form->{ALL_TAXCHARTS} }) {
462 my $key = "$item->{id}--$item->{rate}";
463 $taxchart_init = $key if ($taxchart_init eq $item->{id});
464 push(@taxchart_values, $key);
465 $taxchart_labels{$key} =
466 "$item->{taxdescription} " . ($item->{rate} * 100) . ' %';
467 $taxcharts{$item->{id}} = $item;
470 $form->{fokus} = "arledger.customer";
472 # use JavaScript Calendar or not
473 $form->{jsscript} = $jscalendar;
475 if ($form->{jsscript}) {
477 # with JavaScript Calendar
479 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>
480 <td><input type=button name=transdate id="trigger1" value=|
481 . $locale->text('button') . qq|></td>
484 <td><input name=duedate id=duedate size=11 title="$myconfig{dateformat}" value=$form->{duedate}></td>
485 <td><input type=button name=duedate id="trigger2" value=|
486 . $locale->text('button') . qq|></td></td>
491 Form->write_trigger(\%myconfig, "2", "transdate", "BL", "trigger1",
492 "duedate", "BL", "trigger2");
495 # without JavaScript Calendar
497 qq|<td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>|;
499 qq|<td><input name=duedate id=duedate size=11 title="$myconfig{dateformat}" value=$form->{duedate}></td>|;
505 <body onLoad="fokus()">
507 <form method=post name="arledger" action=$form->{script}>
509 <input type=hidden name=id value=$form->{id}>
510 <input type=hidden name=sort value=$form->{sort}>
511 <input type=hidden name=closedto value=$form->{closedto}>
512 <input type=hidden name=locked value=$form->{locked}>
513 <input type=hidden name=title value="$title">
515 | . ($form->{saved_message} ? qq|<p>$form->{saved_message}</p>| : "") . qq|
519 <th class=listtop>$form->{title}</th>
529 <th align="right" nowrap>| . $locale->text('Customer') . qq|</th>
530 <td colspan=3>$customer</td>
531 <input type=hidden name=selectcustomer value="$form->{selectcustomer}">
532 <input type=hidden name=oldcustomer value="$form->{oldcustomer}">
533 <input type=hidden name=customer_id value="$form->{customer_id}">
534 <input type=hidden name=terms value=$form->{terms}>
541 <th align=left nowrap>| . $locale->text('Credit Limit') . qq|</th>
542 <td>$form->{creditlimit}</td>
543 <th align=left nowrap>| . $locale->text('Remaining') . qq|</th>
544 <td class="plus$n">$form->{creditremaining}</td>
545 <input type=hidden name=creditlimit value=$form->{creditlimit}>
546 <input type=hidden name=creditremaining value=$form->{creditremaining}>
552 <th align=right>| . $locale->text('Currency') . qq|</th>
553 <td><select name=currency>$form->{selectcurrency}</select></td>
554 <input type=hidden name=selectcurrency value="$form->{selectcurrency}">
555 <input type=hidden name=defaultcurrency value=$form->{defaultcurrency}>
556 <input type=hidden name=fxgain_accno value=$form->{fxgain_accno}>
557 <input type=hidden name=fxloss_accno value=$form->{fxloss_accno}>
568 <th align=right nowrap>| . $locale->text('Invoice Number') . qq|</th>
569 <td><input name=invnumber size=11 value="$form->{invnumber}"></td>
572 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
573 <td><input name=ordnumber size=11 value="$form->{ordnumber}"></td>
576 <th align=right nowrap>| . $locale->text('Invoice Date') . qq|</th>
580 <th align=right nowrap>| . $locale->text('Due Date') . qq|</th>
591 <input type=hidden name=rowcount value=$form->{rowcount}>
595 <tr class=listheading>
596 <th class=listheading style="width:15%">|
597 . $locale->text('Account') . qq|</th>
598 <th class=listheading style="width:10%">|
599 . $locale->text('Amount') . qq|</th>
600 <th class=listheading style="width:10%">|
601 . $locale->text('Tax') . qq|</th>
602 <th class=listheading style="width:5%">|
603 . $locale->text('Korrektur') . qq|</th>
604 <th class=listheading style="width:10%">|
605 . $locale->text('Taxkey') . qq|</th>
606 <th class=listheading style="width:10%">|
607 . $locale->text('Project') . qq|</th>
611 $amount = $locale->text('Amount');
612 $project = $locale->text('Project');
614 for $i (1 .. $form->{rowcount}) {
617 $form->{"amount_$i"} =
618 $form->format_amount(\%myconfig, $form->{"amount_$i"}, 2);
619 $form->{"tax_$i"} = $form->format_amount(\%myconfig, $form->{"tax_$i"}, 2);
621 my $selected_accno_full;
622 my ($accno_row) = split(/--/, $form->{"AR_amount_$i"});
623 my $item = $charts{$accno_row};
624 $selected_accno_full = "$item->{accno}--$item->{tax_id}";
626 my $selected_taxchart = $form->{"taxchart_$i"};
627 my ($selected_accno, $selected_tax_id) = split(/--/, $selected_accno_full);
628 my ($previous_accno, $previous_tax_id) = split(/--/, $form->{"previous_AR_amount_$i"});
630 if ($previous_accno &&
631 ($previous_accno eq $selected_accno) &&
632 ($previous_tax_id ne $selected_tax_id)) {
633 my $item = $taxcharts{$selected_tax_id};
634 $selected_taxchart = "$item->{id}--$item->{rate}";
637 $selected_taxchart = $taxchart_init unless ($form->{"taxchart_$i"});
640 NTI($cgi->popup_menu('-name' => "AR_amount_$i",
641 '-id' => "AR_amount_$i",
642 '-style' => 'width:400px',
643 '-onChange' => "setTaxkey(this, $i)",
644 '-values' => \@AR_amount_values,
645 '-labels' => \%AR_amount_labels,
646 '-default' => $selected_accno_full))
647 . $cgi->hidden('-name' => "previous_AR_amount_$i",
648 '-default' => $selected_accno_full);
651 NTI($cgi->popup_menu('-name' => "taxchart_$i",
652 '-id' => "taxchart_$i",
653 '-style' => 'width:200px',
654 '-values' => \@taxchart_values,
655 '-labels' => \%taxchart_labels,
656 '-default' => $selected_taxchart))
659 $korrektur_checked = ($form->{"korrektur_$i"} ? 'checked' : '');
662 NTI($cgi->popup_menu('-name' => "project_id_$i",
663 '-values' => \@project_values,
664 '-labels' => \%project_labels,
665 '-default' => $form->{"project_id_$i"} ));
669 <td>$selectAR_amount</td>
670 <td><input name="amount_$i" size=10 value=$form->{"amount_$i"}></td>
671 <td><input name="tax_$i" size=10 value=$form->{"tax_$i"}></td>
672 <td><input type="checkbox" name="korrektur_$i" value="1" $korrektur_checked></td>
674 <td>$projectnumber</td>
681 $form->{invtotal} = $form->format_amount(\%myconfig, $form->{invtotal}, 2);
684 NTI($cgi->popup_menu('-name' => "ARselected", '-id' => "ARselected",
685 '-style' => 'width:400px',
686 '-values' => \@AR_values, '-labels' => \%AR_labels,
687 '-default' => $form->{ARselected}));
696 <td>${ARselected}</td>
697 <th align=left>$form->{invtotal}</th>
699 <input type=hidden name=oldinvtotal value=$form->{oldinvtotal}>
700 <input type=hidden name=oldtotalpaid value=$form->{oldtotalpaid}>
702 <input type=hidden name=taxaccounts value="$form->{taxaccounts}">
715 <th align=left width=1%>| . $locale->text('Notes') . qq|</th>
716 <td align=left>$notes</td>
724 <tr class=listheading>
725 <th colspan=7 class=listheading>|
726 . $locale->text('Incoming Payments') . qq|</th>
730 if ($form->{currency} eq $form->{defaultcurrency}) {
731 @column_index = qw(datepaid source memo paid AR_paid paid_project_id);
733 @column_index = qw(datepaid source memo paid exchangerate AR_paid paid_project_id);
736 $column_data{datepaid} = "<th>" . $locale->text('Date') . "</th>";
737 $column_data{paid} = "<th>" . $locale->text('Amount') . "</th>";
738 $column_data{exchangerate} = "<th>" . $locale->text('Exch') . "</th>";
739 $column_data{AR_paid} = "<th>" . $locale->text('Account') . "</th>";
740 $column_data{source} = "<th>" . $locale->text('Source') . "</th>";
741 $column_data{memo} = "<th>" . $locale->text('Memo') . "</th>";
742 $column_data{paid_project_id} = "<th>" . $locale->text('Project Number') . "</th>";
747 map { print "$column_data{$_}\n" } @column_index;
753 $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
754 for $i (1 .. $form->{paidaccounts}) {
760 NTI($cgi->popup_menu('-name' => "AR_paid_$i",
761 '-id' => "AR_paid_$i",
762 '-values' => \@AR_paid_values,
763 '-labels' => \%AR_paid_labels,
764 '-default' => $form->{"AR_paid_$i"}));
767 if ($form->{"paid_$i"}) {
769 $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2);
771 $form->{"exchangerate_$i"} =
772 $form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
774 $exchangerate = qq| |;
775 if ($form->{currency} ne $form->{defaultcurrency}) {
776 if ($form->{"forex_$i"}) {
778 qq|<input type=hidden name="exchangerate_$i" value=$form->{"exchangerate_$i"}>$form->{"exchangerate_$i"}|;
781 qq|<input name="exchangerate_$i" size=10 value=$form->{"exchangerate_$i"}>|;
786 <input type=hidden name="forex_$i" value=$form->{"forex_$i"}>
790 qq|<td align=center><input name="paid_$i" size=11 value=$form->{"paid_$i"}></td>|;
791 $column_data{AR_paid} =
792 qq|<td align=center>${selectAR_paid}</td>|;
793 $column_data{exchangerate} = qq|<td align=center>$exchangerate</td>|;
794 $column_data{datepaid} =
795 qq|<td align=center><input name="datepaid_$i" id="datepaid_$i" size=11 value=$form->{"datepaid_$i"}>
796 <input type="button" name="datepaid_$i" id="trigger_datepaid_$i" value="?"></td>|;
797 $column_data{source} =
798 qq|<td align=center><input name="source_$i" size=11 value="$form->{"source_$i"}"></td>|;
800 qq|<td align=center><input name="memo_$i" size=11 value="$form->{"memo_$i"}"></td>|;
802 $column_data{paid_project_id} =
804 . NTI($cgi->popup_menu('-name' => "paid_project_id_$i",
805 '-values' => \@project_values,
806 '-labels' => \%project_labels,
807 '-default' => $form->{"paid_project_id_$i"} ))
810 map { print qq|$column_data{$_}\n| } @column_index;
815 push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i");
818 print $form->write_trigger(\%myconfig, scalar(@triggers) / 3, @triggers) .
820 <input type=hidden name=paidaccounts value=$form->{paidaccounts}>
826 <td><hr size=3 noshade></td>
831 $lxdebug->leave_sub();
835 $lxdebug->enter_sub();
839 <input name=gldate type=hidden value="| . Q($form->{gldate}) . qq|">
841 <input name=callback type=hidden value="$form->{callback}">
843 <input type=hidden name=path value=$form->{path}>
844 <input type=hidden name=login value=$form->{login}>
845 <input type=hidden name=password value=$form->{password}>
847 . $cgi->hidden('-name' => 'draft_id', '-default' => [$form->{draft_id}])
848 . $cgi->hidden('-name' => 'draft_description', '-default' => [$form->{draft_description}])
854 if (!$form->{id} && $form->{draft_id}) {
855 print(NTI($cgi->checkbox('-name' => 'remove_draft', '-id' => 'remove_draft',
856 '-value' => 1, '-checked' => $form->{remove_draft},
858 qq| <label for="remove_draft">| .
859 $locale->text("Remove draft when posting") .
863 $transdate = $form->datetonum($form->{transdate}, \%myconfig);
864 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
866 print qq|<input class="submit" type="submit" name="action" id="update_button" value="|
867 . $locale->text('Update') . qq|">
870 if ($form->{radier}) {
872 <input class=submit type=submit name=action value="|
873 . $locale->text('Post') . qq|">
874 <input class=submit type=submit name=action value="|
875 . $locale->text('Delete') . qq|">
878 if ($transdate > $closedto) {
880 <input class=submit type=submit name=action value="|
881 . $locale->text('Use As Template') . qq|">
885 <input class=submit type=submit name=action value="|
886 . $locale->text('Post Payment') . qq|">
890 if ($transdate > $closedto) {
891 print qq|<input class=submit type=submit name=action value="|
892 . $locale->text('Post') . qq|"> | .
893 NTI($cgi->submit('-name' => 'action', '-value' => $locale->text('Save draft'),
894 '-class' => 'submit'));
898 if ($form->{menubar}) {
899 require "$form->{path}/menu.pl";
902 # button for saving history
903 if($form->{id} ne "") {
905 <input type=button class=submit onclick=set_history_window(|
907 . qq|); name=history id=history value=|
908 . $locale->text('history')
911 # /button for saving history
919 $lxdebug->leave_sub();
923 $lxdebug->enter_sub();
927 $form->{invtotal} = 0;
929 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
930 qw(exchangerate creditlimit creditremaining);
932 @flds = qw(amount AR_amount projectnumber oldprojectnumber project_id);
936 for $i (1 .. $form->{rowcount}) {
937 $form->{"amount_$i"} =
938 $form->parse_amount(\%myconfig, $form->{"amount_$i"});
939 $form->{"tax_$i"} = $form->parse_amount(\%myconfig, $form->{"tax_$i"});
940 if ($form->{"amount_$i"}) {
943 if (!$form->{"korrektur_$i"}) {
944 ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
946 if ($form->{taxincluded}) {
947 $form->{"tax_$i"} = $form->{"amount_$i"} / ($rate + 1) * $rate;
949 $form->{"tax_$i"} = $form->{"amount_$i"} * $rate;
952 $form->{"tax_$i"} = 0;
955 $form->{"tax_$i"} = $form->round_amount($form->{"tax_$i"}, 2);
957 $totaltax += $form->{"tax_$i"};
958 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
963 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
964 $form->{rowcount} = $count + 1;
965 map { $form->{invtotal} += $form->{"amount_$_"} } (1 .. $form->{rowcount});
967 $form->{exchangerate} = $exchangerate
971 $form->check_exchangerate(
972 \%myconfig, $form->{currency}, $form->{transdate}, 'buy'
975 $form->{invdate} = $form->{transdate};
976 $save_AR = $form->{AR};
977 &check_name(customer);
978 $form->{AR} = $save_AR;
981 ($form->{taxincluded}) ? $form->{invtotal} : $form->{invtotal} + $totaltax;
983 for $i (1 .. $form->{paidaccounts}) {
984 if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
987 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
988 } qw(paid exchangerate);
990 $totalpaid += $form->{"paid_$i"};
992 $form->{"exchangerate_$i"} = $exchangerate
994 $form->{"forex_$i"} = (
996 $form->check_exchangerate(
997 \%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'buy'
1002 $form->{creditremaining} -=
1003 ($form->{invtotal} - $totalpaid + $form->{oldtotalpaid} -
1004 $form->{oldinvtotal});
1005 $form->{oldinvtotal} = $form->{invtotal};
1006 $form->{oldtotalpaid} = $totalpaid;
1010 $lxdebug->leave_sub();
1014 $lxdebug->enter_sub();
1015 for $i (1 .. $form->{paidaccounts}) {
1016 if ($form->{"paid_$i"}) {
1017 $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
1019 $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
1021 $form->error($locale->text('Cannot post payment for a closed period!'))
1022 if ($datepaid <= $closedto);
1024 if ($form->{currency} ne $form->{defaultcurrency}) {
1025 $form->{"exchangerate_$i"} = $form->{exchangerate}
1026 if ($invdate == $datepaid);
1027 $form->isblank("exchangerate_$i",
1028 $locale->text('Exchangerate for payment missing!'));
1033 ($form->{AR}) = split /--/, $form->{AR};
1034 ($form->{AR_paid}) = split /--/, $form->{AR_paid};
1035 $form->redirect($locale->text(' Payment posted!'))
1036 if (AR->post_payment(\%myconfig, \%$form));
1037 $form->error($locale->text('Cannot post payment!'));
1040 $lxdebug->leave_sub();
1044 $lxdebug->enter_sub();
1046 # check if there is an invoice number, invoice and due date
1047 $form->isblank("transdate", $locale->text('Invoice Date missing!'));
1048 $form->isblank("duedate", $locale->text('Due Date missing!'));
1049 $form->isblank("customer", $locale->text('Customer missing!'));
1051 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
1052 $transdate = $form->datetonum($form->{transdate}, \%myconfig);
1054 $form->error($locale->text('Cannot post transaction for a closed period!'))
1055 if ($transdate <= $closedto);
1057 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
1058 if ($form->{currency} ne $form->{defaultcurrency});
1060 delete($form->{AR});
1062 for $i (1 .. $form->{paidaccounts}) {
1063 if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
1064 $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
1066 $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
1068 $form->error($locale->text('Cannot post payment for a closed period!'))
1069 if ($datepaid <= $closedto);
1071 if ($form->{currency} ne $form->{defaultcurrency}) {
1072 $form->{"exchangerate_$i"} = $form->{exchangerate}
1073 if ($transdate == $datepaid);
1074 $form->isblank("exchangerate_$i",
1075 $locale->text('Exchangerate for payment missing!'));
1080 # if oldcustomer ne customer redo form
1081 ($customer) = split /--/, $form->{customer};
1082 if ($form->{oldcustomer} ne "$customer--$form->{customer_id}") {
1087 $form->{AR}{receivables} = $form->{ARselected};
1089 $form->{id} = 0 if $form->{postasnew};
1090 if (AR->post_transaction(\%myconfig, \%$form)) {
1091 # saving the history
1092 if(!exists $form->{addition} && $form->{id} ne "") {
1093 $form->{addition} = "POSTED";
1094 $form->save_history($form->dbconnect(\%myconfig));
1096 # /saving the history
1097 remove_draft() if $form->{remove_draft};
1098 $form->redirect($locale->text('Transaction posted!'));
1100 $form->error($locale->text('Cannot post transaction!'));
1102 $lxdebug->leave_sub();
1106 $lxdebug->enter_sub();
1108 $form->{postasnew} = 1;
1109 # saving the history
1110 if(!exists $form->{addition} && $form->{id} ne "") {
1111 $form->{addition} = "POSTED AS NEW";
1112 $form->save_history($form->dbconnect(\%myconfig));
1114 # /saving the history
1117 $lxdebug->leave_sub();
1120 sub use_as_template {
1121 $lxdebug->enter_sub();
1123 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);
1124 $form->{paidaccounts} = 1;
1125 $form->{rowcount}--;
1126 $form->{invdate} = $form->current_date(\%myconfig);
1129 $lxdebug->leave_sub();
1133 $lxdebug->enter_sub();
1135 $form->{title} = $locale->text('Confirm!');
1139 delete $form->{header};
1144 <form method=post action=$form->{script}>
1147 foreach $key (keys %$form) {
1148 $form->{$key} =~ s/\"/"/g;
1149 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
1153 <h2 class=confirm>$form->{title}</h2>
1156 . $locale->text('Are you sure you want to delete Transaction')
1157 . qq| $form->{invnumber}</h4>
1159 <input name=action class=submit type=submit value="|
1160 . $locale->text('Yes') . qq|">
1167 $lxdebug->leave_sub();
1171 $lxdebug->enter_sub();
1172 if (AR->delete_transaction(\%myconfig, \%$form, $spool)) {
1173 # saving the history
1174 if(!exists $form->{addition}) {
1175 $form->{addition} = "DELETED";
1176 $form->save_history($form->dbconnect(\%myconfig));
1178 # /saving the history
1179 $form->redirect($locale->text('Transaction deleted!'));
1181 $form->error($locale->text('Cannot delete transaction!'));
1183 $lxdebug->leave_sub();
1187 $lxdebug->enter_sub();
1189 # setup customer selection
1190 $form->all_vc(\%myconfig, "customer", "AR");
1192 if (@{ $form->{all_customer} }) {
1193 map { $customer .= "<option>$_->{name}--$_->{id}\n" }
1194 @{ $form->{all_customer} };
1195 $customer = qq|<select name=customer><option>\n$customer</select>|;
1197 $customer = qq|<input name=customer size=35>|;
1201 if (@{ $form->{all_departments} }) {
1202 $form->{selectdepartment} = "<option>\n";
1205 $form->{selectdepartment} .=
1206 "<option>$_->{description}--$_->{id}\n"
1207 } (@{ $form->{all_departments} });
1212 <th align=right nowrap>| . $locale->text('Department') . qq|</th>
1213 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
1215 | if $form->{selectdepartment};
1217 $form->{title} = $locale->text('AR Transactions');
1219 # use JavaScript Calendar or not
1220 $form->{jsscript} = $jscalendar;
1222 if ($form->{jsscript}) {
1224 # with JavaScript Calendar
1226 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}">
1227 <input type=button name=transdatefrom id="trigger1" value=|
1228 . $locale->text('button') . qq|></td>
1231 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}">
1232 <input type=button name=transdateto name=transdateto id="trigger2" value=|
1233 . $locale->text('button') . qq|></td>
1238 Form->write_trigger(\%myconfig, "2", "transdatefrom", "BR", "trigger1",
1239 "transdateto", "BL", "trigger2");
1242 # without JavaScript Calendar
1244 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>|;
1246 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}"></td>|;
1249 $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
1254 foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
1255 push(@values, $item->{"id"});
1256 $labels{$item->{"id"}} = $item->{"projectnumber"};
1259 NTI($cgi->popup_menu('-name' => 'project_id', '-values' => \@values,
1260 '-labels' => \%labels));
1262 $form->{fokus} = "search.customer";
1266 <body onLoad="fokus()">
1268 <form method=post name="search" action=$form->{script}>
1271 <tr><th class=listtop>$form->{title}</th></tr>
1272 <tr height="5"></tr>
1277 <th align=right>| . $locale->text('Customer') . qq|</th>
1278 <td colspan=3>$customer</td>
1282 <th align=right nowrap>| . $locale->text('Invoice Number') . qq|</th>
1283 <td colspan=3><input name=invnumber size=20></td>
1286 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
1287 <td colspan=3><input name=ordnumber size=20></td>
1290 <th align=right nowrap>| . $locale->text('Notes') . qq|</th>
1291 <td colspan=3><input name=notes size=40></td>
1294 <th align="right">| . $locale->text("Project Number") . qq|</th>
1295 <td colspan="3">$projectnumber</td>
1298 <th align=right nowrap>| . $locale->text('From') . qq|</th>
1300 <th align=right>| . $locale->text('Bis') . qq|</th>
1303 <input type=hidden name=sort value=transdate>
1311 <th align=right nowrap>| . $locale->text('Include in Report') . qq|</th>
1315 <td align=right><input name=open class=checkbox type=checkbox value=Y checked></td>
1316 <td nowrap>| . $locale->text('Open') . qq|</td>
1317 <td align=right><input name=closed class=checkbox type=checkbox value=Y></td>
1318 <td nowrap>| . $locale->text('Closed') . qq|</td>
1321 <td align=right><input name="l_id" class=checkbox type=checkbox value=Y></td>
1322 <td nowrap>| . $locale->text('ID') . qq|</td>
1323 <td align=right><input name="l_invnumber" class=checkbox type=checkbox value=Y checked></td>
1324 <td nowrap>| . $locale->text('Invoice Number') . qq|</td>
1325 <td align=right><input name="l_ordnumber" class=checkbox type=checkbox value=Y></td>
1326 <td nowrap>| . $locale->text('Order Number') . qq|</td>
1327 <td align=right><input name="l_transdate" class=checkbox type=checkbox value=Y checked></td>
1328 <td nowrap>| . $locale->text('Invoice Date') . qq|</td>
1331 <td align=right><input name="l_name" class=checkbox type=checkbox value=Y checked></td>
1332 <td nowrap>| . $locale->text('Customer') . qq|</td>
1333 <td align=right><input name="l_netamount" class=checkbox type=checkbox value=Y></td>
1334 <td nowrap>| . $locale->text('Amount') . qq|</td>
1335 <td align=right><input name="l_tax" class=checkbox type=checkbox value=Y></td>
1336 <td nowrap>| . $locale->text('Tax') . qq|</td>
1337 <td align=right><input name="l_amount" class=checkbox type=checkbox value=Y checked></td>
1338 <td nowrap>| . $locale->text('Total') . qq|</td>
1341 <td align=right><input name="l_datepaid" class=checkbox type=checkbox value=Y></td>
1342 <td nowrap>| . $locale->text('Date Paid') . qq|</td>
1343 <td align=right><input name="l_paid" class=checkbox type=checkbox value=Y checked></td>
1344 <td nowrap>| . $locale->text('Paid') . qq|</td>
1345 <td align=right><input name="l_duedate" class=checkbox type=checkbox value=Y></td>
1346 <td nowrap>| . $locale->text('Due Date') . qq|</td>
1347 <td align=right><input name="l_due" class=checkbox type=checkbox value=Y></td>
1348 <td nowrap>| . $locale->text('Amount Due') . qq|</td>
1351 <td align=right><input name="l_notes" class=checkbox type=checkbox value=Y></td>
1352 <td nowrap>| . $locale->text('Notes') . qq|</td>
1353 <td align=right><input name="l_employee" class=checkbox type=checkbox value=Y></td>
1354 <td nowrap>| . $locale->text('Salesperson') . qq|</td>
1355 <td align=right><input name="l_shippingpoint" class=checkbox type=checkbox value=Y></td>
1356 <td nowrap>| . $locale->text('Shipping Point') . qq|</td>
1357 <td align=right><input name="l_shipvia" class=checkbox type=checkbox value=Y></td>
1358 <td nowrap>| . $locale->text('Ship via') . qq|</td>
1361 <td align=right><input name="l_subtotal" class=checkbox type=checkbox value=Y></td>
1362 <td nowrap>| . $locale->text('Subtotal') . qq|</td>
1363 <td align=right><input name="l_globalprojectnumber" class=checkbox type=checkbox value=Y></td>
1364 <td nowrap>| . $locale->text('Project Number') . qq|</td>
1373 <td><hr size=3 noshade></td>
1377 <input type=hidden name=nextsub value=$form->{nextsub}>
1379 <input type=hidden name=path value=$form->{path}>
1380 <input type=hidden name=login value=$form->{login}>
1381 <input type=hidden name=password value=$form->{password}>
1384 <input class=submit type=submit name=action value="|
1385 . $locale->text('Continue') . qq|">
1396 $lxdebug->leave_sub();
1399 sub ar_transactions {
1400 $lxdebug->enter_sub();
1402 $form->{customer} = $form->unescape($form->{customer});
1403 ($form->{customer}, $form->{customer_id}) = split(/--/, $form->{customer});
1405 AR->ar_transactions(\%myconfig, \%$form);
1408 "$form->{script}?action=ar_transactions&path=$form->{path}&login=$form->{login}&password=$form->{password}";
1411 if ($form->{customer}) {
1412 $callback .= "&customer=" . $form->escape($form->{customer}, 1);
1413 $href .= "&customer=" . $form->escape($form->{customer});
1414 $option = $locale->text('Customer') . " : $form->{customer}";
1416 if ($form->{department}) {
1417 $callback .= "&department=" . $form->escape($form->{department}, 1);
1418 $href .= "&department=" . $form->escape($form->{department});
1419 ($department) = split /--/, $form->{department};
1420 $option .= "\n<br>" if ($option);
1421 $option .= $locale->text('Department') . " : $department";
1423 if ($form->{invnumber}) {
1424 $callback .= "&invnumber=" . $form->escape($form->{invnumber}, 1);
1425 $href .= "&invnumber=" . $form->escape($form->{invnumber});
1426 $option .= "\n<br>" if ($option);
1427 $option .= $locale->text('Invoice Number') . " : $form->{invnumber}";
1429 if ($form->{ordnumber}) {
1430 $callback .= "&ordnumber=" . $form->escape($form->{ordnumber}, 1);
1431 $href .= "&ordnumber=" . $form->escape($form->{ordnumber});
1432 $option .= "\n<br>" if ($option);
1433 $option .= $locale->text('Order Number') . " : $form->{ordnumber}";
1435 if ($form->{notes}) {
1436 $callback .= "¬es=" . $form->escape($form->{notes}, 1);
1437 $href .= "¬es=" . $form->escape($form->{notes});
1438 $option .= "\n<br>" if $option;
1439 $option .= $locale->text('Notes') . " : $form->{notes}";
1442 if ($form->{transdatefrom}) {
1443 $callback .= "&transdatefrom=$form->{transdatefrom}";
1444 $href .= "&transdatefrom=$form->{transdatefrom}";
1445 $option .= "\n<br>" if ($option);
1447 $locale->text('From') . " "
1448 . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
1450 if ($form->{transdateto}) {
1451 $callback .= "&transdateto=$form->{transdateto}";
1452 $href .= "&transdateto=$form->{transdateto}";
1453 $option .= "\n<br>" if ($option);
1455 $locale->text('Bis') . " "
1456 . $locale->date(\%myconfig, $form->{transdateto}, 1);
1458 if ($form->{open}) {
1459 $callback .= "&open=$form->{open}";
1460 $href .= "&open=$form->{open}";
1461 $option .= "\n<br>" if ($option);
1462 $option .= $locale->text('Open');
1464 if ($form->{closed}) {
1465 $callback .= "&closed=$form->{closed}";
1466 $href .= "&closed=$form->{closed}";
1467 $option .= "\n<br>" if ($option);
1468 $option .= $locale->text('Closed');
1470 if ($form->{globalproject_id}) {
1471 $callback .= "&globalproject_id=" . E($form->{globalproject_id});
1472 $href .= "&globalproject_id=" . E($form->{globalproject_id});
1476 qw(transdate id type invnumber ordnumber name netamount tax amount paid
1477 datepaid due duedate notes employee shippingpoint shipvia
1478 globalprojectnumber);
1480 $form->{"l_type"} = "Y";
1482 foreach $item (@columns) {
1483 if ($form->{"l_$item"} eq "Y") {
1484 push @column_index, $item;
1486 # add column to href and callback
1487 $callback .= "&l_$item=Y";
1488 $href .= "&l_$item=Y";
1492 if ($form->{l_subtotal} eq 'Y') {
1493 $callback .= "&l_subtotal=Y";
1494 $href .= "&l_subtotal=Y";
1497 $column_header{id} =
1498 "<th><a class=listheading href=$href&sort=id>"
1499 . $locale->text('ID')
1501 $column_header{transdate} =
1502 "<th><a class=listheading href=$href&sort=transdate>"
1503 . $locale->text('Date')
1505 $column_header{duedate} =
1506 "<th><a class=listheading href=$href&sort=duedate>"
1507 . $locale->text('Due Date')
1509 $column_header{type} =
1510 "<th class=\"listheading\">" . $locale->text('Type') . "</th>";
1511 $column_header{invnumber} =
1512 "<th><a class=listheading href=$href&sort=invnumber>"
1513 . $locale->text('Invoice')
1515 $column_header{ordnumber} =
1516 "<th><a class=listheading href=$href&sort=ordnumber>"
1517 . $locale->text('Order')
1519 $column_header{name} =
1520 "<th><a class=listheading href=$href&sort=name>"
1521 . $locale->text('Customer')
1523 $column_header{netamount} =
1524 "<th class=listheading>" . $locale->text('Amount') . "</th>";
1525 $column_header{tax} =
1526 "<th class=listheading>" . $locale->text('Tax') . "</th>";
1527 $column_header{amount} =
1528 "<th class=listheading>" . $locale->text('Total') . "</th>";
1529 $column_header{paid} =
1530 "<th class=listheading>" . $locale->text('Paid') . "</th>";
1531 $column_header{datepaid} =
1532 "<th><a class=listheading href=$href&sort=datepaid>"
1533 . $locale->text('Date Paid')
1535 $column_header{due} =
1536 "<th class=listheading>" . $locale->text('Amount Due') . "</th>";
1537 $column_header{notes} =
1538 "<th class=listheading>" . $locale->text('Notes') . "</th>";
1539 $column_header{employee} =
1540 "<th><a class=listheading href=$href&sort=employee>"
1541 . $locale->text('Salesperson') . "</th>";
1543 $column_header{shippingpoint} =
1544 "<th><a class=listheading href=$href&sort=shippingpoint>"
1545 . $locale->text('Shipping Point')
1547 $column_header{shipvia} =
1548 "<th><a class=listheading href=$href&sort=shipvia>"
1549 . $locale->text('Ship via')
1551 $column_header{globalprojectnumber} =
1552 qq|<th class="listheading">| . $locale->text('Project Number') . qq|</th>|;
1554 $form->{title} = $locale->text('AR Transactions');
1563 <th class=listtop>$form->{title}</th>
1565 <tr height="5"></tr>
1572 <tr class=listheading>
1575 map { print "\n$column_header{$_}" } @column_index;
1581 # add sort and escape callback, this one we use for the add sub
1582 $form->{callback} = $callback .= "&sort=$form->{sort}";
1584 # escape callback for href
1585 $callback = $form->escape($callback);
1587 if (@{ $form->{AR} }) {
1588 $sameitem = $form->{AR}->[0]->{ $form->{sort} };
1591 # sums and tax on reports by Antonio Gallardo
1593 foreach $ar (@{ $form->{AR} }) {
1595 if ($form->{l_subtotal} eq 'Y') {
1596 if ($sameitem ne $ar->{ $form->{sort} }) {
1601 $column_data{netamount} =
1603 . $form->format_amount(\%myconfig, $ar->{netamount}, 2, " ")
1605 $column_data{tax} = "<td align=right>"
1606 . $form->format_amount(\%myconfig, $ar->{amount} - $ar->{netamount},
1609 $column_data{amount} =
1611 . $form->format_amount(\%myconfig, $ar->{amount}, 2, " ") . "</td>";
1612 $column_data{paid} =
1614 . $form->format_amount(\%myconfig, $ar->{paid}, 2, " ") . "</td>";
1615 $column_data{due} = "<td align=right>"
1616 . $form->format_amount(\%myconfig, $ar->{amount} - $ar->{paid},
1620 $subtotalnetamount += $ar->{netamount};
1621 $subtotalamount += $ar->{amount};
1622 $subtotalpaid += $ar->{paid};
1623 $subtotaldue += $ar->{amount} - $ar->{paid};
1625 $totalnetamount += $ar->{netamount};
1626 $totalamount += $ar->{amount};
1627 $totalpaid += $ar->{paid};
1628 $totaldue += ($ar->{amount} - $ar->{paid});
1630 $column_data{transdate} = "<td>$ar->{transdate} </td>";
1631 $column_data{id} = "<td>$ar->{id}</td>";
1632 $column_data{datepaid} = "<td>$ar->{datepaid} </td>";
1633 $column_data{duedate} = "<td>$ar->{duedate} </td>";
1635 $module = ($ar->{invoice}) ? "is.pl" : $form->{script};
1637 $column_data{invnumber} =
1638 "<td><a href=$module?action=edit&id=$ar->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ar->{invnumber}</a></td>";
1639 $column_data{type} = "<td>" .
1640 ($ar->{storno} ? $locale->text("Storno (one letter abbreviation)") :
1642 $locale->text("Credit note (one letter abbreviation)") :
1643 $locale->text("Invoice (one letter abbreviation)")) . "</td>";
1644 $column_data{ordnumber} = "<td>$ar->{ordnumber} </td>";
1645 $column_data{name} = "<td>$ar->{name}</td>";
1646 $ar->{notes} =~ s/\r\n/<br>/g;
1647 $column_data{notes} = "<td>$ar->{notes} </td>";
1648 $column_data{shippingpoint} = "<td>$ar->{shippingpoint} </td>";
1649 $column_data{shipvia} = "<td>$ar->{shipvia} </td>";
1650 $column_data{employee} = "<td>$ar->{employee} </td>";
1651 $column_data{globalprojectnumber} =
1652 "<td>" . H($ar->{globalprojectnumber}) . "</td>";
1657 <tr class=listrow$i>
1660 map { print "\n$column_data{$_}" } @column_index;
1668 if ($form->{l_subtotal} eq 'Y') {
1674 <tr class=listtotal>
1677 map { $column_data{$_} = "<td> </td>" } @column_index;
1679 $column_data{netamount} =
1680 "<th class=listtotal align=right>"
1681 . $form->format_amount(\%myconfig, $totalnetamount, 2, " ") . "</th>";
1682 $column_data{tax} = "<th class=listtotal align=right>"
1683 . $form->format_amount(\%myconfig, $totalamount - $totalnetamount,
1686 $column_data{amount} =
1687 "<th class=listtotal align=right>"
1688 . $form->format_amount(\%myconfig, $totalamount, 2, " ") . "</th>";
1689 $column_data{paid} =
1690 "<th class=listtotal align=right>"
1691 . $form->format_amount(\%myconfig, $totalpaid, 2, " ") . "</th>";
1693 "<th class=listtotal align=right>"
1694 . $form->format_amount(\%myconfig, $totaldue, 2, " ") . "</th>";
1696 map { print "\n$column_data{$_}" } @column_index;
1704 <td><hr size=3 noshade></td>
1709 <form method=post action=$form->{script}>
1711 <input name=callback type=hidden value="$form->{callback}">
1713 <input type=hidden name=path value=$form->{path}>
1714 <input type=hidden name=login value=$form->{login}>
1715 <input type=hidden name=password value=$form->{password}>
1717 <input class=submit type=submit name=action value="|
1718 . $locale->text('AR Transaction') . qq|">
1719 <input class=submit type=submit name=action value="|
1720 . $locale->text('Sales Invoice') . qq|">
1728 $lxdebug->leave_sub();
1732 $lxdebug->enter_sub();
1734 map { $column_data{$_} = "<td> </td>" } @column_index;
1736 $column_data{tax} = "<th class=listsubtotal align=right>"
1737 . $form->format_amount(\%myconfig, $subtotalamount - $subtotalnetamount,
1740 $column_data{amount} =
1741 "<th class=listsubtotal align=right>"
1742 . $form->format_amount(\%myconfig, $subtotalamount, 2, " ") . "</th>";
1743 $column_data{paid} =
1744 "<th class=listsubtotal align=right>"
1745 . $form->format_amount(\%myconfig, $subtotalpaid, 2, " ") . "</th>";
1747 "<th class=listsubtotal align=right>"
1748 . $form->format_amount(\%myconfig, $subtotaldue, 2, " ") . "</th>";
1750 $subtotalnetamount = 0;
1751 $subtotalamount = 0;
1755 $sameitem = $ar->{ $form->{sort} };
1757 print "<tr class=listsubtotal>";
1759 map { print "\n$column_data{$_}" } @column_index;
1765 $lxdebug->leave_sub();