diff options
author | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-04-26 20:28:38 +0000 |
---|---|---|
committer | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-04-26 20:28:38 +0000 |
commit | 6c5c1c36fa682244c355f6c06808ec715f0a2baa (patch) | |
tree | 632efc981a5735f7b8d424a680469b71597dd495 /bin/cp.pl | |
parent | 6a118bd31a09a9b8aaabd84f8876952e1cdd6459 (diff) |
Merging bugfixes from current branches/1.2
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1105 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'bin/cp.pl')
-rw-r--r-- | bin/cp.pl | 34 |
1 files changed, 22 insertions, 12 deletions
@@ -45,9 +45,6 @@ # #====================================================================== -use Error qw(:try); - -use LedgerSMB::Template; use LedgerSMB::CP; use LedgerSMB::OP; use LedgerSMB::IS; @@ -59,6 +56,12 @@ require "bin/arap.pl"; # end of main +# This may need to get more sophisticated in the future +# Anyway, it provides one point of control for date handling. +sub default_date { + $form->{date} ||= 'current_date'; +} + sub payment { if ( $form->{type} eq 'receipt' ) { @@ -420,12 +423,13 @@ sub invoices_due { $totalamount += $form->{"amount_$i"}; $totaldue += $form->{"due_$i"}; - if ( $form->{"paid_$i"} !~ /NaN/ ) { - $totalpaid += $form->{"paid_$i"}; + if ( $form->{"paid_$i"} =~ /NaN/ ) { + $form->{"paid_$i"} = ''; } else { - $form->{"paid_$i"} = ''; + $totalpaid += $form->{"paid_$i"}; } + for (qw(amount due paid)) { $form->{"${_}_$i"} = $form->format_amount( \%myconfig, $form->{"${_}_$i"}, 2 ); @@ -441,6 +445,9 @@ sub invoices_due { $column_data{due} = qq|<td align=right>$form->{"due_$i"}</td> <input type=hidden name="due_$i" value=$form->{"due_$i"}>|; + if ( $form->{"paid_$i"} =~ /NaN/ ) { + $form->{"paid_$i"} = ''; + } $column_data{paid} = qq|<td align=right><input name="paid_$i" size=10 value=$form->{"paid_$i"}></td>|; @@ -1147,10 +1154,7 @@ sub list_invoices { $totalamount += $form->{"amount_$i"}; $totaldue += $form->{"due_$i"}; - if ( $form->{"paid_$i"} =~ /NaN/ ) { - $form->{"paid_$i"} = ''; - } - else { + if ( $form->{"paid_$i"} !~ /NaN/ ) { $totalpaid += $form->{"paid_$i"}; } @@ -1170,6 +1174,10 @@ sub list_invoices { $column_data{due} = qq|<td align=right width=15%>$form->{"due_$i"}</td> <input type=hidden name="due_$i" value=$form->{"due_$i"}>|; + if ( $form->{"paid_$i"} =~ /NaN/ ) { + $form->{"paid_$i"} = ''; + } + $column_data{paid} = qq|<td align=right width=15%><input name="paid_$i" size=10 value=$form->{"paid_$i"}></td>|; @@ -1307,7 +1315,10 @@ sub payment_footer { } -sub post { &{"post_$form->{payment}"} } +sub post { + &default_date; + &{"post_$form->{payment}"}; +} sub post_payments { @@ -1533,7 +1544,6 @@ sub check_form { $form->error( $locale->text('Cannot post payment for a closed period!') ) if ( $datepaid <= $closedto ); - # this is just to format the year $form->{datepaid} = $locale->date( \%myconfig, $form->{datepaid} ); $amount = $form->parse_amount( \%myconfig, $form->{amount} ); |