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 require "$form->{path}/arap.pl";
39 require "bin/mozilla/common.pl";
49 # this is for our long dates
50 # $locale->text('January')
51 # $locale->text('February')
52 # $locale->text('March')
53 # $locale->text('April')
54 # $locale->text('May ')
55 # $locale->text('June')
56 # $locale->text('July')
57 # $locale->text('August')
58 # $locale->text('September')
59 # $locale->text('October')
60 # $locale->text('November')
61 # $locale->text('December')
63 # this is for our short month
64 # $locale->text('Jan')
65 # $locale->text('Feb')
66 # $locale->text('Mar')
67 # $locale->text('Apr')
68 # $locale->text('May')
69 # $locale->text('Jun')
70 # $locale->text('Jul')
71 # $locale->text('Aug')
72 # $locale->text('Sep')
73 # $locale->text('Oct')
74 # $locale->text('Nov')
75 # $locale->text('Dec')
77 # $locale->text('Balance Sheet')
78 # $locale->text('Income Statement')
79 # $locale->text('Trial Balance')
80 # $locale->text('AR Aging')
81 # $locale->text('AP Aging')
82 # $locale->text('Tax collected')
83 # $locale->text('Tax paid')
84 # $locale->text('Receipts')
85 # $locale->text('Payments')
86 # $locale->text('Project Transactions')
87 # $locale->text('Non-taxable Sales')
88 # $locale->text('Non-taxable Purchases')
91 $lxdebug->enter_sub();
93 %title = ('balance_sheet' => 'Balance Sheet',
94 'income_statement' => 'Income Statement',
95 'trial_balance' => 'Trial Balance',
96 'ar_aging' => 'AR Aging',
97 'ap_aging' => 'Offene Verbindlichkeiten',
98 'tax_collected' => 'Tax collected',
99 'tax_paid' => 'Tax paid',
100 'nontaxable_sales' => 'Non-taxable Sales',
101 'nontaxable_purchases' => 'Non-taxable Purchases',
102 'receipts' => 'Receipts',
103 'payments' => 'Payments',
104 'projects' => 'Project Transactions',
105 'bwa' => 'Betriebswirtschaftliche Auswertung',
106 'ustva' => 'Umsatzsteuervoranmeldung',);
108 $form->{title} = $locale->text($title{ $form->{report} });
110 $accrual = ($eur) ? "" : "checked";
111 $cash = ($eur) ? "checked" : "";
113 ($null, $null, $null, $null, $null, $year, $null, $null, $null) =
118 $form->all_departments(\%myconfig);
119 if (@{ $form->{all_departments} }) {
120 $form->{selectdepartment} = "<option>\n";
123 $form->{selectdepartment} .=
124 "<option>$_->{description}--$_->{id}\n"
125 } (@{ $form->{all_departments} });
130 <th align=right nowrap>| . $locale->text('Department') . qq|</th>
131 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
133 | if $form->{selectdepartment};
135 $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
138 my %project_labels = ();
139 my @project_values = ("");
140 foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
141 push(@project_values, $item->{"id"});
142 $project_labels{$item->{"id"}} = $item->{"projectnumber"};
146 NTI($cgi->popup_menu('-name' => "project_id",
147 '-values' => \@project_values,
148 '-labels' => \%project_labels));
150 # use JavaScript Calendar or not
151 $form->{jsscript} = $jscalendar;
153 if ($form->{report} eq "ustva") {
156 if ($form->{report} eq "balance_sheet") {
157 $name_1 = "asofdate";
159 $value_1 = "$form->{asofdate}";
160 $trigger_1 = "trigger1";
161 $name_2 = "compareasofdate";
162 $id_2 = "compareasofdate";
163 $value_2 = "$form->{compareasofdate}";
164 $trigger_2 = "trigger2";
165 } elsif ($form->{report} =~ /(receipts|payments)$/) {
166 $name_1 = "fromdate";
168 $value_1 = "$form->{fromdate}";
169 $trigger_1 = "trigger1";
173 $trigger_2 = "trigger2";
175 if (($form->{report} eq "ar_aging") || ($form->{report} eq "ap_aging")) {
183 $trigger_2 = "trigger2";
186 $name_1 = "fromdate";
188 $value_1 = "$form->{fromdate}";
189 $trigger_1 = "trigger1";
193 $trigger_2 = "trigger2";
198 # with JavaScript Calendar
199 if ($form->{jsscript}) {
203 <input name=$name_2 id=$id_2 size=11 title="$myconfig{dateformat}">|;
205 <input type=button name=$name_2 id="$trigger_2" value=|
206 . $locale->text('button') . qq|>|;
210 Form->write_trigger(\%myconfig, "1", "$name_2", "BR", "$trigger_2");
213 <input name=$name_1 id=$id_1 size=11 title="$myconfig{dateformat}" value=$value_1>|;
215 <input type=button name=$name_1 id="$trigger_1" value=|
216 . $locale->text('button') . qq|>|;
218 <input name=$name_2 id=$id_2 size=11 title="$myconfig{dateformat}">|;
220 <input type=button name=$name_2 id="$trigger_2" value=|
221 . $locale->text('button') . qq|>
226 Form->write_trigger(\%myconfig, "2", "$name_1", "BR", "$trigger_1",
227 "$name_2", "BL", "$trigger_2");
231 # without JavaScript Calendar
234 qq|<input name=$name_2 id=$id_2 size=11 title="$myconfig{dateformat}">|;
237 qq|<input name=$name_1 id=$id_1 size=11 title="$myconfig{dateformat}" value=$value_1>|;
239 qq|<input name=$name_2 id=$id_2 size=11 title="$myconfig{dateformat}">|;
248 <form method=post action=$form->{script}>
250 <input type=hidden name=title value="$form->{title}">
254 <th class=listtop>$form->{title}</th>
263 if ($form->{report} eq "projects") {
266 <th align=right nowrap>| . $locale->text('Project') . qq|</th>
267 <td colspan=5><input name=projectnumber size=25</td>
269 <input type=hidden name=nextsub value=generate_projects>
271 <th align=right>| . $locale->text('From') . qq|</th>
274 <th align=right>| . $locale->text('Bis') . qq|</th>
285 <th align=right nowrap>| . $locale->text('Include in Report') . qq|</th>
286 <td><input name=l_heading class=checkbox type=checkbox value=Y> |
287 . $locale->text('Heading') . qq|
288 <input name=l_subtotal class=checkbox type=checkbox value=Y> |
289 . $locale->text('Subtotal') . qq|</td>
296 if ($form->{report} eq "income_statement") {
299 <th align=right nowrap>| . $locale->text('Project') . qq|</th>
300 <td colspan=3>$projectnumber</td>
302 <input type=hidden name=nextsub value=generate_income_statement>
306 <th align=left><input name=reporttype class=radio type=radio value="custom" checked> |
307 . $locale->text('Customized Report') . qq|</th>
310 <th colspan=1>| . $locale->text('Year') . qq|</th>
311 <td><input name=year size=11 title="|
312 . $locale->text('YYYY') . qq|" value="$year"></td>
319 <b> | . $locale->text('Yearly') . qq|</b> </td>
320 <th align=left>| . $locale->text('Quarterly') . qq|</th>
321 <th align=left colspan=3>| . $locale->text('Monthly') . qq|</th>
324 <td align=right> <input name=duetyp class=radio type=radio value="13"
326 <td><input name=duetyp class=radio type=radio value="A" $checked > 1. |
327 . $locale->text('Quarter') . qq|</td>
331 <td><input name=duetyp class=radio type=radio value="1" $checked > |
332 . $locale->text('January') . qq|</td>
336 <td><input name=duetyp class=radio type=radio value="5" $checked > |
337 . $locale->text('May') . qq|</td>
338 <td><input name=duetyp class=radio type=radio value="9" $checked > |
339 . $locale->text('September') . qq|</td>
343 <td align= right> </td>
344 <td><input name=duetyp class=radio type=radio value="B" $checked> 2. |
345 . $locale->text('Quarter') . qq|</td>
346 <td><input name=duetyp class=radio type=radio value="2" $checked > |
347 . $locale->text('February') . qq|</td>
348 <td><input name=duetyp class=radio type=radio value="6" $checked > |
349 . $locale->text('June') . qq|</td>
350 <td><input name=duetyp class=radio type=radio value="10" $checked > |
351 . $locale->text('October') . qq|</td>
355 <td><input name=duetyp class=radio type=radio value="C" $checked> 3. |
356 . $locale->text('Quarter') . qq|</td>
357 <td><input name=duetyp class=radio type=radio value="3" $checked > |
358 . $locale->text('March') . qq|</td>
359 <td><input name=duetyp class=radio type=radio value="7" $checked > |
360 . $locale->text('July') . qq|</td>
361 <td><input name=duetyp class=radio type=radio value="11" $checked > |
362 . $locale->text('November') . qq|</td>
367 <td><input name=duetyp class=radio type=radio value="D" $checked> 4. |
368 . $locale->text('Quarter') . qq| </td>
369 <td><input name=duetyp class=radio type=radio value="4" $checked > |
370 . $locale->text('April') . qq|</td>
371 <td><input name=duetyp class=radio type=radio value="8" $checked > |
372 . $locale->text('August') . qq|</td>
373 <td><input name=duetyp class=radio type=radio value="12" $checked > |
374 . $locale->text('December') . qq|</td>
378 <td colspan=5><hr size=3 noshade></td>
381 <th align=left><input name=reporttype class=radio type=radio value="free" $checked> |
382 . $locale->text('Free report period') . qq|</th>
383 <td align=left colspan=4>| . $locale->text('From') . qq|
386 | . $locale->text('Bis') . qq|
392 <td colspan=5><hr size=3 noshade></td>
395 <th align=leftt>| . $locale->text('Method') . qq|</th>
396 <td colspan=3><input name=method class=radio type=radio value=accrual $accrual>|
397 . $locale->text('Accrual') . qq|
398 <input name=method class=radio type=radio value=cash $cash>|
399 . $locale->text('EUR') . qq|</td>
406 if ($form->{report} eq "bwa") {
409 <th align=right nowrap>| . $locale->text('Project') . qq|</th>
410 <td colspan=3>$projectnumber</td>
412 <input type=hidden name=nextsub value=generate_bwa>
416 <th align=left><input name=reporttype class=radio type=radio value="custom" checked> |
417 . $locale->text('Customized Report') . qq|</th>
420 <th colspan=1>| . $locale->text('Year') . qq|</th>
421 <td><input name=year size=11 title="|
422 . $locale->text('YYYY') . qq|" value="$year"></td>
429 <b> | . $locale->text('Yearly') . qq|</b> </td>
430 <th align=left>| . $locale->text('Quarterly') . qq|</th>
431 <th align=left colspan=3>| . $locale->text('Monthly') . qq|</th>
434 <td align=right> <input name=duetyp class=radio type=radio value="13"
436 <td><input name=duetyp class=radio type=radio value="A" $checked > 1. |
437 . $locale->text('Quarter') . qq|</td>
439 $checked = "checked";
441 <td><input name=duetyp class=radio type=radio value="1" $checked > |
442 . $locale->text('January') . qq|</td>
446 <td><input name=duetyp class=radio type=radio value="5" $checked > |
447 . $locale->text('May') . qq|</td>
448 <td><input name=duetyp class=radio type=radio value="9" $checked > |
449 . $locale->text('September') . qq|</td>
453 <td align= right> </td>
454 <td><input name=duetyp class=radio type=radio value="B" $checked> 2. |
455 . $locale->text('Quarter') . qq|</td>
456 <td><input name=duetyp class=radio type=radio value="2" $checked > |
457 . $locale->text('February') . qq|</td>
458 <td><input name=duetyp class=radio type=radio value="6" $checked > |
459 . $locale->text('June') . qq|</td>
460 <td><input name=duetyp class=radio type=radio value="10" $checked > |
461 . $locale->text('October') . qq|</td>
465 <td><input name=duetyp class=radio type=radio value="C" $checked> 3. |
466 . $locale->text('Quarter') . qq|</td>
467 <td><input name=duetyp class=radio type=radio value="3" $checked > |
468 . $locale->text('March') . qq|</td>
469 <td><input name=duetyp class=radio type=radio value="7" $checked > |
470 . $locale->text('July') . qq|</td>
471 <td><input name=duetyp class=radio type=radio value="11" $checked > |
472 . $locale->text('November') . qq|</td>
477 <td><input name=duetyp class=radio type=radio value="D" $checked> 4. |
478 . $locale->text('Quarter') . qq| </td>
479 <td><input name=duetyp class=radio type=radio value="4" $checked > |
480 . $locale->text('April') . qq|</td>
481 <td><input name=duetyp class=radio type=radio value="8" $checked > |
482 . $locale->text('August') . qq|</td>
483 <td><input name=duetyp class=radio type=radio value="12" $checked > |
484 . $locale->text('December') . qq|</td>
488 <td colspan=5><hr size=3 noshade></td>
491 <th align=left><input name=reporttype class=radio type=radio value="free" $checked> |
492 . $locale->text('Free report period') . qq|</th>
493 <td align=left colspan=4>| . $locale->text('From') . qq|
496 | . $locale->text('Bis') . qq|
502 <td colspan=5><hr size=3 noshade></td>
505 <th align=leftt>| . $locale->text('Method') . qq|</th>
506 <td colspan=3><input name=method class=radio type=radio value=accrual $accrual>|
507 . $locale->text('Accrual') . qq|
508 <input name=method class=radio type=radio value=cash $cash>|
509 . $locale->text('EUR') . qq|</td>
512 <th align=right colspan=4>|
513 . $locale->text('Decimalplaces')
515 <td><input name=decimalplaces size=3 value="2"></td>
522 if ($form->{report} eq "ustva") {
527 <input type=hidden name=nextsub value=generate_ustva>
531 <th align=left><input name=reporttype class=radio type=radio value="custom" checked> |
532 . $locale->text('Zeitraum') . qq|</th>
535 <th colspan=1>| . $locale->text('Year') . qq|</th>
536 <td><input name=year size=11 title="|
537 . $locale->text('YYYY') . qq|" value="$year"></td>
544 <b> | . $locale->text('Yearly') . qq|</b> </td>
545 <th align=left>| . $locale->text('Quarterly') . qq|</th>
546 <th align=left colspan=3>| . $locale->text('Monthly') . qq|</th>
549 <td align=right> <input name=duetyp class=radio type=radio value="13"
551 <td><input name=duetyp class=radio type=radio value="A" $checked > 1. |
552 . $locale->text('Quarter') . qq|</td>
554 $checked = "checked";
556 <td><input name=duetyp class=radio type=radio value="1" $checked > |
557 . $locale->text('January') . qq|</td>
561 <td><input name=duetyp class=radio type=radio value="5" $checked > |
562 . $locale->text('May') . qq|</td>
563 <td><input name=duetyp class=radio type=radio value="9" $checked > |
564 . $locale->text('September') . qq|</td>
568 <td align= right> </td>
569 <td><input name=duetyp class=radio type=radio value="B" $checked> 2. |
570 . $locale->text('Quarter') . qq|</td>
571 <td><input name=duetyp class=radio type=radio value="2" $checked > |
572 . $locale->text('February') . qq|</td>
573 <td><input name=duetyp class=radio type=radio value="6" $checked > |
574 . $locale->text('June') . qq|</td>
575 <td><input name=duetyp class=radio type=radio value="10" $checked > |
576 . $locale->text('October') . qq|</td>
580 <td><input name=duetyp class=radio type=radio value="C" $checked> 3. |
581 . $locale->text('Quarter') . qq|</td>
582 <td><input name=duetyp class=radio type=radio value="3" $checked > |
583 . $locale->text('March') . qq|</td>
584 <td><input name=duetyp class=radio type=radio value="7" $checked > |
585 . $locale->text('July') . qq|</td>
586 <td><input name=duetyp class=radio type=radio value="11" $checked > |
587 . $locale->text('November') . qq|</td>
592 <td><input name=duetyp class=radio type=radio value="D" $checked> 4. |
593 . $locale->text('Quarter') . qq| </td>
594 <td><input name=duetyp class=radio type=radio value="4" $checked > |
595 . $locale->text('April') . qq|</td>
596 <td><input name=duetyp class=radio type=radio value="8" $checked > |
597 . $locale->text('August') . qq|</td>
598 <td><input name=duetyp class=radio type=radio value="12" $checked > |
599 . $locale->text('December') . qq|</td>
603 <td colspan=5><hr size=3 noshade></td>
606 <th align=left>| . $locale->text('Method') . qq|</th>
607 <td colspan=3><input name=method class=radio type=radio value=accrual $accrual>|
608 . $locale->text('Accrual') . qq|
609 <input name=method class=radio type=radio value=cash $cash>|
610 . $locale->text('EUR') . qq|</td>
623 if ($form->{report} eq "balance_sheet") {
625 <input type=hidden name=nextsub value=generate_balance_sheet>
627 <th align=right>| . $locale->text('as at') . qq|</th>
632 <th align=right nowrap>| . $locale->text('Compare to') . qq|</th>
639 <th align=right>| . $locale->text('Decimalplaces') . qq|</th>
640 <td><input name=decimalplaces size=3 value="2"></td>
649 <th align=right>| . $locale->text('Method') . qq|</th>
650 <td colspan=3><input name=method class=radio type=radio value=accrual $accrual>|
651 . $locale->text('Accrual') . qq|
652 <input name=method class=radio type=radio value=cash $cash>|
653 . $locale->text('EUR') . qq|</td>
657 <th align=right nowrap>| . $locale->text('Include in Report') . qq|</th>
658 <td><input name=l_heading class=checkbox type=checkbox value=Y> |
659 . $locale->text('Heading') . qq|
660 <input name=l_subtotal class=checkbox type=checkbox value=Y> |
661 . $locale->text('Subtotal') . qq|
662 <input name=l_accno class=checkbox type=checkbox value=Y> |
663 . $locale->text('Account Number') . qq|</td>
670 if ($form->{report} eq "trial_balance") {
672 <input type=hidden name=nextsub value=generate_trial_balance>
673 <input type=hidden name=eur value=$eur>
675 <th align=right>| . $locale->text('From') . qq|</th>
680 <th align=right>| . $locale->text('Bis') . qq|</th>
693 <th align=right nowrap>| . $locale->text('Include in Report') . qq|</th>
694 <td><input name=l_heading class=checkbox type=checkbox value=Y> |
695 . $locale->text('Heading') . qq|
696 <input name=l_subtotal class=checkbox type=checkbox value=Y> |
697 . $locale->text('Subtotal') . qq|
698 <input name=all_accounts class=checkbox type=checkbox value=Y> |
699 . $locale->text('All Accounts') . qq|</td>
706 if ($form->{report} =~ /^tax_/) {
707 $form->{db} = ($form->{report} =~ /_collected/) ? "ar" : "ap";
709 RP->get_taxaccounts(\%myconfig, \%$form);
712 <input type=hidden name=nextsub value=generate_tax_report>
714 <th align=right>| . $locale->text('From') . qq|</th>
715 <td><input name=fromdate size=11 title="$myconfig{dateformat}" value=$form->{fromdate}></td>
716 <th align=right>| . $locale->text('Bis') . qq|</th>
717 <td><input name=todate size=11 title="$myconfig{dateformat}"></td>
720 <th align=right>| . $locale->text('Report for') . qq|</th>
724 $checked = "checked";
725 foreach $ref (@{ $form->{taxaccounts} }) {
728 qq|<input name=accno class=radio type=radio value=$ref->{accno} $checked> $ref->{description}
730 <input name="$ref->{accno}_description" type=hidden value="$ref->{description}">
731 <input name="$ref->{accno}_rate" type=hidden value="$ref->{rate}">|;
738 <input type=hidden name=db value=$form->{db}>
739 <input type=hidden name=sort value=transdate>
744 <th align=right>| . $locale->text('Method') . qq|</th>
745 <td colspan=3><input name=method class=radio type=radio value=accrual $accrual>|
746 . $locale->text('Accrual') . qq|
747 <input name=method class=radio type=radio value=cash $cash>|
748 . $locale->text('EUR') . qq|</td>
757 <th align=right>| . $locale->text('Include in Report') . qq|</th>
761 <td><input name="l_id" class=checkbox type=checkbox value=Y></td>
762 <td>| . $locale->text('ID') . qq|</td>
763 <td><input name="l_invnumber" class=checkbox type=checkbox value=Y checked></td>
764 <td>| . $locale->text('Invoice') . qq|</td>
765 <td><input name="l_transdate" class=checkbox type=checkbox value=Y checked></td>
766 <td>| . $locale->text('Date') . qq|</td>
769 <td><input name="l_name" class=checkbox type=checkbox value=Y checked></td>
772 if ($form->{db} eq 'ar') {
773 print $locale->text('Customer');
775 if ($form->{db} eq 'ap') {
776 print $locale->text('Vendor');
780 <td><input name="l_netamount" class=checkbox type=checkbox value=Y checked></td>
781 <td>| . $locale->text('Amount') . qq|</td>
782 <td><input name="l_tax" class=checkbox type=checkbox value=Y checked></td>
783 <td>| . $locale->text('Tax') . qq|</td>
784 <td><input name="l_amount" class=checkbox type=checkbox value=Y></td>
785 <td>| . $locale->text('Total') . qq|</td>
788 <td><input name="l_subtotal" class=checkbox type=checkbox value=Y></td>
789 <td>| . $locale->text('Subtotal') . qq|</td>
798 if ($form->{report} =~ /^nontaxable_/) {
799 $form->{db} = ($form->{report} =~ /_sales/) ? "ar" : "ap";
802 <input type=hidden name=nextsub value=generate_tax_report>
804 <input type=hidden name=db value=$form->{db}>
805 <input type=hidden name=sort value=transdate>
806 <input type=hidden name=report value=$form->{report}>
809 <th align=right>| . $locale->text('From') . qq|</th>
810 <td><input name=fromdate size=11 title="$myconfig{dateformat}" value=$form->{fromdate}></td>
811 <th align=right>| . $locale->text('Bis') . qq|</th>
812 <td><input name=todate size=11 title="$myconfig{dateformat}"></td>
815 <th align=right>| . $locale->text('Method') . qq|</th>
816 <td colspan=3><input name=method class=radio type=radio value=accrual $accrual>|
817 . $locale->text('Accrual') . qq|
818 <input name=method class=radio type=radio value=cash $cash>|
819 . $locale->text('EUR') . qq|</td>
822 <th align=right>| . $locale->text('Include in Report') . qq|</th>
826 <td><input name="l_id" class=checkbox type=checkbox value=Y></td>
827 <td>| . $locale->text('ID') . qq|</td>
828 <td><input name="l_invnumber" class=checkbox type=checkbox value=Y checked></td>
829 <td>| . $locale->text('Invoice') . qq|</td>
830 <td><input name="l_transdate" class=checkbox type=checkbox value=Y checked></td>
831 <td>| . $locale->text('Date') . qq|</td>
834 <td><input name="l_name" class=checkbox type=checkbox value=Y checked></td>
837 if ($form->{db} eq 'ar') {
838 print $locale->text('Customer');
840 if ($form->{db} eq 'ap') {
841 print $locale->text('Vendor');
845 <td><input name="l_netamount" class=checkbox type=checkbox value=Y checked></td>
846 <td>| . $locale->text('Amount') . qq|</td>
847 <td><input name="l_amount" class=checkbox type=checkbox value=Y></td>
848 <td>| . $locale->text('Total') . qq|</td>
851 <td><input name="l_subtotal" class=checkbox type=checkbox value=Y></td>
852 <td>| . $locale->text('Subtotal') . qq|</td>
861 if (($form->{report} eq "ar_aging") || ($form->{report} eq "ap_aging")) {
862 if ($form->{report} eq 'ar_aging') {
863 $label = $locale->text('Customer');
864 $form->{vc} = 'customer';
866 $label = $locale->text('Vendor');
867 $form->{vc} = 'vendor';
870 $nextsub = "generate_$form->{report}";
873 $form->all_vc(\%myconfig, $form->{vc},
874 ($form->{vc} eq 'customer') ? "AR" : "AP");
876 map { $vc .= "<option>$_->{name}--$_->{id}\n" }
877 @{ $form->{"all_$form->{vc}"} };
881 ? qq|<select name=$form->{vc}><option>\n$vc</select>|
882 : qq|<input name=$form->{vc} size=35>|;
886 <th align=right>| . $locale->text($label) . qq|</th>
890 <th align=right>| . $locale->text('Bis') . qq|</th>
896 <input type=hidden name=type value=statement>
897 <input type=hidden name=format value=html>
898 <input type=hidden name=media value=screen>
900 <input type=hidden name=nextsub value=$nextsub>
901 <input type=hidden name=action value=$nextsub>
907 # above action can be removed if there is more than one input field
909 if ($form->{report} =~ /(receipts|payments)$/) {
910 $form->{db} = ($form->{report} =~ /payments$/) ? "ap" : "ar";
912 RP->paymentaccounts(\%myconfig, \%$form);
914 $selection = "<option>\n";
915 foreach $ref (@{ $form->{PR} }) {
916 $paymentaccounts .= "$ref->{accno} ";
917 $selection .= "<option>$ref->{accno}--$ref->{description}\n";
920 chop $paymentaccounts;
923 <input type=hidden name=nextsub value=list_payments>
925 <th align=right nowrap>| . $locale->text('Account') . qq|</th>
926 <td colspan=3><select name=account>$selection</select>
927 <input type=hidden name=paymentaccounts value="$paymentaccounts">
931 <th align=right>| . $locale->text('Reference') . qq|</th>
932 <td colspan=3><input name=reference></td>
935 <th align=right nowrap>| . $locale->text('Source') . qq|</th>
936 <td colspan=3><input name=source></td>
939 <th align=right nowrap>| . $locale->text('Memo') . qq|</th>
940 <td colspan=3><input name=memo size=30></td>
943 <th align=right>| . $locale->text('From') . qq|</th>
948 <th align=right>| . $locale->text('Bis') . qq|</th>
955 <td align=right><input type=checkbox style=checkbox name=fx_transaction value=1 checked></td>
956 <th align=left colspan=3>|
957 . $locale->text('Include Exchangerate Difference') . qq|</td>
962 <input type=hidden name=db value=$form->{db}>
963 <input type=hidden name=sort value=transdate>
974 <td><hr size=3 noshade></td>
979 <input type=hidden name=path value=$form->{path}>
980 <input type=hidden name=login value=$form->{login}>
981 <input type=hidden name=password value=$form->{password}>
983 <input type=submit class=submit name=action value="|
984 . $locale->text('Continue') . qq|">
987 # Hier Aufruf von get_config zum Einlesen der Finanzamtdaten
988 USTVA->get_config($userspath, 'finanzamt.ini');
990 $disabled = qq|disabled="disabled"|;
991 $disabled = '' if ($form->{elster} eq '1');
992 if ($form->{report} eq 'ustva') {
994 <input type=submit class=submit name=action value="|
995 . $locale->text('debug') . qq|">
996 <input type=submit class=submit name=action $disabled
997 value="| . $locale->text('winston_export') . qq|">
1000 <input type=submit class=submit name=action value="|
1001 . $locale->text('config') . qq|">
1012 $lxdebug->leave_sub();
1015 sub continue { call_sub($form->{"nextsub"}); }
1018 $lxdebug->enter_sub();
1019 my $nextsub = shift;
1021 $form->{project_id} = $form->{project_id_1};
1022 if ($form->{projectnumber} && !$form->{project_id}) {
1023 $form->{rowcount} = 1;
1025 # call this instead of update
1026 $form->{update} = $nextsub;
1027 $form->{projectnumber_1} = $form->{projectnumber};
1029 delete $form->{sort};
1032 # if there is one only, assign id
1033 $form->{project_id} = $form->{project_id_1};
1036 $lxdebug->leave_sub();
1039 sub generate_income_statement {
1040 $lxdebug->enter_sub();
1042 $form->{padding} = " ";
1043 $form->{bold} = "<b>";
1044 $form->{endbold} = "</b>";
1045 $form->{br} = "<br>";
1047 if ($form->{reporttype} eq "custom") {
1049 #forgotten the year --> thisyear
1050 if ($form->{year} !~ m/^\d\d\d\d$/) {
1051 $locale->date(\%myconfig, $form->current_date(\%myconfig), 0) =~
1057 if ($form->{duetyp} eq "13") {
1058 $form->{fromdate} = "1.1.$form->{year}";
1059 $form->{todate} = "31.12.$form->{year}";
1063 if ($form->{duetyp} eq "A") {
1064 $form->{fromdate} = "1.1.$form->{year}";
1065 $form->{todate} = "31.3.$form->{year}";
1067 if ($form->{duetyp} eq "B") {
1068 $form->{fromdate} = "1.4.$form->{year}";
1069 $form->{todate} = "30.6.$form->{year}";
1071 if ($form->{duetyp} eq "C") {
1072 $form->{fromdate} = "1.7.$form->{year}";
1073 $form->{todate} = "30.9.$form->{year}";
1075 if ($form->{duetyp} eq "D") {
1076 $form->{fromdate} = "1.10.$form->{year}";
1077 $form->{todate} = "31.12.$form->{year}";
1082 $form->{duetyp} eq "1" && do {
1083 $form->{fromdate} = "1.1.$form->{year}";
1084 $form->{todate} = "31.1.$form->{year}";
1087 $form->{duetyp} eq "2" && do {
1088 $form->{fromdate} = "1.2.$form->{year}";
1090 #this works from 1901 to 2099, 1900 and 2100 fail.
1091 $leap = ($form->{year} % 4 == 0) ? "29" : "28";
1092 $form->{todate} = "$leap.2.$form->{year}";
1095 $form->{duetyp} eq "3" && do {
1096 $form->{fromdate} = "1.3.$form->{year}";
1097 $form->{todate} = "31.3.$form->{year}";
1100 $form->{duetyp} eq "4" && do {
1101 $form->{fromdate} = "1.4.$form->{year}";
1102 $form->{todate} = "30.4.$form->{year}";
1105 $form->{duetyp} eq "5" && do {
1106 $form->{fromdate} = "1.5.$form->{year}";
1107 $form->{todate} = "31.5.$form->{year}";
1110 $form->{duetyp} eq "6" && do {
1111 $form->{fromdate} = "1.6.$form->{year}";
1112 $form->{todate} = "30.6.$form->{year}";
1115 $form->{duetyp} eq "7" && do {
1116 $form->{fromdate} = "1.7.$form->{year}";
1117 $form->{todate} = "31.7.$form->{year}";
1120 $form->{duetyp} eq "8" && do {
1121 $form->{fromdate} = "1.8.$form->{year}";
1122 $form->{todate} = "31.8.$form->{year}";
1125 $form->{duetyp} eq "9" && do {
1126 $form->{fromdate} = "1.9.$form->{year}";
1127 $form->{todate} = "30.9.$form->{year}";
1130 $form->{duetyp} eq "10" && do {
1131 $form->{fromdate} = "1.10.$form->{year}";
1132 $form->{todate} = "31.10.$form->{year}";
1135 $form->{duetyp} eq "11" && do {
1136 $form->{fromdate} = "1.11.$form->{year}";
1137 $form->{todate} = "30.11.$form->{year}";
1140 $form->{duetyp} eq "12" && do {
1141 $form->{fromdate} = "1.12.$form->{year}";
1142 $form->{todate} = "31.12.$form->{year}";
1148 RP->income_statement(\%myconfig, \%$form);
1150 ($form->{department}) = split /--/, $form->{department};
1153 $locale->date(\%myconfig, $form->current_date(\%myconfig), 1);
1154 $form->{todate} = $form->current_date(\%myconfig) unless $form->{todate};
1156 # if there are any dates construct a where
1157 if ($form->{fromdate} || $form->{todate}) {
1159 unless ($form->{todate}) {
1160 $form->{todate} = $form->current_date(\%myconfig);
1163 $longtodate = $locale->date(\%myconfig, $form->{todate}, 1);
1164 $shorttodate = $locale->date(\%myconfig, $form->{todate}, 0);
1166 $longfromdate = $locale->date(\%myconfig, $form->{fromdate}, 1);
1167 $shortfromdate = $locale->date(\%myconfig, $form->{fromdate}, 0);
1169 $form->{this_period} = "$shortfromdate\n$shorttodate";
1171 $locale->text('for Period')
1172 . qq|\n$longfromdate |
1173 . $locale->text('Bis')
1177 if ($form->{comparefromdate} || $form->{comparetodate}) {
1178 $longcomparefromdate =
1179 $locale->date(\%myconfig, $form->{comparefromdate}, 1);
1180 $shortcomparefromdate =
1181 $locale->date(\%myconfig, $form->{comparefromdate}, 0);
1183 $longcomparetodate = $locale->date(\%myconfig, $form->{comparetodate}, 1);
1184 $shortcomparetodate = $locale->date(\%myconfig, $form->{comparetodate}, 0);
1186 $form->{last_period} = "$shortcomparefromdate\n$shortcomparetodate";
1188 "\n$longcomparefromdate "
1189 . $locale->text('Bis')
1190 . qq| $longcomparetodate|;
1193 # setup variables for the form
1194 @a = qw(company address businessnumber);
1195 map { $form->{$_} = $myconfig{$_} } @a;
1197 $form->{templates} = $myconfig{templates};
1199 $form->{IN} = "income_statement.html";
1201 $form->parse_template;
1203 $lxdebug->leave_sub();
1206 sub generate_balance_sheet {
1207 $lxdebug->enter_sub();
1209 $form->{padding} = " ";
1210 $form->{bold} = "<b>";
1211 $form->{endbold} = "</b>";
1212 $form->{br} = "<br>";
1214 RP->balance_sheet(\%myconfig, \%$form);
1216 $form->{asofdate} = $form->current_date(\%myconfig) unless $form->{asofdate};
1218 $locale->date(\%myconfig, $form->current_date(\%myconfig), 1);
1220 ($form->{department}) = split /--/, $form->{department};
1222 # define Current Earnings account
1223 $padding = ($form->{l_heading}) ? $form->{padding} : "";
1224 push(@{ $form->{equity_account} },
1225 $padding . $locale->text('Current Earnings'));
1227 $form->{this_period} = $locale->date(\%myconfig, $form->{asofdate}, 0);
1228 $form->{last_period} =
1229 $locale->date(\%myconfig, $form->{compareasofdate}, 0);
1231 $form->{IN} = "balance_sheet.html";
1233 # setup company variables for the form
1234 map { $form->{$_} = $myconfig{$_};
1235 $form->{$_} =~ s/\\n/\n/g; }
1236 (qw(company address businessnumber nativecurr));
1238 $form->{templates} = $myconfig{templates};
1240 $form->parse_template;
1242 $lxdebug->leave_sub();
1245 sub generate_projects {
1246 $lxdebug->enter_sub();
1248 &get_project(generate_projects);
1249 $form->{projectnumber} = $form->{projectnumber_1};
1251 $form->{nextsub} = "generate_projects";
1252 $form->{title} = $locale->text('Project Transactions');
1253 RP->trial_balance(\%myconfig, \%$form);
1257 $lxdebug->leave_sub();
1263 # included links to display transactions for period entered
1264 # added headers and subtotals
1266 sub generate_trial_balance {
1267 $lxdebug->enter_sub();
1269 # get for each account initial balance, debits and credits
1270 RP->trial_balance(\%myconfig, \%$form);
1272 $form->{nextsub} = "generate_trial_balance";
1273 $form->{title} = $locale->text('Trial Balance');
1276 $lxdebug->leave_sub();
1280 $lxdebug->enter_sub();
1282 $title = $form->escape($form->{title});
1284 if ($form->{department}) {
1285 ($department) = split /--/, $form->{department};
1286 $options = $locale->text('Department') . " : $department<br>";
1287 $department = $form->escape($form->{department});
1289 if ($form->{projectnumber}) {
1291 $locale->text('Project Number') . " : $form->{projectnumber}<br>";
1292 $projectnumber = $form->escape($form->{projectnumber});
1295 # if there are any dates
1296 if ($form->{fromdate} || $form->{todate}) {
1297 if ($form->{fromdate}) {
1298 $fromdate = $locale->date(\%myconfig, $form->{fromdate}, 1);
1300 if ($form->{todate}) {
1301 $todate = $locale->date(\%myconfig, $form->{todate}, 1);
1304 $form->{period} = "$fromdate - $todate";
1307 $locale->date(\%myconfig, $form->current_date(\%myconfig), 1);
1310 $options .= $form->{period};
1312 @column_index = qw(accno description begbalance debit credit endbalance);
1314 $column_header{accno} =
1315 qq|<th class=listheading>| . $locale->text('Account') . qq|</th>|;
1316 $column_header{description} =
1317 qq|<th class=listheading>| . $locale->text('Description') . qq|</th>|;
1318 $column_header{debit} =
1319 qq|<th class=listheading>| . $locale->text('Debit') . qq|</th>|;
1320 $column_header{credit} =
1321 qq|<th class=listheading>| . $locale->text('Credit') . qq|</th>|;
1322 $column_header{begbalance} =
1323 qq|<th class=listheading>| . $locale->text('Balance') . qq|</th>|;
1324 $column_header{endbalance} =
1325 qq|<th class=listheading>| . $locale->text('Balance') . qq|</th>|;
1334 <th class=listtop>$form->{title}</th>
1336 <tr height="5"></tr>
1345 map { print "$column_header{$_}\n" } @column_index;
1351 # sort the whole thing by account numbers and display
1352 foreach $ref (sort { $a->{accno} cmp $b->{accno} } @{ $form->{TB} }) {
1354 $description = $form->escape($ref->{description});
1357 qq|ca.pl?path=$form->{path}&action=list_transactions&accounttype=$form->{accounttype}&login=$form->{login}&password=$form->{password}&fromdate=$form->{fromdate}&todate=$form->{todate}&sort=transdate&l_heading=$form->{l_heading}&l_subtotal=$form->{l_subtotal}&department=$department&eur=$form->{eur}&projectnumber=$projectnumber&project_id=$form->{project_id}&title=$title&nextsub=$form->{nextsub}&accno=$ref->{accno}&description=$description|;
1359 $ml = ($ref->{category} =~ /(A|C|E)/) ? -1 : 1;
1361 $debit = ($ref->{debit} != 0) ? $form->format_amount(\%myconfig, $ref->{debit}, 2, " ") : " ";
1362 $credit = ($ref->{credit} != 0) ? $form->format_amount(\%myconfig, $ref->{credit}, 2, " ") : " ";
1364 $form->format_amount(\%myconfig, $ref->{balance} * $ml, 2, " ");
1366 $form->format_amount(\%myconfig,
1367 ($ref->{balance} + $ref->{amount}) * $ml,
1370 # next if ($ref->{debit} == 0 && $ref->{credit} == 0);
1372 if ($ref->{charttype} eq "H" && $subtotal && $form->{l_subtotal}) {
1373 map { $column_data{$_} = "<th> </th>" }
1374 qw(accno begbalance endbalance);
1376 $subtotalbegbalance =
1377 $form->format_amount(\%myconfig, $subtotalbegbalance, 2, " ");
1378 $subtotalendbalance =
1379 $form->format_amount(\%myconfig, $subtotalendbalance, 2, " ");
1381 $form->format_amount(\%myconfig, $subtotaldebit, 2, " ");
1383 $form->format_amount(\%myconfig, $subtotalcredit, 2, " ");
1385 $column_data{description} = "<th>$subtotaldescription</th>";
1386 $column_data{begbalance} = "<th align=right>$subtotalbegbalance</th>";
1387 $column_data{endbalance} = "<th align=right>$subtotalendbalance</th>";
1388 $column_data{debit} = "<th align=right>$subtotaldebit</th>";
1389 $column_data{credit} = "<th align=right>$subtotalcredit</th>";
1392 <tr class=listsubtotal>
1394 map { print "$column_data{$_}\n" } @column_index;
1401 if ($ref->{charttype} eq "H") {
1403 $subtotaldescription = $ref->{description};
1404 $subtotaldebit = $ref->{debit};
1405 $subtotalcredit = $ref->{credit};
1406 $subtotalbegbalance = 0;
1407 $subtotalendbalance = 0;
1409 next unless $form->{l_heading};
1411 map { $column_data{$_} = "<th> </th>" }
1412 qw(accno debit credit begbalance endbalance);
1413 $column_data{description} =
1414 "<th class=listheading>$ref->{description}</th>";
1417 if ($ref->{charttype} eq "A") {
1418 $column_data{accno} = "<td><a href=$href>$ref->{accno}</a></td>";
1419 $column_data{description} = "<td>$ref->{description}</td>";
1420 $column_data{debit} = "<td align=right>$debit</td>";
1421 $column_data{credit} = "<td align=right>$credit</td>";
1422 $column_data{begbalance} = "<td align=right>$begbalance</td>";
1423 $column_data{endbalance} = "<td align=right>$endbalance</td>";
1425 $totaldebit += $ref->{debit};
1426 $totalcredit += $ref->{credit};
1428 $subtotalbegbalance += $ref->{balance} * $ml;
1429 $subtotalendbalance += ($ref->{balance} + $ref->{amount}) * $ml;
1433 if ($ref->{charttype} eq "H") {
1435 <tr class=listheading>
1438 if ($ref->{charttype} eq "A") {
1442 <tr class=listrow$i>
1446 map { print "$column_data{$_}\n" } @column_index;
1453 # print last subtotal
1454 if ($subtotal && $form->{l_subtotal}) {
1455 map { $column_data{$_} = "<th> </th>" }
1456 qw(accno begbalance endbalance);
1457 $subtotalbegbalance =
1458 $form->format_amount(\%myconfig, $subtotalbegbalance, 2, " ");
1459 $subtotalendbalance =
1460 $form->format_amount(\%myconfig, $subtotalendbalance, 2, " ");
1462 $form->format_amount(\%myconfig, $subtotaldebit, 2, " ");
1464 $form->format_amount(\%myconfig, $subtotalcredit, 2, " ");
1465 $column_data{description} = "<th>$subdescription</th>";
1466 $column_data{begbalance} = "<th align=right>$subtotalbegbalance</th>";
1467 $column_data{endbalance} = "<th align=right>$subtotalendbalance</th>";
1468 $column_data{debit} = "<th align=right>$subtotaldebit</th>";
1469 $column_data{credit} = "<th align=right>$subtotalcredit</th>";
1472 <tr class=listsubtotal>
1474 map { print "$column_data{$_}\n" } @column_index;
1481 $totaldebit = $form->format_amount(\%myconfig, $totaldebit, 2, " ");
1482 $totalcredit = $form->format_amount(\%myconfig, $totalcredit, 2, " ");
1484 map { $column_data{$_} = "<th> </th>" }
1485 qw(accno description begbalance endbalance);
1487 $column_data{debit} = qq|<th align=right class=listtotal>$totaldebit</th>|;
1488 $column_data{credit} = qq|<th align=right class=listtotal>$totalcredit</th>|;
1491 <tr class=listtotal>
1494 map { print "$column_data{$_}\n" } @column_index;
1502 <td><hr size=3 noshade></td>
1510 $lxdebug->leave_sub();
1513 sub generate_ar_aging {
1514 $lxdebug->enter_sub();
1517 ($form->{customer}) = split(/--/, $form->{customer});
1518 $customer = $form->escape($form->{customer}, 1);
1519 $title = $form->escape($form->{title}, 1);
1521 $form->{ct} = "customer";
1522 $form->{arap} = "ar";
1525 qq|$form->{script}?path=$form->{path}&action=generate_ar_aging&login=$form->{login}&password=$form->{password}&todate=$form->{todate}&customer=$customer&title=$title|;
1527 RP->aging(\%myconfig, \%$form);
1530 $lxdebug->leave_sub();
1533 sub generate_ap_aging {
1534 $lxdebug->enter_sub();
1537 ($form->{vendor}) = split(/--/, $form->{vendor});
1538 $vendor = $form->escape($form->{vendor}, 1);
1539 $title = $form->escape($form->{title}, 1);
1541 $form->{ct} = "vendor";
1542 $form->{arap} = "ap";
1545 qq|$form->{script}?path=$form->{path}&action=generate_ap_aging&login=$form->{login}&password=$form->{password}&todate=$form->{todate}&vendor=$vendor&title=$title|;
1547 RP->aging(\%myconfig, \%$form);
1550 $lxdebug->leave_sub();
1554 $lxdebug->enter_sub();
1558 $column_header{statement} = qq|<th> </th>|;
1559 $column_header{ct} =
1560 qq|<th class=listheading>|
1561 . $locale->text(ucfirst $form->{ct})
1563 $column_header{invnumber} =
1564 qq|<th class=listheading>| . $locale->text('Invoice') . qq|</th>|;
1565 $column_header{transdate} =
1566 qq|<th class=listheading>| . $locale->text('Date') . qq|</th>|;
1567 $column_header{duedate} =
1568 qq|<th class=listheading>| . $locale->text('Due') . qq|</th>|;
1569 $column_header{c0} =
1570 qq|<th class=listheading>| . $locale->text('Current') . qq|</th>|;
1571 $column_header{c30} = qq|<th class=listheading>30</th>|;
1572 $column_header{c60} = qq|<th class=listheading>60</th>|;
1573 $column_header{c90} = qq|<th class=listheading>90</th>|;
1576 (qw(statement ct invnumber transdate duedate c0 c30 c60 c90));
1578 if ($form->{department}) {
1579 $option .= "\n<br>" if $option;
1580 ($department) = split /--/, $form->{department};
1581 $option .= $locale->text('Department') . " : $department";
1582 $department = $form->escape($form->{department}, 1);
1583 $form->{callback} .= "&department=$department";
1586 if ($form->{arap} eq 'ar') {
1587 if ($form->{customer}) {
1588 $option .= "\n<br>" if $option;
1589 $option .= $form->{customer};
1592 if ($form->{arap} eq 'ap') {
1593 shift @column_index;
1594 if ($form->{vendor}) {
1595 $option .= "\n<br>" if $option;
1596 $option .= $form->{vendor};
1600 $todate = $locale->date(\%myconfig, $form->{todate}, 1);
1601 $option .= "\n<br>" if $option;
1603 $locale->text('for Period') . " " . $locale->text('Bis') . " $todate";
1608 <form method=post action=$form->{script}>
1612 <th class=listtop>$form->{title}</th>
1614 <tr height="5"></tr>
1621 <tr class=listheading>
1624 map { print "$column_header{$_}\n" } @column_index;
1634 foreach $ref (@{ $form->{AG} }) {
1636 if ($ctid != $ref->{ctid}) {
1641 $c0subtotal = ($c0subtotal != 0) ?
1642 $form->format_amount(\%myconfig, $c0subtotal, 2, " ") : "";
1643 $c30subtotal = ($c30subtotal != 0) ?
1644 $form->format_amount(\%myconfig, $c30subtotal, 2, " ") : "";
1645 $c60subtotal = ($c60subtotal != 0) ?
1646 $form->format_amount(\%myconfig, $c60subtotal, 2, " ") : "";
1647 $c90subtotal = ($c90subtotal != 0) ?
1648 $form->format_amount(\%myconfig, $c90subtotal, 2, " ") : "";
1651 $column_data{ct} = qq|<th> </th>|;
1652 $column_data{invnumber} = qq|<th> </th>|;
1653 $column_data{transdate} = qq|<th> </th>|;
1654 $column_data{duedate} = qq|<th> </th>|;
1656 qq|<th align=right class=listsubtotal>$c0subtotal</th>|;
1658 qq|<th align=right class=listsubtotal>$c30subtotal</th>|;
1660 qq|<th align=right class=listsubtotal>$c60subtotal</th>|;
1662 qq|<th align=right class=listsubtotal>$c90subtotal</th>|;
1668 <tr class=listsubtotal>
1671 map { print "$column_data{$_}\n" } @column_index;
1673 $column_data{statement} = qq|<td> </td>|;
1687 $column_data{ct} = qq|<td>$ref->{name}</td>|;
1688 $column_data{statement} =
1689 qq|<td><input name="statement_$i" type=checkbox class=checkbox value=1 $ref->{checked}>
1690 <input type=hidden name="$form->{ct}_id_$i" value=$ref->{ctid}>
1694 $c0subtotal += $ref->{c0};
1695 $c30subtotal += $ref->{c30};
1696 $c60subtotal += $ref->{c60};
1697 $c90subtotal += $ref->{c90};
1699 $c0total += $ref->{c0};
1700 $c30total += $ref->{c30};
1701 $c60total += $ref->{c60};
1702 $c90total += $ref->{c90};
1704 $ref->{c0} = ($ref->{c0} != 0) ? $form->format_amount(\%myconfig, $ref->{c0}, 2, " ") : "";
1705 $ref->{c30} = ($ref->{c30} != 0) ? $form->format_amount(\%myconfig, $ref->{c30}, 2, " ") : "";
1706 $ref->{c60} = ($ref->{c60} != 0) ? $form->format_amount(\%myconfig, $ref->{c60}, 2, " ") : "";
1707 $ref->{c90} = ($ref->{c90} != 0) ? $form->format_amount(\%myconfig, $ref->{c90}, 2, " ") : "";
1710 qq|$ref->{module}.pl?path=$form->{path}&action=edit&id=$ref->{id}&login=$form->{login}&password=$form->{password}&callback=|
1711 . $form->escape($form->{callback});
1713 $column_data{invnumber} = qq|<td><a href=$href>$ref->{invnumber}</a></td>|;
1714 $column_data{transdate} = qq|<td>$ref->{transdate}</td>|;
1715 $column_data{duedate} = qq|<td>$ref->{duedate} </td>|;
1716 $column_data{c0} = qq|<td align=right>$ref->{c0}</td>|;
1717 $column_data{c30} = qq|<td align=right>$ref->{c30}</td>|;
1718 $column_data{c60} = qq|<td align=right>$ref->{c60}</td>|;
1719 $column_data{c90} = qq|<td align=right>$ref->{c90}</td>|;
1724 <tr class=listrow$j>
1727 map { print "$column_data{$_}\n" } @column_index;
1733 $column_data{ct} = qq|<td> </td>|;
1734 $column_data{statement} = qq|<td> </td>|;
1736 $ctid = $ref->{ctid};
1741 $c0subtotal = $form->format_amount(\%myconfig, $c0subtotal, 2, " ");
1742 $c30subtotal = $form->format_amount(\%myconfig, $c30subtotal, 2, " ");
1743 $c60subtotal = $form->format_amount(\%myconfig, $c60subtotal, 2, " ");
1744 $c90subtotal = $form->format_amount(\%myconfig, $c90subtotal, 2, " ");
1747 <tr class=listsubtotal>
1750 map { $column_data{$_} = qq|<th> </th>| } @column_index;
1752 $column_data{c0} = qq|<th align=right class=listsubtotal>$c0subtotal</th>|;
1753 $column_data{c30} = qq|<th align=right class=listsubtotal>$c30subtotal</th>|;
1754 $column_data{c60} = qq|<th align=right class=listsubtotal>$c60subtotal</th>|;
1755 $column_data{c90} = qq|<th align=right class=listsubtotal>$c90subtotal</th>|;
1757 map { print "$column_data{$_}\n" } @column_index;
1761 <tr class=listtotal>
1764 $c0total = $form->format_amount(\%myconfig, $c0total, 2, " ");
1765 $c30total = $form->format_amount(\%myconfig, $c30total, 2, " ");
1766 $c60total = $form->format_amount(\%myconfig, $c60total, 2, " ");
1767 $c90total = $form->format_amount(\%myconfig, $c90total, 2, " ");
1769 $column_data{c0} = qq|<th align=right class=listtotal>$c0total</th>|;
1770 $column_data{c30} = qq|<th align=right class=listtotal>$c30total</th>|;
1771 $column_data{c60} = qq|<th align=right class=listtotal>$c60total</th>|;
1772 $column_data{c90} = qq|<th align=right class=listtotal>$c90total</th>|;
1774 map { print "$column_data{$_}\n" } @column_index;
1777 <input type=hidden name=rowcount value=$i>
1786 &print_options if ($form->{arap} eq 'ar');
1792 <td><hr size=3 noshade></td>
1797 if ($form->{arap} eq 'ar') {
1799 <input type=hidden name=todate value=$form->{todate}>
1801 <input type=hidden name=title value="$form->{title}">
1803 <input type=hidden name=arap value=$form->{arap}>
1804 <input type=hidden name=ct value=$form->{ct}>
1805 <input type=hidden name=$form->{ct} value="$form->{$form->{ct}}">
1807 <input type=hidden name=department value="$form->{department}">
1809 <input type=hidden name=path value=$form->{path}>
1810 <input type=hidden name=login value=$form->{login}>
1811 <input type=hidden name=password value=$form->{password}>
1814 <input class=submit type=submit name=action value="|
1815 . $locale->text('Select all') . qq|">
1816 <input class=submit type=submit name=action value="|
1817 . $locale->text('Print') . qq|">
1818 <input class=submit type=submit name=action value="|
1819 . $locale->text('E-mail') . qq|">|;
1829 $lxdebug->leave_sub();
1833 $lxdebug->enter_sub();
1835 RP->aging(\%myconfig, \%$form);
1837 map { $_->{checked} = "checked" } @{ $form->{AG} };
1841 $lxdebug->leave_sub();
1845 $lxdebug->enter_sub();
1847 # get name and email addresses
1848 for $i (1 .. $form->{rowcount}) {
1849 if ($form->{"statement_$i"}) {
1850 $form->{"$form->{ct}_id"} = $form->{"$form->{ct}_id_$i"};
1851 RP->get_customer(\%myconfig, \%$form);
1857 $form->error($locale->text('Nothing selected!')) unless $selected;
1859 if ($myconfig{role} eq 'admin') {
1861 <th align=right nowrap=true>| . $locale->text('Bcc') . qq|</th>
1862 <td><input name=bcc size=30 value="$form->{bcc}"></td>
1866 $title = $locale->text('E-mail Statement to') . " $form->{$form->{ct}}";
1868 $form->{media} = "email";
1875 <form method=post action=$form->{script}>
1881 <tr height="5"></tr>
1886 <th align=right nowrap>| . $locale->text('E-mail') . qq|</th>
1887 <td><input name=email size=30 value="$form->{email}"></td>
1888 <th align=right nowrap>| . $locale->text('Cc') . qq|</th>
1889 <td><input name=cc size=30 value="$form->{cc}"></td>
1892 <th align=right nowrap>| . $locale->text('Subject') . qq|</th>
1893 <td><input name=subject size=30 value="$form->{subject}"></td>
1903 <th align=left nowrap>| . $locale->text('Message') . qq|</th>
1906 <td><textarea name=message rows=15 cols=60 wrap=soft>$form->{message}</textarea></td>
1917 map { delete $form->{$_} }
1918 qw(action email cc bcc subject message type sendmode format header);
1920 # save all other variables
1921 foreach $key (keys %$form) {
1922 $form->{$key} =~ s/\"/"/g;
1923 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
1930 <td><hr size=3 noshade></td>
1934 <input type=hidden name=nextsub value=send_email>
1937 <input name=action class=submit type=submit value="|
1938 . $locale->text('Continue') . qq|">
1945 $lxdebug->leave_sub();
1949 $lxdebug->enter_sub();
1951 $form->{OUT} = "$sendmail";
1953 $form->{subject} = $locale->text('Statement') . qq| - $form->{todate}|
1954 unless $form->{subject};
1956 RP->aging(\%myconfig, \%$form);
1958 $form->{"statement_1"} = 1;
1963 $locale->text('Statement sent to') . " $form->{$form->{ct}}");
1965 $lxdebug->leave_sub();
1969 $lxdebug->enter_sub();
1971 if ($form->{media} eq 'printer') {
1972 $form->error($locale->text('Select postscript or PDF!'))
1973 if ($form->{format} !~ /(postscript|pdf)/);
1976 for $i (1 .. $form->{rowcount}) {
1977 if ($form->{"statement_$i"}) {
1978 $form->{"$form->{ct}_id"} = $form->{"$form->{ct}_id_$i"};
1984 $form->error($locale->text('Nothing selected!')) unless $selected;
1986 if ($form->{media} eq 'printer') {
1987 $form->{OUT} = "| $myconfig{printer}";
1988 $form->{"$form->{ct}_id"} = "";
1990 $form->{"statement_1"} = 1;
1993 RP->aging(\%myconfig, \%$form);
1997 $form->redirect($locale->text('Statements sent to printer!'))
1998 if ($form->{media} eq 'printer');
2000 $lxdebug->leave_sub();
2004 $lxdebug->enter_sub();
2008 "ä" => "ae", "ö" => "oe", "ü" => "ue",
2009 "Ä" => "Ae", "Ö" => "Oe", "Ü" => "Ue",
2014 $form->{statementdate} = $locale->date(\%myconfig, $form->{todate}, 1);
2016 $form->{templates} = "$myconfig{templates}";
2018 my $suffix = "html";
2019 my $attachment_suffix = "html";
2020 if ($form->{format} eq 'postscript') {
2021 $form->{postscript} = 1;
2023 $attachment_suffix = "ps";
2024 } elsif ($form->{format} eq 'pdf') {
2027 $attachment_suffix = "pdf";
2030 $form->{IN} = "$form->{type}.$suffix";
2033 # Save $form->{email} because it will be overwritten.
2034 $form->{EMAIL_RECIPIENT} = $form->{email};
2037 while (@{ $form->{AG} }) {
2039 $ref = shift @{ $form->{AG} };
2041 if ($ctid != $ref->{ctid}) {
2043 $ctid = $ref->{ctid};
2046 if ($form->{"statement_$i"}) {
2049 (name, street, zipcode, city, country, contact, email,
2050 "$form->{ct}phone", "$form->{ct}fax");
2051 map { $form->{$_} = $ref->{$_} } @a;
2053 $form->{ $form->{ct} } = $form->{name};
2054 $form->{"$form->{ct}_id"} = $ref->{ctid};
2056 map { $form->{$_} = () } qw(invnumber invdate duedate);
2058 foreach $item (qw(c0 c30 c60 c90)) {
2059 $form->{$item} = ();
2060 $form->{"${item}total"} = 0;
2063 &statement_details($ref);
2067 if (scalar(@{ $form->{AG} }) > 0) {
2069 # one or more left to go
2070 if ($ctid == $form->{AG}->[0]->{ctid}) {
2071 $ref = shift @{ $form->{AG} };
2072 &statement_details($ref);
2075 $ref = scalar(@{ $form->{AG} });
2081 # set initial ref to 0
2088 $form->{"${_}total"} =
2089 $form->format_amount(\%myconfig, $form->{"${_}total"}, 2)
2090 } (c0, c30, c60, c90, "");
2092 $form->{attachment_filename} = $locale->text("Statement") . "_$form->{todate}.$attachment_suffix";
2093 map({ $form->{attachment_filename} =~ s/$_/$replacements{$_}/g; } keys(%replacements));
2095 $form->parse_template(\%myconfig, $userspath);
2100 # saving the history
2101 if(!exists $form->{addition} && $form->{id} ne "") {
2102 $form->{addition} = "PRINTED";
2103 $form->{what_done} = $form->{type};
2104 $form->save_history($form->dbconnect(\%myconfig));
2106 # /saving the history
2107 $lxdebug->leave_sub();
2110 sub statement_details {
2111 $lxdebug->enter_sub();
2114 push @{ $form->{invnumber} }, $ref->{invnumber};
2115 push @{ $form->{invdate} }, $ref->{transdate};
2116 push @{ $form->{duedate} }, $ref->{duedate};
2118 foreach $item (qw(c0 c30 c60 c90)) {
2119 if ($ref->{exchangerate} * 1) {
2121 $form->round_amount($ref->{$item} / $ref->{exchangerate}, 2);
2123 $form->{"${item}total"} += $ref->{$item};
2124 $form->{total} += $ref->{$item};
2125 push @{ $form->{$item} },
2126 $form->format_amount(\%myconfig, $ref->{$item}, 2);
2129 $lxdebug->leave_sub();
2132 sub generate_tax_report {
2133 $lxdebug->enter_sub();
2135 RP->tax_report(\%myconfig, \%$form);
2137 $descvar = "$form->{accno}_description";
2138 $description = $form->escape($form->{$descvar});
2139 $ratevar = "$form->{accno}_rate";
2141 $department = $form->escape($form->{department});
2145 "$form->{script}?path=$form->{path}&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}";
2147 # construct callback
2148 $description = $form->escape($form->{$descvar}, 1);
2149 $department = $form->escape($form->{department}, 1);
2151 "$form->{script}?path=$form->{path}&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}";
2153 $title = $form->escape($form->{title});
2154 $href .= "&title=$title";
2155 $title = $form->escape($form->{title}, 1);
2156 $callback .= "&title=$title";
2158 $form->{title} = qq|$form->{title} $form->{"$form->{accno}_description"} |;
2161 $form->sort_columns(qw(id transdate invnumber name netamount tax amount));
2163 foreach $item (@columns) {
2164 if ($form->{"l_$item"} eq "Y") {
2165 push @column_index, $item;
2167 # add column to href and callback
2168 $callback .= "&l_$item=Y";
2169 $href .= "&l_$item=Y";
2173 if ($form->{l_subtotal} eq 'Y') {
2174 $callback .= "&l_subtotal=Y";
2175 $href .= "&l_subtotal=Y";
2178 if ($form->{department}) {
2179 ($department) = split /--/, $form->{department};
2180 $option = $locale->text('Department') . " : $department";
2183 # if there are any dates
2184 if ($form->{fromdate} || $form->{todate}) {
2185 if ($form->{fromdate}) {
2186 $fromdate = $locale->date(\%myconfig, $form->{fromdate}, 1);
2188 if ($form->{todate}) {
2189 $todate = $locale->date(\%myconfig, $form->{todate}, 1);
2192 $form->{period} = "$fromdate - $todate";
2195 $locale->date(\%myconfig, $form->current_date(\%myconfig), 1);
2198 if ($form->{db} eq 'ar') {
2199 $name = $locale->text('Customer');
2203 if ($form->{db} eq 'ap') {
2204 $name = $locale->text('Vendor');
2209 $option .= "<br>" if $option;
2210 $option .= "$form->{period}";
2212 $column_header{id} =
2213 qq|<th><a class=listheading href=$href&sort=id>|
2214 . $locale->text('ID')
2216 $column_header{invnumber} =
2217 qq|<th><a class=listheading href=$href&sort=invnumber>|
2218 . $locale->text('Invoice')
2220 $column_header{transdate} =
2221 qq|<th><a class=listheading href=$href&sort=transdate>|
2222 . $locale->text('Date')
2224 $column_header{netamount} =
2225 qq|<th class=listheading>| . $locale->text('Amount') . qq|</th>|;
2226 $column_header{tax} =
2227 qq|<th class=listheading>| . $locale->text('Tax') . qq|</th>|;
2228 $column_header{amount} =
2229 qq|<th class=listheading>| . $locale->text('Total') . qq|</th>|;
2231 $column_header{name} =
2232 qq|<th><a class=listheading href=$href&sort=name>$name</th>|;
2241 <th class=listtop colspan=$colspan>$form->{title}</th>
2243 <tr height="5"></tr>
2250 <tr class=listheading>
2253 map { print "$column_header{$_}\n" } @column_index;
2259 # add sort and escape callback
2260 $callback = $form->escape($callback . "&sort=$form->{sort}");
2262 if (@{ $form->{TR} }) {
2263 $sameitem = $form->{TR}->[0]->{ $form->{sort} };
2266 foreach $ref (@{ $form->{TR} }) {
2268 $module = ($ref->{invoice}) ? $invoice : $arap;
2270 if ($form->{l_subtotal} eq 'Y') {
2271 if ($sameitem ne $ref->{ $form->{sort} }) {
2273 $sameitem = $ref->{ $form->{sort} };
2277 $totalnetamount += $ref->{netamount};
2278 $totaltax += $ref->{tax};
2279 $ref->{amount} = $ref->{netamount} + $ref->{tax};
2281 $subtotalnetamount += $ref->{netamount};
2282 $subtotaltax += $ref->{tax};
2285 $ref->{$_} = $form->format_amount(\%myconfig, $ref->{$_}, 2, " ");
2286 } qw(netamount tax amount);
2288 $column_data{id} = qq|<td>$ref->{id}</td>|;
2289 $column_data{invnumber} =
2290 qq|<td><a href=$module?path=$form->{path}&action=edit&id=$ref->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{invnumber}</a></td>|;
2291 $column_data{transdate} = qq|<td>$ref->{transdate}</td>|;
2292 $column_data{name} = qq|<td>$ref->{name} </td>|;
2294 map { $column_data{$_} = qq|<td align=right>$ref->{$_}</td>| }
2295 qw(netamount tax amount);
2300 <tr class=listrow$i>
2303 map { print "$column_data{$_}\n" } @column_index;
2311 if ($form->{l_subtotal} eq 'Y') {
2315 map { $column_data{$_} = qq|<th> </th>| } @column_index;
2319 <tr class=listtotal>
2323 $form->format_amount(\%myconfig, $totalnetamount + $totaltax, 2, " ");
2325 $form->format_amount(\%myconfig, $totalnetamount, 2, " ");
2326 $totaltax = $form->format_amount(\%myconfig, $totaltax, 2, " ");
2328 $column_data{netamount} =
2329 qq|<th class=listtotal align=right>$totalnetamount</th>|;
2330 $column_data{tax} = qq|<th class=listtotal align=right>$totaltax</th>|;
2331 $column_data{amount} = qq|<th class=listtotal align=right>$total</th>|;
2333 map { print "$column_data{$_}\n" } @column_index;
2341 <td><hr size=3 noshade></td>
2349 $lxdebug->leave_sub();
2353 $lxdebug->enter_sub();
2355 map { $column_data{$_} = "<td> </td>" } @column_index;
2357 $subtotalnetamount =
2358 $form->format_amount(\%myconfig, $subtotalnetamount, 2, " ");
2359 $subtotaltax = $form->format_amount(\%myconfig, $subtotaltax, 2, " ");
2361 $form->format_amount(\%myconfig, $subtotalnetamount + $subtotaltax,
2364 $column_data{netamount} =
2365 "<th class=listsubtotal align=right>$subtotalnetamount</th>";
2366 $column_data{tax} = "<th class=listsubtotal align=right>$subtotaltax</th>";
2367 $column_data{amount} = "<th class=listsubtotal align=right>$subtotal</th>";
2369 $subtotalnetamount = 0;
2373 <tr class=listsubtotal>
2375 map { print "\n$column_data{$_}" } @column_index;
2381 $lxdebug->leave_sub();
2385 $lxdebug->enter_sub();
2387 if ($form->{account}) {
2388 ($form->{paymentaccounts}) = split /--/, $form->{account};
2390 if ($form->{department}) {
2391 ($department, $form->{department_id}) = split /--/, $form->{department};
2392 $option = $locale->text('Department') . " : $department";
2395 RP->payments(\%myconfig, \%$form);
2398 $form->sort_columns(qw(transdate reference name paid source memo));
2401 $account = $form->escape($form->{account});
2402 $title = $form->escape($form->{title});
2403 $department = $form->escape($form->{department});
2404 $form->{paymentaccounts} =~ s/ /%20/g;
2405 $reference = $form->escape($form->{reference});
2406 $source = $form->escape($form->{source});
2407 $memo = $form->escape($form->{memo});
2410 "$form->{script}?path=$form->{path}&action=list_payments&login=$form->{login}&password=$form->{password}&fromdate=$form->{fromdate}&todate=$form->{todate}&fx_transaction=$form->{fx_transaction}&db=$form->{db}&prepayment=$form->{prepayment}&title=$title&account=$account&department=$department&paymentaccounts=$form->{paymentaccounts}&reference=$reference&source=$source&memo=$memo";
2412 # construct callback
2413 $account = $form->escape($form->{account}, 1);
2414 $title = $form->escape($form->{title}, 1);
2415 $department = $form->escape($form->{department}, 1);
2416 $reference = $form->escape($form->{reference}, 1);
2417 $source = $form->escape($form->{source}, 1);
2418 $memo = $form->escape($form->{memo}, 1);
2421 "$form->{script}?path=$form->{path}&action=list_payments&login=$form->{login}&password=$form->{password}&fromdate=$form->{fromdate}&todate=$form->{todate}&fx_transaction=$form->{fx_transaction}&db=$form->{db}&prepayment=$form->{prepayment}&title=$title&account=$account&department=$department&paymentaccounts=$form->{paymentaccounts}&reference=$reference&source=$source&memo=$memo&sort=$form->{sort}";
2422 $callback = $form->escape($form->{callback});
2424 $column_header{name} =
2425 "<th><a class=listheading href=$href&sort=name>"
2426 . $locale->text('Description')
2428 $column_header{reference} =
2429 "<th><a class=listheading href=$href&sort=invnumber>"
2430 . $locale->text('Reference')
2432 $column_header{transdate} =
2433 "<th><a class=listheading href=$href&sort=transdate>"
2434 . $locale->text('Date')
2436 $column_header{paid} =
2437 "<th class=listheading>" . $locale->text('Amount') . "</a></th>";
2438 $column_header{source} =
2439 "<th><a class=listheading href=$href&sort=source>"
2440 . $locale->text('Source')
2442 $column_header{memo} =
2443 "<th><a class=listheading href=$href&sort=memo>"
2444 . $locale->text('Memo')
2447 if ($form->{fromdate}) {
2448 $option .= "\n<br>" if ($option);
2450 $locale->text('From') . " "
2451 . $locale->date(\%myconfig, $form->{fromdate}, 1);
2453 if ($form->{todate}) {
2454 $option .= "\n<br>" if ($option);
2456 $locale->text('bis') . " "
2457 . $locale->date(\%myconfig, $form->{todate}, 1);
2460 @column_index = @columns;
2461 $colspan = $#column_index + 1;
2470 <th class=listtop>$form->{title}</th>
2472 <tr height="5"></tr>
2479 <tr class=listheading>
2482 map { print "\n$column_header{$_}" } @column_index;
2488 foreach $ref (sort { $a->{accno} cmp $b->{accno} } @{ $form->{PR} }) {
2490 next unless @{ $form->{ $ref->{id} } };
2494 <th colspan=$colspan align=left>$ref->{accno}--$ref->{description}</th>
2498 foreach $payment (@{ $form->{ $ref->{id} } }) {
2500 $module = $payment->{module};
2501 $module = 'is' if ($payment->{invoice} && $payment->{module} eq 'ar');
2502 $module = 'ir' if ($payment->{invoice} && $payment->{module} eq 'ap');
2505 qq|${module}.pl?path=$form->{path}&action=edit&id=$payment->{id}&login=$form->{login}&password=$form->{password}&callback=$callback|;
2507 $column_data{name} = "<td>$payment->{name} </td>";
2508 $column_data{reference} =
2509 qq|<td><a href=$href>$payment->{invnumber}</a></td>|;
2510 $column_data{transdate} = "<td>$payment->{transdate} </td>";
2511 $column_data{paid} =
2513 . $form->format_amount(\%myconfig, $payment->{paid}, 2, " ")
2515 $column_data{source} = "<td>$payment->{source} </td>";
2516 $column_data{memo} = "<td>$payment->{memo} </td>";
2518 $subtotalpaid += $payment->{paid};
2519 $totalpaid += $payment->{paid};
2524 <tr class=listrow$i>
2527 map { print "\n$column_data{$_}" } @column_index;
2536 map { $column_data{$_} = "<td> </td>" } @column_index;
2538 $column_data{paid} =
2539 "<th class=listsubtotal align=right>"
2540 . $form->format_amount(\%myconfig, $subtotalpaid, 2, " ") . "</th>";
2543 <tr class=listsubtotal>
2546 map { print "\n$column_data{$_}" } @column_index;
2557 map { $column_data{$_} = "<td> </td>" } @column_index;
2559 $column_data{paid} =
2560 "<th class=listtotal align=right>"
2561 . $form->format_amount(\%myconfig, $totalpaid, 2, " ") . "</th>";
2564 <tr class=listtotal>
2567 map { print "\n$column_data{$_}" } @column_index;
2576 <td><hr size=3 noshade></td>
2584 $lxdebug->leave_sub();
2588 $lxdebug->enter_sub();
2593 $lxdebug->leave_sub();
2602 sub winston_export {
2603 $lxdebug->enter_sub();
2606 $form->{winston} = 1;
2608 $lxdebug->leave_sub();
2612 $lxdebug->enter_sub();
2614 $form->{sendmode} = "attachment";
2617 $form->{"format"} ? $form->{"format"} :
2618 $myconfig{"template_format"} ? $myconfig{"template_format"} :
2622 $form->{"copies"} ? $form->{"copies"} :
2623 $myconfig{"copies"} ? $myconfig{"copies"} :
2626 $form->{PD}{ $form->{type} } = "selected";
2627 $form->{DF}{ $form->{format} } = "selected";
2628 $form->{OP}{ $form->{media} } = "selected";
2629 $form->{SM}{ $form->{sendmode} } = "selected";
2631 if ($form->{report} eq 'ustva') {
2633 <option value=ustva $form->{PD}{ustva}>| . $locale->text('ustva');
2636 <option value=statement $form->{PD}{statement}>|
2637 . $locale->text('Statement');
2640 if ($form->{media} eq 'email') {
2642 <option value=attachment $form->{SM}{attachment}>|
2643 . $locale->text('Attachment') . qq|
2644 <option value=inline $form->{SM}{inline}>| . $locale->text('In-line');
2647 <option value=screen $form->{OP}{screen}>| . $locale->text('Screen');
2648 if ($myconfig{printer} && $latex_templates) {
2650 <option value=printer $form->{OP}{printer}>|
2651 . $locale->text('Printer');
2655 if ($latex_templates) {
2657 <option value=html $form->{DF}{html}>|
2658 . $locale->text('HTML') . qq|
2659 <option value=pdf $form->{DF}{pdf}>| . $locale->text('PDF');
2660 if ($form->{report} ne 'ustva') {
2662 <option value=postscript $form->{DF}{postscript}>|
2663 . $locale->text('Postscript');
2670 <td><select name=type>$type</select></td>
2671 <td><select name=format>$format</select></td>
2672 <td><select name=media>$media</select></td>
2675 if ($myconfig{printer} && $latex_templates && $form->{media} ne 'email') {
2677 <td>| . $locale->text('Copies') . qq|
2678 <input name=copies size=2 value=$form->{copies}></td>
2687 $lxdebug->leave_sub();
2691 $lxdebug->enter_sub();
2692 $form->{padding} = " ";
2693 $form->{bold} = "<b>";
2694 $form->{endbold} = "</b>";
2695 $form->{br} = "<br>";
2697 if ($form->{reporttype} eq "custom") {
2699 #forgotten the year --> thisyear
2700 if ($form->{year} !~ m/^\d\d\d\d$/) {
2701 $locale->date(\%myconfig, $form->current_date(\%myconfig), 0) =~
2707 if ($form->{duetyp} eq "13") {
2708 $form->{fromdate} = "1.1.$form->{year}";
2709 $form->{todate} = "31.12.$form->{year}";
2710 $form->{comparefromdate} = "1.01.$form->{year}";
2711 $form->{comparetodate} = "31.12.$form->{year}";
2715 if ($form->{duetyp} eq "A") {
2716 $form->{fromdate} = "1.1.$form->{year}";
2717 $form->{todate} = "31.3.$form->{year}";
2718 $form->{comparefromdate} = "1.01.$form->{year}";
2719 $form->{comparetodate} = "31.03.$form->{year}";
2721 if ($form->{duetyp} eq "B") {
2722 $form->{fromdate} = "1.4.$form->{year}";
2723 $form->{todate} = "30.6.$form->{year}";
2724 $form->{comparefromdate} = "1.01.$form->{year}";
2725 $form->{comparetodate} = "30.06.$form->{year}";
2727 if ($form->{duetyp} eq "C") {
2728 $form->{fromdate} = "1.7.$form->{year}";
2729 $form->{todate} = "30.9.$form->{year}";
2730 $form->{comparefromdate} = "1.01.$form->{year}";
2731 $form->{comparetodate} = "30.09.$form->{year}";
2733 if ($form->{duetyp} eq "D") {
2734 $form->{fromdate} = "1.10.$form->{year}";
2735 $form->{todate} = "31.12.$form->{year}";
2736 $form->{comparefromdate} = "1.01.$form->{year}";
2737 $form->{comparetodate} = "31.12.$form->{year}";
2742 $form->{duetyp} eq "1" && do {
2743 $form->{fromdate} = "1.1.$form->{year}";
2744 $form->{todate} = "31.1.$form->{year}";
2745 $form->{comparefromdate} = "1.01.$form->{year}";
2746 $form->{comparetodate} = "31.01.$form->{year}";
2749 $form->{duetyp} eq "2" && do {
2750 $form->{fromdate} = "1.2.$form->{year}";
2752 #this works from 1901 to 2099, 1900 and 2100 fail.
2753 $leap = ($form->{year} % 4 == 0) ? "29" : "28";
2754 $form->{todate} = "$leap.2.$form->{year}";
2755 $form->{comparefromdate} = "1.01.$form->{year}";
2756 $form->{comparetodate} = "$leap.02.$form->{year}";
2759 $form->{duetyp} eq "3" && do {
2760 $form->{fromdate} = "1.3.$form->{year}";
2761 $form->{todate} = "31.3.$form->{year}";
2762 $form->{comparefromdate} = "1.01.$form->{year}";
2763 $form->{comparetodate} = "31.03.$form->{year}";
2766 $form->{duetyp} eq "4" && do {
2767 $form->{fromdate} = "1.4.$form->{year}";
2768 $form->{todate} = "30.4.$form->{year}";
2769 $form->{comparefromdate} = "1.01.$form->{year}";
2770 $form->{comparetodate} = "30.04.$form->{year}";
2773 $form->{duetyp} eq "5" && do {
2774 $form->{fromdate} = "1.5.$form->{year}";
2775 $form->{todate} = "31.5.$form->{year}";
2776 $form->{comparefromdate} = "1.01.$form->{year}";
2777 $form->{comparetodate} = "31.05.$form->{year}";
2780 $form->{duetyp} eq "6" && do {
2781 $form->{fromdate} = "1.6.$form->{year}";
2782 $form->{todate} = "30.6.$form->{year}";
2783 $form->{comparefromdate} = "1.01.$form->{year}";
2784 $form->{comparetodate} = "30.06.$form->{year}";
2787 $form->{duetyp} eq "7" && do {
2788 $form->{fromdate} = "1.7.$form->{year}";
2789 $form->{todate} = "31.7.$form->{year}";
2790 $form->{comparefromdate} = "1.01.$form->{year}";
2791 $form->{comparetodate} = "31.07.$form->{year}";
2794 $form->{duetyp} eq "8" && do {
2795 $form->{fromdate} = "1.8.$form->{year}";
2796 $form->{todate} = "31.8.$form->{year}";
2797 $form->{comparefromdate} = "1.01.$form->{year}";
2798 $form->{comparetodate} = "31.08.$form->{year}";
2801 $form->{duetyp} eq "9" && do {
2802 $form->{fromdate} = "1.9.$form->{year}";
2803 $form->{todate} = "30.9.$form->{year}";
2804 $form->{comparefromdate} = "1.01.$form->{year}";
2805 $form->{comparetodate} = "30.09.$form->{year}";
2808 $form->{duetyp} eq "10" && do {
2809 $form->{fromdate} = "1.10.$form->{year}";
2810 $form->{todate} = "31.10.$form->{year}";
2811 $form->{comparefromdate} = "1.01.$form->{year}";
2812 $form->{comparetodate} = "31.10.$form->{year}";
2815 $form->{duetyp} eq "11" && do {
2816 $form->{fromdate} = "1.11.$form->{year}";
2817 $form->{todate} = "30.11.$form->{year}";
2818 $form->{comparefromdate} = "1.01.$form->{year}";
2819 $form->{comparetodate} = "30.11.$form->{year}";
2822 $form->{duetyp} eq "12" && do {
2823 $form->{fromdate} = "1.12.$form->{year}";
2824 $form->{todate} = "31.12.$form->{year}";
2825 $form->{comparefromdate} = "1.01.$form->{year}";
2826 $form->{comparetodate} = "31.12.$form->{year}";
2831 ($yy, $mm, $dd) = $locale->parse_date(\%myconfig, $form->{fromdate});
2832 $form->{fromdate} = "${dd}.${mm}.${yy}";
2833 ($yy, $mm, $dd) = $locale->parse_date(\%myconfig, $form->{todate});
2834 $form->{todate} = "${dd}.${mm}.${yy}";
2835 $form->{comparefromdate} = "01.01.$yy";
2836 $form->{comparetodate} = $form->{todate};
2839 RP->bwa(\%myconfig, \%$form);
2841 ($form->{department}) = split /--/, $form->{department};
2844 $locale->date(\%myconfig, $form->current_date(\%myconfig), 1);
2845 $form->{todate} = $form->current_date(\%myconfig) unless $form->{todate};
2847 # if there are any dates construct a where
2848 if ($form->{fromdate} || $form->{todate}) {
2850 unless ($form->{todate}) {
2851 $form->{todate} = $form->current_date(\%myconfig);
2854 my %germandate = ("dateformat" => "dd.mm.yyyy");
2856 $longtodate = $locale->date(\%germandate, $form->{todate}, 1);
2857 $shorttodate = $locale->date(\%germandate, $form->{todate}, 0);
2859 $longfromdate = $locale->date(\%germandate, $form->{fromdate}, 1);
2860 $shortfromdate = $locale->date(\%germandate, $form->{fromdate}, 0);
2862 $form->{this_period} = "$shortfromdate\n$shorttodate";
2864 $locale->text('for Period')
2865 . qq|\n$longfromdate |
2866 . $locale->text('bis')
2870 # setup variables for the form
2871 @a = qw(company address businessnumber);
2872 map { $form->{$_} = $myconfig{$_} } @a;
2873 $form->{templates} = $myconfig{templates};
2875 $form->{IN} = "bwa.html";
2877 $form->parse_template;
2879 $lxdebug->leave_sub();
2882 sub generate_ustva {
2883 $lxdebug->enter_sub();
2885 # Hier Aufruf von get_config zum Einlesen der Finanzamtdaten
2886 USTVA->get_config($userspath, 'finanzamt.ini');
2888 # &get_project(generate_bwa);
2889 @anmeldungszeitraum =
2890 qw(0401, 0402, 0403, 0404, 0405, 0405, 0406, 0407, 0408, 0409, 0410, 0411, 0412, 0441, 0442, 0443, 0444);
2892 foreach $item (@anmeldungszeitraum) {
2893 $form->{$item} = "";
2895 if ($form->{reporttype} eq "custom") {
2897 #forgotten the year --> thisyear
2898 if ($form->{year} !~ m/^\d\d\d\d$/) {
2899 $locale->date(\%myconfig, $form->current_date(\%myconfig), 0) =~
2905 if ($form->{duetyp} eq "13") {
2906 $form->{fromdate} = "1.1.$form->{year}";
2907 $form->{todate} = "31.12.$form->{year}";
2911 if ($form->{duetyp} eq "A") {
2912 $form->{fromdate} = "1.1.$form->{year}";
2913 $form->{todate} = "31.3.$form->{year}";
2914 $form->{"0441"} = "X";
2916 if ($form->{duetyp} eq "B") {
2917 $form->{fromdate} = "1.4.$form->{year}";
2918 $form->{todate} = "30.6.$form->{year}";
2919 $form->{"0442"} = "X";
2921 if ($form->{duetyp} eq "C") {
2922 $form->{fromdate} = "1.7.$form->{year}";
2923 $form->{todate} = "30.9.$form->{year}";
2924 $form->{"0443"} = "X";
2926 if ($form->{duetyp} eq "D") {
2927 $form->{fromdate} = "1.10.$form->{year}";
2928 $form->{todate} = "31.12.$form->{year}";
2929 $form->{"0444"} = "X";
2934 $form->{duetyp} eq "1" && do {
2935 $form->{fromdate} = "1.1.$form->{year}";
2936 $form->{todate} = "31.1.$form->{year}";
2937 $form->{"0401"} = "X";
2940 $form->{duetyp} eq "2" && do {
2941 $form->{fromdate} = "1.2.$form->{year}";
2943 #this works from 1901 to 2099, 1900 and 2100 fail.
2944 $leap = ($form->{year} % 4 == 0) ? "29" : "28";
2945 $form->{todate} = "$leap.2.$form->{year}";
2946 $form->{"0402"} = "X";
2949 $form->{duetyp} eq "3" && do {
2950 $form->{fromdate} = "1.3.$form->{year}";
2951 $form->{todate} = "31.3.$form->{year}";
2952 $form->{"0403"} = "X";
2955 $form->{duetyp} eq "4" && do {
2956 $form->{fromdate} = "1.4.$form->{year}";
2957 $form->{todate} = "30.4.$form->{year}";
2958 $form->{"0404"} = "X";
2961 $form->{duetyp} eq "5" && do {
2962 $form->{fromdate} = "1.5.$form->{year}";
2963 $form->{todate} = "31.5.$form->{year}";
2964 $form->{"0405"} = "X";
2967 $form->{duetyp} eq "6" && do {
2968 $form->{fromdate} = "1.6.$form->{year}";
2969 $form->{todate} = "30.6.$form->{year}";
2970 $form->{"0406"} = "X";
2973 $form->{duetyp} eq "7" && do {
2974 $form->{fromdate} = "1.7.$form->{year}";
2975 $form->{todate} = "31.7.$form->{year}";
2976 $form->{"0407"} = "X";
2979 $form->{duetyp} eq "8" && do {
2980 $form->{fromdate} = "1.8.$form->{year}";
2981 $form->{todate} = "31.8.$form->{year}";
2982 $form->{"0408"} = "X";
2985 $form->{duetyp} eq "9" && do {
2986 $form->{fromdate} = "1.9.$form->{year}";
2987 $form->{todate} = "30.9.$form->{year}";
2988 $form->{"0409"} = "X";
2991 $form->{duetyp} eq "10" && do {
2992 $form->{fromdate} = "1.10.$form->{year}";
2993 $form->{todate} = "31.10.$form->{year}";
2994 $form->{"0410"} = "X";
2997 $form->{duetyp} eq "11" && do {
2998 $form->{fromdate} = "1.11.$form->{year}";
2999 $form->{todate} = "30.11.$form->{year}";
3000 $form->{"0411"} = "X";
3003 $form->{duetyp} eq "12" && do {
3004 $form->{fromdate} = "1.12.$form->{year}";
3005 $form->{todate} = "31.12.$form->{year}";
3006 $form->{"0412"} = "X";
3012 # $locale->date(\%myconfig, $form->current_date(\%myconfig), 0)=~ /(\d\d\d\d)/;
3013 # $form->{year}= $1;
3014 # $form->{fromdate}="1.1.$form->{year}";
3015 # $form->{todate}="31.3.$form->{year}";
3016 # $form->{period} = $locale->date(\%myconfig, $form->current_date(\%myconfig), 1);
3019 RP->ustva(\%myconfig, \%$form);
3021 ($form->{department}) = split /--/, $form->{department};
3024 $locale->date(\%myconfig, $form->current_date(\%myconfig), 1);
3025 $form->{todate} = $form->current_date(\%myconfig) unless $form->{todate};
3027 # if there are any dates construct a where
3028 if ($form->{fromdate} || $form->{todate}) {
3030 unless ($form->{todate}) {
3031 $form->{todate} = $form->current_date(\%myconfig);
3034 $longtodate = $locale->date(\%myconfig, $form->{todate}, 1);
3035 $shorttodate = $locale->date(\%myconfig, $form->{todate}, 0);
3037 $longfromdate = $locale->date(\%myconfig, $form->{fromdate}, 1);
3038 $shortfromdate = $locale->date(\%myconfig, $form->{fromdate}, 0);
3040 $form->{this_period} = "$shortfromdate\n$shorttodate";
3042 $locale->text('for Period')
3043 . qq|<br>\n$longfromdate |
3044 . $locale->text('bis')
3048 if ($form->{comparefromdate} || $form->{comparetodate}) {
3049 $longcomparefromdate =
3050 $locale->date(\%myconfig, $form->{comparefromdate}, 1);
3051 $shortcomparefromdate =
3052 $locale->date(\%myconfig, $form->{comparefromdate}, 0);
3054 $longcomparetodate = $locale->date(\%myconfig, $form->{comparetodate}, 1);
3055 $shortcomparetodate = $locale->date(\%myconfig, $form->{comparetodate}, 0);
3057 $form->{last_period} = "$shortcomparefromdate\n$shortcomparetodate";
3059 "\n$longcomparefromdate "
3060 . $locale->text('bis')
3061 . qq| $longcomparetodate|;
3064 $form->{Datum_heute} =
3065 $locale->date(\%myconfig, $form->current_date(\%myconfig), 0);
3067 if ( $form->{format} eq 'pdf'
3068 or $form->{format} eq 'postscript') {
3069 $form->{padding} = "~~";
3070 $form->{bold} = "\textbf{";
3071 $form->{endbold} = "}";
3072 $form->{br} = '\\\\';
3074 @numbers = qw(51r 86r 97r 93r 96 43 45
3076 foreach $number (@numbers) {
3077 $form->{$number} =~ s/,/~~/g;
3080 } elsif ($form->{format} eq 'html') {
3081 $form->{padding} = " ";
3082 $form->{bold} = "<b>";
3083 $form->{endbold} = "</b>";
3084 $form->{br} = "<br>"
3088 # setup variables for the form
3089 @a = qw(company address businessnumber);
3090 map { $form->{$_} = $myconfig{$_} } @a;
3092 $form->{address} =~ s/\\n/$form->{br}/g;
3094 if ($form->{winston} eq '1') {
3098 $form->{templates} = $myconfig{templates};
3099 $form->{IN} = "$form->{type}";
3100 $form->{IN} .= '.tex'
3101 if ( $form->{format} eq 'pdf'
3102 or $form->{format} eq 'postscript');
3103 $form->{IN} .= '.html' if ($form->{format} eq 'html');
3105 $form->parse_template(\%myconfig, $userspath);
3107 # $form->parse_template;
3109 $lxdebug->leave_sub();