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";
176 qq|<option value=\"$_->{id}--$_->{rate}\">$_->{taxdescription} |
177 . ($_->{rate} * 100) . qq| %|
179 $form->{taxchart} = $tax;
180 $form->{selecttaxchart} = $tax;
183 $form->{forex} = $form->{exchangerate};
184 $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
185 foreach $key (keys %{ $form->{AR_links} }) {
187 foreach $ref (@{ $form->{AR_links}{$key} }) {
188 if ($key eq "AR_paid") {
189 $form->{"select$key"} .=
190 "<option value=\"$ref->{accno}\">$ref->{accno}--$ref->{description}</option>\n";
192 $form->{"select$key"} .=
193 "<option value=\"$ref->{accno}--$ref->{tax_id}\">$ref->{accno}--$ref->{description}</option>\n";
197 $form->{$key} = $form->{"select$key"};
199 # if there is a value we have an old entry
203 for $i (1 .. scalar @{ $form->{acc_trans}{$key} }) {
204 if ($key eq "AR_paid") {
206 $form->{"AR_paid_$j"} =
207 "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
210 $form->{"paid_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{amount} * -1;
211 $form->{"datepaid_$j"} =
212 $form->{acc_trans}{$key}->[$i - 1]->{transdate};
213 $form->{"source_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{source};
214 $form->{"memo_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{memo};
216 $form->{"forex_$j"} = $form->{"exchangerate_$i"} =
217 $form->{acc_trans}{$key}->[$i - 1]->{exchangerate};
218 $form->{"AR_paid_$j"} = "$form->{acc_trans}{$key}->[$i-1]->{accno}";
219 $form->{"paid_project_id_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{project_id};
220 $form->{paidaccounts}++;
226 if ($key eq "AR_tax" || $key eq "AP_tax") {
227 $form->{"${key}_$form->{acc_trans}{$key}->[$i-1]->{accno}"} =
228 "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
229 $form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"} =
231 $form->{acc_trans}{$key}->[$i - 1]->{amount} / $exchangerate,
234 if ($form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"} > 0) {
236 $form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"};
238 $form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"};
241 $form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"};
243 $form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"};
245 $index = $form->{acc_trans}{$key}->[$i - 1]->{index};
246 $form->{"tax_$index"} = $form->{acc_trans}{$key}->[$i - 1]->{amount};
247 $totaltax += $form->{"tax_$index"};
251 $form->{"${akey}_$k"} =
253 $form->{acc_trans}{$key}->[$i - 1]->{amount} / $exchangerate,
255 if ($akey eq 'amount') {
257 $totalamount += $form->{"${akey}_$i"};
259 $form->{"oldprojectnumber_$k"} = $form->{"projectnumber_$k"} =
260 "$form->{acc_trans}{$key}->[$i-1]->{projectnumber}";
261 $form->{taxrate} = $form->{acc_trans}{$key}->[$i - 1]->{rate};
262 $form->{"project_id_$k"} =
263 "$form->{acc_trans}{$key}->[$i-1]->{project_id}";
265 $form->{"${key}_$k"} =
266 "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
267 $form->{"${key}_$i"} =
268 "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
269 my $q_description = quotemeta($form->{acc_trans}{$key}->[$i-1]->{description});
270 $form->{"select${key}"} =~
271 /<option value=\"($form->{acc_trans}{$key}->[$i-1]->{accno}--[^\"]*)\">$form->{acc_trans}{$key}->[$i-1]->{accno}--${q_description}<\/option>\n/;
272 $form->{"${key}_$k"} = $1;
273 if ($akey eq 'amount') {
274 $form->{"taxchart_$k"} = $form->{taxchart};
275 $form->{"taxchart_$k"} =~
276 /<option value=\"($form->{acc_trans}{$key}->[$i-1]->{id}--[^\"]*)/;
277 $form->{"taxchart_$k"} = $1;
284 $form->{taxincluded} = $taxincluded if ($form->{id});
285 $form->{paidaccounts} = 1 if not defined $form->{paidaccounts};
287 if ($form->{taxincluded} && $form->{taxrate} && $totalamount) {
289 # add tax to amounts and invtotal
290 for $i (1 .. $form->{rowcount}) {
292 ($totaltax + $totalwithholding) * $form->{"amount_$i"} / $totalamount;
293 $tax = $form->round_amount($taxamount, 2);
294 $diff += ($taxamount - $tax);
295 $form->{"amount_$i"} += $form->{"tax_$i"};
297 $form->{amount_1} += $form->round_amount($diff, 2);
300 $taxamount = $form->round_amount($taxamount, 2);
301 $form->{tax} = $taxamount;
303 $form->{invtotal} = $totalamount + $totaltax;
306 ($form->datetonum($form->{transdate}, \%myconfig) <=
307 $form->datetonum($form->{closedto}, \%myconfig));
309 $form->{"ARselected"} = $form->{"AR_1"};
311 $lxdebug->leave_sub();
315 $lxdebug->enter_sub();
317 $title = $form->{title};
318 $form->{title} = $locale->text("$title Accounts Receivables Transaction");
320 $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
322 # $locale->text('Add Accounts Receivables Transaction')
323 # $locale->text('Edit Accounts Receivables Transaction')
324 $form->{javascript} = qq|<script type="text/javascript">
326 function setTaxkey(accno, row) {
327 var taxkey = accno.options[accno.selectedIndex].value;
328 var reg = /--([0-9]*)/;
329 var found = reg.exec(taxkey);
330 var index = found[1];
331 index = parseInt(index);
332 var tax = 'taxchart_' + row;
333 for (var i = 0; i < document.getElementById(tax).options.length; ++i) {
334 var reg2 = new RegExp("^"+ index, "");
335 if (reg2.exec(document.getElementById(tax).options[i].value)) {
336 document.getElementById(tax).options[i].selected = true;
343 # show history button js
344 $form->{javascript} .= qq|<script type="text/javascript" src="js/show_history.js"></script>|;
345 #/show history button js
347 $readonly = ($form->{id}) ? "readonly" : "";
350 ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0;
351 $readonly = ($form->{radier}) ? "" : $readonly;
353 my $ARselected_quoted = quotemeta($form->{"ARselected"});
354 $form->{selectAR} = $form->{AR};
356 s/value=\"${ARselected_quoted}\"/value=\"$form->{ARselected}\" selected/;
358 # set option selected
359 foreach $item (qw(customer currency department employee)) {
360 $form->{"select$item"} =~ s/ selected//;
361 $form->{"select$item"} =~
362 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
364 $selectAR_amount_unquoted = $form->{selectAR_amount};
365 $taxchart = $form->{taxchart};
366 map { $form->{$_} =~ s/\"/"/g }
367 qw(AR_amount selectAR_amount AR taxchart);
370 $form->{exchangerate} =
371 $form->format_amount(\%myconfig, $form->{exchangerate});
373 $form->{creditlimit} =
374 $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
375 $form->{creditremaining} =
376 $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
379 <input type=hidden name=forex value=$form->{forex}>
381 if ($form->{currency} ne $form->{defaultcurrency}) {
382 if ($form->{forex}) {
384 <th align=right>| . $locale->text('Exchangerate') . qq|</th>
385 <td><input type=hidden name=exchangerate value=$form->{exchangerate}>$form->{exchangerate}</td>
389 <th align=right>| . $locale->text('Exchangerate') . qq|</th>
390 <td><input name=exchangerate size=10 value=$form->{exchangerate}></td>
399 <td align=right><input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}></td>
400 <th align=left nowrap>| . $locale->text('Tax Included') . qq|</th>
404 if (($rows = $form->numtextrows($form->{notes}, 50)) < 2) {
408 qq|<textarea name=notes rows=$rows cols=50 wrap=soft>$form->{notes}</textarea>|;
412 <th align="right" nowrap>| . $locale->text('Department') . qq|</th>
413 <td colspan=3><select name=department>$form->{selectdepartment}</select>
414 <input type=hidden name=selectdepartment value="$form->{selectdepartment}">
417 | if $form->{selectdepartment};
419 $n = ($form->{creditremaining} =~ /-/) ? "0" : "1";
422 ($form->{selectcustomer})
423 ? qq|<select name=customer>$form->{selectcustomer}</select>|
424 : qq|<input name=customer value="$form->{customer}" size=35>|;
427 <input type=hidden name=employee value="$form->{employee}">
430 if ($form->{selectemployee}) {
433 <th align=right nowrap>| . $locale->text('Salesperson') . qq|</th>
434 <td colspan=2><select name=employee>$form->{selectemployee}</select></td>
435 <input type=hidden name=selectemployee value="$form->{selectemployee}">
440 my @old_project_ids = ();
441 map({ push(@old_project_ids, $form->{"project_id_$_"})
442 if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
444 $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
446 "old_id" => \@old_project_ids });
448 my %project_labels = ();
449 my @project_values = ("");
450 foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
451 push(@project_values, $item->{"id"});
452 $project_labels{$item->{"id"}} = $item->{"projectnumber"};
455 $form->{fokus} = "arledger.customer";
457 # use JavaScript Calendar or not
458 $form->{jsscript} = $jscalendar;
460 if ($form->{jsscript}) {
462 # with JavaScript Calendar
464 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>
465 <td><input type=button name=transdate id="trigger1" value=|
466 . $locale->text('button') . qq|></td>
469 <td><input name=duedate id=duedate size=11 title="$myconfig{dateformat}" value=$form->{duedate}></td>
470 <td><input type=button name=duedate id="trigger2" value=|
471 . $locale->text('button') . qq|></td></td>
476 Form->write_trigger(\%myconfig, "2", "transdate", "BL", "trigger1",
477 "duedate", "BL", "trigger2");
480 # without JavaScript Calendar
482 qq|<td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>|;
484 qq|<td><input name=duedate id=duedate size=11 title="$myconfig{dateformat}" value=$form->{duedate}></td>|;
490 <body onLoad="fokus()">
492 <form method=post name="arledger" action=$form->{script}>
494 <input type=hidden name=id value=$form->{id}>
495 <input type=hidden name=sort value=$form->{sort}>
496 <input type=hidden name=closedto value=$form->{closedto}>
497 <input type=hidden name=locked value=$form->{locked}>
498 <input type=hidden name=title value="$title">
500 | . ($form->{saved_message} ? qq|<p>$form->{saved_message}</p>| : "") . qq|
504 <th class=listtop>$form->{title}</th>
514 <th align="right" nowrap>| . $locale->text('Customer') . qq|</th>
515 <td colspan=3>$customer</td>
516 <input type=hidden name=selectcustomer value="$form->{selectcustomer}">
517 <input type=hidden name=oldcustomer value="$form->{oldcustomer}">
518 <input type=hidden name=customer_id value="$form->{customer_id}">
519 <input type=hidden name=terms value=$form->{terms}>
526 <th align=left nowrap>| . $locale->text('Credit Limit') . qq|</th>
527 <td>$form->{creditlimit}</td>
528 <th align=left nowrap>| . $locale->text('Remaining') . qq|</th>
529 <td class="plus$n">$form->{creditremaining}</td>
530 <input type=hidden name=creditlimit value=$form->{creditlimit}>
531 <input type=hidden name=creditremaining value=$form->{creditremaining}>
537 <th align=right>| . $locale->text('Currency') . qq|</th>
538 <td><select name=currency>$form->{selectcurrency}</select></td>
539 <input type=hidden name=selectcurrency value="$form->{selectcurrency}">
540 <input type=hidden name=defaultcurrency value=$form->{defaultcurrency}>
541 <input type=hidden name=fxgain_accno value=$form->{fxgain_accno}>
542 <input type=hidden name=fxloss_accno value=$form->{fxloss_accno}>
553 <th align=right nowrap>| . $locale->text('Invoice Number') . qq|</th>
554 <td><input name=invnumber size=11 value="$form->{invnumber}"></td>
557 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
558 <td><input name=ordnumber size=11 value="$form->{ordnumber}"></td>
561 <th align=right nowrap>| . $locale->text('Invoice Date') . qq|</th>
565 <th align=right nowrap>| . $locale->text('Due Date') . qq|</th>
576 <input type=hidden name=selectAR_amount value="$form->{selectAR_amount}">
577 <input type=hidden name=AR_amount value="$form->{AR_amount}">
578 <input type=hidden name=taxchart value="$form->{taxchart}">
579 <input type=hidden name=rowcount value=$form->{rowcount}>
583 <tr class=listheading>
584 <th class=listheading style="width:15%">|
585 . $locale->text('Account') . qq|</th>
586 <th class=listheading style="width:10%">|
587 . $locale->text('Amount') . qq|</th>
588 <th class=listheading style="width:10%">|
589 . $locale->text('Tax') . qq|</th>
590 <th class=listheading style="width:5%">|
591 . $locale->text('Korrektur') . qq|</th>
592 <th class=listheading style="width:10%">|
593 . $locale->text('Taxkey') . qq|</th>
594 <th class=listheading style="width:10%">|
595 . $locale->text('Project') . qq|</th>
599 $amount = $locale->text('Amount');
600 $project = $locale->text('Project');
602 for $i (1 .. $form->{rowcount}) {
605 $form->{"amount_$i"} =
606 $form->format_amount(\%myconfig, $form->{"amount_$i"}, 2);
607 $form->{"tax_$i"} = $form->format_amount(\%myconfig, $form->{"tax_$i"}, 2);
608 $selectAR_amount = $selectAR_amount_unquoted;
610 s/option value=\"$form->{"AR_amount_$i"}\"/option value=\"$form->{"AR_amount_$i"}\" selected/;
612 $tax_selected = $form->{"taxchart_$i"};
613 $tax =~ s/value=\"$tax_selected\"/value=\"$tax_selected\" selected/;
615 qq|<td><select id="taxchart_$i" name="taxchart_$i" style="width:200px">$tax</select></td>|;
616 $korrektur_checked = ($form->{"korrektur_$i"} ? 'checked' : '');
619 NTI($cgi->popup_menu('-name' => "project_id_$i",
620 '-values' => \@project_values,
621 '-labels' => \%project_labels,
622 '-default' => $form->{"project_id_$i"} ));
626 <td width=50%><select name="AR_amount_$i" onChange="setTaxkey(this, $i)" style="width:100%">$selectAR_amount</select></td>
627 <td><input name="amount_$i" size=10 value=$form->{"amount_$i"}></td>
628 <td><input name="tax_$i" size=10 value=$form->{"tax_$i"}></td>
629 <td><input type="checkbox" name="korrektur_$i" value="1" $korrektur_checked></td>
631 <td>$projectnumber</td>
638 $form->{invtotal} = $form->format_amount(\%myconfig, $form->{invtotal}, 2);
647 <td><select name=ARselected>$form->{selectAR}</select></td>
648 <input type=hidden name=AR value="$form->{AR}">
649 <th align=left>$form->{invtotal}</th>
651 <input type=hidden name=oldinvtotal value=$form->{oldinvtotal}>
652 <input type=hidden name=oldtotalpaid value=$form->{oldtotalpaid}>
654 <input type=hidden name=taxaccounts value="$form->{taxaccounts}">
667 <th align=left width=1%>| . $locale->text('Notes') . qq|</th>
668 <td align=left>$notes</td>
676 <tr class=listheading>
677 <th colspan=7 class=listheading>|
678 . $locale->text('Incoming Payments') . qq|</th>
682 if ($form->{currency} eq $form->{defaultcurrency}) {
683 @column_index = qw(datepaid source memo paid AR_paid paid_project_id);
685 @column_index = qw(datepaid source memo paid exchangerate AR_paid paid_project_id);
688 $column_data{datepaid} = "<th>" . $locale->text('Date') . "</th>";
689 $column_data{paid} = "<th>" . $locale->text('Amount') . "</th>";
690 $column_data{exchangerate} = "<th>" . $locale->text('Exch') . "</th>";
691 $column_data{AR_paid} = "<th>" . $locale->text('Account') . "</th>";
692 $column_data{source} = "<th>" . $locale->text('Source') . "</th>";
693 $column_data{memo} = "<th>" . $locale->text('Memo') . "</th>";
694 $column_data{paid_project_id} = "<th>" . $locale->text('Project Number') . "</th>";
699 map { print "$column_data{$_}\n" } @column_index;
705 $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
706 for $i (1 .. $form->{paidaccounts}) {
711 $form->{"selectAR_paid_$i"} = $form->{selectAR_paid};
712 $form->{"selectAR_paid_$i"} =~
713 s/option value=\"$form->{"AR_paid_$i"}\">/option value=\"$form->{"AR_paid_$i"}\" selected>/;
716 if ($form->{"paid_$i"}) {
718 $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2);
720 $form->{"exchangerate_$i"} =
721 $form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
723 $exchangerate = qq| |;
724 if ($form->{currency} ne $form->{defaultcurrency}) {
725 if ($form->{"forex_$i"}) {
727 qq|<input type=hidden name="exchangerate_$i" value=$form->{"exchangerate_$i"}>$form->{"exchangerate_$i"}|;
730 qq|<input name="exchangerate_$i" size=10 value=$form->{"exchangerate_$i"}>|;
735 <input type=hidden name="forex_$i" value=$form->{"forex_$i"}>
739 qq|<td align=center><input name="paid_$i" size=11 value=$form->{"paid_$i"}></td>|;
740 $column_data{AR_paid} =
741 qq|<td align=center><select name="AR_paid_$i">$form->{"selectAR_paid_$i"}</select></td>|;
742 $column_data{exchangerate} = qq|<td align=center>$exchangerate</td>|;
743 $column_data{datepaid} =
744 qq|<td align=center><input name="datepaid_$i" id="datepaid_$i" size=11 value=$form->{"datepaid_$i"}>
745 <input type="button" name="datepaid_$i" id="trigger_datepaid_$i" value="?"></td>|;
746 $column_data{source} =
747 qq|<td align=center><input name="source_$i" size=11 value="$form->{"source_$i"}"></td>|;
749 qq|<td align=center><input name="memo_$i" size=11 value="$form->{"memo_$i"}"></td>|;
751 $column_data{paid_project_id} =
753 . NTI($cgi->popup_menu('-name' => "paid_project_id_$i",
754 '-values' => \@project_values,
755 '-labels' => \%project_labels,
756 '-default' => $form->{"paid_project_id_$i"} ))
759 map { print qq|$column_data{$_}\n| } @column_index;
764 push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i");
766 map { $form->{$_} =~ s/\"/"/g } qw(selectAR_paid);
768 print $form->write_trigger(\%myconfig, scalar(@triggers) / 3, @triggers) .
770 <input type=hidden name=paidaccounts value=$form->{paidaccounts}>
771 <input type=hidden name=selectAR_paid value="$form->{selectAR_paid}">
777 <td><hr size=3 noshade></td>
782 $lxdebug->leave_sub();
786 $lxdebug->enter_sub();
790 <input name=gldate type=hidden value="| . Q($form->{gldate}) . qq|">
792 <input name=callback type=hidden value="$form->{callback}">
794 <input type=hidden name=path value=$form->{path}>
795 <input type=hidden name=login value=$form->{login}>
796 <input type=hidden name=password value=$form->{password}>
798 . $cgi->hidden('-name' => 'draft_id', '-default' => [$form->{draft_id}])
799 . $cgi->hidden('-name' => 'draft_description', '-default' => [$form->{draft_description}])
805 $transdate = $form->datetonum($form->{transdate}, \%myconfig);
806 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
808 print qq|<input class=submit type=submit name=action value="|
809 . $locale->text('Update') . qq|">
812 if ($form->{radier}) {
814 <input class=submit type=submit name=action value="|
815 . $locale->text('Post') . qq|">
816 <input class=submit type=submit name=action value="|
817 . $locale->text('Delete') . qq|">
820 if ($transdate > $closedto) {
822 <input class=submit type=submit name=action value="|
823 . $locale->text('Use As Template') . qq|">
827 <input class=submit type=submit name=action value="|
828 . $locale->text('Post Payment') . qq|">
832 if ($transdate > $closedto) {
833 print qq|<input class=submit type=submit name=action value="|
834 . $locale->text('Post') . qq|"> | .
835 NTI($cgi->submit('-name' => 'action', '-value' => $locale->text('Save draft'),
836 '-class' => 'submit'));
840 if ($form->{menubar}) {
841 require "$form->{path}/menu.pl";
844 # button for saving history
845 if($form->{id} ne "") {
847 <input type=button class=submit onclick=set_history_window(|
849 . qq|); name=history id=history value=|
850 . $locale->text('history')
853 # /button for saving history
861 $lxdebug->leave_sub();
865 $lxdebug->enter_sub();
873 $form->{invtotal} = 0;
875 # $form->{selectAR_amount} = $form->{AR_amount};
876 # $form->{selectAR_amount} =~
877 # s/value=\"$form->{AR_amountselected}\"/value=\"$form->{AR_amountselected}\" selected/;
879 ($AR_amountaccno, $AR_amounttaxkey) =
880 split(/--/, $form->{AR_amountselected});
881 $form->{selecttaxchart} = $form->{taxchart};
882 $form->{selecttaxchart} =~
883 s/value=\"$AR_amounttaxkey--([^\"]*)\"/value=\"$AR_amounttaxkey--$1\" selected/;
887 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
888 qw(exchangerate creditlimit creditremaining);
890 @flds = qw(amount AR_amount projectnumber oldprojectnumber project_id);
894 for $i (1 .. $form->{rowcount}) {
895 $form->{"amount_$i"} =
896 $form->parse_amount(\%myconfig, $form->{"amount_$i"});
897 $form->{"tax_$i"} = $form->parse_amount(\%myconfig, $form->{"tax_$i"});
898 if ($form->{"amount_$i"}) {
901 if (!$form->{"korrektur_$i"}) {
902 ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
904 if ($form->{taxincluded}) {
905 $form->{"tax_$i"} = $form->{"amount_$i"} / ($rate + 1) * $rate;
907 $form->{"tax_$i"} = $form->{"amount_$i"} * $rate;
910 $form->{"tax_$i"} = 0;
913 $form->{"tax_$i"} = $form->round_amount($form->{"tax_$i"}, 2);
915 $totaltax += $form->{"tax_$i"};
916 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
921 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
922 $form->{rowcount} = $count + 1;
923 map { $form->{invtotal} += $form->{"amount_$_"} } (1 .. $form->{rowcount});
925 $form->{exchangerate} = $exchangerate
929 $form->check_exchangerate(
930 \%myconfig, $form->{currency}, $form->{transdate}, 'buy'
933 $form->{invdate} = $form->{transdate};
934 $save_AR = $form->{AR};
935 &check_name(customer);
936 $form->{AR} = $save_AR;
939 ($form->{taxincluded}) ? $form->{invtotal} : $form->{invtotal} + $totaltax;
941 for $i (1 .. $form->{paidaccounts}) {
942 if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
945 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
946 } qw(paid exchangerate);
948 $totalpaid += $form->{"paid_$i"};
950 $form->{"exchangerate_$i"} = $exchangerate
952 $form->{"forex_$i"} = (
954 $form->check_exchangerate(
955 \%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'buy'
960 $form->{creditremaining} -=
961 ($form->{invtotal} - $totalpaid + $form->{oldtotalpaid} -
962 $form->{oldinvtotal});
963 $form->{oldinvtotal} = $form->{invtotal};
964 $form->{oldtotalpaid} = $totalpaid;
968 $lxdebug->leave_sub();
972 $lxdebug->enter_sub();
973 for $i (1 .. $form->{paidaccounts}) {
974 if ($form->{"paid_$i"}) {
975 $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
977 $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
979 $form->error($locale->text('Cannot post payment for a closed period!'))
980 if ($datepaid <= $closedto);
982 if ($form->{currency} ne $form->{defaultcurrency}) {
983 $form->{"exchangerate_$i"} = $form->{exchangerate}
984 if ($invdate == $datepaid);
985 $form->isblank("exchangerate_$i",
986 $locale->text('Exchangerate for payment missing!'));
991 ($form->{AR}) = split /--/, $form->{AR};
992 ($form->{AR_paid}) = split /--/, $form->{AR_paid};
993 $form->redirect($locale->text(' Payment posted!'))
994 if (AR->post_payment(\%myconfig, \%$form));
995 $form->error($locale->text('Cannot post payment!'));
998 $lxdebug->leave_sub();
1002 $lxdebug->enter_sub();
1004 # check if there is an invoice number, invoice and due date
1005 $form->isblank("transdate", $locale->text('Invoice Date missing!'));
1006 $form->isblank("duedate", $locale->text('Due Date missing!'));
1007 $form->isblank("customer", $locale->text('Customer missing!'));
1009 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
1010 $transdate = $form->datetonum($form->{transdate}, \%myconfig);
1012 $form->error($locale->text('Cannot post transaction for a closed period!'))
1013 if ($transdate <= $closedto);
1015 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
1016 if ($form->{currency} ne $form->{defaultcurrency});
1018 delete($form->{AR});
1020 for $i (1 .. $form->{paidaccounts}) {
1021 if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
1022 $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
1024 $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
1026 $form->error($locale->text('Cannot post payment for a closed period!'))
1027 if ($datepaid <= $closedto);
1029 if ($form->{currency} ne $form->{defaultcurrency}) {
1030 $form->{"exchangerate_$i"} = $form->{exchangerate}
1031 if ($transdate == $datepaid);
1032 $form->isblank("exchangerate_$i",
1033 $locale->text('Exchangerate for payment missing!'));
1038 # if oldcustomer ne customer redo form
1039 ($customer) = split /--/, $form->{customer};
1040 if ($form->{oldcustomer} ne "$customer--$form->{customer_id}") {
1045 my ($creditaccno, $credittaxkey) = split /--/, $form->{AR_amountselected};
1046 my ($taxkey, $NULL) = split /--/, $form->{taxchartselected};
1047 my ($receivablesaccno, $payablestaxkey) = split /--/, $form->{ARselected};
1048 $form->{AR}{amount_1} = $creditaccno;
1049 $form->{AR}{receivables} = $receivablesaccno;
1050 $form->{taxkey} = $taxkey;
1052 $form->{invnumber} = $form->update_defaults(\%myconfig, "invnumber")
1053 unless $form->{invnumber};
1055 $form->{id} = 0 if $form->{postasnew};
1056 if (AR->post_transaction(\%myconfig, \%$form)) {
1057 # saving the history
1058 if(!exists $form->{addition} && $form->{id} ne "") {
1059 $form->{addition} = "POSTED";
1060 $form->save_history($form->dbconnect(\%myconfig));
1062 # /saving the history
1063 remove_draft() if $form->{remove_draft};
1064 $form->redirect($locale->text('Transaction posted!'));
1066 $form->error($locale->text('Cannot post transaction!'));
1068 $lxdebug->leave_sub();
1072 $lxdebug->enter_sub();
1074 $form->{postasnew} = 1;
1075 # saving the history
1076 if(!exists $form->{addition} && $form->{id} ne "") {
1077 $form->{addition} = "POSTED AS NEW";
1078 $form->save_history($form->dbconnect(\%myconfig));
1080 # /saving the history
1083 $lxdebug->leave_sub();
1086 sub use_as_template {
1087 $lxdebug->enter_sub();
1089 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);
1090 $form->{paidaccounts} = 1;
1091 $form->{rowcount}--;
1092 $form->{invdate} = $form->current_date(\%myconfig);
1095 $lxdebug->leave_sub();
1099 $lxdebug->enter_sub();
1101 $form->{title} = $locale->text('Confirm!');
1105 delete $form->{header};
1110 <form method=post action=$form->{script}>
1113 foreach $key (keys %$form) {
1114 $form->{$key} =~ s/\"/"/g;
1115 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
1119 <h2 class=confirm>$form->{title}</h2>
1122 . $locale->text('Are you sure you want to delete Transaction')
1123 . qq| $form->{invnumber}</h4>
1125 <input name=action class=submit type=submit value="|
1126 . $locale->text('Yes') . qq|">
1133 $lxdebug->leave_sub();
1137 $lxdebug->enter_sub();
1138 if (AR->delete_transaction(\%myconfig, \%$form, $spool)) {
1139 # saving the history
1140 if(!exists $form->{addition}) {
1141 $form->{addition} = "DELETED";
1142 $form->save_history($form->dbconnect(\%myconfig));
1144 # /saving the history
1145 $form->redirect($locale->text('Transaction deleted!'));
1147 $form->error($locale->text('Cannot delete transaction!'));
1149 $lxdebug->leave_sub();
1153 $lxdebug->enter_sub();
1155 # setup customer selection
1156 $form->all_vc(\%myconfig, "customer", "AR");
1158 if (@{ $form->{all_customer} }) {
1159 map { $customer .= "<option>$_->{name}--$_->{id}\n" }
1160 @{ $form->{all_customer} };
1161 $customer = qq|<select name=customer><option>\n$customer</select>|;
1163 $customer = qq|<input name=customer size=35>|;
1167 if (@{ $form->{all_departments} }) {
1168 $form->{selectdepartment} = "<option>\n";
1171 $form->{selectdepartment} .=
1172 "<option>$_->{description}--$_->{id}\n"
1173 } (@{ $form->{all_departments} });
1178 <th align=right nowrap>| . $locale->text('Department') . qq|</th>
1179 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
1181 | if $form->{selectdepartment};
1183 $form->{title} = $locale->text('AR Transactions');
1185 # use JavaScript Calendar or not
1186 $form->{jsscript} = $jscalendar;
1188 if ($form->{jsscript}) {
1190 # with JavaScript Calendar
1192 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}">
1193 <input type=button name=transdatefrom id="trigger1" value=|
1194 . $locale->text('button') . qq|></td>
1197 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}">
1198 <input type=button name=transdateto name=transdateto id="trigger2" value=|
1199 . $locale->text('button') . qq|></td>
1204 Form->write_trigger(\%myconfig, "2", "transdatefrom", "BR", "trigger1",
1205 "transdateto", "BL", "trigger2");
1208 # without JavaScript Calendar
1210 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>|;
1212 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}"></td>|;
1215 $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
1220 foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
1221 push(@values, $item->{"id"});
1222 $labels{$item->{"id"}} = $item->{"projectnumber"};
1225 NTI($cgi->popup_menu('-name' => 'project_id', '-values' => \@values,
1226 '-labels' => \%labels));
1228 $form->{fokus} = "search.customer";
1232 <body onLoad="fokus()">
1234 <form method=post name="search" action=$form->{script}>
1237 <tr><th class=listtop>$form->{title}</th></tr>
1238 <tr height="5"></tr>
1243 <th align=right>| . $locale->text('Customer') . qq|</th>
1244 <td colspan=3>$customer</td>
1248 <th align=right nowrap>| . $locale->text('Invoice Number') . qq|</th>
1249 <td colspan=3><input name=invnumber size=20></td>
1252 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
1253 <td colspan=3><input name=ordnumber size=20></td>
1256 <th align=right nowrap>| . $locale->text('Notes') . qq|</th>
1257 <td colspan=3><input name=notes size=40></td>
1260 <th align="right">| . $locale->text("Project Number") . qq|</th>
1261 <td colspan="3">$projectnumber</td>
1264 <th align=right nowrap>| . $locale->text('From') . qq|</th>
1266 <th align=right>| . $locale->text('Bis') . qq|</th>
1269 <input type=hidden name=sort value=transdate>
1277 <th align=right nowrap>| . $locale->text('Include in Report') . qq|</th>
1281 <td align=right><input name=open class=checkbox type=checkbox value=Y checked></td>
1282 <td nowrap>| . $locale->text('Open') . qq|</td>
1283 <td align=right><input name=closed class=checkbox type=checkbox value=Y></td>
1284 <td nowrap>| . $locale->text('Closed') . qq|</td>
1287 <td align=right><input name="l_id" class=checkbox type=checkbox value=Y></td>
1288 <td nowrap>| . $locale->text('ID') . qq|</td>
1289 <td align=right><input name="l_invnumber" class=checkbox type=checkbox value=Y checked></td>
1290 <td nowrap>| . $locale->text('Invoice Number') . qq|</td>
1291 <td align=right><input name="l_ordnumber" class=checkbox type=checkbox value=Y></td>
1292 <td nowrap>| . $locale->text('Order Number') . qq|</td>
1293 <td align=right><input name="l_transdate" class=checkbox type=checkbox value=Y checked></td>
1294 <td nowrap>| . $locale->text('Invoice Date') . qq|</td>
1297 <td align=right><input name="l_name" class=checkbox type=checkbox value=Y checked></td>
1298 <td nowrap>| . $locale->text('Customer') . qq|</td>
1299 <td align=right><input name="l_netamount" class=checkbox type=checkbox value=Y></td>
1300 <td nowrap>| . $locale->text('Amount') . qq|</td>
1301 <td align=right><input name="l_tax" class=checkbox type=checkbox value=Y></td>
1302 <td nowrap>| . $locale->text('Tax') . qq|</td>
1303 <td align=right><input name="l_amount" class=checkbox type=checkbox value=Y checked></td>
1304 <td nowrap>| . $locale->text('Total') . qq|</td>
1307 <td align=right><input name="l_datepaid" class=checkbox type=checkbox value=Y></td>
1308 <td nowrap>| . $locale->text('Date Paid') . qq|</td>
1309 <td align=right><input name="l_paid" class=checkbox type=checkbox value=Y checked></td>
1310 <td nowrap>| . $locale->text('Paid') . qq|</td>
1311 <td align=right><input name="l_duedate" class=checkbox type=checkbox value=Y></td>
1312 <td nowrap>| . $locale->text('Due Date') . qq|</td>
1313 <td align=right><input name="l_due" class=checkbox type=checkbox value=Y></td>
1314 <td nowrap>| . $locale->text('Amount Due') . qq|</td>
1317 <td align=right><input name="l_notes" class=checkbox type=checkbox value=Y></td>
1318 <td nowrap>| . $locale->text('Notes') . qq|</td>
1319 <td align=right><input name="l_employee" class=checkbox type=checkbox value=Y></td>
1320 <td nowrap>| . $locale->text('Salesperson') . qq|</td>
1321 <td align=right><input name="l_shippingpoint" class=checkbox type=checkbox value=Y></td>
1322 <td nowrap>| . $locale->text('Shipping Point') . qq|</td>
1323 <td align=right><input name="l_shipvia" class=checkbox type=checkbox value=Y></td>
1324 <td nowrap>| . $locale->text('Ship via') . qq|</td>
1327 <td align=right><input name="l_subtotal" class=checkbox type=checkbox value=Y></td>
1328 <td nowrap>| . $locale->text('Subtotal') . qq|</td>
1329 <td align=right><input name="l_globalprojectnumber" class=checkbox type=checkbox value=Y></td>
1330 <td nowrap>| . $locale->text('Project Number') . qq|</td>
1339 <td><hr size=3 noshade></td>
1343 <input type=hidden name=nextsub value=$form->{nextsub}>
1345 <input type=hidden name=path value=$form->{path}>
1346 <input type=hidden name=login value=$form->{login}>
1347 <input type=hidden name=password value=$form->{password}>
1350 <input class=submit type=submit name=action value="|
1351 . $locale->text('Continue') . qq|">
1362 $lxdebug->leave_sub();
1365 sub ar_transactions {
1366 $lxdebug->enter_sub();
1368 $form->{customer} = $form->unescape($form->{customer});
1369 ($form->{customer}, $form->{customer_id}) = split(/--/, $form->{customer});
1371 AR->ar_transactions(\%myconfig, \%$form);
1374 "$form->{script}?action=ar_transactions&path=$form->{path}&login=$form->{login}&password=$form->{password}";
1377 if ($form->{customer}) {
1378 $callback .= "&customer=" . $form->escape($form->{customer}, 1);
1379 $href .= "&customer=" . $form->escape($form->{customer});
1380 $option = $locale->text('Customer') . " : $form->{customer}";
1382 if ($form->{department}) {
1383 $callback .= "&department=" . $form->escape($form->{department}, 1);
1384 $href .= "&department=" . $form->escape($form->{department});
1385 ($department) = split /--/, $form->{department};
1386 $option .= "\n<br>" if ($option);
1387 $option .= $locale->text('Department') . " : $department";
1389 if ($form->{invnumber}) {
1390 $callback .= "&invnumber=" . $form->escape($form->{invnumber}, 1);
1391 $href .= "&invnumber=" . $form->escape($form->{invnumber});
1392 $option .= "\n<br>" if ($option);
1393 $option .= $locale->text('Invoice Number') . " : $form->{invnumber}";
1395 if ($form->{ordnumber}) {
1396 $callback .= "&ordnumber=" . $form->escape($form->{ordnumber}, 1);
1397 $href .= "&ordnumber=" . $form->escape($form->{ordnumber});
1398 $option .= "\n<br>" if ($option);
1399 $option .= $locale->text('Order Number') . " : $form->{ordnumber}";
1401 if ($form->{notes}) {
1402 $callback .= "¬es=" . $form->escape($form->{notes}, 1);
1403 $href .= "¬es=" . $form->escape($form->{notes});
1404 $option .= "\n<br>" if $option;
1405 $option .= $locale->text('Notes') . " : $form->{notes}";
1408 if ($form->{transdatefrom}) {
1409 $callback .= "&transdatefrom=$form->{transdatefrom}";
1410 $href .= "&transdatefrom=$form->{transdatefrom}";
1411 $option .= "\n<br>" if ($option);
1413 $locale->text('From') . " "
1414 . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
1416 if ($form->{transdateto}) {
1417 $callback .= "&transdateto=$form->{transdateto}";
1418 $href .= "&transdateto=$form->{transdateto}";
1419 $option .= "\n<br>" if ($option);
1421 $locale->text('Bis') . " "
1422 . $locale->date(\%myconfig, $form->{transdateto}, 1);
1424 if ($form->{open}) {
1425 $callback .= "&open=$form->{open}";
1426 $href .= "&open=$form->{open}";
1427 $option .= "\n<br>" if ($option);
1428 $option .= $locale->text('Open');
1430 if ($form->{closed}) {
1431 $callback .= "&closed=$form->{closed}";
1432 $href .= "&closed=$form->{closed}";
1433 $option .= "\n<br>" if ($option);
1434 $option .= $locale->text('Closed');
1436 if ($form->{globalproject_id}) {
1437 $callback .= "&globalproject_id=" . E($form->{globalproject_id});
1438 $href .= "&globalproject_id=" . E($form->{globalproject_id});
1442 qw(transdate id type invnumber ordnumber name netamount tax amount paid
1443 datepaid due duedate notes employee shippingpoint shipvia
1444 globalprojectnumber);
1446 $form->{"l_type"} = "Y";
1448 foreach $item (@columns) {
1449 if ($form->{"l_$item"} eq "Y") {
1450 push @column_index, $item;
1452 # add column to href and callback
1453 $callback .= "&l_$item=Y";
1454 $href .= "&l_$item=Y";
1458 if ($form->{l_subtotal} eq 'Y') {
1459 $callback .= "&l_subtotal=Y";
1460 $href .= "&l_subtotal=Y";
1463 $column_header{id} =
1464 "<th><a class=listheading href=$href&sort=id>"
1465 . $locale->text('ID')
1467 $column_header{transdate} =
1468 "<th><a class=listheading href=$href&sort=transdate>"
1469 . $locale->text('Date')
1471 $column_header{duedate} =
1472 "<th><a class=listheading href=$href&sort=duedate>"
1473 . $locale->text('Due Date')
1475 $column_header{type} =
1476 "<th class=\"listheading\">" . $locale->text('Type') . "</th>";
1477 $column_header{invnumber} =
1478 "<th><a class=listheading href=$href&sort=invnumber>"
1479 . $locale->text('Invoice')
1481 $column_header{ordnumber} =
1482 "<th><a class=listheading href=$href&sort=ordnumber>"
1483 . $locale->text('Order')
1485 $column_header{name} =
1486 "<th><a class=listheading href=$href&sort=name>"
1487 . $locale->text('Customer')
1489 $column_header{netamount} =
1490 "<th class=listheading>" . $locale->text('Amount') . "</th>";
1491 $column_header{tax} =
1492 "<th class=listheading>" . $locale->text('Tax') . "</th>";
1493 $column_header{amount} =
1494 "<th class=listheading>" . $locale->text('Total') . "</th>";
1495 $column_header{paid} =
1496 "<th class=listheading>" . $locale->text('Paid') . "</th>";
1497 $column_header{datepaid} =
1498 "<th><a class=listheading href=$href&sort=datepaid>"
1499 . $locale->text('Date Paid')
1501 $column_header{due} =
1502 "<th class=listheading>" . $locale->text('Amount Due') . "</th>";
1503 $column_header{notes} =
1504 "<th class=listheading>" . $locale->text('Notes') . "</th>";
1505 $column_header{employee} =
1506 "<th><a class=listheading href=$href&sort=employee>"
1507 . $locale->text('Salesperson') . "</th>";
1509 $column_header{shippingpoint} =
1510 "<th><a class=listheading href=$href&sort=shippingpoint>"
1511 . $locale->text('Shipping Point')
1513 $column_header{shipvia} =
1514 "<th><a class=listheading href=$href&sort=shipvia>"
1515 . $locale->text('Ship via')
1517 $column_header{globalprojectnumber} =
1518 qq|<th class="listheading">| . $locale->text('Project Number') . qq|</th>|;
1520 $form->{title} = $locale->text('AR Transactions');
1529 <th class=listtop>$form->{title}</th>
1531 <tr height="5"></tr>
1538 <tr class=listheading>
1541 map { print "\n$column_header{$_}" } @column_index;
1547 # add sort and escape callback, this one we use for the add sub
1548 $form->{callback} = $callback .= "&sort=$form->{sort}";
1550 # escape callback for href
1551 $callback = $form->escape($callback);
1553 if (@{ $form->{AR} }) {
1554 $sameitem = $form->{AR}->[0]->{ $form->{sort} };
1557 # sums and tax on reports by Antonio Gallardo
1559 foreach $ar (@{ $form->{AR} }) {
1561 if ($form->{l_subtotal} eq 'Y') {
1562 if ($sameitem ne $ar->{ $form->{sort} }) {
1567 $column_data{netamount} =
1569 . $form->format_amount(\%myconfig, $ar->{netamount}, 2, " ")
1571 $column_data{tax} = "<td align=right>"
1572 . $form->format_amount(\%myconfig, $ar->{amount} - $ar->{netamount},
1575 $column_data{amount} =
1577 . $form->format_amount(\%myconfig, $ar->{amount}, 2, " ") . "</td>";
1578 $column_data{paid} =
1580 . $form->format_amount(\%myconfig, $ar->{paid}, 2, " ") . "</td>";
1581 $column_data{due} = "<td align=right>"
1582 . $form->format_amount(\%myconfig, $ar->{amount} - $ar->{paid},
1586 $subtotalnetamount += $ar->{netamount};
1587 $subtotalamount += $ar->{amount};
1588 $subtotalpaid += $ar->{paid};
1589 $subtotaldue += $ar->{amount} - $ar->{paid};
1591 $totalnetamount += $ar->{netamount};
1592 $totalamount += $ar->{amount};
1593 $totalpaid += $ar->{paid};
1594 $totaldue += ($ar->{amount} - $ar->{paid});
1596 $column_data{transdate} = "<td>$ar->{transdate} </td>";
1597 $column_data{id} = "<td>$ar->{id}</td>";
1598 $column_data{datepaid} = "<td>$ar->{datepaid} </td>";
1599 $column_data{duedate} = "<td>$ar->{duedate} </td>";
1601 $module = ($ar->{invoice}) ? "is.pl" : $form->{script};
1603 $column_data{invnumber} =
1604 "<td><a href=$module?action=edit&id=$ar->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ar->{invnumber}</a></td>";
1605 $column_data{type} = "<td>" .
1606 ($ar->{storno} ? $locale->text("Storno (one letter abbreviation)") :
1608 $locale->text("Credit note (one letter abbreviation)") :
1609 $locale->text("Invoice (one letter abbreviation)")) . "</td>";
1610 $column_data{ordnumber} = "<td>$ar->{ordnumber} </td>";
1611 $column_data{name} = "<td>$ar->{name}</td>";
1612 $ar->{notes} =~ s/\r\n/<br>/g;
1613 $column_data{notes} = "<td>$ar->{notes} </td>";
1614 $column_data{shippingpoint} = "<td>$ar->{shippingpoint} </td>";
1615 $column_data{shipvia} = "<td>$ar->{shipvia} </td>";
1616 $column_data{employee} = "<td>$ar->{employee} </td>";
1617 $column_data{globalprojectnumber} =
1618 "<td>" . H($ar->{globalprojectnumber}) . "</td>";
1623 <tr class=listrow$i>
1626 map { print "\n$column_data{$_}" } @column_index;
1634 if ($form->{l_subtotal} eq 'Y') {
1640 <tr class=listtotal>
1643 map { $column_data{$_} = "<td> </td>" } @column_index;
1645 $column_data{netamount} =
1646 "<th class=listtotal align=right>"
1647 . $form->format_amount(\%myconfig, $totalnetamount, 2, " ") . "</th>";
1648 $column_data{tax} = "<th class=listtotal align=right>"
1649 . $form->format_amount(\%myconfig, $totalamount - $totalnetamount,
1652 $column_data{amount} =
1653 "<th class=listtotal align=right>"
1654 . $form->format_amount(\%myconfig, $totalamount, 2, " ") . "</th>";
1655 $column_data{paid} =
1656 "<th class=listtotal align=right>"
1657 . $form->format_amount(\%myconfig, $totalpaid, 2, " ") . "</th>";
1659 "<th class=listtotal align=right>"
1660 . $form->format_amount(\%myconfig, $totaldue, 2, " ") . "</th>";
1662 map { print "\n$column_data{$_}" } @column_index;
1670 <td><hr size=3 noshade></td>
1675 <form method=post action=$form->{script}>
1677 <input name=callback type=hidden value="$form->{callback}">
1679 <input type=hidden name=path value=$form->{path}>
1680 <input type=hidden name=login value=$form->{login}>
1681 <input type=hidden name=password value=$form->{password}>
1683 <input class=submit type=submit name=action value="|
1684 . $locale->text('AR Transaction') . qq|">
1685 <input class=submit type=submit name=action value="|
1686 . $locale->text('Sales Invoice') . qq|">
1694 $lxdebug->leave_sub();
1698 $lxdebug->enter_sub();
1700 map { $column_data{$_} = "<td> </td>" } @column_index;
1702 $column_data{tax} = "<th class=listsubtotal align=right>"
1703 . $form->format_amount(\%myconfig, $subtotalamount - $subtotalnetamount,
1706 $column_data{amount} =
1707 "<th class=listsubtotal align=right>"
1708 . $form->format_amount(\%myconfig, $subtotalamount, 2, " ") . "</th>";
1709 $column_data{paid} =
1710 "<th class=listsubtotal align=right>"
1711 . $form->format_amount(\%myconfig, $subtotalpaid, 2, " ") . "</th>";
1713 "<th class=listsubtotal align=right>"
1714 . $form->format_amount(\%myconfig, $subtotaldue, 2, " ") . "</th>";
1716 $subtotalnetamount = 0;
1717 $subtotalamount = 0;
1721 $sameitem = $ar->{ $form->{sort} };
1723 print "<tr class=listsubtotal>";
1725 map { print "\n$column_data{$_}" } @column_index;
1731 $lxdebug->leave_sub();