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

SF.net SVN: ledger-smb:[6237] trunk/bin/io.pl



Revision: 6237
          http://sourceforge.net/p/ledger-smb/code/6237
Author:   einhverfr
Date:     2013-11-07 08:24:47 +0000 (Thu, 07 Nov 2013)
Log Message:
-----------
Giovanni Biscuolo's patches for rounding differences during posting vs printing

Modified Paths:
--------------
    trunk/bin/io.pl

Modified: trunk/bin/io.pl
===================================================================
--- trunk/bin/io.pl	2013-11-07 08:19:44 UTC (rev 6236)
+++ trunk/bin/io.pl	2013-11-07 08:24:47 UTC (rev 6237)
@@ -91,11 +91,14 @@
 sub _calc_taxes {
     $form->{subtotal} = $form->{invsubtotal};
     for $i (1 .. $form->{rowcount}){
-        my $linetotal = 
-             $form->parse_amount(\%myconfig, $form->{"sellprice_$i"}) 
-             * $form->parse_amount(\%myconfig, $form->{"qty_$i"}) 
-             * (1 - $form->parse_amount(\%myconfig, $form->{"discount_$i"})
-                    / 100);
+        my $discount_amount = $form->round_amount( $form->{"sellprice_$i"} 
+        		       			   * ($form->{"discount_$i"} / 100), 
+		  	       			   $decimalplaces);
+        my $linetotal = $form->round_amount( $form->{"sellprice_$i"}
+                         		     - $discount_amount,
+                         		     $decimalplaces);
+        $linetotal = $form->round_amount( $linetotal * $form->{"qty_$i"}, 
+                                          $moneyplaces);
         @taxaccounts = Tax::init_taxes(
             $form, $form->{"taxaccounts_$i"},
             $form->{'taxaccounts'}
@@ -320,8 +323,11 @@
             }
         }
 
+	my $discount_amount = $form->round_amount( $form->{"sellprice_$i"} 
+			   			   * ($form->{"discount_$i"} / 100), 
+						   $decimalplaces);
         $linetotal = $form->round_amount( $form->{"sellprice_$i"}
-                                          * (1 - ($form->{"discount_$i"} / 100)),
+                                          - $discount_amount,
                                           $decimalplaces);
         $linetotal = $form->round_amount( $linetotal * $form->{"qty_$i"}, 
                                          $moneyplaces);

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


------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most 
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
Ledger-smb-commits mailing list
..hidden..
https://lists.sourceforge.net/lists/listinfo/ledger-smb-commits