From 7fad3552f9a62dcaf51fb13880bf0dba476883bf Mon Sep 17 00:00:00 2001 From: einhverfr Date: Thu, 25 Sep 2008 02:01:35 +0000 Subject: Addressing performance issues in multiple payments interface. Adding additional formatting options to format_number, and making multiple payment interface more locale safe. git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@2340 4979c152-3d1c-0410-bac9-87ea11338e46 --- LedgerSMB.pm | 3 +++ LedgerSMB/DBObject/Payment.pm | 8 ++++-- UI/payments/payments_detail.html | 57 ++++++++++++++++++---------------------- scripts/payment.pl | 36 ++++++++++++++++++------- 4 files changed, 61 insertions(+), 43 deletions(-) diff --git a/LedgerSMB.pm b/LedgerSMB.pm index 61293a2b..08bf1a38 100755 --- a/LedgerSMB.pm +++ b/LedgerSMB.pm @@ -380,6 +380,9 @@ sub format_amount { if (!defined $format){ $format = $myconfig->{numberformat} } + if (!defined $args{precision} and defined $args{money}){ + $places = $LedgerSMB::Sysconfig::decimal_places; + } my $negative; if ($amount) { diff --git a/LedgerSMB/DBObject/Payment.pm b/LedgerSMB/DBObject/Payment.pm index eaee4d20..e87cd7a6 100644 --- a/LedgerSMB/DBObject/Payment.pm +++ b/LedgerSMB/DBObject/Payment.pm @@ -459,10 +459,14 @@ sub get_payment_detail_data { my $tmp_invoices = $inv->{invoices}; $inv->{invoices} = []; @{$inv->{invoices}} = $self->_parse_array($tmp_invoices); -# $self->error(Dumper($inv->{invoices})); @{$inv->{invoices}} = sort { $a->[2] cmp $b->[2] } @{ $inv->{invoices} }; + for my $invoice (@{$inv->{invoices}}){ + $invoice->[6] = Math::BigFloat->new($invoice->[6]); + $invoice->[3] = Math::BigFloat->new($invoice->[3]); + $invoice->[4] = Math::BigFloat->new($invoice->[4]); + } } - + $self->{dbh}->commit; # Commit locks } diff --git a/UI/payments/payments_detail.html b/UI/payments/payments_detail.html index c69a88fe..f80cab95 100644 --- a/UI/payments/payments_detail.html +++ b/UI/payments/payments_detail.html @@ -5,8 +5,8 @@ 'UI/payments/payments.css' ] ?> - + @@ -198,7 +198,7 @@ ELSE ; 'name_has_no_vouchers' ; END ?>"> - +   - " type = "hidden" value = i.2 - } ?> + />   - " type = "hidden" - value = i.1 + value = "" } ?>   - +   - +   - + - - - - - " + value = "" size = 20 type = "text" class = "monetary" - } ?> - + - " + value = "" + /> + + name = "" + value = "" + /> @@ -297,7 +292,7 @@ - + @@ -310,7 +305,7 @@ - + diff --git a/scripts/payment.pl b/scripts/payment.pl index 09472dd3..b9d6f94c 100644 --- a/scripts/payment.pl +++ b/scripts/payment.pl @@ -363,24 +363,40 @@ sub display_payments { $payment->{grand_total} = 0; for (@{$payment->{contact_invoices}}){ my $contact_total = 0; - $_->{total_due} = $payment->format_amount(amount => $_->{total_due}); - - if (($payment->{action} ne 'update_payments') + $_->{total_due} = $payment->format_amount(amount => $_->{total_due}, + money => 1); + for my $invoice (@{$_->{invoices}}){ + if (($payment->{action} ne 'update_payments') or (defined $payment->{"id_$_->{contact_id}"})){ - if ($payment->{"paid_$_->{contact_id}"} eq 'some'){ - for my $invoice (@{$_->{invoices}}){ + + if ($payment->{"paid_$_->{contact_id}"} eq 'some'){ my $i_id = $invoice->[0]; $contact_total += $payment->{"paid_$_->{contact_id}_$i_id"}; - } - } else { - $contact_total = $_->{total_due}; + } + } + $invoice->[3] = $payment->format_amount(amount => $invoice->[3], + money => 1); + $invoice->[4] = $payment->format_amount(amount => $invoice->[4], + money => 1); + $invoice->[5] = $payment->format_amount(amount => $invoice->[5], + money => 1); + $invoice->[6] = $payment->format_amount(amount => $invoice->[6], + money => 1); + if (!$payment->{action} ne 'update_payments'){ + my $fld = "payment_" . $invoice->[0]; + $payment->{"$fld"} = $invoice->[6]; } + } + if ($payment->{"paid_$_->{contact_id}"} ne 'some') { + $contact_total = $_->{total_due}; + } + if (($payment->{action} ne 'update_payments') + or (defined $payment->{"id_$_->{contact_id}"})){ + $_->{contact_total} = $contact_total; $payment->{grand_total} += $contact_total; } - $_->{contact_total} = $contact_total; } - @{$payment->{media_options}} = ( {text => $request->{_locale}->text('Screen'), value => 'screen'}); -- cgit v1.2.3