summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2008-09-12 22:57:58 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2008-09-12 22:57:58 +0000
commite6b2f50939b78d5f181070b3aedcd528f5393833 (patch)
tree6a5095dd448bad8d2ab1ee5969ac17443bb91f96
parentaeb8fa97fcadab8e48b014f66650dac8ac4d32c4 (diff)
Added description field to customer/vendor generation.
Corrected entity credit account autogenerated number sequences. git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@2321 4979c152-3d1c-0410-bac9-87ea11338e46
-rw-r--r--LedgerSMB/DBObject/Company.pm6
-rw-r--r--UI/Contact/contact.html18
-rw-r--r--sql/Pg-database.sql1
-rw-r--r--sql/modules/Company.sql27
4 files changed, 42 insertions, 10 deletions
diff --git a/LedgerSMB/DBObject/Company.pm b/LedgerSMB/DBObject/Company.pm
index b2eed72c..a0cce914 100644
--- a/LedgerSMB/DBObject/Company.pm
+++ b/LedgerSMB/DBObject/Company.pm
@@ -71,7 +71,8 @@ sub save_credit {
my $self = shift @_;
$self->set_entity_class();
$self->{threshold} = $self->parse_amount(amount => $self->{threshold});
- $self->exec_method(funcname => 'entity_credit_save');
+ my ($ref) = $self->exec_method(funcname => 'entity_credit_save');
+ $self->{credit_id} = (values %$ref)[0];
$self->{threshold} = $self->format_amount(amount => $self->{threshold});
$self->{dbh}->commit;
}
@@ -218,7 +219,8 @@ sub get {
for (@{$self->{credit_list}}){
print STDERR "credit_id: $_->{credit_id}\n";
if (($_->{credit_id} eq $self->{credit_id})
- or ($_->{meta_number} eq $self->{meta_number})){
+ or ($_->{meta_number} eq $self->{meta_number})
+ or ($_->{id} eq $self->{credit_id})){
$self->merge($_);
last;
}
diff --git a/UI/Contact/contact.html b/UI/Contact/contact.html
index c061ac52..2ccd5491 100644
--- a/UI/Contact/contact.html
+++ b/UI/Contact/contact.html
@@ -229,6 +229,7 @@ problems with multi-word single-quoted constructs in PI tags. -CT -->
<tr class="listheading">
<th class="account_class"><?lsmb text('Type') ?></th>
<th class="number"><?lsmb text("Number") ?></th>
+ <th class="description"><?lsmb text("Description") ?></th>
<th class="credit_limit"><?lsmb text('Credit Limit') ?></th>
<th class="start_date"><?lsmb text('Start Date') ?></th>
<th class="end_date"><?lsmb text('End Date') ?></th>
@@ -242,6 +243,7 @@ problems with multi-word single-quoted constructs in PI tags. -CT -->
<td><a href="<?lsmb script ?>?action=get&account_class=<?lsmb
account_class ?>&entity_id=<?lsmb entity_id
?>&meta_number=<?lsmb cl_item.meta_number ?>"><?lsmb cl_item.meta_number ?></a></td>
+ <td><?lsmb cl_item.description ?></td>
<td><?lsmb cl_item.credit_limit ?></td>
<td><?lsmb cl_item.start_date ?></td>
<td><?lsmb cl_item.end_date ?></td>
@@ -265,14 +267,24 @@ problems with multi-word single-quoted constructs in PI tags. -CT -->
name = "account_class"
value = account_class
} ?>
- <?lsmb PROCESS input element_data = {
+ <table>
+ <tr class="eca_row">
+ <td>
+ <?lsmb PROCESS input element_data = {
label = text("$entity_classname Number:"),
type= "text",
name = "meta_number",
value = meta_number,
size = "20"
- } # " ?><br/>
- <table>
+ } # " ?></td>
+ <td><?lsmb PROCESS input element_data = {
+ label = text("Description:"),
+ type= "text",
+ name = "description",
+ value = description,
+ size = "20"
+ } ?></td>
+ </tr>
<tr id="date-row">
<td>
<?lsmb PROCESS input element_data = {
diff --git a/sql/Pg-database.sql b/sql/Pg-database.sql
index 4648f535..1fe40ada 100644
--- a/sql/Pg-database.sql
+++ b/sql/Pg-database.sql
@@ -307,6 +307,7 @@ CREATE TABLE entity_credit_account (
entity_id int not null references entity(id) ON DELETE CASCADE,
entity_class int not null references entity_class(id) check ( entity_class in (1,2) ),
discount numeric,
+ description text,
discount_terms int default 0,
discount_account_id int references chart(id),
taxincluded bool default 'f',
diff --git a/sql/modules/Company.sql b/sql/modules/Company.sql
index f8095201..0ee77159 100644
--- a/sql/modules/Company.sql
+++ b/sql/modules/Company.sql
@@ -178,6 +178,7 @@ CREATE TYPE entity_credit_retrieve AS (
creditlimit numeric,
terms int2,
meta_number text,
+ description text,
business_id int,
language_code text,
pricegroup_id int,
@@ -218,7 +219,8 @@ BEGIN
FOR out_row IN
SELECT c.id, e.id, ec.entity_class, ec.discount,
ec.taxincluded, ec.creditlimit, ec.terms,
- ec.meta_number, ec.business_id, ec.language_code,
+ ec.meta_number, ec.description, ec.business_id,
+ ec.language_code,
ec.pricegroup_id, ec.curr, ec.startdate,
ec.enddate, ec.ar_ap_account_id, ec.cash_account_id,
ec.threshold, e.control_code, ec.id
@@ -335,7 +337,7 @@ $$ LANGUAGE PLPGSQL;
CREATE OR REPLACE FUNCTION entity_credit_save (
in_credit_id int, in_entity_class int,
- in_entity_id 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,
@@ -350,15 +352,29 @@ CREATE OR REPLACE FUNCTION entity_credit_save (
DECLARE
t_entity_class int;
l_id int;
+ t_meta_number text;
+ t_mn_default_key text;
BEGIN
+ -- TODO: Move to mapping table.
+ IF in_entity_class = 1 THEN
+ t_mn_default_key := 'vendornumber';
+ ELSIF in_entity_class = 2 THEN
+ t_mn_default_key := 'customernumber';
+ END IF;
+ IF in_meta_number IS NULL THEN
+ t_meta_number := setting_increment(t_mn_default_key);
+ ELSE
+ t_meta_number := in_meta_number;
+ END IF;
update entity_credit_account SET
discount = in_discount,
taxincluded = in_taxincluded,
creditlimit = in_creditlimit,
+ description = in_description,
terms = in_terms,
ar_ap_account_id = in_ar_ap_account_id,
cash_account_id = in_cash_account_id,
- meta_number = in_meta_number,
+ meta_number = t_meta_number,
business_id = in_business_id,
language_code = in_language,
pricegroup_id = in_pricegroup_id,
@@ -376,6 +392,7 @@ CREATE OR REPLACE FUNCTION entity_credit_save (
entity_id,
entity_class,
discount,
+ description,
taxincluded,
creditlimit,
terms,
@@ -395,10 +412,11 @@ CREATE OR REPLACE FUNCTION entity_credit_save (
in_entity_id,
in_entity_class,
in_discount,
+ in_description,
in_taxincluded,
in_creditlimit,
in_terms,
- in_meta_number,
+ t_meta_number,
in_business_id,
in_language,
in_pricegroup_id,
@@ -410,7 +428,6 @@ CREATE OR REPLACE FUNCTION entity_credit_save (
in_ar_ap_account_id,
in_cash_account_id
);
- -- entity note class
RETURN currval('entity_credit_account_id_seq');
END IF;