[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[4502] trunk
- Subject: SF.net SVN: ledger-smb:[4502] trunk
- From: ..hidden..
- Date: Sat, 17 Mar 2012 07:53:33 +0000
Revision: 4502
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4502&view=rev
Author: einhverfr
Date: 2012-03-17 07:53:33 +0000 (Sat, 17 Mar 2012)
Log Message:
-----------
Sales tax settings now save again in trunk
Modified Paths:
--------------
trunk/LedgerSMB/DBObject/Entity/Credit_Account.pm
trunk/LedgerSMB.pm
trunk/UI/Contact/contact.html
trunk/sql/modules/Company.sql
Modified: trunk/LedgerSMB/DBObject/Entity/Credit_Account.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Entity/Credit_Account.pm 2012-03-17 03:50:51 UTC (rev 4501)
+++ trunk/LedgerSMB/DBObject/Entity/Credit_Account.pm 2012-03-17 07:53:33 UTC (rev 4502)
@@ -295,6 +295,7 @@
my ($self, $id) = @_;
my ($ref) = $self->call_procedure(procname => 'entity_credit__get',
args => [$id]);
+ $ref->{tax_ids} = $self->_get_tax_ids($id);
$self->prepare_dbhash($ref);
return $self->new(%$ref);
}
@@ -312,9 +313,24 @@
args => [$meta_number,
$entity_class]);
$self->prepare_dbhash($ref);
+ $ref->{tax_ids} = $self->_set_tax_ids($ref->{id});
return $self->new(%$ref);
}
+# Private methid _get_tax_ids
+# returns an array ref of chart ids for the taxes.
+
+sub _get_tax_ids {
+ my ($self, $id) = @_;
+ my @tax_ids;
+ my @results = $self->call_procedure(procname => 'eca__get_taxes',
+ args => [$id]);
+ for my $ref (@results){
+ push @tax_ids, $ref->{chart_id};
+ }
+ return ..hidden..
+}
+
=item list_for_entity($entity_id int, [$entity_class int]);
Returns a list of entity credit accounts for the entity (company or person)
@@ -328,6 +344,7 @@
args => [$entity_id, $entity_class]
);
for my $ref (@results){
+ $ref->{tax_ids} = $self->_get_tax_ids($ref->{id});
$self->prepare_dbhash($ref);
$ref = $self->new(%$ref);
}
@@ -356,6 +373,9 @@
sub save {
my ($self) = @_;
my ($ref) = $self->exec_method({funcname => 'eca__save'});
+ if (@{$self->{tax_ids}}){
+ $self->exec_method(funcname => 'eca__set_taxes');
+ }
$self->prepare_dbhash($ref);
$self = $self->new(%$ref);
}
Modified: trunk/LedgerSMB.pm
===================================================================
--- trunk/LedgerSMB.pm 2012-03-17 03:50:51 UTC (rev 4501)
+++ trunk/LedgerSMB.pm 2012-03-17 07:53:33 UTC (rev 4502)
@@ -667,7 +667,10 @@
$schema = $self->{dbh}->quote_identifier($schema);
- for ( 1 .. scalar @call_args ) {
+ for my $arg ( @call_args ) {
+ if (eval { $arg->can('to_db') }){
+ $arg = $arg->to_db;
+ }
$argstr .= "?, ";
}
$argstr =~ s/\, $//;
Modified: trunk/UI/Contact/contact.html
===================================================================
--- trunk/UI/Contact/contact.html 2012-03-17 03:50:51 UTC (rev 4501)
+++ trunk/UI/Contact/contact.html 2012-03-17 07:53:33 UTC (rev 4502)
@@ -474,7 +474,7 @@
} ?>
<?lsmb PROCESS input element_data = {
type = "hidden"
- name = "credit_id"
+ name = "id"
value = credit_act.id
} ?>
<?lsmb PROCESS input element_data = {
@@ -676,7 +676,7 @@
<?lsmb tx.accno ?>--<?lsmb tx.description ?></span>
<span class="input" id="txinput-<?lsmb tx.id ?>">
<?lsmb checked = "";
- IF eca_tax.grep(tx.id).size == 1;
+ IF credit_act.tax_ids.grep(tx.id).size == 1;
checked = "CHECKED";
END;
INCLUDE input element_data = {
Modified: trunk/sql/modules/Company.sql
===================================================================
--- trunk/sql/modules/Company.sql 2012-03-17 03:50:51 UTC (rev 4501)
+++ trunk/sql/modules/Company.sql 2012-03-17 07:53:33 UTC (rev 4502)
@@ -322,7 +322,9 @@
meta_number must match exactly or be NULL. inc_open and inc_closed are exact
matches too. All other values specify ranges or may match partially.$$;
-CREATE OR REPLACE FUNCTION eca__get_taxes(in_credit_id int)
+DROP FUNCTION IF EXISTS eca__get_taxes(in_credit_id int);
+
+CREATE OR REPLACE FUNCTION eca__get_taxes(in_id int)
returns setof eca_tax AS
$$
select * from eca_tax where eca_id = $1;
@@ -331,7 +333,8 @@
COMMENT ON FUNCTION eca__get_taxes(in_credit_id int) IS
$$ Returns a set of taxable account id's.$$; --'
-CREATE OR REPLACE FUNCTION eca__set_taxes(in_credit_id int, in_tax_ids int[])
+DROP FUNCTION IF EXISTS eca__set_taxes(int, int[]);
+CREATE OR REPLACE FUNCTION eca__set_taxes(in_id int, in_tax_ids int[])
RETURNS bool AS
$$
DECLARE
@@ -341,19 +344,19 @@
IF in_tax_ids = '{}' THEN
RETURN NULL;
END IF;
- SELECT * FROM entity_credit_account into eca WHERE id = in_credit_id;
+ SELECT * FROM entity_credit_account into eca WHERE id = in_id;
- DELETE FROM eca_tax WHERE eca_id = in_credit_id;
+ 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_credit_id, in_tax_ids[iter]);
+ 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_credit_id int, in_tax_ids int[]) is
+comment on function eca__set_taxes(in_id int, in_tax_ids int[]) is
$$Sets the tax values for the customer or vendor.
The entity credit account must exist before calling this function, and must
@@ -741,9 +744,23 @@
in_pay_to_name text,
in_taxform_id int);
-CREATE OR REPLACE FUNCTION eca__save (
+DROP FUNCTION IF EXISTS eca__save (
in_credit_id int, in_entity_class int,
in_entity_id int, in_description text,
+ in_discount numeric, in_taxincluded bool, in_creditlimit numeric,
+ in_discount_terms int,
+ in_terms int, in_meta_number varchar(32), in_business_id int,
+ in_language_code varchar(6), in_pricegroup_id int,
+ in_curr char, in_startdate date, in_enddate date,
+ in_threshold NUMERIC,
+ in_ar_ap_account_id int,
+ in_cash_account_id int,
+ in_pay_to_name text,
+ in_taxform_id int);
+
+CREATE OR REPLACE FUNCTION eca__save (
+ in_id int, in_entity_class int,
+ in_entity_id int, in_description text,
in_discount numeric, in_taxincluded bool, in_creditlimit numeric,
in_discount_terms int,
in_terms int, in_meta_number varchar(32), in_business_id int,
@@ -793,10 +810,10 @@
discount_terms = in_discount_terms,
pay_to_name = in_pay_to_name,
taxform_id = in_taxform_id
- where id = in_credit_id;
+ where id = in_id;
IF FOUND THEN
- RETURN in_credit_id;
+ RETURN in_id;
ELSE
INSERT INTO entity_credit_account (
entity_id,
@@ -851,7 +868,7 @@
$$ language 'plpgsql';
COMMENT ON FUNCTION eca__save (
- in_credit_id int, in_entity_class int,
+ in_id int, in_entity_class int,
in_entity_id int, in_description text,
in_discount numeric, in_taxincluded bool, in_creditlimit numeric,
in_discount_terms int,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.