[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[3130] trunk



Revision: 3130
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3130&view=rev
Author:   einhverfr
Date:     2011-03-25 13:10:25 +0000 (Fri, 25 Mar 2011)

Log Message:
-----------
Allowing for arbitrary rounding rules in trial balance.  This allows for:
Proper investigation of fractional cent distribution issues when tracking down a trial balance discrepancy and
Support for some international rules specifying specific precisions for aggregation and display.

Modified Paths:
--------------
    trunk/LedgerSMB/Form.pm
    trunk/LedgerSMB/RP.pm
    trunk/UI/rp-search-generate_trial_balance.html
    trunk/bin/rp.pl

Modified: trunk/LedgerSMB/Form.pm
===================================================================
--- trunk/LedgerSMB/Form.pm	2011-03-18 22:46:07 UTC (rev 3129)
+++ trunk/LedgerSMB/Form.pm	2011-03-25 13:10:25 UTC (rev 3130)
@@ -763,12 +763,14 @@
     my ( $self, $myconfig, $amount, $places, $dash ) = @_;
 
     $self = "" unless defined $self;
+    my $negative;
     $myconfig = "" unless defined $myconfig;
     $amount = "" unless defined $amount;
     $places = "" unless defined $places;
     $dash = "" unless defined $dash;
-
-    my $negative;
+    if ($self->{money_precision}){
+       $places= $self->{money_precision};
+    }
     $amount = $self->parse_amount( $myconfig, $amount );
     $negative = ( $amount < 0 );
     $amount =~ s/-//;

Modified: trunk/LedgerSMB/RP.pm
===================================================================
--- trunk/LedgerSMB/RP.pm	2011-03-18 22:46:07 UTC (rev 3129)
+++ trunk/LedgerSMB/RP.pm	2011-03-25 13:10:25 UTC (rev 3130)
@@ -1342,10 +1342,16 @@
       if $form->{year} && $form->{month};
     my $amount_cast; # Whitelisted, safe for interpolation
     if ($form->{discrete_money}){
-        $amount_cast = "NUMERIC(30,$LedgerSMB::Sysconfig::decimal_places)";
+        $form->{calc_precision} = $LedgerSMB::Sysconfig::precision;
+    }
+    if ($form->{calc_precision} =~ /\D/){
+        $form->error('Illegal calculation precision');
+    }
+    if ($form->{calc_precision} =~ /\d+/){
+        $amount_cast = "NUMERIC(30,$form->{calc_precision})";
     } else {
         $amount_cast = "NUMERIC";
-    };
+    }
 
     # get beginning balances
     if ( ($department_id or $form->{accounttype} eq 'gifi') and $form->{fromdate}) {
@@ -1398,7 +1404,6 @@
 
         while ( my $ref = $sth->fetchrow_hashref(NAME_lc) ) {
             $form->db_parse_numeric(sth=>$sth, hashref=>$ref);
-            $ref->{amount} = $form->round_amount( $ref->{amount}, 2 );
             $balance{ $ref->{accno} } = $ref->{amount};
 
             if ( $form->{all_accounts} ) {
@@ -1505,9 +1510,6 @@
         $sth->execute();
         while ($ref = $sth->fetchrow_hashref('NAME_lc')){
             $form->db_parse_numeric(sth=>$sth, hashref=>$ref);
-            $ref->{debit}   = $form->round_amount($ref->{debit}, 2);
-            $ref->{credit}  = $form->round_amount($ref->{credit}, 2);
-            $ref->{balance} = $form->round_amount($ref->{balance}, 2);
             $trb{ $ref->{accno} }{accno}       = $ref->{accno};
             $trb{ $ref->{accno} }{description} = $ref->{description};
             $trb{ $ref->{accno} }{charttype}   = 'A';
@@ -1681,8 +1683,6 @@
 
             }
 
-            $ref->{debit}  = $form->round_amount( $ref->{debit},  2 );
-            $ref->{credit} = $form->round_amount( $ref->{credit}, 2 );
 
             if ( !$form->{all_accounts} ) {
                 next

Modified: trunk/UI/rp-search-generate_trial_balance.html
===================================================================
--- trunk/UI/rp-search-generate_trial_balance.html	2011-03-18 22:46:07 UTC (rev 3129)
+++ trunk/UI/rp-search-generate_trial_balance.html	2011-03-25 13:10:25 UTC (rev 3130)
@@ -49,6 +49,28 @@
     } -?>
         </td>
       </tr>
+      <tr>
+      <th align="right"><?lsmb text('Display Precision') ?></th>
+      <td><?lsmb PROCESS input element_data = {
+              name = 'display_precision'
+              value = display_precision
+              type = 'input'
+              size = 10
+              class = 'int'
+      } ?>
+      </td>
+      </tr>
+      <tr>
+      <th><?lsmb text('Calc. Precision') ?></th>
+      <td><?lsmb PROCESS input element_data = {
+              name = 'calc_precision'
+              value = calc_precision
+              type = 'input'
+              size = 10
+              class = 'int'
+      } ?>
+      </td>
+      </tr>
 <?lsmb END ?>
     </table>
   </td>

Modified: trunk/bin/rp.pl
===================================================================
--- trunk/bin/rp.pl	2011-03-18 22:46:07 UTC (rev 3129)
+++ trunk/bin/rp.pl	2011-03-25 13:10:25 UTC (rev 3130)
@@ -619,7 +619,7 @@
 # added headers and subtotals
 #
 sub generate_trial_balance {
-
+    $form->{money_precision} = $form->{display_precision};
     # get for each account initial balance, debits and credits
     RP->trial_balance( \%myconfig, \%$form );
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.