Log in / create account
View source | Discuss page | Page history | Printable version   
ADVERTISEMENT
Accounting eLearning Courses
Partnerships
SourceForge.net Logo
Openbravo ERP at SourceForge

SourceForge.net Logo
Openbravo POS at SourceForge

Open Solution Alliance Logo
Openbravo at Open Solutions Alliance

CallOutExample

Code snippet

Name: CallOutExample
Version: Openbravo 2.35
Author: Victor Gaspar



Rating :
5.00/5
(1 votes cast)
You have to be registered to be able to vote

Modifying a Callout to show a Message to the user, for clients checked as debtors, always that they try to buy NOT in cash (in certain windows with periodical payments).


1.- Create a new column in the C_BPARTNER table called isdebtor as char. Don't forget to Synchronize. Add this field to the windows Partner.

2.- Create a new message in the AD called isdebtor, with the alert wanted to show to the user.

3.- Add the next Sqlmethod to the file SE_Order_BPartner_data.xsql located under ~/OpenbravoERP/AppsOpenbravo/src/org/openbravo/erpCommon/ad_callouts/ if you are using Linux. This method gets if the partner was checked as debtor.

 <SqlMethod name="partnerDebtor" type="preparedStatement" return="String" default="">
 <SqlMethodComment></SqlMethodComment>
   <Sql>
    <![CDATA[
     select isdebtor
     from c_bpartner
     where c_bpartner_id = ?
    ]]>
   </Sql>
   <Parameter name="cBpartnerId"/>
   <Field name="isdebtor" value=""/>
 </SqlMethod>


4.- At the end of SE_Order_BPartner.java file located in the same directory, add the following java code. Pay attention to the if-condition to see if it fulfil your requirements.

   ...
   //Modified BEGINS
   //Get if the partner was checked as debtor
   String debtor = SEOrderBPartnerData.partnerDebtor(this, strBPartner);
   char[] is_debtor = debtor.toCharArray();

   //Get windows_id
   int intWindowId = Integer.parseInt(strWindowId);

   //If Partner is Debtor and Windows isn't "Cash windows" and Windows isn't Ticket Windows  
   if(is_debtor[0]=='Y' && intWindowId!=100001 && intWindowId!=100003)
   {
      resultado.append(", new Array('MESSAGE', \"" + Utility.messageBD(this, "isdebtor", vars.getLanguage()) + "\")");
   }
   //Modified END

   resultado.append(");");
   xmlDocument.setParameter("array", resultado.toString());
   xmlDocument.setParameter("frameName", "frameAplicacion");
   response.setContentType("text/html; charset=UTF-8");
   PrintWriter out = response.getWriter();
   out.println(xmlDocument.print());
   out.close();
   ...


5.- Compile

Retrieved from "http://wiki.openbravo.com/wiki/CallOutExample"

This page has been accessed 990 times. This page was last modified 12:21, 20 August 2008. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.


Category: Code Snippets