CallOutExample
Code snippetName: CallOutExample
|
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
Category: Code Snippets

