The ar.person_id column was set to
NULL when sales invoices were added to LedgerSMB
programmatically. Turns out stored procedure (function)
person__get_my_entity_id() was selecting against the users table
based on the value of SESSION_USER. But, when connected as the
postgres user, no rows were returned from the stored procedure.
I've come up with a work around, albeit not the most elegant
solution. Please find below, if it is helpful to you.
Brian -- Function: person__get_my_entity_id() -- DROP FUNCTION person__get_my_entity_id(); CREATE OR REPLACE FUNCTION person__get_my_entity_id() RETURNS integer AS $BODY$ SELECT entity_id FROM users WHERE username = SESSION_USER UNION SELECT A.entity_id FROM (SELECT users.entity_id FROM users join entity on entity.id = users.entity_id WHERE entity.entity_class = 3 ORDER BY users.id ASC LIMIT 1) A WHERE NOT EXISTS ( SELECT entity_id FROM users WHERE username = SESSION_USER ) ; $BODY$ LANGUAGE sql VOLATILE COST 100; ALTER FUNCTION person__get_my_entity_id() OWNER TO postgres; COMMENT ON FUNCTION person__get_my_entity_id() IS ' Returns the entity_id of the current, logged in user.'; Brian Wolf
Phone: 410.367.2958
Email: ..hidden..
Try out Activus
Secure Payments™, our recurring payments
application.
Demo at http://demo.activustech.com
|
------------------------------------------------------------------------------ This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev
_______________________________________________ Ledger-smb-users mailing list ..hidden.. https://lists.sourceforge.net/lists/listinfo/ledger-smb-users