diff options
-rwxr-xr-x | LedgerSMB.pm | 3 | ||||
-rw-r--r-- | LedgerSMB/DBObject/Payment.pm | 8 | ||||
-rw-r--r-- | UI/payments/payments_detail.html | 57 | ||||
-rw-r--r-- | 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' ] ?> -<?lsmb BLOCK format_money ?><?lsmb FILTER format('%15.2f') ?><?lsmb number -?><?lsmb END # filter ?><?lsmb END # block ?> +<?lsmb BLOCK format_money ?><?lsmb number +?><?lsmb END # block ?> <?lsmb PROCESS elements.html # Include form elements helper. ?> <?lsmb contact_type = (account_class == 1) ? text('Vendor') : text('Customer') ?> @@ -198,7 +198,7 @@ ELSE ; 'name_has_no_vouchers' ; END ?>"><?lsmb r.contact_name ?></span></td> - <td class="invoice"><?lsmb INCLUDE format_money number=r.total_due ?> + <td class="invoice"><?lsmb r.total_due ?> <?lsmb currency ?></td> <td class="payment" class="details_select"> <?lsmb INCLUDE input element_data = { @@ -243,47 +243,42 @@ <?lsmb icount = icount + 1 ?> <tr> <td class="invoice_date_list"> <?lsmb i.2 ?></td> - <?lsmb PROCESS input element_data = { - name = "invdate_$i.0" + <input + name = "<?lsmb "invdate_$i.0" ?>" type = "hidden" value = i.2 - } ?> + /> <td class="invoice_list"> <?lsmb i.1 ?></td> - <?lsmb PROCESS input element_data = { - name = "invnumber_$i.0" + <input + name = "<?lsmb "invnumber_$i.0" ?>" type = "hidden" - value = i.1 + value = "<?lsmb i.1 ?>" } ?> <td class="total_due_list"> - <?lsmb INCLUDE format_money number=i.3 ?></td> + <?lsmb i.3 ?></td> <td class="paid_list"> - <?lsmb INCLUDE format_money number=i.4 ?></td> + <?lsmb i.4 ?></td> <td class="net_due_list"> - <?lsmb INCLUDE format_money number= i.6 ?> + <?lsmb i.6 ?> <?lsmb currency ?></td> <td class="to_pay_list"> - <?lsmb IF ! ${"payment_$r.contact_id_$i.0"} ?> - - <?lsmb ${"payment_$r.contact_id_$i.0"} = - INCLUDE format_money number= i.6 ?> - <?lsmb END # if ?> - <?lsmb INCLUDE input element_data = { - name = "payment_$r.contact_id_$i.0" - value = ${"payment_$r.contact_id_$i.0"} + <input + name = "<?lsmb "payment_$i.0" ?>" + value = "<?lsmb ${"payment_$i.0"} ?>" size = 20 type = "text" class = "monetary" - } ?> - <?lsmb INCLUDE input element_data = { + /> + <input type = "hidden" - name = "invoice_${r.contact_id}_$icount" - value = i.0 - } ?> - <?lsmb INCLUDE input element_data = { + name = "<?lsmb "invoice_${r.contact_id}_$icount" ?>" + value = "<?lsmb i.0 ?>" + /> + <input type = "hidden" - name = "net_$i.0" - value = ${"payment_$r.contact_id_$i.0"} - } ?> + name = "<?lsmb "net_$i.0" ?>" + value = "<?lsmb ${"payment_$r.contact_id_$i.0"} ?>" + /> </td> </tr> <?lsmb END # foreach i ?> @@ -297,7 +292,7 @@ <?lsmb text('Contact Total (if paying "some")') ?> </td> <td><span id='<?lsmb ${"contact_total_$r.id"} ?>'> - <?lsmb INCLUDE format_money number= r.contact_total ?> + <?lsmb r.contact_total ?> </span><span class="currency"> <?lsmb currency ?></span> </td> @@ -310,7 +305,7 @@ <td class="total_label"><?lsmb text('Grand Total') ?></td> <td> <span id="grand_total"> - <?lsmb INCLUDE format_money number = grand_total ?> + <?lsmb grand_total ?> </span> <span class="currency"> <?lsmb currency ?> 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'}); |