3
 9/12/2014 POS - Check stock of the product - OpenbravoWi k i http://w ik i .openbravo.com/w i k i /POS_- Check stock _of the product 1/3 Log in / create account  Openbravo.com Partn er Portal Is su es Blogs Forge Excha ng e University Dow nl oads View source | Discuss this page | Page history | Printable version Contents 1 Code snippet 2 Add Four variables into evalScript method in JPanelTicket 3 Create Script.StockCurrentAdd resource 4 Create Script.StockCurrentSet resource 5 Insert two events Code snippet Name:  POS - Сheck stock of the product Version: POS 2.30 Author: Andrej Svininykh POS - Check stock of the product Add Four variables into evalScript method in JPanelTicket (In JPanelTicket add this line : import com.openbravo.pos.util.AltEncrypter;) Modify the method evalScript  in ScriptObject class inside JPanelTick et . Get user and password of database.  String sDBUser = m_App. getProperties ().getProperty("db.user");  String sDBPassword = m_App. getProperties ().getProperty ("db.password");  if (sDBUser != null && sDBPassword != null && sDBPassword. startsWith ("crypt:" )) {  AltEncrypter cypher = new AltEncrypter ("cypherkey" + sDBUser );  sDBPasswor d = cypher. decrypt(sDBPassword. substring(6));  } Create variable for connecting into the database and getting resources.  script.put("hostname", m_App.getProperties ().getProperty ("machine.hostname" ));  script. put("dbURL", m_App.getProperties().getProperty("db.URL" )); script.put("dbUser", sDBUser);  script. put("dbPassword" , sDBPassword); ll the together looks like:  public Object evalScript (String code, ScriptArg... args) throws ScriptException {  ScriptEngine script = ScriptFactory. getScriptEngine(ScriptFactory. BEANSHELL );  String sDBUser = m_App. getProperties().getProperty ("db.user");  String sDBPassword = m_App. getProperties().getProperty("db.password" );  if (sDBUser != null && sDBPassword != null && sDBPassword. startsWith ("crypt:" )) {  AltEncrypter cypher = new AltEncrypter ("cypherkey" + sDBUser );  sDBPassword = cypher. decrypt(sDBPassword. substring(6));  }  script.put("hostname" , m_App.getProperties().getProperty("machine.hostname" ));  script. put("dbURL", m_App.getProperties ().getProperty ("db.URL")); script.put("dbUser" , sDBUser);  script. put("dbPassword" , sDBPassword);  

POS - Check Stock of the Product - OpenbravoWiki

Embed Size (px)

DESCRIPTION

POS - Check Stock of the ProductOpenBravo POSuniCenta oPOS

Citation preview

  • 9/12/2014 POSCheckstockoftheproductOpenbravoWiki

    http://wiki.openbravo.com/wiki/POS__Check_stock_of_the_product 1/3

    Login/createaccount Openbravo.com PartnerPortal Issues Blogs Forge Exchange University Downloads

    Viewsource| Discussthispage|Pagehistory|Printableversion

    Contents

    1Codesnippet2AddFourvariablesintoevalScriptmethodinJPanelTicket3CreateScript.StockCurrentAddresource4CreateScript.StockCurrentSetresource5Inserttwoevents

    CodesnippetName:POSheckstockoftheproductVersion:POS2.30Author:AndrejSvininykh

    POSCheckstockoftheproduct

    AddFourvariablesintoevalScriptmethodinJPanelTicket(InJPanelTicketaddthisline:importcom.openbravo.pos.util.AltEncrypter)

    ModifythemethodevalScriptinScriptObjectclassinsideJPanelTicket.

    Getuserandpasswordofdatabase.

    StringsDBUser=m_App.getProperties().getProperty("db.user");StringsDBPassword=m_App.getProperties().getProperty("db.password");if(sDBUser!=null&&sDBPassword!=null&&sDBPassword.startsWith("crypt:")){AltEncryptercypher=newAltEncrypter("cypherkey"+sDBUser);sDBPassword=cypher.decrypt(sDBPassword.substring(6));}

    Createvariableforconnectingintothedatabaseandgettingresources.

    script.put("hostname",m_App.getProperties().getProperty("machine.hostname"));script.put("dbURL",m_App.getProperties().getProperty("db.URL"));script.put("dbUser",sDBUser);script.put("dbPassword",sDBPassword);

    Allthetogetherlookslike:

    publicObjectevalScript(Stringcode,ScriptArg...args)throwsScriptException{ScriptEnginescript=ScriptFactory.getScriptEngine(ScriptFactory.BEANSHELL);StringsDBUser=m_App.getProperties().getProperty("db.user");StringsDBPassword=m_App.getProperties().getProperty("db.password");if(sDBUser!=null&&sDBPassword!=null&&sDBPassword.startsWith("crypt:")){AltEncryptercypher=newAltEncrypter("cypherkey"+sDBUser);sDBPassword=cypher.decrypt(sDBPassword.substring(6));}script.put("hostname",m_App.getProperties().getProperty("machine.hostname"));script.put("dbURL",m_App.getProperties().getProperty("db.URL"));script.put("dbUser",sDBUser);script.put("dbPassword",sDBPassword);

  • 9/12/2014 POSCheckstockoftheproductOpenbravoWiki

    http://wiki.openbravo.com/wiki/POS__Check_stock_of_the_product 2/3

    script.put("ticket",ticket);script.put("place",ticketext);script.put("taxes",taxcollection);script.put("taxeslogic",taxeslogic);script.put("user",m_App.getAppUserView().getUser());script.put("sales",this);//moreargumentsfor(ScriptArgarg:args){script.put(arg.getKey(),arg.getValue());}returnscript.eval(code);}

    CreateScript.StockCurrentAddresource

    importcom.openbravo.pos.forms.DataLogicSales;importcom.openbravo.pos.forms.DataLogicSystem;importcom.openbravo.data.loader.Session;importjava.util.Properties;Sessionsession=newSession(dbURL,dbUser,dbPassword);DataLogicSaleslogicsale=newDataLogicSales();logicsale.init(session);DataLogicSystemlogicsystem=newDataLogicSystem();logicsystem.init(session);Propertiesp=logicsystem.getResourceAsProperties(hostname+"/properties");Stringloc=p.getProperty("location");product=line.getProductID();units=logicsale.findProductStock(loc,product,null);multiply=0;for(inti=0;i

  • 9/12/2014 POSCheckstockoftheproductOpenbravoWiki

    http://wiki.openbravo.com/wiki/POS__Check_stock_of_the_product 3/3

    for(inti=0;iTicket.Buttonsandcreatetwonewevents:

    Itisall.

    Retrievedfrom"http://wiki.openbravo.com/wiki/POS__Check_stock_of_the_product"

    Thispagehasbeenaccessed12,817times.Thispagewaslastmodifiedon24July2010,at14:45.ContentisavailableunderCreativeCommonsAttributionShareAlike2.5SpainLicense.

    Categories:Templates|CodeSnippetsPOS