[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[5807] branches/1.3
- Subject: SF.net SVN: ledger-smb:[5807] branches/1.3
- From: ..hidden..
- Date: Thu, 16 May 2013 10:57:03 +0000
Revision: 5807
http://sourceforge.net/p/ledger-smb/code/5807
Author: einhverfr
Date: 2013-05-16 10:57:02 +0000 (Thu, 16 May 2013)
Log Message:
-----------
Fixing tax boxes can't all be unset once some have been set, bug 818
Modified Paths:
--------------
branches/1.3/Changelog
branches/1.3/LedgerSMB/DBObject/Company.pm
branches/1.3/sql/modules/Company.sql
Modified: branches/1.3/Changelog
===================================================================
--- branches/1.3/Changelog 2013-05-16 10:44:02 UTC (rev 5806)
+++ branches/1.3/Changelog 2013-05-16 10:57:02 UTC (rev 5807)
@@ -8,6 +8,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: branches/1.3/LedgerSMB/DBObject/Company.pm
===================================================================
--- branches/1.3/LedgerSMB/DBObject/Company.pm 2013-05-16 10:44:02 UTC (rev 5806)
+++ branches/1.3/LedgerSMB/DBObject/Company.pm 2013-05-16 10:57:02 UTC (rev 5807)
@@ -310,9 +310,7 @@
);
$sth->execute($self->{taxform1_id}, $self->{credit_id});
}
- if ($self->{tax_ids} ne '{}'){
- $self->exec_method(funcname => 'eca__set_taxes');
- }
+ $self->exec_method(funcname => 'eca__set_taxes');
$self->{threshold} = $self->format_amount(amount => $self->{threshold});
$self->{dbh}->commit;
}
Modified: branches/1.3/sql/modules/Company.sql
===================================================================
--- branches/1.3/sql/modules/Company.sql 2013-05-16 10:44:02 UTC (rev 5806)
+++ branches/1.3/sql/modules/Company.sql 2013-05-16 10:57:02 UTC (rev 5807)
@@ -320,33 +320,23 @@
CREATE OR REPLACE FUNCTION eca__set_taxes(in_credit_id int, in_tax_ids int[])
RETURNS bool AS
$$
-DECLARE
- eca entity_credit_account;
- iter int;
-BEGIN
- SELECT * FROM entity_credit_account into eca WHERE id = in_credit_id;
+ DELETE FROM customertax WHERE customer_id = $1;
+ DELETE FROM vendortax WHERE vendor_id = $1;
- IF eca.entity_class = 1 then
- DELETE FROM vendortax WHERE vendor_id = in_credit_id;
- FOR iter in array_lower(in_tax_ids, 1) .. array_upper(in_tax_ids, 1)
- LOOP
- INSERT INTO vendortax (vendor_id, chart_id)
- values (in_credit_id, in_tax_ids[iter]);
- END LOOP;
- ELSIF eca.entity_class = 2 then
- DELETE FROM customertax WHERE customer_id = in_credit_id;
- FOR iter in array_lower(in_tax_ids, 1) .. array_upper(in_tax_ids, 1)
- LOOP
- INSERT INTO customertax (customer_id, chart_id)
- values (in_credit_id, in_tax_ids[iter]);
- END LOOP;
- ELSE
- RAISE EXCEPTION 'Wrong entity class or credit account not found!';
- END IF;
- RETURN TRUE;
-end;
-$$ language plpgsql;
+ INSERT INTO customertax (customer_id, chart_id)
+ SELECT $1, tax_id
+ FROM unnest($2) tax_id
+ WHERE exists (select * from entity_credit_account
+ where entity_class = 2 AND id = $1);
+ INSERT INTO vendortax (vendor_id, chart_id)
+ SELECT $1, tax_id
+ FROM unnest($2) tax_id
+ WHERE exists (select * from entity_credit_account
+ where entity_class = 1 AND id = $1);
+ SELECT TRUE;
+$$ language sql;
+
comment on function eca__set_taxes(in_credit_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.