📄 msetup.java
字号:
String err = "Default Accounts NOT inserted";
log.log(Level.SEVERE, err);
m_info.append(err);
m_trx.rollback();
m_trx.close();
return false;
}
// GL Categories
createGLCategory("Standard", MGLCategory.CATEGORYTYPE_Manual, true);
int GL_None = createGLCategory("None", MGLCategory.CATEGORYTYPE_Document, false);
int GL_GL = createGLCategory("Manual", MGLCategory.CATEGORYTYPE_Manual, false);
int GL_ARI = createGLCategory("AR Invoice", MGLCategory.CATEGORYTYPE_Document, false);
int GL_ARR = createGLCategory("AR Receipt", MGLCategory.CATEGORYTYPE_Document, false);
int GL_MM = createGLCategory("Material Management", MGLCategory.CATEGORYTYPE_Document, false);
int GL_API = createGLCategory("AP Invoice", MGLCategory.CATEGORYTYPE_Document, false);
int GL_APP = createGLCategory("AP Payment", MGLCategory.CATEGORYTYPE_Document, false);
int GL_CASH = createGLCategory("Cash/Payments", MGLCategory.CATEGORYTYPE_Document, false);
// Base DocumentTypes
int ii = createDocType("GL Journal", Msg.getElement(m_ctx, "GL_Journal_ID"),
MDocType.DOCBASETYPE_GLJournal, null, 0, 0, 1000, GL_GL);
if (ii == 0)
{
String err = "Document Type not created";
m_info.append(err);
m_trx.rollback();
m_trx.close();
return false;
}
createDocType("GL Journal Batch", Msg.getElement(m_ctx, "GL_JournalBatch_ID"),
MDocType.DOCBASETYPE_GLJournal, null, 0, 0, 100, GL_GL);
// MDocType.DOCBASETYPE_GLDocument
//
int DT_I = createDocType("AR Invoice", Msg.getElement(m_ctx, "C_Invoice_ID", true),
MDocType.DOCBASETYPE_ARInvoice, null, 0, 0, 100000, GL_ARI);
int DT_II = createDocType("AR Invoice Indirect", Msg.getElement(m_ctx, "C_Invoice_ID", true),
MDocType.DOCBASETYPE_ARInvoice, null, 0, 0, 150000, GL_ARI);
int DT_IC = createDocType("AR Credit Memo", Msg.getMsg(m_ctx, "CreditMemo"),
MDocType.DOCBASETYPE_ARCreditMemo, null, 0, 0, 170000, GL_ARI);
// MDocType.DOCBASETYPE_ARProFormaInvoice
createDocType("AP Invoice", Msg.getElement(m_ctx, "C_Invoice_ID", false),
MDocType.DOCBASETYPE_APInvoice, null, 0, 0, 0, GL_API);
createDocType("AP CreditMemo", Msg.getMsg(m_ctx, "CreditMemo"),
MDocType.DOCBASETYPE_APCreditMemo, null, 0, 0, 0, GL_API);
createDocType("Match Invoice", Msg.getElement(m_ctx, "M_MatchInv_ID", false),
MDocType.DOCBASETYPE_MatchInvoice, null, 0, 0, 390000, GL_API);
createDocType("AR Receipt", Msg.getElement(m_ctx, "C_Payment_ID", true),
MDocType.DOCBASETYPE_ARReceipt, null, 0, 0, 0, GL_ARR);
createDocType("AP Payment", Msg.getElement(m_ctx, "C_Payment_ID", false),
MDocType.DOCBASETYPE_APPayment, null, 0, 0, 0, GL_APP);
createDocType("Allocation", "Allocation",
MDocType.DOCBASETYPE_PaymentAllocation, null, 0, 0, 490000, GL_CASH);
int DT_S = createDocType("MM Shipment", "Delivery Note",
MDocType.DOCBASETYPE_MaterialDelivery, null, 0, 0, 500000, GL_MM);
int DT_SI = createDocType("MM Shipment Indirect", "Delivery Note",
MDocType.DOCBASETYPE_MaterialDelivery, null, 0, 0, 550000, GL_MM);
createDocType("MM Receipt", "Vendor Delivery",
MDocType.DOCBASETYPE_MaterialReceipt, null, 0, 0, 0, GL_MM);
int DT_RM = createDocType("MM Returns", "Customer Returns",
MDocType.DOCBASETYPE_MaterialReceipt, null, 0, 0, 570000, GL_MM);
createDocType("Purchase Order", Msg.getElement(m_ctx, "C_Order_ID", false),
MDocType.DOCBASETYPE_PurchaseOrder, null, 0, 0, 800000, GL_None);
createDocType("Match PO", Msg.getElement(m_ctx, "M_MatchPO_ID", false),
MDocType.DOCBASETYPE_MatchPO, null, 0, 0, 890000, GL_None);
createDocType("Purchase Requisition", Msg.getElement(m_ctx, "M_Requisition_ID", false),
MDocType.DOCBASETYPE_PurchaseRequisition, null, 0, 0, 900000, GL_None);
createDocType("Bank Statement", Msg.getElement(m_ctx, "C_BankStatemet_ID", true),
MDocType.DOCBASETYPE_BankStatement, null, 0, 0, 700000, GL_CASH);
createDocType("Cash Journal", Msg.getElement(m_ctx, "C_Cash_ID", true),
MDocType.DOCBASETYPE_CashJournal, null, 0, 0, 750000, GL_CASH);
createDocType("Material Movement", Msg.getElement(m_ctx, "M_Movement_ID", false),
MDocType.DOCBASETYPE_MaterialMovement, null, 0, 0, 610000, GL_MM);
createDocType("Physical Inventory", Msg.getElement(m_ctx, "M_Inventory_ID", false),
MDocType.DOCBASETYPE_MaterialPhysicalInventory, null, 0, 0, 620000, GL_MM);
createDocType("Material Production", Msg.getElement(m_ctx, "M_Production_ID", false),
MDocType.DOCBASETYPE_MaterialProduction, null, 0, 0, 630000, GL_MM);
createDocType("Project Issue", Msg.getElement(m_ctx, "C_ProjectIssue_ID", false),
MDocType.DOCBASETYPE_ProjectIssue, null, 0, 0, 640000, GL_MM);
// Order Entry
createDocType("Binding offer", "Quotation",
MDocType.DOCBASETYPE_SalesOrder, MDocType.DOCSUBTYPESO_Quotation,
0, 0, 10000, GL_None);
createDocType("Non binding offer", "Proposal",
MDocType.DOCBASETYPE_SalesOrder, MDocType.DOCSUBTYPESO_Proposal,
0, 0, 20000, GL_None);
createDocType("Prepay Order", "Prepay Order",
MDocType.DOCBASETYPE_SalesOrder, MDocType.DOCSUBTYPESO_PrepayOrder,
DT_S, DT_I, 30000, GL_None);
createDocType("Return Material", "Return Material Authorization",
MDocType.DOCBASETYPE_SalesOrder, MDocType.DOCSUBTYPESO_ReturnMaterial,
DT_RM, DT_IC, 30000, GL_None);
createDocType("Standard Order", "Order Confirmation",
MDocType.DOCBASETYPE_SalesOrder, MDocType.DOCSUBTYPESO_StandardOrder,
DT_S, DT_I, 50000, GL_None);
createDocType("Credit Order", "Order Confirmation",
MDocType.DOCBASETYPE_SalesOrder, MDocType.DOCSUBTYPESO_OnCreditOrder,
DT_SI, DT_I, 60000, GL_None); // RE
createDocType("Warehouse Order", "Order Confirmation",
MDocType.DOCBASETYPE_SalesOrder, MDocType.DOCSUBTYPESO_WarehouseOrder,
DT_S, DT_I, 70000, GL_None); // LS
int DT = createDocType("POS Order", "Order Confirmation",
MDocType.DOCBASETYPE_SalesOrder, MDocType.DOCSUBTYPESO_POSOrder,
DT_SI, DT_II, 80000, GL_None); // Bar
// POS As Default for window SO
createPreference("C_DocTypeTarget_ID", String.valueOf(DT), 143);
// Update ClientInfo
sqlCmd = new StringBuffer ("UPDATE AD_ClientInfo SET ");
sqlCmd.append("C_AcctSchema1_ID=").append(m_as.getC_AcctSchema_ID())
.append(", C_Calendar_ID=").append(m_calendar.getC_Calendar_ID())
.append(" WHERE AD_Client_ID=").append(m_client.getAD_Client_ID());
no = DB.executeUpdate(sqlCmd.toString(), m_trx.getTrxName());
if (no != 1)
{
String err = "ClientInfo not updated";
log.log(Level.SEVERE, err);
m_info.append(err);
m_trx.rollback();
m_trx.close();
return false;
}
// Validate Completeness
DocumentTypeVerify.createDocumentTypes(m_ctx, getAD_Client_ID(), null, m_trx.getTrxName());
DocumentTypeVerify.createPeriodControls(m_ctx, getAD_Client_ID(), null, m_trx.getTrxName());
//
log.info("fini");
return true;
} // createAccounting
/**
* Get Account ID for key
* @param key key
* @return C_ValidCombination_ID
*/
private int getAcct (String key)
{
log.fine(key);
// Element
int C_ElementValue_ID = m_nap.getC_ElementValue_ID(key.toUpperCase());
if (C_ElementValue_ID == 0)
{
log.severe("Account not defined: " + key);
m_accountsOK = false;
return 0;
}
MAccount vc = MAccount.getDefault(m_as, true); // optional null
vc.setAD_Org_ID(0); // will be overwritten
vc.setAccount_ID(C_ElementValue_ID);
if (!vc.save())
{
log.severe("Not Saved - Key=" + key + ", C_ElementValue_ID=" + C_ElementValue_ID);
m_accountsOK = false;
return 0;
}
int C_ValidCombination_ID = vc.getC_ValidCombination_ID();
if (C_ValidCombination_ID == 0)
{
log.severe("No account - Key=" + key + ", C_ElementValue_ID=" + C_ElementValue_ID);
m_accountsOK = false;
}
return C_ValidCombination_ID;
} // getAcct
/**
* Create GL Category
* @param Name name
* @param CategoryType category type MGLCategory.CATEGORYTYPE_*
* @param isDefault is default value
* @return GL_Category_ID
*/
private int createGLCategory (String Name, String CategoryType, boolean isDefault)
{
MGLCategory cat = new MGLCategory (m_ctx, 0, m_trx.getTrxName());
cat.setName(Name);
cat.setCategoryType(CategoryType);
cat.setIsDefault(isDefault);
if (!cat.save())
{
log.log(Level.SEVERE, "GL Category NOT created - " + Name);
return 0;
}
//
return cat.getGL_Category_ID();
} // createGLCategory
/**
* Create Document Types with Sequence
* @param Name name
* @param PrintName print name
* @param DocBaseType document base type
* @param DocSubTypeSO sales order sub type
* @param C_DocTypeShipment_ID shipment doc
* @param C_DocTypeInvoice_ID invoice doc
* @param StartNo start doc no
* @param GL_Category_ID gl category
* @return C_DocType_ID doc type or 0 for error
*/
private int createDocType (String Name, String PrintName,
String DocBaseType, String DocSubTypeSO,
int C_DocTypeShipment_ID, int C_DocTypeInvoice_ID,
int StartNo, int GL_Category_ID)
{
MSequence sequence = null;
if (StartNo != 0)
{
sequence = new MSequence(m_ctx, getAD_Client_ID(), Name, StartNo, m_trx.getTrxName());
if (!sequence.save())
{
log.log(Level.SEVERE, "Sequence NOT created - " + Name);
return 0;
}
}
MDocType dt = new MDocType (m_ctx, DocBaseType, Name, m_trx.getTrxName());
if (PrintName != null && PrintName.length() > 0)
dt.setPrintName(PrintName); // Defaults to Name
if (DocSubTypeSO != null)
dt.setDocSubTypeSO(DocSubTypeSO);
if (C_DocTypeShipment_ID != 0)
dt.setC_DocTypeShipment_ID(C_DocTypeShipment_ID);
if (C_DocTypeInvoice_ID != 0)
dt.setC_DocTypeInvoice_ID(C_DocTypeInvoice_ID);
if (GL_Category_ID != 0)
dt.setGL_Category_ID(GL_Category_ID);
if (sequence == null)
dt.setIsDocNoControlled(false);
else
{
dt.setIsDocNoControlled(true);
dt.setDocNoSequence_ID(sequence.getAD_Sequence_ID());
}
dt.setIsSOTrx();
if (!dt.save())
{
log.log(Level.SEVERE, "DocType NOT created - " + Name);
return 0;
}
//
return dt.getC_DocType_ID();
} // createDocType
/**************************************************************************
* Create Default main entities.
* - Dimensions & BPGroup, Prod Category)
* - Location, Locator, Warehouse
* - PriceList
* - Cashbook, PaymentTerm
* @param C_Country_ID country
* @param City city
* @param C_Region_ID region
* @return true if created
*/
public boolean createEntities (int C_Country_ID, String City, int C_Region_ID, int C_Currency_ID)
{
if (m_as == null)
{
log.severe ("No AcctountingSChema");
m_trx.rollback();
m_trx.close();
return false;
}
log.info("C_Country_ID=" + C_Country_ID
+ ", City=" + City + ", C_Region_ID=" + C_Region_ID);
m_info.append("\n----\n");
//
String defaultName = Msg.translate(m_lang, "Standard");
String defaultEntry = "'" + defaultName + "',";
StringBuffer sqlCmd = null;
int no = 0;
// Create Marketing Channel/Campaign
int C_Channel_ID = getNextID(getAD_Client_ID(), "C_Channel");
sqlCmd = new StringBuffer("INSERT INTO C_Channel ");
sqlCmd.append("(C_Channel_ID,Name,");
sqlCmd.append(m_stdColumns).append(") VALUES (");
sqlCmd.append(C_Channel_ID).append(",").append(defaultEntry);
sqlCmd.append(m_stdValues).append(")");
no = DB.executeUpdate(sqlCmd.toString(), m_trx.getTrxName());
if (no != 1)
log.log(Level.SEVERE, "Channel NOT inserted");
int C_Campaign_ID = getNextID(getAD_Client_ID(), "C_Campaign");
sqlCmd = new StringBuffer("INSERT INTO C_Campaign ");
sqlCmd.append("(C_Campaign_ID,C_Channel_ID,").append(m_stdColumns).append(",");
sqlCmd.append(" Value,Name,Costs) VALUES (");
sqlCmd.append(C_Campaign_ID).append(",").append(C_Channel_ID).append(",").append(m_stdValues).append(",");
sqlCmd.append(defaultEntry).append(defaultEntry).append("0)");
no = DB.executeUpdate(sqlCmd.toString(), m_trx.getTrxName());
if (no == 1)
m_info.append(Msg.translate(m_lang, "C_Campaign_ID")).append("=").append(defaultName).append("\n");
else
log.log(Level.SEVERE, "Campaign NOT inserted");
if (m_hasMCampaign)
{
// Default
sqlCmd = new StringBuffer ("UPDATE C_AcctSchema_Element SET ");
sqlCmd.append("C_Campaign_ID=").append(C_Campaign_ID);
sqlCmd.append(" WHERE C_AcctSchema_ID=").append(m_as.getC_AcctSchema_ID());
sqlCmd.append(" AND ElementType='MC'");
no = DB.executeUpdate(sqlCmd.toString(), m_trx.getTrxName());
if (no != 1)
log.log(Level.SEVERE, "AcctSchema ELement Campaign NOT updated");
}
// Create Sales Region
int C_SalesRegion_ID = getNextID(getAD_Client_ID(), "C_SalesRegion");
sqlCmd = new StringBuffer ("INSERT INTO C_SalesRegion ");
sqlCmd.append("(C_SalesRegion_ID,").append(m_stdColumns).append(",");
sqlCmd.append(" Value,Name,IsSummary) VALUES (");
sqlCmd.append(C_SalesRegion_ID).append(",").append(m_stdValues).append(", ");
sqlCmd.append(defaultEntry).append(defaultEntry).append("'N')");
no = DB.executeUpdate(sqlCmd.toString(), m_trx.getTrxName());
if (no == 1)
m_info.append(Msg.translate(m_lang, "C_SalesRegion_ID")).append("=").append(defaultName).append("\n");
else
log.log(Level.SEVERE, "SalesRegion NOT inserted");
if (m_hasSRegion)
{
// Default
sqlCmd = new StringBuffer ("UPDATE C_AcctSchema_Element SET ");
sqlCmd.append("C_SalesRegion_ID=").append(C_SalesRegion_ID);
sqlCmd.append(" WHERE C_AcctSchema_ID=").append(m_as.getC_AcctSchema_ID());
sqlCmd.append(" AND ElementType='SR'");
no = DB.executeUpdate(sqlCmd.toString(), m_trx.getTrxName());
if (no != 1)
log.log(Level.SEVERE, "AcctSchema ELement SalesRegion NOT updated");
}
/**
* Business Partner
*/
// Create BP Group
MBPGroup bpg = new MBPGroup (m_ctx, 0, m_trx.getTrxName());
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -