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

SF.net SVN: ledger-smb:[4685] branches/1.3



Revision: 4685
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4685&view=rev
Author:   einhverfr
Date:     2012-04-26 08:39:51 +0000 (Thu, 26 Apr 2012)
Log Message:
-----------
Adding API for tax rate floors.  How a tax rate floor is handled is dependent on tax rule module.  Simple ignores this.

Modified Paths:
--------------
    branches/1.3/Changelog
    branches/1.3/LedgerSMB/AM.pm
    branches/1.3/LedgerSMB/Tax.pm
    branches/1.3/LedgerSMB/Taxes/Simple.pm
    branches/1.3/UI/am-taxes.html
    branches/1.3/bin/am.pl
    branches/1.3/sql/Pg-database.sql
    branches/1.3/sql/modules/Account.sql
    branches/1.3/sql/modules/Fixes.sql

Modified: branches/1.3/Changelog
===================================================================
--- branches/1.3/Changelog	2012-04-25 10:59:04 UTC (rev 4684)
+++ branches/1.3/Changelog	2012-04-26 08:39:51 UTC (rev 4685)
@@ -10,9 +10,10 @@
 * Correcting ordering of aging reports so currencies are clustered (Chris T)
 * Fixed curr totals not showing for aging rpts (Chris T, 3512591, h/t John L)
 * Fixed new user screen not respecting default country (Chris T, 3513760)
-* Fixed hasn(...) in HTML payment receipt (Chris T, 3515924, h/t Michael R)
+* Fixed hash(...) in HTML payment receipt (Chris T, 3515924, h/t Michael R)
 * Fixed errors about Concat() not found on Pg 8.4 (Erik H)
 * Fixed can't edit templates with absolute templates path (Chris T 3516725)
+* Added API for minimum value for taxes for local tax modules (Chris T)
 
 John L is John Locke
 Michael R is Michael Richardson

Modified: branches/1.3/LedgerSMB/AM.pm
===================================================================
--- branches/1.3/LedgerSMB/AM.pm	2012-04-25 10:59:04 UTC (rev 4684)
+++ branches/1.3/LedgerSMB/AM.pm	2012-04-26 08:39:51 UTC (rev 4685)
@@ -1860,7 +1860,7 @@
     my $query = qq|
 		  SELECT c.id, c.accno, c.description, 
 		         t.rate * 100 AS rate, t.taxnumber, t.validto,
-			 t.pass, m.taxmodulename
+			 t.minvalue, t.pass, m.taxmodulename
 		    FROM chart c
 		    LEFT JOIN
                      (tax t JOIN taxmodule m 
@@ -1948,11 +1948,11 @@
         $form->{"pass_$i"} = 0 if not $form->{"pass_$i"};
         delete $form->{"old_validto_$i"} if ! $form->{"old_validto_$i"};
 
-        $sth = $dbh->prepare('select account__save_tax(?,?,?,?,?,?,?)');         
+        $sth = $dbh->prepare('select account__save_tax(?,?,?,?,?,?,?,?)');         
         my @queryargs = (
-            $chart_id, $validto, $rate, $form->{"taxnumber_$i"},
-            $form->{"pass_$i"}, $form->{"taxmodule_id_$i"},
-            $form->{"old_validto_$i"}
+            $chart_id, $validto, $rate, $form->{"minvalue_$i"},
+            $form->{"taxnumber_$i"}, $form->{"pass_$i"}, 
+            $form->{"taxmodule_id_$i"}, $form->{"old_validto_$i"}
         );
        $sth->execute(@queryargs) ||$form->dberror($query);
        $sth->finish;

Modified: branches/1.3/LedgerSMB/Tax.pm
===================================================================
--- branches/1.3/LedgerSMB/Tax.pm	2012-04-25 10:59:04 UTC (rev 4684)
+++ branches/1.3/LedgerSMB/Tax.pm	2012-04-26 08:39:51 UTC (rev 4685)
@@ -51,7 +51,7 @@
     }
     my $query = qq|
 		SELECT t.taxnumber, c.description,
-			t.rate, t.chart_id, t.pass, m.taxmodulename
+			t.rate, t.chart_id, t.pass, m.taxmodulename, t.minvalue
 			FROM tax t INNER JOIN chart c ON (t.chart_id = c.id)
 			INNER JOIN taxmodule m 
 				ON (t.taxmodule_id = m.taxmodule_id)
@@ -82,6 +82,7 @@
         $tax->chart( $ref->{'chart'} );
         $tax->description( $ref->{'description'} );
         $tax->value( Math::BigFloat->bzero() );
+        $tax->minvalue($ref->{'minvalue'});
 
         push @taxes, $tax;
         $sth->finish;#should this not be out of foreach loop?, to examine

Modified: branches/1.3/LedgerSMB/Taxes/Simple.pm
===================================================================
--- branches/1.3/LedgerSMB/Taxes/Simple.pm	2012-04-25 10:59:04 UTC (rev 4684)
+++ branches/1.3/LedgerSMB/Taxes/Simple.pm	2012-04-26 08:39:51 UTC (rev 4685)
@@ -36,6 +36,7 @@
     chart       => '$',
     account     => '$',
     value       => 'Math::BigFloat',
+    minvalue    => 'Math::BigFloat', #Ignored in Simple Tax rules
     pass        => '$'
 };
 

Modified: branches/1.3/UI/am-taxes.html
===================================================================
--- branches/1.3/UI/am-taxes.html	2012-04-25 10:59:04 UTC (rev 4684)
+++ branches/1.3/UI/am-taxes.html	2012-04-26 08:39:51 UTC (rev 4685)
@@ -10,6 +10,7 @@
 	<tr>
 	  <th></th>
 	  <th><?lsmb text('Rate (%)') ?></th>
