1 #=====================================================================
4 # Based on SQL-Ledger Version 2.1.9
5 # Web http://www.lx-office.org
7 #=====================================================================
8 # SQL-Ledger Accounting
9 # Copyright (c) 1998-2002
11 # Author: Dieter Simader
12 # Email: dsimader@sql-ledger.org
13 # Web: http://www.sql-ledger.org
15 # Contributors: Antonio Gallardo <agssa@ibw.com.ni>
16 # Benjamin Lee <benjaminlee@consultant.com>
17 # Philip Reetz <p.reetz@linet-services.de>
20 # This program is free software; you can redistribute it and/or modify
21 # it under the terms of the GNU General Public License as published by
22 # the Free Software Foundation; either version 2 of the License, or
23 # (at your option) any later version.
25 # This program is distributed in the hope that it will be useful,
26 # but WITHOUT ANY WARRANTY; without even the implied warranty of
27 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 # GNU General Public License for more details.
29 # You should have received a copy of the GNU General Public License
30 # along with this program; if not, write to the Free Software
31 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
32 #======================================================================
34 # module for preparing Income Statement and Balance Sheet
36 #======================================================================
38 use POSIX qw(strftime);
44 use SL::ReportGenerator;
46 require "bin/mozilla/arap.pl";
47 require "bin/mozilla/common.pl";
48 require "bin/mozilla/reportgenerator.pl";
54 # this is for our long dates
55 # $locale->text('January')
56 # $locale->text('February')
57 # $locale->text('March')
58 # $locale->text('April')
59 # $locale->text('May ')
60 # $locale->text('June')
61 # $locale->text('July')
62 # $locale->text('August')
63 # $locale->text('September')
64 # $locale->text('October')
65 # $locale->text('November')
66 # $locale->text('December')
68 # this is for our short month
69 # $locale->text('Jan')
70 # $locale->text('Feb')
71 # $locale->text('Mar')
72 # $locale->text('Apr')
73 # $locale->text('May')
74 # $locale->text('Jun')
75 # $locale->text('Jul')
76 # $locale->text('Aug')
77 # $locale->text('Sep')
78 # $locale->text('Oct')
79 # $locale->text('Nov')
80 # $locale->text('Dec')
82 # $locale->text('Balance Sheet')
83 # $locale->text('Income Statement')
84 # $locale->text('Trial Balance')
85 # $locale->text('AR Aging')
86 # $locale->text('AP Aging')
87 # $locale->text('Tax collected')
88 # $locale->text('Tax paid')
89 # $locale->text('Receipts')
90 # $locale->text('Payments')
91 # $locale->text('Project Transactions')
92 # $locale->text('Non-taxable Sales')
93 # $locale->text('Non-taxable Purchases')
96 $lxdebug->enter_sub();
98 %title = ('balance_sheet' => 'Balance Sheet',
99 'income_statement' => 'Income Statement',
100 'trial_balance' => 'Trial Balance',
101 'ar_aging' => 'AR Aging',
102 'ap_aging' => 'Offene Verbindlichkeiten',
103 'tax_collected' => 'Tax collected',
104 'tax_paid' => 'Tax paid',
105 'nontaxable_sales' => 'Non-taxable Sales',
106 'nontaxable_purchases' => 'Non-taxable Purchases',
107 'receipts' => 'Receipts',
108 'payments' => 'Payments',
109 'projects' => 'Project Transactions',
110 'bwa' => 'Betriebswirtschaftliche Auswertung',
111 'ustva' => 'Umsatzsteuervoranmeldung',);
113 $form->{title} = $locale->text($title{ $form->{report} });
115 $accrual = ($eur) ? "" : "checked";
116 $cash = ($eur) ? "checked" : "";
118 $year = (localtime)[5] + 1900;
121 $form->all_departments(\%myconfig);
122 if (@{ $form->{all_departments} }) {
123 $form->{selectdepartment} = "<option>\n";
126 $form->{selectdepartment} .=
127 "<option>$_->{description}--$_->{id}\n"
128 } (@{ $form->{all_departments} });
133 <th align=right nowrap>| . $locale->text('Department') . qq|</th>
134 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
136 | if $form->{selectdepartment};
138 $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
141 my %project_labels = ();
142 my @project_values = ("");
143 foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
144 push(@project_values, $item->{"id"});
145 $project_labels{$item->{"id"}} = $item->{"projectnumber"};
149 NTI($cgi->popup_menu('-name' => "project_id",
150 '-values' => \@project_values,
151 '-labels' => \%project_labels));
153 # use JavaScript Calendar or not
154 $form->{jsscript} = 1;
156 if ($form->{report} eq "ustva") {
159 if ($form->{report} eq "balance_sheet") {
160 $name_1 = "asofdate";
162 $value_1 = "$form->{asofdate}";
163 $trigger_1 = "trigger1";
164 $name_2 = "compareasofdate";
165 $id_2 = "compareasofdate";
166 $value_2 = "$form->{compareasofdate}";
167 $trigger_2 = "trigger2";
168 } elsif ($form->{report} =~ /(receipts|payments)$/) {
169 $name_1 = "fromdate";
171 $value_1 = "$form->{fromdate}";
172 $trigger_1 = "trigger1";
176 $trigger_2 = "trigger2";
178 if (($form->{report} eq "ar_aging") || ($form->{report} eq "ap_aging")) {
186 $trigger_2 = "trigger2";
189 $name_1 = "fromdate";
191 $value_1 = "$form->{fromdate}";
192 $trigger_1 = "trigger1";
196 $trigger_2 = "trigger2";
201 # with JavaScript Calendar
202 if ($form->{jsscript}) {
206 <input name=$name_2 id=$id_2 size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\">|;
208 <input type=button name=$name_2 id="$trigger_2" value=|
209 . $locale->text('button') . qq|>|;
213 Form->write_trigger(\%myconfig, "1", "$name_2", "BR", "$trigger_2");
216 <input name=$name_1 id=$id_1 size=11 title="$myconfig{dateformat}" value="$value_1" onBlur=\"check_right_date_format(this)\">|;
218 <input type=button name=$name_1 id="$trigger_1" value=|
219 . $locale->text('button') . qq|>|;
221 <input name=$name_2 id=$id_2 size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\">|;
223 <input type=button name=$name_2 id="$trigger_2" value=|
224 . $locale->text('button') . qq|>
229 Form->write_trigger(\%myconfig, "2", "$name_1", "BR", "$trigger_1",
230 "$name_2", "BL", "$trigger_2");
234 # without JavaScript Calendar
237 qq|<input name=$name_2 id=$id_2 size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\">|;
240 qq|<input name=$name_1 id=$id_1 size=11 title="$myconfig{dateformat}" value=$value_1 onBlur=\"check_right_date_format(this)\">|;
242 qq|<input name=$name_2 id=$id_2 size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\">|;
245 $form->{javascript} .= qq|<script type="text/javascript" src="js/common.js"></script>|;
247 $onload = qq|focus()|;
248 $onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
249 $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
251 <body onLoad="$onload">
253 <form method=post action=$form->{script}>
255 <input type=hidden name=title value="$form->{title}">
259 <th class=listtop>$form->{title}</th>
268 if ($form->{report} eq "projects") {
271 <th align=right nowrap>| . $locale->text('Project') . qq|</th>
272 <td colspan=5><input name=projectnumber size=25</td>
274 <input type=hidden name=nextsub value=generate_projects>
276 <th align=right>| . $locale->text('From') . qq|</th>
279 <th align=right>| . $locale->text('Bis') . qq|</th>
290 <th align=right nowrap>| . $locale->text('Include in Report') . qq|</th>
291 <td><input name=l_heading class=checkbox type=checkbox value=Y> |
292 . $locale->text('Heading') . qq|
293 <input name=l_subtotal class=checkbox type=checkbox value=Y> |
294 . $locale->text('Subtotal') . qq|</td>
301 if ($form->{report} eq "income_statement") {
304 <th align=right nowrap>| . $locale->text('Project') . qq|</th>
305 <td colspan=3>$projectnumber</td>
307 <input type=hidden name=nextsub value=generate_income_statement>
311 <th align=left><input name=reporttype class=radio type=radio value="custom" checked> |
312 . $locale->text('Customized Report') . qq|</th>
315 <th colspan=1>| . $locale->text('Year') . qq|</th>
316 <td><input name=year size=11 title="|
317 . $locale->text('YYYY') . qq|" value="$year"></td>
324 <b> | . $locale->text('Yearly') . qq|</b> </td>
325 <th align=left>| . $locale->text('Quarterly') . qq|</th>
326 <th align=left colspan=3>| . $locale->text('Monthly') . qq|</th>
329 <td align=right> <input name=duetyp class=radio type=radio value="13"
331 <td><input name=duetyp class=radio type=radio value="A" $checked > 1. |
332 . $locale->text('Quarter') . qq|</td>
336 <td><input name=duetyp class=radio type=radio value="1" $checked > |
337 . $locale->text('January') . qq|</td>
341 <td><input name=duetyp class=radio type=radio value="5" $checked > |
342 . $locale->text('May') . qq|</td>
343 <td><input name=duetyp class=radio type=radio value="9" $checked > |
344 . $locale->text('September') . qq|</td>
348 <td align= right> </td>
349 <td><input name=duetyp class=radio type=radio value="B" $checked> 2. |
350 . $locale->text('Quarter') . qq|</td>
351 <td><input name=duetyp class=radio type=radio value="2" $checked > |
352 . $locale->text('February') . qq|</td>
353 <td><input name=duetyp class=radio type=radio value="6" $checked > |
354 . $locale->text('June') . qq|</td>
355 <td><input name=duetyp class=radio type=radio value="10" $checked > |
356 . $locale->text('October') . qq|</td>
360 <td><input name=duetyp class=radio type=radio value="C" $checked> 3. |
361 . $locale->text('Quarter') . qq|</td>
362 <td><input name=duetyp class=radio type=radio value="3" $checked > |
363 . $locale->text('March') . qq|</td>
364 <td><input name=duetyp class=radio type=radio value="7" $checked > |
365 . $locale->text('July') . qq|</td>
366 <td><input name=duetyp class=radio type=radio value="11" $checked > |
367 . $locale->text('November') . qq|</td>
372 <td><input name=duetyp class=radio type=radio value="D" $checked> 4. |
373 . $locale->text('Quarter') . qq| </td>
374 <td><input name=duetyp class=radio type=radio value="4" $checked > |
375 . $locale->text('April') . qq|</td>
376 <td><input name=duetyp class=radio type=radio value="8" $checked > |
377 . $locale->text('August') . qq|</td>
378 <td><input name=duetyp class=radio type=radio value="12" $checked > |
379 . $locale->text('December') . qq|</td>
383 <td colspan=5><hr size=3 noshade></td>
386 <th align=left><input name=reporttype class=radio type=radio value="free" $checked> |
387 . $locale->text('Free report period') . qq|</th>
388 <td align=left colspan=4>| . $locale->text('From') . qq|
391 | . $locale->text('Bis') . qq|
397 <td colspan=5><hr size=3 noshade></td>
400 <th align=leftt>| . $locale->text('Method') . qq|</th>
401 <td colspan=3><input name=method class=radio type=radio value=accrual $accrual>|
402 . $locale->text('Accrual') . qq|
403 <input name=method class=radio type=radio value=cash $cash>|
404 . $locale->text('EUR') . qq|</td>
411 if ($form->{report} eq "bwa") {
414 <th align=right nowrap>| . $locale->text('Project') . qq|</th>
415 <td colspan=3>$projectnumber</td>
417 <input type=hidden name=nextsub value=generate_bwa>
421 <th align=left><input name=reporttype class=radio type=radio value="custom" checked> |
422 . $locale->text('Customized Report') . qq|</th>
425 <th colspan=1>| . $locale->text('Year') . qq|</th>
426 <td><input name=year size=11 title="|
427 . $locale->text('YYYY') . qq|" value="$year"></td>
434 <b> | . $locale->text('Yearly') . qq|</b> </td>
435 <th align=left>| . $locale->text('Quarterly') . qq|</th>
436 <th align=left colspan=3>| . $locale->text('Monthly') . qq|</th>
439 <td align=right> <input name=duetyp class=radio type=radio value="13"
441 <td><input name=duetyp class=radio type=radio value="A" $checked > 1. |
442 . $locale->text('Quarter') . qq|</td>
444 $checked = "checked";
446 <td><input name=duetyp class=radio type=radio value="1" $checked > |
447 . $locale->text('January') . qq|</td>
451 <td><input name=duetyp class=radio type=radio value="5" $checked > |
452 . $locale->text('May') . qq|</td>
453 <td><input name=duetyp class=radio type=radio value="9" $checked > |
454 . $locale->text('September') . qq|</td>
458 <td align= right> </td>
459 <td><input name=duetyp class=radio type=radio value="B" $checked> 2. |
460 . $locale->text('Quarter') . qq|</td>
461 <td><input name=duetyp class=radio type=radio value="2" $checked > |
462 . $locale->text('February') . qq|</td>
463 <td><input name=duetyp class=radio type=radio value="6" $checked > |
464 . $locale->text('June') . qq|</td>
465 <td><input name=duetyp class=radio type=radio value="10" $checked > |
466 . $locale->text('October') . qq|</td>
470 <td><input name=duetyp class=radio type=radio value="C" $checked> 3. |
471 . $locale->text('Quarter') . qq|</td>
472 <td><input name=duetyp class=radio type=radio value="3" $checked > |
473 . $locale->text('March') . qq|</td>
474 <td><input name=duetyp class=radio type=radio value="7" $checked > |
475 . $locale->text('July') . qq|</td>
476 <td><input name=duetyp class=radio type=radio value="11" $checked > |
477 . $locale->text('November') . qq|</td>
482 <td><input name=duetyp class=radio type=radio value="D" $checked> 4. |
483 . $locale->text('Quarter') . qq| </td>
484 <td><input name=duetyp class=radio type=radio value="4" $checked > |
485 . $locale->text('April') . qq|</td>
486 <td><input name=duetyp class=radio type=radio value="8" $checked > |
487 . $locale->text('August') . qq|</td>
488 <td><input name=duetyp class=radio type=radio value="12" $checked > |
489 . $locale->text('December') . qq|</td>
493 <td colspan=5><hr size=3 noshade></td>
496 <th align=left><input name=reporttype class=radio type=radio value="free" $checked> |
497 . $locale->text('Free report period') . qq|</th>
498 <td align=left colspan=4>| . $locale->text('From') . qq|
501 | . $locale->text('Bis') . qq|
507 <td colspan=5><hr size=3 noshade></td>
510 <th align=leftt>| . $locale->text('Method') . qq|</th>
511 <td colspan=3><input name=method class=radio type=radio value=accrual $accrual>|
512 . $locale->text('Accrual') . qq|
513 <input name=method class=radio type=radio value=cash $cash>|
514 . $locale->text('EUR') . qq|</td>
517 <th align=right colspan=4>|
518 . $locale->text('Decimalplaces')
520 <td><input name=decimalplaces size=3 value="2"></td>
527 if ($form->{report} eq "ustva") {
532 <input type=hidden name=nextsub value=generate_ustva>
536 <th align=left><input name=reporttype class=radio type=radio value="custom" checked> |
537 . $locale->text('Zeitraum') . qq|</th>
540 <th colspan=1>| . $locale->text('Year') . qq|</th>
541 <td><input name=year size=11 title="|
542 . $locale->text('YYYY') . qq|" value="$year"></td>
549 <b> | . $locale->text('Yearly') . qq|</b> </td>
550 <th align=left>| . $locale->text('Quarterly') . qq|</th>
551 <th align=left colspan=3>| . $locale->text('Monthly') . qq|</th>
554 <td align=right> <input name=duetyp class=radio type=radio value="13"
556 <td><input name=duetyp class=radio type=radio value="A" $checked > 1. |
557 . $locale->text('Quarter') . qq|</td>
559 $checked = "checked";
561 <td><input name=duetyp class=radio type=radio value="1" $checked > |
562 . $locale->text('January') . qq|</td>
566 <td><input name=duetyp class=radio type=radio value="5" $checked > |
567 . $locale->text('May') . qq|</td>
568 <td><input name=duetyp class=radio type=radio value="9" $checked > |
569 . $locale->text('September') . qq|</td>
573 <td align= right> </td>
574 <td><input name=duetyp class=radio type=radio value="B" $checked> 2. |
575 . $locale->text('Quarter') . qq|</td>
576 <td><input name=duetyp class=radio type=radio value="2" $checked > |
577 . $locale->text('February') . qq|</td>
578 <td><input name=duetyp class=radio type=radio value="6" $checked > |
579 . $locale->text('June') . qq|</td>
580 <td><input name=duetyp class=radio type=radio value="10" $checked > |
581 . $locale->text('October') . qq|</td>
585 <td><input name=duetyp class=radio type=radio value="C" $checked> 3. |
586 . $locale->text('Quarter') . qq|</td>
587 <td><input name=duetyp class=radio type=radio value="3" $checked > |
588 . $locale->text('March') . qq|</td>
589 <td><input name=duetyp class=radio type=radio value="7" $checked > |
590 . $locale->text('July') . qq|</td>
591 <td><input name=duetyp class=radio type=radio value="11" $checked > |
592 . $locale->text('November') . qq|</td>
597 <td><input name=duetyp class=radio type=radio value="D" $checked> 4. |
598 . $locale->text('Quarter') . qq| </td>
599 <td><input name=duetyp class=radio type=radio value="4" $checked > |
600 . $locale->text('April') . qq|</td>
601 <td><input name=duetyp class=radio type=radio value="8" $checked > |
602 . $locale->text('August') . qq|</td>
603 <td><input name=duetyp class=radio type=radio value="12" $checked > |
604 . $locale->text('December') . qq|</td>
608 <td colspan=5><hr size=3 noshade></td>
611 <th align=left>| . $locale->text('Method') . qq|</th>
612 <td colspan=3><input name=method class=radio type=radio value=accrual $accrual>|
613 . $locale->text('Accrual') . qq|
614 <input name=method class=radio type=radio value=cash $cash>|
615 . $locale->text('EUR') . qq|</td>
628 if ($form->{report} eq "balance_sheet") {
630 <input type=hidden name=nextsub value=generate_balance_sheet>
632 <th align=right>| . $locale->text('as at') . qq|</th>
637 <th align=right nowrap>| . $locale->text('Compare to') . qq|</th>
644 <th align=right>| . $locale->text('Decimalplaces') . qq|</th>
645 <td><input name=decimalplaces size=3 value="2"></td>
654 <th align=right>| . $locale->text('Method') . qq|</th>
655 <td colspan=3><input name=method class=radio type=radio value=accrual $accrual>|
656 . $locale->text('Accrual') . qq|
657 <input name=method class=radio type=radio value=cash $cash>|
658 . $locale->text('EUR') . qq|</td>
662 <th align=right nowrap>| . $locale->text('Include in Report') . qq|</th>
663 <td><input name=l_heading class=checkbox type=checkbox value=Y> |
664 . $locale->text('Heading') . qq|
665 <input name=l_subtotal class=checkbox type=checkbox value=Y> |
666 . $locale->text('Subtotal') . qq|
667 <input name=l_accno class=checkbox type=checkbox value=Y> |
668 . $locale->text('Account Number') . qq|</td>
675 if ($form->{report} eq "trial_balance") {
677 <input type=hidden name=nextsub value=generate_trial_balance>
678 <input type=hidden name=eur value=$eur>
680 <th align=right>| . $locale->text('From') . qq|</th>
685 <th align=right>| . $locale->text('Bis') . qq|</th>
698 <th align=right nowrap>| . $locale->text('Include in Report') . qq|</th>
699 <td><input name=l_heading class=checkbox type=checkbox value=Y> |
700 . $locale->text('Heading') . qq|
701 <input name=l_subtotal class=checkbox type=checkbox value=Y> |
702 . $locale->text('Subtotal') . qq|
703 <input name=all_accounts class=checkbox type=checkbox value=Y> |
704 . $locale->text('All Accounts') . qq|</td>
711 if ($form->{report} =~ /^tax_/) {
712 $form->{db} = ($form->{report} =~ /_collected/) ? "ar" : "ap";
714 RP->get_taxaccounts(\%myconfig, \%$form);
717 <input type=hidden name=nextsub value=generate_tax_report>
719 <th align=right>| . $locale->text('From') . qq|</th>
720 <td><input name=fromdate size=11 title="$myconfig{dateformat}" value=$form->{fromdate}></td>
721 <th align=right>| . $locale->text('Bis') . qq|</th>
722 <td><input name=todate size=11 title="$myconfig{dateformat}"></td>
725 <th align=right>| . $locale->text('Report for') . qq|</th>
729 $checked = "checked";
730 foreach $ref (@{ $form->{taxaccounts} }) {
733 qq|<input name=accno class=radio type=radio value=$ref->{accno} $checked> $ref->{description}
735 <input name="$ref->{accno}_description" type=hidden value="$ref->{description}">
736 <input name="$ref->{accno}_rate" type=hidden value="$ref->{rate}">|;
743 <input type=hidden name=db value=$form->{db}>
744 <input type=hidden name=sort value=transdate>
749 <th align=right>| . $locale->text('Method') . qq|</th>
750 <td colspan=3><input name=method class=radio type=radio value=accrual $accrual>|
751 . $locale->text('Accrual') . qq|
752 <input name=method class=radio type=radio value=cash $cash>|
753 . $locale->text('EUR') . qq|</td>
762 <th align=right>| . $locale->text('Include in Report') . qq|</th>
766 <td><input name="l_id" class=checkbox type=checkbox value=Y></td>
767 <td>| . $locale->text('ID') . qq|</td>
768 <td><input name="l_invnumber" class=checkbox type=checkbox value=Y checked></td>
769 <td>| . $locale->text('Invoice') . qq|</td>
770 <td><input name="l_transdate" class=checkbox type=checkbox value=Y checked></td>
771 <td>| . $locale->text('Date') . qq|</td>
774 <td><input name="l_name" class=checkbox type=checkbox value=Y checked></td>
777 if ($form->{db} eq 'ar') {
778 print $locale->text('Customer');
780 if ($form->{db} eq 'ap') {
781 print $locale->text('Vendor');
785 <td><input name="l_netamount" class=checkbox type=checkbox value=Y checked></td>
786 <td>| . $locale->text('Amount') . qq|</td>
787 <td><input name="l_tax" class=checkbox type=checkbox value=Y checked></td>
788 <td>| . $locale->text('Tax') . qq|</td>
789 <td><input name="l_amount" class=checkbox type=checkbox value=Y></td>
790 <td>| . $locale->text('Total') . qq|</td>
793 <td><input name="l_subtotal" class=checkbox type=checkbox value=Y></td>
794 <td>| . $locale->text('Subtotal') . qq|</td>
803 if ($form->{report} =~ /^nontaxable_/) {
804 $form->{db} = ($form->{report} =~ /_sales/) ? "ar" : "ap";
807 <input type=hidden name=nextsub value=generate_tax_report>
809 <input type=hidden name=db value=$form->{db}>
810 <input type=hidden name=sort value=transdate>
811 <input type=hidden name=report value=$form->{report}>
814 <th align=right>| . $locale->text('From') . qq|</th>
815 <td><input name=fromdate size=11 title="$myconfig{dateformat}" value=$form->{fromdate}></td>
816 <th align=right>| . $locale->text('Bis') . qq|</th>
817 <td><input name=todate size=11 title="$myconfig{dateformat}"></td>
820 <th align=right>| . $locale->text('Method') . qq|</th>
821 <td colspan=3><input name=method class=radio type=radio value=accrual $accrual>|
822 . $locale->text('Accrual') . qq|
823 <input name=method class=radio type=radio value=cash $cash>|
824 . $locale->text('EUR') . qq|</td>
827 <th align=right>| . $locale->text('Include in Report') . qq|</th>
831 <td><input name="l_id" class=checkbox type=checkbox value=Y></td>
832 <td>| . $locale->text('ID') . qq|</td>
833 <td><input name="l_invnumber" class=checkbox type=checkbox value=Y checked></td>
834 <td>| . $locale->text('Invoice') . qq|</td>
835 <td><input name="l_transdate" class=checkbox type=checkbox value=Y checked></td>
836 <td>| . $locale->text('Date') . qq|</td>
839 <td><input name="l_name" class=checkbox type=checkbox value=Y checked></td>
842 if ($form->{db} eq 'ar') {
843 print $locale->text('Customer');
845 if ($form->{db} eq 'ap') {
846 print $locale->text('Vendor');
850 <td><input name="l_netamount" class=checkbox type=checkbox value=Y checked></td>
851 <td>| . $locale->text('Amount') . qq|</td>
852 <td><input name="l_amount" class=checkbox type=checkbox value=Y></td>
853 <td>| . $locale->text('Total') . qq|</td>
856 <td><input name="l_subtotal" class=checkbox type=checkbox value=Y></td>
857 <td>| . $locale->text('Subtotal') . qq|</td>
866 if (($form->{report} eq "ar_aging") || ($form->{report} eq "ap_aging")) {
867 if ($form->{report} eq 'ar_aging') {
868 $label = $locale->text('Customer');
869 $form->{vc} = 'customer';
871 $label = $locale->text('Vendor');
872 $form->{vc} = 'vendor';
875 $nextsub = "generate_$form->{report}";
878 $form->all_vc(\%myconfig, $form->{vc},
879 ($form->{vc} eq 'customer') ? "AR" : "AP");
881 map { $vc .= "<option>$_->{name}--$_->{id}\n" }
882 @{ $form->{"all_$form->{vc}"} };
886 ? qq|<select name=$form->{vc}><option>\n$vc</select>|
887 : qq|<input name=$form->{vc} size=35>|;
891 <th align=right>| . $locale->text($label) . qq|</th>
895 <th align=right>| . $locale->text('Bis') . qq|</th>
901 <input type=hidden name=type value=statement>
902 <input type=hidden name=format value=html>
903 <input type=hidden name=media value=screen>
905 <input type=hidden name=nextsub value=$nextsub>
906 <input type=hidden name=action value=$nextsub>
912 # above action can be removed if there is more than one input field
914 if ($form->{report} =~ /(receipts|payments)$/) {
915 $form->{db} = ($form->{report} =~ /payments$/) ? "ap" : "ar";
917 RP->paymentaccounts(\%myconfig, \%$form);
919 $selection = "<option>\n";
920 foreach $ref (@{ $form->{PR} }) {
921 $paymentaccounts .= "$ref->{accno} ";
922 $selection .= "<option>$ref->{accno}--$ref->{description}\n";
925 chop $paymentaccounts;
928 <input type=hidden name=nextsub value=list_payments>
930 <th align=right nowrap>| . $locale->text('Account') . qq|</th>
931 <td colspan=3><select name=account>$selection</select>
932 <input type=hidden name=paymentaccounts value="$paymentaccounts">
936 <th align=right>| . $locale->text('Reference') . qq|</th>
937 <td colspan=3><input name=reference></td>
940 <th align=right nowrap>| . $locale->text('Source') . qq|</th>
941 <td colspan=3><input name=source></td>
944 <th align=right nowrap>| . $locale->text('Memo') . qq|</th>
945 <td colspan=3><input name=memo size=30></td>
948 <th align=right>| . $locale->text('From') . qq|</th>
953 <th align=right>| . $locale->text('Bis') . qq|</th>
960 <td align=right><input type=checkbox style=checkbox name=fx_transaction value=1 checked></td>
961 <th align=left colspan=3>|
962 . $locale->text('Include Exchangerate Difference') . qq|</td>
967 <input type=hidden name=db value=$form->{db}>
968 <input type=hidden name=sort value=transdate>
979 <td><hr size=3 noshade></td>
984 <input type=hidden name=login value=$form->{login}>
985 <input type=hidden name=password value=$form->{password}>
987 <input type=submit class=submit name=action value="|
988 . $locale->text('Continue') . qq|">
991 # Hier Aufruf von get_config zum Einlesen der Finanzamtdaten
992 USTVA->get_config($userspath, 'finanzamt.ini');
994 $disabled = qq|disabled="disabled"|;
995 $disabled = '' if ($form->{elster} eq '1');
996 if ($form->{report} eq 'ustva') {
998 <input type=submit class=submit name=action value="|
999 . $locale->text('debug') . qq|">
1000 <input type=submit class=submit name=action $disabled
1001 value="| . $locale->text('winston_export') . qq|">
1004 <input type=submit class=submit name=action value="|
1005 . $locale->text('config') . qq|">
1016 $lxdebug->leave_sub();
1019 sub continue { call_sub($form->{"nextsub"}); }
1022 $lxdebug->enter_sub();
1023 my $nextsub = shift;
1025 $form->{project_id} = $form->{project_id_1};
1026 if ($form->{projectnumber} && !$form->{project_id}) {
1027 $form->{rowcount} = 1;
1029 # call this instead of update
1030 $form->{update} = $nextsub;
1031 $form->{projectnumber_1} = $form->{projectnumber};
1033 delete $form->{sort};
1036 # if there is one only, assign id
1037 $form->{project_id} = $form->{project_id_1};
1040 $lxdebug->leave_sub();
1043 sub generate_income_statement {
1044 $lxdebug->enter_sub();
1046 $form->{padding} = " ";
1047 $form->{bold} = "<b>";
1048 $form->{endbold} = "</b>";
1049 $form->{br} = "<br>";
1051 if ($form->{reporttype} eq "custom") {
1053 #forgotten the year --> thisyear
1054 if ($form->{year} !~ m/^\d\d\d\d$/) {
1055 $locale->date(\%myconfig, $form->current_date(\%myconfig), 0) =~
1061 if ($form->{duetyp} eq "13") {
1062 $form->{fromdate} = "1.1.$form->{year}";
1063 $form->{todate} = "31.12.$form->{year}";
1067 if ($form->{duetyp} eq "A") {
1068 $form->{fromdate} = "1.1.$form->{year}";
1069 $form->{todate} = "31.3.$form->{year}";
1071 if ($form->{duetyp} eq "B") {
1072 $form->{fromdate} = "1.4.$form->{year}";
1073 $form->{todate} = "30.6.$form->{year}";
1075 if ($form->{duetyp} eq "C") {
1076 $form->{fromdate} = "1.7.$form->{year}";
1077 $form->{todate} = "30.9.$form->{year}";
1079 if ($form->{duetyp} eq "D") {
1080 $form->{fromdate} = "1.10.$form->{year}";
1081 $form->{todate} = "31.12.$form->{year}";
1086 $form->{duetyp} eq "1" && do {
1087 $form->{fromdate} = "1.1.$form->{year}";
1088 $form->{todate} = "31.1.$form->{year}";
1091 $form->{duetyp} eq "2" && do {
1092 $form->{fromdate} = "1.2.$form->{year}";
1094 #this works from 1901 to 2099, 1900 and 2100 fail.
1095 $leap = ($form->{year} % 4 == 0) ? "29" : "28";
1096 $form->{todate} = "$leap.2.$form->{year}";
1099 $form->{duetyp} eq "3" && do {
1100 $form->{fromdate} = "1.3.$form->{year}";
1101 $form->{todate} = "31.3.$form->{year}";
1104 $form->{duetyp} eq "4" && do {
1105 $form->{fromdate} = "1.4.$form->{year}";
1106 $form->{todate} = "30.4.$form->{year}";
1109 $form->{duetyp} eq "5" && do {
1110 $form->{fromdate} = "1.5.$form->{year}";
1111 $form->{todate} = "31.5.$form->{year}";
1114 $form->{duetyp} eq "6" && do {
1115 $form->{fromdate} = "1.6.$form->{year}";
1116 $form->{todate} = "30.6.$form->{year}";
1119 $form->{duetyp} eq "7" && do {
1120 $form->{fromdate} = "1.7.$form->{year}";
1121 $form->{todate} = "31.7.$form->{year}";
1124 $form->{duetyp} eq "8" && do {
1125 $form->{fromdate} = "1.8.$form->{year}";
1126 $form->{todate} = "31.8.$form->{year}";
1129 $form->{duetyp} eq "9" && do {
1130 $form->{fromdate} = "1.9.$form->{year}";
1131 $form->{todate} = "30.9.$form->{year}";
1134 $form->{duetyp} eq "10" && do {
1135 $form->{fromdate} = "1.10.$form->{year}";
1136 $form->{todate} = "31.10.$form->{year}";
1139 $form->{duetyp} eq "11" && do {
1140 $form->{fromdate} = "1.11.$form->{year}";
1141 $form->{todate} = "30.11.$form->{year}";
1144 $form->{duetyp} eq "12" && do {
1145 $form->{fromdate} = "1.12.$form->{year}";
1146 $form->{todate} = "31.12.$form->{year}";
1152 RP->income_statement(\%myconfig, \%$form);
1154 ($form->{department}) = split /--/, $form->{department};
1157 $locale->date(\%myconfig, $form->current_date(\%myconfig), 1);
1158 $form->{todate} = $form->current_date(\%myconfig) unless $form->{todate};
1160 # if there are any dates construct a where
1161 if ($form->{fromdate} || $form->{todate}) {
1163 unless ($form->{todate}) {
1164 $form->{todate} = $form->current_date(\%myconfig);
1167 $longtodate = $locale->date(\%myconfig, $form->{todate}, 1);
1168 $shorttodate = $locale->date(\%myconfig, $form->{todate}, 0);
1170 $longfromdate = $locale->date(\%myconfig, $form->{fromdate}, 1);
1171 $shortfromdate = $locale->date(\%myconfig, $form->{fromdate}, 0);
1173 $form->{this_period} = "$shortfromdate\n$shorttodate";
1175 $locale->text('for Period')
1176 . qq|\n$longfromdate |
1177 . $locale->text('Bis')
1181 if ($form->{comparefromdate} || $form->{comparetodate}) {
1182 $longcomparefromdate =
1183 $locale->date(\%myconfig, $form->{comparefromdate}, 1);
1184 $shortcomparefromdate =
1185 $locale->date(\%myconfig, $form->{comparefromdate}, 0);
1187 $longcomparetodate = $locale->date(\%myconfig, $form->{comparetodate}, 1);
1188 $shortcomparetodate = $locale->date(\%myconfig, $form->{comparetodate}, 0);
1190 $form->{last_period} = "$shortcomparefromdate\n$shortcomparetodate";
1192 "\n$longcomparefromdate "
1193 . $locale->text('Bis')
1194 . qq| $longcomparetodate|;
1197 # setup variables for the form
1198 @a = qw(company address businessnumber);
1199 map { $form->{$_} = $myconfig{$_} } @a;
1201 $form->{templates} = $myconfig{templates};
1203 $form->{IN} = "income_statement.html";
1205 $form->parse_template;
1207 $lxdebug->leave_sub();
1210 sub generate_balance_sheet {
1211 $lxdebug->enter_sub();
1213 $form->{padding} = " ";
1214 $form->{bold} = "<b>";
1215 $form->{endbold} = "</b>";
1216 $form->{br} = "<br>";
1218 RP->balance_sheet(\%myconfig, \%$form);
1220 $form->{asofdate} = $form->current_date(\%myconfig) unless $form->{asofdate};
1222 $locale->date(\%myconfig, $form->current_date(\%myconfig), 1);
1224 ($form->{department}) = split /--/, $form->{department};
1226 # define Current Earnings account
1227 $padding = ($form->{l_heading}) ? $form->{padding} : "";
1228 push(@{ $form->{equity_account} },
1229 $padding . $locale->text('Current Earnings'));
1231 $form->{this_period} = $locale->date(\%myconfig, $form->{asofdate}, 0);
1232 $form->{last_period} =
1233 $locale->date(\%myconfig, $form->{compareasofdate}, 0);
1235 $form->{IN} = "balance_sheet.html";
1237 # setup company variables for the form
1238 map { $form->{$_} = $myconfig{$_};
1239 $form->{$_} =~ s/\\n/\n/g; }
1240 (qw(company address businessnumber nativecurr));
1242 $form->{templates} = $myconfig{templates};
1244 $form->parse_template;
1246 $lxdebug->leave_sub();
1249 sub generate_projects {
1250 $lxdebug->enter_sub();
1252 &get_project(generate_projects);
1253 $form->{projectnumber} = $form->{projectnumber_1};
1255 $form->{nextsub} = "generate_projects";
1256 $form->{title} = $locale->text('Project Transactions');
1257 RP->trial_balance(\%myconfig, \%$form);
1259 list_accounts('generate_projects');
1261 $lxdebug->leave_sub();
1267 # included links to display transactions for period entered
1268 # added headers and subtotals
1270 sub generate_trial_balance {
1271 $lxdebug->enter_sub();
1273 # get for each account initial balance, debits and credits
1274 RP->trial_balance(\%myconfig, \%$form);
1276 $form->{nextsub} = "generate_trial_balance";
1277 $form->{title} = $locale->text('Trial Balance');
1278 list_accounts('generate_trial_balance');
1280 $lxdebug->leave_sub();
1283 sub create_list_accounts_subtotal_row {
1284 $lxdebug->enter_sub();
1286 my ($subtotals, $columns, $fields, $class) = @_;
1288 my $row = { map { $_ => { 'data' => '', 'class' => $class, 'align' => 'right' } } @{ $columns } };
1290 map { $row->{$_}->{data} = $form->format_amount(\%myconfig, $subtotals->{$_}, 2) } @{ $fields };
1292 $lxdebug->leave_sub();
1298 $lxdebug->enter_sub();
1303 if ($form->{department}) {
1304 my ($department) = split /--/, $form->{department};
1305 push @options, $locale->text('Department') . " : $department";
1307 if ($form->{projectnumber}) {
1308 push @options, $locale->text('Project Number') . " : $form->{projectnumber}";
1311 # if there are any dates
1312 if ($form->{fromdate} || $form->{todate}) {
1313 my ($fromdate, $todate);
1315 if ($form->{fromdate}) {
1316 $fromdate = $locale->date(\%myconfig, $form->{fromdate}, 1);
1318 if ($form->{todate}) {
1319 $todate = $locale->date(\%myconfig, $form->{todate}, 1);
1322 push @options, "$fromdate - $todate";
1325 push @options, $locale->date(\%myconfig, $form->current_date(\%myconfig), 1);
1328 my @columns = qw(accno description begbalance debit credit endbalance);
1330 'accno' => { 'text' => $locale->text('Account'), },
1331 'description' => { 'text' => $locale->text('Description'), },
1332 'debit' => { 'text' => $locale->text('Debit'), },
1333 'credit' => { 'text' => $locale->text('Credit'), },
1334 'begbalance' => { 'text' => $locale->text('Balance'), },
1335 'endbalance' => { 'text' => $locale->text('Balance'), },
1337 my %column_alignment = map { $_ => 'right' } qw(debit credit begbalance endbalance);
1339 my @hidden_variables = qw(fromdate todate department l_heading l_subtotal all_accounts sort accounttype eur projectnumber project_id title nextsub);
1341 $form->{callback} = build_std_url("action=$action", grep { $form->{$_} } @hidden_variables);
1343 my $report = SL::ReportGenerator->new(\%myconfig, $form);
1345 $report->set_options('top_info_text' => join("\n", @options),
1346 'output_format' => 'HTML',
1347 'title' => $form->{title},
1348 'attachment_basename' => $locale->text('list_of_transactions') . strftime('_%Y%m%d', localtime time),
1349 'std_column_visibility' => 1,
1351 $report->set_options_from_form();
1353 $report->set_columns(%column_defs);
1354 $report->set_column_order(@columns);
1356 $report->set_export_options($action, @hidden_variables);
1358 $report->set_sort_indicator('accno', 1);
1360 my @totals_columns = qw(credit debit begbalance endbalance);
1361 my %subtotals = map { $_ => 0 } @totals_columns;
1362 my %totals = map { $_ => 0 } @totals_columns;
1363 my $found_heading = 0;
1364 my @tb = sort { $a->{accno} cmp $b->{accno} } @{ $form->{TB} };
1366 # sort the whole thing by account numbers and display
1367 foreach my $idx (0 .. scalar(@tb) - 1) {
1368 my $ref = $tb[$idx];
1369 my $href = build_std_url('script=ca.pl', 'action=list_transactions', 'accno=' . E($ref->{accno}), 'description=' . E($ref->{description}), @hidden_variables);
1371 my $ml = ($ref->{category} =~ /(A|C|E)/) ? -1 : 1;
1373 my $row = { map { $_ => { 'align' => $column_alignment{$_} } } @columns };
1375 if ($ref->{charttype} eq 'H') {
1376 next unless ($form->{l_heading});
1378 %subtotals = map { $_ => 0 } @totals_columns;
1380 $row->{description}->{class} = 'listheading';
1381 $row->{description}->{data} = $ref->{description};
1383 $report->add_data($row);
1388 foreach (qw(debit credit)) {
1389 $subtotals{$_} += $ref->{$_};
1390 $totals{$_} += $ref->{$_};
1393 $subtotals{begbalance} += $ref->{balance} * $ml;
1394 $subtotals{endbalance} += ($ref->{balance} + $ref->{amount}) * $ml;
1396 map { $row->{$_}->{data} = $ref->{$_} } qw(accno description);
1397 map { $row->{$_}->{data} = $form->format_amount(\%myconfig, $ref->{$_}, 2) if ($ref->{$_} != 0) } qw(credit debit);
1399 $row->{begbalance}->{data} = $form->format_amount(\%myconfig, $ref->{balance} * $ml, 2);
1400 $row->{endbalance}->{data} = $form->format_amount(\%myconfig, ($ref->{balance} + $ref->{amount}) * $ml, 2);
1402 $report->add_data($row);
1404 if ($form->{l_heading} && $found_heading &&
1405 (($idx == scalar(@tb) - 1) || ('H' eq $tb[$idx + 1]->{charttype}))) {
1406 $report->add_data(create_list_accounts_subtotal_row(\%subtotals, \@columns, \@totals_columns, 'listsubtotal'));
1410 $report->add_separator();
1412 $report->add_data(create_list_accounts_subtotal_row(\%totals, \@columns, [ qw(debit credit) ], 'listtotal'));
1414 $report->generate_with_headers();
1416 $lxdebug->leave_sub();
1419 sub generate_ar_aging {
1420 $lxdebug->enter_sub();
1423 ($form->{customer}) = split(/--/, $form->{customer});
1425 $form->{ct} = "customer";
1426 $form->{arap} = "ar";
1428 $form->{callback} = build_std_url('action=generate_ar_aging', qw(todate customer title));
1430 RP->aging(\%myconfig, \%$form);
1433 $lxdebug->leave_sub();
1436 sub generate_ap_aging {
1437 $lxdebug->enter_sub();
1440 ($form->{vendor}) = split(/--/, $form->{vendor});
1442 $form->{ct} = "vendor";
1443 $form->{arap} = "ap";
1445 $form->{callback} = build_std_url('action=generate_ap_aging', qw(todate vendor title));
1447 RP->aging(\%myconfig, \%$form);
1450 $lxdebug->leave_sub();
1453 sub create_aging_subtotal_row {
1454 $lxdebug->enter_sub();
1456 my ($subtotals, $columns, $periods, $class) = @_;
1458 my $row = { map { $_ => { 'data' => '', 'class' => $class, 'align' => 'right' } } @{ $columns } };
1460 foreach (@{ $periods }) {
1461 $row->{"c$_"}->{data} = $subtotals->{$_} != 0 ? $form->format_amount(\%myconfig, $subtotals->{$_}, 2) : '';
1462 $subtotals->{$_} = 0;
1465 $lxdebug->leave_sub();
1471 $lxdebug->enter_sub();
1473 my $report = SL::ReportGenerator->new(\%myconfig, $form);
1475 my @columns = qw(statement ct invnumber transdate duedate c0 c30 c60 c90);
1478 'statement' => { 'text' => '', 'visible' => $form->{ct} eq 'customer' ? 'HTML' : 0, },
1479 'ct' => { 'text' => $form->{ct} eq 'customer' ? $locale->text('Customer') : $locale->text('Vendor'), },
1480 'invnumber' => { 'text' => $locale->text('Invoice'), },
1481 'transdate' => { 'text' => $locale->text('Date'), },
1482 'duedate' => { 'text' => $locale->text('Due'), },
1483 'c0' => { 'text' => $locale->text('Current'), },
1484 'c30' => { 'text' => '30', },
1485 'c60' => { 'text' => '60', },
1486 'c90' => { 'text' => '90', },
1489 my %column_alignment = ('statement' => 'center',
1490 map { $_ => 'right' } qw(c0 c30 c60 c90));
1492 $report->set_options('std_column_visibility' => 1);
1493 $report->set_columns(%column_defs);
1494 $report->set_column_order(@columns);
1496 my @hidden_variables = qw(todate customer vendor arap title ct);
1497 $report->set_export_options('generate_' . ($form->{arap} eq 'ar' ? 'ar' : 'ap') . '_aging', @hidden_variables);
1501 if ($form->{department}) {
1502 my ($department) = split /--/, $form->{department};
1503 push @options, $locale->text('Department') . " : $department";
1504 $form->{callback} .= "&department=" . E($department);
1507 if (($form->{arap} eq 'ar') && $form->{customer}) {
1508 push @options, $form->{customer};
1511 if (($form->{arap} eq 'ap') && $form->{vendor}) {
1512 push @options, $form->{vendor};
1515 push @options, $locale->text('for Period') . " " . $locale->text('Bis') . " " . $locale->date(\%myconfig, $form->{todate}, 1);
1517 my $attachment_basename = $form->{ct} eq 'customer' ? $locale->text('ar_aging_list') : $locale->text('ap_aging_list');
1519 $report->set_options('top_info_text' => join("\n", @options),
1520 'output_format' => 'HTML',
1521 'title' => $form->{title},
1522 'attachment_basename' => $attachment_basename . strftime('_%Y%m%d', localtime time),
1525 my $previous_ctid = 0;
1527 my @periods = qw(0 30 60 90);
1528 my %subtotals = map { $_ => 0 } @periods;
1529 my %totals = map { $_ => 0 } @periods;
1531 foreach $ref (@{ $form->{AG} }) {
1532 if ($row_idx && ($previous_ctid != $ref->{ctid})) {
1533 $report->add_data(create_aging_subtotal_row(\%subtotals, \@columns, \@periods, 'listsubtotal'));
1536 foreach my $key (@periods) {
1537 $subtotals{$key} += $ref->{"c${key}"};
1538 $totals{$key} += $ref->{"c${key}"};
1539 $ref->{"c${key}"} = $ref->{"c${key}"} != 0 ? $form->format_amount(\%myconfig, $ref->{"c${key}"}, 2) : '';
1544 foreach my $column (@columns) {
1546 'data' => (($column eq 'ct') || ($column eq 'statement')) ? '' : $ref->{$column},
1547 'align' => $column_alignment{$column},
1548 'valign' => $column eq 'statement' ? 'center' : '',
1552 $row->{invnumber}->{link} = build_std_url("script=$ref->{module}.pl", 'action=edit', 'callback', 'id=' . E($ref->{id}));
1554 if ($previous_ctid != $ref->{ctid}) {
1555 $row->{statement}->{raw_data} =
1556 $cgi->hidden('-name' => "customer_id_${row_idx}", '-value' => $ref->{ctid})
1557 . $cgi->checkbox('-name' => "statement_${row_idx}", '-value' => 1, '-label' => '', 'checked' => $ref->{checked});
1558 $row->{ct}->{data} = $ref->{name};
1563 $previous_ctid = $ref->{ctid};
1565 $report->add_data($row);
1568 $report->add_data(create_aging_subtotal_row(\%subtotals, \@columns, \@periods, 'listsubtotal')) if ($row_idx);
1570 $report->add_data(create_aging_subtotal_row(\%totals, \@columns, \@periods, 'listtotal'));
1572 if ($form->{arap} eq 'ar') {
1573 $raw_top_info_text = $form->parse_html_template('rp/aging_ar_top');
1574 $raw_bottom_info_text = $form->parse_html_template('rp/aging_ar_bottom', { 'row_idx' => $row_idx,
1575 'PRINT_OPTIONS' => print_options(1), });
1576 $report->set_options('raw_top_info_text' => $raw_top_info_text,
1577 'raw_bottom_info_text' => $raw_bottom_info_text);
1580 $report->set_options_from_form();
1582 $report->generate_with_headers();
1584 $lxdebug->leave_sub();
1588 $lxdebug->enter_sub();
1590 RP->aging(\%myconfig, \%$form);
1592 map { $_->{checked} = "checked" } @{ $form->{AG} };
1596 $lxdebug->leave_sub();
1600 $lxdebug->enter_sub();
1602 # get name and email addresses
1603 for $i (1 .. $form->{rowcount}) {
1604 if ($form->{"statement_$i"}) {
1605 $form->{"$form->{ct}_id"} = $form->{"$form->{ct}_id_$i"};
1606 RP->get_customer(\%myconfig, \%$form);
1612 $form->error($locale->text('Nothing selected!')) unless $selected;
1614 if ($myconfig{role} eq 'admin') {
1616 <th align=right nowrap=true>| . $locale->text('Bcc') . qq|</th>
1617 <td><input name=bcc size=30 value="$form->{bcc}"></td>
1621 $title = $locale->text('E-mail Statement to') . " $form->{$form->{ct}}";
1623 $form->{media} = "email";
1630 <form method=post action=$form->{script}>
1636 <tr height="5"></tr>
1641 <th align=right nowrap>| . $locale->text('E-mail') . qq|</th>
1642 <td><input name=email size=30 value="$form->{email}"></td>
1643 <th align=right nowrap>| . $locale->text('Cc') . qq|</th>
1644 <td><input name=cc size=30 value="$form->{cc}"></td>
1647 <th align=right nowrap>| . $locale->text('Subject') . qq|</th>
1648 <td><input name=subject size=30 value="$form->{subject}"></td>
1658 <th align=left nowrap>| . $locale->text('Message') . qq|</th>
1661 <td><textarea name=message rows=15 cols=60 wrap=soft>$form->{message}</textarea></td>
1672 map { delete $form->{$_} }
1673 qw(action email cc bcc subject message type sendmode format header);
1675 # save all other variables
1676 foreach $key (keys %$form) {
1677 $form->{$key} =~ s/\"/"/g;
1678 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
1685 <td><hr size=3 noshade></td>
1689 <input type=hidden name=nextsub value=send_email>
1692 <input name=action class=submit type=submit value="|
1693 . $locale->text('Continue') . qq|">
1700 $lxdebug->leave_sub();
1704 $lxdebug->enter_sub();
1706 $form->{subject} = $locale->text('Statement') . qq| - $form->{todate}|
1707 unless $form->{subject};
1709 RP->aging(\%myconfig, \%$form);
1711 $form->{"statement_1"} = 1;
1713 $form->{media} = 'email';
1716 $form->redirect($locale->text('Statement sent to') . " $form->{$form->{ct}}");
1718 $lxdebug->leave_sub();
1722 $lxdebug->enter_sub();
1724 if ($form->{media} eq 'printer') {
1725 $form->error($locale->text('Select postscript or PDF!'))
1726 if ($form->{format} !~ /(postscript|pdf)/);
1729 for $i (1 .. $form->{rowcount}) {
1730 if ($form->{"statement_$i"}) {
1731 $form->{"$form->{ct}_id"} = $form->{"$form->{ct}_id_$i"};
1737 $form->error($locale->text('Nothing selected!')) unless $selected;
1739 if ($form->{media} eq 'printer') {
1740 $form->{"$form->{ct}_id"} = "";
1742 $form->{"statement_1"} = 1;
1745 RP->aging(\%myconfig, \%$form);
1749 $form->redirect($locale->text('Statements sent to printer!'))
1750 if ($form->{media} eq 'printer');
1752 $lxdebug->leave_sub();
1756 $lxdebug->enter_sub();
1760 "ä" => "ae", "ö" => "oe", "ü" => "ue",
1761 "Ä" => "Ae", "Ö" => "Oe", "Ü" => "Ue",
1766 foreach my $key (keys %replacements) {
1767 my $new_key = SL::Iconv::convert("ISO-8859-15", $dbcharset, $key);
1768 $replacements{$new_key} = $replacements{$key} if $new_key ne $key;
1771 $form->{statementdate} = $locale->date(\%myconfig, $form->{todate}, 1);
1773 $form->{templates} = "$myconfig{templates}";
1775 my $suffix = "html";
1776 my $attachment_suffix = "html";
1777 if ($form->{format} eq 'postscript') {
1778 $form->{postscript} = 1;
1780 $attachment_suffix = "ps";
1781 } elsif ($form->{format} eq 'pdf') {
1784 $attachment_suffix = "pdf";
1787 $form->{IN} = "$form->{type}.$suffix";
1789 $form->{media} eq 'email' ? $sendmail :
1790 $form->{media} eq 'printer' ? "| $myconfig{printer}" : "";
1792 # Save $form->{email} because it will be overwritten.
1793 $form->{EMAIL_RECIPIENT} = $form->{email};
1796 while (@{ $form->{AG} }) {
1798 $ref = shift @{ $form->{AG} };
1800 if ($ctid != $ref->{ctid}) {
1802 $ctid = $ref->{ctid};
1805 if ($form->{"statement_$i"}) {
1808 (name, street, zipcode, city, country, contact, email,
1809 "$form->{ct}phone", "$form->{ct}fax");
1810 map { $form->{$_} = $ref->{$_} } @a;
1812 $form->{ $form->{ct} } = $form->{name};
1813 $form->{"$form->{ct}_id"} = $ref->{ctid};
1815 map { $form->{$_} = () } qw(invnumber invdate duedate);
1817 foreach $item (qw(c0 c30 c60 c90)) {
1818 $form->{$item} = ();
1819 $form->{"${item}total"} = 0;
1822 &statement_details($ref);
1826 if (scalar(@{ $form->{AG} }) > 0) {
1828 # one or more left to go
1829 if ($ctid == $form->{AG}->[0]->{ctid}) {
1830 $ref = shift @{ $form->{AG} };
1831 &statement_details($ref);
1834 $ref = scalar(@{ $form->{AG} });
1840 # set initial ref to 0
1847 $form->{"${_}total"} =
1848 $form->format_amount(\%myconfig, $form->{"${_}total"}, 2)
1849 } (c0, c30, c60, c90, "");
1851 $form->{attachment_filename} = $locale->text("Statement") . "_$form->{todate}.$attachment_suffix";
1852 map({ $form->{attachment_filename} =~ s/$_/$replacements{$_}/g; } keys(%replacements));
1854 $form->parse_template(\%myconfig, $userspath);
1859 # saving the history
1860 if(!exists $form->{addition} && $form->{id} ne "") {
1861 $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
1862 $form->{addition} = "PRINTED";
1863 $form->{what_done} = $form->{type};
1864 $form->save_history($form->dbconnect(\%myconfig));
1866 # /saving the history
1867 $lxdebug->leave_sub();
1870 sub statement_details {
1871 $lxdebug->enter_sub();
1874 push @{ $form->{invnumber} }, $ref->{invnumber};
1875 push @{ $form->{invdate} }, $ref->{transdate};
1876 push @{ $form->{duedate} }, $ref->{duedate};
1878 foreach $item (qw(c0 c30 c60 c90)) {
1879 if ($ref->{exchangerate} * 1) {
1881 $form->round_amount($ref->{$item} / $ref->{exchangerate}, 2);
1883 $form->{"${item}total"} += $ref->{$item};
1884 $form->{total} += $ref->{$item};
1885 push @{ $form->{$item} },
1886 $form->format_amount(\%myconfig, $ref->{$item}, 2);
1889 $lxdebug->leave_sub();
1892 sub generate_tax_report {
1893 $lxdebug->enter_sub();
1895 RP->tax_report(\%myconfig, \%$form);
1897 $descvar = "$form->{accno}_description";
1898 $description = $form->escape($form->{$descvar});
1899 $ratevar = "$form->{accno}_rate";
1901 $department = $form->escape($form->{department});
1905 "$form->{script}?&action=generate_tax_report&login=$form->{login}&password=$form->{password}&fromdate=$form->{fromdate}&todate=$form->{todate}&db=$form->{db}&method=$form->{method}&accno=$form->{accno}&$descvar=$description&department=$department&$ratevar=$taxrate&report=$form->{report}";
1907 # construct callback
1908 $description = $form->escape($form->{$descvar}, 1);
1909 $department = $form->escape($form->{department}, 1);
1911 "$form->{script}?&action=generate_tax_report&login=$form->{login}&password=$form->{password}&fromdate=$form->{fromdate}&todate=$form->{todate}&db=$form->{db}&method=$form->{method}&accno=$form->{accno}&$descvar=$description&department=$department&$ratevar=$taxrate&report=$form->{report}";
1913 $title = $form->escape($form->{title});
1914 $href .= "&title=$title";
1915 $title = $form->escape($form->{title}, 1);
1916 $callback .= "&title=$title";
1918 $form->{title} = qq|$form->{title} $form->{"$form->{accno}_description"} |;
1921 $form->sort_columns(qw(id transdate invnumber name netamount tax amount));
1923 foreach $item (@columns) {
1924 if ($form->{"l_$item"} eq "Y") {
1925 push @column_index, $item;
1927 # add column to href and callback
1928 $callback .= "&l_$item=Y";
1929 $href .= "&l_$item=Y";
1933 if ($form->{l_subtotal} eq 'Y') {
1934 $callback .= "&l_subtotal=Y";
1935 $href .= "&l_subtotal=Y";
1938 if ($form->{department}) {
1939 ($department) = split /--/, $form->{department};
1940 $option = $locale->text('Department') . " : $department";
1943 # if there are any dates
1944 if ($form->{fromdate} || $form->{todate}) {
1945 if ($form->{fromdate}) {
1946 $fromdate = $locale->date(\%myconfig, $form->{fromdate}, 1);
1948 if ($form->{todate}) {
1949 $todate = $locale->date(\%myconfig, $form->{todate}, 1);
1952 $form->{period} = "$fromdate - $todate";
1955 $locale->date(\%myconfig, $form->current_date(\%myconfig), 1);
1958 if ($form->{db} eq 'ar') {
1959 $name = $locale->text('Customer');
1963 if ($form->{db} eq 'ap') {
1964 $name = $locale->text('Vendor');
1969 $option .= "<br>" if $option;
1970 $option .= "$form->{period}";
1972 $column_header{id} =
1973 qq|<th><a class=listheading href=$href&sort=id>|
1974 . $locale->text('ID')
1976 $column_header{invnumber} =
1977 qq|<th><a class=listheading href=$href&sort=invnumber>|
1978 . $locale->text('Invoice')
1980 $column_header{transdate} =
1981 qq|<th><a class=listheading href=$href&sort=transdate>|
1982 . $locale->text('Date')
1984 $column_header{netamount} =
1985 qq|<th class=listheading>| . $locale->text('Amount') . qq|</th>|;
1986 $column_header{tax} =
1987 qq|<th class=listheading>| . $locale->text('Tax') . qq|</th>|;
1988 $column_header{amount} =
1989 qq|<th class=listheading>| . $locale->text('Total') . qq|</th>|;
1991 $column_header{name} =
1992 qq|<th><a class=listheading href=$href&sort=name>$name</th>|;
2001 <th class=listtop colspan=$colspan>$form->{title}</th>
2003 <tr height="5"></tr>
2010 <tr class=listheading>
2013 map { print "$column_header{$_}\n" } @column_index;
2019 # add sort and escape callback
2020 $callback = $form->escape($callback . "&sort=$form->{sort}");
2022 if (@{ $form->{TR} }) {
2023 $sameitem = $form->{TR}->[0]->{ $form->{sort} };
2026 foreach $ref (@{ $form->{TR} }) {
2028 $module = ($ref->{invoice}) ? $invoice : $arap;
2030 if ($form->{l_subtotal} eq 'Y') {
2031 if ($sameitem ne $ref->{ $form->{sort} }) {
2033 $sameitem = $ref->{ $form->{sort} };
2037 $totalnetamount += $ref->{netamount};
2038 $totaltax += $ref->{tax};
2039 $ref->{amount} = $ref->{netamount} + $ref->{tax};
2041 $subtotalnetamount += $ref->{netamount};
2042 $subtotaltax += $ref->{tax};
2045 $ref->{$_} = $form->format_amount(\%myconfig, $ref->{$_}, 2, " ");
2046 } qw(netamount tax amount);
2048 $column_data{id} = qq|<td>$ref->{id}</td>|;
2049 $column_data{invnumber} =
2050 qq|<td><a href=$module?action=edit&id=$ref->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{invnumber}</a></td>|;
2051 $column_data{transdate} = qq|<td>$ref->{transdate}</td>|;
2052 $column_data{name} = qq|<td>$ref->{name} </td>|;
2054 map { $column_data{$_} = qq|<td align=right>$ref->{$_}</td>| }
2055 qw(netamount tax amount);
2060 <tr class=listrow$i>
2063 map { print "$column_data{$_}\n" } @column_index;
2071 if ($form->{l_subtotal} eq 'Y') {
2075 map { $column_data{$_} = qq|<th> </th>| } @column_index;
2079 <tr class=listtotal>
2083 $form->format_amount(\%myconfig, $totalnetamount + $totaltax, 2, " ");
2085 $form->format_amount(\%myconfig, $totalnetamount, 2, " ");
2086 $totaltax = $form->format_amount(\%myconfig, $totaltax, 2, " ");
2088 $column_data{netamount} =
2089 qq|<th class=listtotal align=right>$totalnetamount</th>|;
2090 $column_data{tax} = qq|<th class=listtotal align=right>$totaltax</th>|;
2091 $column_data{amount} = qq|<th class=listtotal align=right>$total</th>|;
2093 map { print "$column_data{$_}\n" } @column_index;
2101 <td><hr size=3 noshade></td>
2109 $lxdebug->leave_sub();
2113 $lxdebug->enter_sub();
2115 map { $column_data{$_} = "<td> </td>" } @column_index;
2117 $subtotalnetamount =
2118 $form->format_amount(\%myconfig, $subtotalnetamount, 2, " ");
2119 $subtotaltax = $form->format_amount(\%myconfig, $subtotaltax, 2, " ");
2121 $form->format_amount(\%myconfig, $subtotalnetamount + $subtotaltax,
2124 $column_data{netamount} =
2125 "<th class=listsubtotal align=right>$subtotalnetamount</th>";
2126 $column_data{tax} = "<th class=listsubtotal align=right>$subtotaltax</th>";
2127 $column_data{amount} = "<th class=listsubtotal align=right>$subtotal</th>";
2129 $subtotalnetamount = 0;
2133 <tr class=listsubtotal>
2135 map { print "\n$column_data{$_}" } @column_index;
2141 $lxdebug->leave_sub();
2145 $lxdebug->enter_sub();
2147 if ($form->{account}) {
2148 ($form->{paymentaccounts}) = split /--/, $form->{account};
2150 if ($form->{department}) {
2151 ($department, $form->{department_id}) = split /--/, $form->{department};
2152 $option = $locale->text('Department') . " : $department";
2155 RP->payments(\%myconfig, \%$form);
2157 my @hidden_variables = qw(account title department reference source memo fromdate todate
2158 fx_transaction db prepayment paymentaccounts sort);
2160 my $href = build_std_url('action=list_payments', grep { $form->{$_} } @hidden_variables);
2161 $form->{callback} = $href;
2163 my @columns = qw(transdate invnumber name paid source memo);
2165 'name' => { 'text' => $locale->text('Description'), },
2166 'invnumber' => { 'text' => $locale->text('Reference'), },
2167 'transdate' => { 'text' => $locale->text('Date'), },
2168 'paid' => { 'text' => $locale->text('Amount'), },
2169 'source' => { 'text' => $locale->text('Source'), },
2170 'memo' => { 'text' => $locale->text('Memo'), },
2172 my %column_alignment = ('paid' => 'right');
2174 map { $column_defs{$_}->{link} = $href . "&sort=$_" } grep { $_ ne 'paid' } @columns;
2177 if ($form->{fromdate}) {
2178 push @options, $locale->text('From') . " " . $locale->date(\%myconfig, $form->{fromdate}, 1);
2180 if ($form->{todate}) {
2181 push @options, $locale->text('bis') . " " . $locale->date(\%myconfig, $form->{todate}, 1);
2184 my $report = SL::ReportGenerator->new(\%myconfig, $form);
2186 my $attachment_basename = $form->{db} eq 'ar' ? $locale->text('list_of_receipts') : $locale->text('list_of_payments');
2188 $report->set_options('top_info_text' => join("\n", @options),
2189 'output_format' => 'HTML',
2190 'title' => $form->{title},
2191 'attachment_basename' => $attachment_basename . strftime('_%Y%m%d', localtime time),
2192 'std_column_visibility' => 1,
2194 $report->set_options_from_form();
2196 $report->set_columns(%column_defs);
2197 $report->set_column_order(@columns);
2199 $report->set_export_options('list_payments', @hidden_variables);
2201 $report->set_sort_indicator($form->{sort}, 1);
2205 foreach my $ref (sort { $a->{accno} cmp $b->{accno} } @{ $form->{PR} }) {
2206 next unless @{ $form->{ $ref->{id} } };
2208 $report->add_control({ 'type' => 'colspan_data', 'data' => "$ref->{accno}--$ref->{description}" });
2210 my $subtotal_paid = 0;
2212 foreach my $payment (@{ $form->{ $ref->{id} } }) {
2213 my $module = $payment->{module};
2214 $module = 'is' if ($payment->{invoice} && $payment->{module} eq 'ar');
2215 $module = 'ir' if ($payment->{invoice} && $payment->{module} eq 'ap');
2217 $subtotal_paid += $payment->{paid};
2218 $total_paid += $payment->{paid};
2220 $payment->{paid} = $form->format_amount(\%myconfig, $payment->{paid}, 2);
2224 foreach my $column (@columns) {
2226 'data' => $payment->{$column},
2227 'align' => $column_alignment{$column},
2231 $row->{invnumber}->{link} = build_std_url("script=${module}.pl", 'action=edit', 'id=' . E($payment->{id}), 'callback');
2233 $report->add_data($row);
2236 my $row = { map { $_ => { 'class' => 'listsubtotal' } } @columns };
2238 'data' => $form->format_amount(\%myconfig, $subtotal_paid, 2),
2240 'class' => 'listsubtotal',
2243 $report->add_data($row);
2246 $report->add_separator();
2248 my $row = { map { $_ => { 'class' => 'listtotal' } } @columns };
2250 'data' => $form->format_amount(\%myconfig, $total_paid, 2),
2252 'class' => 'listtotal',
2255 $report->add_data($row);
2257 $report->generate_with_headers();
2259 $lxdebug->leave_sub();
2263 $lxdebug->enter_sub();
2268 $lxdebug->leave_sub();
2277 sub winston_export {
2278 $lxdebug->enter_sub();
2281 $form->{winston} = 1;
2283 $lxdebug->leave_sub();
2287 $lxdebug->enter_sub();
2289 my ($dont_print) = @_;
2291 $form->{sendmode} = "attachment";
2294 $form->{"format"} ? $form->{"format"} :
2295 $myconfig{"template_format"} ? $myconfig{"template_format"} :
2299 $form->{"copies"} ? $form->{"copies"} :
2300 $myconfig{"copies"} ? $myconfig{"copies"} :
2303 $form->{PD}{ $form->{type} } = "selected";
2304 $form->{DF}{ $form->{format} } = "selected";
2305 $form->{OP}{ $form->{media} } = "selected";
2306 $form->{SM}{ $form->{sendmode} } = "selected";
2308 if ($form->{report} eq 'ustva') {
2310 <option value=ustva $form->{PD}{ustva}>| . $locale->text('ustva');
2313 <option value=statement $form->{PD}{statement}>|
2314 . $locale->text('Statement');
2317 if ($form->{media} eq 'email') {
2319 <option value=attachment $form->{SM}{attachment}>|
2320 . $locale->text('Attachment') . qq|
2321 <option value=inline $form->{SM}{inline}>| . $locale->text('In-line');
2324 <option value=screen $form->{OP}{screen}>| . $locale->text('Screen');
2325 if ($myconfig{printer} && $latex_templates) {
2327 <option value=printer $form->{OP}{printer}>|
2328 . $locale->text('Printer');
2332 if ($latex_templates) {
2334 <option value=html $form->{DF}{html}>|
2335 . $locale->text('HTML') . qq|
2336 <option value=pdf $form->{DF}{pdf}>| . $locale->text('PDF');
2337 if ($form->{report} ne 'ustva') {
2339 <option value=postscript $form->{DF}{postscript}>|
2340 . $locale->text('Postscript');
2347 <td><select name=type>$type</select></td>
2348 <td><select name=format>$format</select></td>
2349 <td><select name=media>$media</select></td>
2352 if ($myconfig{printer} && $latex_templates && $form->{media} ne 'email') {
2354 <td>| . $locale->text('Copies') . qq|
2355 <input name=copies size=2 value=$form->{copies}></td>
2364 print $output unless $dont_print;
2366 $lxdebug->leave_sub();
2372 $lxdebug->enter_sub();
2373 $form->{padding} = " ";
2374 $form->{bold} = "<b>";
2375 $form->{endbold} = "</b>";
2376 $form->{br} = "<br>";
2378 if ($form->{reporttype} eq "custom") {
2380 #forgotten the year --> thisyear
2381 if ($form->{year} !~ m/^\d\d\d\d$/) {
2382 $locale->date(\%myconfig, $form->current_date(\%myconfig), 0) =~
2388 if ($form->{duetyp} eq "13") {
2389 $form->{fromdate} = "1.1.$form->{year}";
2390 $form->{todate} = "31.12.$form->{year}";
2391 $form->{comparefromdate} = "1.01.$form->{year}";
2392 $form->{comparetodate} = "31.12.$form->{year}";
2396 if ($form->{duetyp} eq "A") {
2397 $form->{fromdate} = "1.1.$form->{year}";
2398 $form->{todate} = "31.3.$form->{year}";
2399 $form->{comparefromdate} = "1.01.$form->{year}";
2400 $form->{comparetodate} = "31.03.$form->{year}";
2402 if ($form->{duetyp} eq "B") {
2403 $form->{fromdate} = "1.4.$form->{year}";
2404 $form->{todate} = "30.6.$form->{year}";
2405 $form->{comparefromdate} = "1.01.$form->{year}";
2406 $form->{comparetodate} = "30.06.$form->{year}";
2408 if ($form->{duetyp} eq "C") {
2409 $form->{fromdate} = "1.7.$form->{year}";
2410 $form->{todate} = "30.9.$form->{year}";
2411 $form->{comparefromdate} = "1.01.$form->{year}";
2412 $form->{comparetodate} = "30.09.$form->{year}";
2414 if ($form->{duetyp} eq "D") {
2415 $form->{fromdate} = "1.10.$form->{year}";
2416 $form->{todate} = "31.12.$form->{year}";
2417 $form->{comparefromdate} = "1.01.$form->{year}";
2418 $form->{comparetodate} = "31.12.$form->{year}";
2423 $form->{duetyp} eq "1" && do {
2424 $form->{fromdate} = "1.1.$form->{year}";
2425 $form->{todate} = "31.1.$form->{year}";
2426 $form->{comparefromdate} = "1.01.$form->{year}";
2427 $form->{comparetodate} = "31.01.$form->{year}";
2430 $form->{duetyp} eq "2" && do {
2431 $form->{fromdate} = "1.2.$form->{year}";
2433 #this works from 1901 to 2099, 1900 and 2100 fail.
2434 $leap = ($form->{year} % 4 == 0) ? "29" : "28";
2435 $form->{todate} = "$leap.2.$form->{year}";
2436 $form->{comparefromdate} = "1.01.$form->{year}";
2437 $form->{comparetodate} = "$leap.02.$form->{year}";
2440 $form->{duetyp} eq "3" && do {
2441 $form->{fromdate} = "1.3.$form->{year}";
2442 $form->{todate} = "31.3.$form->{year}";
2443 $form->{comparefromdate} = "1.01.$form->{year}";
2444 $form->{comparetodate} = "31.03.$form->{year}";
2447 $form->{duetyp} eq "4" && do {
2448 $form->{fromdate} = "1.4.$form->{year}";
2449 $form->{todate} = "30.4.$form->{year}";
2450 $form->{comparefromdate} = "1.01.$form->{year}";
2451 $form->{comparetodate} = "30.04.$form->{year}";
2454 $form->{duetyp} eq "5" && do {
2455 $form->{fromdate} = "1.5.$form->{year}";
2456 $form->{todate} = "31.5.$form->{year}";
2457 $form->{comparefromdate} = "1.01.$form->{year}";
2458 $form->{comparetodate} = "31.05.$form->{year}";
2461 $form->{duetyp} eq "6" && do {
2462 $form->{fromdate} = "1.6.$form->{year}";
2463 $form->{todate} = "30.6.$form->{year}";
2464 $form->{comparefromdate} = "1.01.$form->{year}";
2465 $form->{comparetodate} = "30.06.$form->{year}";
2468 $form->{duetyp} eq "7" && do {
2469 $form->{fromdate} = "1.7.$form->{year}";
2470 $form->{todate} = "31.7.$form->{year}";
2471 $form->{comparefromdate} = "1.01.$form->{year}";
2472 $form->{comparetodate} = "31.07.$form->{year}";
2475 $form->{duetyp} eq "8" && do {
2476 $form->{fromdate} = "1.8.$form->{year}";
2477 $form->{todate} = "31.8.$form->{year}";
2478 $form->{comparefromdate} = "1.01.$form->{year}";
2479 $form->{comparetodate} = "31.08.$form->{year}";
2482 $form->{duetyp} eq "9" && do {
2483 $form->{fromdate} = "1.9.$form->{year}";
2484 $form->{todate} = "30.9.$form->{year}";
2485 $form->{comparefromdate} = "1.01.$form->{year}";
2486 $form->{comparetodate} = "30.09.$form->{year}";
2489 $form->{duetyp} eq "10" && do {
2490 $form->{fromdate} = "1.10.$form->{year}";
2491 $form->{todate} = "31.10.$form->{year}";
2492 $form->{comparefromdate} = "1.01.$form->{year}";
2493 $form->{comparetodate} = "31.10.$form->{year}";
2496 $form->{duetyp} eq "11" && do {
2497 $form->{fromdate} = "1.11.$form->{year}";
2498 $form->{todate} = "30.11.$form->{year}";
2499 $form->{comparefromdate} = "1.01.$form->{year}";
2500 $form->{comparetodate} = "30.11.$form->{year}";
2503 $form->{duetyp} eq "12" && do {
2504 $form->{fromdate} = "1.12.$form->{year}";
2505 $form->{todate} = "31.12.$form->{year}";
2506 $form->{comparefromdate} = "1.01.$form->{year}";
2507 $form->{comparetodate} = "31.12.$form->{year}";
2512 ($yy, $mm, $dd) = $locale->parse_date(\%myconfig, $form->{fromdate});
2513 $form->{fromdate} = "${dd}.${mm}.${yy}";
2514 ($yy, $mm, $dd) = $locale->parse_date(\%myconfig, $form->{todate});
2515 $form->{todate} = "${dd}.${mm}.${yy}";
2516 $form->{comparefromdate} = "01.01.$yy";
2517 $form->{comparetodate} = $form->{todate};
2520 RP->bwa(\%myconfig, \%$form);
2522 ($form->{department}) = split /--/, $form->{department};
2525 $locale->date(\%myconfig, $form->current_date(\%myconfig), 1);
2526 $form->{todate} = $form->current_date(\%myconfig) unless $form->{todate};
2528 # if there are any dates construct a where
2529 if ($form->{fromdate} || $form->{todate}) {
2531 unless ($form->{todate}) {
2532 $form->{todate} = $form->current_date(\%myconfig);
2535 my %germandate = ("dateformat" => "dd.mm.yyyy");
2537 $longtodate = $locale->date(\%germandate, $form->{todate}, 1);
2538 $shorttodate = $locale->date(\%germandate, $form->{todate}, 0);
2540 $longfromdate = $locale->date(\%germandate, $form->{fromdate}, 1);
2541 $shortfromdate = $locale->date(\%germandate, $form->{fromdate}, 0);
2543 $form->{this_period} = "$shortfromdate\n$shorttodate";
2545 $locale->text('for Period')
2546 . qq|\n$longfromdate |
2547 . $locale->text('bis')
2551 # setup variables for the form
2552 @a = qw(company address businessnumber);
2553 map { $form->{$_} = $myconfig{$_} } @a;
2554 $form->{templates} = $myconfig{templates};
2556 $form->{IN} = "bwa.html";
2558 $form->parse_template;
2560 $lxdebug->leave_sub();
2563 sub generate_ustva {
2564 $lxdebug->enter_sub();
2566 # Hier Aufruf von get_config zum Einlesen der Finanzamtdaten
2567 USTVA->get_config($userspath, 'finanzamt.ini');
2569 # &get_project(generate_bwa);
2570 @anmeldungszeitraum =
2571 qw(0401, 0402, 0403, 0404, 0405, 0405, 0406, 0407, 0408, 0409, 0410, 0411, 0412, 0441, 0442, 0443, 0444);
2573 foreach $item (@anmeldungszeitraum) {
2574 $form->{$item} = "";
2576 if ($form->{reporttype} eq "custom") {
2578 #forgotten the year --> thisyear
2579 if ($form->{year} !~ m/^\d\d\d\d$/) {
2580 $locale->date(\%myconfig, $form->current_date(\%myconfig), 0) =~
2586 if ($form->{duetyp} eq "13") {
2587 $form->{fromdate} = "1.1.$form->{year}";
2588 $form->{todate} = "31.12.$form->{year}";
2592 if ($form->{duetyp} eq "A") {
2593 $form->{fromdate} = "1.1.$form->{year}";
2594 $form->{todate} = "31.3.$form->{year}";
2595 $form->{"0441"} = "X";
2597 if ($form->{duetyp} eq "B") {
2598 $form->{fromdate} = "1.4.$form->{year}";
2599 $form->{todate} = "30.6.$form->{year}";
2600 $form->{"0442"} = "X";
2602 if ($form->{duetyp} eq "C") {
2603 $form->{fromdate} = "1.7.$form->{year}";
2604 $form->{todate} = "30.9.$form->{year}";
2605 $form->{"0443"} = "X";
2607 if ($form->{duetyp} eq "D") {
2608 $form->{fromdate} = "1.10.$form->{year}";
2609 $form->{todate} = "31.12.$form->{year}";
2610 $form->{"0444"} = "X";
2615 $form->{duetyp} eq "1" && do {
2616 $form->{fromdate} = "1.1.$form->{year}";
2617 $form->{todate} = "31.1.$form->{year}";
2618 $form->{"0401"} = "X";
2621 $form->{duetyp} eq "2" && do {
2622 $form->{fromdate} = "1.2.$form->{year}";
2624 #this works from 1901 to 2099, 1900 and 2100 fail.
2625 $leap = ($form->{year} % 4 == 0) ? "29" : "28";
2626 $form->{todate} = "$leap.2.$form->{year}";
2627 $form->{"0402"} = "X";
2630 $form->{duetyp} eq "3" && do {
2631 $form->{fromdate} = "1.3.$form->{year}";
2632 $form->{todate} = "31.3.$form->{year}";
2633 $form->{"0403"} = "X";
2636 $form->{duetyp} eq "4" && do {
2637 $form->{fromdate} = "1.4.$form->{year}";
2638 $form->{todate} = "30.4.$form->{year}";
2639 $form->{"0404"} = "X";
2642 $form->{duetyp} eq "5" && do {
2643 $form->{fromdate} = "1.5.$form->{year}";
2644 $form->{todate} = "31.5.$form->{year}";
2645 $form->{"0405"} = "X";
2648 $form->{duetyp} eq "6" && do {
2649 $form->{fromdate} = "1.6.$form->{year}";
2650 $form->{todate} = "30.6.$form->{year}";
2651 $form->{"0406"} = "X";
2654 $form->{duetyp} eq "7" && do {
2655 $form->{fromdate} = "1.7.$form->{year}";
2656 $form->{todate} = "31.7.$form->{year}";
2657 $form->{"0407"} = "X";
2660 $form->{duetyp} eq "8" && do {
2661 $form->{fromdate} = "1.8.$form->{year}";
2662 $form->{todate} = "31.8.$form->{year}";
2663 $form->{"0408"} = "X";
2666 $form->{duetyp} eq "9" && do {
2667 $form->{fromdate} = "1.9.$form->{year}";
2668 $form->{todate} = "30.9.$form->{year}";
2669 $form->{"0409"} = "X";
2672 $form->{duetyp} eq "10" && do {
2673 $form->{fromdate} = "1.10.$form->{year}";
2674 $form->{todate} = "31.10.$form->{year}";
2675 $form->{"0410"} = "X";
2678 $form->{duetyp} eq "11" && do {
2679 $form->{fromdate} = "1.11.$form->{year}";
2680 $form->{todate} = "30.11.$form->{year}";
2681 $form->{"0411"} = "X";
2684 $form->{duetyp} eq "12" && do {
2685 $form->{fromdate} = "1.12.$form->{year}";
2686 $form->{todate} = "31.12.$form->{year}";
2687 $form->{"0412"} = "X";
2693 # $locale->date(\%myconfig, $form->current_date(\%myconfig), 0)=~ /(\d\d\d\d)/;
2694 # $form->{year}= $1;
2695 # $form->{fromdate}="1.1.$form->{year}";
2696 # $form->{todate}="31.3.$form->{year}";
2697 # $form->{period} = $locale->date(\%myconfig, $form->current_date(\%myconfig), 1);
2700 RP->ustva(\%myconfig, \%$form);
2702 ($form->{department}) = split /--/, $form->{department};
2705 $locale->date(\%myconfig, $form->current_date(\%myconfig), 1);
2706 $form->{todate} = $form->current_date(\%myconfig) unless $form->{todate};
2708 # if there are any dates construct a where
2709 if ($form->{fromdate} || $form->{todate}) {
2711 unless ($form->{todate}) {
2712 $form->{todate} = $form->current_date(\%myconfig);
2715 $longtodate = $locale->date(\%myconfig, $form->{todate}, 1);
2716 $shorttodate = $locale->date(\%myconfig, $form->{todate}, 0);
2718 $longfromdate = $locale->date(\%myconfig, $form->{fromdate}, 1);
2719 $shortfromdate = $locale->date(\%myconfig, $form->{fromdate}, 0);
2721 $form->{this_period} = "$shortfromdate\n$shorttodate";
2723 $locale->text('for Period')
2724 . qq|<br>\n$longfromdate |
2725 . $locale->text('bis')
2729 if ($form->{comparefromdate} || $form->{comparetodate}) {
2730 $longcomparefromdate =
2731 $locale->date(\%myconfig, $form->{comparefromdate}, 1);
2732 $shortcomparefromdate =
2733 $locale->date(\%myconfig, $form->{comparefromdate}, 0);
2735 $longcomparetodate = $locale->date(\%myconfig, $form->{comparetodate}, 1);
2736 $shortcomparetodate = $locale->date(\%myconfig, $form->{comparetodate}, 0);
2738 $form->{last_period} = "$shortcomparefromdate\n$shortcomparetodate";
2740 "\n$longcomparefromdate "
2741 . $locale->text('bis')
2742 . qq| $longcomparetodate|;
2745 $form->{Datum_heute} =
2746 $locale->date(\%myconfig, $form->current_date(\%myconfig), 0);
2748 if ( $form->{format} eq 'pdf'
2749 or $form->{format} eq 'postscript') {
2750 $form->{padding} = "~~";
2751 $form->{bold} = "\textbf{";
2752 $form->{endbold} = "}";
2753 $form->{br} = '\\\\';
2755 @numbers = qw(51r 86r 97r 93r 96 43 45
2757 foreach $number (@numbers) {
2758 $form->{$number} =~ s/,/~~/g;
2761 } elsif ($form->{format} eq 'html') {
2762 $form->{padding} = " ";
2763 $form->{bold} = "<b>";
2764 $form->{endbold} = "</b>";
2765 $form->{br} = "<br>"
2769 # setup variables for the form
2770 @a = qw(company address businessnumber);
2771 map { $form->{$_} = $myconfig{$_} } @a;
2773 $form->{address} =~ s/\\n/$form->{br}/g;
2775 if ($form->{winston} eq '1') {
2779 $form->{templates} = $myconfig{templates};
2780 $form->{IN} = "$form->{type}";
2781 $form->{IN} .= '.tex'
2782 if ( $form->{format} eq 'pdf'
2783 or $form->{format} eq 'postscript');
2784 $form->{IN} .= '.html' if ($form->{format} eq 'html');
2786 $form->parse_template(\%myconfig, $userspath);
2788 # $form->parse_template;
2790 $lxdebug->leave_sub();