Search in sources :

Example 1 with MAcctSchemaElement

use of org.compiere.model.MAcctSchemaElement in project adempiere by adempiere.

the class ImportBudget method fillIdValues.

/**
     * Fill Id Values
     * @param importBudget
     * @param acctSchemaElements
     * @param trxName
     */
private void fillIdValues(X_I_Budget importBudget, MAcctSchemaElement[] acctSchemaElements, String trxName) {
    StringBuffer stringError = new StringBuffer("");
    // Set Organization
    Integer orgId = 0;
    if (importBudget.getAD_Org_ID() > 0)
        orgId = importBudget.getAD_Org_ID();
    if (orgId <= 0 && importBudget.getOrgValue() != null)
        orgId = getId(MOrg.Table_Name, MOrg.COLUMNNAME_Value + "=?", trxName, importBudget.getOrgValue());
    if (orgId > 0 && importBudget.getAD_Org_ID() <= 0)
        importBudget.setAD_Org_ID(orgId);
    if (importBudget.getAD_Org_ID() <= 0 && importBudget.getOrgValue() != null)
        stringError.append("@AD_Org_ID@ @NotFound@ ");
    // Set Organization Trx
    Integer orgTrxId = 0;
    if (importBudget.getAD_OrgTrx_ID() > 0)
        orgTrxId = importBudget.getAD_OrgTrx_ID();
    if (orgTrxId <= 0 && importBudget.getOrgTrxValue() != null)
        orgTrxId = getId(MOrg.Table_Name, MOrg.COLUMNNAME_Value + "=?", trxName, importBudget.getOrgTrxValue());
    if (orgTrxId > 0 && importBudget.getAD_OrgTrx_ID() <= 0)
        importBudget.setAD_OrgTrx_ID(orgTrxId);
    if (importBudget.getAD_Org_ID() <= 0 && importBudget.getOrgTrxValue() != null)
        stringError.append("@AD_OrgTrx_ID@ @NotFound@ ");
    // Set Account Schema
    Integer accountSchemaId = 0;
    if (importBudget.getC_AcctSchema_ID() > 0)
        accountSchemaId = importBudget.getC_AcctSchema_ID();
    if (accountSchemaId <= 0 && importBudget.getAcctSchemaName() != null)
        accountSchemaId = getId(MAcctSchema.Table_Name, MAcctSchema.COLUMNNAME_Name + "=?", trxName, importBudget.getAcctSchemaName());
    if (accountSchemaId > 0 && importBudget.getC_AcctSchema_ID() <= 0)
        importBudget.setC_AcctSchema_ID(accountSchemaId);
    else {
        accountSchemaId = getAccountingSchemaId();
        importBudget.setC_AcctSchema_ID(accountSchemaId);
    }
    // Set Budget
    Integer budgetId = 0;
    if (importBudget.getGL_Budget_ID() > 0)
        budgetId = importBudget.getGL_Budget_ID();
    if (budgetId <= 0 && importBudget.getBudgetCode() != null)
        budgetId = getId(X_GL_Budget.Table_Name, X_GL_Budget.COLUMNNAME_Name + "=?", trxName, importBudget.getBudgetCode());
    if (budgetId > 0 && importBudget.getGL_Budget_ID() <= 0)
        importBudget.setGL_Budget_ID(budgetId);
    if (importBudget.getGL_Budget_ID() <= 0 && importBudget.getBudgetCode() != null)
        stringError.append("@GL_Budget_ID@ @NotFound@ ");
    // Set Asset
    Integer assetId = 0;
    if (importBudget.getA_Asset_ID() > 0)
        assetId = importBudget.getA_Asset_ID();
    if (assetId <= 0 && importBudget.getAssetValue() != null)
        assetId = getId(X_A_Asset.Table_Name, X_A_Asset.COLUMNNAME_Value + "=?", trxName, importBudget.getAssetValue());
    if (assetId > 0 && importBudget.getA_Asset_ID() <= 0)
        importBudget.setA_Asset_ID(assetId);
    if (importBudget.getA_Asset_ID() <= 0 && importBudget.getAssetValue() != null)
        stringError.append("@A_Asset_ID@ @NotFound@ ");
    // Set Account
    int accountId = 0;
    if (importBudget.getAccount_ID() > 0)
        accountId = importBudget.getAccount_ID();
    if (accountId <= 0 && importBudget.getAccountValue() != null)
        accountId = getId(MElementValue.Table_Name, MElementValue.COLUMNNAME_Value + "=?", trxName, importBudget.getAccountValue());
    if (accountId > 0 && importBudget.getAccount_ID() <= 0)
        importBudget.setAccount_ID(accountId);
    if (importBudget.getAccount_ID() <= 0 && importBudget.getAccountValue() != null)
        stringError.append("@Account_ID@ @NotFound@ ");
    int partnerId = 0;
    if (importBudget.getC_BPartner_ID() > 0)
        partnerId = importBudget.getC_BPartner_ID();
    if (partnerId <= 0 && importBudget.getBPartnerValue() != null) {
        MBPartner partner = MBPartner.get(getCtx(), importBudget.getBPartnerValue());
        if (partner != null)
            partnerId = partner.getC_BPartner_ID();
    }
    if (partnerId > 0 && importBudget.getC_BPartner_ID() <= 0)
        importBudget.setC_BPartner_ID(partnerId);
    if (importBudget.getC_BPartner_ID() <= 0 && importBudget.getBPartnerValue() != null)
        stringError.append("@C_BPartner_ID@ @NotFound@ ");
    // Set Product
    Integer productId = 0;
    if (importBudget.getM_Product_ID() > 0)
        productId = importBudget.getM_Product_ID();
    if (productId <= 0 && importBudget.getProductValue() != null)
        productId = getId(MProduct.Table_Name, MProduct.COLUMNNAME_Value + "=?", trxName, importBudget.getProductValue());
    if (productId > 0 && importBudget.getM_Product_ID() <= 0)
        importBudget.setM_Product_ID(productId);
    if (importBudget.getM_Product_ID() <= 0 && importBudget.getProductValue() != null)
        stringError.append("@M_Product_ID@ @NotFound@ ");
    // Set Project
    Integer projectId = 0;
    if (importBudget.getC_Project_ID() > 0)
        projectId = importBudget.getC_Project_ID();
    if (projectId <= 0 && importBudget.getProjectValue() != null)
        projectId = getId(MProject.Table_Name, MProject.COLUMNNAME_Value + "=?", trxName, importBudget.getProjectValue());
    if (projectId > 0 && importBudget.getC_Project_ID() <= 0)
        importBudget.setC_Project_ID(projectId);
    if (importBudget.getC_Project_ID() <= 0 && importBudget.getProjectValue() != null)
        stringError.append("@C_Project_ID@ @NotFound@ ");
    // Set Campaign
    Integer campaignId = 0;
    if (importBudget.getC_Campaign_ID() > 0)
        campaignId = importBudget.getC_Campaign_ID();
    if (campaignId <= 0 && importBudget.getCampaignValue() != null)
        campaignId = getId(MCampaign.Table_Name, MCampaign.COLUMNNAME_Value + "=?", trxName, importBudget.getCampaignValue());
    if (campaignId > 0 && importBudget.getC_Campaign_ID() <= 0)
        importBudget.setC_Campaign_ID(campaignId);
    if (importBudget.getC_Campaign_ID() <= 0 && importBudget.getCampaignValue() != null)
        stringError.append("@C_Campaign_ID@ @NotFound@ ");
    // Set Sales Region
    Integer salesRegionId = 0;
    if (importBudget.getC_SalesRegion_ID() > 0)
        salesRegionId = importBudget.getC_SalesRegion_ID();
    if (salesRegionId <= 0 && importBudget.getSalesRegionValue() != null)
        salesRegionId = getId(MSalesRegion.Table_Name, MSalesRegion.COLUMNNAME_Value + "=?", trxName, importBudget.getSalesRegionValue());
    if (salesRegionId > 0 && importBudget.getC_SalesRegion_ID() <= 0)
        importBudget.setC_SalesRegion_ID(salesRegionId);
    if (importBudget.getC_SalesRegion_ID() <= 0 && importBudget.getSalesRegionValue() != null)
        stringError.append("@C_SalesRegion_ID@ @NotFound@");
    // Set Activity Id
    Integer activityId = 0;
    if (importBudget.getC_Activity_ID() > 0)
        activityId = importBudget.getC_Activity_ID();
    if (activityId <= 0 && importBudget.getActivityValue() != null)
        activityId = getId(MActivity.Table_Name, MActivity.COLUMNNAME_Value + "=?", trxName, importBudget.getActivityValue());
    if (accountId > 0 && importBudget.getC_Activity_ID() <= 0)
        importBudget.setC_Activity_ID(activityId);
    if (importBudget.getC_Activity_ID() <= 0 && importBudget.getActivityValue() != null)
        stringError.append("@C_SalesRegion_ID@ @NotFound@ ");
    // Set Sub Acct Id
    Integer subAcctountId = 0;
    if (importBudget.getC_SubAcct_ID() > 0)
        subAcctountId = importBudget.getC_SubAcct_ID();
    if (subAcctountId <= 0 && importBudget.getSubAcctValue() != null)
        subAcctountId = getId(X_C_SubAcct.Table_Name, X_C_SubAcct.COLUMNNAME_Value + "=?", trxName, importBudget.getSubAcctValue());
    if (subAcctountId > 0 && importBudget.getC_SubAcct_ID() <= 0)
        importBudget.setC_SubAcct_ID(subAcctountId);
    if (importBudget.getC_SubAcct_ID() <= 0 && importBudget.getSubAcctValue() != null)
        stringError.append("@C_SubAcct_ID@ @NotFound@ ");
    // Set User 1
    Integer user1Id = 0;
    if (importBudget.getUser1_ID() > 0)
        user1Id = importBudget.getUser1_ID();
    if (user1Id <= 0 && importBudget.getUser1_ID() <= 0 && importBudget.getUserValue1() != null) {
        Arrays.stream(acctSchemaElements).filter(acctSchemaElement -> MAcctSchemaElement.ELEMENTTYPE_UserList1.equals(acctSchemaElement.getElementType())).forEach(acctSchemaElement -> {
            String where = MElementValue.COLUMNNAME_C_Element_ID + "=? AND " + MElementValue.COLUMNNAME_Value + "=?";
            importBudget.setUser1_ID(getId(MElementValue.Table_Name, where, trxName, acctSchemaElement.getC_Element_ID(), importBudget.getUserValue1()));
        });
    }
    if (importBudget.getUser1_ID() <= 0 && importBudget.getUserValue1() != null)
        stringError.append("@User1_ID@ @NotFound@ ");
    // User 2
    Integer user2Id = 0;
    if (importBudget.getUser2_ID() > 0)
        user2Id = importBudget.getUser2_ID();
    if (user2Id <= 0 && importBudget.getUser2_ID() <= 0 && importBudget.getUserValue2() != null) {
        Arrays.stream(acctSchemaElements).filter(acctSchemaElement -> MAcctSchemaElement.ELEMENTTYPE_UserList2.equals(acctSchemaElement.getElementType())).forEach(acctSchemaElement -> {
            String where = MElementValue.COLUMNNAME_C_Element_ID + "=? AND " + MElementValue.COLUMNNAME_Value + "=?";
            importBudget.setUser2_ID(getId(MElementValue.Table_Name, where, trxName, acctSchemaElement.getC_Element_ID(), importBudget.getUserValue2()));
        });
    }
    if (importBudget.getUser2_ID() <= 0 && importBudget.getUserValue2() != null)
        stringError.append("@User2_ID@ @NotFound@ ");
    Integer user3Id = 0;
    if (importBudget.getUser3_ID() > 0)
        user3Id = importBudget.getUser3_ID();
    if (user3Id <= 0 && importBudget.getUser3_ID() <= 0 && importBudget.getUserValue3() != null) {
        Arrays.stream(acctSchemaElements).filter(acctSchemaElement -> MAcctSchemaElement.ELEMENTTYPE_UserList3.equals(acctSchemaElement.getElementType())).forEach(acctSchemaElement -> {
            String where = MElementValue.COLUMNNAME_C_Element_ID + "=? AND " + MElementValue.COLUMNNAME_Value + "=?";
            importBudget.setUser3_ID(getId(MElementValue.Table_Name, where, trxName, acctSchemaElement.getC_Element_ID(), importBudget.getUserValue3()));
        });
    }
    if (importBudget.getUser3_ID() <= 0 && importBudget.getUserValue3() != null)
        stringError.append("@User3_ID@ @NotFound@ ");
    Integer user4Id = 0;
    if (importBudget.getUser4_ID() > 0)
        user4Id = importBudget.getUser4_ID();
    if (user4Id <= 0 && importBudget.getUser4_ID() <= 0 && importBudget.getUserValue4() != null) {
        Arrays.stream(acctSchemaElements).filter(acctSchemaElement -> MAcctSchemaElement.ELEMENTTYPE_UserList4.equals(acctSchemaElement.getElementType())).forEach(acctSchemaElement -> {
            String where = MElementValue.COLUMNNAME_C_Element_ID + "=? AND " + MElementValue.COLUMNNAME_Value + "=?";
            importBudget.setUser4_ID(getId(MElementValue.Table_Name, where, trxName, acctSchemaElement.getC_Element_ID(), importBudget.getUserValue4()));
        });
    }
    if (importBudget.getUser4_ID() <= 0 && importBudget.getUserValue4() != null)
        stringError.append("@User4_ID@ @NotFound@ ");
    Integer userElement1Id = 0;
    if (importBudget.getUserElement1_ID() > 0)
        userElement1Id = importBudget.getUserElement1_ID();
    if (userElement1Id <= 0 && importBudget.getUserElement1_ID() <= 0 && importBudget.getUserElementValue1() != null) {
        Arrays.stream(acctSchemaElements).filter(acctSchemaElement -> MAcctSchemaElement.ELEMENTTYPE_UserElement1.equals(acctSchemaElement.getElementType())).forEach(acctSchemaElement -> {
            I_AD_Column column = acctSchemaElement.getAD_Column();
            MTable table = (MTable) column.getAD_Table();
            MColumn columnName = table.getColumn("Value");
            if (columnName == null)
                columnName = table.getColumn("Name");
            if (columnName != null)
                importBudget.setUserElement1_ID(getId(table.getTableName(), columnName.getColumnName() + "=?", trxName, importBudget.getUserElementValue1()));
        });
    }
    if (importBudget.getUserElement1_ID() <= 0 && importBudget.getUserElementValue1() != null)
        stringError.append("@UserElement1_ID@ @NotFound@ ");
    Integer userElement2Id = 0;
    if (importBudget.getUserElement2_ID() > 0)
        userElement2Id = importBudget.getUserElement2_ID();
    if (userElement2Id <= 0 && importBudget.getUserElement2_ID() <= 0 && importBudget.getUserElementValue2() != null) {
        Arrays.stream(acctSchemaElements).filter(acctSchemaElement -> MAcctSchemaElement.ELEMENTTYPE_UserElement2.equals(acctSchemaElement.getElementType())).forEach(acctSchemaElement -> {
            I_AD_Column column = acctSchemaElement.getAD_Column();
            MTable table = (MTable) column.getAD_Table();
            MColumn columnName = table.getColumn("Value");
            if (columnName == null)
                columnName = table.getColumn("Name");
            if (columnName != null)
                importBudget.setUserElement2_ID(getId(table.getTableName(), columnName.getColumnName() + "=?", trxName, importBudget.getUserElementValue2()));
        });
    }
    if (importBudget.getUserElement2_ID() <= 0 && importBudget.getUserElementValue2() != null)
        stringError.append("@UserElement2_ID@ @NotFound@ ");
    if (accountSchemaId <= 0)
        stringError.append("@C_AcctSchema_ID@ @NotFound@ ");
    if (budgetId <= 0)
        stringError.append("@GL_Budget_ID@ @NotFound@ ");
    if (accountId <= 0)
        stringError.append("@Account_ID@ @NotFound@ ");
    if (!stringError.toString().isEmpty() && stringError.toString().length() > 0) {
        importBudget.setI_ErrorMsg(Msg.parseTranslation(getCtx(), stringError.toString()));
        importBudget.saveEx();
    }
    importBudget.saveEx();
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) MAcctSchemaElement(org.compiere.model.MAcctSchemaElement) Arrays(java.util.Arrays) MProject(org.compiere.model.MProject) X_I_Budget(org.compiere.model.X_I_Budget) CLogger(org.compiere.util.CLogger) MJournalLine(org.compiere.model.MJournalLine) MJournalBatch(org.compiere.model.MJournalBatch) Env(org.compiere.util.Env) SimpleDateFormat(java.text.SimpleDateFormat) X_GL_Budget(org.compiere.model.X_GL_Budget) MCampaign(org.compiere.model.MCampaign) AtomicReference(java.util.concurrent.atomic.AtomicReference) MAcctSchema(org.compiere.model.MAcctSchema) ArrayList(java.util.ArrayList) MActivity(org.compiere.model.MActivity) MSalesRegion(org.compiere.model.MSalesRegion) BigDecimal(java.math.BigDecimal) Query(org.compiere.model.Query) DB(org.compiere.util.DB) Calendar(java.util.Calendar) MBPartner(org.compiere.model.MBPartner) Msg(org.compiere.util.Msg) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) MElementValue(org.compiere.model.MElementValue) MPeriod(org.compiere.model.MPeriod) Trx(org.compiere.util.Trx) MJournal(org.compiere.model.MJournal) DateFormat(java.text.DateFormat) Timestamp(java.sql.Timestamp) X_C_SubAcct(org.compiere.model.X_C_SubAcct) Logger(java.util.logging.Logger) MColumn(org.compiere.model.MColumn) Date(java.sql.Date) I_AD_Column(org.compiere.model.I_AD_Column) List(java.util.List) MOrg(org.compiere.model.MOrg) AdempiereException(org.adempiere.exceptions.AdempiereException) X_A_Asset(org.compiere.model.X_A_Asset) MTable(org.compiere.model.MTable) MAccount(org.compiere.model.MAccount) MProduct(org.compiere.model.MProduct) I_I_Budget(org.compiere.model.I_I_Budget) MColumn(org.compiere.model.MColumn) MTable(org.compiere.model.MTable) I_AD_Column(org.compiere.model.I_AD_Column) MBPartner(org.compiere.model.MBPartner)

