tko_pb

ImportProductPurchasing.java

Jul 1st, 2020
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 20.14 KB | None | 0 0
  1. /******************************************************************************
  2.  * Product: Adempiere ERP & CRM Smart Business Solution                       *
  3.  * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved.                *
  4.  * This program is free software; you can redistribute it and/or modify it    *
  5.  * under the terms version 2 of the GNU General Public License as published   *
  6.  * by the Free Software Foundation. This program is distributed in the hope   *
  7.  * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
  8.  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.           *
  9.  * See the GNU General Public License for more details.                       *
  10.  * You should have received a copy of the GNU General Public License along    *
  11.  * with this program; if not, write to the Free Software Foundation, Inc.,    *
  12.  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.                     *
  13.  * For the text or an alternative of this public license, you may reach us    *
  14.  * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA        *
  15.  * or via info@compiere.org or http://www.compiere.org/license.html           *
  16.  *****************************************************************************/
  17. package org.compiere.process;
  18.  
  19. import java.math.BigDecimal;
  20. import java.sql.PreparedStatement;
  21. import java.sql.ResultSet;
  22. import java.sql.SQLException;
  23. import java.sql.Timestamp;
  24. import java.util.logging.Level;
  25.  
  26. import org.adempiere.model.ImportValidator;
  27. import org.adempiere.process.ImportProcess;
  28. import org.compiere.model.MProductPO;
  29. import org.compiere.model.ModelValidationEngine;
  30. import org.compiere.model.Query;
  31. import org.compiere.util.DB;
  32. import org.compiere.util.Env;
  33. import org.kosta.aoi.model.X_I_Product_PO;
  34.  
  35. /**
  36.  *  Import Products from I_Product
  37.  *
  38.  *  @author     Jorg Janke
  39.  *  @version    $Id: ImportProduct.java,v 1.3 2006/07/30 00:51:01 jjanke Exp $
  40.  *
  41.  * @author Carlos Ruiz, globalqss
  42.  *          <li>FR [ 2788278 ] Data Import Validator - migrate core processes
  43.  *              https://sourceforge.net/tracker/?func=detail&aid=2788278&group_id=176962&atid=879335
  44.  */
  45. public class ImportProductPurchasing extends SvrProcess implements ImportProcess
  46. {
  47.     /** Client to be imported to        */
  48.     private int             m_AD_Client_ID = 0;
  49.     /** Delete old Imported             */
  50.     private boolean         m_deleteOldImported = false;
  51.  
  52.     /** Effective                       */
  53.     private Timestamp       m_DateValue = null;
  54.     /** Pricelist to Update             */
  55.     private int             p_M_PriceList_Version_ID = 0;
  56.    
  57.     private int AD_User_ID = 100; // SuperUser
  58.  
  59.     /**
  60.      *  Prepare - e.g., get Parameters.
  61.      */
  62.     protected void prepare()
  63.     {
  64.         ProcessInfoParameter[] para = getParameter();
  65.         for (int i = 0; i < para.length; i++)
  66.         {
  67.             String name = para[i].getParameterName();
  68.             if (name.equals("AD_Client_ID"))
  69.                 m_AD_Client_ID = ((BigDecimal)para[i].getParameter()).intValue();
  70.             else if (name.equals("DeleteOldImported"))
  71.                 m_deleteOldImported = "Y".equals(para[i].getParameter());
  72.             else if (name.equals("M_PriceList_Version_ID"))
  73.                 p_M_PriceList_Version_ID = para[i].getParameterAsInt();
  74.             else
  75.                 log.log(Level.SEVERE, "Unknown Parameter: " + name);
  76.         }
  77.         if (m_DateValue == null)
  78.             m_DateValue = new Timestamp (System.currentTimeMillis());
  79.     }   //  prepare
  80.  
  81.     //  Field to copy From Product if Import does not have value
  82.     private String[] strFieldsToCopy = new String[] {
  83.             "Value",
  84.             "Name",
  85.             "Description",
  86.             "DocumentNote",
  87.             "Help",
  88.             "UPC",
  89.             "SKU",
  90.             "Classification",
  91.             "ProductType",
  92.             "Discontinued",
  93.             "DiscontinuedBy",
  94.             "DiscontinuedAt",
  95.             "ImageURL",
  96.             "DescriptionURL"
  97.         };
  98.  
  99.     /**
  100.      *  Perform process.
  101.      *  @return Message
  102.      *  @throws Exception
  103.      */
  104.     protected String doIt() throws java.lang.Exception
  105.     {
  106.         StringBuilder sql = null;
  107.  
  108.         AD_User_ID = Env.getAD_User_ID(getCtx());
  109.        
  110.         int no = 0;
  111.         String clientCheck = getWhereClause();
  112.        
  113.  
  114.         //  ****    Prepare ****
  115.  
  116.         //  Delete Old Imported
  117.         if (m_deleteOldImported)
  118.         {
  119.             sql = new StringBuilder ("DELETE I_Product_PO ")
  120.                 .append("WHERE I_IsImported='Y'").append(clientCheck);
  121.             no = DB.executeUpdate(sql.toString(), get_TrxName());
  122.             if (log.isLoggable(Level.INFO)) log.info("Delete Old Imported =" + no);
  123.         }
  124.  
  125.         //  Set Client, Org, IaActive, Created/Updated,     ProductType
  126.         sql = new StringBuilder ("UPDATE I_Product_PO ")
  127.             .append("SET AD_Client_ID = COALESCE (AD_Client_ID, ").append(m_AD_Client_ID).append("),")
  128.             .append(" AD_Org_ID = COALESCE (AD_Org_ID, 0),")
  129.             .append(" IsActive = COALESCE (IsActive, 'Y'),")
  130.             .append(" Created = COALESCE (Created, SysDate),")
  131.             .append(" CreatedBy = COALESCE (CreatedBy, 0),")
  132.             .append(" Updated = COALESCE (Updated, SysDate),")
  133.             .append(" UpdatedBy = COALESCE (UpdatedBy, 0),")
  134.             //.append(" ProductType = COALESCE (ProductType, 'I'),")
  135.             .append(" I_ErrorMsg = ' ',")
  136.             .append(" I_IsImported = 'N' ")
  137.             .append("WHERE I_IsImported<>'Y' OR I_IsImported IS NULL");
  138.         no = DB.executeUpdate(sql.toString(), get_TrxName());
  139.         if (log.isLoggable(Level.INFO)) log.info("Reset=" + no);
  140.  
  141.         ModelValidationEngine.get().fireImportValidate(this, null, null, ImportValidator.TIMING_BEFORE_VALIDATE);
  142.    
  143.        
  144.         sql = new StringBuilder ("UPDATE I_Product_PO ")
  145.         .append("SET I_IsImported='N', I_ErrorMsg=I_ErrorMsg||'ERR=Product, BP dan Promised Delivery Time harus diisi,' ")
  146.         .append("WHERE product IS NULL OR C_Bpartnername IS NULL OR deliverytime_promised IS NULL")
  147.         .append(" AND I_IsImported<>'Y'").append(clientCheck);
  148.         no = DB.executeUpdate(sql.toString(), get_TrxName());
  149.         if (no != 0)
  150.             log.warning("Invalid Mandatory Field =" + no);
  151.        
  152.         //  Value
  153.         sql = new StringBuilder ("UPDATE I_Product_PO i ")
  154.             .append("SET M_Product_ID=(SELECT M_Product_ID FROM M_Product p")
  155.             .append(" WHERE i.product=p.Value AND i.AD_Client_ID=p.AD_Client_ID) ")
  156.             .append("WHERE M_Product_ID IS NULL AND product IS NOT NULL")
  157.             .append(" AND I_IsImported='N'").append(clientCheck);
  158.         no = DB.executeUpdate(sql.toString(), get_TrxName());
  159.         if (log.isLoggable(Level.INFO)) log.info("Product Existing Value=" + no);
  160.        
  161.         sql = new StringBuilder ("UPDATE I_Product_PO ")
  162.         .append("SET I_IsImported='N', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Product,' ")
  163.         .append("WHERE M_Product_ID IS NULL AND product IS NOT NULL")
  164.         .append(" AND I_IsImported<>'Y'").append(clientCheck);
  165.         no = DB.executeUpdate(sql.toString(), get_TrxName());
  166.         if (no != 0)
  167.             log.warning("Invalid Product =" + no);
  168.        
  169.         // set UOM
  170.         sql = new StringBuilder ("UPDATE I_Product_PO i ")
  171.             .append("SET C_UOM_ID=(SELECT C_UOM_ID FROM C_UOM p")
  172.             .append(" WHERE i.uom=p.Name AND i.AD_Client_ID IN (0,p.AD_Client_ID)) ")
  173.             .append("WHERE C_UOM_ID IS NULL AND uom IS NOT NULL")
  174.             .append(" AND I_IsImported<>'Y'").append(clientCheck);
  175.             no = DB.executeUpdate(sql.toString(), get_TrxName());
  176.             if (log.isLoggable(Level.INFO)) log.info("UOM=" + no);
  177.             //
  178.         sql = new StringBuilder ("UPDATE I_Product_PO ")
  179.             .append("SET I_IsImported='N', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid UOM,' ")
  180.             .append("WHERE C_UOM_ID IS NULL AND uom IS NOT NULL")
  181.             .append(" AND I_IsImported<>'Y'").append(clientCheck);
  182.         no = DB.executeUpdate(sql.toString(), get_TrxName());
  183.         if (no != 0)
  184.             log.warning("Invalid UOM=" + no);
  185.            
  186.         sql = new StringBuilder ("UPDATE I_Product_PO i ")
  187.             .append("SET I_IsImported='N', I_ErrorMsg=I_ErrorMsg||'ERR=UOM tidak ada di dalam product,' ")
  188.             .append("WHERE C_UOM_ID IS NOT NULL AND C_UOM_ID NOT IN ")
  189.             .append("(SELECT DISTINCT C_UOM_ID FROM C_UOM_Conversion where M_PRODUCT_ID = i.M_Product_ID ")
  190.             .append("UNION ")
  191.             .append("SELECT DISTINCT C_UOM_TO_ID FROM C_UOM_Conversion where M_PRODUCT_ID = i.M_Product_ID ")
  192.             .append("UNION ")
  193.             .append("SELECT C_UOM_ID FROM M_PRODUCT WHERE M_PRODUCT_ID = i.M_Product_ID) ")
  194.             .append(" AND I_IsImported<>'Y'").append(clientCheck);
  195.         no = DB.executeUpdate(sql.toString(), get_TrxName());
  196.         if (no != 0)
  197.             log.warning("Invalid UOM=" + no);
  198.        
  199.        
  200.         //  Set BPartner
  201.         sql = new StringBuilder ("UPDATE I_Product_PO i ")
  202.             .append("SET C_BPartner_ID=(SELECT C_BPartner_ID FROM C_BPartner p")
  203.             .append(" WHERE i.C_BPartnerName=p.value AND i.AD_Client_ID=p.AD_Client_ID) ")
  204.             .append("WHERE C_BPartner_ID IS NULL AND C_BPartnerName IS NOT NULL ")
  205.             .append(" AND I_IsImported<>'Y'").append(clientCheck);
  206.         no = DB.executeUpdate(sql.toString(), get_TrxName());
  207.         if (log.isLoggable(Level.INFO)) log.info("BPartner=" + no);
  208.        
  209.         sql = new StringBuilder ("UPDATE I_Product_PO ")
  210.         .append("SET I_IsImported='N', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid BPartner,' ")
  211.         .append("WHERE C_BPartner_ID IS NULL AND C_BPartnerName IS NOT NULL")
  212.         .append(" AND I_IsImported<>'Y'").append(clientCheck);
  213.         no = DB.executeUpdate(sql.toString(), get_TrxName());
  214.         if (no != 0)
  215.             log.warning("Invalid BPartner=" + no);
  216.    
  217.        
  218.         sql = new StringBuilder ("UPDATE I_Product_PO i ")
  219.         .append("SET C_Currency_ID=(SELECT C_Currency_ID FROM C_Currency c")
  220.         .append(" WHERE i.Currency=c.ISO_Code AND c.AD_Client_ID IN (0,i.AD_Client_ID)) ")
  221.         .append("WHERE C_Currency_ID IS NULL AND Currency IS NOT NULL")
  222.         .append(" AND I_IsImported<>'Y'").append(clientCheck);
  223.         no = DB.executeUpdate(sql.toString(), get_TrxName());
  224.             if (log.isLoggable(Level.INFO)) log.info("doIt- Set Currency=" + no);
  225.     //
  226.         sql = new StringBuilder ("UPDATE I_Product_PO ")
  227.         .append("SET I_IsImported='N', I_ErrorMsg=I_ErrorMsg||'ERR=Currency,' ")
  228.         .append("WHERE C_Currency_ID IS NULL AND Currency IS NOT NULL")
  229.         .append(" AND I_IsImported<>'Y'").append(clientCheck);
  230.         no = DB.executeUpdate(sql.toString(), get_TrxName());
  231.         if (no != 0)
  232.             log.warning("Invalid Currency=" + no);
  233.    
  234.        
  235.  
  236.         ModelValidationEngine.get().fireImportValidate(this, null, null, ImportValidator.TIMING_AFTER_VALIDATE);
  237.  
  238.         commitEx();
  239.        
  240.         //  -------------------------------------------------------------------
  241.         //int noInsert = 0;
  242.         //int noUpdate = 0;
  243.         int noInsertPO = 0;
  244.         int noUpdatePO = 0;
  245.  
  246.         //  Go through Records
  247.         log.fine("start inserting/updating ...");
  248.         sql = new StringBuilder ("SELECT * FROM I_Product_PO WHERE I_IsImported='N' AND I_ErrorMsg=' ' ")
  249.             .append(clientCheck);
  250.         PreparedStatement pstmt = null;
  251.         ResultSet rs = null;
  252.         PreparedStatement pstmt_insertProductPO = null;
  253.         try
  254.         {
  255.             pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
  256.             rs = pstmt.executeQuery();
  257.             while (rs.next())
  258.             {
  259.                 X_I_Product_PO imp = new X_I_Product_PO(getCtx(), rs, get_TrxName());
  260.                
  261.                 int M_Product_ID = imp.getM_Product_ID();
  262.                 int C_BPartner_ID = imp.getC_BPartner_ID();
  263.                
  264.                 String where = "M_Product_ID = "+ M_Product_ID+" AND C_BPartner_ID = "+C_BPartner_ID;
  265.                 MProductPO mpo = new Query(getCtx(),MProductPO.Table_Name, where, get_TrxName()).first();
  266.                 boolean newProduct = mpo==null;
  267.                
  268.                 if (log.isLoggable(Level.FINE)) log.fine("M_Product_ID=" + M_Product_ID
  269.                     + ", C_BPartner_ID=" + C_BPartner_ID);
  270.  
  271.                 //  Product
  272.                 if (newProduct)         //  Insert new Product
  273.                 {
  274.  
  275.                     pstmt_insertProductPO = DB.prepareStatement
  276.                             ("INSERT INTO M_Product_PO (M_Product_ID,C_BPartner_ID, "
  277.                             + "AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,"
  278.                             + "IsCurrentVendor,C_UOM_ID,C_Currency_ID,UPC,"
  279.                             + "PriceList,PricePO,RoyaltyAmt,PriceEffective,"
  280.                             + "VendorProductNo,VendorCategory,Manufacturer,"
  281.                             + "Discontinued, DiscontinuedAt, Order_Min,Order_Pack,"
  282.                             + "CostPerOrder,DeliveryTime_Promised) "
  283.                             + "SELECT M_Product_ID,C_Bpartner_ID, "
  284.                             + "AD_Client_ID,AD_Org_ID,'Y',SysDate,CreatedBy,SysDate,UpdatedBy,"
  285.                             + "IsCurrentVendor,COALESCE(C_UOM_ID,(SELECT C_UOM_ID FROM M_PRODUCT WHERE M_Product_ID = ?))"
  286.                             + ",COALESCE(C_Currency_ID,(SELECT C_Currency_ID FROM C_BPartner WHERE C_BPartner_ID = ?))"
  287.                             + ",UPC,"
  288.                             + "PriceList,PricePO,RoyaltyAmt,PriceEffective,"
  289.                             + "COALESCE(VendorProductNo,'-'),VendorCategory,Manufacturer,"
  290.                             + "Discontinued,DiscontinuedAt, Order_Min,Order_Pack,"
  291.                             + "CostPerOrder,DeliveryTime_Promised "
  292.                             + "FROM I_Product_PO "
  293.                             + "WHERE M_Product_ID=? AND C_BPartner_ID = ?", get_TrxName());
  294.                    
  295.                     pstmt_insertProductPO.setInt(1, M_Product_ID);
  296.                     pstmt_insertProductPO.setInt(2, C_BPartner_ID);
  297.                     pstmt_insertProductPO.setInt(3, M_Product_ID);
  298.                     pstmt_insertProductPO.setInt(4, C_BPartner_ID);
  299.                    
  300.                     try
  301.                     {
  302.                         no = pstmt_insertProductPO.executeUpdate();
  303.                         if (log.isLoggable(Level.FINER)) log.finer("Insert Product_PO = " + no);
  304.                         noInsertPO++;
  305.                         imp.setProcessed(true);
  306.                         imp.setI_IsImported(true);
  307.                         imp.save();
  308.                     }
  309.                     catch (SQLException ex)
  310.                     {
  311.                         log.warning("Insert Product_PO - " + ex.toString());
  312.                         //noInsert--;           //  assume that product also did not exist
  313.                         rollback();
  314.                         StringBuilder sql0 = new StringBuilder ("UPDATE I_Product_PO i ")
  315.                             .append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||").append(DB.TO_STRING("Insert Product_PO: " + ex.toString()))
  316.                             .append("WHERE M_Product_ID=").append(M_Product_ID)
  317.                             .append(" AND C_BPartner_ID =").append(C_BPartner_ID);
  318.                         DB.executeUpdate(sql0.toString(), get_TrxName());
  319.                         continue;
  320.                     }
  321.                    
  322.                 }
  323.                 else                    //  Update Product
  324.                 {
  325.                     //mpo.set_ValueOfColumn("IsCurrentVendor",imp.get_ValueAsBoolean("IsCurrentVendor"));
  326.                     if(imp.get_ValueAsInt("C_UOM_ID")>0)
  327.                         mpo.set_ValueOfColumn("C_UOM_ID",imp.get_ValueAsInt("C_UOM_ID"));
  328.                     if(imp.get_ValueAsInt("C_Currency_ID")>0)
  329.                         mpo.set_ValueOfColumn("C_Currency_ID",imp.get_ValueAsInt("C_Currency_ID"));
  330.                    
  331.                     //mpo.set_ValueOfColumn("UPC",imp.get_Value("UPC"));
  332.                     //mpo.set_ValueOfColumn("PriceList",imp.get_Value("PriceList"));
  333.                     //mpo.set_ValueOfColumn("PricePO",imp.get_Value("PricePO"));
  334.                     //mpo.set_ValueOfColumn("RoyaltyAmt",imp.get_Value("RoyaltyAmt"));
  335.                     //mpo.set_ValueOfColumn("PriceEffective",imp.get_Value("PriceEffective"));
  336.                     if(imp.get_Value("VendorProductNo")!=null)
  337.                         mpo.set_ValueOfColumn("VendorProductNo",imp.get_Value("VendorProductNo"));
  338.                     //mpo.set_ValueOfColumn("Manufacturer",imp.get_Value("Manufacturer"));
  339.                     //mpo.set_ValueOfColumn("Discontinued",imp.get_Value("Discontinued"));
  340.                     if(imp.get_Value("Order_Min")!=null)
  341.                         mpo.set_ValueOfColumn("Order_Min",imp.get_Value("Order_Min"));
  342.                     //mpo.set_ValueOfColumn("Order_Pack",imp.get_Value("Order_Pack"));
  343.                     //mpo.set_ValueOfColumn("CostPerOrder",imp.get_Value("CostPerOrder"));
  344.                     mpo.set_ValueOfColumn("DeliveryTime_Promised",imp.get_Value("DeliveryTime_Promised"));
  345.                     mpo.saveEx();
  346.                     imp.setProcessed(true);
  347.                     imp.setI_IsImported(true);
  348.                     imp.saveEx();
  349.                     noUpdatePO++;
  350.                    
  351.                     /*
  352.                     pstmt_insertProductPO = DB.prepareStatement
  353.                             ("UPDATE M_Product_PO SET (M_Product_ID,C_BPartner_ID, "
  354.                             + "AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,"
  355.                             + "IsCurrentVendor,C_UOM_ID,C_Currency_ID,UPC,"
  356.                             + "PriceList,PricePO,RoyaltyAmt,PriceEffective,"
  357.                             + "VendorProductNo,VendorCategory,Manufacturer,"
  358.                             + "Discontinued, DiscontinuedAt, Order_Min,Order_Pack,"
  359.                             + "CostPerOrder,DeliveryTime_Promised) = "
  360.                             + "SELECT M_Product_ID,C_Bpartner_ID, "
  361.                             + "AD_Client_ID,AD_Org_ID,IsActive,SysDate,CreatedBy,SysDate,UpdatedBy,"
  362.                             + "IsCurrentVendor,C_UOM_ID,C_Currency_ID,UPC," // get currentVendor from column. modified by @ZuhriUtama
  363.                             + "PriceList,PricePO,RoyaltyAmt,PriceEffective,"
  364.                             + "VendorProductNo,VendorCategory,Manufacturer,"
  365.                             + "Discontinued,DiscontinuedAt, Order_Min,Order_Pack,"
  366.                             + "CostPerOrder,DeliveryTime_Promised "
  367.                             + "FROM I_Product_PO "
  368.                             + "WHERE M_Product_ID=? AND C_BPartner_ID = ?", get_TrxName());
  369.                    
  370.                     pstmt_insertProductPO.setInt(1, M_Product_ID);
  371.                     pstmt_insertProductPO.setInt(2, C_BPartner_ID);
  372.                    
  373.                     try
  374.                     {
  375.                         no = pstmt_insertProductPO.executeUpdate();
  376.                         if (log.isLoggable(Level.FINER)) log.finer("Insert Product_PO = " + no);
  377.                         noUpdatePO++;
  378.                         imp.setProcessed(true);
  379.                         imp.setI_IsImported(true);
  380.                         imp.save();
  381.                     }
  382.                     catch (SQLException ex)
  383.                     {
  384.                         log.warning("Update Product_PO - " + ex.toString());
  385.                         noUpdatePO--;           //  assume that product also did not exist
  386.                         rollback();
  387.                         StringBuilder sql0 = new StringBuilder ("UPDATE I_Product_PO i ")
  388.                             .append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||").append(DB.TO_STRING("Insert Product_PO: " + ex.toString()))
  389.                             .append("WHERE M_Product_ID=").append(M_Product_ID)
  390.                             .append(" AND C_BPartner_ID =").append(C_BPartner_ID);
  391.                         DB.executeUpdate(sql0.toString(), get_TrxName());
  392.                         continue;
  393.                     }*/
  394.                    
  395.                 }
  396.                
  397.                 commitEx();
  398.             }   //  for all I_Product
  399.         }
  400.         catch (SQLException e)
  401.         {
  402.         }
  403.         finally
  404.         {
  405.             DB.close(rs, pstmt);
  406.             rs = null;pstmt = null;
  407.             DB.close(pstmt_insertProductPO);
  408.             pstmt_insertProductPO = null;
  409.         }
  410.  
  411.         //  Set Error to indicator to not imported
  412.         sql = new StringBuilder ("UPDATE I_Product_PO ")
  413.             .append("SET I_IsImported='N', Updated=SysDate ")
  414.             .append("WHERE I_IsImported<>'Y'").append(clientCheck);
  415.         no = DB.executeUpdate(sql.toString(), get_TrxName());
  416.         addLog (0, null, new BigDecimal (no), "@Errors@");
  417. //      addLog (0, null, new BigDecimal (noInsert), "@M_Product_ID@: @Inserted@");
  418. //      addLog (0, null, new BigDecimal (noUpdate), "@M_Product_ID@: @Updated@");
  419.         addLog (0, null, new BigDecimal (noInsertPO), "@M_Product_ID@ @Purchase@: @Inserted@");
  420.         addLog (0, null, new BigDecimal (noUpdatePO), "@M_Product_ID@ @Purchase@: @Updated@");
  421.         return "";
  422.     }   //  doIt
  423.  
  424. //
  425. //  private void setProductName(X_I_Product imp) {
  426. //      Properties ctx = getCtx();
  427. //     
  428. //      MProductCategory prodCat = new MProductCategory(ctx, imp.getM_Product_Category_ID(), null);
  429. //      boolean isFG = prodCat.get_ValueAsBoolean("isFGkst");
  430. //      boolean isWIP = prodCat.get_ValueAsBoolean("isWIPkst");
  431. //     
  432. //      String upc = imp.getUPC();
  433. //     
  434. //      String colorKey = "0";
  435. //      String colorName = "";
  436. //      if(imp.get_ValueAsInt("kst_ColorDetails_ID")>0){
  437. //          X_kst_ColorDetails colorDetails = new X_kst_ColorDetails(ctx, imp.get_ValueAsInt("kst_ColorDetails_ID"), null);
  438. //          colorKey = colorDetails.get_ValueAsString("value");
  439. //          colorName = colorDetails.get_ValueAsString("name");
  440. //      }
  441. //     
  442. //      String sourceSizeKey = "0";
  443. //      String sourceSizeName = "";
  444. //      if(imp.get_ValueAsInt("KST_SourceSize_ID")>0){
  445. //          X_kst_SourceSize sourceSize = new X_kst_SourceSize(ctx, imp.get_ValueAsInt("KST_SourceSize_ID"), null);
  446. //          sourceSizeKey = sourceSize.get_ValueAsString("value");
  447. //          sourceSizeName = sourceSize.get_ValueAsString("name");
  448. //      }
  449. //     
  450. //      String widthKey = "0";
  451. //      String widthName = "";
  452. //      if(imp.get_ValueAsInt("KST_Width_ID")>0){
  453. //          X_kst_width width = new X_kst_width(ctx, imp.get_ValueAsInt("KST_Width_ID"), null);
  454. //          widthKey = width.get_ValueAsString("value");
  455. //          widthName = width.get_ValueAsString("name");
  456. //      }
  457. //     
  458. //      String season = imp.get_ValueAsString("kst_Season");
  459. //      String articleNo = imp.get_ValueAsString("kst_ArticleNo");
  460. //     
  461. //      String productCode = "";
  462. //     
  463. //      //  kode FG kst_Season-UPC-kst_ArticleNo-kst_sourcesize
  464. //      if(isFG)
  465. //          productCode = season+"-"+upc+"-"+articleNo+"-"+sourceSizeKey;
  466. //      else if(isWIP)
  467. //          productCode = "WIP-"+season+"-"+upc+"-"+articleNo+"-"+sourceSizeKey;
  468. //      // kode material UPC-Color Detail-Width
  469. //      else
  470. //          productCode = upc+"-"+colorKey+"-"+widthKey;
  471. //     
  472. //      //if(imp.getValue()==null || imp.getValue().equals(""))
  473. //          imp.setValue(productCode);
  474. //     
  475. //      // set name
  476. //      String name = imp.get_ValueAsString("kst_Name");
  477. //      if(isFG || isWIP)
  478. //          name += " " + articleNo + " " + sourceSizeName;
  479. //      else
  480. //          name += " " + colorName + " " + widthName;
  481. //     
  482. //      //if(imp.getName()==null || imp.getName().equals(""))
  483. //          imp.setName(name);
  484. //     
  485. //      imp.saveEx();
  486. //  }
  487.  
  488.  
  489.     @Override
  490.     public String getImportTableName() {
  491.         return X_I_Product_PO.Table_Name;
  492.     }
  493.  
  494.  
  495.     @Override
  496.     public String getWhereClause() {
  497.         StringBuilder msgreturn = new StringBuilder(" AND AD_Client_ID=").append(m_AD_Client_ID)
  498.                 .append(" AND CreatedBy = ").append(AD_User_ID);
  499.         return msgreturn.toString();
  500.     }
  501.  
  502. }   //  ImportProduct
Add Comment
Please, Sign In to add comment