1 #=====================================================================
2 # SQL-Ledger Accounting
5 # Author: Dieter Simader
6 # Email: dsimader@sql-ledger.org
7 # Web: http://www.sql-ledger.org
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2 of the License, or
14 # (at your option) any later version.
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write to the Free Software
22 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #======================================================================
27 #======================================================================
34 require "$form->{path}/arap.pl";
35 require "$form->{path}/arapprn.pl";
40 # this is for our long dates
41 # $locale->text('January')
42 # $locale->text('February')
43 # $locale->text('March')
44 # $locale->text('April')
45 # $locale->text('May ')
46 # $locale->text('June')
47 # $locale->text('July')
48 # $locale->text('August')
49 # $locale->text('September')
50 # $locale->text('October')
51 # $locale->text('November')
52 # $locale->text('December')
54 # this is for our short month
55 # $locale->text('Jan')
56 # $locale->text('Feb')
57 # $locale->text('Mar')
58 # $locale->text('Apr')
59 # $locale->text('May')
60 # $locale->text('Jun')
61 # $locale->text('Jul')
62 # $locale->text('Aug')
63 # $locale->text('Sep')
64 # $locale->text('Oct')
65 # $locale->text('Nov')
66 # $locale->text('Dec')
71 $form->{title} = "Add";
72 $form->{callback} = "$form->{script}?action=add&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}" unless $form->{callback};
82 $form->{title} = "Edit";
100 $form->create_links("AR", \%myconfig, "customer");
101 $duedate = $form->{duedate};
103 $form->{formname} = "transaction";
104 $form->{format} = "postscript" if $myconfig{printer};
105 $form->{media} = $myconfig{printer};
108 @curr = split /:/, $form->{currencies};
110 $form->{defaultcurrency} = $curr[0];
112 map { $form->{selectcurrency} .= "<option>$_\n" } @curr;
114 IS->get_customer(\%myconfig, \%$form);
116 $form->{duedate} = $duedate if $duedate;
117 $form->{notes} = $form->{intnotes} if !$form->{id};
119 $form->{oldcustomer} = "$form->{customer}--$form->{customer_id}";
120 $form->{oldtransdate} = $form->{transdate};
123 if (@{ $form->{all_customer} }) {
124 $form->{customer} = "$form->{customer}--$form->{customer_id}";
125 map { $form->{selectcustomer} .= qq|<option value="$_->{name}--$_->{id}">$_->{name}\n| } (@{ $form->{all_customer} });
129 if (@{ $form->{all_departments} }) {
130 $form->{selectdepartment} = "<option>\n";
131 $form->{department} = "$form->{department}--$form->{department_id}";
133 map { $form->{selectdepartment} .= qq|<option value="$_->{description}--$_->{id}">$_->{description}\n| } (@{ $form->{all_departments} });
136 $form->{employee} = "$form->{employee}--$form->{employee_id}";
138 if (@{ $form->{all_employees} }) {
139 $form->{selectemployee} = "";
140 map { $form->{selectemployee} .= qq|<option value="$_->{name}--$_->{id}">$_->{name}\n| } (@{ $form->{all_employees} });
144 if (@{ $form->{all_projects} }) {
145 $form->{selectprojectnumber} = "<option>\n";
146 map { $form->{selectprojectnumber} .= qq|<option value="$_->{projectnumber}--$_->{id}">$_->{projectnumber}\n| } (@{ $form->{all_projects} });
149 if (@{ $form->{all_languages} }) {
150 $form->{selectlanguage} = "<option>\n";
151 map { $form->{selectlanguage} .= qq|<option value="$_->{code}">$_->{description}\n| } @{ $form->{all_languages} };
155 $form->{forex} = $form->{exchangerate};
156 $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
158 foreach $key (keys %{ $form->{AR_links} }) {
160 foreach $ref (@{ $form->{AR_links}{$key} }) {
161 if ($key eq 'AR_tax') {
162 $form->{"selectAR_tax_$ref->{accno}"} = "<option>$ref->{accno}--$ref->{description}\n";
163 $form->{"calctax_$ref->{accno}"} = 1;
166 $form->{"select$key"} .= "<option>$ref->{accno}--$ref->{description}\n";
169 # if there is a value we have an old entry
170 for $i (1 .. scalar @{ $form->{acc_trans}{$key} }) {
171 if ($key eq "AR_paid") {
172 $form->{"AR_paid_$i"} = "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
174 $form->{"paid_$i"} = $form->{acc_trans}{$key}->[$i-1]->{amount} * -1;
175 $form->{"datepaid_$i"} = $form->{acc_trans}{$key}->[$i-1]->{transdate};
176 $form->{"source_$i"} = $form->{acc_trans}{$key}->[$i-1]->{source};
177 $form->{"memo_$i"} = $form->{acc_trans}{$key}->[$i-1]->{memo};
179 $form->{"forex_$i"} = $form->{"exchangerate_$i"} = $form->{acc_trans}{$key}->[$i-1]->{exchangerate};
181 $form->{paidaccounts}++;
187 if ($key eq "AR_tax") {
188 $form->{"${key}_$form->{acc_trans}{$key}->[$i-1]->{accno}"} = "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
189 $form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"} = $form->round_amount($form->{acc_trans}{$key}->[$i-1]->{amount} / $exchangerate, 2);
191 if ($form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"} > 0) {
192 $totaltax += $form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"};
193 $taxrate += $form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"};
195 $totalwithholding += $form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"};
196 $withholdingrate += $form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"};
200 $form->{"${akey}_$i"} = $form->round_amount($form->{acc_trans}{$key}->[$i-1]->{amount} / $exchangerate, 2);
201 if ($akey eq 'amount') {
203 $totalamount += $form->{"${akey}_$i"};
205 $form->{"projectnumber_$i"} = "$form->{acc_trans}{$key}->[$i-1]->{projectnumber}--$form->{acc_trans}{$key}->[$i-1]->{project_id}";
207 $form->{"${key}_$i"} = "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
213 $form->{paidaccounts} = 1 if not defined $form->{paidaccounts};
215 if ($form->{taxincluded} && $totalamount) {
216 # add tax to individual amounts
217 for $i (1 .. $form->{rowcount}) {
218 $taxamount = ($totaltax + $totalwithholding) * $form->{"amount_$i"} / $totalamount;
219 $tax = $form->round_amount($taxamount, 2);
220 $diff += ($taxamount - $tax);
221 $form->{"amount_$i"} += $tax;
223 $form->{amount_1} += $form->round_amount($diff, 2);
226 # check if calculated is equal to stored
227 # taxincluded is terrible to calculate
228 # this works only if all taxes are checked
229 foreach $item (split / /, $form->{taxaccounts}) {
230 if ($form->{taxincluded}) {
231 if ($form->{"${item}_rate"} > 0) {
233 $taxamount = $form->round_amount(($totalamount + $totaltax + $totalwithholding) * $taxrate / (1 + $taxrate), 2) * $form->{"${item}_rate"} / $taxrate;
236 if ($withholdingrate) {
237 $taxamount = $form->round_amount(($totalamount + $totaltax + $totalwithholding) * $withholdingrate / (1 - $withholdingrate), 2) * $form->{"${item}_rate"} / $withholdingrate;
241 $taxamount = $totalamount * $form->{"${item}_rate"};
243 $taxamount = $form->round_amount($taxamount, 2);
245 $form->{"calctax_$item"} = 0;
246 if ($form->{"tax_$item"} == $taxamount) {
247 $form->{"calctax_$item"} = 1;
251 $form->{invtotal} = $totalamount + $totaltax + $totalwithholding;
252 $form->{rowcount}++ if $form->{id};
254 $form->{AR} = $form->{AR_1};
255 $form->{rowcount} = 1 unless $form->{AR_amount_1};
257 $form->{locked} = ($form->{revtrans}) ? '1' : ($form->datetonum($form->{transdate}, \%myconfig) <= $form->datetonum($form->{closedto}, \%myconfig));
260 $form->{readonly} = 1 if $myconfig{acs} =~ /AR--Add Transaction/;
267 $title = $form->{title};
268 $form->{title} = $locale->text("$title AR Transaction");
270 $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
272 # $locale->text('Add AR Transaction')
273 # $locale->text('Edit AR Transaction')
275 # set option selected
276 foreach $item (qw(AR currency)) {
277 $form->{"select$item"} =~ s/ selected//;
278 $form->{"select$item"} =~ s/<option>\Q$form->{$item}\E/<option selected>$form->{$item}/;
281 foreach $item (qw(customer department employee)) {
282 $form->{"select$item"} = $form->unescape($form->{"select$item"});
283 $form->{"select$item"} =~ s/ selected//;
284 $form->{"select$item"} =~ s/(<option value="\Q$form->{$item}\E")/$1 selected/;
287 $form->{selectprojectnumber} = $form->unescape($form->{selectprojectnumber});
290 $form->{exchangerate} = $form->format_amount(\%myconfig, $form->{exchangerate});
293 <input type=hidden name=forex value=$form->{forex}>
295 if ($form->{currency} ne $form->{defaultcurrency}) {
296 if ($form->{forex}) {
298 <th align=right>|.$locale->text('Exchange Rate').qq|</th>
299 <td><input type=hidden name=exchangerate value=$form->{exchangerate}>$form->{exchangerate}</td>
303 <th align=right>|.$locale->text('Exchange Rate').qq|</th>
304 <td><input name=exchangerate size=10 value=$form->{exchangerate}></td>
310 if ($form->{taxaccounts}) {
313 <td align=right><input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}></td>
314 <th align=left nowrap>|.$locale->text('Tax Included').qq|</th>
320 if (($rows = $form->numtextrows($form->{notes}, 50)) < 2) {
323 $notes = qq|<textarea name=notes rows=$rows cols=50 wrap=soft>$form->{notes}</textarea>|;
327 <th align="right" nowrap>|.$locale->text('Department').qq|</th>
328 <td colspan=3><select name=department>$form->{selectdepartment}</select>
329 <input type=hidden name=selectdepartment value="|.$form->escape($form->{selectdepartment},1).qq|">
332 | if $form->{selectdepartment};
335 $n = ($form->{creditremaining} < 0) ? "0" : "1";
337 $customer = ($form->{selectcustomer}) ? qq|<select name=customer>$form->{selectcustomer}</select>| : qq|<input name=customer value="$form->{customer}" size=35>|;
340 <input type=hidden name=employee value="$form->{employee}">
345 <th align=right nowrap>|.$locale->text('Salesperson').qq|</th>
346 <td><select name=employee>$form->{selectemployee}</select></td>
347 <input type=hidden name=selectemployee value="|.$form->escape($form->{selectemployee},1).qq|">
349 | if $form->{selectemployee};
356 <form method=post action=$form->{script}>
358 <input type=hidden name=id value=$form->{id}>
360 <input type=hidden name=type value="transaction">
361 <input type=hidden name=vc value="customer">
363 <input type=hidden name=queued value="$form->{queued}">
364 <input type=hidden name=printed value="$form->{printed}">
365 <input type=hidden name=emailed value="$form->{emailed}">
367 <input type=hidden name=sort value=$form->{sort}>
369 <input type=hidden name=closedto value=$form->{closedto}>
370 <input type=hidden name=locked value=$form->{locked}>
372 <input type=hidden name=title value="$title">
374 <input type=hidden name=oldtransdate value=$form->{oldtransdate}>
375 <input type=hidden name=audittrail value="$form->{audittrail}">
379 <th class=listtop>$form->{title}</th>
389 <th align="right" nowrap>|.$locale->text('Customer').qq|</th>
390 <td colspan=3>$customer</td>
391 <input type=hidden name=selectcustomer value="|.$form->escape($form->{selectcustomer},1).qq|">
392 <input type=hidden name=oldcustomer value="$form->{oldcustomer}">
393 <input type=hidden name=customer_id value="$form->{customer_id}">
394 <input type=hidden name=terms value=$form->{terms}>
401 <th align=left nowrap>|.$locale->text('Credit Limit').qq|</th>
402 <td>$form->{creditlimit}</td>
403 <th align=left nowrap>|.$locale->text('Remaining').qq|</th>
404 <td class="plus$n">|.$form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0").qq|</td>
405 <input type=hidden name=creditlimit value=$form->{creditlimit}>
406 <input type=hidden name=creditremaining value=$form->{creditremaining}>
412 <th align=right>|.$locale->text('Currency').qq|</th>
413 <td><select name=currency>$form->{selectcurrency}</select></td>
414 <input type=hidden name=selectcurrency value="$form->{selectcurrency}">
415 <input type=hidden name=defaultcurrency value=$form->{defaultcurrency}>
416 <input type=hidden name=fxgain_accno value=$form->{fxgain_accno}>
417 <input type=hidden name=fxloss_accno value=$form->{fxloss_accno}>
428 <th align=right nowrap>|.$locale->text('Invoice Number').qq|</th>
429 <td><input name=invnumber size=20 value="$form->{invnumber}"></td>
432 <th align=right nowrap>|.$locale->text('Order Number').qq|</th>
433 <td><input name=ordnumber size=20 value="$form->{ordnumber}"></td>
436 <th align=right nowrap>|.$locale->text('Invoice Date').qq|</th>
437 <td><input name=transdate size=11 title="($myconfig{'dateformat'})" value=$form->{transdate}></td>
440 <th align=right nowrap>|.$locale->text('Due Date').qq|</th>
441 <td><input name=duedate size=11 title="$myconfig{'dateformat'}" value=$form->{duedate}></td>
453 <input type=hidden name=selectAR_amount value="$form->{selectAR_amount}">
454 <input type=hidden name=selectprojectnumber value="|.$form->escape($form->{selectprojectnumber},1).qq|">
455 <input type=hidden name=rowcount value=$form->{rowcount}>
458 $amount = $locale->text('Amount');
460 for $i (1 .. $form->{rowcount}) {
462 $selectAR_amount = $form->{selectAR_amount};
463 $selectAR_amount =~ s/option>\Q$form->{"AR_amount_$i"}\E/option selected>$form->{"AR_amount_$i"}/;
465 $selectprojectnumber = $form->{selectprojectnumber};
466 $selectprojectnumber =~ s/(<option value="\Q$form->{"projectnumber_$i"}\E")/$1 selected/;
469 $form->{"amount_$i"} = $form->format_amount(\%myconfig, $form->{"amount_$i"}, 2);
472 <td align=right><select name="projectnumber_$i">$selectprojectnumber</select></td>
473 | if $form->{selectprojectnumber};
477 <th align=right>$amount</th>
478 <td><input name="amount_$i" size=10 value=$form->{"amount_$i"}></td>
480 <td><select name="AR_amount_$i">$selectAR_amount</select></td>
488 $taxlabel = ($form->{taxincluded}) ? $locale->text('Tax Included') : $locale->text('Tax');
490 foreach $item (split / /, $form->{taxaccounts}) {
492 $form->{"calctax_$item"} = ($form->{"calctax_$item"}) ? "checked" : "";
494 $form->{"tax_$item"} = $form->format_amount(\%myconfig, $form->{"tax_$item"}, 2);
497 <th align=right nowrap>$taxlabel</th>
498 <td><input name="tax_$item" size=10 value=$form->{"tax_$item"}></td>
499 <td align=right><input name="calctax_$item" class=checkbox type=checkbox value=1 $form->{"calctax_$item"}></td>
500 <td><select name="AR_tax_$item">$form->{"selectAR_tax_$item"}</select></td>
502 <input type=hidden name="${item}_rate" value="$form->{"${item}_rate"}">
503 <input type=hidden name="${item}_description" value="$form->{"${item}_description"}">
504 <input type=hidden name="selectAR_tax_$item" value="$form->{"selectAR_tax_$item"}">
509 $form->{invtotal} = $form->format_amount(\%myconfig, $form->{invtotal}, 2);
514 <th align=right>|.$locale->text('Total').qq|</th>
515 <th align=left>$form->{invtotal}</th>
518 <input type=hidden name=oldinvtotal value=$form->{oldinvtotal}>
519 <input type=hidden name=oldtotalpaid value=$form->{oldtotalpaid}>
521 <input type=hidden name=taxaccounts value="$form->{taxaccounts}">
523 <td><select name=AR>$form->{selectAR}</select></td>
524 <input type=hidden name=selectAR value="$form->{selectAR}">
528 <th align=right>|.$locale->text('Notes').qq|</th>
529 <td colspan=4>$notes</td>
537 <tr class=listheading>
538 <th colspan=6 class=listheading>|.$locale->text('Payments').qq|</th>
542 if ($form->{currency} eq $form->{defaultcurrency}) {
543 @column_index = qw(datepaid source memo paid AR_paid);
545 @column_index = qw(datepaid source memo paid exchangerate AR_paid);
548 $column_data{datepaid} = "<th>".$locale->text('Date')."</th>";
549 $column_data{paid} = "<th>".$locale->text('Amount')."</th>";
550 $column_data{exchangerate} = "<th>".$locale->text('Exch')."</th>";
551 $column_data{AR_paid} = "<th>".$locale->text('Account')."</th>";
552 $column_data{source} = "<th>".$locale->text('Source')."</th>";
553 $column_data{memo} = "<th>".$locale->text('Memo')."</th>";
558 map { print "$column_data{$_}\n" } @column_index;
564 $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
565 for $i (1 .. $form->{paidaccounts}) {
570 $form->{"selectAR_paid_$i"} = $form->{selectAR_paid};
571 $form->{"selectAR_paid_$i"} =~ s/option>\Q$form->{"AR_paid_$i"}\E/option selected>$form->{"AR_paid_$i"}/;
574 $form->{"paid_$i"} = $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2);
575 $form->{"exchangerate_$i"} = $form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
577 $exchangerate = qq| |;
578 if ($form->{currency} ne $form->{defaultcurrency}) {
579 if ($form->{"forex_$i"}) {
580 $exchangerate = qq|<input type=hidden name="exchangerate_$i" value=$form->{"exchangerate_$i"}>$form->{"exchangerate_$i"}|;
582 $exchangerate = qq|<input name="exchangerate_$i" size=10 value=$form->{"exchangerate_$i"}>|;
587 <input type=hidden name="forex_$i" value=$form->{"forex_$i"}>
590 $column_data{paid} = qq|<td align=center><input name="paid_$i" size=11 value=$form->{"paid_$i"}></td>|;
591 $column_data{AR_paid} = qq|<td align=center><select name="AR_paid_$i">$form->{"selectAR_paid_$i"}</select></td>|;
592 $column_data{exchangerate} = qq|<td align=center>$exchangerate</td>|;
593 $column_data{datepaid} = qq|<td align=center><input name="datepaid_$i" size=11 value=$form->{"datepaid_$i"}></td>|;
594 $column_data{source} = qq|<td align=center><input name="source_$i" size=11 value="$form->{"source_$i"}"></td>|;
595 $column_data{memo} = qq|<td align=center><input name="memo_$i" size=11 value="$form->{"memo_$i"}"></td>|;
597 map { print qq|$column_data{$_}\n| } @column_index;
605 <input type=hidden name=paidaccounts value=$form->{paidaccounts}>
606 <input type=hidden name=selectAR_paid value="$form->{selectAR_paid}">
612 <td><hr size=3 noshade></td>
626 <input name=callback type=hidden value="$form->{callback}">
628 <input type=hidden name=path value=$form->{path}>
629 <input type=hidden name=login value=$form->{login}>
630 <input type=hidden name=sessionid value=$form->{sessionid}>
635 $transdate = $form->datetonum($form->{transdate}, \%myconfig);
636 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
638 if (! $form->{readonly}) {
641 print qq|<input class=submit type=submit name=action value="|.$locale->text('Update').qq|">
644 if (!$form->{locked}) {
646 <input class=submit type=submit name=action value="|.$locale->text('Post').qq|">
647 <input class=submit type=submit name=action value="|.$locale->text('Print').qq|">
648 <input class=submit type=submit name=action value="|.$locale->text('Print and Post').qq|">
649 <input class=submit type=submit name=action value="|.$locale->text('Delete').qq|">
654 <input class=submit type=submit name=action value="|.$locale->text('Post as new').qq|">
658 if ($transdate > $closedto) {
659 print qq|<input class=submit type=submit name=action value="|.$locale->text('Update').qq|">
660 <input class=submit type=submit name=action value="|.$locale->text('Print').qq|">
661 <input class=submit type=submit name=action value="|.$locale->text('Post').qq|">
662 <input class=submit type=submit name=action value="|.$locale->text('Print and Post').qq|">|;
667 if ($form->{menubar}) {
668 require "$form->{path}/menu.pl";
689 $form->{invtotal} = 0;
691 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } qw(exchangerate);
693 @flds = qw(amount AR_amount projectnumber);
696 for $i (1 .. $form->{rowcount}) {
697 $form->{"amount_$i"} = $form->parse_amount(\%myconfig, $form->{"amount_$i"});
698 if ($form->{"amount_$i"}) {
702 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
707 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
708 $form->{rowcount} = $count + 1;
710 map { $form->{invtotal} += $form->{"amount_$_"} } (1 .. $form->{rowcount});
712 $form->{exchangerate} = $exchangerate if ($form->{forex} = ($exchangerate = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{transdate}, 'buy')));
715 if (&check_name(customer)) {
716 $form->{notes} = $form->{intnotes} unless $form->{id};
719 if ($form->{transdate} ne $form->{oldtransdate}) {
720 $form->{duedate} = $form->current_date(\%myconfig, $form->{transdate}, $form->{terms} * 1);
721 $form->{oldtransdate} = $form->{transdate};
729 @taxaccounts = split / /, $form->{taxaccounts};
731 map { $form->{"tax_$_"} = $form->parse_amount(\%myconfig, $form->{"tax_$_"}) } @taxaccounts;
733 if ($form->{taxincluded}) {
735 $withholdingrate = 0;
737 foreach $item (@taxaccounts) {
738 $form->{"calctax_$item"} = 1 if $form->{calctax};
740 if ($form->{"calctax_$item"}) {
741 if ($form->{"${item}_rate"} > 0) {
742 $taxrate += $form->{"${item}_rate"};
744 $withholdingrate += $form->{"${item}_rate"};
749 foreach $item (@taxaccounts) {
751 if ($form->{"calctax_$item"}) {
752 if ($form->{"${item}_rate"} > 0) {
754 $amount = $form->round_amount($form->{invtotal} * $taxrate / (1 + $taxrate), 2) * $form->{"${item}_rate"} / $taxrate;
755 $form->{"tax_$item"} = $form->round_amount($amount, 2);
756 $taxdiff += ($amount - $form->{"tax_$item"});
759 if ($withholdingrate) {
760 $amount = $form->round_amount($form->{invtotal} * $withholdingrate / (1 - $withholdingrate), 2) * $form->{"${item}_rate"} / $withholdingrate;
761 $form->{"tax_$item"} = $form->round_amount($amount, 2);
762 $taxdiff += ($amount - $form->{"tax_$item"});
766 if (abs($taxdiff) >= 0.005) {
767 $form->{"tax_$item"} += $form->round_amount($taxdiff, 2);
771 $form->{"selectAR_tax_$item"} = qq|<option>$item--$form->{"${item}_description"}|;
772 $totaltax += $form->{"tax_$item"};
775 foreach $item (@taxaccounts) {
776 $form->{"calctax_$item"} = 1 if $form->{calctax};
778 if ($form->{"calctax_$item"}) {
779 $form->{"tax_$item"} = $form->round_amount($form->{invtotal} * $form->{"${item}_rate"}, 2);
781 $form->{"selectAR_tax_$item"} = qq|<option>$item--$form->{"${item}_description"}|;
782 $totaltax += $form->{"tax_$item"};
786 $form->{invtotal} = ($form->{taxincluded}) ? $form->{invtotal} : $form->{invtotal} + $totaltax;
788 for $i (1 .. $form->{paidaccounts}) {
789 if ($form->{"paid_$i"}) {
790 map { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } qw(paid exchangerate);
792 $totalpaid += $form->{"paid_$i"};
794 $form->{"exchangerate_$i"} = $exchangerate if ($form->{"forex_$i"} = ($exchangerate = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'buy')));
798 $form->{creditremaining} -= ($form->{invtotal} - $totalpaid + $form->{oldtotalpaid} - $form->{oldinvtotal});
799 $form->{oldinvtotal} = $form->{invtotal};
800 $form->{oldtotalpaid} = $totalpaid;
809 # check if there is an invoice number, invoice and due date
810 $form->isblank("transdate", $locale->text('Invoice Date missing!'));
811 $form->isblank("duedate", $locale->text('Due Date missing!'));
812 $form->isblank("customer", $locale->text('Customer missing!'));
814 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
815 $transdate = $form->datetonum($form->{transdate}, \%myconfig);
817 $form->error($locale->text('Cannot post transaction for a closed period!')) if ($transdate <= $closedto);
819 $form->isblank("exchangerate", $locale->text('Exchange rate missing!')) if ($form->{currency} ne $form->{defaultcurrency});
821 for $i (1 .. $form->{paidaccounts}) {
822 if ($form->{"paid_$i"}) {
823 $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
825 $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
827 $form->error($locale->text('Cannot post payment for a closed period!')) if ($datepaid <= $closedto);
829 if ($form->{currency} ne $form->{defaultcurrency}) {
830 $form->{"exchangerate_$i"} = $form->{exchangerate} if ($transdate == $datepaid);
831 $form->isblank("exchangerate_$i", $locale->text('Exchange rate for payment missing!'));
836 # if oldcustomer ne customer redo form
837 ($customer) = split /--/, $form->{customer};
838 if ($form->{oldcustomer} ne "$customer--$form->{customer_id}") {
843 $form->{invnumber} = $form->update_defaults(\%myconfig, "sinumber") unless $form->{invnumber};
845 $form->{id} = 0 if $form->{postasnew};
847 $form->redirect($locale->text('Transaction posted!')) if (AR->post_transaction(\%myconfig, \%$form));
848 $form->error($locale->text('Cannot post transaction!'));
855 $form->{postasnew} = 1;
863 $form->{title} = $locale->text('Confirm!');
867 delete $form->{header};
872 <form method=post action=$form->{script}>
878 <h2 class=confirm>$form->{title}</h2>
880 <h4>|.$locale->text('Are you sure you want to delete Transaction').qq| $form->{invnumber}</h4>
882 <input name=action class=submit type=submit value="|.$locale->text('Yes').qq|">
895 $form->redirect($locale->text('Transaction deleted!')) if (AR->delete_transaction(\%myconfig, \%$form, $spool));
896 $form->error($locale->text('Cannot delete transaction!'));
903 $form->create_links("AR", \%myconfig, "customer");
905 $form->{selectAR} = "<option>\n";
906 map { $form->{selectAR} .= "<option>$_->{accno}--$_->{description}\n" } @{ $form->{AR_links}{AR} };
908 if (@{ $form->{all_customer} }) {
909 map { $customer .= qq|<option value="$_->{name}--$_->{id}">$_->{name}\n| } @{ $form->{all_customer} };
910 $customer = qq|<select name=customer><option>\n$customer</select>|;
912 $customer = qq|<input name=customer size=35>|;
916 if (@{ $form->{all_departments} }) {
917 $form->{selectdepartment} = "<option>\n";
919 map { $form->{selectdepartment} .= qq|<option value="$_->{description}--$_->{id}">$_->{description}\n| } (@{ $form->{all_departments} });
924 <th align=right nowrap>|.$locale->text('Department').qq|</th>
925 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
927 | if $form->{selectdepartment};
930 $form->{title} = $locale->text('AR Transactions');
934 <th align=right nowrap>|.$locale->text('Invoice Number').qq|</th>
935 <td colspan=3><input name=invnumber size=20></td>
938 <th align=right nowrap>|.$locale->text('Order Number').qq|</th>
939 <td colspan=3><input name=ordnumber size=20></td>
942 <th align=right nowrap>|.$locale->text('Notes').qq|</th>
943 <td colspan=3><input name=notes size=40></td>
949 <td align=right><input name=open class=checkbox type=checkbox value=Y checked></td>
950 <td nowrap>|.$locale->text('Open').qq|</td>
951 <td align=right><input name=closed class=checkbox type=checkbox value=Y></td>
952 <td nowrap>|.$locale->text('Closed').qq|</td>
956 if ($form->{outstanding}) {
957 $form->{title} = $locale->text('AR Outstanding');
963 $form->{selectaccountingyear} = "<option>\n";
964 map { $form->{selectaccountingyear} .= qq|<option>$_\n| } @{ $form->{all_years} };
965 $form->{selectaccountingmonth} = "<option>\n";
966 map { $form->{selectaccountingmonth} .= qq|<option value=$_>|.$locale->text($form->{all_month}{$_}).qq|\n| } sort keys %{ $form->{all_month} };
970 <th align=right>|.$locale->text('Period').qq|</th>
972 <select name=month>$form->{selectaccountingmonth}</select>
973 <select name=year>$form->{selectaccountingyear}</select>
974 <input name=interval class=radio type=radio value=0 checked>|.$locale->text('Current').qq|
975 <input name=interval class=radio type=radio value=1>|.$locale->text('Month').qq|
976 <input name=interval class=radio type=radio value=3>|.$locale->text('Quarter').qq|
977 <input name=interval class=radio type=radio value=12>|.$locale->text('Year').qq|
988 <form method=post action=$form->{script}>
990 <input type=hidden name=title value="$form->{title}">
991 <input type=hidden name=outstanding value=$form->{outstanding}>
994 <tr><th class=listtop>$form->{title}</th></tr>
1000 <th align=right>|.$locale->text('Account').qq|</th>
1001 <td colspan=3><select name=AR>$form->{selectAR}</select></td>
1004 <th align=right>|.$locale->text('Customer').qq|</th>
1005 <td colspan=3>$customer</td>
1010 <th align=right>|.$locale->text('Ship via').qq|</th>
1011 <td colspan=3><input name=shipvia size=40></td>
1014 <th align=right nowrap>|.$locale->text('From').qq|</th>
1015 <td><input name=transdatefrom size=11 title="$myconfig{dateformat}"></td>
1016 <th align=right>|.$locale->text('To').qq|</th>
1017 <td><input name=transdateto size=11 title="$myconfig{dateformat}"></td>
1019 <input type=hidden name=sort value=transdate>
1028 <th align=right nowrap>|.$locale->text('Include in Report').qq|</th>
1033 <td align=right><input name="l_id" class=checkbox type=checkbox value=Y></td>
1034 <td nowrap>|.$locale->text('ID').qq|</td>
1035 <td align=right><input name="l_invnumber" class=checkbox type=checkbox value=Y checked></td>
1036 <td nowrap>|.$locale->text('Invoice Number').qq|</td>
1037 <td align=right><input name="l_ordnumber" class=checkbox type=checkbox value=Y></td>
1038 <td nowrap>|.$locale->text('Order Number').qq|</td>
1039 <td align=right><input name="l_transdate" class=checkbox type=checkbox value=Y checked></td>
1040 <td nowrap>|.$locale->text('Invoice Date').qq|</td>
1043 <td align=right><input name="l_name" class=checkbox type=checkbox value=Y checked></td>
1044 <td nowrap>|.$locale->text('Customer').qq|</td>
1045 <td align=right><input name="l_employee" class=checkbox type=checkbox value=Y></td>
1046 <td nowrap>|.$locale->text('Salesperson').qq|</td>
1047 <td align=right><input name="l_manager" class=checkbox type=checkbox value=Y></td>
1048 <td nowrap>|.$locale->text('Manager').qq|</td>
1051 <td align=right><input name="l_netamount" class=checkbox type=checkbox value=Y></td>
1052 <td nowrap>|.$locale->text('Amount').qq|</td>
1053 <td align=right><input name="l_tax" class=checkbox type=checkbox value=Y></td>
1054 <td nowrap>|.$locale->text('Tax').qq|</td>
1055 <td align=right><input name="l_amount" class=checkbox type=checkbox value=Y checked></td>
1056 <td nowrap>|.$locale->text('Total').qq|</td>
1057 <td align=right><input name="l_curr" class=checkbox type=checkbox value=Y></td>
1058 <td nowrap>|.$locale->text('Currency').qq|</td>
1061 <td align=right><input name="l_datepaid" class=checkbox type=checkbox value=Y></td>
1062 <td nowrap>|.$locale->text('Date Paid').qq|</td>
1063 <td align=right><input name="l_paid" class=checkbox type=checkbox value=Y checked></td>
1064 <td nowrap>|.$locale->text('Paid').qq|</td>
1065 <td align=right><input name="l_duedate" class=checkbox type=checkbox value=Y></td>
1066 <td nowrap>|.$locale->text('Due Date').qq|</td>
1067 <td align=right><input name="l_due" class=checkbox type=checkbox value=Y></td>
1068 <td nowrap>|.$locale->text('Amount Due').qq|</td>
1071 <td align=right><input name="l_notes" class=checkbox type=checkbox value=Y></td>
1072 <td nowrap>|.$locale->text('Notes').qq|</td>
1073 <td align=right><input name="l_till" class=checkbox type=checkbox value=Y></td>
1074 <td nowrap>|.$locale->text('Till').qq|</td>
1075 <td align=right><input name="l_shippingpoint" class=checkbox type=checkbox value=Y></td>
1076 <td nowrap>|.$locale->text('Shipping Point').qq|</td>
1077 <td align=right><input name="l_shipvia" class=checkbox type=checkbox value=Y></td>
1078 <td nowrap>|.$locale->text('Ship via').qq|</td>
1081 <td align=right><input name="l_subtotal" class=checkbox type=checkbox value=Y></td>
1082 <td nowrap>|.$locale->text('Subtotal').qq|</td>
1091 <td><hr size=3 noshade></td>
1095 <input type=hidden name=nextsub value=$form->{nextsub}>
1097 <input type=hidden name=path value=$form->{path}>
1098 <input type=hidden name=login value=$form->{login}>
1099 <input type=hidden name=sessionid value=$form->{sessionid}>
1102 <input class=submit type=submit name=action value="|.$locale->text('Continue').qq|">
1113 sub ar_transactions {
1115 if ($form->{customer}) {
1116 $form->{customer} = $form->unescape($form->{customer});
1117 ($form->{customer}, $form->{customer_id}) = split(/--/, $form->{customer});
1120 AR->ar_transactions(\%myconfig, \%$form);
1122 $href = "$form->{script}?action=ar_transactions&direction=$form->{direction}&oldsort=$form->{oldsort}&till=$form->{till}&outstanding=$form->{outstanding}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}";
1124 $href .= "&title=".$form->escape($form->{title});
1126 $form->sort_order();
1128 $callback = "$form->{script}?action=ar_transactions&direction=$form->{direction}&oldsort=$form->{oldsort}&till=$form->{till}&outstanding=$form->{outstanding}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}";
1130 $callback .= "&title=".$form->escape($form->{title},1);
1133 $callback .= "&AR=".$form->escape($form->{AR},1);
1134 $href .= "&AR=".$form->escape($form->{AR});
1135 $form->{AR} =~ s/--/ /;
1136 $option = $locale->text('Account')." : $form->{AR}";
1139 if ($form->{customer}) {
1140 $callback .= "&customer=".$form->escape($form->{customer},1)."--$form->{customer_id}";
1141 $href .= "&customer=".$form->escape($form->{customer})."--$form->{customer_id}";
1142 $option .= "\n<br>" if ($option);
1143 $option .= $locale->text('Customer')." : $form->{customer}";
1145 if ($form->{department}) {
1146 $callback .= "&department=".$form->escape($form->{department},1);
1147 $href .= "&department=".$form->escape($form->{department});
1148 ($department) = split /--/, $form->{department};
1149 $option .= "\n<br>" if ($option);
1150 $option .= $locale->text('Department')." : $department";
1152 if ($form->{invnumber}) {
1153 $callback .= "&invnumber=".$form->escape($form->{invnumber},1);
1154 $href .= "&invnumber=".$form->escape($form->{invnumber});
1155 $option .= "\n<br>" if ($option);
1156 $option .= $locale->text('Invoice Number')." : $form->{invnumber}";
1158 if ($form->{ordnumber}) {
1159 $callback .= "&ordnumber=".$form->escape($form->{ordnumber},1);
1160 $href .= "&ordnumber=".$form->escape($form->{ordnumber});
1161 $option .= "\n<br>" if ($option);
1162 $option .= $locale->text('Order Number')." : $form->{ordnumber}";
1164 if ($form->{notes}) {
1165 $callback .= "¬es=".$form->escape($form->{notes},1);
1166 $href .= "¬es=".$form->escape($form->{notes});
1167 $option .= "\n<br>" if $option;
1168 $option .= $locale->text('Notes')." : $form->{notes}";
1171 if ($form->{transdatefrom}) {
1172 $callback .= "&transdatefrom=$form->{transdatefrom}";
1173 $href .= "&transdatefrom=$form->{transdatefrom}";
1174 $option .= "\n<br>" if ($option);
1175 $option .= $locale->text('From')." ".$locale->date(\%myconfig, $form->{transdatefrom}, 1);
1177 if ($form->{transdateto}) {
1178 $callback .= "&transdateto=$form->{transdateto}";
1179 $href .= "&transdateto=$form->{transdateto}";
1180 $option .= "\n<br>" if ($option);
1181 $option .= $locale->text('To')." ".$locale->date(\%myconfig, $form->{transdateto}, 1);
1183 if ($form->{open}) {
1184 $callback .= "&open=$form->{open}";
1185 $href .= "&open=$form->{open}";
1186 $option .= "\n<br>" if ($option);
1187 $option .= $locale->text('Open');
1189 if ($form->{closed}) {
1190 $callback .= "&closed=$form->{closed}";
1191 $href .= "&closed=$form->{closed}";
1192 $option .= "\n<br>" if ($option);
1193 $option .= $locale->text('Closed');
1196 @columns = $form->sort_columns(qw(transdate id invnumber ordnumber name netamount tax amount paid due curr datepaid duedate notes till employee manager shippingpoint shipvia));
1198 foreach $item (@columns) {
1199 if ($form->{"l_$item"} eq "Y") {
1200 push @column_index, $item;
1202 if ($form->{l_curr} && $item =~ /(amount|tax|paid|due)/) {
1203 push @column_index, "fx_$item";
1206 # add column to href and callback
1207 $callback .= "&l_$item=Y";
1208 $href .= "&l_$item=Y";
1214 if ($form->{l_subtotal} eq 'Y') {
1215 $callback .= "&l_subtotal=Y";
1216 $href .= "&l_subtotal=Y";
1220 $column_header{id} = "<th><a class=listheading href=$href&sort=id}>".$locale->text('ID')."</a></th>";
1221 $column_header{transdate} = "<th><a class=listheading href=$href&sort=transdate>".$locale->text('Date')."</a></th>";
1222 $column_header{duedate} = "<th><a class=listheading href=$href&sort=duedate>".$locale->text('Due Date')."</a></th>";
1223 $column_header{invnumber} = "<th><a class=listheading href=$href&sort=invnumber>".$locale->text('Invoice')."</a></th>";
1224 $column_header{ordnumber} = "<th><a class=listheading href=$href&sort=ordnumber>".$locale->text('Order')."</a></th>";
1225 $column_header{name} = "<th><a class=listheading href=$href&sort=name>".$locale->text('Customer')."</a></th>";
1226 $column_header{netamount} = "<th class=listheading>" . $locale->text('Amount') . "</th>";
1227 $column_header{tax} = "<th class=listheading>" . $locale->text('Tax') . "</th>";
1228 $column_header{amount} = "<th class=listheading>" . $locale->text('Total') . "</th>";
1229 $column_header{paid} = "<th class=listheading>" . $locale->text('Paid') . "</th>";
1230 $column_header{datepaid} = "<th><a class=listheading href=$href&sort=datepaid>" . $locale->text('Date Paid') . "</a></th>";
1231 $column_header{due} = "<th class=listheading>" . $locale->text('Amount Due') . "</th>";
1232 $column_header{notes} = "<th class=listheading>".$locale->text('Notes')."</th>";
1233 $column_header{employee} = "<th><a class=listheading href=$href&sort=employee>".$locale->text('Salesperson')."</th>";
1234 $column_header{manager} = "<th><a class=listheading href=$href&sort=manager>".$locale->text('Manager')."</th>";
1235 $column_header{till} = "<th class=listheading><a class=listheading href=$href&sort=till>".$locale->text('Till')."</th>";
1237 $column_header{shippingpoint} = "<th><a class=listheading href=$href&sort=shippingpoint>" . $locale->text('Shipping Point') . "</a></th>";
1238 $column_header{shipvia} = "<th><a class=listheading href=$href&sort=shipvia>" . $locale->text('Ship via') . "</a></th>";
1240 $column_header{curr} = "<th><a class=listheading href=$href&sort=curr>" . $locale->text('Curr') . "</a></th>";
1241 map { $column_header{"fx_$_"} = "<th> </th>" } qw(amount tax netamount paid due);
1243 $form->{title} = ($form->{title}) ? $form->{title} : $locale->text('AR Transactions');
1252 <th class=listtop>$form->{title}</th>
1254 <tr height="5"></tr>
1261 <tr class=listheading>
1264 map { print "\n$column_header{$_}" } @column_index;
1271 # add sort and escape callback, this one we use for the add sub
1272 $form->{callback} = $callback .= "&sort=$form->{sort}";
1274 # escape callback for href
1275 $callback = $form->escape($callback);
1278 $direction = ($form->{direction} eq 'ASC') ? "ASC" : "DESC";
1279 $href =~ s/&direction=(\w+)&/&direction=$direction&/;
1281 if (@{ $form->{transactions} }) {
1282 $sameitem = $form->{transactions}->[0]->{$form->{sort}};
1285 # sums and tax on reports by Antonio Gallardo
1287 foreach $ar (@{ $form->{transactions} }) {
1289 if ($form->{l_subtotal} eq 'Y') {
1290 if ($sameitem ne $ar->{$form->{sort}}) {
1295 if ($form->{l_curr}) {
1296 map { $ar->{"fx_$_"} = $ar->{$_}/$ar->{exchangerate} } qw(netamount amount paid);
1298 map { $column_data{"fx_$_"} = "<td align=right>".$form->format_amount(\%myconfig, $ar->{"fx_$_"}, 2, " ")."</td>" } qw(netamount amount paid);
1300 $column_data{fx_tax} = "<td align=right>".$form->format_amount(\%myconfig, $ar->{fx_amount} - $ar->{fx_netamount}, 2, " ")."</td>";
1301 $column_data{fx_due} = "<td align=right>".$form->format_amount(\%myconfig, $ar->{fx_amount} - $ar->{fx_paid}, 2, " ")."</td>";
1303 $subtotalfxnetamount += $ar->{fx_netamount};
1304 $subtotalfxamount += $ar->{fx_amount};
1305 $subtotalfxpaid += $ar->{fx_paid};
1307 $totalfxnetamount += $ar->{fx_netamount};
1308 $totalfxamount += $ar->{fx_amount};
1309 $totalfxpaid += $ar->{fx_paid};
1313 map { $column_data{$_} = "<td align=right>".$form->format_amount(\%myconfig, $ar->{$_}, 2, " ")."</td>" } qw(netamount amount paid);
1315 $column_data{tax} = "<td align=right>".$form->format_amount(\%myconfig, $ar->{amount} - $ar->{netamount}, 2, " ")."</td>";
1316 $column_data{due} = "<td align=right>".$form->format_amount(\%myconfig, $ar->{amount} - $ar->{paid}, 2, " ")."</td>";
1319 $subtotalnetamount += $ar->{netamount};
1320 $subtotalamount += $ar->{amount};
1321 $subtotalpaid += $ar->{paid};
1323 $totalnetamount += $ar->{netamount};
1324 $totalamount += $ar->{amount};
1325 $totalpaid += $ar->{paid};
1327 $column_data{transdate} = "<td>$ar->{transdate} </td>";
1328 $column_data{id} = "<td>$ar->{id}</td>";
1329 $column_data{datepaid} = "<td>$ar->{datepaid} </td>";
1330 $column_data{duedate} = "<td>$ar->{duedate} </td>";
1332 $module = ($ar->{invoice}) ? "is.pl" : $form->{script};
1333 $module = ($ar->{till}) ? "ps.pl" : $module;
1335 $column_data{invnumber} = "<td><a href=$module?action=edit&id=$ar->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ar->{invnumber}</a></td>";
1336 $column_data{ordnumber} = "<td>$ar->{ordnumber} </td>";
1339 $name = $form->escape($ar->{name});
1340 $column_data{name} = "<td><a href=$href&customer=$name--$ar->{customer_id}&sort=$form->{sort}>$ar->{name}</a></td>";
1342 $ar->{notes} =~ s/\r\n/<br>/g;
1343 $column_data{notes} = "<td>$ar->{notes} </td>";
1344 $column_data{shippingpoint} = "<td>$ar->{shippingpoint} </td>";
1345 $column_data{shipvia} = "<td>$ar->{shipvia} </td>";
1346 $column_data{employee} = "<td>$ar->{employee} </td>";
1347 $column_data{manager} = "<td>$ar->{manager} </td>";
1348 $column_data{till} = "<td>$ar->{till} </td>";
1349 $column_data{curr} = "<td>$ar->{curr}</td>";
1353 <tr class=listrow$i>
1356 map { print "\n$column_data{$_}" } @column_index;
1365 if ($form->{l_subtotal} eq 'Y') {
1371 <tr class=listtotal>
1374 map { $column_data{$_} = "<td> </td>" } @column_index;
1376 $column_data{netamount} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalnetamount, 2, " ")."</th>";
1377 $column_data{tax} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalamount - $totalnetamount, 2, " ")."</th>";
1378 $column_data{amount} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalamount, 2, " ")."</th>";
1379 $column_data{paid} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalpaid, 2, " ")."</th>";
1380 $column_data{due} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalamount - $totalpaid, 2, " ")."</th>";
1382 if ($form->{l_curr} && $form->{sort} eq 'curr' && $form->{l_subtotal}) {
1383 $column_data{fx_netamount} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalfxnetamount, 2, " ")."</th>";
1384 $column_data{fx_tax} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalfxamount - $totalfxnetamount, 2, " ")."</th>";
1385 $column_data{fx_amount} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalfxamount, 2, " ")."</th>";
1386 $column_data{fx_paid} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalfxpaid, 2, " ")."</th>";
1387 $column_data{fx_due} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalfxamount - $totalfxpaid, 2, " ")."</th>";
1390 map { print "\n$column_data{$_}" } @column_index;
1392 if ($myconfig{acs} !~ /AR--AR/) {
1394 $button{'AR--Add Transaction'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('AR Transaction').qq|"> |;
1395 $button{'AR--Add Transaction'}{order} = $i++;
1396 $button{'AR--Sales Invoice'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('Sales Invoice.').qq|"> |;
1397 $button{'AR--Sales Invoice'}{order} = $i++;
1399 foreach $item (split /;/, $myconfig{acs}) {
1400 delete $button{$item};
1410 <td><hr size=3 noshade></td>
1415 <form method=post action=$form->{script}>
1417 <input name=callback type=hidden value="$form->{callback}">
1419 <input type=hidden name=customer value="$form->{customer}">
1420 <input type=hidden name=customer_id value=$form->{customer_id}>
1421 <input type=hidden name=vc value=customer>
1423 <input type=hidden name=path value=$form->{path}>
1424 <input type=hidden name=login value=$form->{login}>
1425 <input type=hidden name=sessionid value=$form->{sessionid}>
1428 if (! $form->{till}) {
1429 foreach $item (sort { $a->{order} <=> $b->{order} } %button) {
1430 print $item->{code};
1434 if ($form->{menubar}) {
1435 require "$form->{path}/menu.pl";
1451 map { $column_data{$_} = "<td> </td>" } @column_index;
1453 $column_data{tax} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotalamount - $subtotalnetamount, 2, " ")."</th>";
1454 $column_data{amount} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotalamount, 2, " ")."</th>";
1455 $column_data{paid} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotalpaid, 2, " ")."</th>";
1456 $column_data{due} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotalamount - $subtotalpaid, 2, " ")."</th>";
1458 if ($form->{l_curr} && $form->{sort} eq 'curr' && $form->{l_subtotal}) {
1459 $column_data{fx_tax} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotalfxamount - $subtotalfxnetamount, 2, " ")."</th>";
1460 $column_data{fx_amount} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotalfxamount, 2, " ")."</th>";
1461 $column_data{fx_paid} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotalfxpaid, 2, " ")."</th>";
1462 $column_data{fx_due} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotalfxmount - $subtotalfxpaid, 2, " ")."</th>";
1465 $subtotalnetamount = 0;
1466 $subtotalamount = 0;
1469 $subtotalfxnetamount = 0;
1470 $subtotalfxamount = 0;
1471 $subtotalfxpaid = 0;
1473 $sameitem = $ar->{$form->{sort}};
1475 print "<tr class=listsubtotal>";
1477 map { print "\n$column_data{$_}" } @column_index;