View source | Discuss this page | Page history | Printable version   
Toolbox
Main Page
Upload file
What links here
Recent changes
Help

PDF Books
Show collection (0 pages)
Collections help

Search

ERP 2.50:Acceptance Testing/Create payment terms script PostgreSQL

Scripts for 2.40/2.3x

 
 CREATE OR REPLACE FUNCTION create_paymentTerm()
   RETURNS void AS
 $BODY$ DECLARE
 
 v_paymentterm_id numeric(10);
 v_client_id numeric(10);
 
 BEGIN
 
 SELECT MAX(AD_CLIENT_ID) INTO v_client_id FROM AD_CLIENT;
 
 SELECT COALESCE(MAX(C_PAYMENTTERM_ID),999999) +1 INTO v_paymentterm_id FROM  C_PAYMENTTERM;
  
 INSERT INTO C_PAYMENTTERM
 (C_PAYMENTTERM_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY,  UPDATED, UPDATEDBY,  NAME, ISDUEFIXED, NETDAYS, FIXMONTHOFFSET,  ISNEXTBUSINESSDAY, ISDEFAULT, VALUE, ISVALID)
 VALUES
  (v_paymentterm_id, v_client_id, 0, 'Y', now(), 100, now(), 100, '90 DAYS',  'N', 0, 3, 'N', 'N', '90d', 'N');
 
 PERFORM AD_UPDATE_SEQUENCE();
 
 END ; $BODY$
 LANGUAGE 'plpgsql' VOLATILE;
 
 SELECT create_paymentTerm();
 
 DROP FUNCTION create_paymentTerm();

Scripts 2.50 or higher

 
 CREATE OR REPLACE FUNCTION create_paymentTerm()
   RETURNS void AS
 $BODY$ DECLARE
 
 v_paymentterm_id varchar(32);
 v_client_id varchar(32);
 
 BEGIN
 
 SELECT AD_CLIENT_ID INTO v_client_id FROM AD_CLIENT WHERE created=(SELECT max(created) FROM ad_client);
 
 SELECT get_uuid() INTO v_paymentterm_id;
 
 INSERT INTO C_PAYMENTTERM
 (C_PAYMENTTERM_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY,  UPDATED, UPDATEDBY,  NAME, ISDUEFIXED, NETDAYS, FIXMONTHOFFSET,  ISNEXTBUSINESSDAY, ISDEFAULT, VALUE, ISVALID)
 VALUES
  (v_paymentterm_id, v_client_id, 0, 'Y', now(), 100, now(), 100, '90 DAYS',  'N', 0, 3, 'N', 'N', '90d', 'N');
 
 END ; $BODY$
 LANGUAGE 'plpgsql' VOLATILE;
 
 SELECT create_paymentTerm();
 
 DROP FUNCTION create_paymentTerm();

Retrieved from "http://wiki.openbravo.com/wiki/ERP_2.50:Acceptance_Testing/Create_payment_terms_script_PostgreSQL"

This page has been accessed 3,644 times. This page was last modified on 3 April 2012, at 10:59. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.