Upload
danielle-ross
View
15
Download
0
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