1 #=====================================================================
4 # Based on SQL-Ledger Version 2.1.9
5 # Web http://www.lx-office.org
7 #=====================================================================
8 # SQL-Ledger Accounting
11 # Author: Dieter Simader
12 # Email: dsimader@sql-ledger.org
13 # Web: http://www.sql-ledger.org
16 # This program is free software; you can redistribute it and/or modify
17 # it under the terms of the GNU General Public License as published by
18 # the Free Software Foundation; either version 2 of the License, or
19 # (at your option) any later version.
21 # This program is distributed in the hope that it will be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 # GNU General Public License for more details.
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write to the Free Software
27 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #======================================================================
30 # Accounts Receivables
32 #======================================================================
39 require "$form->{path}/arap.pl";
40 require "bin/mozilla/common.pl";
41 require "bin/mozilla/drafts.pl";
47 # this is for our long dates
48 # $locale->text('January')
49 # $locale->text('February')
50 # $locale->text('March')
51 # $locale->text('April')
52 # $locale->text('May ')
53 # $locale->text('June')
54 # $locale->text('July')
55 # $locale->text('August')
56 # $locale->text('September')
57 # $locale->text('October')
58 # $locale->text('November')
59 # $locale->text('December')
61 # this is for our short month
62 # $locale->text('Jan')
63 # $locale->text('Feb')
64 # $locale->text('Mar')
65 # $locale->text('Apr')
66 # $locale->text('May')
67 # $locale->text('Jun')
68 # $locale->text('Jul')
69 # $locale->text('Aug')
70 # $locale->text('Sep')
71 # $locale->text('Oct')
72 # $locale->text('Nov')
73 # $locale->text('Dec')
76 $lxdebug->enter_sub();
78 return $lxdebug->leave_sub() if (load_draft_maybe());
81 if(!exists $form->{addition} && ($form->{id} ne "")) {
82 $form->{addition} = "ADDED";
83 $form->save_history($form->dbconnect(\%myconfig));
87 $form->{title} = "Add";
89 "$form->{script}?action=add&path=$form->{path}&login=$form->{login}&password=$form->{password}"
90 unless $form->{callback};
93 AR->get_transdate(\%myconfig, $form);
95 $lxdebug->leave_sub();
99 $lxdebug->enter_sub();
100 # show history button
101 $form->{javascript} = qq|<script type="text/javascript" src="js/show_history.js"></script>|;
102 #/show hhistory button
104 $form->{title} = "Edit";
109 $lxdebug->leave_sub();
113 $lxdebug->enter_sub();
118 $lxdebug->leave_sub();
122 $lxdebug->enter_sub();
124 $form->create_links("AR", \%myconfig, "customer");
125 $duedate = $form->{duedate};
127 $taxincluded = $form->{taxincluded};
128 my $id = $form->{id};
129 IS->get_customer(\%myconfig, \%$form);
130 $form->{taxincluded} = $taxincluded;
133 $form->{duedate} = $duedate if $duedate;
134 $form->{oldcustomer} = "$form->{customer}--$form->{customer_id}";
135 $form->{rowcount} = 1;
138 @curr = split(/:/, $form->{currencies});
140 $form->{defaultcurrency} = $curr[0];
142 map { $form->{selectcurrency} .= "<option>$_\n" } @curr;
145 if (@{ $form->{all_customer} }) {
146 $form->{customer} = "$form->{customer}--$form->{customer_id}";
147 map { $form->{selectcustomer} .= "<option>$_->{name}--$_->{id}\n" }
148 (@{ $form->{all_customer} });
152 if (@{ $form->{all_departments} }) {
153 $form->{selectdepartment} = "<option>\n";
154 $form->{department} = "$form->{department}--$form->{department_id}";
157 $form->{selectdepartment} .=
158 "<option>$_->{description}--$_->{id}\n"
159 } (@{ $form->{all_departments} });
162 $form->{employee} = "$form->{employee}--$form->{employee_id}";
165 if (@{ $form->{all_employees} }) {
166 $form->{selectemployee} = "";
167 map { $form->{selectemployee} .= "<option>$_->{name}--$_->{id}\n" }
168 (@{ $form->{all_employees} });
171 # build the popup menus
172 $form->{taxincluded} = ($form->{id}) ? $form->{taxincluded} : "checked";
175 $form->{forex} = $form->{exchangerate};
176 $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
177 foreach $key (keys %{ $form->{AR_links} }) {
178 # if there is a value we have an old entry
182 for $i (1 .. scalar @{ $form->{acc_trans}{$key} }) {
183 if ($key eq "AR_paid") {
185 $form->{"AR_paid_$j"} = $form->{acc_trans}{$key}->[$i-1]->{accno};
188 $form->{"paid_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{amount} * -1;
189 $form->{"datepaid_$j"} =
190 $form->{acc_trans}{$key}->[$i - 1]->{transdate};
191 $form->{"source_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{source};
192 $form->{"memo_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{memo};
194 $form->{"forex_$j"} = $form->{"exchangerate_$i"} =
195 $form->{acc_trans}{$key}->[$i - 1]->{exchangerate};
196 $form->{"paid_project_id_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{project_id};
197 $form->{paidaccounts}++;
204 if ($key eq "AR_tax" || $key eq "AP_tax") {
205 $form->{"${key}_$form->{acc_trans}{$key}->[$i-1]->{accno}"} =
206 "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
207 $form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"} =
209 $form->{acc_trans}{$key}->[$i - 1]->{amount} / $exchangerate,
212 if ($form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"} > 0) {
214 $form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"};
216 $form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"};
219 $form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"};
221 $form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"};
223 $index = $form->{acc_trans}{$key}->[$i - 1]->{index};
224 $form->{"tax_$index"} = $form->{acc_trans}{$key}->[$i - 1]->{amount};
225 $totaltax += $form->{"tax_$index"};
229 $form->{"${akey}_$k"} =
231 $form->{acc_trans}{$key}->[$i - 1]->{amount} / $exchangerate,
233 if ($akey eq 'amount') {
235 $totalamount += $form->{"${akey}_$i"};
237 $form->{"oldprojectnumber_$k"} = $form->{"projectnumber_$k"} =
238 "$form->{acc_trans}{$key}->[$i-1]->{projectnumber}";
239 $form->{taxrate} = $form->{acc_trans}{$key}->[$i - 1]->{rate};
240 $form->{"project_id_$k"} =
241 "$form->{acc_trans}{$key}->[$i-1]->{project_id}";
243 $form->{"${key}_$i"} =
244 "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
247 $form->{ARselected} = $form->{acc_trans}{$key}->[$i-1]->{accno};
249 } elsif ($akey eq "amount") {
250 $form->{"${key}_$k"} = $form->{acc_trans}{$key}->[$i-1]->{accno} .
251 "--" . $form->{acc_trans}{$key}->[$i-1]->{id};
252 $form->{"taxchart_$k"} = $form->{acc_trans}{$key}->[$i-1]->{id} .
253 "--" . $form->{acc_trans}{$key}->[$i-1]->{rate};
260 $lxdebug->message(0, "1 ARselected $form->{ARselected}");
262 $form->{taxincluded} = $taxincluded if ($form->{id});
263 $form->{paidaccounts} = 1 if not defined $form->{paidaccounts};
265 if ($form->{taxincluded} && $form->{taxrate} && $totalamount) {
267 # add tax to amounts and invtotal
268 for $i (1 .. $form->{rowcount}) {
270 ($totaltax + $totalwithholding) * $form->{"amount_$i"} / $totalamount;
271 $tax = $form->round_amount($taxamount, 2);
272 $diff += ($taxamount - $tax);
273 $form->{"amount_$i"} += $form->{"tax_$i"};
275 $form->{amount_1} += $form->round_amount($diff, 2);
278 $taxamount = $form->round_amount($taxamount, 2);
279 $form->{tax} = $taxamount;
281 $form->{invtotal} = $totalamount + $totaltax;
284 ($form->datetonum($form->{transdate}, \%myconfig) <=
285 $form->datetonum($form->{closedto}, \%myconfig));
287 $lxdebug->leave_sub();
291 $lxdebug->enter_sub();
293 $title = $form->{title};
294 $form->{title} = $locale->text("$title Accounts Receivables Transaction");
296 $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
298 # $locale->text('Add Accounts Receivables Transaction')
299 # $locale->text('Edit Accounts Receivables Transaction')
300 $form->{javascript} = qq|<script type="text/javascript">
302 function setTaxkey(accno, row) {
303 var taxkey = accno.options[accno.selectedIndex].value;
304 var reg = /--([0-9]*)/;
305 var found = reg.exec(taxkey);
306 var index = found[1];
307 index = parseInt(index);
308 var tax = 'taxchart_' + row;
309 for (var i = 0; i < document.getElementById(tax).options.length; ++i) {
310 var reg2 = new RegExp("^"+ index, "");
311 if (reg2.exec(document.getElementById(tax).options[i].value)) {
312 document.getElementById(tax).options[i].selected = true;
319 # show history button js
320 $form->{javascript} .= qq|<script type="text/javascript" src="js/show_history.js"></script>|;
321 #/show history button js
323 $readonly = ($form->{id}) ? "readonly" : "";
326 ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0;
327 $readonly = ($form->{radier}) ? "" : $readonly;
329 # set option selected
330 foreach $item (qw(customer currency department employee)) {
331 $form->{"select$item"} =~ s/ selected//;
332 $form->{"select$item"} =~
333 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
337 $form->{exchangerate} =
338 $form->format_amount(\%myconfig, $form->{exchangerate});
340 $form->{creditlimit} =
341 $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
342 $form->{creditremaining} =
343 $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
346 <input type=hidden name=forex value=$form->{forex}>
348 if ($form->{currency} ne $form->{defaultcurrency}) {
349 if ($form->{forex}) {
351 <th align=right>| . $locale->text('Exchangerate') . qq|</th>
352 <td><input type=hidden name=exchangerate value=$form->{exchangerate}>$form->{exchangerate}</td>
356 <th align=right>| . $locale->text('Exchangerate') . qq|</th>
357 <td><input name=exchangerate size=10 value=$form->{exchangerate}></td>
366 <td align=right><input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}></td>
367 <th align=left nowrap>| . $locale->text('Tax Included') . qq|</th>
371 if (($rows = $form->numtextrows($form->{notes}, 50)) < 2) {
375 qq|<textarea name=notes rows=$rows cols=50 wrap=soft>$form->{notes}</textarea>|;
379 <th align="right" nowrap>| . $locale->text('Department') . qq|</th>
380 <td colspan=3><select name=department>$form->{selectdepartment}</select>
381 <input type=hidden name=selectdepartment value="$form->{selectdepartment}">
384 | if $form->{selectdepartment};
386 $n = ($form->{creditremaining} =~ /-/) ? "0" : "1";
389 ($form->{selectcustomer})
390 ? qq|<select name=customer>$form->{selectcustomer}</select>|
391 : qq|<input name=customer value="$form->{customer}" size=35>|;
394 <input type=hidden name=employee value="$form->{employee}">
397 if ($form->{selectemployee}) {
400 <th align=right nowrap>| . $locale->text('Salesperson') . qq|</th>
401 <td colspan=2><select name=employee>$form->{selectemployee}</select></td>
402 <input type=hidden name=selectemployee value="$form->{selectemployee}">
407 my @old_project_ids = ();
408 map({ push(@old_project_ids, $form->{"project_id_$_"})
409 if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
411 $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
413 "old_id" => \@old_project_ids },
414 "charts" => { "key" => "ALL_CHARTS",
415 "transdate" => $form->{transdate} },
416 "taxcharts" => "ALL_TAXCHARTS");
418 map({ $_->{link_split} = [ split(/:/, $_->{link}) ]; }
419 @{ $form->{ALL_CHARTS} });
421 my %project_labels = ();
422 my @project_values = ("");
423 foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
424 push(@project_values, $item->{"id"});
425 $project_labels{$item->{"id"}} = $item->{"projectnumber"};
428 my (%AR_amount_labels, @AR_amount_values);
429 my (%AR_labels, @AR_values);
430 my (%AR_paid_labels, @AR_paid_values);
433 foreach my $item (@{ $form->{ALL_CHARTS} }) {
434 if (grep({ $_ eq "AR_amount" } @{ $item->{link_split} })) {
435 $taxchart_init = $item->{tax_id} if ($taxchart_init eq "");
436 my $key = "$item->{accno}--$item->{tax_id}";
437 push(@AR_amount_values, $key);
438 $AR_amount_labels{$key} =
439 "$item->{accno}--$item->{description}";
441 } elsif (grep({ $_ eq "AR" } @{ $item->{link_split} })) {
442 push(@AR_values, $item->{accno});
443 $AR_labels{$item->{accno}} = "$item->{accno}--$item->{description}";
445 } elsif (grep({ $_ eq "AR_paid" } @{ $item->{link_split} })) {
446 push(@AR_paid_values, $item->{accno});
447 $AR_paid_labels{$item->{accno}} =
448 "$item->{accno}--$item->{description}";
452 my %taxchart_labels = ();
453 my @taxchart_values = ();
454 foreach my $item (@{ $form->{ALL_TAXCHARTS} }) {
455 my $key = "$item->{id}--$item->{rate}";
456 $taxchart_init = $key if ($taxchart_init eq $item->{id});
457 push(@taxchart_values, $key);
458 $taxchart_labels{$key} =
459 "$item->{taxdescription} " . ($item->{rate} * 100) . ' %';
462 $form->{fokus} = "arledger.customer";
464 # use JavaScript Calendar or not
465 $form->{jsscript} = $jscalendar;
467 if ($form->{jsscript}) {
469 # with JavaScript Calendar
471 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>
472 <td><input type=button name=transdate id="trigger1" value=|
473 . $locale->text('button') . qq|></td>
476 <td><input name=duedate id=duedate size=11 title="$myconfig{dateformat}" value=$form->{duedate}></td>
477 <td><input type=button name=duedate id="trigger2" value=|
478 . $locale->text('button') . qq|></td></td>
483 Form->write_trigger(\%myconfig, "2", "transdate", "BL", "trigger1",
484 "duedate", "BL", "trigger2");
487 # without JavaScript Calendar
489 qq|<td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>|;
491 qq|<td><input name=duedate id=duedate size=11 title="$myconfig{dateformat}" value=$form->{duedate}></td>|;
497 <body onLoad="fokus()">
499 <form method=post name="arledger" action=$form->{script}>
501 <input type=hidden name=id value=$form->{id}>
502 <input type=hidden name=sort value=$form->{sort}>
503 <input type=hidden name=closedto value=$form->{closedto}>
504 <input type=hidden name=locked value=$form->{locked}>
505 <input type=hidden name=title value="$title">
507 | . ($form->{saved_message} ? qq|<p>$form->{saved_message}</p>| : "") . qq|
511 <th class=listtop>$form->{title}</th>
521 <th align="right" nowrap>| . $locale->text('Customer') . qq|</th>
522 <td colspan=3>$customer</td>
523 <input type=hidden name=selectcustomer value="$form->{selectcustomer}">
524 <input type=hidden name=oldcustomer value="$form->{oldcustomer}">
525 <input type=hidden name=customer_id value="$form->{customer_id}">
526 <input type=hidden name=terms value=$form->{terms}>
533 <th align=left nowrap>| . $locale->text('Credit Limit') . qq|</th>
534 <td>$form->{creditlimit}</td>
535 <th align=left nowrap>| . $locale->text('Remaining') . qq|</th>
536 <td class="plus$n">$form->{creditremaining}</td>
537 <input type=hidden name=creditlimit value=$form->{creditlimit}>
538 <input type=hidden name=creditremaining value=$form->{creditremaining}>
544 <th align=right>| . $locale->text('Currency') . qq|</th>
545 <td><select name=currency>$form->{selectcurrency}</select></td>
546 <input type=hidden name=selectcurrency value="$form->{selectcurrency}">
547 <input type=hidden name=defaultcurrency value=$form->{defaultcurrency}>
548 <input type=hidden name=fxgain_accno value=$form->{fxgain_accno}>
549 <input type=hidden name=fxloss_accno value=$form->{fxloss_accno}>
560 <th align=right nowrap>| . $locale->text('Invoice Number') . qq|</th>
561 <td><input name=invnumber size=11 value="$form->{invnumber}"></td>
564 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
565 <td><input name=ordnumber size=11 value="$form->{ordnumber}"></td>
568 <th align=right nowrap>| . $locale->text('Invoice Date') . qq|</th>
572 <th align=right nowrap>| . $locale->text('Due Date') . qq|</th>
583 <input type=hidden name=rowcount value=$form->{rowcount}>
587 <tr class=listheading>
588 <th class=listheading style="width:15%">|
589 . $locale->text('Account') . qq|</th>
590 <th class=listheading style="width:10%">|
591 . $locale->text('Amount') . qq|</th>
592 <th class=listheading style="width:10%">|
593 . $locale->text('Tax') . qq|</th>
594 <th class=listheading style="width:5%">|
595 . $locale->text('Korrektur') . qq|</th>
596 <th class=listheading style="width:10%">|
597 . $locale->text('Taxkey') . qq|</th>
598 <th class=listheading style="width:10%">|
599 . $locale->text('Project') . qq|</th>
603 $amount = $locale->text('Amount');
604 $project = $locale->text('Project');
606 for $i (1 .. $form->{rowcount}) {
609 $form->{"amount_$i"} =
610 $form->format_amount(\%myconfig, $form->{"amount_$i"}, 2);
611 $form->{"tax_$i"} = $form->format_amount(\%myconfig, $form->{"tax_$i"}, 2);
614 NTI($cgi->popup_menu('-name' => "AR_amount_$i",
615 '-id' => "AR_amount_$i",
616 '-style' => 'width:400px',
617 '-onChange' => "setTaxkey(this, $i)",
618 '-values' => \@AR_amount_values,
619 '-labels' => \%AR_amount_labels,
620 '-default' => $form->{"AR_amount_$i"}));
623 NTI($cgi->popup_menu('-name' => "taxchart_$i",
624 '-id' => "taxchart_$i",
625 '-style' => 'width:200px',
626 '-values' => \@taxchart_values,
627 '-labels' => \%taxchart_labels,
628 '-default' => $form->{"taxchart_$i"} eq "" ?
629 $taxchart_init : $form->{"taxchart_$i"}))
632 $korrektur_checked = ($form->{"korrektur_$i"} ? 'checked' : '');
635 NTI($cgi->popup_menu('-name' => "project_id_$i",
636 '-values' => \@project_values,
637 '-labels' => \%project_labels,
638 '-default' => $form->{"project_id_$i"} ));
642 <td>$selectAR_amount</td>
643 <td><input name="amount_$i" size=10 value=$form->{"amount_$i"}></td>
644 <td><input name="tax_$i" size=10 value=$form->{"tax_$i"}></td>
645 <td><input type="checkbox" name="korrektur_$i" value="1" $korrektur_checked></td>
647 <td>$projectnumber</td>
654 $form->{invtotal} = $form->format_amount(\%myconfig, $form->{invtotal}, 2);
657 NTI($cgi->popup_menu('-name' => "ARselected", '-id' => "ARselected",
658 '-style' => 'width:400px',
659 '-values' => \@AR_values, '-labels' => \%AR_labels,
660 '-default' => $form->{ARselected}));
669 <td>${ARselected}</td>
670 <th align=left>$form->{invtotal}</th>
672 <input type=hidden name=oldinvtotal value=$form->{oldinvtotal}>
673 <input type=hidden name=oldtotalpaid value=$form->{oldtotalpaid}>
675 <input type=hidden name=taxaccounts value="$form->{taxaccounts}">
688 <th align=left width=1%>| . $locale->text('Notes') . qq|</th>
689 <td align=left>$notes</td>
697 <tr class=listheading>
698 <th colspan=7 class=listheading>|
699 . $locale->text('Incoming Payments') . qq|</th>
703 if ($form->{currency} eq $form->{defaultcurrency}) {
704 @column_index = qw(datepaid source memo paid AR_paid paid_project_id);
706 @column_index = qw(datepaid source memo paid exchangerate AR_paid paid_project_id);
709 $column_data{datepaid} = "<th>" . $locale->text('Date') . "</th>";
710 $column_data{paid} = "<th>" . $locale->text('Amount') . "</th>";
711 $column_data{exchangerate} = "<th>" . $locale->text('Exch') . "</th>";
712 $column_data{AR_paid} = "<th>" . $locale->text('Account') . "</th>";
713 $column_data{source} = "<th>" . $locale->text('Source') . "</th>";
714 $column_data{memo} = "<th>" . $locale->text('Memo') . "</th>";
715 $column_data{paid_project_id} = "<th>" . $locale->text('Project Number') . "</th>";
720 map { print "$column_data{$_}\n" } @column_index;
726 $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
727 for $i (1 .. $form->{paidaccounts}) {
733 NTI($cgi->popup_menu('-name' => "AR_paid_$i",
734 '-id' => "AR_paid_$i",
735 '-values' => \@AR_paid_values,
736 '-labels' => \%AR_paid_labels,
737 '-default' => $form->{"AR_paid_$i"}));
740 if ($form->{"paid_$i"}) {
742 $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2);
744 $form->{"exchangerate_$i"} =
745 $form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
747 $exchangerate = qq| |;
748 if ($form->{currency} ne $form->{defaultcurrency}) {
749 if ($form->{"forex_$i"}) {
751 qq|<input type=hidden name="exchangerate_$i" value=$form->{"exchangerate_$i"}>$form->{"exchangerate_$i"}|;
754 qq|<input name="exchangerate_$i" size=10 value=$form->{"exchangerate_$i"}>|;
759 <input type=hidden name="forex_$i" value=$form->{"forex_$i"}>
763 qq|<td align=center><input name="paid_$i" size=11 value=$form->{"paid_$i"}></td>|;
764 $column_data{AR_paid} =
765 qq|<td align=center>${selectAR_paid}</td>|;
766 $column_data{exchangerate} = qq|<td align=center>$exchangerate</td>|;
767 $column_data{datepaid} =
768 qq|<td align=center><input name="datepaid_$i" id="datepaid_$i" size=11 value=$form->{"datepaid_$i"}>
769 <input type="button" name="datepaid_$i" id="trigger_datepaid_$i" value="?"></td>|;
770 $column_data{source} =
771 qq|<td align=center><input name="source_$i" size=11 value="$form->{"source_$i"}"></td>|;
773 qq|<td align=center><input name="memo_$i" size=11 value="$form->{"memo_$i"}"></td>|;
775 $column_data{paid_project_id} =
777 . NTI($cgi->popup_menu('-name' => "paid_project_id_$i",
778 '-values' => \@project_values,
779 '-labels' => \%project_labels,
780 '-default' => $form->{"paid_project_id_$i"} ))
783 map { print qq|$column_data{$_}\n| } @column_index;
788 push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i");
791 print $form->write_trigger(\%myconfig, scalar(@triggers) / 3, @triggers) .
793 <input type=hidden name=paidaccounts value=$form->{paidaccounts}>
799 <td><hr size=3 noshade></td>
804 $lxdebug->leave_sub();
808 $lxdebug->enter_sub();
812 <input name=gldate type=hidden value="| . Q($form->{gldate}) . qq|">
814 <input name=callback type=hidden value="$form->{callback}">
816 <input type=hidden name=path value=$form->{path}>
817 <input type=hidden name=login value=$form->{login}>
818 <input type=hidden name=password value=$form->{password}>
820 . $cgi->hidden('-name' => 'draft_id', '-default' => [$form->{draft_id}])
821 . $cgi->hidden('-name' => 'draft_description', '-default' => [$form->{draft_description}])
827 $transdate = $form->datetonum($form->{transdate}, \%myconfig);
828 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
830 print qq|<input class=submit type=submit name=action value="|
831 . $locale->text('Update') . qq|">
834 if ($form->{radier}) {
836 <input class=submit type=submit name=action value="|
837 . $locale->text('Post') . qq|">
838 <input class=submit type=submit name=action value="|
839 . $locale->text('Delete') . qq|">
842 if ($transdate > $closedto) {
844 <input class=submit type=submit name=action value="|
845 . $locale->text('Use As Template') . qq|">
849 <input class=submit type=submit name=action value="|
850 . $locale->text('Post Payment') . qq|">
854 if ($transdate > $closedto) {
855 print qq|<input class=submit type=submit name=action value="|
856 . $locale->text('Post') . qq|"> | .
857 NTI($cgi->submit('-name' => 'action', '-value' => $locale->text('Save draft'),
858 '-class' => 'submit'));
862 if ($form->{menubar}) {
863 require "$form->{path}/menu.pl";
866 # button for saving history
867 if($form->{id} ne "") {
869 <input type=button class=submit onclick=set_history_window(|
871 . qq|); name=history id=history value=|
872 . $locale->text('history')
875 # /button for saving history
883 $lxdebug->leave_sub();
887 $lxdebug->enter_sub();
891 $form->{invtotal} = 0;
893 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
894 qw(exchangerate creditlimit creditremaining);
896 @flds = qw(amount AR_amount projectnumber oldprojectnumber project_id);
900 for $i (1 .. $form->{rowcount}) {
901 $form->{"amount_$i"} =
902 $form->parse_amount(\%myconfig, $form->{"amount_$i"});
903 $form->{"tax_$i"} = $form->parse_amount(\%myconfig, $form->{"tax_$i"});
904 if ($form->{"amount_$i"}) {
907 if (!$form->{"korrektur_$i"}) {
908 ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
910 if ($form->{taxincluded}) {
911 $form->{"tax_$i"} = $form->{"amount_$i"} / ($rate + 1) * $rate;
913 $form->{"tax_$i"} = $form->{"amount_$i"} * $rate;
916 $form->{"tax_$i"} = 0;
919 $form->{"tax_$i"} = $form->round_amount($form->{"tax_$i"}, 2);
921 $totaltax += $form->{"tax_$i"};
922 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
927 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
928 $form->{rowcount} = $count + 1;
929 map { $form->{invtotal} += $form->{"amount_$_"} } (1 .. $form->{rowcount});
931 $form->{exchangerate} = $exchangerate
935 $form->check_exchangerate(
936 \%myconfig, $form->{currency}, $form->{transdate}, 'buy'
939 $form->{invdate} = $form->{transdate};
940 $save_AR = $form->{AR};
941 &check_name(customer);
942 $form->{AR} = $save_AR;
945 ($form->{taxincluded}) ? $form->{invtotal} : $form->{invtotal} + $totaltax;
947 for $i (1 .. $form->{paidaccounts}) {
948 if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
951 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
952 } qw(paid exchangerate);
954 $totalpaid += $form->{"paid_$i"};
956 $form->{"exchangerate_$i"} = $exchangerate
958 $form->{"forex_$i"} = (
960 $form->check_exchangerate(
961 \%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'buy'
966 $form->{creditremaining} -=
967 ($form->{invtotal} - $totalpaid + $form->{oldtotalpaid} -
968 $form->{oldinvtotal});
969 $form->{oldinvtotal} = $form->{invtotal};
970 $form->{oldtotalpaid} = $totalpaid;
974 $lxdebug->leave_sub();
978 $lxdebug->enter_sub();
979 for $i (1 .. $form->{paidaccounts}) {
980 if ($form->{"paid_$i"}) {
981 $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
983 $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
985 $form->error($locale->text('Cannot post payment for a closed period!'))
986 if ($datepaid <= $closedto);
988 if ($form->{currency} ne $form->{defaultcurrency}) {
989 $form->{"exchangerate_$i"} = $form->{exchangerate}
990 if ($invdate == $datepaid);
991 $form->isblank("exchangerate_$i",
992 $locale->text('Exchangerate for payment missing!'));
997 ($form->{AR}) = split /--/, $form->{AR};
998 ($form->{AR_paid}) = split /--/, $form->{AR_paid};
999 $form->redirect($locale->text(' Payment posted!'))
1000 if (AR->post_payment(\%myconfig, \%$form));
1001 $form->error($locale->text('Cannot post payment!'));
1004 $lxdebug->leave_sub();
1008 $lxdebug->enter_sub();
1010 # check if there is an invoice number, invoice and due date
1011 $form->isblank("transdate", $locale->text('Invoice Date missing!'));
1012 $form->isblank("duedate", $locale->text('Due Date missing!'));
1013 $form->isblank("customer", $locale->text('Customer missing!'));
1015 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
1016 $transdate = $form->datetonum($form->{transdate}, \%myconfig);
1018 $form->error($locale->text('Cannot post transaction for a closed period!'))
1019 if ($transdate <= $closedto);
1021 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
1022 if ($form->{currency} ne $form->{defaultcurrency});
1024 delete($form->{AR});
1026 for $i (1 .. $form->{paidaccounts}) {
1027 if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
1028 $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
1030 $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
1032 $form->error($locale->text('Cannot post payment for a closed period!'))
1033 if ($datepaid <= $closedto);
1035 if ($form->{currency} ne $form->{defaultcurrency}) {
1036 $form->{"exchangerate_$i"} = $form->{exchangerate}
1037 if ($transdate == $datepaid);
1038 $form->isblank("exchangerate_$i",
1039 $locale->text('Exchangerate for payment missing!'));
1044 # if oldcustomer ne customer redo form
1045 ($customer) = split /--/, $form->{customer};
1046 if ($form->{oldcustomer} ne "$customer--$form->{customer_id}") {
1051 $form->{AR}{receivables} = $form->{ARselected};
1053 $form->{id} = 0 if $form->{postasnew};
1054 if (AR->post_transaction(\%myconfig, \%$form)) {
1055 # saving the history
1056 if(!exists $form->{addition} && $form->{id} ne "") {
1057 $form->{addition} = "POSTED";
1058 $form->save_history($form->dbconnect(\%myconfig));
1060 # /saving the history
1061 remove_draft() if $form->{remove_draft};
1062 $form->redirect($locale->text('Transaction posted!'));
1064 $form->error($locale->text('Cannot post transaction!'));
1066 $lxdebug->leave_sub();
1070 $lxdebug->enter_sub();
1072 $form->{postasnew} = 1;
1073 # saving the history
1074 if(!exists $form->{addition} && $form->{id} ne "") {
1075 $form->{addition} = "POSTED AS NEW";
1076 $form->save_history($form->dbconnect(\%myconfig));
1078 # /saving the history
1081 $lxdebug->leave_sub();
1084 sub use_as_template {
1085 $lxdebug->enter_sub();
1087 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);
1088 $form->{paidaccounts} = 1;
1089 $form->{rowcount}--;
1090 $form->{invdate} = $form->current_date(\%myconfig);
1093 $lxdebug->leave_sub();
1097 $lxdebug->enter_sub();
1099 $form->{title} = $locale->text('Confirm!');
1103 delete $form->{header};
1108 <form method=post action=$form->{script}>
1111 foreach $key (keys %$form) {
1112 $form->{$key} =~ s/\"/"/g;
1113 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
1117 <h2 class=confirm>$form->{title}</h2>
1120 . $locale->text('Are you sure you want to delete Transaction')
1121 . qq| $form->{invnumber}</h4>
1123 <input name=action class=submit type=submit value="|
1124 . $locale->text('Yes') . qq|">
1131 $lxdebug->leave_sub();
1135 $lxdebug->enter_sub();
1136 if (AR->delete_transaction(\%myconfig, \%$form, $spool)) {
1137 # saving the history
1138 if(!exists $form->{addition}) {
1139 $form->{addition} = "DELETED";
1140 $form->save_history($form->dbconnect(\%myconfig));
1142 # /saving the history
1143 $form->redirect($locale->text('Transaction deleted!'));
1145 $form->error($locale->text('Cannot delete transaction!'));
1147 $lxdebug->leave_sub();
1151 $lxdebug->enter_sub();
1153 # setup customer selection
1154 $form->all_vc(\%myconfig, "customer", "AR");
1156 if (@{ $form->{all_customer} }) {
1157 map { $customer .= "<option>$_->{name}--$_->{id}\n" }
1158 @{ $form->{all_customer} };
1159 $customer = qq|<select name=customer><option>\n$customer</select>|;
1161 $customer = qq|<input name=customer size=35>|;
1165 if (@{ $form->{all_departments} }) {
1166 $form->{selectdepartment} = "<option>\n";
1169 $form->{selectdepartment} .=
1170 "<option>$_->{description}--$_->{id}\n"
1171 } (@{ $form->{all_departments} });
1176 <th align=right nowrap>| . $locale->text('Department') . qq|</th>
1177 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
1179 | if $form->{selectdepartment};
1181 $form->{title} = $locale->text('AR Transactions');
1183 # use JavaScript Calendar or not
1184 $form->{jsscript} = $jscalendar;
1186 if ($form->{jsscript}) {
1188 # with JavaScript Calendar
1190 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}">
1191 <input type=button name=transdatefrom id="trigger1" value=|
1192 . $locale->text('button') . qq|></td>
1195 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}">
1196 <input type=button name=transdateto name=transdateto id="trigger2" value=|
1197 . $locale->text('button') . qq|></td>
1202 Form->write_trigger(\%myconfig, "2", "transdatefrom", "BR", "trigger1",
1203 "transdateto", "BL", "trigger2");
1206 # without JavaScript Calendar
1208 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>|;
1210 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}"></td>|;
1213 $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
1218 foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
1219 push(@values, $item->{"id"});
1220 $labels{$item->{"id"}} = $item->{"projectnumber"};
1223 NTI($cgi->popup_menu('-name' => 'project_id', '-values' => \@values,
1224 '-labels' => \%labels));
1226 $form->{fokus} = "search.customer";
1230 <body onLoad="fokus()">
1232 <form method=post name="search" action=$form->{script}>
1235 <tr><th class=listtop>$form->{title}</th></tr>
1236 <tr height="5"></tr>
1241 <th align=right>| . $locale->text('Customer') . qq|</th>
1242 <td colspan=3>$customer</td>
1246 <th align=right nowrap>| . $locale->text('Invoice Number') . qq|</th>
1247 <td colspan=3><input name=invnumber size=20></td>
1250 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
1251 <td colspan=3><input name=ordnumber size=20></td>
1254 <th align=right nowrap>| . $locale->text('Notes') . qq|</th>
1255 <td colspan=3><input name=notes size=40></td>
1258 <th align="right">| . $locale->text("Project Number") . qq|</th>
1259 <td colspan="3">$projectnumber</td>
1262 <th align=right nowrap>| . $locale->text('From') . qq|</th>
1264 <th align=right>| . $locale->text('Bis') . qq|</th>
1267 <input type=hidden name=sort value=transdate>
1275 <th align=right nowrap>| . $locale->text('Include in Report') . qq|</th>
1279 <td align=right><input name=open class=checkbox type=checkbox value=Y checked></td>
1280 <td nowrap>| . $locale->text('Open') . qq|</td>
1281 <td align=right><input name=closed class=checkbox type=checkbox value=Y></td>
1282 <td nowrap>| . $locale->text('Closed') . qq|</td>
1285 <td align=right><input name="l_id" class=checkbox type=checkbox value=Y></td>
1286 <td nowrap>| . $locale->text('ID') . qq|</td>
1287 <td align=right><input name="l_invnumber" class=checkbox type=checkbox value=Y checked></td>
1288 <td nowrap>| . $locale->text('Invoice Number') . qq|</td>
1289 <td align=right><input name="l_ordnumber" class=checkbox type=checkbox value=Y></td>
1290 <td nowrap>| . $locale->text('Order Number') . qq|</td>
1291 <td align=right><input name="l_transdate" class=checkbox type=checkbox value=Y checked></td>
1292 <td nowrap>| . $locale->text('Invoice Date') . qq|</td>
1295 <td align=right><input name="l_name" class=checkbox type=checkbox value=Y checked></td>
1296 <td nowrap>| . $locale->text('Customer') . qq|</td>
1297 <td align=right><input name="l_netamount" class=checkbox type=checkbox value=Y></td>
1298 <td nowrap>| . $locale->text('Amount') . qq|</td>
1299 <td align=right><input name="l_tax" class=checkbox type=checkbox value=Y></td>
1300 <td nowrap>| . $locale->text('Tax') . qq|</td>
1301 <td align=right><input name="l_amount" class=checkbox type=checkbox value=Y checked></td>
1302 <td nowrap>| . $locale->text('Total') . qq|</td>
1305 <td align=right><input name="l_datepaid" class=checkbox type=checkbox value=Y></td>
1306 <td nowrap>| . $locale->text('Date Paid') . qq|</td>
1307 <td align=right><input name="l_paid" class=checkbox type=checkbox value=Y checked></td>
1308 <td nowrap>| . $locale->text('Paid') . qq|</td>
1309 <td align=right><input name="l_duedate" class=checkbox type=checkbox value=Y></td>
1310 <td nowrap>| . $locale->text('Due Date') . qq|</td>
1311 <td align=right><input name="l_due" class=checkbox type=checkbox value=Y></td>
1312 <td nowrap>| . $locale->text('Amount Due') . qq|</td>
1315 <td align=right><input name="l_notes" class=checkbox type=checkbox value=Y></td>
1316 <td nowrap>| . $locale->text('Notes') . qq|</td>
1317 <td align=right><input name="l_employee" class=checkbox type=checkbox value=Y></td>
1318 <td nowrap>| . $locale->text('Salesperson') . qq|</td>
1319 <td align=right><input name="l_shippingpoint" class=checkbox type=checkbox value=Y></td>
1320 <td nowrap>| . $locale->text('Shipping Point') . qq|</td>
1321 <td align=right><input name="l_shipvia" class=checkbox type=checkbox value=Y></td>
1322 <td nowrap>| . $locale->text('Ship via') . qq|</td>
1325 <td align=right><input name="l_subtotal" class=checkbox type=checkbox value=Y></td>
1326 <td nowrap>| . $locale->text('Subtotal') . qq|</td>
1327 <td align=right><input name="l_globalprojectnumber" class=checkbox type=checkbox value=Y></td>
1328 <td nowrap>| . $locale->text('Project Number') . qq|</td>
1337 <td><hr size=3 noshade></td>
1341 <input type=hidden name=nextsub value=$form->{nextsub}>
1343 <input type=hidden name=path value=$form->{path}>
1344 <input type=hidden name=login value=$form->{login}>
1345 <input type=hidden name=password value=$form->{password}>
1348 <input class=submit type=submit name=action value="|
1349 . $locale->text('Continue') . qq|">
1360 $lxdebug->leave_sub();
1363 sub ar_transactions {
1364 $lxdebug->enter_sub();
1366 $form->{customer} = $form->unescape($form->{customer});
1367 ($form->{customer}, $form->{customer_id}) = split(/--/, $form->{customer});
1369 AR->ar_transactions(\%myconfig, \%$form);
1372 "$form->{script}?action=ar_transactions&path=$form->{path}&login=$form->{login}&password=$form->{password}";
1375 if ($form->{customer}) {
1376 $callback .= "&customer=" . $form->escape($form->{customer}, 1);
1377 $href .= "&customer=" . $form->escape($form->{customer});
1378 $option = $locale->text('Customer') . " : $form->{customer}";
1380 if ($form->{department}) {
1381 $callback .= "&department=" . $form->escape($form->{department}, 1);
1382 $href .= "&department=" . $form->escape($form->{department});
1383 ($department) = split /--/, $form->{department};
1384 $option .= "\n<br>" if ($option);
1385 $option .= $locale->text('Department') . " : $department";
1387 if ($form->{invnumber}) {
1388 $callback .= "&invnumber=" . $form->escape($form->{invnumber}, 1);
1389 $href .= "&invnumber=" . $form->escape($form->{invnumber});
1390 $option .= "\n<br>" if ($option);
1391 $option .= $locale->text('Invoice Number') . " : $form->{invnumber}";
1393 if ($form->{ordnumber}) {
1394 $callback .= "&ordnumber=" . $form->escape($form->{ordnumber}, 1);
1395 $href .= "&ordnumber=" . $form->escape($form->{ordnumber});
1396 $option .= "\n<br>" if ($option);
1397 $option .= $locale->text('Order Number') . " : $form->{ordnumber}";
1399 if ($form->{notes}) {
1400 $callback .= "¬es=" . $form->escape($form->{notes}, 1);
1401 $href .= "¬es=" . $form->escape($form->{notes});
1402 $option .= "\n<br>" if $option;
1403 $option .= $locale->text('Notes') . " : $form->{notes}";
1406 if ($form->{transdatefrom}) {
1407 $callback .= "&transdatefrom=$form->{transdatefrom}";
1408 $href .= "&transdatefrom=$form->{transdatefrom}";
1409 $option .= "\n<br>" if ($option);
1411 $locale->text('From') . " "
1412 . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
1414 if ($form->{transdateto}) {
1415 $callback .= "&transdateto=$form->{transdateto}";
1416 $href .= "&transdateto=$form->{transdateto}";
1417 $option .= "\n<br>" if ($option);
1419 $locale->text('Bis') . " "
1420 . $locale->date(\%myconfig, $form->{transdateto}, 1);
1422 if ($form->{open}) {
1423 $callback .= "&open=$form->{open}";
1424 $href .= "&open=$form->{open}";
1425 $option .= "\n<br>" if ($option);
1426 $option .= $locale->text('Open');
1428 if ($form->{closed}) {
1429 $callback .= "&closed=$form->{closed}";
1430 $href .= "&closed=$form->{closed}";
1431 $option .= "\n<br>" if ($option);
1432 $option .= $locale->text('Closed');
1434 if ($form->{globalproject_id}) {
1435 $callback .= "&globalproject_id=" . E($form->{globalproject_id});
1436 $href .= "&globalproject_id=" . E($form->{globalproject_id});
1440 qw(transdate id type invnumber ordnumber name netamount tax amount paid
1441 datepaid due duedate notes employee shippingpoint shipvia
1442 globalprojectnumber);
1444 $form->{"l_type"} = "Y";
1446 foreach $item (@columns) {
1447 if ($form->{"l_$item"} eq "Y") {
1448 push @column_index, $item;
1450 # add column to href and callback
1451 $callback .= "&l_$item=Y";
1452 $href .= "&l_$item=Y";
1456 if ($form->{l_subtotal} eq 'Y') {
1457 $callback .= "&l_subtotal=Y";
1458 $href .= "&l_subtotal=Y";
1461 $column_header{id} =
1462 "<th><a class=listheading href=$href&sort=id>"
1463 . $locale->text('ID')
1465 $column_header{transdate} =
1466 "<th><a class=listheading href=$href&sort=transdate>"
1467 . $locale->text('Date')
1469 $column_header{duedate} =
1470 "<th><a class=listheading href=$href&sort=duedate>"
1471 . $locale->text('Due Date')
1473 $column_header{type} =
1474 "<th class=\"listheading\">" . $locale->text('Type') . "</th>";
1475 $column_header{invnumber} =
1476 "<th><a class=listheading href=$href&sort=invnumber>"
1477 . $locale->text('Invoice')
1479 $column_header{ordnumber} =
1480 "<th><a class=listheading href=$href&sort=ordnumber>"
1481 . $locale->text('Order')
1483 $column_header{name} =
1484 "<th><a class=listheading href=$href&sort=name>"
1485 . $locale->text('Customer')
1487 $column_header{netamount} =
1488 "<th class=listheading>" . $locale->text('Amount') . "</th>";
1489 $column_header{tax} =
1490 "<th class=listheading>" . $locale->text('Tax') . "</th>";
1491 $column_header{amount} =
1492 "<th class=listheading>" . $locale->text('Total') . "</th>";
1493 $column_header{paid} =
1494 "<th class=listheading>" . $locale->text('Paid') . "</th>";
1495 $column_header{datepaid} =
1496 "<th><a class=listheading href=$href&sort=datepaid>"
1497 . $locale->text('Date Paid')
1499 $column_header{due} =
1500 "<th class=listheading>" . $locale->text('Amount Due') . "</th>";
1501 $column_header{notes} =
1502 "<th class=listheading>" . $locale->text('Notes') . "</th>";
1503 $column_header{employee} =
1504 "<th><a class=listheading href=$href&sort=employee>"
1505 . $locale->text('Salesperson') . "</th>";
1507 $column_header{shippingpoint} =
1508 "<th><a class=listheading href=$href&sort=shippingpoint>"
1509 . $locale->text('Shipping Point')
1511 $column_header{shipvia} =
1512 "<th><a class=listheading href=$href&sort=shipvia>"
1513 . $locale->text('Ship via')
1515 $column_header{globalprojectnumber} =
1516 qq|<th class="listheading">| . $locale->text('Project Number') . qq|</th>|;
1518 $form->{title} = $locale->text('AR Transactions');
1527 <th class=listtop>$form->{title}</th>
1529 <tr height="5"></tr>
1536 <tr class=listheading>
1539 map { print "\n$column_header{$_}" } @column_index;
1545 # add sort and escape callback, this one we use for the add sub
1546 $form->{callback} = $callback .= "&sort=$form->{sort}";
1548 # escape callback for href
1549 $callback = $form->escape($callback);
1551 if (@{ $form->{AR} }) {
1552 $sameitem = $form->{AR}->[0]->{ $form->{sort} };
1555 # sums and tax on reports by Antonio Gallardo
1557 foreach $ar (@{ $form->{AR} }) {
1559 if ($form->{l_subtotal} eq 'Y') {
1560 if ($sameitem ne $ar->{ $form->{sort} }) {
1565 $column_data{netamount} =
1567 . $form->format_amount(\%myconfig, $ar->{netamount}, 2, " ")
1569 $column_data{tax} = "<td align=right>"
1570 . $form->format_amount(\%myconfig, $ar->{amount} - $ar->{netamount},
1573 $column_data{amount} =
1575 . $form->format_amount(\%myconfig, $ar->{amount}, 2, " ") . "</td>";
1576 $column_data{paid} =
1578 . $form->format_amount(\%myconfig, $ar->{paid}, 2, " ") . "</td>";
1579 $column_data{due} = "<td align=right>"
1580 . $form->format_amount(\%myconfig, $ar->{amount} - $ar->{paid},
1584 $subtotalnetamount += $ar->{netamount};
1585 $subtotalamount += $ar->{amount};
1586 $subtotalpaid += $ar->{paid};
1587 $subtotaldue += $ar->{amount} - $ar->{paid};
1589 $totalnetamount += $ar->{netamount};
1590 $totalamount += $ar->{amount};
1591 $totalpaid += $ar->{paid};
1592 $totaldue += ($ar->{amount} - $ar->{paid});
1594 $column_data{transdate} = "<td>$ar->{transdate} </td>";
1595 $column_data{id} = "<td>$ar->{id}</td>";
1596 $column_data{datepaid} = "<td>$ar->{datepaid} </td>";
1597 $column_data{duedate} = "<td>$ar->{duedate} </td>";
1599 $module = ($ar->{invoice}) ? "is.pl" : $form->{script};
1601 $column_data{invnumber} =
1602 "<td><a href=$module?action=edit&id=$ar->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ar->{invnumber}</a></td>";
1603 $column_data{type} = "<td>" .
1604 ($ar->{storno} ? $locale->text("Storno (one letter abbreviation)") :
1606 $locale->text("Credit note (one letter abbreviation)") :
1607 $locale->text("Invoice (one letter abbreviation)")) . "</td>";
1608 $column_data{ordnumber} = "<td>$ar->{ordnumber} </td>";
1609 $column_data{name} = "<td>$ar->{name}</td>";
1610 $ar->{notes} =~ s/\r\n/<br>/g;
1611 $column_data{notes} = "<td>$ar->{notes} </td>";
1612 $column_data{shippingpoint} = "<td>$ar->{shippingpoint} </td>";
1613 $column_data{shipvia} = "<td>$ar->{shipvia} </td>";
1614 $column_data{employee} = "<td>$ar->{employee} </td>";
1615 $column_data{globalprojectnumber} =
1616 "<td>" . H($ar->{globalprojectnumber}) . "</td>";
1621 <tr class=listrow$i>
1624 map { print "\n$column_data{$_}" } @column_index;
1632 if ($form->{l_subtotal} eq 'Y') {
1638 <tr class=listtotal>
1641 map { $column_data{$_} = "<td> </td>" } @column_index;
1643 $column_data{netamount} =
1644 "<th class=listtotal align=right>"
1645 . $form->format_amount(\%myconfig, $totalnetamount, 2, " ") . "</th>";
1646 $column_data{tax} = "<th class=listtotal align=right>"
1647 . $form->format_amount(\%myconfig, $totalamount - $totalnetamount,
1650 $column_data{amount} =
1651 "<th class=listtotal align=right>"
1652 . $form->format_amount(\%myconfig, $totalamount, 2, " ") . "</th>";
1653 $column_data{paid} =
1654 "<th class=listtotal align=right>"
1655 . $form->format_amount(\%myconfig, $totalpaid, 2, " ") . "</th>";
1657 "<th class=listtotal align=right>"
1658 . $form->format_amount(\%myconfig, $totaldue, 2, " ") . "</th>";
1660 map { print "\n$column_data{$_}" } @column_index;
1668 <td><hr size=3 noshade></td>
1673 <form method=post action=$form->{script}>
1675 <input name=callback type=hidden value="$form->{callback}">
1677 <input type=hidden name=path value=$form->{path}>
1678 <input type=hidden name=login value=$form->{login}>
1679 <input type=hidden name=password value=$form->{password}>
1681 <input class=submit type=submit name=action value="|
1682 . $locale->text('AR Transaction') . qq|">
1683 <input class=submit type=submit name=action value="|
1684 . $locale->text('Sales Invoice') . qq|">
1692 $lxdebug->leave_sub();
1696 $lxdebug->enter_sub();
1698 map { $column_data{$_} = "<td> </td>" } @column_index;
1700 $column_data{tax} = "<th class=listsubtotal align=right>"
1701 . $form->format_amount(\%myconfig, $subtotalamount - $subtotalnetamount,
1704 $column_data{amount} =
1705 "<th class=listsubtotal align=right>"
1706 . $form->format_amount(\%myconfig, $subtotalamount, 2, " ") . "</th>";
1707 $column_data{paid} =
1708 "<th class=listsubtotal align=right>"
1709 . $form->format_amount(\%myconfig, $subtotalpaid, 2, " ") . "</th>";
1711 "<th class=listsubtotal align=right>"
1712 . $form->format_amount(\%myconfig, $subtotaldue, 2, " ") . "</th>";
1714 $subtotalnetamount = 0;
1715 $subtotalamount = 0;
1719 $sameitem = $ar->{ $form->{sort} };
1721 print "<tr class=listsubtotal>";
1723 map { print "\n$column_data{$_}" } @column_index;
1729 $lxdebug->leave_sub();