Example 2 with MAcctSchemaElement

use of org.compiere.model.MAcctSchemaElement in project adempiere by adempiere.

the class VAccountDialog method initAccount.

//	jbInit
/**
	 *	Dyanmic Init.
	 *  When a row is selected, the editor values are set
	 *  (editors do not change grid)
	 *  @return true if initialized
	 */
private boolean initAccount() {
    m_AD_Client_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, "AD_Client_ID");
    //	Get AcctSchema Info
    if (s_AcctSchema == null || s_AcctSchema.getC_AcctSchema_ID() != m_C_AcctSchema_ID)
        s_AcctSchema = new MAcctSchema(Env.getCtx(), m_C_AcctSchema_ID, null);
    log.config(s_AcctSchema.toString() + ", #" + s_AcctSchema.getAcctSchemaElements().length);
    Env.setContext(Env.getCtx(), m_WindowNo, "C_AcctSchema_ID", m_C_AcctSchema_ID);
    //  Model
    //	Maintain Account Combinations 
    int AD_Window_ID = 153;
    GridWindowVO wVO = AEnv.getMWindowVO(m_WindowNo, AD_Window_ID, 0);
    if (wVO == null)
        return false;
    m_mWindow = new GridWindow(wVO);
    m_mTab = m_mWindow.getTab(0);
    // Make sure is the tab is loaded - teo_sarca [ 1659124 ]
    if (!m_mTab.isLoadComplete())
        m_mWindow.initTab(0);
    //  ParameterPanel restrictions
    m_mTab.getField("Alias").setDisplayLength(15);
    m_mTab.getField("Combination").setDisplayLength(15);
    //  Grid restrictions
    m_mTab.getField("AD_Client_ID").setDisplayed(false);
    m_mTab.getField("C_AcctSchema_ID").setDisplayed(false);
    m_mTab.getField("IsActive").setDisplayed(false);
    m_mTab.getField("IsFullyQualified").setDisplayed(false);
    //  don't show fields not being displayed in this environment
    for (int i = 0; i < m_mTab.getFieldCount(); i++) {
        GridField field = m_mTab.getField(i);
        if (//  check context
        !field.isDisplayed(true))
            field.setDisplayed(false);
    }
    //  GridController
    m_gridController = new GridController();
    m_gridController.initGrid(m_mTab, true, m_WindowNo, null, null);
    m_gridController.setPreferredSize(new Dimension(300, 100));
    panel.add(m_gridController, BorderLayout.CENTER);
    //  Prepare Parameter
    m_gbc.anchor = GridBagConstraints.NORTHWEST;
    //	line
    m_gbc.gridy = 0;
    m_gbc.gridx = 0;
    m_gbc.gridwidth = 1;
    m_gbc.insets = m_fieldInsets;
    m_gbc.fill = GridBagConstraints.HORIZONTAL;
    m_gbc.weightx = 0;
    m_gbc.weighty = 0;
    int TabNo = 0;
    //	Alias
    if (s_AcctSchema.isHasAlias()) {
        GridField alias = m_mTab.getField("Alias");
        f_Alias = VEditorFactory.getEditor(m_mTab, alias, false);
        addLine(alias, f_Alias, false);
    }
    //	Alias
    //	Combination
    GridField combination = m_mTab.getField("Combination");
    f_Combination = VEditorFactory.getEditor(m_mTab, combination, false);
    addLine(combination, f_Combination, false);
    m_newRow = true;
    /**
		 *	Create Fields in Element Order
		 */
    MAcctSchemaElement[] elements = s_AcctSchema.getAcctSchemaElements();
    for (int i = 0; i < elements.length; i++) {
        MAcctSchemaElement ase = elements[i];
        String type = ase.getElementType();
        boolean isMandatory = ase.isMandatory();
        //
        if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Organization)) {
            GridField field = m_mTab.getField("AD_Org_ID");
            f_AD_Org_ID = VEditorFactory.getEditor(m_mTab, field, false);
            addLine(field, f_AD_Org_ID, isMandatory);
        } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Account)) {
            GridField field = m_mTab.getField("Account_ID");
            f_Account_ID = VEditorFactory.getEditor(m_mTab, field, false);
            //	((VLookup)f_Account_ID).setWidth(400);
            addLine(field, f_Account_ID, isMandatory);
            f_Account_ID.addVetoableChangeListener(this);
        } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_SubAccount)) {
            GridField field = m_mTab.getField("C_SubAcct_ID");
            f_SubAcct_ID = VEditorFactory.getEditor(m_mTab, field, false);
            //	((VLookup)f_SubAcct_ID).setWidth(400);
            addLine(field, f_SubAcct_ID, isMandatory);
        } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Product)) {
            GridField field = m_mTab.getField("M_Product_ID");
            f_M_Product_ID = VEditorFactory.getEditor(m_mTab, field, false);
            addLine(field, f_M_Product_ID, isMandatory);
        } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_BPartner)) {
            GridField field = m_mTab.getField("C_BPartner_ID");
            f_C_BPartner_ID = VEditorFactory.getEditor(m_mTab, field, false);
            addLine(field, f_C_BPartner_ID, isMandatory);
        } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Campaign)) {
            GridField field = m_mTab.getField("C_Campaign_ID");
            f_C_Campaign_ID = VEditorFactory.getEditor(m_mTab, field, false);
            addLine(field, f_C_Campaign_ID, isMandatory);
        } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_LocationFrom)) {
            GridField field = m_mTab.getField("C_LocFrom_ID");
            f_C_LocFrom_ID = VEditorFactory.getEditor(m_mTab, field, false);
            addLine(field, f_C_LocFrom_ID, isMandatory);
        } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_LocationTo)) {
            GridField field = m_mTab.getField("C_LocTo_ID");
            f_C_LocTo_ID = VEditorFactory.getEditor(m_mTab, field, false);
            addLine(field, f_C_LocTo_ID, isMandatory);
        } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Project)) {
            GridField field = m_mTab.getField("C_Project_ID");
            f_C_Project_ID = VEditorFactory.getEditor(m_mTab, field, false);
            addLine(field, f_C_Project_ID, isMandatory);
        } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_SalesRegion)) {
            GridField field = m_mTab.getField("C_SalesRegion_ID");
            f_C_SalesRegion_ID = VEditorFactory.getEditor(m_mTab, field, false);
            addLine(field, f_C_SalesRegion_ID, isMandatory);
        } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_OrgTrx)) {
            GridField field = m_mTab.getField("AD_OrgTrx_ID");
            f_AD_OrgTrx_ID = VEditorFactory.getEditor(m_mTab, field, false);
            addLine(field, f_AD_OrgTrx_ID, isMandatory);
        } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Activity)) {
            GridField field = m_mTab.getField("C_Activity_ID");
            f_C_Activity_ID = VEditorFactory.getEditor(m_mTab, field, false);
            addLine(field, f_C_Activity_ID, isMandatory);
        } else //	User1
        if (type.equals(MAcctSchemaElement.ELEMENTTYPE_UserList1)) {
            GridField field = m_mTab.getField("User1_ID");
            f_User1_ID = VEditorFactory.getEditor(m_mTab, field, false);
            GridFieldVO newFieldVO = f_User1_ID.getField().getVO();
            newFieldVO.Header = f_User1_ID.getName();
            field = new GridField(newFieldVO);
            addLine(field, f_User1_ID, isMandatory);
        } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_UserList2)) {
            GridField field = m_mTab.getField("User2_ID");
            f_User2_ID = VEditorFactory.getEditor(m_mTab, field, false);
            GridFieldVO newFieldVO = f_User2_ID.getField().getVO();
            newFieldVO.Header = f_User2_ID.getName();
            field = new GridField(newFieldVO);
            addLine(field, f_User2_ID, isMandatory);
        } else //	User3
        if (type.equals(MAcctSchemaElement.ELEMENTTYPE_UserList3)) {
            GridField field = m_mTab.getField("User3_ID");
            f_User3_ID = VEditorFactory.getEditor(m_mTab, field, false);
            GridFieldVO newFieldVO = f_User3_ID.getField().getVO();
            newFieldVO.Header = f_User3_ID.getName();
            field = new GridField(newFieldVO);
            addLine(field, f_User3_ID, isMandatory);
        } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_UserList4)) {
            GridField field = m_mTab.getField("User4_ID");
            f_User4_ID = VEditorFactory.getEditor(m_mTab, field, false);
            GridFieldVO newFieldVO = f_User4_ID.getField().getVO();
            newFieldVO.Header = f_User4_ID.getName();
            field = new GridField(newFieldVO);
            addLine(field, f_User4_ID, isMandatory);
        }
    }
    //	Create Fields in Element Order
    //	Add description
    m_newRow = true;
    m_gbc.gridy = m_line++;
    m_gbc.gridx = 0;
    m_gbc.gridwidth = 4;
    // 	top,left,bottom,right
    m_gbc.insets = new Insets(5, 15, 2, 0);
    m_gbc.fill = GridBagConstraints.HORIZONTAL;
    f_Description.setFont(f_Description.getFont().deriveFont(Font.ITALIC));
    parameterPanel.add(f_Description, m_gbc);
    //	Finish
    m_query = new MQuery();
    m_query.addRestriction("C_AcctSchema_ID", MQuery.EQUAL, m_C_AcctSchema_ID);
    m_query.addRestriction("IsFullyQualified", MQuery.EQUAL, "Y");
    if (m_mAccount.C_ValidCombination_ID == 0)
        m_mTab.setQuery(MQuery.getEqualQuery("1", "2"));
    else {
        MQuery query = new MQuery();
        query.addRestriction("C_AcctSchema_ID", MQuery.EQUAL, m_C_AcctSchema_ID);
        query.addRestriction("C_ValidCombination_ID", MQuery.EQUAL, m_mAccount.C_ValidCombination_ID);
        m_mTab.setQuery(query);
    }
    m_mTab.query(false);
    m_gridController.getTable().addMouseListener(new VAccountDialog_mouseAdapter(this));
    m_gridController.addDataStatusListener(this);
    statusBar.setStatusLine(s_AcctSchema.toString());
    statusBar.setStatusDB("?");
    //	Initial value
    if (m_mAccount.C_ValidCombination_ID != 0)
        m_mTab.navigate(0);
    log.config("fini");
    return true;
}
Also used : Insets(java.awt.Insets) GridWindow(org.compiere.model.GridWindow) GridFieldVO(org.compiere.model.GridFieldVO) MQuery(org.compiere.model.MQuery) GridField(org.compiere.model.GridField) Dimension(java.awt.Dimension) MAcctSchema(org.compiere.model.MAcctSchema) GridWindowVO(org.compiere.model.GridWindowVO) GridController(org.compiere.grid.GridController) MAcctSchemaElement(org.compiere.model.MAcctSchemaElement)