+	  <th><?lsmb text('Min Taxable') ?></th>
 	  <th><?lsmb text('Number') ?></th>
 	  <th><?lsmb text('Valid To') ?></th>
 	  <th><?lsmb text('Ordering') ?></th>
@@ -19,6 +20,7 @@
 	<tr>
 	  <th align="right"><?lsmb row.0 ?></th>
 	  <td><input name="taxrate_<?lsmb i ?>" size="6" value="<?lsmb form.item("taxrate_$i") ?>" /></td>
+	  <td><input name="minvalue_<?lsmb i ?>" size="6" value="<?lsmb form.item("minvalue_$i") ?>" /></td>
 	  <td><input name="taxnumber_<?lsmb i ?>" value="<?lsmb form.item("taxnumber_$i") ?>" /></td>
 	  <td><input class="date" name="validto_<?lsmb i ?>" size="11" value="<?lsmb form.item("validto_$i") ?>" title="<?lsmb user.dateformat ?>" /></td>
 	  <td><input name="pass_<?lsmb i ?>" size="6" value="<?lsmb form.item("pass_$i") ?>" /></td>

Modified: branches/1.3/bin/am.pl
===================================================================
--- branches/1.3/bin/am.pl	2012-04-25 10:59:04 UTC (rev 4684)
+++ branches/1.3/bin/am.pl	2012-04-26 08:39:51 UTC (rev 4685)
@@ -1508,6 +1508,9 @@
     $i = 0;
     foreach $ref ( @{ $form->{taxrates} } ) {
         $i++;
+        $form->{"minvalue_$i"} = 
+          $form->format_amount( \%myconfig, $ref->{minvalue}) || 0;
+        
         $form->{"taxrate_$i"} =
           $form->format_amount( \%myconfig, $ref->{rate} );
         $form->{"taxdescription_$i"} = $ref->{description};

Modified: branches/1.3/sql/Pg-database.sql
===================================================================
--- branches/1.3/sql/Pg-database.sql	2012-04-25 10:59:04 UTC (rev 4684)
+++ branches/1.3/sql/Pg-database.sql	2012-04-26 08:39:51 UTC (rev 4685)
@@ -1460,6 +1460,7 @@
 CREATE TABLE tax (
   chart_id int REFERENCES account(id),
   rate numeric,
+  minvalue numeric,
   taxnumber text,
   validto timestamp not null default 'infinity',
   pass integer DEFAULT 0 NOT NULL,

Modified: branches/1.3/sql/modules/Account.sql
===================================================================
--- branches/1.3/sql/modules/Account.sql	2012-04-25 10:59:04 UTC (rev 4684)
+++ branches/1.3/sql/modules/Account.sql	2012-04-26 08:39:51 UTC (rev 4685)
@@ -254,14 +254,20 @@
 $$ Returns a list of all account headings, currently ordered by account number.
 $$;
 
+DROP FUNCTION IF EXISTS account__save_tax
+(in_chart_id int, in_validto date, in_rate numeric, in_taxnumber text,
+in_pass int, in_taxmodule_id int, in_old_validto date);
+
 CREATE OR REPLACE FUNCTION account__save_tax
-(in_chart_id int, in_validto date, in_rate numeric, in_taxnumber text, 
+(in_chart_id int, in_validto date, in_rate numeric, in_minvalue numeric, 
+in_taxnumber text, 
 in_pass int, in_taxmodule_id int, in_old_validto date)
 returns bool as
 $$
 BEGIN
 	UPDATE tax SET validto = in_validto,
                rate = in_rate,
+               minvalue = in_minvalue,
                taxnumber = in_taxnumber,
                pass = in_pass,
                taxmodule_id = in_taxmodule_id
@@ -271,9 +277,10 @@
              return true;
          END IF;
 
-         INSERT INTO tax(chart_id, validto, rate, taxnumber, pass, taxmodule_id)
-         VALUES (in_chart_id, in_validto, in_rate, in_taxnumber, in_pass,
-                 in_taxmodule_id);
+         INSERT INTO tax(chart_id, validto, rate, minvalue, taxnumber, pass, 
+                        taxmodule_id)
+         VALUES (in_chart_id, in_validto, in_rate, in_minvalue, in_taxnumber, 
+                in_pass, in_taxmodule_id);
 
          RETURN TRUE;
 
@@ -281,6 +288,6 @@
 $$ language plpgsql;
 
 COMMENT ON FUNCTION account__save_tax
-(in_chart_id int, in_validto date, in_rate numeric, in_taxnumber text,
-in_pass int, in_taxmodule_id int, in_old_validto date) IS
+(in_chart_id int, in_validto date, in_rate numeric, in_minval numeric, 
+in_taxnumber text, in_pass int, in_taxmodule_id int, in_old_validto date) IS
 $$ This saves tax rates.$$; 

Modified: branches/1.3/sql/modules/Fixes.sql
===================================================================
--- branches/1.3/sql/modules/Fixes.sql	2012-04-25 10:59:04 UTC (rev 4684)
+++ branches/1.3/sql/modules/Fixes.sql	2012-04-26 08:39:51 UTC (rev 4685)
@@ -261,3 +261,11 @@
 ALTER TABLE cr_report ADD recon_fx bool default false;
 
 COMMIT;
+
+BEGIN;
+
+-- MIN VALUE FOR TAXES
+
+ALTER TABLE tax ADD minvalue numeric;
+
+COMMIT;

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