IDEMPIERE-1099 - Process/Form Generate Charges should include account key in charge name
This commit is contained in:
parent
c607a29f31
commit
d67d3efc73
|
@ -16,9 +16,12 @@ package org.compiere.apps.form;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.Properties;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import javax.security.auth.login.AccountException;
|
||||||
|
|
||||||
import org.compiere.minigrid.IMiniTable;
|
import org.compiere.minigrid.IMiniTable;
|
||||||
import org.compiere.model.MAccount;
|
import org.compiere.model.MAccount;
|
||||||
import org.compiere.model.MAcctSchema;
|
import org.compiere.model.MAcctSchema;
|
||||||
|
@ -232,29 +235,30 @@ public class Charge
|
||||||
MCharge charge;
|
MCharge charge;
|
||||||
MAccount account;
|
MAccount account;
|
||||||
|
|
||||||
if (log.isLoggable(Level.CONFIG)) log.config(name + " - ");
|
|
||||||
// Charge
|
|
||||||
charge = new MCharge(Env.getCtx(), 0, null);
|
|
||||||
charge.setName(name);
|
|
||||||
charge.setC_TaxCategory_ID(m_C_TaxCategory_ID);
|
|
||||||
if (!charge.save())
|
|
||||||
{
|
|
||||||
log.log(Level.SEVERE, name + " not created");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
refreshAccountSchema();
|
refreshAccountSchema();
|
||||||
if (!isAccountSchemaValid())
|
if (!isAccountSchemaValid())
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Target Account
|
// Target Account
|
||||||
account = getAccount(elementValueId, charge);
|
account = getAccount(elementValueId);
|
||||||
if (account == null)
|
if (account == null)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (log.isLoggable(Level.CONFIG)) log.config(name + " - ");
|
||||||
|
// Charge
|
||||||
|
charge = new MCharge(Env.getCtx(), 0, null);
|
||||||
|
// IDEMPIERE-1099 - Key must be included in name to avoid name crashes in account schema.
|
||||||
|
charge.setName(account.getAccount().getValue() + " " + name);
|
||||||
|
charge.setC_TaxCategory_ID(m_C_TaxCategory_ID);
|
||||||
|
if (!charge.save())
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, name + " not created");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
updateAccount(charge, account);
|
updateAccount(charge, account);
|
||||||
|
|
||||||
|
@ -338,15 +342,15 @@ public class Charge
|
||||||
* Gets the account for the specified charge and element value.
|
* Gets the account for the specified charge and element value.
|
||||||
* The account is created if it doesn't already exist.
|
* The account is created if it doesn't already exist.
|
||||||
* @param elementValueId identifier for the element value
|
* @param elementValueId identifier for the element value
|
||||||
* @param charge charge
|
|
||||||
* @return the account
|
* @return the account
|
||||||
*/
|
*/
|
||||||
private MAccount getAccount(int elementValueId, MCharge charge)
|
private MAccount getAccount(int elementValueId)
|
||||||
{
|
{
|
||||||
|
Properties ctx = Env.getCtx();
|
||||||
MAccount defaultAccount = MAccount.getDefault(m_acctSchema, true); // optional null
|
MAccount defaultAccount = MAccount.getDefault(m_acctSchema, true); // optional null
|
||||||
MAccount account = MAccount.get(Env.getCtx(),
|
MAccount account = MAccount.get(ctx,
|
||||||
charge.getAD_Client_ID(),
|
Env.getAD_Client_ID(ctx),
|
||||||
charge.getAD_Org_ID(),
|
Env.getAD_Org_ID(ctx),
|
||||||
m_acctSchema.getC_AcctSchema_ID(),
|
m_acctSchema.getC_AcctSchema_ID(),
|
||||||
elementValueId,
|
elementValueId,
|
||||||
defaultAccount.getC_SubAcct_ID(),
|
defaultAccount.getC_SubAcct_ID(),
|
||||||
|
|
Loading…
Reference in New Issue