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

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



Revision: 1909
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=1909&view=rev
Author:   einhverfr
Date:     2007-11-26 18:27:48 -0800 (Mon, 26 Nov 2007)

Log Message:
-----------
AR/AP Breakage Fixed

Modified Paths:
--------------
    trunk/LedgerSMB/AA.pm
    trunk/LedgerSMB/DBObject/Company.pm
    trunk/LedgerSMB/DBObject.pm
    trunk/LedgerSMB/Form.pm
    trunk/LedgerSMB.pm
    trunk/UI/Contact/contact.html
    trunk/scripts/customer.pl
    trunk/scripts/employee.pl
    trunk/scripts/vendor.pl
    trunk/sql/Pg-database.sql
    trunk/sql/modules/Company.sql
    trunk/sql/modules/Roles.sql

Modified: trunk/LedgerSMB/AA.pm
===================================================================
--- trunk/LedgerSMB/AA.pm	2007-11-25 23:00:12 UTC (rev 1908)
+++ trunk/LedgerSMB/AA.pm	2007-11-27 02:27:48 UTC (rev 1909)
@@ -908,7 +908,7 @@
 
         if ( $myconfig->{role} eq 'user' ) {
             my $login = $dbh->quote( $form->{login} );
-            $where .= " AND e.login = $login";
+            $where .= " AND e.entity_id = (select entity_id from users where username = $login";
         }
     }
 

Modified: trunk/LedgerSMB/DBObject/Company.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Company.pm	2007-11-25 23:00:12 UTC (rev 1908)
+++ trunk/LedgerSMB/DBObject/Company.pm	2007-11-27 02:27:48 UTC (rev 1909)
@@ -52,6 +52,12 @@
     $self->{dbh}->commit;
 }
 