Example 3 with MAcctSchemaElement

use of org.compiere.model.MAcctSchemaElement in project adempiere by adempiere.

the class VAccountDialog method action_Save.

//	action_Find
/**
	 *	Create/Save Account
	 */
private void action_Save() {
    log.info("");
    /**
		 *	Check completeness (mandatory fields) ... and for duplicates
		 */
    StringBuffer sb = new StringBuffer();
    StringBuffer sql = new StringBuffer("SELECT C_ValidCombination_ID, Alias FROM C_ValidCombination WHERE ");
    Object value = null;
    if (s_AcctSchema.isHasAlias()) {
        value = f_Alias.getValue().toString();
        if (value == null)
            sb.append(Msg.translate(Env.getCtx(), "Alias")).append(", ");
    }
    MAcctSchemaElement[] elements = s_AcctSchema.getAcctSchemaElements();
    for (int i = 0; i < elements.length; i++) {
        MAcctSchemaElement ase = elements[i];
        String type = ase.getElementType();
        //
        if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Organization)) {
            value = f_AD_Org_ID.getValue();
            sql.append("AD_Org_ID");
            if (value == null)
                sql.append(" IS NULL AND ");
            else
                sql.append("=").append(value).append(" AND ");
        } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Account)) {
            value = f_Account_ID.getValue();
            sql.append("Account_ID");
            if (value == null)
                sql.append(" IS NULL AND ");
            else
                sql.append("=").append(value).append(" AND ");
        } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_SubAccount)) {
            value = f_SubAcct_ID.getValue();
            sql.append("C_SubAcct_ID");
            if (value == null)
                sql.append(" IS NULL AND ");
            else
                sql.append("=").append(value).append(" AND ");
        } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Product)) {
            value = f_M_Product_ID.getValue();
            sql.append("M_Product_ID");
            if (value == null)
                sql.append(" IS NULL AND ");
            else
                sql.append("=").append(value).append(" AND ");
        } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_BPartner)) {
            value = f_C_BPartner_ID.getValue();
            sql.append("C_BPartner_ID");
            if (value == null)
                sql.append(" IS NULL AND ");
            else
                sql.append("=").append(value).append(" AND ");
        } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Campaign)) {
            value = f_C_Campaign_ID.getValue();
            sql.append("C_Campaign_ID");
            if (value == null)
                sql.append(" IS NULL AND ");
            else
                sql.append("=").append(value).append(" AND ");
        } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_LocationFrom)) {
            value = f_C_LocFrom_ID.getValue();
            sql.append("C_LocFrom_ID");
            if (value == null)
                sql.append(" IS NULL AND ");
            else
                sql.append("=").append(value).append(" AND ");
        } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_LocationTo)) {
            value = f_C_LocTo_ID.getValue();
            sql.append("C_LocTo_ID");
            if (value == null)
                sql.append(" IS NULL AND ");
            else
                sql.append("=").append(value).append(" AND ");
        } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Project)) {
            value = f_C_Project_ID.getValue();
            sql.append("C_Project_ID");
            if (value == null)
                sql.append(" IS NULL AND ");
            else
                sql.append("=").append(value).append(" AND ");
        } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_SalesRegion)) {
            value = f_C_SalesRegion_ID.getValue();
            sql.append("C_SalesRegion_ID");
            if (value == null)
                sql.append(" IS NULL AND ");
            else
                sql.append("=").append(value).append(" AND ");
        } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_OrgTrx)) {
            value = f_AD_OrgTrx_ID.getValue();
            sql.append("AD_OrgTrx_ID");
            if (value == null)
                sql.append(" IS NULL AND ");
            else
                sql.append("=").append(value).append(" AND ");
        } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Activity)) {
            value = f_C_Activity_ID.getValue();
            sql.append("C_Activity_ID");
            if (value == null)
                sql.append(" IS NULL AND ");
            else
                sql.append("=").append(value).append(" AND ");
        } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_UserList1)) {
            value = f_User1_ID.getValue();
            sql.append("User1_ID");
            if (value == null)
                sql.append(" IS NULL AND ");
            else
                sql.append("=").append(value).append(" AND ");
        } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_UserList2)) {
            value = f_User2_ID.getValue();
            sql.append("User2_ID");
            if (value == null)
                sql.append(" IS NULL AND ");
            else
                sql.append("=").append(value).append(" AND ");
        } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_UserList3)) {
            value = f_User3_ID.getValue();
            sql.append("User3_ID");
            if (value == null)
                sql.append(" IS NULL AND ");
            else
                sql.append("=").append(value).append(" AND ");
        } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_UserList4)) {
            value = f_User4_ID.getValue();
            sql.append("User4_ID");
            if (value == null)
                sql.append(" IS NULL AND ");
            else
                sql.append("=").append(value).append(" AND ");
        }
        //
        if (ase.isMandatory() && value == null)
            sb.append(ase.getName()).append(", ");
    }
    if (sb.length() != 0) {
        ADialog.error(m_WindowNo, this, "FillMandatory", sb.substring(0, sb.length() - 2));
        return;
    }
    if (f_AD_Org_ID == null || f_AD_Org_ID.getValue() == null) {
        ADialog.error(m_WindowNo, this, "FillMandatory", Msg.getElement(Env.getCtx(), "AD_Org_ID"));
        return;
    }
    if (f_Account_ID == null || f_Account_ID.getValue() == null) {
        ADialog.error(m_WindowNo, this, "FillMandatory", Msg.getElement(Env.getCtx(), "Account_ID"));
        return;
    }
    /**
		 *	Check if already exists
		 */
    sql.append("AD_Client_ID=? AND C_AcctSchema_ID=?");
    log.fine("Check = " + sql.toString());
    int IDvalue = 0;
    String Alias = null;
    try {
        PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
        pstmt.setInt(1, m_AD_Client_ID);
        pstmt.setInt(2, s_AcctSchema.getC_AcctSchema_ID());
        ResultSet rs = pstmt.executeQuery();
        if (rs.next()) {
            IDvalue = rs.getInt(1);
            Alias = rs.getString(2);
        }
        rs.close();
        pstmt.close();
    } catch (SQLException e) {
        log.log(Level.SEVERE, sql.toString(), e);
        IDvalue = 0;
    }
    log.fine("ID=" + IDvalue + ", Alias=" + Alias);
    if (Alias == null)
        Alias = "";
    //	We have an account like this already - check alias
    if (IDvalue != 0 && s_AcctSchema.isHasAlias() && !f_Alias.getValue().toString().equals(Alias)) {
        sql = new StringBuffer("UPDATE C_ValidCombination SET Alias=");
        if (f_Alias.getValue().toString().length() == 0)
            sql.append("NULL");
        else
            sql.append("'").append(f_Alias.getValue()).append("'");
        sql.append(" WHERE C_ValidCombination_ID=").append(IDvalue);
        int i = 0;
        try {
            java.sql.PreparedStatement stmt = DB.prepareStatement(sql.toString(), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE, null);
            i = stmt.executeUpdate();
            stmt.close();
        } catch (SQLException e) {
            log.log(Level.SEVERE, sql.toString(), e);
        }
        if (i == 0)
            ADialog.error(m_WindowNo, this, "AccountNotUpdated");
    }
    //	load and display
    if (IDvalue != 0) {
        loadInfo(IDvalue, s_AcctSchema.getC_AcctSchema_ID());
        action_Find(false);
        return;
    }
    log.config("New");
    Alias = null;
    if (f_Alias != null)
        Alias = f_Alias.getValue().toString();
    int C_SubAcct_ID = 0;
    if (f_SubAcct_ID != null && f_SubAcct_ID.getValue() != null)
        C_SubAcct_ID = ((Integer) f_SubAcct_ID.getValue()).intValue();
    int M_Product_ID = 0;
    if (f_M_Product_ID != null && f_M_Product_ID.getValue() != null)
        M_Product_ID = ((Integer) f_M_Product_ID.getValue()).intValue();
    int C_BPartner_ID = 0;
    if (f_C_BPartner_ID != null && f_C_BPartner_ID.getValue() != null)
        C_BPartner_ID = ((Integer) f_C_BPartner_ID.getValue()).intValue();
    int AD_OrgTrx_ID = 0;
    if (f_AD_OrgTrx_ID != null && f_AD_OrgTrx_ID.getValue() != null)
        AD_OrgTrx_ID = ((Integer) f_AD_OrgTrx_ID.getValue()).intValue();
    int C_LocFrom_ID = 0;
    if (f_C_LocFrom_ID != null && f_C_LocFrom_ID.getValue() != null)
        C_LocFrom_ID = ((Integer) f_C_LocFrom_ID.getValue()).intValue();
    int C_LocTo_ID = 0;
    if (f_C_LocTo_ID != null && f_C_LocTo_ID.getValue() != null)
        C_LocTo_ID = ((Integer) f_C_LocTo_ID.getValue()).intValue();
    int C_SRegion_ID = 0;
    if (f_C_SalesRegion_ID != null && f_C_SalesRegion_ID.getValue() != null)
        C_SRegion_ID = ((Integer) f_C_SalesRegion_ID.getValue()).intValue();
    int C_Project_ID = 0;
    if (f_C_Project_ID != null && f_C_Project_ID.getValue() != null)
        C_Project_ID = ((Integer) f_C_Project_ID.getValue()).intValue();
    int C_Campaign_ID = 0;
    if (f_C_Campaign_ID != null && f_C_Campaign_ID.getValue() != null)
        C_Campaign_ID = ((Integer) f_C_Campaign_ID.getValue()).intValue();
    int C_Activity_ID = 0;
    if (f_C_Activity_ID != null && f_C_Activity_ID.getValue() != null)
        C_Activity_ID = ((Integer) f_C_Activity_ID.getValue()).intValue();
    int User1_ID = 0;
    if (f_User1_ID != null && f_User1_ID.getValue() != null)
        User1_ID = ((Integer) f_User1_ID.getValue()).intValue();
    int User2_ID = 0;
    if (f_User2_ID != null && f_User2_ID.getValue() != null)
        User2_ID = ((Integer) f_User2_ID.getValue()).intValue();
    int User3_ID = 0;
    if (f_User3_ID != null && f_User3_ID.getValue() != null)
        User3_ID = ((Integer) f_User3_ID.getValue()).intValue();
    int User4_ID = 0;
    if (f_User4_ID != null && f_User4_ID.getValue() != null)
        User4_ID = ((Integer) f_User4_ID.getValue()).intValue();
    MAccount acct = MAccount.get(Env.getCtx(), m_AD_Client_ID, ((Integer) f_AD_Org_ID.getValue()).intValue(), s_AcctSchema.getC_AcctSchema_ID(), ((Integer) f_Account_ID.getValue()).intValue(), C_SubAcct_ID, M_Product_ID, C_BPartner_ID, AD_OrgTrx_ID, C_LocFrom_ID, C_LocTo_ID, C_SRegion_ID, C_Project_ID, C_Campaign_ID, C_Activity_ID, User1_ID, User2_ID, User3_ID, User4_ID, 0, 0, null);
    if (acct != null && acct.get_ID() == 0)
        acct.saveEx();
    //  Show Info
    if (acct == null || acct.get_ID() == 0)
        loadInfo(0, 0);
    else {
        //	Update Account with optional Alias
        if (Alias != null && Alias.length() > 0) {
            acct.setAlias(Alias);
            acct.saveEx();
        }
        loadInfo(acct.get_ID(), s_AcctSchema.getC_AcctSchema_ID());
    }
    action_Find(false);
}
Also used : SQLException(java.sql.SQLException) MAccount(org.compiere.model.MAccount) PreparedStatement(java.sql.PreparedStatement) PreparedStatement(java.sql.PreparedStatement) ResultSet(java.sql.ResultSet) MAcctSchemaElement(org.compiere.model.MAcctSchemaElement)

