From e783d17dd9470f2dc2868e05119ea5bdaf0d00aa Mon Sep 17 00:00:00 2001 From: einhverfr Date: Tue, 20 Nov 2007 19:43:27 +0000 Subject: A few more Customer improvements git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1882 4979c152-3d1c-0410-bac9-87ea11338e46 --- LedgerSMB/DBObject/Customer.pm | 4 +++- UI/Customer/customer.html | 29 +++++++++++++++++++---------- scripts/customer.pl | 13 ++++++++----- sql/modules/Customer.sql | 7 ++----- 4 files changed, 32 insertions(+), 21 deletions(-) diff --git a/LedgerSMB/DBObject/Customer.pm b/LedgerSMB/DBObject/Customer.pm index 9a120f91..aa4404ce 100644 --- a/LedgerSMB/DBObject/Customer.pm +++ b/LedgerSMB/DBObject/Customer.pm @@ -9,7 +9,9 @@ sub save { # This saves both the entity and the credit account. -- CT $self->{entity_class} = 2; - $self->{id} = $self->exec_method(funcname => 'entity_credit_save'); + + $self->{entity_id} = $self->exec_method(funcname => 'entity_credit_save'); + $self->{dbh}->commit; } sub get_metadata { diff --git a/UI/Customer/customer.html b/UI/Customer/customer.html index 759f4d72..3b45e91e 100644 --- a/UI/Customer/customer.html +++ b/UI/Customer/customer.html @@ -1,13 +1,21 @@ + +
+
- - -
@@ -43,7 +51,8 @@ - + @@ -81,11 +90,11 @@ - + / - + maxlength="3" value="">%/ + days @@ -151,8 +160,8 @@
- -
+ +
diff --git a/scripts/customer.pl b/scripts/customer.pl index 988538a8..27e3d4d0 100644 --- a/scripts/customer.pl +++ b/scripts/customer.pl @@ -150,13 +150,16 @@ sub save { my ($request) = @_; my $customer = LedgerSMB::DBObject::Customer->new({base => $request}); + $customer->save(); + $customer->get_metadata(); - my $result = $customer->save(); - - my $template = LedgerSMB::Template->new( user => $request->{_user}, - template => 'customer', locale => $request->{_locale}, + my $template = LedgerSMB::Template->new( + user => $request->{_user}, + template => 'customer', + locale => $request->{_locale}, path => 'UI/Customer', - format => 'HTML'); + format => 'HTML' + ); $template->render($customer); } diff --git a/sql/modules/Customer.sql b/sql/modules/Customer.sql index 6071bc4a..7f2a8da0 100644 --- a/sql/modules/Customer.sql +++ b/sql/modules/Customer.sql @@ -54,10 +54,6 @@ CREATE OR REPLACE FUNCTION entity_credit_save ( ) returns INT as $$ - -- does not require entity_class, as entity_class is a known given to be 1 - - -- Maybe we should make this generic and pass through? -- CT - DECLARE t_entity_class int; new_entity_id int; @@ -99,7 +95,7 @@ CREATE OR REPLACE FUNCTION entity_credit_save ( VALUES ( new_entity_id, in_entity_class, - in_discount, + in_discount / 100, in_taxincluded, in_creditlimit, in_terms, @@ -116,6 +112,7 @@ CREATE OR REPLACE FUNCTION entity_credit_save ( -- entity note class insert into entity_note (note_class, note, ref_key, vector) VALUES ( 1, in_notes, new_entity_id, ''); + return new_entity_id; ELSIF FOUND THEN -- cgit v1.2.3