+sub save_notes {
+    my $self = shift @_;
+    $self->exec_method(funcname => 'entity__save_notes');
+    $self->{dbh}->commit;
+}
+
 sub get {
     my $self = shift @_;
 

Modified: trunk/LedgerSMB/DBObject.pm
===================================================================
--- trunk/LedgerSMB/DBObject.pm	2007-11-25 23:00:12 UTC (rev 1908)
+++ trunk/LedgerSMB/DBObject.pm	2007-11-27 02:27:48 UTC (rev 1909)
@@ -45,18 +45,6 @@
 use strict;
 use warnings;
 
-our $AUTOLOAD;
-
-sub AUTOLOAD {
-    my ($self) = shift;
-    my $type = Scalar::Util::blessed $self;
-    $type =~ m/::(.*?)$/;
-    $type = lc $1;
-    $self->exec_method( funcname => "$type" . "_" . $AUTOLOAD, args => ..hidden..);
-}
-
-sub DESTROY {} 
-
 sub __validate__ {}
 
 sub new {

Modified: trunk/LedgerSMB/Form.pm
===================================================================
--- trunk/LedgerSMB/Form.pm	2007-11-25 23:00:12 UTC (rev 1908)
+++ trunk/LedgerSMB/Form.pm	2007-11-27 02:27:48 UTC (rev 1909)
@@ -1616,8 +1616,8 @@
     my $query = qq|
 		SELECT name, id
 		  FROM entity WHERE id IN (select entity_id
-					 FROM employee 
-					WHERE login = ?)|;
+					 FROM users 
+					WHERE username = ?)|;
 
     my $sth = $self->{dbh}->prepare($query);
     $sth->execute($login);
@@ -1721,9 +1721,9 @@
     my $sth;
 
     if ($vc eq 'customer'){
+        $self->{vc_class} = 1;
+    } else {
         $self->{vc_class} = 2;
-    } else {
-        $self->{vc_class} = 1;
         $vc = 'vendor';
     }
     my $query = qq|SELECT count(*) FROM entity_credit_account where entity_class = ?|;

Modified: trunk/LedgerSMB.pm
===================================================================
--- trunk/LedgerSMB.pm	2007-11-25 23:00:12 UTC (rev 1908)
+++ trunk/LedgerSMB.pm	2007-11-27 02:27:48 UTC (rev 1909)
@@ -150,6 +150,15 @@
 
     $self->merge($params);
 
+    # Adding this so that empty values are stored in the db as NULL's.  If
+    # stored procedures want to handle them differently, they must opt to do so.
+    # -- CT
+    for (keys %$self){
+        if ($self->{$_} eq ''){
+            $self->{$_} = undef;
+        }
+    }
+
     if ($self->is_run_mode('cgi', 'mod_perl')) {
         $ENV{HTTP_COOKIE} =~ s/;\s*/;/g;
         my @cookies = split /;/, $ENV{HTTP_COOKIE};

Modified: trunk/UI/Contact/contact.html
===================================================================
--- trunk/UI/Contact/contact.html	2007-11-25 23:00:12 UTC (rev 1908)
+++ trunk/UI/Contact/contact.html	2007-11-27 02:27:48 UTC (rev 1909)
@@ -17,23 +17,29 @@
 <?lsmb text("Edit Employee") ?>
 -->
 <ul class="navigation">
+	<?lsmb IF entity_class == 3 ?>
+	<li><a href="#hr_div"><?lsmb text('HR') ?></a></li>
+	<?lsmb ELSE ?>
 	<li><a href="#customer_div"><?lsmb text('Account') ?></a></li>
+	<?lsmb END ?>
 	<?lsmb IF entity_id ?>
 	<li><a href="#location_div"><?lsmb text('Addresses') ?></a></li>
 	<li><a href="#contact_div"><?lsmb text('Contact Info') ?></a></li>
 	<li><a href="#bank_div"><?lsmb text('Bank Accounts') ?></a></li>
+	<li><a href="#notes_div"><?lsmb text('Notes') ?></a></li>
 	<!-- Commented out as not yet implemented -CT
-	<li><a href="#notes_div"><?lsmb text('Notes') ?></a></li>
 	<li><a href="#history_div"><?lsmb text('History') ?></a></li>
+	<li><a href="#user_div"><?lsmb text('User') ?></a></li>
 	-->
 	<?lsmb END ?>
 </ul>
 </div>
+<?lsmb IF entity_class == 3 ?>
+<?lsmb ELSE ?>
 <div class="container" id="customer_div">
 <?lsmb SWITCH entity_class
 	?><?lsmb CASE 1 ?><?lsmb entity_classname = "Vendor" 
 	?><?lsmb CASE 2 ?><?lsmb entity_classname = "Customer" 
-	?><?lsmb CASE 3 ?><?lsmb entity_classname = "Employee" 
 ?><?lsmb END ?>
 <div class="listtop"><strong><?lsmb text("$operation $entity_classname") ?></strong></div>
 <?lsmb FOREACH n = notes ?>
@@ -60,8 +66,6 @@
 		size = "20"
 	} ?><br/>
         <table>
-	<!-- TODO:  Create another tab for order history, and another one 
-		for notes -->
         <tr>
             <td>
 		<?lsmb PROCESS input element_data = {
@@ -182,28 +186,28 @@
                         class="submit" 
                         type="submit" 
                         name="action" 
-                        value="ap_transaction" 
+                        value="add_transaction" 
                         accesskey="A" 
-                        title="AP Transaction [Alt-A]"
-			text = text('AP Transaction') 
+                        title="Transaction [Alt-A]"
+			text = (entity_class == 1) ? text('AP Transaction') : text('AR Transaction')
 		} ?>
 		<?lsmb PROCESS button element_data = {
                         class="submit" 
                         type="submit" 
                         name="action" 
-                        value="customer_invoice" 
+                        value="add_invoice" 
                         accesskey="I" 
-                        title="customer Invoice [Alt-I]"
-			text = text('Customer Invoice') 
+                        title="Invoice [Alt-I]"
+			text = (entity_class == 1) ? text('Vendor Invoice')  : text('Customer Invoice') 
 		} ?>
 		<?lsmb PROCESS button element_data = {
                         class="submit" 
                         type="submit" 
                         name="action" 
-                        value="purchase_order" 
+                        value="add_order" 
                         accesskey="O" 
-                        title="Purchase Order [Alt-O]"
-			text = text('Purchase Order') 
+                        title="Order [Alt-O]"
+			text = (entity_class == 1) ? text('Purchase Order') : text('Sales Order')
 		} ?>
 		<?lsmb PROCESS button element_data = {
                         class="submit" 
@@ -211,8 +215,8 @@
                         name="action" 
                         value="rfq" 
                         accesskey="Q" 
-                        title="RFQ [Alt-Q]"
-			text = text('RFQ') 
+                        title="Quotation [Alt-Q]"
+			text = (entity_class == 1) ? text('RFQ') : text('Quotation')
 		} ?>
 		<?lsmb PROCESS button element_data = {
                         class="submit" 
@@ -225,6 +229,7 @@
 		} ?>
     </form>
 </div>
+<?lsmb END ?>
 <?lsmb IF entity_id ?>
 <div id="location_div" class="container">
     <div class="listtop"><?lsmb text('Locations') ?></div>
@@ -469,7 +474,35 @@
 		text = text('Save') 
 		} ?>
 	</div>
