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

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



Revision: 5806
          http://sourceforge.net/p/ledger-smb/code/5806
Author:   einhverfr
Date:     2013-05-16 10:44:02 +0000 (Thu, 16 May 2013)
Log Message:
-----------
Tax checkboxes can now fully all be unset

Modified Paths:
--------------
    trunk/Changelog
    trunk/LedgerSMB/Entity/Credit_Account.pm
    trunk/sql/modules/Company.sql

Modified: trunk/Changelog
===================================================================
--- trunk/Changelog	2013-05-16 10:31:47 UTC (rev 5805)
+++ trunk/Changelog	2013-05-16 10:44:02 UTC (rev 5806)
@@ -90,6 +90,7 @@
 * Fixed Project dropdown ordering and selection (Chris T, 809)
 * Fixed UI inconsistency re: language dropdown (Chris T, 816)
 * Fixed grants to menus (which can cause problems for submenus (Chris T, 820)
+* Fixed tax boxes cannot be all unset (Chris T, 818)
 
 Changelog for 1.3.32
 * Fixed em-dash handling for pdfs (Chris T)

Modified: trunk/LedgerSMB/Entity/Credit_Account.pm
===================================================================
--- trunk/LedgerSMB/Entity/Credit_Account.pm	2013-05-16 10:31:47 UTC (rev 5805)
+++ trunk/LedgerSMB/Entity/Credit_Account.pm	2013-05-16 10:44:02 UTC (rev 5806)
@@ -381,9 +381,7 @@
     my ($self) = @_;
     warn $self->{entity_class};
     my ($ref) = $self->exec_method({funcname => 'eca__save'});
-    if (@{$self->{tax_ids}}){
-        $self->exec_method(funcname => 'eca__set_taxes');
-    }
+    $self->exec_method(funcname => 'eca__set_taxes');
     return $self->get_by_id($ref->{eca__save});
 }
 

Modified: trunk/sql/modules/Company.sql
===================================================================
--- trunk/sql/modules/Company.sql	2013-05-16 10:31:47 UTC (rev 5805)
+++ trunk/sql/modules/Company.sql	2013-05-16 10:44:02 UTC (rev 5806)
@@ -385,25 +385,13 @@
 CREATE OR REPLACE FUNCTION eca__set_taxes(in_id int, in_tax_ids int[])
 RETURNS bool AS
 $$
-DECLARE 
-    eca entity_credit_account;
-    iter int;
-BEGIN
-     IF in_tax_ids = '{}' THEN
-         RETURN NULL;
-     END IF;
-     SELECT * FROM entity_credit_account into eca WHERE id = in_id;
+     DELETE FROM eca_tax WHERE eca_id = $1;
+     INSERT INTO eca_tax (eca_id, chart_id)
+     SELECT $1, tax_id
+       FROM unnest($2) tax_id;
+     SELECT TRUE;
+$$ language sql;
 
-     DELETE FROM eca_tax WHERE eca_id = in_id;
-     FOR iter in array_lower(in_tax_ids, 1) .. array_upper(in_tax_ids, 1)
-     LOOP
-          INSERT INTO eca_tax (eca_id, chart_id)
-          values (in_id, in_tax_ids[iter]);
-     END LOOP;
-     RETURN TRUE;
-end;
-$$ language plpgsql;
-
 comment on function eca__set_taxes(in_id int, in_tax_ids int[]) is
 $$Sets the tax values for the customer or vendor.
 

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