32 |
32 |
#======================================================================
|
33 |
33 |
|
34 |
34 |
use POSIX qw(strftime);
|
35 |
|
use List::Util qw(sum first);
|
|
35 |
use List::Util qw(sum first max);
|
36 |
36 |
|
37 |
37 |
use SL::AR;
|
38 |
38 |
use SL::FU;
|
... | ... | |
218 |
218 |
my $cgi = $::request->{cgi};
|
219 |
219 |
|
220 |
220 |
my ($title, $readonly, $exchangerate, $rows);
|
221 |
|
my ($taxincluded, $notes, $department, $customer, $employee, $amount, $project);
|
222 |
|
my ($jsscript, $button1, $button2, $onload);
|
223 |
|
my ($selectAR_amount, $selectAR_paid, $ARselected, $tax);
|
224 |
|
my (@column_index, %column_data);
|
|
221 |
my ($notes, $department, $customer, $employee, $amount, $project);
|
|
222 |
my ($onload);
|
|
223 |
my ($ARselected);
|
225 |
224 |
|
226 |
225 |
|
227 |
226 |
$title = $form->{title};
|
228 |
|
$form->{title} = $locale->text("$title Accounts Receivables Transaction");
|
229 |
|
|
230 |
|
$form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
|
231 |
|
|
232 |
227 |
# $locale->text('Add Accounts Receivables Transaction')
|
233 |
228 |
# $locale->text('Edit Accounts Receivables Transaction')
|
|
229 |
$form->{title} = $locale->text("$title Accounts Receivables Transaction");
|
|
230 |
|
234 |
231 |
$form->{javascript} = qq|<script type="text/javascript">
|
235 |
232 |
<!--
|
236 |
233 |
function setTaxkey(accno, row) {
|
... | ... | |
253 |
250 |
# show history button js
|
254 |
251 |
$form->{javascript} .= qq|<script type="text/javascript" src="js/show_history.js"></script>|;
|
255 |
252 |
#/show history button js
|
256 |
|
$form->{javascript} .= qq|<script type="text/javascript" src="js/common.js"></script>|;
|
257 |
253 |
$readonly = ($form->{id}) ? "readonly" : "";
|
258 |
254 |
|
259 |
|
$form->{radier} =
|
260 |
|
($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0;
|
|
255 |
$form->{radier} = ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0;
|
261 |
256 |
$readonly = ($form->{radier}) ? "" : $readonly;
|
262 |
257 |
|
263 |
258 |
# set option selected
|
264 |
259 |
foreach my $item (qw(customer currency department employee)) {
|
265 |
260 |
$form->{"select$item"} =~ s/ selected//;
|
266 |
|
$form->{"select$item"} =~
|
267 |
|
s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
|
|
261 |
$form->{"select$item"} =~ s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
|
268 |
262 |
}
|
269 |
263 |
|
270 |
264 |
$form->{forex} = $form->check_exchangerate( \%myconfig, $form->{currency}, $form->{transdate}, 'buy');
|
271 |
265 |
$form->{exchangerate} = $form->{forex} if $form->{forex};
|
272 |
266 |
|
273 |
|
# format amounts
|
274 |
|
$form->{exchangerate} = $form->{exchangerate} ? $form->format_amount(\%myconfig, $form->{exchangerate}) : '';
|
275 |
|
$form->{creditlimit} = $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
|
276 |
|
$form->{creditremaining} = $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
|
277 |
|
|
278 |
|
$exchangerate = qq|
|
279 |
|
<input type=hidden name=forex value=$form->{forex}>
|
280 |
|
|;
|
281 |
|
if ($form->{defaultcurrency} && ($form->{currency} ne $form->{defaultcurrency})) {
|
282 |
|
if ($form->{forex}) {
|
283 |
|
$exchangerate .= qq|
|
284 |
|
<th align=right>| . $locale->text('Exchangerate') . qq|</th>
|
285 |
|
<td><input type=hidden name=exchangerate value=$form->{exchangerate}>$form->{exchangerate}</td>
|
286 |
|
|;
|
287 |
|
} else {
|
288 |
|
$exchangerate .= qq|
|
289 |
|
<th align=right>| . $locale->text('Exchangerate') . qq|</th>
|
290 |
|
<td><input name=exchangerate size=10 value=$form->{exchangerate}></td>
|
291 |
|
|;
|
292 |
|
}
|
293 |
|
}
|
294 |
|
|
295 |
|
$taxincluded = qq|
|
296 |
|
<tr>
|
297 |
|
<td align=right><input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}></td>
|
298 |
|
<th align=left nowrap>| . $locale->text('Tax Included') . qq|</th>
|
299 |
|
</tr>
|
300 |
|
|;
|
301 |
|
|
302 |
|
if (($rows = $form->numtextrows($form->{notes}, 50)) < 2) {
|
303 |
|
$rows = 2;
|
304 |
|
}
|
305 |
|
$notes =
|
306 |
|
qq|<textarea name=notes rows=$rows cols=50 wrap=soft>$form->{notes}</textarea>|;
|
307 |
|
|
308 |
|
$department = qq|
|
309 |
|
<tr>
|
310 |
|
<th align="right" nowrap>| . $locale->text('Department') . qq|</th>
|
311 |
|
<td colspan=3><select name=department>$form->{selectdepartment}</select>
|
312 |
|
<input type=hidden name=selectdepartment value="$form->{selectdepartment}">
|
313 |
|
</td>
|
314 |
|
</tr>
|
315 |
|
| if $form->{selectdepartment};
|
316 |
|
|
317 |
|
my $n = ($form->{creditremaining} =~ /-/) ? "0" : "1";
|
318 |
|
|
319 |
|
$customer = ($form->{selectcustomer})
|
320 |
|
? qq|<select name="customer" onchange="document.getElementById('update_button').click();">$form->{selectcustomer}</select>|
|
321 |
|
: qq|<input name=customer value="$form->{customer}" size=35>|;
|
322 |
|
|
323 |
|
$employee = qq|
|
324 |
|
<input type=hidden name=employee value="$form->{employee}">
|
325 |
|
|;
|
326 |
|
|
327 |
|
if ($form->{selectemployee}) {
|
328 |
|
$employee = qq|
|
329 |
|
<tr>
|
330 |
|
<th align=right nowrap>| . $locale->text('Salesperson') . qq|</th>
|
331 |
|
<td colspan=2><select name=employee>$form->{selectemployee}</select></td>
|
332 |
|
<input type=hidden name=selectemployee value="$form->{selectemployee}">
|
333 |
|
</tr>
|
334 |
|
|;
|
335 |
|
}
|
|
267 |
$rows = max 2, $form->numtextrows($form->{notes}, 50);
|
336 |
268 |
|
337 |
|
my @old_project_ids = ();
|
338 |
|
map({ push(@old_project_ids, $form->{"project_id_$_"})
|
339 |
|
if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
|
|
269 |
my @old_project_ids = grep { $_ } map { $form->{"project_id_$_"} } 1..$form->{rowcount};
|
340 |
270 |
|
341 |
271 |
$form->get_lists("projects" => { "key" => "ALL_PROJECTS",
|
342 |
272 |
"all" => 0,
|
... | ... | |
346 |
276 |
"taxcharts" => { "key" => "ALL_TAXCHARTS",
|
347 |
277 |
"module" => "AR" },);
|
348 |
278 |
|
349 |
|
map({ $_->{link_split} = [ split(/:/, $_->{link}) ]; }
|
350 |
|
@{ $form->{ALL_CHARTS} });
|
|
279 |
$_->{link_split} = { map { $_ => 1 } split/:/, $_->{link} } for @{ $form->{ALL_CHARTS} };
|
351 |
280 |
|
352 |
|
my %project_labels = ();
|
353 |
|
my @project_values = ("");
|
354 |
|
foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
|
355 |
|
push(@project_values, $item->{"id"});
|
356 |
|
$project_labels{$item->{"id"}} = $item->{"projectnumber"};
|
357 |
|
}
|
|
281 |
my %project_labels = map { $_->{id} => $_->{projectnumber} } @{ $form->{"ALL_PROJECTS"} };
|
358 |
282 |
|
359 |
|
my (%AR_amount_labels, @AR_amount_values);
|
360 |
|
my (%AR_labels, @AR_values);
|
361 |
|
my (%AR_paid_labels, @AR_paid_values);
|
|
283 |
my (@AR_amount_values);
|
|
284 |
my (@AR_values);
|
|
285 |
my (@AR_paid_values);
|
|
286 |
my %chart_labels;
|
362 |
287 |
my %charts;
|
363 |
288 |
my $taxchart_init;
|
364 |
289 |
|
365 |
290 |
foreach my $item (@{ $form->{ALL_CHARTS} }) {
|
366 |
|
if (grep({ $_ eq "AR_amount" } @{ $item->{link_split} })) {
|
|
291 |
if ($item->{link_split}{AR_amount}) {
|
367 |
292 |
$taxchart_init = $item->{tax_id} if ($taxchart_init eq "");
|
368 |
293 |
my $key = "$item->{accno}--$item->{tax_id}";
|
369 |
294 |
push(@AR_amount_values, $key);
|
370 |
|
$AR_amount_labels{$key} =
|
371 |
|
"$item->{accno}--$item->{description}";
|
372 |
|
|
373 |
|
} elsif (grep({ $_ eq "AR" } @{ $item->{link_split} })) {
|
|
295 |
} elsif ($item->{link_split}{AR}) {
|
374 |
296 |
push(@AR_values, $item->{accno});
|
375 |
|
$AR_labels{$item->{accno}} = "$item->{accno}--$item->{description}";
|
376 |
|
|
377 |
|
} elsif (grep({ $_ eq "AR_paid" } @{ $item->{link_split} })) {
|
|
297 |
} elsif ($item->{link_split}{AR_paid}) {
|
378 |
298 |
push(@AR_paid_values, $item->{accno});
|
379 |
|
$AR_paid_labels{$item->{accno}} =
|
380 |
|
"$item->{accno}--$item->{description}";
|
381 |
299 |
}
|
382 |
300 |
|
|
301 |
# weirdness for AR_amount
|
|
302 |
$chart_labels{$item->{accno}} = "$item->{accno}--$item->{description}";
|
|
303 |
$chart_labels{"$item->{accno}--$item->{tax_id}"} = "$item->{accno}--$item->{description}";
|
|
304 |
|
383 |
305 |
$charts{$item->{accno}} = $item;
|
384 |
306 |
}
|
385 |
307 |
|
... | ... | |
390 |
312 |
my $key = "$item->{id}--$item->{rate}";
|
391 |
313 |
$taxchart_init = $key if ($taxchart_init eq $item->{id});
|
392 |
314 |
push(@taxchart_values, $key);
|
393 |
|
$taxchart_labels{$key} =
|
394 |
|
"$item->{taxdescription} " . ($item->{rate} * 100) . ' %';
|
|
315 |
$taxchart_labels{$key} = "$item->{taxdescription} " . ($item->{rate} * 100) . ' %';
|
395 |
316 |
$taxcharts{$item->{id}} = $item;
|
396 |
317 |
}
|
397 |
318 |
|
398 |
319 |
$form->{fokus} = "arledger.customer";
|
399 |
320 |
|
400 |
|
# use JavaScript Calendar or not
|
401 |
|
$form->{jsscript} = 1;
|
402 |
|
$jsscript = "";
|
403 |
|
if ($form->{jsscript}) {
|
404 |
|
|
405 |
|
# with JavaScript Calendar
|
406 |
|
$button1 = qq|
|
407 |
|
<td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value="$form->{transdate}" onBlur=\"check_right_date_format(this)\"></td>
|
408 |
|
<td><input type=button name=transdate id="trigger1" value=|
|
409 |
|
. $locale->text('button') . qq|></td>
|
410 |
|
|;
|
411 |
|
$button2 = qq|
|
412 |
|
<td><input name=duedate id=duedate size=11 title="$myconfig{dateformat}" value="$form->{duedate}" onBlur=\"check_right_date_format(this)\"></td>
|
413 |
|
<td><input type=button name=duedate id="trigger2" value=|
|
414 |
|
. $locale->text('button') . qq|></td></td>
|
415 |
|
|;
|
416 |
|
|
417 |
|
#write Trigger
|
418 |
|
$jsscript =
|
419 |
|
Form->write_trigger(\%myconfig, "2", "transdate", "BL", "trigger1",
|
420 |
|
"duedate", "BL", "trigger2");
|
421 |
|
} else {
|
422 |
|
|
423 |
|
# without JavaScript Calendar
|
424 |
|
$button1 =
|
425 |
|
qq|<td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value="$form->{transdate}" onBlur=\"check_right_date_format(this)\"></td>|;
|
426 |
|
$button2 =
|
427 |
|
qq|<td><input name=duedate id=duedate size=11 title="$myconfig{dateformat}" value="$form->{duedate}" onBlur=\"check_right_date_format(this)\"></td>|;
|
428 |
|
}
|
429 |
|
|
430 |
321 |
my $follow_up_vc = $form->{customer};
|
431 |
322 |
$follow_up_vc =~ s/--.*?//;
|
432 |
323 |
my $follow_up_trans_info = "$form->{invnumber} ($follow_up_vc)";
|
433 |
324 |
|
434 |
325 |
$form->{javascript} .=
|
435 |
|
qq|<script type="text/javascript" src="js/common.js"></script>| .
|
436 |
326 |
qq|<script type="text/javascript" src="js/show_vc_details.js"></script>| .
|
437 |
327 |
qq|<script type="text/javascript" src="js/follow_up.js"></script>|;
|
438 |
328 |
|
439 |
|
my $globalprojectnumber =
|
440 |
|
NTI($cgi->popup_menu('-name' => "globalproject_id",
|
441 |
|
'-values' => \@project_values,
|
442 |
|
'-labels' => \%project_labels,
|
443 |
|
'-default' => $form->{"globalproject_id"} ));
|
444 |
|
|
445 |
|
$form->header;
|
446 |
329 |
$onload = qq|focus()|;
|
447 |
|
$onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
|
448 |
330 |
$onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
|
449 |
|
print qq|
|
450 |
|
<body onLoad="$onload">
|
451 |
|
|
452 |
|
<form method=post name="arledger" action=$form->{script}>
|
453 |
|
|
454 |
|
<input type=hidden name=id value=$form->{id}>
|
455 |
|
<input type=hidden name=sort value=$form->{sort}>
|
456 |
|
<input type=hidden name=closedto value=$form->{closedto}>
|
457 |
|
<input type=hidden name=locked value=$form->{locked}>
|
458 |
|
<input type=hidden name=title value="$title">
|
459 |
|
<input type="hidden" name="follow_up_trans_id_1" value="| . H($form->{id}) . qq|">
|
460 |
|
<input type="hidden" name="follow_up_trans_type_1" value="ar_transaction">
|
461 |
|
<input type="hidden" name="follow_up_trans_info_1" value="| . H($follow_up_trans_info) . qq|">
|
462 |
|
<input type="hidden" name="follow_up_rowcount" value="1">
|
463 |
|
|
464 |
|
| . ($form->{saved_message} ? qq|<p>$form->{saved_message}</p>| : "") . qq|
|
465 |
|
|
466 |
|
<table width=100%>
|
467 |
|
<tr class=listtop>
|
468 |
|
<th class=listtop>$form->{title}</th>
|
469 |
|
</tr>
|
470 |
|
<tr height="5"></tr>
|
471 |
|
<tr valign=top>
|
472 |
|
<td>
|
473 |
|
<table width=100%>
|
474 |
|
<tr valign=top>
|
475 |
|
<td>
|
476 |
|
<table>
|
477 |
|
<tr>
|
478 |
|
<th align="right" nowrap>| . $locale->text('Customer') . qq|</th>
|
479 |
|
<td colspan=3>$customer <input type="button" value="| . $locale->text('Details (one letter abbreviation)') . qq|" onclick="show_vc_details('customer')"></td>
|
480 |
|
<input type=hidden name=selectcustomer value="$form->{selectcustomer}">
|
481 |
|
<input type=hidden name=oldcustomer value="$form->{oldcustomer}">
|
482 |
|
<input type=hidden name=customer_id value="$form->{customer_id}">
|
483 |
|
<input type=hidden name=terms value=$form->{terms}>
|
484 |
|
</tr>
|
485 |
|
<tr>
|
486 |
|
<td></td>
|
487 |
|
<td colspan=3>
|
488 |
|
<table width=100%>
|
489 |
|
<tr>
|
490 |
|
<th align=left nowrap>| . $locale->text('Credit Limit') . qq|</th>
|
491 |
|
<td>$form->{creditlimit}</td>
|
492 |
|
<th align=left nowrap>| . $locale->text('Remaining') . qq|</th>
|
493 |
|
<td class="plus$n">$form->{creditremaining}</td>
|
494 |
|
<input type=hidden name=creditlimit value=$form->{creditlimit}>
|
495 |
|
<input type=hidden name=creditremaining value=$form->{creditremaining}>
|
496 |
|
</tr>
|
497 |
|
</table>
|
498 |
|
</td>
|
499 |
|
</tr>
|
500 |
|
<tr>
|
501 |
|
<th align=right>| . $locale->text('Currency') . qq|</th>
|
502 |
|
<td><select name=currency>$form->{selectcurrency}</select></td>
|
503 |
|
<input type=hidden name=selectcurrency value="$form->{selectcurrency}">
|
504 |
|
<input type=hidden name=defaultcurrency value=$form->{defaultcurrency}>
|
505 |
|
<input type=hidden name=fxgain_accno value=$form->{fxgain_accno}>
|
506 |
|
<input type=hidden name=fxloss_accno value=$form->{fxloss_accno}>
|
507 |
|
$exchangerate
|
508 |
|
</tr>
|
509 |
|
$department
|
510 |
|
$taxincluded
|
511 |
|
</table>
|
512 |
|
</td>
|
513 |
|
<td align=right>
|
514 |
|
<table>
|
515 |
|
$employee
|
516 |
|
<tr>
|
517 |
|
<th align=right nowrap>| . $locale->text('Invoice Number') . qq|</th>
|
518 |
|
<td><input name=invnumber size=11 value="$form->{invnumber}"></td>
|
519 |
|
</tr>
|
520 |
|
<tr>
|
521 |
|
<th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
|
522 |
|
<td><input name=ordnumber size=11 value="$form->{ordnumber}"></td>
|
523 |
|
</tr>
|
524 |
|
<tr>
|
525 |
|
<th align=right nowrap>| . $locale->text('Invoice Date') . qq|</th>
|
526 |
|
$button1
|
527 |
|
</tr>
|
528 |
|
<tr>
|
529 |
|
<th align=right nowrap>| . $locale->text('Due Date') . qq|</th>
|
530 |
|
$button2
|
531 |
|
</tr>
|
532 |
|
<tr>
|
533 |
|
<th align=right nowrap>| . $locale->text('Project Number') . qq|</th>
|
534 |
|
<td>$globalprojectnumber</td>
|
535 |
|
</tr>
|
536 |
|
</table>
|
537 |
|
</td>
|
538 |
|
</tr>
|
539 |
|
</table>
|
540 |
|
</td>
|
541 |
|
</tr>
|
542 |
|
|
543 |
|
$jsscript
|
544 |
|
<input type=hidden name=rowcount value=$form->{rowcount}>
|
545 |
|
<tr>
|
546 |
|
<td>
|
547 |
|
<table width=100%>
|
548 |
|
<tr class=listheading>
|
549 |
|
<th class=listheading style="width:15%">|
|
550 |
|
. $locale->text('Account') . qq|</th>
|
551 |
|
<th class=listheading style="width:10%">|
|
552 |
|
. $locale->text('Amount') . qq|</th>
|
553 |
|
<th class=listheading style="width:10%">|
|
554 |
|
. $locale->text('Tax') . qq|</th>
|
555 |
|
<th class=listheading style="width:5%">|
|
556 |
|
. $locale->text('Taxkey') . qq|</th>
|
557 |
|
<th class=listheading style="width:10%">|
|
558 |
|
. $locale->text('Project') . qq|</th>
|
559 |
|
</tr>
|
560 |
|
|;
|
561 |
331 |
|
562 |
|
$amount = $locale->text('Amount');
|
563 |
|
$project = $locale->text('Project');
|
|
332 |
# $amount = $locale->text('Amount');
|
|
333 |
# $project = $locale->text('Project');
|
564 |
334 |
|
|
335 |
my @transactions;
|
565 |
336 |
for my $i (1 .. $form->{rowcount}) {
|
566 |
|
|
567 |
|
# format amounts
|
568 |
|
$form->{"amount_$i"} =
|
569 |
|
$form->format_amount(\%myconfig, $form->{"amount_$i"}, 2);
|
570 |
|
$form->{"tax_$i"} = $form->format_amount(\%myconfig, $form->{"tax_$i"}, 2);
|
|
337 |
my $transaction = {
|
|
338 |
amount => $form->{"amount_$i"},
|
|
339 |
tax => $form->{"tax$i"},
|
|
340 |
project_id => $form->{"project_id_$i"},
|
|
341 |
};
|
571 |
342 |
|
572 |
343 |
my $selected_accno_full;
|
573 |
344 |
my ($accno_row) = split(/--/, $form->{"AR_amount_$i"});
|
... | ... | |
593 |
364 |
}
|
594 |
365 |
}
|
595 |
366 |
|
596 |
|
$selectAR_amount =
|
|
367 |
$transaction->{selectAR_amount} =
|
597 |
368 |
NTI($cgi->popup_menu('-name' => "AR_amount_$i",
|
598 |
369 |
'-id' => "AR_amount_$i",
|
599 |
370 |
'-style' => 'width:400px',
|
600 |
371 |
'-onChange' => "setTaxkey(this, $i)",
|
601 |
372 |
'-values' => \@AR_amount_values,
|
602 |
|
'-labels' => \%AR_amount_labels,
|
|
373 |
'-labels' => \%chart_labels,
|
603 |
374 |
'-default' => $selected_accno_full))
|
604 |
375 |
. $cgi->hidden('-name' => "previous_AR_amount_$i",
|
605 |
376 |
'-default' => $selected_accno_full);
|
606 |
377 |
|
607 |
|
$tax = qq|<td>| .
|
|
378 |
$transaction->{tax} =
|
608 |
379 |
NTI($cgi->popup_menu('-name' => "taxchart_$i",
|
609 |
380 |
'-id' => "taxchart_$i",
|
610 |
381 |
'-style' => 'width:200px',
|
611 |
382 |
'-values' => \@taxchart_values,
|
612 |
383 |
'-labels' => \%taxchart_labels,
|
613 |
|
'-default' => $selected_taxchart))
|
614 |
|
. qq|</td>|;
|
|
384 |
'-default' => $selected_taxchart));
|
615 |
385 |
|
616 |
|
my $projectnumber =
|
617 |
|
NTI($cgi->popup_menu('-name' => "project_id_$i",
|
618 |
|
'-values' => \@project_values,
|
619 |
|
'-labels' => \%project_labels,
|
620 |
|
'-default' => $form->{"project_id_$i"} ));
|
621 |
|
|
622 |
|
print qq|
|
623 |
|
<tr>
|
624 |
|
<td>$selectAR_amount</td>
|
625 |
|
<td><input name="amount_$i" size=10 value=$form->{"amount_$i"}></td>
|
626 |
|
<td><input type="hidden" name="tax_$i" value="$form->{"tax_$i"}">$form->{"tax_$i"}</td>
|
627 |
|
$tax
|
628 |
|
<td>$projectnumber</td>
|
629 |
|
</tr>
|
630 |
|
|;
|
631 |
|
$amount = "";
|
632 |
|
$project = "";
|
|
386 |
push @transactions, $transaction;
|
633 |
387 |
}
|
634 |
388 |
|
635 |
389 |
$form->{invtotal_unformatted} = $form->{invtotal};
|
636 |
|
$form->{invtotal} = $form->format_amount(\%myconfig, $form->{invtotal}, 2);
|
637 |
390 |
|
638 |
391 |
$ARselected =
|
639 |
392 |
NTI($cgi->popup_menu('-name' => "ARselected", '-id' => "ARselected",
|
640 |
393 |
'-style' => 'width:400px',
|
641 |
|
'-values' => \@AR_values, '-labels' => \%AR_labels,
|
|
394 |
'-values' => \@AR_values, '-labels' => \%chart_labels,
|
642 |
395 |
'-default' => $form->{ARselected}));
|
643 |
396 |
|
644 |
|
print qq|
|
645 |
|
<tr>
|
646 |
|
<td colspan=6>
|
647 |
|
<hr noshade>
|
648 |
|
</td>
|
649 |
|
</tr>
|
650 |
|
<tr>
|
651 |
|
<td>${ARselected}</td>
|
652 |
|
<th align=left>$form->{invtotal}</th>
|
653 |
|
|
654 |
|
<input type=hidden name=oldinvtotal value=$form->{oldinvtotal}>
|
655 |
|
<input type=hidden name=oldtotalpaid value=$form->{oldtotalpaid}>
|
656 |
|
|
657 |
|
<input type=hidden name=taxaccounts value="$form->{taxaccounts}">
|
658 |
|
|
659 |
|
<td colspan=4></td>
|
660 |
|
|
661 |
|
|
662 |
|
</tr>
|
663 |
|
</table>
|
664 |
|
</td>
|
665 |
|
</tr>
|
666 |
|
<tr>
|
667 |
|
<td>
|
668 |
|
<table width=100%>
|
669 |
|
<tr>
|
670 |
|
<th align=left width=1%>| . $locale->text('Notes') . qq|</th>
|
671 |
|
<td align=left>$notes</td>
|
672 |
|
</tr>
|
673 |
|
</table>
|
674 |
|
</td>
|
675 |
|
</tr>
|
676 |
|
<tr>
|
677 |
|
<td>
|
678 |
|
<table width=100%>
|
679 |
|
<tr class=listheading>
|
680 |
|
<th colspan=7 class=listheading>|
|
681 |
|
. $locale->text('Incoming Payments') . qq|</th>
|
682 |
|
</tr>
|
683 |
|
|;
|
684 |
397 |
|
685 |
|
if ($form->{defaultcurrency} && ($form->{currency} eq $form->{defaultcurrency})) {
|
686 |
|
@column_index = qw(datepaid source memo paid AR_paid paid_project_id);
|
687 |
|
} else {
|
688 |
|
@column_index = qw(datepaid source memo paid exchangerate AR_paid paid_project_id);
|
689 |
|
}
|
690 |
|
|
691 |
|
$column_data{datepaid} = "<th>" . $locale->text('Date') . "</th>";
|
692 |
|
$column_data{paid} = "<th>" . $locale->text('Amount') . "</th>";
|
693 |
|
$column_data{exchangerate} = "<th>" . $locale->text('Exch') . "</th>";
|
694 |
|
$column_data{AR_paid} = "<th>" . $locale->text('Account') . "</th>";
|
695 |
|
$column_data{source} = "<th>" . $locale->text('Source') . "</th>";
|
696 |
|
$column_data{memo} = "<th>" . $locale->text('Memo') . "</th>";
|
697 |
|
$column_data{paid_project_id} = "<th>" . $locale->text('Project Number') . "</th>";
|
698 |
|
|
699 |
|
print "
|
700 |
|
<tr>
|
701 |
|
";
|
702 |
|
map { print "$column_data{$_}\n" } @column_index;
|
703 |
|
print "
|
704 |
|
</tr>
|
705 |
|
";
|
|
398 |
$form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
|
706 |
399 |
|
707 |
|
my @triggers = ();
|
708 |
|
$form->{totalpaid} = 0;
|
|
400 |
my $now = $form->current_date(\%myconfig);
|
709 |
401 |
|
710 |
|
$form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
|
|
402 |
my @payments;
|
711 |
403 |
for my $i (1 .. $form->{paidaccounts}) {
|
712 |
|
print "
|
713 |
|
<tr>
|
714 |
|
";
|
715 |
|
|
716 |
|
$selectAR_paid =
|
|
404 |
my $payment = {
|
|
405 |
paid => $form->{"paid_$i"},
|
|
406 |
exchangerate => $form->{"exchangerate_$i"} || '',
|
|
407 |
gldate => $form->{"gldate_$i"},
|
|
408 |
acc_trans_id => $form->{"acc_trans_id_$i"},
|
|
409 |
source => $form->{"source_$i"},
|
|
410 |
memo => $form->{"memo_$i"},
|
|
411 |
AR_paid => $form->{"AR_paid_$i"},
|
|
412 |
forex => $form->{"forex_$i"},
|
|
413 |
datepaid => $form->{"datepaid_$i"},
|
|
414 |
paid_project_id => $form->{"paid_project_id_$i"},
|
|
415 |
gldate => $form->{"gldate_$i"},
|
|
416 |
};
|
|
417 |
|
|
418 |
$payment->{selectAR_paid} =
|
717 |
419 |
NTI($cgi->popup_menu('-name' => "AR_paid_$i",
|
718 |
420 |
'-id' => "AR_paid_$i",
|
719 |
421 |
'-values' => \@AR_paid_values,
|
720 |
|
'-labels' => \%AR_paid_labels,
|
721 |
|
'-default' => $form->{"AR_paid_$i"}));
|
|
422 |
'-labels' => \%chart_labels,
|
|
423 |
'-default' => $payment->{AR_paid}));
|
722 |
424 |
|
723 |
|
$form->{totalpaid} += $form->{"paid_$i"};
|
724 |
425 |
|
725 |
|
# format amounts
|
726 |
|
if ($form->{"paid_$i"}) {
|
727 |
|
$form->{"paid_$i"} =
|
728 |
|
$form->format_amount(\%myconfig, $form->{"paid_$i"}, 2);
|
729 |
|
}
|
730 |
|
if ($form->{"exchangerate_$i"} == 0) {
|
731 |
|
$form->{"exchangerate_$i"} = "";
|
732 |
|
} else {
|
733 |
|
$form->{"exchangerate_$i"} =
|
734 |
|
$form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
|
735 |
|
}
|
736 |
426 |
|
737 |
|
print qq|<input type=hidden name="acc_trans_id_$i" value=$form->{"acc_trans_id_$i"}>\n|;
|
738 |
|
print qq|<input type=hidden name="gldate_$i" value=$form->{"gldate_$i"}>\n|;
|
739 |
|
my $changeable = 1;
|
740 |
|
if ($::lx_office_conf{features}->{payments_changeable} == 0) {
|
741 |
|
# never
|
742 |
|
$changeable = ($form->{"acc_trans_id_$i"})? 0 : 1;
|
743 |
|
}
|
744 |
|
if ($::lx_office_conf{features}->{payments_changeable} == 2) {
|
745 |
|
# on the same day
|
746 |
|
$changeable = (($form->{"gldate_$i"} eq '') || $form->current_date(\%myconfig) eq $form->{"gldate_$i"});
|
747 |
|
}
|
748 |
|
|
749 |
|
$exchangerate = qq| |;
|
750 |
|
if ($form->{defaultcurrency} && ($form->{currency} ne $form->{defaultcurrency})) {
|
751 |
|
if ($form->{"forex_$i"}) {
|
752 |
|
$exchangerate =
|
753 |
|
qq|<input type=hidden name="exchangerate_$i" value=$form->{"exchangerate_$i"}>$form->{"exchangerate_$i"}|;
|
754 |
|
} else {
|
755 |
|
if ($changeable) {
|
756 |
|
$exchangerate =
|
757 |
|
qq|<input name="exchangerate_$i" size=10 value=$form->{"exchangerate_$i"}>|;
|
758 |
|
} else {
|
759 |
|
$exchangerate =
|
760 |
|
qq|<input type=hidden name="exchangerate_$i" value=$form->{"exchangerate_$i"}>$form->{"exchangerate_$i"}|;
|
761 |
|
}
|
762 |
|
}
|
763 |
|
}
|
|
427 |
$payment->{changeable} =
|
|
428 |
$::lx_office_conf{features}->{payments_changeable} == 0 ? !$payment->{acc_trans_id} # never
|
|
429 |
: $::lx_office_conf{features}->{payments_changeable} == 2 ? $payment->{gldate} eq '' || $payment->{gldate} eq $now
|
|
430 |
: 1;
|
764 |
431 |
|
765 |
|
$exchangerate .= qq|
|
766 |
|
<input type=hidden name="forex_$i" value=$form->{"forex_$i"}>
|
767 |
|
|;
|
768 |
|
|
769 |
|
my $datepaid;
|
770 |
|
if ($changeable) {
|
771 |
|
$datepaid = qq|<td align=center><input name="datepaid_$i" id="datepaid_$i" size=11 value="$form->{"datepaid_$i"}" onBlur=\"check_right_date_format(this)\">
|
772 |
|
<input type="button" name="datepaid_$i" id="trigger_datepaid_$i" value="?"></td>|;
|
773 |
|
} else {
|
774 |
|
$datepaid = qq|<td align=center>$form->{"datepaid_$i"}</td>|.
|
775 |
|
qq|<input type=hidden name="datepaid_$i" value=$form->{"datepaid_$i"}>|;
|
776 |
|
}
|
777 |
|
|
778 |
|
my $paid;
|
779 |
|
if ($changeable) {
|
780 |
|
$paid = qq|<td align=center><input name="paid_$i" size=11 value="$form->{"paid_$i"}" onBlur=\"check_right_number_format(this)\"></td>|;
|
781 |
|
} else {
|
782 |
|
$paid = qq|<td align=center>$form->{"paid_$i"}</td>|.
|
783 |
|
qq|<input type=hidden name="paid_$i" value=$form->{"paid_$i"}>|;
|
784 |
|
}
|
785 |
|
|
786 |
|
my $source;
|
787 |
|
if ($changeable) {
|
788 |
|
$source = qq|<td align=center><input name="source_$i" size=11 value="$form->{"source_$i"}"></td>|;
|
789 |
|
} else {
|
790 |
|
$source = qq|<td align=center>$form->{"source_$i"}</td>|.
|
791 |
|
qq|<input type=hidden name="source_$i" value=$form->{"source_$i"}>|;
|
792 |
|
}
|
793 |
|
|
794 |
|
my $memo;
|
795 |
|
if ($changeable) {
|
796 |
|
$memo = qq|<td align=center><input name="memo_$i" size=11 value="$form->{"memo_$i"}"></td>|;
|
797 |
|
} else {
|
798 |
|
$memo = qq|<td align=center>$form->{"memo_$i"}</td>|.
|
799 |
|
qq|<input type=hidden name="memo_$i" value=$form->{"memo_$i"}>|;
|
800 |
|
}
|
801 |
|
|
802 |
|
my $AR_paid;
|
803 |
|
if ($changeable) {
|
804 |
|
$AR_paid = qq|<td align=center>${selectAR_paid}</td>|;
|
805 |
|
} else {
|
806 |
|
$AR_paid = qq|<td align=center>$form->{"AR_paid_$i"}</td>|.
|
807 |
|
qq|<input type=hidden name="AR_paid_$i" value=$form->{"AR_paid_$i"}>|;
|
808 |
|
}
|
809 |
|
|
810 |
|
my $paid_project_id;
|
811 |
|
if ($changeable) {
|
812 |
|
$paid_project_id =
|
813 |
|
qq|<td>|
|
814 |
|
. NTI($cgi->popup_menu('-name' => "paid_project_id_$i",
|
815 |
|
'-values' => \@project_values,
|
816 |
|
'-labels' => \%project_labels,
|
817 |
|
'-default' => $form->{"paid_project_id_$i"} ))
|
818 |
|
. qq|</td>|;
|
819 |
|
} else {
|
820 |
|
my $projectnumber = $project_labels{$form->{"paid_project_id_$i"}};
|
821 |
|
$paid_project_id = qq|<td>$projectnumber</td>|.
|
822 |
|
qq|<input type=hidden name="paid_project_id_$i" value=$form->{"paid_project_id_$i"}>|;
|
823 |
|
}
|
824 |
|
|
825 |
|
$column_data{paid} = $paid;
|
826 |
|
$column_data{AR_paid} = $AR_paid;
|
827 |
|
$column_data{exchangerate} = qq|<td align=center>$exchangerate</td>|;
|
828 |
|
$column_data{datepaid} = $datepaid;
|
829 |
|
$column_data{source} = $source;
|
830 |
|
$column_data{memo} = $memo;
|
831 |
|
$column_data{paid_project_id} = $paid_project_id;
|
832 |
|
|
833 |
|
map { print qq|$column_data{$_}\n| } @column_index;
|
834 |
|
|
835 |
|
print "
|
836 |
|
</tr>
|
837 |
|
";
|
838 |
|
if ($changeable) {
|
839 |
|
push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i");
|
840 |
|
}
|
|
432 |
push @payments, $payment;
|
841 |
433 |
}
|
842 |
434 |
|
843 |
|
my $paid_missing = $form->{invtotal_unformatted} - $form->{totalpaid};
|
|
435 |
$form->{totalpaid} = sum map { $_->{paid} } @payments;
|
844 |
436 |
|
845 |
|
print qq|
|
846 |
|
<tr>
|
847 |
|
<td></td>
|
848 |
|
<td></td>
|
849 |
|
<td align="center">| . $locale->text('Total') . qq|</td>
|
850 |
|
<td align="center">| . H($form->format_amount(\%myconfig, $form->{totalpaid}, 2)) . qq|</td>
|
851 |
|
</tr>
|
852 |
|
<tr>
|
853 |
|
<td></td>
|
854 |
|
<td></td>
|
855 |
|
<td align="center">| . $locale->text('Missing amount') . qq|</td>
|
856 |
|
<td align="center">| . H($form->format_amount(\%myconfig, $paid_missing, 2)) . qq|</td>
|
857 |
|
</tr>
|
858 |
|
| . $form->write_trigger(\%myconfig, scalar(@triggers) / 3, @triggers) .
|
859 |
|
qq|
|
860 |
|
<input type=hidden name=paidaccounts value=$form->{paidaccounts}>
|
861 |
|
|
862 |
|
</table>
|
863 |
|
</td>
|
864 |
|
</tr>
|
865 |
|
<tr>
|
866 |
|
<td><hr size=3 noshade></td>
|
867 |
|
</tr>
|
868 |
|
</table>
|
869 |
|
|;
|
|
437 |
$form->header;
|
|
438 |
print $::form->parse_html_template('ar/form_header', {
|
|
439 |
paid_missing => $::form->{invtotal} - $::form->{totalpaid},
|
|
440 |
show_exch => ($::form->{defaultcurrency} && ($::form->{currency} ne $::form->{defaultcurrency})),
|
|
441 |
payments => \@payments,
|
|
442 |
transactions => \@transactions,
|
|
443 |
project_labels => \%project_labels,
|
|
444 |
rows => $rows,
|
|
445 |
ARselected => $ARselected,
|
|
446 |
onload => $onload,
|
|
447 |
title_str => $title,
|
|
448 |
follow_up_trans_info => $follow_up_trans_info,
|
|
449 |
});
|
870 |
450 |
|
871 |
451 |
$main::lxdebug->leave_sub();
|
872 |
452 |
}
|
ar form_header nach template ausgelagert