+</form>
 </div>
+<div id="notes_div">
+<div class="listtop"><?lsmb text('Notes') ?></div>
+<?lsmb FOREACH n = notes ?>
+<div class="note">
+<div class="timestamp"><?lsmb text('Entered at: [_1]', n.created) ?></div>
+<div class="contents"><?lsmb n.note ?></div>
 <?lsmb END ?>
+<form action="<?lsmb script ?>" method="post">
+	<?lsmb PROCESS input element_data = {
+		type="hidden" 
+		name="entity_id" 
+		value=entity_id
+	} ?>
+<div class="input"><?lsmb PROCESS textarea element_data = {
+	label = text('Notes:')
+	name = notes
+} ?></div>
+<div class="input">
+<?lsmb PROCESS button element_data = {
+	text = text('Save')
+	class = 'submit'
+	name = 'action'
+	value = 'save_notes'
+} ?>
+
+</form>
+</div>
+<?lsmb END ?>
 </body>
 </html>

Modified: trunk/scripts/customer.pl
===================================================================
--- trunk/scripts/customer.pl	2007-11-25 23:00:12 UTC (rev 1908)
+++ trunk/scripts/customer.pl	2007-11-27 02:27:48 UTC (rev 1909)
@@ -202,4 +202,12 @@
     _render_main_screen($customer);
 }
 
+sub save_notes {
+    my ($request) = @_;
+    my $customer = LedgerSMB::DBObject::Customer->new({base => $request});
+    $customer->save_notes();
+    $customer->get();
+    _render_main_screen($customer);
+}
+    
 1;

Modified: trunk/scripts/employee.pl
===================================================================
--- trunk/scripts/employee.pl	2007-11-25 23:00:12 UTC (rev 1908)
+++ trunk/scripts/employee.pl	2007-11-27 02:27:48 UTC (rev 1909)
@@ -202,4 +202,12 @@
     _render_main_screen($employee);
 }
 
+sub save_notes {
+    my ($request) = @_;
+    my $employee = LedgerSMB::DBObject::Employee->new({base => $request});
+    $employee->save_notes();
+    $employee->get();
+    _render_main_screen($employee);
+}
+    
 1;

Modified: trunk/scripts/vendor.pl
===================================================================
--- trunk/scripts/vendor.pl	2007-11-25 23:00:12 UTC (rev 1908)
+++ trunk/scripts/vendor.pl	2007-11-27 02:27:48 UTC (rev 1909)
@@ -194,6 +194,7 @@
     _render_main_screen($vendor );
 }
 
+
 sub save_bank_account {
     my ($request) = @_;
     my $vendor = LedgerSMB::DBObject::Vendor->new({base => $request});
@@ -202,4 +203,12 @@
     _render_main_screen($vendor );
 }
 
+sub save_notes {
+    my ($request) = @_;
+    my $vendor = LedgerSMB::DBObject::Vendor->new({base => $request});
+    $vendor->save_notes();
+    $vendor->get();
+    _render_main_screen($vendor );
+}
+    
 1;

Modified: trunk/sql/Pg-database.sql
===================================================================
--- trunk/sql/Pg-database.sql	2007-11-25 23:00:12 UTC (rev 1908)
+++ trunk/sql/Pg-database.sql	2007-11-27 02:27:48 UTC (rev 1909)
@@ -431,6 +431,12 @@
 -- ssn, iban and bic are from entity_credit_account
 -- 
 -- The view below is broken.  Disabling for now.