Example 4 with MAcctSchemaElement

use of org.compiere.model.MAcctSchemaElement in project adempiere by adempiere.

the class WAcctViewerData method createKeyColumns.

// createRModel
/**
	 *  Create the key columns in sequence
	 *  @return List of Key Columns
	 */
private ArrayList<String> createKeyColumns() {
    ArrayList<String> columns = new ArrayList<String>();
    m_leadingColumns = 0;
    //  Sorting Fields
    //  may add ""
    columns.add(sortBy1);
    if (!columns.contains(sortBy2))
        columns.add(sortBy2);
    if (!columns.contains(sortBy3))
        columns.add(sortBy3);
    if (!columns.contains(sortBy4))
        columns.add(sortBy4);
    //  Add Account Segments
    MAcctSchemaElement[] elements = ASchema.getAcctSchemaElements();
    for (int i = 0; i < elements.length; i++) {
        if (m_leadingColumns == 0 && columns.contains("AD_Org_ID") && columns.contains("Account_ID"))
            m_leadingColumns = columns.size();
        MAcctSchemaElement ase = elements[i];
        String columnName = ase.getColumnName();
        if (columnName.startsWith("UserElement")) {
            if (columnName.indexOf('1') != -1)
                m_ref1 = ase.getDisplayColumnName();
            else
                m_ref2 = ase.getDisplayColumnName();
        }
        if (!columns.contains(columnName))
            columns.add(columnName);
    }
    if (m_leadingColumns == 0 && columns.contains("AD_Org_ID") && columns.contains("Account_ID"))
        m_leadingColumns = columns.size();
    return columns;
}
Also used : ArrayList(java.util.ArrayList) MAcctSchemaElement(org.compiere.model.MAcctSchemaElement)

