From 7130d91ec4941cad5aba49bdd39911a2d5fa9a89 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Tue, 27 Oct 2009 12:49:23 +0100 Subject: [PATCH] form_footer 2. Version --- SL/Template/Plugin/LxERP.pm | 7 + bin/mozilla/is.pl | 83 ++++------ templates/webpages/is/_payments_de.html | 85 ++++++++++ templates/webpages/is/_payments_master.html | 155 ++++++++---------- templates/webpages/is/form_footer_de.html | 51 +++--- templates/webpages/is/form_footer_master.html | 51 +++--- 6 files changed, 247 insertions(+), 185 deletions(-) create mode 100644 templates/webpages/is/_payments_de.html diff --git a/SL/Template/Plugin/LxERP.pm b/SL/Template/Plugin/LxERP.pm index 66f32689b..c26988beb 100644 --- a/SL/Template/Plugin/LxERP.pm +++ b/SL/Template/Plugin/LxERP.pm @@ -23,6 +23,13 @@ sub format_amount { return ''; } +sub round_amount { + my ($self, $var, $places, $skip_zero) = @_; + + return $main::form->round_amount($var * 1, $places) unless $skip_zero && $var == 0; + return ''; +} + sub format_amount_units { my ($self, $amount, $amount_unit, $part_unit) = @_; diff --git a/bin/mozilla/is.pl b/bin/mozilla/is.pl index a732e4d95..5dc3b1a1f 100644 --- a/bin/mozilla/is.pl +++ b/bin/mozilla/is.pl @@ -397,73 +397,60 @@ sub form_footer { $form->{rows} = ($rows > $introws) ? $rows : $introws; my ($tax, $subtotal); - if (!$form->{taxincluded}) { + $form->{taxaccounts_array} = [ split / /, $form->{taxaccounts} ]; - foreach my $item (split / /, $form->{taxaccounts}) { - if ($form->{"${item}_base"}) { + foreach my $item (@{ $form->{taxaccounts_array} }) { + if ($form->{"${item}_base"}) { + if ($form->{taxincluded}) { + $form->{"${item}_total"} = $form->round_amount( ($form->{"${item}_base"} * $form->{"${item}_rate"} + / (1 + $form->{"${item}_rate"})), 2); + $form->{"${item}_netto"} = $form->round_amount( ($form->{"${item}_base"} - $form->{"${item}_total"}), 2); + } else { $form->{"${item}_total"} = $form->round_amount( $form->{"${item}_base"} * $form->{"${item}_rate"}, 2); $form->{invtotal} += $form->{"${item}_total"}; - $form->{"${item}_total"} = $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2); - - $tax .= qq| - - $form->{"${item}_description"} | . $form->{"${item}_rate"} * 100 .qq|% - $form->{"${item}_total"} - |; } } - -# $form->{invsubtotal} = $form->format_amount(\%myconfig, $form->{invsubtotal}, 2, 0); - - $subtotal = qq| - - | . $locale->text('Subtotal') . qq| - $form->{invsubtotal} - -|; - - } - - if ($form->{taxincluded}) { - $form->{taxaccounts_array} = [ split / /, $form->{taxaccounts} ]; - foreach my $item (split / /, $form->{taxaccounts}) { - if ($form->{"${item}_base"}) { - $form->{"${item}_total"} = $form->round_amount( ($form->{"${item}_base"} * $form->{"${item}_rate"} / (1 + $form->{"${item}_rate"})), 2); - $form->{"${item}_netto"} = $form->round_amount( ($form->{"${item}_base"} - $form->{"${item}_total"}), 2); - $form->{"${item}_total"} = $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2); - $form->{"${item}_netto"} = $form->format_amount(\%myconfig, $form->{"${item}_netto"}, 2); - -# $tax .= qq| -# -# Enthaltene $form->{"${item}_description"} | -# . $form->{"${item}_rate"} * 100 .qq|% -# $form->{"${item}_total"} -# -# -# Nettobetrag -# $form->{"${item}_netto"} -# -#|; - } - } - } $form->{oldinvtotal} = $form->{invtotal}; -# $form->{invtotal} = $form->format_amount(\%myconfig, $form->{invtotal}, 2, 0); # unfortunately locales doesn't support extended syntax if ($form->{id}) { my $follow_ups = FU->follow_ups('trans_id' => $form->{id}); if (@{ $follow_ups} ) { - $form->{follow_ups_text} = $locale->text("There are #1 unfinished follow-ups of which #2 are due.", - scalar @{ $follow_ups }, + $form->{follow_up_text} = $locale->text("There are #1 unfinished follow-ups of which #2 are due.", + scalar(@{ $follow_ups }), sum map { $_->{due} * 1 } @{ $follow_ups }); } } +# payments + my $totalpaid = 0; + + $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"}); + $form->{paid_indices} = [ 1 .. $form->{paidaccounts} ]; + + for my $i (1 .. $form->{paidaccounts}) { + $form->{"selectAR_paid_$i"} = $form->{selectAR_paid}; + $form->{"selectAR_paid_$i"} =~ s/option>\Q$form->{"AR_paid_$i"}\E/option selected>$form->{"AR_paid_$i"}/; + + # format amounts + $totalpaid += $form->{"paid_$i"}; + if ($form->{"paid_$i"}) { + $form->{"paid_$i"} = $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2); + } + $form->{"exchangerate_$i"} = $form->format_amount(\%myconfig, $form->{"exchangerate_$i"}); + $form->{"exchangerate_$i"} ||= ""; + } + + + $form->{print_options} = print_options(inline => 1); + print $form->parse_html_template('is/form_footer'); +# print $form->parse_html_template('is/_payments'); # parser + + # print qq| # diff --git a/templates/webpages/is/_payments_de.html b/templates/webpages/is/_payments_de.html new file mode 100644 index 000000000..048569fd8 --- /dev/null +++ b/templates/webpages/is/_payments_de.html @@ -0,0 +1,85 @@ +[%- USE LxERP %] + + + + +[% IF is_credit_note %] + +[% ELSE %] + +[%- END %] + + + + + + + + +[% IF show_exchangerate %] + +[% END %] + + + + +[% paidaccounts %] + +[% FOREACH i = paid_indices %] +[% SET row = {} %] + [% SET row.datepaid = 'datepaid_' _ i %] + [% SET row.source = 'source_' _ i %] + [% SET row.memo = 'memo_' _ i %] + [% SET row.paid = 'paid_' _ i %] + + + + + |; + |; + |; + + |; + + +[%# push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i"); %] + +[% END # foreach %] + + + + + + + + + + + + + + + + + + + +
ZahlungsausgängeZahlungseingänge
DatumBelegMemoBetragWechselkurs.Konto
+ + + +[% IF show_exchangerate %] + [% SET row.forex = 'forex_' _ i %] + [% SET row.exchangerate = 'exchangerate_' _ i %] + [% IF row.forex %] + + [% row.exchangerate | html %] + [% ELSE %] + + [% END %] + ; +[% END %] +
Summe[% LxERP.foramt_amount(totalpaid, 2) | html %]
Fehlbetrag[% LxERP.format_amount(paid_missing, 2) | html %]
+ + + diff --git a/templates/webpages/is/_payments_master.html b/templates/webpages/is/_payments_master.html index 09c0812c2..0549e2805 100644 --- a/templates/webpages/is/_payments_master.html +++ b/templates/webpages/is/_payments_master.html @@ -1,100 +1,85 @@ +[%- USE LxERP %] + + + + +[% IF is_credit_note %] + +[% ELSE %] + +[%- END %] + + + + + + + + +[% IF show_exchangerate %] + +[% END %] + + + + +[% paidaccounts %] + +[% FOREACH i = paid_indices %] +[% SET row = {} %] + [% SET row.datepaid = 'datepaid_' _ i %] + [% SET row.source = 'source_' _ i %] + [% SET row.memo = 'memo_' _ i %] + [% SET row.paid = 'paid_' _ i %] + + + + + |; + |; + |; + + |; + +[%# push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i"); %] - - - - - my @column_index; - if ($form->{currency} eq $form->{defaultcurrency}) { - @column_index = qw(datepaid source memo paid AR_paid); - } else { - @column_index = qw(datepaid source memo paid exchangerate AR_paid); - } - - my %column_data; - $column_data{datepaid} = ""; - $column_data{paid} = ""; - $column_data{exchangerate} = ""; - $column_data{AR_paid} = ""; - $column_data{source} = ""; - $column_data{memo} = ""; - - - - map { print "$column_data{$_}\n" } @column_index; - - - - my @triggers = (); - my $totalpaid = 0; - - $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"}); - - - - [% FOREACH i = 1 .. paidaccounts %] - - - - - $form->{"selectAR_paid_$i"} = $form->{selectAR_paid}; - $form->{"selectAR_paid_$i"} =~ - s/option>\Q$form->{"AR_paid_$i"}\E/option selected>$form->{"AR_paid_$i"}/; - - # format amounts - $totalpaid += $form->{"paid_$i"}; - if ($form->{"paid_$i"}) { - $form->{"paid_$i"} = $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2); - } - $form->{"exchangerate_$i"} = $form->format_amount(\%myconfig, $form->{"exchangerate_$i"}); - - if ($form->{"exchangerate_$i"} == 0) { - $form->{"exchangerate_$i"} = ""; - } - my $exchangerate = qq| |; - if ($form->{currency} ne $form->{defaultcurrency}) { - if ($form->{"forex_$i"}) { - $exchangerate = qq|$form->{"exchangerate_$i"}|; - } else { - $exchangerate = qq||; - } - } - - $exchangerate .= qq||; - - $column_data{"paid_$i"} = - qq||; - $column_data{"exchangerate_$i"} = qq||; - $column_data{"AR_paid_$i"} = - qq||; - $column_data{"datepaid_$i"} = - qq||; - $column_data{"source_$i"} = - qq||; - $column_data{"memo_$i"} = - qq||; - - map { print qq|$column_data{"${_}_$i"}\n| } @column_index; - print " - \n"; - push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i"); - } +[% END # foreach %] - - + + - - + + - map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); } qw(paidaccounts selectAR_paid oldinvtotal)); + + +
PaymentsIncoming Payments
DateSourceMemoAmountExchAccount
+ + + +[% IF show_exchangerate %] + [% SET row.forex = 'forex_' _ i %] + [% SET row.exchangerate = 'exchangerate_' _ i %] + [% IF row.forex %] + + [% row.exchangerate | html %] + [% ELSE %] + + [% END %] + ; +[% END %] +
" . $locale->text('Date') . "" . $locale->text('Amount') . "" . $locale->text('Exch') . "" . $locale->text('Account') . "" . $locale->text('Source') . "" . $locale->text('Memo') . "
$exchangerate -
| . $locale->text('Total') . qq|| . H($form->format_amount(\%myconfig, $totalpaid, 2)) . qq|Total[% LxERP.foramt_amount(totalpaid, 2) | html %]
| . $locale->text('Missing amount') . qq|| . H($form->format_amount(\%myconfig, $paid_missing, 2)) . qq|Missing amount[% LxERP.format_amount(paid_missing, 2) | html %]
+ + + diff --git a/templates/webpages/is/form_footer_de.html b/templates/webpages/is/form_footer_de.html index eeae7564d..cc974d56a 100644 --- a/templates/webpages/is/form_footer_de.html +++ b/templates/webpages/is/form_footer_de.html @@ -58,22 +58,30 @@ [%- END %] - $subtotal +[%#- subtotal %] +[%- UNLESS taxincluded %] + + + + +[%- END %] [%# tax %] [% FOREACH item = taxaccounts_array %] -[% SET description_ref = item _ 'description' %] -[% SET rate_ref = item _ 'rate' %] -[% SET total_ref = item _ 'total' %] -[% SET netto_ref = item _ 'netto' %] +[% SET description_ref = item _ '_description' %] +[% SET rate_ref = item _ '_rate' %] +[% SET total_ref = item _ '_total' %] +[% SET netto_ref = item _ '_netto' %] - - + + + [%- IF taxincluded %] - + + [%- END %] [%- END %] @@ -87,6 +95,7 @@ +[%#--------------------------- WEB DAV BLOCK %] [%- IF webdav %] @@ -108,34 +117,24 @@
Zwischensumme[% LxERP.format_amount(invsubtotal, 2) %]
Enthaltene [% $description_ref %] [% $rate_ref * 100 %]%[% $total_ref %]Enthaltene [% $description_ref | html %] [% $rate_ref * 100 %]%[% LxERP.format_amount($total_ref, 2) %]
Nettobetrag[% $netto_ref %][% LxERP.format_amount($netto_ref, 2) %]

[% END %] +[%#--------------------------- WEB DAV BLOCK %] - - - - -[% IF is_credit_note %] - -[% ELSE %] - -[%- END %] - - +[% PROCESS 'is/_payments_de.html' %] -[%# INCLUDE _payments %] - - -
ZahlungsausgängeZahlungseingänge

- [% print_options %] +[% print_options %]
+ + + [% IF id %] @@ -156,14 +155,14 @@ [% END %] - [%- IF invdate > closedto %] + [%- UNLESS locked %] [%- END %] [% ELSE # no id %] - [% IF invdate > closedto %] + [% UNLESS locked %] diff --git a/templates/webpages/is/form_footer_master.html b/templates/webpages/is/form_footer_master.html index cc1810885..b7548d7ea 100644 --- a/templates/webpages/is/form_footer_master.html +++ b/templates/webpages/is/form_footer_master.html @@ -58,22 +58,30 @@ [%- END %] - $subtotal +[%#- subtotal %] +[%- UNLESS taxincluded %] + + + + +[%- END %] [%# tax %] [% FOREACH item = taxaccounts_array %] -[% SET description_ref = item _ 'description' %] -[% SET rate_ref = item _ 'rate' %] -[% SET total_ref = item _ 'total' %] -[% SET netto_ref = item _ 'netto' %] +[% SET description_ref = item _ '_description' %] +[% SET rate_ref = item _ '_rate' %] +[% SET total_ref = item _ '_total' %] +[% SET netto_ref = item _ '_netto' %] - - + + + [%- IF taxincluded %] - + + [%- END %] [%- END %] @@ -87,6 +95,7 @@ +[%#--------------------------- WEB DAV BLOCK %] [%- IF webdav %] @@ -108,34 +117,24 @@
Subtotal[% LxERP.format_amount(invsubtotal, 2) %]
Enthaltene [% $description_ref %] [% $rate_ref * 100 %]%[% $total_ref %]Enthaltene [% $description_ref | html %] [% $rate_ref * 100 %]%[% LxERP.format_amount($total_ref, 2) %]
Nettobetrag[% $netto_ref %][% LxERP.format_amount($netto_ref, 2) %]

[% END %] +[%#--------------------------- WEB DAV BLOCK %] - - - - -[% IF is_credit_note %] - -[% ELSE %] - -[%- END %] - - +[% PROCESS 'is/_payments_master.html' %] -[%# INCLUDE _payments %] - - -
PaymentsIncoming Payments

- [% print_options %] +[% print_options %]
+ + + [% IF id %] @@ -156,14 +155,14 @@ [% END %] - [%- IF invdate > closedto %] + [%- UNLESS locked %] [%- END %] [% ELSE # no id %] - [% IF invdate > closedto %] + [% UNLESS locked %] -- 2.20.1