+CREATE VIEW employee AS
+ SELECT s.salutation, p.first_name, p.last_name, ee.person_id, ee.entity_id, ee.startdate, ee.enddate, ee."role", ee.ssn, ee.sales, ee.manager_id, ee.employeenumber, ee.dob
+   FROM person p
+   JOIN entity_employee ee USING (entity_id)
+   JOIN salutation s ON p.salutation_id = s.id;
+
 /*
 create view employee as
     SELECT 
@@ -535,7 +541,7 @@
 
 
 
--- COMMENT ON TABLE employee IS $$ Is a metadata table specific to employees $$;
+-- COMMENT ON TABLE employee IS $$ Is a metadata table specific to employee $$;
 
 CREATE TABLE parts (
   id serial PRIMARY KEY,

Modified: trunk/sql/modules/Company.sql
===================================================================
--- trunk/sql/modules/Company.sql	2007-11-25 23:00:12 UTC (rev 1908)
+++ trunk/sql/modules/Company.sql	2007-11-27 02:27:48 UTC (rev 1909)
@@ -1,4 +1,19 @@
 BEGIN;
+
+CREATE OR REPLACE FUNCTION entity__save_notes(in_entity_id int, in_note text)
+RETURNS INT AS
+$$
+DECLARE out_id int;
+BEGIN
+	-- TODO, change this to create vector too
+	INSERT INTO entity_note (ref_key, note_class, entity_id, note, vector)
+	VALUES (in_entity_id, 1, in_entity_id, in_note, '');
+
+	SELECT currval('note_id_seq') INTO out_id;
+	RETURN out_id;
+END;
+$$ LANGUAGE PLPGSQL;
+
 CREATE OR REPLACE FUNCTION entity_list_contact_class() 
 RETURNS SETOF contact_class AS
 $$
@@ -35,11 +50,12 @@
 $$ This may change in 1.4 and should not be relied upon too much $$;
 
 CREATE OR REPLACE FUNCTION entity__retrieve_credit
-(in_entity_id int, in_entity_cass int) 
+(in_entity_id int, in_entity_class int) 
 RETURNS entity_credit_search_return AS
 $$
 DECLARE out_row customer_search_return;
 BEGIN
+	
 	SELECT c.legal_name, 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.pricegroup_id, 
@@ -49,12 +65,15 @@
 	JOIN entity e ON (c.entity_id = e.id)
 	JOIN entity_credit_account ec ON (c.entity_id = ec.entity_id)
 	WHERE e.id = in_entity_id
-		AND ec.entity_class = in_entity_class;
+		AND ec.entity_class = CASE WHEN in_entity_class = 3 THEN 2
+				ELSE in_entity_class END;
 
 	RETURN out_row;
 END;
 $$ LANGUAGE PLPGSQL;
 
+CREATE company
+
 CREATE OR REPLACE FUNCTION entity_credit_save (
     in_id int, in_entity_class int,
     
@@ -89,6 +108,9 @@
             
             INSERT INTO company ( entity_id, legal_name, tax_id ) 
                 VALUES ( new_entity_id, in_name, in_tax_id );
+	IF in_entity_class NOT IN (1, 2) THEN
+		RETURN new_entity_id;
+	END IF;
             
             INSERT INTO entity_credit_account (
                 entity_id,
@@ -126,7 +148,7 @@
             );
             -- entity note class
             insert into entity_note (note_class, note, ref_key, vector) VALUES (
-                1, in_notes, new_entity_id, '');
+                1, in_notes, new_entity_id, to_tsvector(in_notes));
 
             return new_entity_id;
 
@@ -251,12 +273,12 @@
 );
 
 CREATE OR REPLACE FUNCTION company__list_notes(in_entity_id int) 
-RETURNS SETOF entity_note_list AS 
+RETURNS SETOF entity_note AS 
 $$
 DECLARE out_row record;
 BEGIN
 	FOR out_row IN
-		SELECT id, note
+		SELECT *
 		FROM entity_note
 		WHERE ref_key = in_entity_id
 	LOOP

Modified: trunk/sql/modules/Roles.sql
===================================================================
--- trunk/sql/modules/Roles.sql	2007-11-25 23:00:12 UTC (rev 1908)
+++ trunk/sql/modules/Roles.sql	2007-11-27 02:27:48 UTC (rev 1909)
@@ -1380,3 +1380,7 @@
 GRANT SELECT ON custom_field_catalog TO PUBLIC;
 grant select on menu_node, menu_attribute, menu_acl to public;
 GRANT select on chart, gifi, country to public;
+ grant select on employee to public;
+ GRANT SELECT ON parts, partsgroup TO public;
+ GRANT SELECT ON language TO public;
+GRANT SELECT ON business, exchangerate, shipto, tax TO public;


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