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";
46 # this is for our long dates
47 # $locale->text('January')
48 # $locale->text('February')
49 # $locale->text('March')
50 # $locale->text('April')
51 # $locale->text('May ')
52 # $locale->text('June')
53 # $locale->text('July')
54 # $locale->text('August')
55 # $locale->text('September')
56 # $locale->text('October')
57 # $locale->text('November')
58 # $locale->text('December')
60 # this is for our short month
61 # $locale->text('Jan')
62 # $locale->text('Feb')
63 # $locale->text('Mar')
64 # $locale->text('Apr')
65 # $locale->text('May')
66 # $locale->text('Jun')
67 # $locale->text('Jul')
68 # $locale->text('Aug')
69 # $locale->text('Sep')
70 # $locale->text('Oct')
71 # $locale->text('Nov')
72 # $locale->text('Dec')
74 # $locale->text('Balance Sheet')
75 # $locale->text('Income Statement')
76 # $locale->text('Trial Balance')
77 # $locale->text('AR Aging')
78 # $locale->text('AP Aging')
79 # $locale->text('Tax collected')
80 # $locale->text('Tax paid')
81 # $locale->text('Receipts')
82 # $locale->text('Payments')
83 # $locale->text('Project Transactions')
84 # $locale->text('Non-taxable Sales')
85 # $locale->text('Non-taxable Purchases')
88 $lxdebug->enter_sub();
90 %title = ( 'balance_sheet' => 'Balance Sheet',
91 'income_statement' => 'Income Statement',
92 'trial_balance' => 'Trial Balance',
93 'ar_aging' => 'AR Aging',
94 'ap_aging' => 'Offene Verbindlichkeiten',
95 'tax_collected' => 'Tax collected',
96 'tax_paid' => 'Tax paid',
97 'nontaxable_sales' => 'Non-taxable Sales',
98 'nontaxable_purchases' => 'Non-taxable Purchases',
99 'receipts' => 'Receipts',
100 'payments' => 'Payments',
101 'projects' => 'Project Transactions',
102 'bwa' => 'Betriebswirtschaftliche Auswertung',
103 'ustva' => 'Umsatzsteuervoranmeldung',
106 $form->{title} = $locale->text($title{$form->{report}});
108 $accrual = ($eur) ? "" : "checked";
109 $cash = ($eur) ? "checked" : "";
111 ($null,$null,$null,$null,$null,$year,$null,$null,$null) = localtime();
115 $form->all_departments(\%myconfig);
116 if (@{ $form->{all_departments} }) {
117 $form->{selectdepartment} = "<option>\n";
119 map { $form->{selectdepartment} .= "<option>$_->{description}--$_->{id}\n" } (@{ $form->{all_departments} });
124 <th align=right nowrap>|.$locale->text('Department').qq|</th>
125 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
127 | if $form->{selectdepartment};
129 # use JavaScript Calendar or not
130 $form->{jsscript} = $jscalendar;
132 if ($form->{report} eq "ustva") {
137 if ($form->{report} eq "balance_sheet")
139 $name_1 = "compareasofdate";
140 $id_1 = "compareasofdate";
142 $trigger_1 = "trigger1";
143 $name_2 = "asofdate";
145 $value_2 = "$form->{asofdate}";
146 $trigger_2 = "trigger2";
148 elsif ($form->{report} =~ /(receipts|payments)$/)
150 $name_1 = "fromdate";
152 $value_1 = "$form->{fromdate}";
153 $trigger_1 = "trigger1";
157 $trigger_2 = "trigger2";
161 if (($form->{report} eq "ar_aging") || ($form->{report} eq "ap_aging"))
170 $trigger_2 = "trigger2";
175 $name_1 = "fromdate";
177 $value_1 = "$form->{fromdate}";
178 $trigger_1 = "trigger1";
182 $trigger_2 = "trigger2";
187 # with JavaScript Calendar
188 if ($form->{jsscript})
193 <input name=$name_2 id=$id_2 size=11 title="$myconfig{dateformat}">|;
195 <input type=button name=$name_2 id="$trigger_2" value=|.$locale->text('button').qq|>|;
197 $jsscript = Form->write_trigger(\%myconfig,"1","$name_2","BR","$trigger_2","","","");
202 <input name=$name_1 id=$id_1 size=11 title="$myconfig{dateformat}" value=$value_1>|;
204 <input type=button name=$name_1 id="$trigger_1" value=|.$locale->text('button').qq|>|;
206 <input name=$name_2 id=$id_2 size=11 title="$myconfig{dateformat}">|;
208 <input type=button name=$name_2 id="$trigger_2" value=|.$locale->text('button').qq|>
211 $jsscript = Form->write_trigger(\%myconfig,"2","$name_1","BR","$trigger_1","$name_2","BL","$trigger_2");
216 # without JavaScript Calendar
218 $button1 = qq|<input name=$name_2 id=$id_2 size=11 title="$myconfig{dateformat}">|;
222 $button1 = qq|<input name=$name_1 id=$id_1 size=11 title="$myconfig{dateformat}" value=$value_1>|;
223 $button2 = qq|<input name=$name_2 id=$id_2 size=11 title="$myconfig{dateformat}">|;
232 <form method=post action=$form->{script}>
234 <input type=hidden name=title value="$form->{title}">
238 <th class=listtop>$form->{title}</th>
247 if ($form->{report} eq "projects") {
250 <th align=right nowrap>|.$locale->text('Project').qq|</th>
251 <td colspan=5><input name=projectnumber size=25</td>
253 <input type=hidden name=nextsub value=generate_projects>
255 <th align=right>|.$locale->text('From').qq|</th>
258 <th align=right>|.$locale->text('Bis').qq|</th>
269 <th align=right nowrap>|.$locale->text('Include in Report').qq|</th>
270 <td><input name=l_heading class=checkbox type=checkbox value=Y> |.$locale->text('Heading').qq|
271 <input name=l_subtotal class=checkbox type=checkbox value=Y> |.$locale->text('Subtotal').qq|</td>
278 if ($form->{report} eq "income_statement") {
281 <th align=right nowrap>|.$locale->text('Project').qq|</th>
282 <td colspan=3><input name=projectnumber size=25</td>
284 <input type=hidden name=nextsub value=generate_income_statement>
288 <th align=left><input name=reporttype class=radio type=radio value="custom" checked> |.$locale->text('Customized Report').qq|</th>
291 <th colspan=1>|.$locale->text('Year').qq|</th>
292 <td><input name=year size=11 title="|.$locale->text('YYYY').qq|" value="$year"></td>
300 <b> |.$locale->text('Yearly').qq|</b> </td>
301 <th align=left>|.$locale->text('Quarterly').qq|</th>
302 <th align=left colspan=3>|.$locale->text('Monthly').qq|</th>
305 <td align=right> <input name=duetyp class=radio type=radio value="13"
307 <td><input name=duetyp class=radio type=radio value="A" $checked > 1. |.$locale->text('Quarter').qq|</td>
311 <td><input name=duetyp class=radio type=radio value="1" $checked > |.$locale->text('January').qq|</td>
315 <td><input name=duetyp class=radio type=radio value="5" $checked > |.$locale->text('May').qq|</td>
316 <td><input name=duetyp class=radio type=radio value="9" $checked > |.$locale->text('September').qq|</td>
320 <td align= right> </td>
321 <td><input name=duetyp class=radio type=radio value="B" $checked> 2. |.$locale->text('Quarter').qq|</td>
322 <td><input name=duetyp class=radio type=radio value="2" $checked > |.$locale->text('February').qq|</td>
323 <td><input name=duetyp class=radio type=radio value="6" $checked > |.$locale->text('June').qq|</td>
324 <td><input name=duetyp class=radio type=radio value="10" $checked > |.$locale->text('October').qq|</td>
328 <td><input name=duetyp class=radio type=radio value="C" $checked> 3. |.$locale->text('Quarter').qq|</td>
329 <td><input name=duetyp class=radio type=radio value="3" $checked > |.$locale->text('March').qq|</td>
330 <td><input name=duetyp class=radio type=radio value="7" $checked > |.$locale->text('July').qq|</td>
331 <td><input name=duetyp class=radio type=radio value="11" $checked > |.$locale->text('November').qq|</td>
336 <td><input name=duetyp class=radio type=radio value="D" $checked> 4. |.$locale->text('Quarter').qq| </td>
337 <td><input name=duetyp class=radio type=radio value="4" $checked > |.$locale->text('April').qq|</td>
338 <td><input name=duetyp class=radio type=radio value="8" $checked > |.$locale->text('August').qq|</td>
339 <td><input name=duetyp class=radio type=radio value="12" $checked > |.$locale->text('December').qq|</td>
343 <td colspan=5><hr size=3 noshade></td>
346 <th align=left><input name=reporttype class=radio type=radio value="free" $checked> |.$locale->text('Free report period').qq|</th>
347 <td align=left colspan=4>|.$locale->text('From').qq|
350 |.$locale->text('Bis').qq|
356 <td colspan=5><hr size=3 noshade></td>
359 <th align=leftt>|.$locale->text('Method').qq|</th>
360 <td colspan=3><input name=method class=radio type=radio value=accrual $accrual>|.$locale->text('Accrual').qq|
361 <input name=method class=radio type=radio value=cash $cash>|.$locale->text('EUR').qq|</td>
368 if ($form->{report} eq "bwa") {
371 <th align=right nowrap>|.$locale->text('Project').qq|</th>
372 <td colspan=3><input name=projectnumber size=25</td>
374 <input type=hidden name=nextsub value=generate_bwa>
378 <th align=left><input name=reporttype class=radio type=radio value="custom" checked> |.$locale->text('Customized Report').qq|</th>
381 <th colspan=1>|.$locale->text('Year').qq|</th>
382 <td><input name=year size=11 title="|.$locale->text('YYYY').qq|" value="$year"></td>
390 <b> |.$locale->text('Yearly').qq|</b> </td>
391 <th align=left>|.$locale->text('Quarterly').qq|</th>
392 <th align=left colspan=3>|.$locale->text('Monthly').qq|</th>
395 <td align=right> <input name=duetyp class=radio type=radio value="13"
397 <td><input name=duetyp class=radio type=radio value="A" $checked > 1. |.$locale->text('Quarter').qq|</td>
399 $checked = "checked";
401 <td><input name=duetyp class=radio type=radio value="1" $checked > |.$locale->text('January').qq|</td>
405 <td><input name=duetyp class=radio type=radio value="5" $checked > |.$locale->text('May').qq|</td>
406 <td><input name=duetyp class=radio type=radio value="9" $checked > |.$locale->text('September').qq|</td>
410 <td align= right> </td>
411 <td><input name=duetyp class=radio type=radio value="B" $checked> 2. |.$locale->text('Quarter').qq|</td>
412 <td><input name=duetyp class=radio type=radio value="2" $checked > |.$locale->text('February').qq|</td>
413 <td><input name=duetyp class=radio type=radio value="6" $checked > |.$locale->text('June').qq|</td>
414 <td><input name=duetyp class=radio type=radio value="10" $checked > |.$locale->text('October').qq|</td>
418 <td><input name=duetyp class=radio type=radio value="C" $checked> 3. |.$locale->text('Quarter').qq|</td>
419 <td><input name=duetyp class=radio type=radio value="3" $checked > |.$locale->text('March').qq|</td>
420 <td><input name=duetyp class=radio type=radio value="7" $checked > |.$locale->text('July').qq|</td>
421 <td><input name=duetyp class=radio type=radio value="11" $checked > |.$locale->text('November').qq|</td>
426 <td><input name=duetyp class=radio type=radio value="D" $checked> 4. |.$locale->text('Quarter').qq| </td>
427 <td><input name=duetyp class=radio type=radio value="4" $checked > |.$locale->text('April').qq|</td>
428 <td><input name=duetyp class=radio type=radio value="8" $checked > |.$locale->text('August').qq|</td>
429 <td><input name=duetyp class=radio type=radio value="12" $checked > |.$locale->text('December').qq|</td>
433 <td colspan=5><hr size=3 noshade></td>
436 <th align=left><input name=reporttype class=radio type=radio value="free" $checked> |.$locale->text('Free report period').qq|</th>
437 <td align=left colspan=4>|.$locale->text('From').qq|
440 |.$locale->text('Bis').qq|
446 <td colspan=5><hr size=3 noshade></td>
449 <th align=leftt>|.$locale->text('Method').qq|</th>
450 <td colspan=3><input name=method class=radio type=radio value=accrual $accrual>|.$locale->text('Accrual').qq|
451 <input name=method class=radio type=radio value=cash $cash>|.$locale->text('EUR').qq|</td>
458 if ($form->{report} eq "ustva") {
463 <input type=hidden name=nextsub value=generate_ustva>
467 <th align=left><input name=reporttype class=radio type=radio value="custom" checked> |.$locale->text('Zeitraum').qq|</th>
470 <th colspan=1>|.$locale->text('Year').qq|</th>
471 <td><input name=year size=11 title="|.$locale->text('YYYY').qq|" value="$year"></td>
479 <b> |.$locale->text('Yearly').qq|</b> </td>
480 <th align=left>|.$locale->text('Quarterly').qq|</th>
481 <th align=left colspan=3>|.$locale->text('Monthly').qq|</th>
484 <td align=right> <input name=duetyp class=radio type=radio value="13"
486 <td><input name=duetyp class=radio type=radio value="A" $checked > 1. |.$locale->text('Quarter').qq|</td>
488 $checked = "checked";
490 <td><input name=duetyp class=radio type=radio value="1" $checked > |.$locale->text('January').qq|</td>
494 <td><input name=duetyp class=radio type=radio value="5" $checked > |.$locale->text('May').qq|</td>
495 <td><input name=duetyp class=radio type=radio value="9" $checked > |.$locale->text('September').qq|</td>
499 <td align= right> </td>
500 <td><input name=duetyp class=radio type=radio value="B" $checked> 2. |.$locale->text('Quarter').qq|</td>
501 <td><input name=duetyp class=radio type=radio value="2" $checked > |.$locale->text('February').qq|</td>
502 <td><input name=duetyp class=radio type=radio value="6" $checked > |.$locale->text('June').qq|</td>
503 <td><input name=duetyp class=radio type=radio value="10" $checked > |.$locale->text('October').qq|</td>
507 <td><input name=duetyp class=radio type=radio value="C" $checked> 3. |.$locale->text('Quarter').qq|</td>
508 <td><input name=duetyp class=radio type=radio value="3" $checked > |.$locale->text('March').qq|</td>
509 <td><input name=duetyp class=radio type=radio value="7" $checked > |.$locale->text('July').qq|</td>
510 <td><input name=duetyp class=radio type=radio value="11" $checked > |.$locale->text('November').qq|</td>
515 <td><input name=duetyp class=radio type=radio value="D" $checked> 4. |.$locale->text('Quarter').qq| </td>
516 <td><input name=duetyp class=radio type=radio value="4" $checked > |.$locale->text('April').qq|</td>
517 <td><input name=duetyp class=radio type=radio value="8" $checked > |.$locale->text('August').qq|</td>
518 <td><input name=duetyp class=radio type=radio value="12" $checked > |.$locale->text('December').qq|</td>
522 <td colspan=5><hr size=3 noshade></td>
525 <th align=left>|.$locale->text('Method').qq|</th>
526 <td colspan=3><input name=method class=radio type=radio value=accrual $accrual>|.$locale->text('Accrual').qq|
527 <input name=method class=radio type=radio value=cash $cash>|.$locale->text('EUR').qq|</td>
540 if ($form->{report} eq "balance_sheet") {
542 <input type=hidden name=nextsub value=generate_balance_sheet>
544 <th align=right>|.$locale->text('as at').qq|</th>
549 <th align=right nowrap>|.$locale->text('Compare to').qq|</th>
556 <th align=right>|.$locale->text('Decimalplaces').qq|</th>
557 <td><input name=decimalplaces size=3></td>
566 <th align=right>|.$locale->text('Method').qq|</th>
567 <td colspan=3><input name=method class=radio type=radio value=accrual $accrual>|.$locale->text('Accrual').qq|
568 <input name=method class=radio type=radio value=cash $cash>|.$locale->text('EUR').qq|</td>
572 <th align=right nowrap>|.$locale->text('Include in Report').qq|</th>
573 <td><input name=l_heading class=checkbox type=checkbox value=Y> |.$locale->text('Heading').qq|
574 <input name=l_subtotal class=checkbox type=checkbox value=Y> |.$locale->text('Subtotal').qq|
575 <input name=l_accno class=checkbox type=checkbox value=Y> |.$locale->text('Account Number').qq|</td>
583 if ($form->{report} eq "trial_balance") {
585 <input type=hidden name=nextsub value=generate_trial_balance>
586 <input type=hidden name=eur value=$eur>
588 <th align=right>|.$locale->text('From').qq|</th>
593 <th align=right>|.$locale->text('Bis').qq|</th>
606 <th align=right nowrap>|.$locale->text('Include in Report').qq|</th>
607 <td><input name=l_heading class=checkbox type=checkbox value=Y> |.$locale->text('Heading').qq|
608 <input name=l_subtotal class=checkbox type=checkbox value=Y> |.$locale->text('Subtotal').qq|
609 <input name=all_accounts class=checkbox type=checkbox value=Y> |.$locale->text('All Accounts').qq|</td>
617 if ($form->{report} =~ /^tax_/) {
620 $form->{db} = ($form->{report} =~ /_collected/) ? "ar" : "ap";
622 RP->get_taxaccounts(\%myconfig, \%$form);
625 <input type=hidden name=nextsub value=generate_tax_report>
627 <th align=right>|.$locale->text('From').qq|</th>
628 <td><input name=fromdate size=11 title="$myconfig{dateformat}" value=$form->{fromdate}></td>
629 <th align=right>|.$locale->text('Bis').qq|</th>
630 <td><input name=todate size=11 title="$myconfig{dateformat}"></td>
633 <th align=right>|.$locale->text('Report for').qq|</th>
637 $checked = "checked";
638 foreach $ref (@{ $form->{taxaccounts} }) {
640 print qq|<input name=accno class=radio type=radio value=$ref->{accno} $checked> $ref->{description}
642 <input name="$ref->{accno}_description" type=hidden value="$ref->{description}">
643 <input name="$ref->{accno}_rate" type=hidden value="$ref->{rate}">|;
650 <input type=hidden name=db value=$form->{db}>
651 <input type=hidden name=sort value=transdate>
658 if (@{ $form->{gifi_taxaccounts} }) {
661 <th align=right>|.$locale->text('GIFI').qq|</th>
665 foreach $ref (@{ $form->{gifi_taxaccounts} }) {
667 print qq|<input name=accno class=radio type=radio value="gifi_$ref->{accno}"> $ref->{description}
669 <input name="gifi_$ref->{accno}_description" type=hidden value="$ref->{description}">
670 <input name="gifi_$ref->{accno}_rate" type=hidden value="$ref->{rate}">|;
683 <th align=right>|.$locale->text('Method').qq|</th>
684 <td colspan=3><input name=method class=radio type=radio value=accrual $accrual>|.$locale->text('Accrual').qq|
685 <input name=method class=radio type=radio value=cash $cash>|.$locale->text('EUR').qq|</td>
694 <th align=right>|.$locale->text('Include in Report').qq|</th>
698 <td><input name="l_id" class=checkbox type=checkbox value=Y></td>
699 <td>|.$locale->text('ID').qq|</td>
700 <td><input name="l_invnumber" class=checkbox type=checkbox value=Y checked></td>
701 <td>|.$locale->text('Invoice').qq|</td>
702 <td><input name="l_transdate" class=checkbox type=checkbox value=Y checked></td>
703 <td>|.$locale->text('Date').qq|</td>
706 <td><input name="l_name" class=checkbox type=checkbox value=Y checked></td>
709 if ($form->{db} eq 'ar') {
710 print $locale->text('Customer');
712 if ($form->{db} eq 'ap') {
713 print $locale->text('Vendor');
717 <td><input name="l_netamount" class=checkbox type=checkbox value=Y checked></td>
718 <td>|.$locale->text('Amount').qq|</td>
719 <td><input name="l_tax" class=checkbox type=checkbox value=Y checked></td>
720 <td>|.$locale->text('Tax').qq|</td>
721 <td><input name="l_amount" class=checkbox type=checkbox value=Y></td>
722 <td>|.$locale->text('Total').qq|</td>
725 <td><input name="l_subtotal" class=checkbox type=checkbox value=Y></td>
726 <td>|.$locale->text('Subtotal').qq|</td>
736 if ($form->{report} =~ /^nontaxable_/) {
739 $form->{db} = ($form->{report} =~ /_sales/) ? "ar" : "ap";
742 <input type=hidden name=nextsub value=generate_tax_report>
744 <input type=hidden name=db value=$form->{db}>
745 <input type=hidden name=sort value=transdate>
746 <input type=hidden name=report value=$form->{report}>
749 <th align=right>|.$locale->text('From').qq|</th>
750 <td><input name=fromdate size=11 title="$myconfig{dateformat}" value=$form->{fromdate}></td>
751 <th align=right>|.$locale->text('Bis').qq|</th>
752 <td><input name=todate size=11 title="$myconfig{dateformat}"></td>
755 <th align=right>|.$locale->text('Method').qq|</th>
756 <td colspan=3><input name=method class=radio type=radio value=accrual $accrual>|.$locale->text('Accrual').qq|
757 <input name=method class=radio type=radio value=cash $cash>|.$locale->text('EUR').qq|</td>
760 <th align=right>|.$locale->text('Include in Report').qq|</th>
764 <td><input name="l_id" class=checkbox type=checkbox value=Y></td>
765 <td>|.$locale->text('ID').qq|</td>
766 <td><input name="l_invnumber" class=checkbox type=checkbox value=Y checked></td>
767 <td>|.$locale->text('Invoice').qq|</td>
768 <td><input name="l_transdate" class=checkbox type=checkbox value=Y checked></td>
769 <td>|.$locale->text('Date').qq|</td>
772 <td><input name="l_name" class=checkbox type=checkbox value=Y checked></td>
775 if ($form->{db} eq 'ar') {
776 print $locale->text('Customer');
778 if ($form->{db} eq 'ap') {
779 print $locale->text('Vendor');
783 <td><input name="l_netamount" class=checkbox type=checkbox value=Y checked></td>
784 <td>|.$locale->text('Amount').qq|</td>
785 <td><input name="l_amount" class=checkbox type=checkbox value=Y></td>
786 <td>|.$locale->text('Total').qq|</td>
789 <td><input name="l_subtotal" class=checkbox type=checkbox value=Y></td>
790 <td>|.$locale->text('Subtotal').qq|</td>
801 if (($form->{report} eq "ar_aging") || ($form->{report} eq "ap_aging")) {
804 if ($form->{report} eq 'ar_aging') {
805 $label = $locale->text('Customer');
806 $form->{vc} = 'customer';
808 $label = $locale->text('Vendor');
809 $form->{vc} = 'vendor';
812 $nextsub = "generate_$form->{report}";
815 $form->all_vc(\%myconfig, $form->{vc}, ($form->{vc} eq 'customer') ? "AR" : "AP");
817 map { $vc .= "<option>$_->{name}--$_->{id}\n" } @{ $form->{"all_$form->{vc}"} };
819 $vc = ($vc) ? qq|<select name=$form->{vc}><option>\n$vc</select>| : qq|<input name=$form->{vc} size=35>|;
823 <th align=right>|.$locale->text($label).qq|</th>
827 <th align=right>|.$locale->text('Bis').qq|</th>
833 <input type=hidden name=type value=statement>
834 <input type=hidden name=format value=html>
835 <input type=hidden name=media value=screen>
837 <input type=hidden name=nextsub value=$nextsub>
838 <input type=hidden name=action value=$nextsub>
844 # above action can be removed if there is more than one input field
847 if ($form->{report} =~ /(receipts|payments)$/) {
850 $form->{db} = ($form->{report} =~ /payments$/) ? "ap" : "ar";
852 RP->paymentaccounts(\%myconfig, \%$form);
854 $selection = "<option>\n";
855 foreach $ref (@{ $form->{PR} }) {
856 $paymentaccounts .= "$ref->{accno} ";
857 $selection .= "<option>$ref->{accno}--$ref->{description}\n";
860 chop $paymentaccounts;
863 <input type=hidden name=nextsub value=list_payments>
865 <th align=right nowrap>|.$locale->text('Account').qq|</th>
866 <td colspan=3><select name=account>$selection</select>
867 <input type=hidden name=paymentaccounts value="$paymentaccounts">
871 <th align=right>|.$locale->text('Reference').qq|</th>
872 <td colspan=3><input name=reference></td>
875 <th align=right nowrap>|.$locale->text('Source').qq|</th>
876 <td colspan=3><input name=source></td>
879 <th align=right nowrap>|.$locale->text('Memo').qq|</th>
880 <td colspan=3><input name=memo size=30></td>
883 <th align=right>|.$locale->text('From').qq|</th>
888 <th align=right>|.$locale->text('Bis').qq|</th>
895 <td align=right><input type=checkbox style=checkbox name=fx_transaction value=1 checked></td>
896 <th align=left colspan=3>|.$locale->text('Include Exchangerate Difference').qq|</td>
901 <input type=hidden name=db value=$form->{db}>
902 <input type=hidden name=sort value=transdate>
913 <td><hr size=3 noshade></td>
918 <input type=hidden name=path value=$form->{path}>
919 <input type=hidden name=login value=$form->{login}>
920 <input type=hidden name=password value=$form->{password}>
922 <input type=submit class=submit name=action value="|.$locale->text('Continue').qq|">
925 # Hier Aufruf von get_config aus bin/mozilla/fa.pl zum
926 # Einlesen der Finanzamtdaten
927 get_config($userspath, 'finanzamt.ini');
929 $disabled= qq|disabled="disabled"|;
930 $disabled='' if ($form->{elster} eq '1' );
931 if ( $form->{report} eq 'ustva'){
933 <input type=submit class=submit name=action value="|.$locale->text('debug').qq|">
934 <input type=submit class=submit name=action $disabled
935 value="|.$locale->text('winston_export').qq|">
938 <input type=submit class=submit name=action value="|.$locale->text('config').qq|">
949 $lxdebug->leave_sub();
953 sub continue { &{$form->{nextsub}} };
957 $lxdebug->enter_sub();
960 $form->{project_id} = $form->{project_id_1};
961 if ($form->{projectnumber} && !$form->{project_id}) {
962 $form->{rowcount} = 1;
964 # call this instead of update
965 $form->{update} = $nextsub;
966 $form->{projectnumber_1} = $form->{projectnumber};
968 delete $form->{sort};
971 # if there is one only, assign id
972 $form->{project_id} = $form->{project_id_1};
975 $lxdebug->leave_sub();
979 sub generate_income_statement {
980 $lxdebug->enter_sub();
982 $form->{padding} = " ";
983 $form->{bold} = "<b>";
984 $form->{endbold} = "</b>";
985 $form->{br} = "<br>";
987 &get_project(generate_income_statement);
989 $form->{projectnumber} = $form->{projectnumber_1};
991 if ($form->{reporttype} eq "custom"){
993 #forgotten the year --> thisyear
994 if ($form->{year} !~ m/^\d\d\d\d$/ ) {
995 $locale->date(\%myconfig, $form->current_date(\%myconfig), 0)=~ /(\d\d\d\d)/;
999 if ($form->{duetyp} eq "13" ){
1000 $form->{fromdate}="1.1.$form->{year}";
1001 $form->{todate}="31.12.$form->{year}";
1004 if ($form->{duetyp} eq "A" ){
1005 $form->{fromdate}="1.1.$form->{year}";
1006 $form->{todate}="31.3.$form->{year}";
1008 if ($form->{duetyp} eq "B" ){
1009 $form->{fromdate}="1.4.$form->{year}";
1010 $form->{todate}="30.6.$form->{year}";
1012 if ($form->{duetyp} eq "C" ){
1013 $form->{fromdate}="1.7.$form->{year}";
1014 $form->{todate}="30.9.$form->{year}";
1016 if ($form->{duetyp} eq "D" ){
1017 $form->{fromdate}="1.10.$form->{year}";
1018 $form->{todate}="31.12.$form->{year}";
1023 $form->{duetyp} eq "1" && do {
1024 $form->{fromdate}="1.1.$form->{year}";
1025 $form->{todate}="31.1.$form->{year}";
1028 $form->{duetyp} eq "2" && do {
1029 $form->{fromdate}="1.2.$form->{year}";
1030 #this works from 1901 to 2099, 1900 and 2100 fail.
1031 $leap=($form->{year} % 4 == 0) ? "29" : "28";
1032 $form->{todate}="$leap.2.$form->{year}";
1035 $form->{duetyp} eq "3" && do {
1036 $form->{fromdate}="1.3.$form->{year}";
1037 $form->{todate}="31.3.$form->{year}";
1040 $form->{duetyp} eq "4" && do {
1041 $form->{fromdate}="1.4.$form->{year}";
1042 $form->{todate}="30.4.$form->{year}";
1045 $form->{duetyp} eq "5" && do {
1046 $form->{fromdate}="1.5.$form->{year}";
1047 $form->{todate}="31.5.$form->{year}";
1050 $form->{duetyp} eq "6" && do {
1051 $form->{fromdate}="1.6.$form->{year}";
1052 $form->{todate}="30.6.$form->{year}";
1055 $form->{duetyp} eq "7" && do {
1056 $form->{fromdate}="1.7.$form->{year}";
1057 $form->{todate}="31.7.$form->{year}";
1060 $form->{duetyp} eq "8" && do {
1061 $form->{fromdate}="1.8.$form->{year}";
1062 $form->{todate}="31.8.$form->{year}";
1065 $form->{duetyp} eq "9" && do {
1066 $form->{fromdate}="1.9.$form->{year}";
1067 $form->{todate}="30.9.$form->{year}";
1070 $form->{duetyp} eq "10" && do {
1071 $form->{fromdate}="1.10.$form->{year}";
1072 $form->{todate}="31.10.$form->{year}";
1075 $form->{duetyp} eq "11" && do {
1076 $form->{fromdate}="1.11.$form->{year}";
1077 $form->{todate}="30.11.$form->{year}";
1080 $form->{duetyp} eq "12" && do {
1081 $form->{fromdate}="1.12.$form->{year}";
1082 $form->{todate}="31.12.$form->{year}";
1088 RP->income_statement(\%myconfig, \%$form);
1090 ($form->{department}) = split /--/, $form->{department};
1092 $form->{period} = $locale->date(\%myconfig, $form->current_date(\%myconfig), 1);
1093 $form->{todate} = $form->current_date(\%myconfig) unless $form->{todate};
1095 # if there are any dates construct a where
1096 if ($form->{fromdate} || $form->{todate}) {
1098 unless ($form->{todate}) {
1099 $form->{todate} = $form->current_date(\%myconfig);
1102 $longtodate = $locale->date(\%myconfig, $form->{todate}, 1);
1103 $shorttodate = $locale->date(\%myconfig, $form->{todate}, 0);
1105 $longfromdate = $locale->date(\%myconfig, $form->{fromdate}, 1);
1106 $shortfromdate = $locale->date(\%myconfig, $form->{fromdate}, 0);
1108 $form->{this_period} = "$shortfromdate<br>\n$shorttodate";
1109 $form->{period} = $locale->text('for Period').qq|<br>\n$longfromdate |.$locale->text('Bis').qq| $longtodate|;
1112 if ($form->{comparefromdate} || $form->{comparetodate}) {
1113 $longcomparefromdate = $locale->date(\%myconfig, $form->{comparefromdate}, 1);
1114 $shortcomparefromdate = $locale->date(\%myconfig, $form->{comparefromdate}, 0);
1116 $longcomparetodate = $locale->date(\%myconfig, $form->{comparetodate}, 1);
1117 $shortcomparetodate = $locale->date(\%myconfig, $form->{comparetodate}, 0);
1119 $form->{last_period} = "$shortcomparefromdate<br>\n$shortcomparetodate";
1120 $form->{period} .= "<br>\n$longcomparefromdate ".$locale->text('Bis').qq| $longcomparetodate|;
1123 # setup variables for the form
1124 @a = qw(company address businessnumber);
1125 map { $form->{$_} = $myconfig{$_} } @a;
1126 $form->{address} =~ s/\\n/<br>/g;
1128 $form->{templates} = $myconfig{templates};
1130 $form->{IN} = "income_statement.html";
1132 $form->parse_template;
1134 $lxdebug->leave_sub();
1138 sub generate_balance_sheet {
1139 $lxdebug->enter_sub();
1141 $form->{padding} = " ";
1142 $form->{bold} = "<b>";
1143 $form->{endbold} = "</b>";
1144 $form->{br} = "<br>";
1146 RP->balance_sheet(\%myconfig, \%$form);
1148 $form->{asofdate} = $form->current_date(\%myconfig) unless $form->{asofdate};
1149 $form->{period} = $locale->date(\%myconfig, $form->current_date(\%myconfig), 1);
1151 ($form->{department}) = split /--/, $form->{department};
1153 # define Current Earnings account
1154 $padding = ($form->{l_heading}) ? $form->{padding} : "";
1155 push(@{$form->{equity_account}}, $padding.$locale->text('Current Earnings'));
1157 $form->{this_period} = $locale->date(\%myconfig, $form->{asofdate}, 0);
1158 $form->{last_period} = $locale->date(\%myconfig, $form->{compareasofdate}, 0);
1160 $form->{IN} = "balance_sheet.html";
1162 # setup company variables for the form
1163 map { $form->{$_} = $myconfig{$_} } (qw(company address businessnumber nativecurr));
1164 $form->{address} =~ s/\\n/<br>/g;
1166 $form->{templates} = $myconfig{templates};
1168 $form->parse_template;
1170 $lxdebug->leave_sub();
1174 sub generate_projects {
1175 $lxdebug->enter_sub();
1177 &get_project(generate_projects);
1178 $form->{projectnumber} = $form->{projectnumber_1};
1180 $form->{nextsub} = "generate_projects";
1181 $form->{title} = $locale->text('Project Transactions');
1182 RP->trial_balance(\%myconfig, \%$form);
1186 $lxdebug->leave_sub();
1193 # included links to display transactions for period entered
1194 # added headers and subtotals
1196 sub generate_trial_balance {
1197 $lxdebug->enter_sub();
1199 # get for each account initial balance, debits and credits
1200 RP->trial_balance(\%myconfig, \%$form);
1202 $form->{nextsub} = "generate_trial_balance";
1203 $form->{title} = $locale->text('Trial Balance');
1206 $lxdebug->leave_sub();
1211 $lxdebug->enter_sub();
1213 $title = $form->escape($form->{title});
1215 if ($form->{department}) {
1216 ($department) = split /--/, $form->{department};
1217 $options = $locale->text('Department')." : $department<br>";
1218 $department = $form->escape($form->{department});
1220 if ($form->{projectnumber}) {
1221 $options .= $locale->text('Project Number')." : $form->{projectnumber}<br>";
1222 $projectnumber = $form->escape($form->{projectnumber});
1225 # if there are any dates
1226 if ($form->{fromdate} || $form->{todate}) {
1227 if ($form->{fromdate}) {
1228 $fromdate = $locale->date(\%myconfig, $form->{fromdate}, 1);
1230 if ($form->{todate}) {
1231 $todate = $locale->date(\%myconfig, $form->{todate}, 1);
1234 $form->{period} = "$fromdate - $todate";
1236 $form->{period} = $locale->date(\%myconfig, $form->current_date(\%myconfig), 1);
1239 $options .= $form->{period};
1241 @column_index = qw(accno description begbalance debit credit endbalance);
1243 $column_header{accno} = qq|<th class=listheading>|.$locale->text('Account').qq|</th>|;
1244 $column_header{description} = qq|<th class=listheading>|.$locale->text('Description').qq|</th>|;
1245 $column_header{debit} = qq|<th class=listheading>|.$locale->text('Debit').qq|</th>|;
1246 $column_header{credit} = qq|<th class=listheading>|.$locale->text('Credit').qq|</th>|;
1247 $column_header{begbalance} = qq|<th class=listheading>|.$locale->text('Balance').qq|</th>|;
1248 $column_header{endbalance} = qq|<th class=listheading>|.$locale->text('Balance').qq|</th>|;
1251 if ($form->{accounttype} eq 'gifi') {
1252 $column_header{accno} = qq|<th class=listheading>|.$locale->text('GIFI').qq|</th>|;
1263 <th class=listtop>$form->{title}</th>
1265 <tr height="5"></tr>
1274 map { print "$column_header{$_}\n" } @column_index;
1282 # sort the whole thing by account numbers and display
1283 foreach $ref (sort { $a->{accno} cmp $b->{accno} } @{ $form->{TB} }) {
1285 $description = $form->escape($ref->{description});
1287 $href = 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}|;
1289 if ($form->{accounttype} eq 'gifi') {
1290 $href .= "&gifi_accno=$ref->{accno}&gifi_description=$description";
1291 $na = $locale->text('N/A');
1292 map { $ref->{$_} = $na } qw(accno description) unless $ref->{accno};
1294 $href .= "&accno=$ref->{accno}&description=$description";
1297 $ml = ($ref->{category} =~ /(A|C|E)/) ? -1 : 1;
1299 $debit = $form->format_amount(\%myconfig, $ref->{debit}, 2, " ");
1300 $credit = $form->format_amount(\%myconfig, $ref->{credit}, 2, " ");
1301 $begbalance = $form->format_amount(\%myconfig, $ref->{balance} * $ml, 2, " ");
1302 $endbalance = $form->format_amount(\%myconfig, ($ref->{balance} + $ref->{amount}) * $ml, 2, " ");
1304 # next if ($ref->{debit} == 0 && $ref->{credit} == 0);
1306 if ($ref->{charttype} eq "H" && $subtotal && $form->{l_subtotal}) {
1307 map { $column_data{$_} = "<th> </th>" } qw(accno begbalance endbalance);
1309 $subtotalbegbalance = $form->format_amount(\%myconfig, $subtotalbegbalance, 2, " ");
1310 $subtotalendbalance = $form->format_amount(\%myconfig, $subtotalendbalance, 2, " ");
1311 $subtotaldebit = $form->format_amount(\%myconfig, $subtotaldebit, 2, " ");
1312 $subtotalcredit = $form->format_amount(\%myconfig, $subtotalcredit, 2, " ");
1314 $column_data{description} = "<th>$subtotaldescription</th>";
1315 $column_data{begbalance} = "<th align=right>$subtotalbegbalance</th>";
1316 $column_data{endbalance} = "<th align=right>$subtotalendbalance</th>";
1317 $column_data{debit} = "<th align=right>$subtotaldebit</th>";
1318 $column_data{credit} = "<th align=right>$subtotalcredit</th>";
1321 <tr class=listsubtotal>
1323 map { print "$column_data{$_}\n" } @column_index;
1330 if ($ref->{charttype} eq "H") {
1332 $subtotaldescription = $ref->{description};
1333 $subtotaldebit = $ref->{debit};
1334 $subtotalcredit = $ref->{credit};
1335 $subtotalbegbalance = 0;
1336 $subtotalendbalance = 0;
1338 next unless $form->{l_heading};
1340 map { $column_data{$_} = "<th> </th>" } qw(accno debit credit begbalance endbalance);
1341 $column_data{description} = "<th class=listheading>$ref->{description}</th>";
1344 if ($ref->{charttype} eq "A") {
1345 $column_data{accno} = "<td><a href=$href>$ref->{accno}</a></td>";
1346 $column_data{description} = "<td>$ref->{description}</td>";
1347 $column_data{debit} = "<td align=right>$debit</td>";
1348 $column_data{credit} = "<td align=right>$credit</td>";
1349 $column_data{begbalance} = "<td align=right>$begbalance</td>";
1350 $column_data{endbalance} = "<td align=right>$endbalance</td>";
1352 $totaldebit += $ref->{debit};
1353 $totalcredit += $ref->{credit};
1355 $subtotalbegbalance += $ref->{balance} * $ml;
1356 $subtotalendbalance += ($ref->{balance} + $ref->{amount}) * $ml;
1360 if ($ref->{charttype} eq "H") {
1362 <tr class=listheading>
1365 if ($ref->{charttype} eq "A") {
1368 <tr class=listrow$i>
1372 map { print "$column_data{$_}\n" } @column_index;
1380 # print last subtotal
1381 if ($subtotal && $form->{l_subtotal}) {
1382 map { $column_data{$_} = "<th> </th>" } qw(accno begbalance endbalance);
1383 $subtotalbegbalance = $form->format_amount(\%myconfig, $subtotalbegbalance, 2, " ");
1384 $subtotalendbalance = $form->format_amount(\%myconfig, $subtotalendbalance, 2, " ");
1385 $subtotaldebit = $form->format_amount(\%myconfig, $subtotaldebit, 2, " ");
1386 $subtotalcredit = $form->format_amount(\%myconfig, $subtotalcredit, 2, " ");
1387 $column_data{description} = "<th>$subdescription</th>";
1388 $column_data{begbalance} = "<th align=right>$subtotalbegbalance</th>";
1389 $column_data{endbalance} = "<th align=right>$subtotalendbalance</th>";
1390 $column_data{debit} = "<th align=right>$subtotaldebit</th>";
1391 $column_data{credit} = "<th align=right>$subtotalcredit</th>";
1394 <tr class=listsubtotal>
1396 map { print "$column_data{$_}\n" } @column_index;
1403 $totaldebit = $form->format_amount(\%myconfig, $totaldebit, 2, " ");
1404 $totalcredit = $form->format_amount(\%myconfig, $totalcredit, 2, " ");
1406 map { $column_data{$_} = "<th> </th>" } qw(accno description begbalance endbalance);
1408 $column_data{debit} = qq|<th align=right class=listtotal>$totaldebit</th>|;
1409 $column_data{credit} = qq|<th align=right class=listtotal>$totalcredit</th>|;
1412 <tr class=listtotal>
1415 map { print "$column_data{$_}\n" } @column_index;
1423 <td><hr size=3 noshade></td>
1431 $lxdebug->leave_sub();
1435 sub generate_ar_aging {
1436 $lxdebug->enter_sub();
1439 ($form->{customer}) = split(/--/, $form->{customer});
1440 $customer = $form->escape($form->{customer},1);
1441 $title = $form->escape($form->{title},1);
1443 $form->{ct} = "customer";
1444 $form->{arap} = "ar";
1446 $form->{callback} = qq|$form->{script}?path=$form->{path}&action=generate_ar_aging&login=$form->{login}&password=$form->{password}&todate=$form->{todate}&customer=$customer&title=$title|;
1448 RP->aging(\%myconfig, \%$form);
1451 $lxdebug->leave_sub();
1455 sub generate_ap_aging {
1456 $lxdebug->enter_sub();
1459 ($form->{vendor}) = split(/--/, $form->{vendor});
1460 $vendor = $form->escape($form->{vendor},1);
1461 $title = $form->escape($form->{title},1);
1463 $form->{ct} = "vendor";
1464 $form->{arap} = "ap";
1466 $form->{callback} = qq|$form->{script}?path=$form->{path}&action=generate_ap_aging&login=$form->{login}&password=$form->{password}&todate=$form->{todate}&vendor=$vendor&title=$title|;
1468 RP->aging(\%myconfig, \%$form);
1471 $lxdebug->leave_sub();
1476 $lxdebug->enter_sub();
1481 $column_header{statement} = qq|<th> </th>|;
1482 $column_header{ct} = qq|<th class=listheading>|.$locale->text(ucfirst $form->{ct}).qq|</th>|;
1483 $column_header{invnumber} = qq|<th class=listheading>|.$locale->text('Invoice').qq|</th>|;
1484 $column_header{transdate} = qq|<th class=listheading>|.$locale->text('Date').qq|</th>|;
1485 $column_header{duedate} = qq|<th class=listheading>|.$locale->text('Due').qq|</th>|;
1486 $column_header{c0} = qq|<th class=listheading>|.$locale->text('Current').qq|</th>|;
1487 $column_header{c30} = qq|<th class=listheading>30</th>|;
1488 $column_header{c60} = qq|<th class=listheading>60</th>|;
1489 $column_header{c90} = qq|<th class=listheading>90</th>|;
1491 @column_index = (qw(statement ct invnumber transdate duedate c0 c30 c60 c90));
1493 if ($form->{department}) {
1494 $option .= "\n<br>" if $option;
1495 ($department) = split /--/, $form->{department};
1496 $option .= $locale->text('Department')." : $department";
1497 $department = $form->escape($form->{department},1);
1498 $form->{callback} .= "&department=$department";
1501 if ($form->{arap} eq 'ar') {
1502 if ($form->{customer}) {
1503 $option .= "\n<br>" if $option;
1504 $option .= $form->{customer};
1507 if ($form->{arap} eq 'ap') {
1508 shift @column_index;
1509 if ($form->{vendor}) {
1510 $option .= "\n<br>" if $option;
1511 $option .= $form->{vendor};
1515 $todate = $locale->date(\%myconfig, $form->{todate}, 1);
1516 $option .= "\n<br>" if $option;
1517 $option .= $locale->text('for Period')." ".$locale->text('Bis')." $todate";
1522 <form method=post action=$form->{script}>
1526 <th class=listtop>$form->{title}</th>
1528 <tr height="5"></tr>
1535 <tr class=listheading>
1538 map { print "$column_header{$_}\n" } @column_index;
1549 foreach $ref (@{ $form->{AG} }) {
1551 if ($ctid != $ref->{ctid}) {
1556 $c0subtotal = $form->format_amount(\%myconfig, $c0subtotal, 2, " ");
1557 $c30subtotal = $form->format_amount(\%myconfig, $c30subtotal, 2, " ");
1558 $c60subtotal = $form->format_amount(\%myconfig, $c60subtotal, 2, " ");
1559 $c90subtotal = $form->format_amount(\%myconfig, $c90subtotal, 2, " ");
1562 $column_data{ct} = qq|<th> </th>|;
1563 $column_data{invnumber} = qq|<th> </th>|;
1564 $column_data{transdate} = qq|<th> </th>|;
1565 $column_data{duedate} = qq|<th> </th>|;
1566 $column_data{c0} = qq|<th align=right class=listsubtotal>$c0subtotal</th>|;
1567 $column_data{c30} = qq|<th align=right class=listsubtotal>$c30subtotal</th>|;
1568 $column_data{c60} = qq|<th align=right class=listsubtotal>$c60subtotal</th>|;
1569 $column_data{c90} = qq|<th align=right class=listsubtotal>$c90subtotal</th>|;
1574 <tr class=listsubtotal>
1577 map { print "$column_data{$_}\n" } @column_index;
1579 $column_data{statement} = qq|<td> </td>|;
1593 $column_data{ct} = qq|<td>$ref->{name}</td>|;
1594 $column_data{statement} = qq|<td><input name="statement_$i" type=checkbox class=checkbox value=1 $ref->{checked}>
1595 <input type=hidden name="$form->{ct}_id_$i" value=$ref->{ctid}>
1599 $c0subtotal += $ref->{c0};
1600 $c30subtotal += $ref->{c30};
1601 $c60subtotal += $ref->{c60};
1602 $c90subtotal += $ref->{c90};
1604 $c0total += $ref->{c0};
1605 $c30total += $ref->{c30};
1606 $c60total += $ref->{c60};
1607 $c90total += $ref->{c90};
1609 $ref->{c0} = $form->format_amount(\%myconfig, $ref->{c0}, 2, " ");
1610 $ref->{c30} = $form->format_amount(\%myconfig, $ref->{c30}, 2, " ");
1611 $ref->{c60} = $form->format_amount(\%myconfig, $ref->{c60}, 2, " ");
1612 $ref->{c90} = $form->format_amount(\%myconfig, $ref->{c90}, 2, " ");
1614 $href = qq|$ref->{module}.pl?path=$form->{path}&action=edit&id=$ref->{id}&login=$form->{login}&password=$form->{password}&callback=|.$form->escape($form->{callback});
1616 $column_data{invnumber} = qq|<td><a href=$href>$ref->{invnumber}</a></td>|;
1617 $column_data{transdate} = qq|<td>$ref->{transdate}</td>|;
1618 $column_data{duedate} = qq|<td>$ref->{duedate} </td>|;
1619 $column_data{c0} = qq|<td align=right>$ref->{c0}</td>|;
1620 $column_data{c30} = qq|<td align=right>$ref->{c30}</td>|;
1621 $column_data{c60} = qq|<td align=right>$ref->{c60}</td>|;
1622 $column_data{c90} = qq|<td align=right>$ref->{c90}</td>|;
1626 <tr class=listrow$j>
1629 map { print "$column_data{$_}\n" } @column_index;
1635 $column_data{ct} = qq|<td> </td>|;
1636 $column_data{statement} = qq|<td> </td>|;
1638 $ctid = $ref->{ctid};
1643 $c0subtotal = $form->format_amount(\%myconfig, $c0subtotal, 2, " ");
1644 $c30subtotal = $form->format_amount(\%myconfig, $c30subtotal, 2, " ");
1645 $c60subtotal = $form->format_amount(\%myconfig, $c60subtotal, 2, " ");
1646 $c90subtotal = $form->format_amount(\%myconfig, $c90subtotal, 2, " ");
1649 <tr class=listsubtotal>
1652 map { $column_data{$_} = qq|<th> </th>| } @column_index;
1654 $column_data{c0} = qq|<th align=right class=listsubtotal>$c0subtotal</th>|;
1655 $column_data{c30} = qq|<th align=right class=listsubtotal>$c30subtotal</th>|;
1656 $column_data{c60} = qq|<th align=right class=listsubtotal>$c60subtotal</th>|;
1657 $column_data{c90} = qq|<th align=right class=listsubtotal>$c90subtotal</th>|;
1659 map { print "$column_data{$_}\n" } @column_index;
1664 <tr class=listtotal>
1667 $c0total = $form->format_amount(\%myconfig, $c0total, 2, " ");
1668 $c30total = $form->format_amount(\%myconfig, $c30total, 2, " ");
1669 $c60total = $form->format_amount(\%myconfig, $c60total, 2, " ");
1670 $c90total = $form->format_amount(\%myconfig, $c90total, 2, " ");
1672 $column_data{c0} = qq|<th align=right class=listtotal>$c0total</th>|;
1673 $column_data{c30} = qq|<th align=right class=listtotal>$c30total</th>|;
1674 $column_data{c60} = qq|<th align=right class=listtotal>$c60total</th>|;
1675 $column_data{c90} = qq|<th align=right class=listtotal>$c90total</th>|;
1678 map { print "$column_data{$_}\n" } @column_index;
1682 <input type=hidden name=rowcount value=$i>
1691 &print_options if ($form->{arap} eq 'ar');
1697 <td><hr size=3 noshade></td>
1702 if ($form->{arap} eq 'ar') {
1704 <input type=hidden name=todate value=$form->{todate}>
1706 <input type=hidden name=title value="$form->{title}">
1708 <input type=hidden name=arap value=$form->{arap}>
1709 <input type=hidden name=ct value=$form->{ct}>
1710 <input type=hidden name=$form->{ct} value="$form->{$form->{ct}}">
1712 <input type=hidden name=department value="$form->{department}">
1714 <input type=hidden name=path value=$form->{path}>
1715 <input type=hidden name=login value=$form->{login}>
1716 <input type=hidden name=password value=$form->{password}>
1719 <input class=submit type=submit name=action value="|.$locale->text('Select all').qq|">
1720 <input class=submit type=submit name=action value="|.$locale->text('Print').qq|">
1721 <input class=submit type=submit name=action value="|.$locale->text('E-mail').qq|">
1725 if ($form->{menubar}) {
1726 require "$form->{path}/menu.pl";
1737 $lxdebug->leave_sub();
1742 $lxdebug->enter_sub();
1744 RP->aging(\%myconfig, \%$form);
1746 map { $_->{checked} = "checked" } @{ $form->{AG} };
1750 $lxdebug->leave_sub();
1755 $lxdebug->enter_sub();
1757 $form->{sendmode} = "attachment";
1758 $form->{copies} = 2 unless $form->{copies};
1760 $form->{PD}{$form->{type}} = "selected";
1761 $form->{DF}{$form->{format}} = "selected";
1762 $form->{OP}{$form->{media}} = "selected";
1763 $form->{SM}{$form->{sendmode}} = "selected";
1766 <option value=statement $form->{PD}{statement}>|.$locale->text('Statement');
1768 if ($form->{media} eq 'email') {
1770 <option value=attachment $form->{SM}{attachment}>|.$locale->text('Attachment').qq|
1771 <option value=inline $form->{SM}{inline}>|.$locale->text('In-line');
1774 <option value=screen $form->{OP}{screen}>|.$locale->text('Screen');
1775 if ($myconfig{printer} && $latex) {
1777 <option value=printer $form->{OP}{printer}>|.$locale->text('Printer');
1783 <option value=postscript $form->{DF}{postscript}>|.$locale->text('Postscript').qq|
1784 <option value=pdf $form->{DF}{pdf}>|.$locale->text('PDF');
1790 <td><select name=type>$type</select></td>
1791 <td><select name=format>$format</select></td>
1792 <td><select name=media>$media</select></td>
1795 if ($myconfig{printer} && $latex && $form->{media} ne 'email') {
1797 <td>|.$locale->text('Copies').qq|
1798 <input name=copies size=2 value=$form->{copies}></td>
1807 $lxdebug->leave_sub();
1812 $lxdebug->enter_sub();
1814 # get name and email addresses
1815 for $i (1 .. $form->{rowcount}) {
1816 if ($form->{"statement_$i"}) {
1817 $form->{"$form->{ct}_id"} = $form->{"$form->{ct}_id_$i"};
1818 RP->get_customer(\%myconfig, \%$form);
1824 $form->error($locale->text('Nothing selected!')) unless $selected;
1826 if ($myconfig{role} eq 'admin') {
1828 <th align=right nowrap=true>|.$locale->text('Bcc').qq|</th>
1829 <td><input name=bcc size=30 value="$form->{bcc}"></td>
1833 $title = $locale->text('E-mail Statement to')." $form->{$form->{ct}}";
1835 $form->{media} = "email";
1842 <form method=post action=$form->{script}>
1848 <tr height="5"></tr>
1853 <th align=right nowrap>|.$locale->text('E-mail').qq|</th>
1854 <td><input name=email size=30 value="$form->{email}"></td>
1855 <th align=right nowrap>|.$locale->text('Cc').qq|</th>
1856 <td><input name=cc size=30 value="$form->{cc}"></td>
1859 <th align=right nowrap>|.$locale->text('Subject').qq|</th>
1860 <td><input name=subject size=30 value="$form->{subject}"></td>
1870 <th align=left nowrap>|.$locale->text('Message').qq|</th>
1873 <td><textarea name=message rows=15 cols=60 wrap=soft>$form->{message}</textarea></td>
1884 map { delete $form->{$_} } qw(action email cc bcc subject message type sendmode format header);
1886 # save all other variables
1887 foreach $key (keys %$form) {
1888 $form->{$key} =~ s/\"/"/g;
1889 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
1896 <td><hr size=3 noshade></td>
1900 <input type=hidden name=nextsub value=send_email>
1903 <input name=action class=submit type=submit value="|.$locale->text('Continue').qq|">
1910 $lxdebug->leave_sub();
1915 $lxdebug->enter_sub();
1917 $form->{OUT} = "$sendmail";
1919 $form->{subject} = $locale->text('Statement').qq| - $form->{todate}| unless $form->{subject};
1921 RP->aging(\%myconfig, \%$form);
1923 $form->{"statement_1"} = 1;
1927 $form->redirect($locale->text('Statement sent to')." $form->{$form->{ct}}");
1929 $lxdebug->leave_sub();
1935 $lxdebug->enter_sub();
1937 if ($form->{media} eq 'printer') {
1938 $form->error($locale->text('Select postscript or PDF!')) if ($form->{format} !~ /(postscript|pdf)/);
1941 for $i (1 .. $form->{rowcount}) {
1942 if ($form->{"statement_$i"}) {
1943 $form->{"$form->{ct}_id"} = $form->{"$form->{ct}_id_$i"};
1949 $form->error($locale->text('Nothing selected!')) unless $selected;
1952 if ($form->{media} eq 'printer') {
1953 $form->{OUT} = "| $myconfig{printer}";
1954 $form->{"$form->{ct}_id"} = "";
1956 $form->{"statement_1"} = 1;
1959 RP->aging(\%myconfig, \%$form);
1963 $form->redirect($locale->text('Statements sent to printer!')) if ($form->{media} eq 'printer');
1965 $lxdebug->leave_sub();
1970 $lxdebug->enter_sub();
1972 $form->{statementdate} = $locale->date(\%myconfig, $form->{todate}, 1);
1974 $form->{templates} = "$myconfig{templates}";
1976 # setup variables for the form
1977 @a = qw(company address businessnumber tel fax);
1978 map { $form->{$_} = $myconfig{$_} } @a;
1979 $form->format_string(@a);
1981 $form->{IN} = "$form->{type}.html";
1983 if ($form->{format} eq 'postscript') {
1984 $form->{postscript} = 1;
1985 $form->{IN} =~ s/html$/tex/;
1987 if ($form->{format} eq 'pdf') {
1989 $form->{IN} =~ s/html$/tex/;
1993 while (@{ $form->{AG} }) {
1995 $ref = shift @{ $form->{AG} };
1997 if ($ctid != $ref->{ctid}) {
1999 $ctid = $ref->{ctid};
2002 if ($form->{"statement_$i"}) {
2004 @a = (name, street, zipcode, city, country, contact, email, "$form->{ct}phone", "$form->{ct}fax");
2005 map { $form->{$_} = $ref->{$_} } @a;
2006 $form->format_string(@a);
2008 $form->{$form->{ct}} = $form->{name};
2009 $form->{"$form->{ct}_id"} = $ref->{ctid};
2011 map { $form->{$_} = () } qw(invnumber invdate duedate);
2013 foreach $item (qw(c0 c30 c60 c90)) {
2014 $form->{$item} = ();
2015 $form->{"${item}total"} = 0;
2018 &statement_details($ref);
2022 if (scalar (@{ $form->{AG} }) > 0) {
2023 # one or more left to go
2024 if ($ctid == $form->{AG}->[0]->{ctid}) {
2025 $ref = shift @{ $form->{AG} };
2026 &statement_details($ref);
2028 $ref = scalar (@{ $form->{AG} });
2033 # set initial ref to 0
2039 map { $form->{"${_}total"} = $form->format_amount(\%myconfig, $form->{"${_}total"}, 2) } (c0, c30, c60, c90, "");
2041 $form->parse_template(\%myconfig, $userspath);
2047 $lxdebug->leave_sub();
2051 sub statement_details {
2052 $lxdebug->enter_sub();
2055 push @{ $form->{invnumber} }, $ref->{invnumber};
2056 push @{ $form->{invdate} }, $ref->{transdate};
2057 push @{ $form->{duedate} }, $ref->{duedate};
2059 foreach $item (qw(c0 c30 c60 c90)) {
2060 eval { $ref->{$item} = $form->round_amount($ref->{$item} / $ref->{exchangerate}, 2) };
2061 $form->{"${item}total"} += $ref->{$item};
2062 $form->{total} += $ref->{$item};
2063 push @{ $form->{$item} }, $form->format_amount(\%myconfig, $ref->{$item}, 2);
2066 $lxdebug->leave_sub();
2070 sub generate_tax_report {
2071 $lxdebug->enter_sub();
2073 RP->tax_report(\%myconfig, \%$form);
2075 $descvar = "$form->{accno}_description";
2076 $description = $form->escape($form->{$descvar});
2077 $ratevar = "$form->{accno}_rate";
2079 if ($form->{accno} =~ /^gifi_/) {
2080 $descvar = "gifi_$form->{accno}_description";
2081 $description = $form->escape($form->{$descvar});
2082 $ratevar = "gifi_$form->{accno}_rate";
2085 $department = $form->escape($form->{department});
2088 $href = "$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}";
2090 # construct callback
2091 $description = $form->escape($form->{$descvar},1);
2092 $department = $form->escape($form->{department},1);
2093 $callback = "$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}";
2095 $form->{title} = $locale->text('GIFI')." - " if ($form->{accno} =~ /^gifi_/);
2097 $title = $form->escape($form->{title});
2098 $href .= "&title=$title";
2099 $title = $form->escape($form->{title},1);
2100 $callback .= "&title=$title";
2102 $form->{title} = qq|$form->{title} $form->{"$form->{accno}_description"} |;
2104 @columns = $form->sort_columns(qw(id transdate invnumber name netamount tax amount));
2106 foreach $item (@columns) {
2107 if ($form->{"l_$item"} eq "Y") {
2108 push @column_index, $item;
2110 # add column to href and callback
2111 $callback .= "&l_$item=Y";
2112 $href .= "&l_$item=Y";
2116 if ($form->{l_subtotal} eq 'Y') {
2117 $callback .= "&l_subtotal=Y";
2118 $href .= "&l_subtotal=Y";
2122 if ($form->{department}) {
2123 ($department) = split /--/, $form->{department};
2124 $option = $locale->text('Department')." : $department";
2127 # if there are any dates
2128 if ($form->{fromdate} || $form->{todate}) {
2129 if ($form->{fromdate}) {
2130 $fromdate = $locale->date(\%myconfig, $form->{fromdate}, 1);
2132 if ($form->{todate}) {
2133 $todate = $locale->date(\%myconfig, $form->{todate}, 1);
2136 $form->{period} = "$fromdate - $todate";
2138 $form->{period} = $locale->date(\%myconfig, $form->current_date(\%myconfig), 1);
2142 if ($form->{db} eq 'ar') {
2143 $name = $locale->text('Customer');
2147 if ($form->{db} eq 'ap') {
2148 $name = $locale->text('Vendor');
2153 $option .= "<br>" if $option;
2154 $option .= "$form->{period}";
2157 $column_header{id} = qq|<th><a class=listheading href=$href&sort=id>|.$locale->text('ID').qq|</th>|;
2158 $column_header{invnumber} = qq|<th><a class=listheading href=$href&sort=invnumber>|.$locale->text('Invoice').qq|</th>|;
2159 $column_header{transdate} = qq|<th><a class=listheading href=$href&sort=transdate>|.$locale->text('Date').qq|</th>|;
2160 $column_header{netamount} = qq|<th class=listheading>|.$locale->text('Amount').qq|</th>|;
2161 $column_header{tax} = qq|<th class=listheading>|.$locale->text('Tax').qq|</th>|;
2162 $column_header{amount} = qq|<th class=listheading>|.$locale->text('Total').qq|</th>|;
2164 $column_header{name} = qq|<th><a class=listheading href=$href&sort=name>$name</th>|;
2174 <th class=listtop colspan=$colspan>$form->{title}</th>
2176 <tr height="5"></tr>
2183 <tr class=listheading>
2186 map { print "$column_header{$_}\n" } @column_index;
2192 # add sort and escape callback
2193 $callback = $form->escape($callback . "&sort=$form->{sort}");
2195 if (@{ $form->{TR} }) {
2196 $sameitem = $form->{TR}->[0]->{$form->{sort}};
2199 foreach $ref (@{ $form->{TR} }) {
2201 $module = ($ref->{invoice}) ? $invoice : $arap;
2203 if ($form->{l_subtotal} eq 'Y') {
2204 if ($sameitem ne $ref->{$form->{sort}}) {
2206 $sameitem = $ref->{$form->{sort}};
2210 $totalnetamount += $ref->{netamount};
2211 $totaltax += $ref->{tax};
2212 $ref->{amount} = $ref->{netamount} + $ref->{tax};
2214 $subtotalnetamount += $ref->{netamount};
2215 $subtotaltax += $ref->{tax};
2217 map { $ref->{$_} = $form->format_amount(\%myconfig, $ref->{$_}, 2, " "); } qw(netamount tax amount);
2219 $column_data{id} = qq|<td>$ref->{id}</td>|;
2220 $column_data{invnumber} = 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>|;
2221 $column_data{transdate} = qq|<td>$ref->{transdate}</td>|;
2222 $column_data{name} = qq|<td>$ref->{name} </td>|;
2224 map { $column_data{$_} = qq|<td align=right>$ref->{$_}</td>| } qw(netamount tax amount);
2228 <tr class=listrow$i>
2231 map { print "$column_data{$_}\n" } @column_index;
2239 if ($form->{l_subtotal} eq 'Y') {
2244 map { $column_data{$_} = qq|<th> </th>| } @column_index;
2248 <tr class=listtotal>
2251 $total = $form->format_amount(\%myconfig, $totalnetamount + $totaltax, 2, " ");
2252 $totalnetamount = $form->format_amount(\%myconfig, $totalnetamount, 2, " ");
2253 $totaltax = $form->format_amount(\%myconfig, $totaltax, 2, " ");
2255 $column_data{netamount} = qq|<th class=listtotal align=right>$totalnetamount</th>|;
2256 $column_data{tax} = qq|<th class=listtotal align=right>$totaltax</th>|;
2257 $column_data{amount} = qq|<th class=listtotal align=right>$total</th>|;
2259 map { print "$column_data{$_}\n" } @column_index;
2268 <td><hr size=3 noshade></td>
2276 $lxdebug->leave_sub();
2281 $lxdebug->enter_sub();
2283 map { $column_data{$_} = "<td> </td>" } @column_index;
2285 $subtotalnetamount = $form->format_amount(\%myconfig, $subtotalnetamount, 2, " ");
2286 $subtotaltax = $form->format_amount(\%myconfig, $subtotaltax, 2, " ");
2287 $subtotal = $form->format_amount(\%myconfig, $subtotalnetamount + $subtotaltax, 2, " ");
2289 $column_data{netamount} = "<th class=listsubtotal align=right>$subtotalnetamount</th>";
2290 $column_data{tax} = "<th class=listsubtotal align=right>$subtotaltax</th>";
2291 $column_data{amount} = "<th class=listsubtotal align=right>$subtotal</th>";
2293 $subtotalnetamount = 0;
2297 <tr class=listsubtotal>
2299 map { print "\n$column_data{$_}" } @column_index;
2305 $lxdebug->leave_sub();
2311 $lxdebug->enter_sub();
2314 if ($form->{account}) {
2315 ($form->{paymentaccounts}) = split /--/, $form->{account};
2317 if ($form->{department}) {
2318 ($department, $form->{department_id}) = split /--/, $form->{department};
2319 $option = $locale->text('Department')." : $department";
2322 RP->payments(\%myconfig, \%$form);
2324 @columns = $form->sort_columns(qw(transdate reference name paid source memo));
2327 $account = $form->escape($form->{account});
2328 $title = $form->escape($form->{title});
2329 $department = $form->escape($form->{department});
2330 $form->{paymentaccounts} =~ s/ /%20/g;
2331 $reference = $form->escape($form->{reference});
2332 $source = $form->escape($form->{source});
2333 $memo = $form->escape($form->{memo});
2335 $href = "$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";
2337 # construct callback
2338 $account = $form->escape($form->{account},1);
2339 $title = $form->escape($form->{title},1);
2340 $department = $form->escape($form->{department},1);
2341 $reference = $form->escape($form->{reference},1);
2342 $source = $form->escape($form->{source},1);
2343 $memo = $form->escape($form->{memo},1);
2345 $form->{callback} = "$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}";
2346 $callback = $form->escape($form->{callback});
2349 $column_header{name} = "<th><a class=listheading href=$href&sort=name>".$locale->text('Description')."</a></th>";
2350 $column_header{reference} = "<th><a class=listheading href=$href&sort=invnumber>".$locale->text('Reference')."</a></th>";
2351 $column_header{transdate} = "<th><a class=listheading href=$href&sort=transdate>".$locale->text('Date')."</a></th>";
2352 $column_header{paid} = "<th class=listheading>".$locale->text('Amount')."</a></th>";
2353 $column_header{source} = "<th><a class=listheading href=$href&sort=source>".$locale->text('Source')."</a></th>";
2354 $column_header{memo} = "<th><a class=listheading href=$href&sort=memo>".$locale->text('Memo')."</a></th>";
2357 if ($form->{fromdate}) {
2358 $option .= "\n<br>" if ($option);
2359 $option .= $locale->text('From')." ".$locale->date(\%myconfig, $form->{fromdate}, 1);
2361 if ($form->{todate}) {
2362 $option .= "\n<br>" if ($option);
2363 $option .= $locale->text('bis')." ".$locale->date(\%myconfig, $form->{todate}, 1);
2366 @column_index = @columns;
2367 $colspan = $#column_index + 1;
2376 <th class=listtop>$form->{title}</th>
2378 <tr height="5"></tr>
2385 <tr class=listheading>
2388 map { print "\n$column_header{$_}" } @column_index;
2395 foreach $ref (sort { $a->{accno} cmp $b->{accno} } @{ $form->{PR} }) {
2397 next unless @{ $form->{$ref->{id}} };
2401 <th colspan=$colspan align=left>$ref->{accno}--$ref->{description}</th>
2405 foreach $payment (@{ $form->{$ref->{id}} }) {
2407 $module = $payment->{module};
2408 $module = 'is' if ($payment->{invoice} && $payment->{module} eq 'ar');
2409 $module = 'ir' if ($payment->{invoice} && $payment->{module} eq 'ap');
2411 $href = qq|${module}.pl?path=$form->{path}&action=edit&id=$payment->{id}&login=$form->{login}&password=$form->{password}&callback=$callback|;
2414 $column_data{name} = "<td>$payment->{name} </td>";
2415 $column_data{reference} = qq|<td><a href=$href>$payment->{invnumber}</a></td>|;
2416 $column_data{transdate} = "<td>$payment->{transdate} </td>";
2417 $column_data{paid} = "<td align=right>".$form->format_amount(\%myconfig, $payment->{paid}, 2, " ")."</td>";
2418 $column_data{source} = "<td>$payment->{source} </td>";
2419 $column_data{memo} = "<td>$payment->{memo} </td>";
2421 $subtotalpaid += $payment->{paid};
2422 $totalpaid += $payment->{paid};
2426 <tr class=listrow$i>
2429 map { print "\n$column_data{$_}" } @column_index;
2438 map { $column_data{$_} = "<td> </td>" } @column_index;
2440 $column_data{paid} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotalpaid, 2, " ")."</th>";
2443 <tr class=listsubtotal>
2446 map { print "\n$column_data{$_}" } @column_index;
2458 map { $column_data{$_} = "<td> </td>" } @column_index;
2460 $column_data{paid} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalpaid, 2, " ")."</th>";
2463 <tr class=listtotal>
2466 map { print "\n$column_data{$_}" } @column_index;
2475 <td><hr size=3 noshade></td>
2483 $lxdebug->leave_sub();
2487 $lxdebug->enter_sub();
2491 $lxdebug->leave_sub();
2501 sub winston_export {
2502 $lxdebug->enter_sub();
2503 print (STDERR "Winston Export1\n");
2505 $form->{winston} = 1;
2507 $lxdebug->leave_sub();
2512 $lxdebug->enter_sub();
2514 $form->{sendmode} = "attachment";
2515 $form->{copies} = 2 unless $form->{copies};
2517 $form->{PD}{$form->{type}} = "selected";
2518 $form->{DF}{$form->{format}} = "selected";
2519 $form->{OP}{$form->{media}} = "selected";
2520 $form->{SM}{$form->{sendmode}} = "selected";
2522 if ($form->{report} eq 'ustva'){
2524 <option value=ustva $form->{PD}{ustva}>|.$locale->text('ustva');
2527 <option value=statement $form->{PD}{statement}>|.$locale->text('Statement');
2530 if ($form->{media} eq 'email') {
2532 <option value=attachment $form->{SM}{attachment}>|.$locale->text('Attachment').qq|
2533 <option value=inline $form->{SM}{inline}>|.$locale->text('In-line');
2536 <option value=screen $form->{OP}{screen}>|.$locale->text('Screen');
2537 if ($myconfig{printer} && $latex) {
2539 <option value=printer $form->{OP}{printer}>|.$locale->text('Printer');
2545 <option value=html $form->{DF}{html}>|.$locale->text('HTML').qq|
2546 <option value=pdf $form->{DF}{pdf}>|.$locale->text('PDF');
2547 if ( $form->{report} ne 'ustva' ){
2549 <option value=postscript $form->{DF}{postscript}>|.$locale->text('Postscript');
2556 <td><select name=type>$type</select></td>
2557 <td><select name=format>$format</select></td>
2558 <td><select name=media>$media</select></td>
2561 if ($myconfig{printer} && $latex && $form->{media} ne 'email') {
2563 <td>|.$locale->text('Copies').qq|
2564 <input name=copies size=2 value=$form->{copies}></td>
2573 $lxdebug->leave_sub();
2577 $lxdebug->enter_sub();
2578 $form->{padding} = " ";
2579 $form->{bold} = "<b>";
2580 $form->{endbold} = "</b>";
2581 $form->{br} = "<br>";
2583 # &get_project(generate_bwa);
2585 if ($form->{reporttype} eq "custom"){
2587 #forgotten the year --> thisyear
2588 if ($form->{year} !~ m/^\d\d\d\d$/ ) {
2589 $locale->date(\%myconfig, $form->current_date(\%myconfig), 0)=~ /(\d\d\d\d)/;
2593 if ($form->{duetyp} eq "13" ){
2594 $form->{fromdate}="1.1.$form->{year}";
2595 $form->{todate}="31.12.$form->{year}";
2596 $form->{comparefromdate}="1.01.$form->{year}";
2597 $form->{comparetodate}="31.12.$form->{year}";
2600 if ($form->{duetyp} eq "A" ){
2601 $form->{fromdate}="1.1.$form->{year}";
2602 $form->{todate}="31.3.$form->{year}";
2603 $form->{comparefromdate}="1.01.$form->{year}";
2604 $form->{comparetodate}="31.03.$form->{year}";
2606 if ($form->{duetyp} eq "B" ){
2607 $form->{fromdate}="1.4.$form->{year}";
2608 $form->{todate}="30.6.$form->{year}";
2609 $form->{comparefromdate}="1.01.$form->{year}";
2610 $form->{comparetodate}="30.06.$form->{year}";
2612 if ($form->{duetyp} eq "C" ){
2613 $form->{fromdate}="1.7.$form->{year}";
2614 $form->{todate}="30.9.$form->{year}";
2615 $form->{comparefromdate}="1.01.$form->{year}";
2616 $form->{comparetodate}="30.09.$form->{year}";
2618 if ($form->{duetyp} eq "D" ){
2619 $form->{fromdate}="1.10.$form->{year}";
2620 $form->{todate}="31.12.$form->{year}";
2621 $form->{comparefromdate}="1.01.$form->{year}";
2622 $form->{comparetodate}="31.12.$form->{year}";
2627 $form->{duetyp} eq "1" && do {
2628 $form->{fromdate}="1.1.$form->{year}";
2629 $form->{todate}="31.1.$form->{year}";
2630 $form->{comparefromdate}="1.01.$form->{year}";
2631 $form->{comparetodate}="31.01.$form->{year}";
2634 $form->{duetyp} eq "2" && do {
2635 $form->{fromdate}="1.2.$form->{year}";
2636 #this works from 1901 to 2099, 1900 and 2100 fail.
2637 $leap=($form->{year} % 4 == 0) ? "29" : "28";
2638 $form->{todate}="$leap.2.$form->{year}";
2639 $form->{comparefromdate}="1.01.$form->{year}";
2640 $form->{comparetodate}="$leap.02.$form->{year}";
2643 $form->{duetyp} eq "3" && do {
2644 $form->{fromdate}="1.3.$form->{year}";
2645 $form->{todate}="31.3.$form->{year}";
2646 $form->{comparefromdate}="1.01.$form->{year}";
2647 $form->{comparetodate}="31.03.$form->{year}";
2650 $form->{duetyp} eq "4" && do {
2651 $form->{fromdate}="1.4.$form->{year}";
2652 $form->{todate}="30.4.$form->{year}";
2653 $form->{comparefromdate}="1.01.$form->{year}";
2654 $form->{comparetodate}="30.04.$form->{year}";
2657 $form->{duetyp} eq "5" && do {
2658 $form->{fromdate}="1.5.$form->{year}";
2659 $form->{todate}="31.5.$form->{year}";
2660 $form->{comparefromdate}="1.01.$form->{year}";
2661 $form->{comparetodate}="31.05.$form->{year}";
2664 $form->{duetyp} eq "6" && do {
2665 $form->{fromdate}="1.6.$form->{year}";
2666 $form->{todate}="30.6.$form->{year}";
2667 $form->{comparefromdate}="1.01.$form->{year}";
2668 $form->{comparetodate}="30.06.$form->{year}";
2671 $form->{duetyp} eq "7" && do {
2672 $form->{fromdate}="1.7.$form->{year}";
2673 $form->{todate}="31.7.$form->{year}";
2674 $form->{comparefromdate}="1.01.$form->{year}";
2675 $form->{comparetodate}="31.07.$form->{year}";
2678 $form->{duetyp} eq "8" && do {
2679 $form->{fromdate}="1.8.$form->{year}";
2680 $form->{todate}="31.8.$form->{year}";
2681 $form->{comparefromdate}="1.01.$form->{year}";
2682 $form->{comparetodate}="31.08.$form->{year}";
2685 $form->{duetyp} eq "9" && do {
2686 $form->{fromdate}="1.9.$form->{year}";
2687 $form->{todate}="30.9.$form->{year}";
2688 $form->{comparefromdate}="1.01.$form->{year}";
2689 $form->{comparetodate}="30.09.$form->{year}";
2692 $form->{duetyp} eq "10" && do {
2693 $form->{fromdate}="1.10.$form->{year}";
2694 $form->{todate}="31.10.$form->{year}";
2695 $form->{comparefromdate}="1.01.$form->{year}";
2696 $form->{comparetodate}="31.10.$form->{year}";
2699 $form->{duetyp} eq "11" && do {
2700 $form->{fromdate}="1.11.$form->{year}";
2701 $form->{todate}="30.11.$form->{year}";
2702 $form->{comparefromdate}="1.01.$form->{year}";
2703 $form->{comparetodate}="30.11.$form->{year}";
2706 $form->{duetyp} eq "12" && do {
2707 $form->{fromdate}="1.12.$form->{year}";
2708 $form->{todate}="31.12.$form->{year}";
2709 $form->{comparefromdate}="1.01.$form->{year}";
2710 $form->{comparetodate}="31.12.$form->{year}";
2715 ($yy, $mm, $dd) = $locale->parse_date(\%myconfig, $form->{fromdate});
2716 $form->{fromdate} = "${dd}.${mm}.${yy}";
2717 ($yy, $mm, $dd) = $locale->parse_date(\%myconfig, $form->{todate});
2718 $form->{todate} = "${dd}.${mm}.${yy}";
2719 $form->{comparefromdate} = "01.01.$yy";
2720 $form->{comparetodate} = $form->{todate};
2723 RP->bwa(\%myconfig, \%$form);
2725 ($form->{department}) = split /--/, $form->{department};
2727 $form->{period} = $locale->date(\%myconfig, $form->current_date(\%myconfig), 1);
2728 $form->{todate} = $form->current_date(\%myconfig) unless $form->{todate};
2730 # if there are any dates construct a where
2731 if ($form->{fromdate} || $form->{todate}) {
2733 unless ($form->{todate}) {
2734 $form->{todate} = $form->current_date(\%myconfig);
2737 my %germandate = ("dateformat" => "dd.mm.yyyy");
2739 $longtodate = $locale->date(\%germandate, $form->{todate}, 1);
2740 $shorttodate = $locale->date(\%germandate, $form->{todate}, 0);
2742 $longfromdate = $locale->date(\%germandate, $form->{fromdate}, 1);
2743 $shortfromdate = $locale->date(\%germandate, $form->{fromdate}, 0);
2745 $form->{this_period} = "$shortfromdate<br>\n$shorttodate";
2746 $form->{period} = $locale->text('for Period').qq|<br>\n$longfromdate |.$locale->text('bis').qq| $longtodate|;
2750 # setup variables for the form
2751 @a = qw(company address businessnumber);
2752 map { $form->{$_} = $myconfig{$_} } @a;
2753 $form->{address} =~ s/\\n/<br>/g;
2754 $form->{templates} = $myconfig{templates};
2756 $form->{IN} = "bwa.html";
2758 $form->parse_template;
2760 $lxdebug->leave_sub();
2764 sub generate_ustva {
2765 $lxdebug->enter_sub();
2767 # Hier Aufruf von get_config aus bin/mozilla/fa.pl zum
2768 # Einlesen der Finanzamtdaten
2769 print (STDERR "Winston4\n");
2770 get_config($userspath, 'finanzamt.ini');
2772 # &get_project(generate_bwa);
2773 @anmeldungszeitraum = qw(0401, 0402, 0403, 0404, 0405, 0405, 0406, 0407, 0408, 0409, 0410, 0411, 0412, 0441, 0442, 0443, 0444);
2775 foreach $item (@anmeldungszeitraum) {
2776 $form->{$item} = "";
2778 print (STDERR "Winston2\n");
2779 if ($form->{reporttype} eq "custom"){
2781 #forgotten the year --> thisyear
2782 if ($form->{year} !~ m/^\d\d\d\d$/ ) {
2783 $locale->date(\%myconfig, $form->current_date(\%myconfig), 0)=~ /(\d\d\d\d)/;
2787 if ($form->{duetyp} eq "13" ){
2788 $form->{fromdate}="1.1.$form->{year}";
2789 $form->{todate}="31.12.$form->{year}";
2792 if ($form->{duetyp} eq "A" ){
2793 $form->{fromdate}="1.1.$form->{year}";
2794 $form->{todate}="31.3.$form->{year}";
2795 $form->{"0441"} = "X";
2797 if ($form->{duetyp} eq "B" ){
2798 $form->{fromdate}="1.4.$form->{year}";
2799 $form->{todate}="30.6.$form->{year}";
2800 $form->{"0442"} = "X";
2802 if ($form->{duetyp} eq "C" ){
2803 $form->{fromdate}="1.7.$form->{year}";
2804 $form->{todate}="30.9.$form->{year}";
2805 $form->{"0443"} = "X";
2807 if ($form->{duetyp} eq "D" ){
2808 $form->{fromdate}="1.10.$form->{year}";
2809 $form->{todate}="31.12.$form->{year}";
2810 $form->{"0444"} = "X";
2815 $form->{duetyp} eq "1" && do {
2816 $form->{fromdate}="1.1.$form->{year}";
2817 $form->{todate}="31.1.$form->{year}";
2818 $form->{"0401"} = "X";
2821 $form->{duetyp} eq "2" && do {
2822 $form->{fromdate}="1.2.$form->{year}";
2823 #this works from 1901 to 2099, 1900 and 2100 fail.
2824 $leap=($form->{year} % 4 == 0) ? "29" : "28";
2825 $form->{todate}="$leap.2.$form->{year}";
2826 $form->{"0402"} = "X";
2829 $form->{duetyp} eq "3" && do {
2830 $form->{fromdate}="1.3.$form->{year}";
2831 $form->{todate}="31.3.$form->{year}";
2832 $form->{"0403"} = "X";
2835 $form->{duetyp} eq "4" && do {
2836 $form->{fromdate}="1.4.$form->{year}";
2837 $form->{todate}="30.4.$form->{year}";
2838 $form->{"0404"} = "X";
2841 $form->{duetyp} eq "5" && do {
2842 $form->{fromdate}="1.5.$form->{year}";
2843 $form->{todate}="31.5.$form->{year}";
2844 $form->{"0405"} = "X";
2847 $form->{duetyp} eq "6" && do {
2848 $form->{fromdate}="1.6.$form->{year}";
2849 $form->{todate}="30.6.$form->{year}";
2850 $form->{"0406"} = "X";
2853 $form->{duetyp} eq "7" && do {
2854 $form->{fromdate}="1.7.$form->{year}";
2855 $form->{todate}="31.7.$form->{year}";
2856 $form->{"0407"} = "X";
2859 $form->{duetyp} eq "8" && do {
2860 $form->{fromdate}="1.8.$form->{year}";
2861 $form->{todate}="31.8.$form->{year}";
2862 $form->{"0408"} = "X";
2865 $form->{duetyp} eq "9" && do {
2866 $form->{fromdate}="1.9.$form->{year}";
2867 $form->{todate}="30.9.$form->{year}";
2868 $form->{"0409"} = "X";
2871 $form->{duetyp} eq "10" && do {
2872 $form->{fromdate}="1.10.$form->{year}";
2873 $form->{todate}="31.10.$form->{year}";
2874 $form->{"0410"} = "X";
2877 $form->{duetyp} eq "11" && do {
2878 $form->{fromdate}="1.11.$form->{year}";
2879 $form->{todate}="30.11.$form->{year}";
2880 $form->{"0411"} = "X";
2883 $form->{duetyp} eq "12" && do {
2884 $form->{fromdate}="1.12.$form->{year}";
2885 $form->{todate}="31.12.$form->{year}";
2886 $form->{"0412"} = "X";
2894 # $locale->date(\%myconfig, $form->current_date(\%myconfig), 0)=~ /(\d\d\d\d)/;
2895 # $form->{year}= $1;
2896 # $form->{fromdate}="1.1.$form->{year}";
2897 # $form->{todate}="31.3.$form->{year}";
2898 # $form->{period} = $locale->date(\%myconfig, $form->current_date(\%myconfig), 1);
2901 RP->ustva(\%myconfig, \%$form);
2903 ($form->{department}) = split /--/, $form->{department};
2905 $form->{period} = $locale->date(\%myconfig, $form->current_date(\%myconfig), 1);
2906 $form->{todate} = $form->current_date(\%myconfig) unless $form->{todate};
2908 # if there are any dates construct a where
2909 if ($form->{fromdate} || $form->{todate}) {
2911 unless ($form->{todate}) {
2912 $form->{todate} = $form->current_date(\%myconfig);
2915 $longtodate = $locale->date(\%myconfig, $form->{todate}, 1);
2916 $shorttodate = $locale->date(\%myconfig, $form->{todate}, 0);
2918 $longfromdate = $locale->date(\%myconfig, $form->{fromdate}, 1);
2919 $shortfromdate = $locale->date(\%myconfig, $form->{fromdate}, 0);
2921 $form->{this_period} = "$shortfromdate<br>\n$shorttodate";
2922 $form->{period} = $locale->text('for Period').qq|<br>\n$longfromdate |.$locale->text('bis').qq| $longtodate|;
2925 if ($form->{comparefromdate} || $form->{comparetodate}) {
2926 $longcomparefromdate = $locale->date(\%myconfig, $form->{comparefromdate}, 1);
2927 $shortcomparefromdate = $locale->date(\%myconfig, $form->{comparefromdate}, 0);
2929 $longcomparetodate = $locale->date(\%myconfig, $form->{comparetodate}, 1);
2930 $shortcomparetodate = $locale->date(\%myconfig, $form->{comparetodate}, 0);
2932 $form->{last_period} = "$shortcomparefromdate<br>\n$shortcomparetodate";
2933 $form->{period} .= "<br>\n$longcomparefromdate ".$locale->text('bis').qq| $longcomparetodate|;
2936 $form->{Datum_heute} = $locale->date(\%myconfig, $form->current_date(\%myconfig), 0);
2938 if ($form->{format} eq 'pdf'
2939 or $form->{format} eq 'postscript') {
2940 $form->{padding} = "~~";
2941 $form->{bold} = "\textbf{";
2942 $form->{endbold} = "}";
2943 $form->{br} = '\\\\';
2945 @numbers = qw(51r 86r 97r 93r 96 43 45
2947 foreach $number ( @numbers){
2948 $form->{$number} =~ s/,/~~/g;
2951 } elsif ($form->{format} eq 'html') {
2952 $form->{padding} = " ";
2953 $form->{bold} = "<b>";
2954 $form->{endbold} = "</b>";
2955 $form->{br} = "<br>"
2959 # setup variables for the form
2960 @a = qw(company address businessnumber);
2961 map { $form->{$_} = $myconfig{$_} } @a;
2964 $form->{address} =~ s/\\n/$form->{br}/g;
2966 if ($form->{winston} eq '1'){
2967 print(STDERR "fast bei winston\n");
2971 $form->{templates} = $myconfig{templates};
2972 $form->{IN} = "$form->{type}";
2973 $form->{IN} .= '.tex' if ($form->{format} eq 'pdf'
2974 or $form->{format} eq 'postscript');
2975 $form->{IN} .= '.html' if ($form->{format} eq 'html');
2977 $form->parse_template(\%myconfig, $userspath);
2978 # $form->parse_template;
2980 $lxdebug->leave_sub();