Example 5 with MAcctSchemaElement

use of org.compiere.model.MAcctSchemaElement in project adempiere by adempiere.

the class WAcctViewer method actionButton.

// actionTable
/**
	 *  Action Button
	 *
	 *  @param button pressed button
	 *  @return ID
	 * @throws Exception
	 */
private int actionButton(Button button) throws Exception {
    String keyColumn = button.getName();
    log.info(keyColumn);
    // String whereClause = ""; // Elaine 2008/07/28
    String whereClause = "(IsSummary='N' OR IsSummary IS NULL)";
    String lookupColumn = keyColumn;
    int record_id = m_data.getButtonRecordID(keyColumn);
    if ("Account_ID".equals(keyColumn)) {
        lookupColumn = "C_ElementValue_ID";
        MAcctSchemaElement ase = m_data.ASchema.getAcctSchemaElement(X_C_AcctSchema_Element.ELEMENTTYPE_Account);
        if (ase != null)
            whereClause += " AND C_Element_ID=" + ase.getC_Element_ID();
    } else if ("User1_ID".equals(keyColumn)) {
        lookupColumn = "C_ElementValue_ID";
        MAcctSchemaElement ase = m_data.ASchema.getAcctSchemaElement(X_C_AcctSchema_Element.ELEMENTTYPE_UserList1);
        if (ase != null)
            whereClause += " AND C_Element_ID=" + ase.getC_Element_ID();
    } else if ("User2_ID".equals(keyColumn)) {
        lookupColumn = "C_ElementValue_ID";
        MAcctSchemaElement ase = m_data.ASchema.getAcctSchemaElement(X_C_AcctSchema_Element.ELEMENTTYPE_UserList2);
        if (ase != null)
            whereClause += " AND C_Element_ID=" + ase.getC_Element_ID();
    } else if ("User3_ID".equals(keyColumn)) {
        lookupColumn = "C_ElementValue_ID";
        MAcctSchemaElement ase = m_data.ASchema.getAcctSchemaElement(X_C_AcctSchema_Element.ELEMENTTYPE_UserList3);
        if (ase != null)
            whereClause += " AND C_Element_ID=" + ase.getC_Element_ID();
    } else if ("User4_ID".equals(keyColumn)) {
        lookupColumn = "C_ElementValue_ID";
        MAcctSchemaElement ase = m_data.ASchema.getAcctSchemaElement(X_C_AcctSchema_Element.ELEMENTTYPE_UserList4);
        if (ase != null)
            whereClause += " AND C_Element_ID=" + ase.getC_Element_ID();
    } else if ("UserElement1_ID".equals(keyColumn)) {
        MAcctSchemaElement et = new Query(Env.getCtx(), MAcctSchemaElement.Table_Name, "elementtype = 'X1' ", null).setClient_ID().firstOnly();
        String tableName = et.getAD_Column().getAD_Table().getTableName();
        String lookupcolumnname = tableName + "_ID";
        lookupColumn = lookupcolumnname;
        whereClause = "";
    } else if ("UserElement2_ID".equals(keyColumn)) {
        MAcctSchemaElement et = new Query(Env.getCtx(), MAcctSchemaElement.Table_Name, "elementtype = 'X2' ", null).setClient_ID().firstOnly();
        String tableName = et.getAD_Column().getAD_Table().getTableName();
        String lookupcolumnname = tableName + "_ID";
        lookupColumn = lookupcolumnname;
        whereClause = "";
    } else if (keyColumn.equals("M_Product_ID")) {
        whereClause = "";
    } else if (selDocument.isChecked())
        whereClause = "";
    if (//  Record_ID
    button == selRecord)
        record_id = m_data.Record_ID;
    else
        record_id = m_data.getButtonRecordID(keyColumn);
    String tableName = lookupColumn.substring(0, lookupColumn.length() - 3);
    //whereClause = tableName + ".IsSummary='N'" + whereClause; // Elaine 2008/07/28
    //  Open modal
    InfoPanel info = InfoPanel.create(m_data.WindowNo, tableName, lookupColumn, record_id, "", false, whereClause);
    if (!info.loadedOK()) {
        info.dispose();
        info = null;
        button.setLabel("");
        m_data.whereInfo.put(keyColumn, "");
        m_data.buttonRecordID.put(keyColumn, null);
        return 0;
    }
    info.setVisible(true);
    AEnv.showWindow(info);
    boolean isCancelled = info.isCancelled();
    boolean isOK = info.isOk();
    Integer key = 0;
    if (// Delete the saved info
    isCancelled && !isOK) {
        key = 0;
        if (//  Record_ID
        button == selRecord)
            m_data.Record_ID = key.intValue();
        else {
            //  no query
            m_data.whereInfo.put(keyColumn, "");
            m_data.buttonRecordID.put(keyColumn, key.intValue());
        }
        button.setLabel("");
    } else if (!isCancelled && isOK) {
        //  Save for query
        //  C_Project_ID=100 or ""
        String selectSQL = info.getSelectedSQL();
        key = (Integer) info.getSelectedKey();
        log.config(keyColumn + " - " + key);
        if (//  Record_ID
        button == selRecord)
            m_data.Record_ID = key.intValue();
        else {
            //  Add to query
            m_data.whereInfo.put(keyColumn, keyColumn + "=" + key.intValue());
            m_data.buttonRecordID.put(keyColumn, key.intValue());
        }
        //  Display Selection and resize
        button.setLabel(m_data.getButtonText(tableName, lookupColumn, selectSQL));
    } else if (// xor: window closed or error - no change
    !(isCancelled ^ isOK)) {
        // m_data not changed
        if (//  Record_ID
        button == selRecord)
            key = m_data.Record_ID = key.intValue();
        else
            key = m_data.getButtonRecordID(keyColumn);
    }
    info = null;
    return key.intValue();
}
Also used : Query(org.compiere.model.Query) InfoPanel(org.adempiere.webui.panel.InfoPanel) MAcctSchemaElement(org.compiere.model.MAcctSchemaElement)

Aggregations

MAcctSchemaElement (org.compiere.model.MAcctSchemaElement)18 MAcctSchema (org.compiere.model.MAcctSchema)7 ArrayList (java.util.ArrayList)5 MAccount (org.compiere.model.MAccount)4 Timestamp (java.sql.Timestamp)3 Query (org.compiere.model.Query)3 KeyNamePair (org.compiere.util.KeyNamePair)3 ValueNamePair (org.compiere.util.ValueNamePair)3 BigDecimal (java.math.BigDecimal)2 Date (java.sql.Date)2 PreparedStatement (java.sql.PreparedStatement)2 ResultSet (java.sql.ResultSet)2 SQLException (java.sql.SQLException)2 DateFormat (java.text.DateFormat)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Arrays (java.util.Arrays)2 Calendar (java.util.Calendar)2 List (java.util.List)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2