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";
46 # this is for our long dates
47 # $locale->text('January')
48 # $locale->text('February')
49 # $locale->text('March')
50 # $locale->text('April')
51 # $locale->text('May ')
52 # $locale->text('June')
53 # $locale->text('July')
54 # $locale->text('August')
55 # $locale->text('September')
56 # $locale->text('October')
57 # $locale->text('November')
58 # $locale->text('December')
60 # this is for our short month
61 # $locale->text('Jan')
62 # $locale->text('Feb')
63 # $locale->text('Mar')
64 # $locale->text('Apr')
65 # $locale->text('May')
66 # $locale->text('Jun')
67 # $locale->text('Jul')
68 # $locale->text('Aug')
69 # $locale->text('Sep')
70 # $locale->text('Oct')
71 # $locale->text('Nov')
72 # $locale->text('Dec')
75 $lxdebug->enter_sub();
77 $form->{title} = "Add";
79 "$form->{script}?action=add&path=$form->{path}&login=$form->{login}&password=$form->{password}"
80 unless $form->{callback};
83 AR->get_transdate(\%myconfig, $form);
86 $lxdebug->leave_sub();
90 $lxdebug->enter_sub();
92 $form->{title} = "Edit";
97 $lxdebug->leave_sub();
101 $lxdebug->enter_sub();
106 $lxdebug->leave_sub();
110 $lxdebug->enter_sub();
112 $form->create_links("AR", \%myconfig, "customer");
113 $duedate = $form->{duedate};
115 $taxincluded = $form->{taxincluded};
116 my $id = $form->{id};
117 IS->get_customer(\%myconfig, \%$form);
118 $form->{taxincluded} = $taxincluded;
121 $form->{duedate} = $duedate if $duedate;
122 $form->{oldcustomer} = "$form->{customer}--$form->{customer_id}";
123 $form->{rowcount} = 1;
126 @curr = split(/:/, $form->{currencies});
128 $form->{defaultcurrency} = $curr[0];
130 map { $form->{selectcurrency} .= "<option>$_\n" } @curr;
133 if (@{ $form->{all_customer} }) {
134 $form->{customer} = "$form->{customer}--$form->{customer_id}";
135 map { $form->{selectcustomer} .= "<option>$_->{name}--$_->{id}\n" }
136 (@{ $form->{all_customer} });
140 if (@{ $form->{all_departments} }) {
141 $form->{selectdepartment} = "<option>\n";
142 $form->{department} = "$form->{department}--$form->{department_id}";
145 $form->{selectdepartment} .=
146 "<option>$_->{description}--$_->{id}\n"
147 } (@{ $form->{all_departments} });
150 $form->{employee} = "$form->{employee}--$form->{employee_id}";
153 if (@{ $form->{all_employees} }) {
154 $form->{selectemployee} = "";
155 map { $form->{selectemployee} .= "<option>$_->{name}--$_->{id}\n" }
156 (@{ $form->{all_employees} });
159 # build the popup menus
160 $form->{taxincluded} = ($form->{id}) ? $form->{taxincluded} : "checked";
164 qq|<option value=\"$_->{id}--$_->{rate}\">$_->{taxdescription} |
165 . ($_->{rate} * 100) . qq| %|
167 $form->{taxchart} = $tax;
168 $form->{selecttaxchart} = $tax;
171 $form->{forex} = $form->{exchangerate};
172 $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
173 foreach $key (keys %{ $form->{AR_links} }) {
175 foreach $ref (@{ $form->{AR_links}{$key} }) {
176 if ($key eq "AR_paid") {
177 $form->{"select$key"} .=
178 "<option value=\"$ref->{accno}\">$ref->{accno}--$ref->{description}</option>\n";
180 $form->{"select$key"} .=
181 "<option value=\"$ref->{accno}--$ref->{tax_id}\">$ref->{accno}--$ref->{description}</option>\n";
185 $form->{$key} = $form->{"select$key"};
187 # if there is a value we have an old entry
191 for $i (1 .. scalar @{ $form->{acc_trans}{$key} }) {
192 if ($key eq "AR_paid") {
194 $form->{"AR_paid_$j"} =
195 "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
198 $form->{"paid_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{amount} * -1;
199 $form->{"datepaid_$j"} =
200 $form->{acc_trans}{$key}->[$i - 1]->{transdate};
201 $form->{"source_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{source};
202 $form->{"memo_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{memo};
204 $form->{"forex_$j"} = $form->{"exchangerate_$i"} =
205 $form->{acc_trans}{$key}->[$i - 1]->{exchangerate};
206 $form->{"AR_paid_$j"} = "$form->{acc_trans}{$key}->[$i-1]->{accno}";
207 $form->{"paid_project_id_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{project_id};
208 $form->{paidaccounts}++;
214 if ($key eq "AR_tax" || $key eq "AP_tax") {
215 $form->{"${key}_$form->{acc_trans}{$key}->[$i-1]->{accno}"} =
216 "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
217 $form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"} =
219 $form->{acc_trans}{$key}->[$i - 1]->{amount} / $exchangerate,
222 if ($form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"} > 0) {
224 $form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"};
226 $form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"};
229 $form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"};
231 $form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"};
233 $index = $form->{acc_trans}{$key}->[$i - 1]->{index};
234 $form->{"tax_$index"} = $form->{acc_trans}{$key}->[$i - 1]->{amount};
235 $totaltax += $form->{"tax_$index"};
239 $form->{"${akey}_$k"} =
241 $form->{acc_trans}{$key}->[$i - 1]->{amount} / $exchangerate,
243 if ($akey eq 'amount') {
245 $totalamount += $form->{"${akey}_$i"};
247 $form->{"oldprojectnumber_$k"} = $form->{"projectnumber_$k"} =
248 "$form->{acc_trans}{$key}->[$i-1]->{projectnumber}";
249 $form->{taxrate} = $form->{acc_trans}{$key}->[$i - 1]->{rate};
250 $form->{"project_id_$k"} =
251 "$form->{acc_trans}{$key}->[$i-1]->{project_id}";
253 $form->{"${key}_$k"} =
254 "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
255 $form->{"${key}_$i"} =
256 "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
257 my $q_description = quotemeta($form->{acc_trans}{$key}->[$i-1]->{description});
258 $form->{"select${key}"} =~
259 /<option value=\"($form->{acc_trans}{$key}->[$i-1]->{accno}--[^\"]*)\">$form->{acc_trans}{$key}->[$i-1]->{accno}--${q_description}<\/option>\n/;
260 $form->{"${key}_$k"} = $1;
261 if ($akey eq 'amount') {
262 $form->{"taxchart_$k"} = $form->{taxchart};
263 $form->{"taxchart_$k"} =~
264 /<option value=\"($form->{acc_trans}{$key}->[$i-1]->{id}--[^\"]*)/;
265 $form->{"taxchart_$k"} = $1;
272 $form->{taxincluded} = $taxincluded if ($form->{id});
273 $form->{paidaccounts} = 1 if not defined $form->{paidaccounts};
275 if ($form->{taxincluded} && $form->{taxrate} && $totalamount) {
277 # add tax to amounts and invtotal
278 for $i (1 .. $form->{rowcount}) {
280 ($totaltax + $totalwithholding) * $form->{"amount_$i"} / $totalamount;
281 $tax = $form->round_amount($taxamount, 2);
282 $diff += ($taxamount - $tax);
283 $form->{"amount_$i"} += $form->{"tax_$i"};
285 $form->{amount_1} += $form->round_amount($diff, 2);
288 $taxamount = $form->round_amount($taxamount, 2);
289 $form->{tax} = $taxamount;
291 $form->{invtotal} = $totalamount + $totaltax;
294 ($form->datetonum($form->{transdate}, \%myconfig) <=
295 $form->datetonum($form->{closedto}, \%myconfig));
297 $form->{"ARselected"} = $form->{"AR_1"};
299 $lxdebug->leave_sub();
303 $lxdebug->enter_sub();
305 $title = $form->{title};
306 $form->{title} = $locale->text("$title Accounts Receivables Transaction");
308 $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
310 # $locale->text('Add Accounts Receivables Transaction')
311 # $locale->text('Edit Accounts Receivables Transaction')
312 $form->{javascript} = qq|<script type="text/javascript">
314 function setTaxkey(accno, row) {
315 var taxkey = accno.options[accno.selectedIndex].value;
316 var reg = /--([0-9]*)/;
317 var found = reg.exec(taxkey);
318 var index = found[1];
319 index = parseInt(index);
320 var tax = 'taxchart_' + row;
321 for (var i = 0; i < document.getElementById(tax).options.length; ++i) {
322 var reg2 = new RegExp("^"+ index, "");
323 if (reg2.exec(document.getElementById(tax).options[i].value)) {
324 document.getElementById(tax).options[i].selected = true;
332 $readonly = ($form->{id}) ? "readonly" : "";
335 ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0;
336 $readonly = ($form->{radier}) ? "" : $readonly;
338 my $ARselected_quoted = quotemeta($form->{"ARselected"});
339 $form->{selectAR} = $form->{AR};
341 s/value=\"${ARselected_quoted}\"/value=\"$form->{ARselected}\" selected/;
343 # set option selected
344 foreach $item (qw(customer currency department employee)) {
345 $form->{"select$item"} =~ s/ selected//;
346 $form->{"select$item"} =~
347 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
349 $selectAR_amount_unquoted = $form->{selectAR_amount};
350 $taxchart = $form->{taxchart};
351 map { $form->{$_} =~ s/\"/"/g }
352 qw(AR_amount selectAR_amount AR taxchart);
355 $form->{exchangerate} =
356 $form->format_amount(\%myconfig, $form->{exchangerate});
358 $form->{creditlimit} =
359 $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
360 $form->{creditremaining} =
361 $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
364 <input type=hidden name=forex value=$form->{forex}>
366 if ($form->{currency} ne $form->{defaultcurrency}) {
367 if ($form->{forex}) {
369 <th align=right>| . $locale->text('Exchangerate') . qq|</th>
370 <td><input type=hidden name=exchangerate value=$form->{exchangerate}>$form->{exchangerate}</td>
374 <th align=right>| . $locale->text('Exchangerate') . qq|</th>
375 <td><input name=exchangerate size=10 value=$form->{exchangerate}></td>
384 <td align=right><input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}></td>
385 <th align=left nowrap>| . $locale->text('Tax Included') . qq|</th>
389 if (($rows = $form->numtextrows($form->{notes}, 50)) < 2) {
393 qq|<textarea name=notes rows=$rows cols=50 wrap=soft>$form->{notes}</textarea>|;
397 <th align="right" nowrap>| . $locale->text('Department') . qq|</th>
398 <td colspan=3><select name=department>$form->{selectdepartment}</select>
399 <input type=hidden name=selectdepartment value="$form->{selectdepartment}">
402 | if $form->{selectdepartment};
404 $n = ($form->{creditremaining} =~ /-/) ? "0" : "1";
407 ($form->{selectcustomer})
408 ? qq|<select name=customer>$form->{selectcustomer}</select>|
409 : qq|<input name=customer value="$form->{customer}" size=35>|;
412 <input type=hidden name=employee value="$form->{employee}">
415 if ($form->{selectemployee}) {
418 <th align=right nowrap>| . $locale->text('Salesperson') . qq|</th>
419 <td colspan=2><select name=employee>$form->{selectemployee}</select></td>
420 <input type=hidden name=selectemployee value="$form->{selectemployee}">
425 my @old_project_ids = ();
426 map({ push(@old_project_ids, $form->{"project_id_$_"})
427 if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
429 $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
431 "old_id" => \@old_project_ids });
433 my %project_labels = ();
434 my @project_values = ("");
435 foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
436 push(@project_values, $item->{"id"});
437 $project_labels{$item->{"id"}} = $item->{"projectnumber"};
440 $form->{fokus} = "arledger.customer";
442 # use JavaScript Calendar or not
443 $form->{jsscript} = $jscalendar;
445 if ($form->{jsscript}) {
447 # with JavaScript Calendar
449 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>
450 <td><input type=button name=transdate id="trigger1" value=|
451 . $locale->text('button') . qq|></td>
454 <td><input name=duedate id=duedate size=11 title="$myconfig{dateformat}" value=$form->{duedate}></td>
455 <td><input type=button name=duedate id="trigger2" value=|
456 . $locale->text('button') . qq|></td></td>
461 Form->write_trigger(\%myconfig, "2", "transdate", "BL", "trigger1",
462 "duedate", "BL", "trigger2");
465 # without JavaScript Calendar
467 qq|<td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>|;
469 qq|<td><input name=duedate id=duedate size=11 title="$myconfig{dateformat}" value=$form->{duedate}></td>|;
475 <body onLoad="fokus()">
477 <form method=post name="arledger" action=$form->{script}>
479 <input type=hidden name=id value=$form->{id}>
480 <input type=hidden name=sort value=$form->{sort}>
481 <input type=hidden name=closedto value=$form->{closedto}>
482 <input type=hidden name=locked value=$form->{locked}>
483 <input type=hidden name=title value="$title">
487 <th class=listtop>$form->{title}</th>
497 <th align="right" nowrap>| . $locale->text('Customer') . qq|</th>
498 <td colspan=3>$customer</td>
499 <input type=hidden name=selectcustomer value="$form->{selectcustomer}">
500 <input type=hidden name=oldcustomer value="$form->{oldcustomer}">
501 <input type=hidden name=customer_id value="$form->{customer_id}">
502 <input type=hidden name=terms value=$form->{terms}>
509 <th align=left nowrap>| . $locale->text('Credit Limit') . qq|</th>
510 <td>$form->{creditlimit}</td>
511 <th align=left nowrap>| . $locale->text('Remaining') . qq|</th>
512 <td class="plus$n">$form->{creditremaining}</td>
513 <input type=hidden name=creditlimit value=$form->{creditlimit}>
514 <input type=hidden name=creditremaining value=$form->{creditremaining}>
520 <th align=right>| . $locale->text('Currency') . qq|</th>
521 <td><select name=currency>$form->{selectcurrency}</select></td>
522 <input type=hidden name=selectcurrency value="$form->{selectcurrency}">
523 <input type=hidden name=defaultcurrency value=$form->{defaultcurrency}>
524 <input type=hidden name=fxgain_accno value=$form->{fxgain_accno}>
525 <input type=hidden name=fxloss_accno value=$form->{fxloss_accno}>
536 <th align=right nowrap>| . $locale->text('Invoice Number') . qq|</th>
537 <td><input name=invnumber size=11 value="$form->{invnumber}"></td>
540 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
541 <td><input name=ordnumber size=11 value="$form->{ordnumber}"></td>
544 <th align=right nowrap>| . $locale->text('Invoice Date') . qq|</th>
548 <th align=right nowrap>| . $locale->text('Due Date') . qq|</th>
559 <input type=hidden name=selectAR_amount value="$form->{selectAR_amount}">
560 <input type=hidden name=AR_amount value="$form->{AR_amount}">
561 <input type=hidden name=taxchart value="$form->{taxchart}">
562 <input type=hidden name=rowcount value=$form->{rowcount}>
566 <tr class=listheading>
567 <th class=listheading style="width:15%">|
568 . $locale->text('Account') . qq|</th>
569 <th class=listheading style="width:10%">|
570 . $locale->text('Amount') . qq|</th>
571 <th class=listheading style="width:10%">|
572 . $locale->text('Tax') . qq|</th>
573 <th class=listheading style="width:5%">|
574 . $locale->text('Korrektur') . qq|</th>
575 <th class=listheading style="width:10%">|
576 . $locale->text('Taxkey') . qq|</th>
577 <th class=listheading style="width:10%">|
578 . $locale->text('Project') . qq|</th>
582 $amount = $locale->text('Amount');
583 $project = $locale->text('Project');
585 for $i (1 .. $form->{rowcount}) {
588 $form->{"amount_$i"} =
589 $form->format_amount(\%myconfig, $form->{"amount_$i"}, 2);
590 $form->{"tax_$i"} = $form->format_amount(\%myconfig, $form->{"tax_$i"}, 2);
591 $selectAR_amount = $selectAR_amount_unquoted;
593 s/option value=\"$form->{"AR_amount_$i"}\"/option value=\"$form->{"AR_amount_$i"}\" selected/;
595 $tax_selected = $form->{"taxchart_$i"};
596 $tax =~ s/value=\"$tax_selected\"/value=\"$tax_selected\" selected/;
598 qq|<td><select id="taxchart_$i" name="taxchart_$i" style="width:200px">$tax</select></td>|;
599 $korrektur_checked = ($form->{"korrektur_$i"} ? 'checked' : '');
602 NTI($cgi->popup_menu('-name' => "project_id_$i",
603 '-values' => \@project_values,
604 '-labels' => \%project_labels,
605 '-default' => $form->{"project_id_$i"} ));
609 <td width=50%><select name="AR_amount_$i" onChange="setTaxkey(this, $i)" style="width:100%">$selectAR_amount</select></td>
610 <td><input name="amount_$i" size=10 value=$form->{"amount_$i"}></td>
611 <td><input name="tax_$i" size=10 value=$form->{"tax_$i"}></td>
612 <td><input type="checkbox" name="korrektur_$i" value="1" $korrektur_checked></td>
614 <td>$projectnumber</td>
621 $form->{invtotal} = $form->format_amount(\%myconfig, $form->{invtotal}, 2);
630 <td><select name=ARselected>$form->{selectAR}</select></td>
631 <input type=hidden name=AR value="$form->{AR}">
632 <th align=left>$form->{invtotal}</th>
634 <input type=hidden name=oldinvtotal value=$form->{oldinvtotal}>
635 <input type=hidden name=oldtotalpaid value=$form->{oldtotalpaid}>
637 <input type=hidden name=taxaccounts value="$form->{taxaccounts}">
650 <th align=left width=1%>| . $locale->text('Notes') . qq|</th>
651 <td align=left>$notes</td>
659 <tr class=listheading>
660 <th colspan=7 class=listheading>|
661 . $locale->text('Incoming Payments') . qq|</th>
665 if ($form->{currency} eq $form->{defaultcurrency}) {
666 @column_index = qw(datepaid source memo paid AR_paid paid_project_id);
668 @column_index = qw(datepaid source memo paid exchangerate AR_paid paid_project_id);
671 $column_data{datepaid} = "<th>" . $locale->text('Date') . "</th>";
672 $column_data{paid} = "<th>" . $locale->text('Amount') . "</th>";
673 $column_data{exchangerate} = "<th>" . $locale->text('Exch') . "</th>";
674 $column_data{AR_paid} = "<th>" . $locale->text('Account') . "</th>";
675 $column_data{source} = "<th>" . $locale->text('Source') . "</th>";
676 $column_data{memo} = "<th>" . $locale->text('Memo') . "</th>";
677 $column_data{paid_project_id} = "<th>" . $locale->text('Project Number') . "</th>";
682 map { print "$column_data{$_}\n" } @column_index;
688 $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
689 for $i (1 .. $form->{paidaccounts}) {
694 $form->{"selectAR_paid_$i"} = $form->{selectAR_paid};
695 $form->{"selectAR_paid_$i"} =~
696 s/option value=\"$form->{"AR_paid_$i"}\">/option value=\"$form->{"AR_paid_$i"}\" selected>/;
699 if ($form->{"paid_$i"}) {
701 $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2);
703 $form->{"exchangerate_$i"} =
704 $form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
706 $exchangerate = qq| |;
707 if ($form->{currency} ne $form->{defaultcurrency}) {
708 if ($form->{"forex_$i"}) {
710 qq|<input type=hidden name="exchangerate_$i" value=$form->{"exchangerate_$i"}>$form->{"exchangerate_$i"}|;
713 qq|<input name="exchangerate_$i" size=10 value=$form->{"exchangerate_$i"}>|;
718 <input type=hidden name="forex_$i" value=$form->{"forex_$i"}>
722 qq|<td align=center><input name="paid_$i" size=11 value=$form->{"paid_$i"}></td>|;
723 $column_data{AR_paid} =
724 qq|<td align=center><select name="AR_paid_$i">$form->{"selectAR_paid_$i"}</select></td>|;
725 $column_data{exchangerate} = qq|<td align=center>$exchangerate</td>|;
726 $column_data{datepaid} =
727 qq|<td align=center><input name="datepaid_$i" id="datepaid_$i" size=11 value=$form->{"datepaid_$i"}>
728 <input type="button" name="datepaid_$i" id="trigger_datepaid_$i" value="?"></td>|;
729 $column_data{source} =
730 qq|<td align=center><input name="source_$i" size=11 value="$form->{"source_$i"}"></td>|;
732 qq|<td align=center><input name="memo_$i" size=11 value="$form->{"memo_$i"}"></td>|;
734 $column_data{paid_project_id} =
736 . NTI($cgi->popup_menu('-name' => "paid_project_id_$i",
737 '-values' => \@project_values,
738 '-labels' => \%project_labels,
739 '-default' => $form->{"paid_project_id_$i"} ))
742 map { print qq|$column_data{$_}\n| } @column_index;
747 push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i");
749 map { $form->{$_} =~ s/\"/"/g } qw(selectAR_paid);
751 print $form->write_trigger(\%myconfig, scalar(@triggers) / 3, @triggers) .
753 <input type=hidden name=paidaccounts value=$form->{paidaccounts}>
754 <input type=hidden name=selectAR_paid value="$form->{selectAR_paid}">
760 <td><hr size=3 noshade></td>
765 $lxdebug->leave_sub();
769 $lxdebug->enter_sub();
773 <input name=gldate type=hidden value="| . Q($form->{gldate}) . qq|">
775 <input name=callback type=hidden value="$form->{callback}">
777 <input type=hidden name=path value=$form->{path}>
778 <input type=hidden name=login value=$form->{login}>
779 <input type=hidden name=password value=$form->{password}>
784 $transdate = $form->datetonum($form->{transdate}, \%myconfig);
785 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
787 print qq|<input class=submit type=submit name=action value="|
788 . $locale->text('Update') . qq|">
791 if ($form->{radier}) {
793 <input class=submit type=submit name=action value="|
794 . $locale->text('Post') . qq|">
795 <input class=submit type=submit name=action value="|
796 . $locale->text('Delete') . qq|">
799 if ($transdate > $closedto) {
801 <input class=submit type=submit name=action value="|
802 . $locale->text('Use As Template') . qq|">
806 <input class=submit type=submit name=action value="|
807 . $locale->text('Post Payment') . qq|">
811 if ($transdate > $closedto) {
812 print qq|<input class=submit type=submit name=action value="|
813 . $locale->text('Post') . qq|">|;
824 $lxdebug->leave_sub();
828 $lxdebug->enter_sub();
836 $form->{invtotal} = 0;
838 # $form->{selectAR_amount} = $form->{AR_amount};
839 # $form->{selectAR_amount} =~
840 # s/value=\"$form->{AR_amountselected}\"/value=\"$form->{AR_amountselected}\" selected/;
842 ($AR_amountaccno, $AR_amounttaxkey) =
843 split(/--/, $form->{AR_amountselected});
844 $form->{selecttaxchart} = $form->{taxchart};
845 $form->{selecttaxchart} =~
846 s/value=\"$AR_amounttaxkey--([^\"]*)\"/value=\"$AR_amounttaxkey--$1\" selected/;
850 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
851 qw(exchangerate creditlimit creditremaining);
853 @flds = qw(amount AR_amount projectnumber oldprojectnumber project_id);
857 for $i (1 .. $form->{rowcount}) {
858 $form->{"amount_$i"} =
859 $form->parse_amount(\%myconfig, $form->{"amount_$i"});
860 $form->{"tax_$i"} = $form->parse_amount(\%myconfig, $form->{"tax_$i"});
861 if ($form->{"amount_$i"}) {
864 if (!$form->{"korrektur_$i"}) {
865 ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
867 if ($form->{taxincluded}) {
868 $form->{"tax_$i"} = $form->{"amount_$i"} / ($rate + 1) * $rate;
870 $form->{"tax_$i"} = $form->{"amount_$i"} * $rate;
873 $form->{"tax_$i"} = 0;
876 $form->{"tax_$i"} = $form->round_amount($form->{"tax_$i"}, 2);
878 $totaltax += $form->{"tax_$i"};
879 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
884 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
885 $form->{rowcount} = $count + 1;
886 map { $form->{invtotal} += $form->{"amount_$_"} } (1 .. $form->{rowcount});
888 $form->{exchangerate} = $exchangerate
892 $form->check_exchangerate(
893 \%myconfig, $form->{currency}, $form->{transdate}, 'buy'
896 $form->{invdate} = $form->{transdate};
897 $save_AR = $form->{AR};
898 &check_name(customer);
899 $form->{AR} = $save_AR;
902 ($form->{taxincluded}) ? $form->{invtotal} : $form->{invtotal} + $totaltax;
904 for $i (1 .. $form->{paidaccounts}) {
905 if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
908 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
909 } qw(paid exchangerate);
911 $totalpaid += $form->{"paid_$i"};
913 $form->{"exchangerate_$i"} = $exchangerate
915 $form->{"forex_$i"} = (
917 $form->check_exchangerate(
918 \%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'buy'
923 $form->{creditremaining} -=
924 ($form->{invtotal} - $totalpaid + $form->{oldtotalpaid} -
925 $form->{oldinvtotal});
926 $form->{oldinvtotal} = $form->{invtotal};
927 $form->{oldtotalpaid} = $totalpaid;
931 $lxdebug->leave_sub();
935 $lxdebug->enter_sub();
936 for $i (1 .. $form->{paidaccounts}) {
937 if ($form->{"paid_$i"}) {
938 $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
940 $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
942 $form->error($locale->text('Cannot post payment for a closed period!'))
943 if ($datepaid <= $closedto);
945 if ($form->{currency} ne $form->{defaultcurrency}) {
946 $form->{"exchangerate_$i"} = $form->{exchangerate}
947 if ($invdate == $datepaid);
948 $form->isblank("exchangerate_$i",
949 $locale->text('Exchangerate for payment missing!'));
954 ($form->{AR}) = split /--/, $form->{AR};
955 ($form->{AR_paid}) = split /--/, $form->{AR_paid};
956 $form->redirect($locale->text(' Payment posted!'))
957 if (AR->post_payment(\%myconfig, \%$form));
958 $form->error($locale->text('Cannot post payment!'));
961 $lxdebug->leave_sub();
965 $lxdebug->enter_sub();
967 # check if there is an invoice number, invoice and due date
968 $form->isblank("transdate", $locale->text('Invoice Date missing!'));
969 $form->isblank("duedate", $locale->text('Due Date missing!'));
970 $form->isblank("customer", $locale->text('Customer missing!'));
972 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
973 $transdate = $form->datetonum($form->{transdate}, \%myconfig);
975 $form->error($locale->text('Cannot post transaction for a closed period!'))
976 if ($transdate <= $closedto);
978 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
979 if ($form->{currency} ne $form->{defaultcurrency});
983 for $i (1 .. $form->{paidaccounts}) {
984 if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
985 $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
987 $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
989 $form->error($locale->text('Cannot post payment for a closed period!'))
990 if ($datepaid <= $closedto);
992 if ($form->{currency} ne $form->{defaultcurrency}) {
993 $form->{"exchangerate_$i"} = $form->{exchangerate}
994 if ($transdate == $datepaid);
995 $form->isblank("exchangerate_$i",
996 $locale->text('Exchangerate for payment missing!'));
1001 # if oldcustomer ne customer redo form
1002 ($customer) = split /--/, $form->{customer};
1003 if ($form->{oldcustomer} ne "$customer--$form->{customer_id}") {
1008 ($creditaccno, $credittaxkey) = split /--/, $form->{AR_amountselected};
1009 ($taxkey, $NULL) = split /--/, $form->{taxchartselected};
1010 ($receivablesaccno, $payablestaxkey) = split /--/, $form->{ARselected};
1011 $form->{AR}{amount_1} = $creditaccno;
1012 $form->{AR}{receivables} = $receivablesaccno;
1013 $form->{taxkey} = $taxkey;
1015 $form->{invnumber} = $form->update_defaults(\%myconfig, "invnumber")
1016 unless $form->{invnumber};
1018 $form->{id} = 0 if $form->{postasnew};
1020 $form->redirect($locale->text('Transaction posted!'))
1021 if (AR->post_transaction(\%myconfig, \%$form));
1022 $form->error($locale->text('Cannot post transaction!'));
1024 $lxdebug->leave_sub();
1028 $lxdebug->enter_sub();
1030 $form->{postasnew} = 1;
1033 $lxdebug->leave_sub();
1036 sub use_as_template {
1037 $lxdebug->enter_sub();
1039 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);
1040 $form->{paidaccounts} = 1;
1041 $form->{rowcount}--;
1042 $form->{invdate} = $form->current_date(\%myconfig);
1045 $lxdebug->leave_sub();
1049 $lxdebug->enter_sub();
1051 $form->{title} = $locale->text('Confirm!');
1055 delete $form->{header};
1060 <form method=post action=$form->{script}>
1063 foreach $key (keys %$form) {
1064 $form->{$key} =~ s/\"/"/g;
1065 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
1069 <h2 class=confirm>$form->{title}</h2>
1072 . $locale->text('Are you sure you want to delete Transaction')
1073 . qq| $form->{invnumber}</h4>
1075 <input name=action class=submit type=submit value="|
1076 . $locale->text('Yes') . qq|">
1083 $lxdebug->leave_sub();
1087 $lxdebug->enter_sub();
1089 $form->redirect($locale->text('Transaction deleted!'))
1090 if (AR->delete_transaction(\%myconfig, \%$form, $spool));
1091 $form->error($locale->text('Cannot delete transaction!'));
1093 $lxdebug->leave_sub();
1097 $lxdebug->enter_sub();
1099 # setup customer selection
1100 $form->all_vc(\%myconfig, "customer", "AR");
1102 if (@{ $form->{all_customer} }) {
1103 map { $customer .= "<option>$_->{name}--$_->{id}\n" }
1104 @{ $form->{all_customer} };
1105 $customer = qq|<select name=customer><option>\n$customer</select>|;
1107 $customer = qq|<input name=customer size=35>|;
1111 if (@{ $form->{all_departments} }) {
1112 $form->{selectdepartment} = "<option>\n";
1115 $form->{selectdepartment} .=
1116 "<option>$_->{description}--$_->{id}\n"
1117 } (@{ $form->{all_departments} });
1122 <th align=right nowrap>| . $locale->text('Department') . qq|</th>
1123 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
1125 | if $form->{selectdepartment};
1127 $form->{title} = $locale->text('AR Transactions');
1129 # use JavaScript Calendar or not
1130 $form->{jsscript} = $jscalendar;
1132 if ($form->{jsscript}) {
1134 # with JavaScript Calendar
1136 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}">
1137 <input type=button name=transdatefrom id="trigger1" value=|
1138 . $locale->text('button') . qq|></td>
1141 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}">
1142 <input type=button name=transdateto name=transdateto id="trigger2" value=|
1143 . $locale->text('button') . qq|></td>
1148 Form->write_trigger(\%myconfig, "2", "transdatefrom", "BR", "trigger1",
1149 "transdateto", "BL", "trigger2");
1152 # without JavaScript Calendar
1154 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>|;
1156 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}"></td>|;
1159 $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
1164 foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
1165 push(@values, $item->{"id"});
1166 $labels{$item->{"id"}} = $item->{"projectnumber"};
1169 NTI($cgi->popup_menu('-name' => 'project_id', '-values' => \@values,
1170 '-labels' => \%labels));
1172 $form->{fokus} = "search.customer";
1176 <body onLoad="fokus()">
1178 <form method=post name="search" action=$form->{script}>
1181 <tr><th class=listtop>$form->{title}</th></tr>
1182 <tr height="5"></tr>
1187 <th align=right>| . $locale->text('Customer') . qq|</th>
1188 <td colspan=3>$customer</td>
1192 <th align=right nowrap>| . $locale->text('Invoice Number') . qq|</th>
1193 <td colspan=3><input name=invnumber size=20></td>
1196 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
1197 <td colspan=3><input name=ordnumber size=20></td>
1200 <th align=right nowrap>| . $locale->text('Notes') . qq|</th>
1201 <td colspan=3><input name=notes size=40></td>
1204 <th align="right">| . $locale->text("Project Number") . qq|</th>
1205 <td colspan="3">$projectnumber</td>
1208 <th align=right nowrap>| . $locale->text('From') . qq|</th>
1210 <th align=right>| . $locale->text('Bis') . qq|</th>
1213 <input type=hidden name=sort value=transdate>
1221 <th align=right nowrap>| . $locale->text('Include in Report') . qq|</th>
1225 <td align=right><input name=open class=checkbox type=checkbox value=Y checked></td>
1226 <td nowrap>| . $locale->text('Open') . qq|</td>
1227 <td align=right><input name=closed class=checkbox type=checkbox value=Y></td>
1228 <td nowrap>| . $locale->text('Closed') . qq|</td>
1231 <td align=right><input name="l_id" class=checkbox type=checkbox value=Y></td>
1232 <td nowrap>| . $locale->text('ID') . qq|</td>
1233 <td align=right><input name="l_invnumber" class=checkbox type=checkbox value=Y checked></td>
1234 <td nowrap>| . $locale->text('Invoice Number') . qq|</td>
1235 <td align=right><input name="l_ordnumber" class=checkbox type=checkbox value=Y></td>
1236 <td nowrap>| . $locale->text('Order Number') . qq|</td>
1237 <td align=right><input name="l_transdate" class=checkbox type=checkbox value=Y checked></td>
1238 <td nowrap>| . $locale->text('Invoice Date') . qq|</td>
1241 <td align=right><input name="l_name" class=checkbox type=checkbox value=Y checked></td>
1242 <td nowrap>| . $locale->text('Customer') . qq|</td>
1243 <td align=right><input name="l_netamount" class=checkbox type=checkbox value=Y></td>
1244 <td nowrap>| . $locale->text('Amount') . qq|</td>
1245 <td align=right><input name="l_tax" class=checkbox type=checkbox value=Y></td>
1246 <td nowrap>| . $locale->text('Tax') . qq|</td>
1247 <td align=right><input name="l_amount" class=checkbox type=checkbox value=Y checked></td>
1248 <td nowrap>| . $locale->text('Total') . qq|</td>
1251 <td align=right><input name="l_datepaid" class=checkbox type=checkbox value=Y></td>
1252 <td nowrap>| . $locale->text('Date Paid') . qq|</td>
1253 <td align=right><input name="l_paid" class=checkbox type=checkbox value=Y checked></td>
1254 <td nowrap>| . $locale->text('Paid') . qq|</td>
1255 <td align=right><input name="l_duedate" class=checkbox type=checkbox value=Y></td>
1256 <td nowrap>| . $locale->text('Due Date') . qq|</td>
1257 <td align=right><input name="l_due" class=checkbox type=checkbox value=Y></td>
1258 <td nowrap>| . $locale->text('Amount Due') . qq|</td>
1261 <td align=right><input name="l_notes" class=checkbox type=checkbox value=Y></td>
1262 <td nowrap>| . $locale->text('Notes') . qq|</td>
1263 <td align=right><input name="l_employee" class=checkbox type=checkbox value=Y></td>
1264 <td nowrap>| . $locale->text('Salesperson') . qq|</td>
1265 <td align=right><input name="l_shippingpoint" class=checkbox type=checkbox value=Y></td>
1266 <td nowrap>| . $locale->text('Shipping Point') . qq|</td>
1267 <td align=right><input name="l_shipvia" class=checkbox type=checkbox value=Y></td>
1268 <td nowrap>| . $locale->text('Ship via') . qq|</td>
1271 <td align=right><input name="l_subtotal" class=checkbox type=checkbox value=Y></td>
1272 <td nowrap>| . $locale->text('Subtotal') . qq|</td>
1273 <td align=right><input name="l_globalprojectnumber" class=checkbox type=checkbox value=Y></td>
1274 <td nowrap>| . $locale->text('Project Number') . qq|</td>
1283 <td><hr size=3 noshade></td>
1287 <input type=hidden name=nextsub value=$form->{nextsub}>
1289 <input type=hidden name=path value=$form->{path}>
1290 <input type=hidden name=login value=$form->{login}>
1291 <input type=hidden name=password value=$form->{password}>
1294 <input class=submit type=submit name=action value="|
1295 . $locale->text('Continue') . qq|">
1306 $lxdebug->leave_sub();
1309 sub ar_transactions {
1310 $lxdebug->enter_sub();
1312 $form->{customer} = $form->unescape($form->{customer});
1313 ($form->{customer}, $form->{customer_id}) = split(/--/, $form->{customer});
1315 AR->ar_transactions(\%myconfig, \%$form);
1318 "$form->{script}?action=ar_transactions&path=$form->{path}&login=$form->{login}&password=$form->{password}";
1321 if ($form->{customer}) {
1322 $callback .= "&customer=" . $form->escape($form->{customer}, 1);
1323 $href .= "&customer=" . $form->escape($form->{customer});
1324 $option = $locale->text('Customer') . " : $form->{customer}";
1326 if ($form->{department}) {
1327 $callback .= "&department=" . $form->escape($form->{department}, 1);
1328 $href .= "&department=" . $form->escape($form->{department});
1329 ($department) = split /--/, $form->{department};
1330 $option .= "\n<br>" if ($option);
1331 $option .= $locale->text('Department') . " : $department";
1333 if ($form->{invnumber}) {
1334 $callback .= "&invnumber=" . $form->escape($form->{invnumber}, 1);
1335 $href .= "&invnumber=" . $form->escape($form->{invnumber});
1336 $option .= "\n<br>" if ($option);
1337 $option .= $locale->text('Invoice Number') . " : $form->{invnumber}";
1339 if ($form->{ordnumber}) {
1340 $callback .= "&ordnumber=" . $form->escape($form->{ordnumber}, 1);
1341 $href .= "&ordnumber=" . $form->escape($form->{ordnumber});
1342 $option .= "\n<br>" if ($option);
1343 $option .= $locale->text('Order Number') . " : $form->{ordnumber}";
1345 if ($form->{notes}) {
1346 $callback .= "¬es=" . $form->escape($form->{notes}, 1);
1347 $href .= "¬es=" . $form->escape($form->{notes});
1348 $option .= "\n<br>" if $option;
1349 $option .= $locale->text('Notes') . " : $form->{notes}";
1352 if ($form->{transdatefrom}) {
1353 $callback .= "&transdatefrom=$form->{transdatefrom}";
1354 $href .= "&transdatefrom=$form->{transdatefrom}";
1355 $option .= "\n<br>" if ($option);
1357 $locale->text('From') . " "
1358 . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
1360 if ($form->{transdateto}) {
1361 $callback .= "&transdateto=$form->{transdateto}";
1362 $href .= "&transdateto=$form->{transdateto}";
1363 $option .= "\n<br>" if ($option);
1365 $locale->text('Bis') . " "
1366 . $locale->date(\%myconfig, $form->{transdateto}, 1);
1368 if ($form->{open}) {
1369 $callback .= "&open=$form->{open}";
1370 $href .= "&open=$form->{open}";
1371 $option .= "\n<br>" if ($option);
1372 $option .= $locale->text('Open');
1374 if ($form->{closed}) {
1375 $callback .= "&closed=$form->{closed}";
1376 $href .= "&closed=$form->{closed}";
1377 $option .= "\n<br>" if ($option);
1378 $option .= $locale->text('Closed');
1380 if ($form->{globalproject_id}) {
1381 $callback .= "&globalproject_id=" . E($form->{globalproject_id});
1382 $href .= "&globalproject_id=" . E($form->{globalproject_id});
1386 qw(transdate id type invnumber ordnumber name netamount tax amount paid
1387 datepaid due duedate notes employee shippingpoint shipvia
1388 globalprojectnumber);
1390 $form->{"l_type"} = "Y";
1392 foreach $item (@columns) {
1393 if ($form->{"l_$item"} eq "Y") {
1394 push @column_index, $item;
1396 # add column to href and callback
1397 $callback .= "&l_$item=Y";
1398 $href .= "&l_$item=Y";
1402 if ($form->{l_subtotal} eq 'Y') {
1403 $callback .= "&l_subtotal=Y";
1404 $href .= "&l_subtotal=Y";
1407 $column_header{id} =
1408 "<th><a class=listheading href=$href&sort=id>"
1409 . $locale->text('ID')
1411 $column_header{transdate} =
1412 "<th><a class=listheading href=$href&sort=transdate>"
1413 . $locale->text('Date')
1415 $column_header{duedate} =
1416 "<th><a class=listheading href=$href&sort=duedate>"
1417 . $locale->text('Due Date')
1419 $column_header{type} =
1420 "<th class=\"listheading\">" . $locale->text('Type') . "</th>";
1421 $column_header{invnumber} =
1422 "<th><a class=listheading href=$href&sort=invnumber>"
1423 . $locale->text('Invoice')
1425 $column_header{ordnumber} =
1426 "<th><a class=listheading href=$href&sort=ordnumber>"
1427 . $locale->text('Order')
1429 $column_header{name} =
1430 "<th><a class=listheading href=$href&sort=name>"
1431 . $locale->text('Customer')
1433 $column_header{netamount} =
1434 "<th class=listheading>" . $locale->text('Amount') . "</th>";
1435 $column_header{tax} =
1436 "<th class=listheading>" . $locale->text('Tax') . "</th>";
1437 $column_header{amount} =
1438 "<th class=listheading>" . $locale->text('Total') . "</th>";
1439 $column_header{paid} =
1440 "<th class=listheading>" . $locale->text('Paid') . "</th>";
1441 $column_header{datepaid} =
1442 "<th><a class=listheading href=$href&sort=datepaid>"
1443 . $locale->text('Date Paid')
1445 $column_header{due} =
1446 "<th class=listheading>" . $locale->text('Amount Due') . "</th>";
1447 $column_header{notes} =
1448 "<th class=listheading>" . $locale->text('Notes') . "</th>";
1449 $column_header{employee} =
1450 "<th><a class=listheading href=$href&sort=employee>"
1451 . $locale->text('Salesperson') . "</th>";
1453 $column_header{shippingpoint} =
1454 "<th><a class=listheading href=$href&sort=shippingpoint>"
1455 . $locale->text('Shipping Point')
1457 $column_header{shipvia} =
1458 "<th><a class=listheading href=$href&sort=shipvia>"
1459 . $locale->text('Ship via')
1461 $column_header{globalprojectnumber} =
1462 qq|<th class="listheading">| . $locale->text('Project Number') . qq|</th>|;
1464 $form->{title} = $locale->text('AR Transactions');
1473 <th class=listtop>$form->{title}</th>
1475 <tr height="5"></tr>
1482 <tr class=listheading>
1485 map { print "\n$column_header{$_}" } @column_index;
1491 # add sort and escape callback, this one we use for the add sub
1492 $form->{callback} = $callback .= "&sort=$form->{sort}";
1494 # escape callback for href
1495 $callback = $form->escape($callback);
1497 if (@{ $form->{AR} }) {
1498 $sameitem = $form->{AR}->[0]->{ $form->{sort} };
1501 # sums and tax on reports by Antonio Gallardo
1503 foreach $ar (@{ $form->{AR} }) {
1505 if ($form->{l_subtotal} eq 'Y') {
1506 if ($sameitem ne $ar->{ $form->{sort} }) {
1511 $column_data{netamount} =
1513 . $form->format_amount(\%myconfig, $ar->{netamount}, 2, " ")
1515 $column_data{tax} = "<td align=right>"
1516 . $form->format_amount(\%myconfig, $ar->{amount} - $ar->{netamount},
1519 $column_data{amount} =
1521 . $form->format_amount(\%myconfig, $ar->{amount}, 2, " ") . "</td>";
1522 $column_data{paid} =
1524 . $form->format_amount(\%myconfig, $ar->{paid}, 2, " ") . "</td>";
1525 $column_data{due} = "<td align=right>"
1526 . $form->format_amount(\%myconfig, $ar->{amount} - $ar->{paid},
1530 $subtotalnetamount += $ar->{netamount};
1531 $subtotalamount += $ar->{amount};
1532 $subtotalpaid += $ar->{paid};
1533 $subtotaldue += $ar->{amount} - $ar->{paid};
1535 $totalnetamount += $ar->{netamount};
1536 $totalamount += $ar->{amount};
1537 $totalpaid += $ar->{paid};
1538 $totaldue += ($ar->{amount} - $ar->{paid});
1540 $column_data{transdate} = "<td>$ar->{transdate} </td>";
1541 $column_data{id} = "<td>$ar->{id}</td>";
1542 $column_data{datepaid} = "<td>$ar->{datepaid} </td>";
1543 $column_data{duedate} = "<td>$ar->{duedate} </td>";
1545 $module = ($ar->{invoice}) ? "is.pl" : $form->{script};
1547 $column_data{invnumber} =
1548 "<td><a href=$module?action=edit&id=$ar->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ar->{invnumber}</a></td>";
1549 $column_data{type} = "<td>" .
1550 ($ar->{storno} ? $locale->text("Storno (one letter abbreviation)") :
1552 $locale->text("Credit note (one letter abbreviation)") :
1553 $locale->text("Invoice (one letter abbreviation)")) . "</td>";
1554 $column_data{ordnumber} = "<td>$ar->{ordnumber} </td>";
1555 $column_data{name} = "<td>$ar->{name}</td>";
1556 $ar->{notes} =~ s/\r\n/<br>/g;
1557 $column_data{notes} = "<td>$ar->{notes} </td>";
1558 $column_data{shippingpoint} = "<td>$ar->{shippingpoint} </td>";
1559 $column_data{shipvia} = "<td>$ar->{shipvia} </td>";
1560 $column_data{employee} = "<td>$ar->{employee} </td>";
1561 $column_data{globalprojectnumber} =
1562 "<td>" . H($ar->{globalprojectnumber}) . "</td>";
1567 <tr class=listrow$i>
1570 map { print "\n$column_data{$_}" } @column_index;
1578 if ($form->{l_subtotal} eq 'Y') {
1584 <tr class=listtotal>
1587 map { $column_data{$_} = "<td> </td>" } @column_index;
1589 $column_data{netamount} =
1590 "<th class=listtotal align=right>"
1591 . $form->format_amount(\%myconfig, $totalnetamount, 2, " ") . "</th>";
1592 $column_data{tax} = "<th class=listtotal align=right>"
1593 . $form->format_amount(\%myconfig, $totalamount - $totalnetamount,
1596 $column_data{amount} =
1597 "<th class=listtotal align=right>"
1598 . $form->format_amount(\%myconfig, $totalamount, 2, " ") . "</th>";
1599 $column_data{paid} =
1600 "<th class=listtotal align=right>"
1601 . $form->format_amount(\%myconfig, $totalpaid, 2, " ") . "</th>";
1603 "<th class=listtotal align=right>"
1604 . $form->format_amount(\%myconfig, $totaldue, 2, " ") . "</th>";
1606 map { print "\n$column_data{$_}" } @column_index;
1614 <td><hr size=3 noshade></td>
1619 <form method=post action=$form->{script}>
1621 <input name=callback type=hidden value="$form->{callback}">
1623 <input type=hidden name=path value=$form->{path}>
1624 <input type=hidden name=login value=$form->{login}>
1625 <input type=hidden name=password value=$form->{password}>
1627 <input class=submit type=submit name=action value="|
1628 . $locale->text('AR Transaction') . qq|">
1629 <input class=submit type=submit name=action value="|
1630 . $locale->text('Sales Invoice') . qq|">
1638 $lxdebug->leave_sub();
1642 $lxdebug->enter_sub();
1644 map { $column_data{$_} = "<td> </td>" } @column_index;
1646 $column_data{tax} = "<th class=listsubtotal align=right>"
1647 . $form->format_amount(\%myconfig, $subtotalamount - $subtotalnetamount,
1650 $column_data{amount} =
1651 "<th class=listsubtotal align=right>"
1652 . $form->format_amount(\%myconfig, $subtotalamount, 2, " ") . "</th>";
1653 $column_data{paid} =
1654 "<th class=listsubtotal align=right>"
1655 . $form->format_amount(\%myconfig, $subtotalpaid, 2, " ") . "</th>";
1657 "<th class=listsubtotal align=right>"
1658 . $form->format_amount(\%myconfig, $subtotaldue, 2, " ") . "</th>";
1660 $subtotalnetamount = 0;
1661 $subtotalamount = 0;
1665 $sameitem = $ar->{ $form->{sort} };
1667 print "<tr class=listsubtotal>";
1669 map { print "\n$column_data{$_}" } @column_index;
1675 $lxdebug->leave_sub();