Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.wirabumi.gen.oez.callout;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.text.DecimalFormat;
- import javax.servlet.ServletException;
- import org.openbravo.dal.service.OBDal;
- import org.openbravo.erpCommon.ad_callouts.SimpleCallout;
- import org.openbravo.erpCommon.utility.Utility;
- import org.openbravo.model.common.businesspartner.Category;
- public class GenerateBPSearchKeyCallout extends SimpleCallout {
- @Override
- protected void execute(CalloutInfo info) throws ServletException {
- //get key from sub Category inpmProductCategoryId
- String strClientId = info.getStringParameter("inpadClientId", null);
- //validation bahwa data merupakan supplier
- String bpCategoryID = info.getStringParameter("inpcBpGroupId", null);
- Category bpCategory = OBDal.getInstance().get(Category.class, bpCategoryID);
- String bpCategoryName = bpCategory.getName().toLowerCase();
- String supplierValidation = Utility.getPreference(info.vars, "supplierValidation", null);
- Boolean bpIsSupplierValidation;
- bpIsSupplierValidation = bpCategoryName.contains(supplierValidation);
- //client id Idol Mart
- String ClientIdFromParameter = "0E5A159A4D88441F8B5EEF4A90366669";
- //id client id role match with client id from preference
- if (strClientId.equalsIgnoreCase(ClientIdFromParameter)) {
- if (bpIsSupplierValidation) {
- // get preference
- String bpPrefix = Utility.getPreference(info.vars, "BusinessPartnerPrefix", null);
- String bpSuffix = Utility.getPreference(info.vars, "BusinessPartnerSuffix", null);
- //get increment number
- String sql = " select count(*) as JumlahBP " +
- " from c_bpartner as a " +
- " inner join c_bp_group as b on a.ad_client_id = b.ad_client_id " +
- " where a.ad_client_id=? " +
- " and lower(b.\"name\") like '%supplier%' ";
- java.sql.Connection conn = OBDal.getInstance().getConnection();
- try {
- PreparedStatement ps = conn.prepareStatement(sql);
- ps.setString(1, strClientId);
- ResultSet rs = ps.executeQuery();
- int JumlahBP = 0;
- while (rs.next()) {
- JumlahBP = rs.getInt("JumlahBP");
- }
- JumlahBP++;
- DecimalFormat myFormatter = new DecimalFormat("00000000");
- String strJumlahBPartner = myFormatter.format(JumlahBP);
- String searchKey = bpPrefix+ strJumlahBPartner + bpSuffix;
- info.addResult("inpvalue", searchKey);
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
- else
- {
- return;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement