IDEMPIERE-5320 Refactor unit test to use share constant for dictionary IDs (#1369)

This commit is contained in:
hengsin 2022-06-22 20:51:42 +08:00 committed by GitHub
parent 1873e175be
commit 006d47ce6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 1019 additions and 815 deletions

View File

@ -89,10 +89,14 @@ public class SystemIDs
public final static int PROCESS_C_INVOICE_GENERATE = 119;
public final static int PROCESS_C_INVOICE_GENERATE_MANUAL = 134;
public final static int PROCESS_C_INVOICE_GENERATERMA_MANUAL = 52002;
public final static int PROCESS_C_PAYSELECTION_CREATEPAYMENT = 155;
public final static int PROCESS_C_ORDER_PROCESS = 104;
public final static int PROCESS_C_PAYSELECTION_CREATEPAYMENT = 155;
public final static int PROCESS_M_INOUT_GENERATE = 118;
public final static int PROCESS_M_INOUT_GENERATE_MANUAL = 199;
public final static int PROCESS_M_INOUT_GENERATERMA_MANUAL = 52001;
public final static int PROCESS_M_MATCHPO_REVERSAL = 200016;
public final static int PROCESS_M_StorageCleanup = 325;
public final static int PROCESS_PP_PRODUCT_BOM = 136;
public final static int PROCESS_RPT_C_ORDER = 110;
public final static int PROCESS_RPT_C_PAYMENT = 313;
public final static int PROCESS_RPT_M_INOUT = 117;
@ -190,19 +194,25 @@ public class SystemIDs
public final static int WINDOW_ACCOUNTCOMBINATION = 153;
public final static int WINDOW_ATTRIBUTESETINSTANCE = 358;
public final static int WINDOW_BUSINESS_PARTNER = 123;
public static final int WINDOW_CHART = 53124;
public final static int WINDOW_CUSTOMERRETURN = 53097;
public final static int WINDOW_IMAGE = 227;
public final static int WINDOW_INVOICE_CUSTOMER = 167;
public final static int WINDOW_LOCATION = 121;
public final static int WINDOW_LOCATOR = 139;
public final static int WINDOW_LOT = 257;
public final static int WINDOW_MATERIALTRANSACTIONS_INDIRECTUSER = 223;
public final static int WINDOW_MY_REQUESTS = 237;
public final static int WINDOW_NOTICE = 193;
public final static int WINDOW_REQUEST = 201;
public final static int WINDOW_REQUESTS_ALL = 232;
public final static int WINDOW_RESOURCE = 236;
public final static int WINDOW_RETURNTOVENDOR = 53098;
public final static int WINDOW_SALES_ORDER = 143;
public final static int WINDOW_WAREHOUSE_LOCATOR = 139;
public final static int WINDOW_WINDOW_TAB_FIELD = 102;
public final static int WINDOW_WORKFLOW_ACTIVITIES = 298;
public final static int TAB_TAB = 106;

View File

@ -34,6 +34,47 @@ public final class DictionaryIDs {
private DictionaryIDs() {
}
public enum AD_Org {
HQ(11),
STORE_CENTRAL(12),
FURNITURE(50000),
FERTILIZER(50001),
STORE_NORTH(50002),
STORE_SOUTH(50004),
STORE_EAST(50005),
STORE_WEST(50006),
STORES(50007);
public final int id;
private AD_Org(int id) {
this.id = id;
}
}
public enum AD_Role {
GARDEN_WORLD_ADMIN(102),
GARDEN_WORLD_USER(103),
GARDEN_WORLD_ADMIN_NOT_ADVANCED(200001);
public final int id;
private AD_Role(int id) {
this.id = id;
}
}
public enum AD_User {
GARDEN_ADMIN(101),
GARDEN_USER(102);
public final int id;
private AD_User(int id) {
this.id = id;
}
}
public enum C_BankAccount {
ACCOUNT_1234(100),
ACCOUNT_5678(101),
@ -88,7 +129,10 @@ public final class DictionaryIDs {
public enum C_Currency {
USD(100),
EUR(102);
EUR(102),
JPY(113),
GBP(114),
AUD(120);
public final int id;
@ -100,13 +144,48 @@ public final class DictionaryIDs {
public enum C_DocType {
GL_JOURNAL(115),
AR_INVOICE(116),
AR_INVOICE_INDIRECT(117),
AR_CREDIT_MEMO(118),
AR_RECEIPT(119),
MM_SHIPMENT(120),
MM_SHIPMENT_INDIRECT(121),
MM_RECEIPT(122),
AP_INVOICE(123),
AP_CREDIT_MEMO(124),
AP_PAYMENT(125);
AP_PAYMENT(125),
PURCHASE_ORDER(126),
PURCHASE_REQUISITION(127),
QUOTATION(128),
PROPOSAL(129),
PREPAY_ORDER(130),
CUSTOMER_RETURN_MATERIAL(131),
STANDARD_ORDER(132),
ON_CREDIT_ORDER(133),
WAREHOUSE_ORDER(134),
POS_ORDER(135),
PROJECT_ISSUE(136),
PAYMENT_ALLOCATION(137),
MATCH_INVOICE(138),
MATERIAL_PRODUCTION(139),
GL_DOCUMENT(140),
CASH_JOURNAL(141),
MATCH_PO(142),
MATERIAL_MOVEMENT(143),
MATERIAL_PHYSICAL_INVENTORY(144),
AR_PRO_FORMA_INVOICE(145),
BANK_STATEMENT(146),
MM_RECEIPT_WITH_CONFIRMATION(147),
MM_SHIPMENT_WITH_PICK(148),
MM_CUSTOMER_RETURN(149),
VENDOR_RETURN_MATERIAL(150),
MM_VENDOR_RETURN(151),
INTERNAL_USE_INVENTORY(200000),
ASSET_ADDITION(200001),
ASSET_DEPRECIATION(200002),
ASSET_DISPOSAL(200003),
COST_ADJUSTMENT(200004),
WAREHOUSE_PURCHASE_ORDER(200026),
POINT_OF_PURCHASE_ORDER(200027);
public final int id;
@ -128,6 +207,41 @@ public final class DictionaryIDs {
}
}
public enum C_Phase {
INITIAL_NEED_EVALUATION(100),
CRITICAL_OPERATION(101),
INITIAL_SCOPE_DEFINITION(102),
DESIGN(103),
IMPLEMENTATION(104),
INITIAL_CONTACT(105),
INITIAL_QUALIFICATION(106),
INITIAL_SALES_PRESENTATION(107),
INITIAL_SCOPE(108),
FIRST_PRODUCT_PRESENTATION(109),
PAID_SCOPE_STUDY(110),
CONTRACT_NEGOTIATION(111),
CLOSED(112);
public final int id;
private C_Phase(int id) {
this.id = id;
}
}
public enum C_ProjectType {
IMPLEMENTATION(100),
CONSULTING(101),
IDEMPIERE_PRESALES(102),
WORK_ORDER(103);
public final int id;
private C_ProjectType(int id) {
this.id = id;
}
}
public enum C_Tax {
STANDARD(104),
CT_SALES(105),
@ -143,6 +257,96 @@ public final class DictionaryIDs {
}
}
public enum C_TaxCategory {
STANDARD(107);
public final int id;
private C_TaxCategory(int id) {
this.id = id;
}
}
public enum C_UOM {
EACH(100),
HOUR(101),
DAY(102),
MINUTES(103),
WORK_DAY(104),
WEEK(105),
MONTH(106),
WORKING_MONTH(107),
YEAR(108),
SIX_PACK(109),
MILILITER(50000),
KILOGRAM(50001),
MILLIGRAM(50002),
LITRE(50003),
CENTIMETER(200001);
public final int id;
private C_UOM(int id) {
this.id = id;
}
}
public enum M_Attribute {
SIZE(100),
COLOR(101),
USE_FACTOR(102),
USE_DESCRIPTION(103);
public final int id;
private M_Attribute(int id) {
this.id = id;
}
}
public enum M_AttributeSet {
T_SHIRT(100),
FERTILIZER_LOT(101),
PATIO_CHAIR(102);
public final int id;
private M_AttributeSet(int id) {
this.id = id;
}
}
public enum M_DiscountSchema {
SALES_2001(100),
PURCHASE_2001(101),
FIVE_PERCENT_DISCOUNT(102);
public final int id;
private M_DiscountSchema(int id) {
this.id = id;
}
}
public enum M_Locator {
HQ(101),
STORE(102),
HQ_TRANSIT(50000),
FERTILIZER(50001),
STORE_NORTH(50002),
FURNITURE(50003),
STORE_EAST(50004),
STORE_WEST(50005),
FERTILIZER_TRANSIT(50006),
FURNITURE_TRANSIT(50007);
public final int id;
private M_Locator(int id) {
this.id = id;
}
}
public enum M_PriceList {
STANDARD(101),
PURCHASE(102),
@ -155,4 +359,93 @@ public final class DictionaryIDs {
this.id = id;
}
}
public enum M_Product {
STANDARD(122),
OAK(123),
ELM(124),
GRASS(125),
PLANTING(126),
ROSE_BUSH(127),
AZALEA_BUSH(128),
HOLLY_BUSH(129),
PLUM_TREE(130),
TRAVEL(131),
MARY(132),
P_CHAIR(133),
P_TABLE(134),
SCREEN(135),
FERTILIZER_50(136),
MULCH(137),
HOE(138),
RAKE_BAMBOO(139),
RAKE_METAL(140),
WEEDER(141),
TRANSPLANTER(142),
SEEDER(143),
TILLER(144),
PATIOSET(145),
DOC(146),
TSHIRT_RL(147),
TSHIRT_GL(148);
public final int id;
private M_Product(int id) {
this.id = id;
}
}
public enum M_Product_Category {
STANDARD(105),
TREE(106),
BUSH(107),
TOOLS(108),
CHEMICALS(109),
PATIO(110),
DOC(111),
TRAINING(112),
ASSEMBLY(50000),
RAW_MATERIAL(50001),
PACKING(50002),
RESOURCES(50003),
ASSET_VEHICLE(200000),
ASSET_COMPUTERS(200001);
public final int id;
private M_Product_Category(int id) {
this.id = id;
}
}
public enum M_RMAType {
DAMAGE_ON_ARRIVAL(100);
public final int id;
private M_RMAType(int id) {
this.id = id;
}
}
public enum M_Warehouse {
HQ(103),
STORE_CENTRAL(104),
HQT(50000),
FURNITURE(50001),
FERTILIZER(50002),
STORE_NORTH(50003),
STORE_SOUTH(50004),
STORE_EAST(50005),
STORE_WEST(50006),
FERTILIZER_T(50007),
FURNITURE_T(50008);
public final int id;
private M_Warehouse(int id) {
this.id = id;
}
}
}

View File

@ -36,8 +36,10 @@ import org.compiere.model.GridWindowVO;
import org.compiere.model.MBPartner;
import org.compiere.model.MOrder;
import org.compiere.model.MQuery;
import org.compiere.model.SystemIDs;
import org.compiere.util.Env;
import org.idempiere.test.AbstractTestCase;
import org.idempiere.test.DictionaryIDs;
import org.junit.jupiter.api.Test;
/**
@ -47,26 +49,19 @@ import org.junit.jupiter.api.Test;
*/
public class GridTabTest extends AbstractTestCase {
////Business Partner Job Block
private final static int BP_JOE_BLOCK = 118;
//Business Partner Window
private final static int BP_WINDOW_ID = 123;
//Sales Order Window
private final static int SO_WINDOW_ID = 143;
public GridTabTest() {
}
@Test
public void testQuery() {
int AD_Window_ID = BP_WINDOW_ID;
int AD_Window_ID = SystemIDs.WINDOW_BUSINESS_PARTNER;
var gWindowVO = GridWindowVO.create (Env.getCtx(), 1, AD_Window_ID);
var gridWindow = new GridWindow(gWindowVO, true);
int tabCount = gridWindow.getTabCount();
assertTrue(tabCount > 0, "Tab Count is Zero. AD_Window_ID="+AD_Window_ID);
MQuery query = new MQuery(MBPartner.Table_Name);
query.addRestriction(MBPartner.COLUMNNAME_C_BPartner_ID, MQuery.EQUAL, BP_JOE_BLOCK);
query.addRestriction(MBPartner.COLUMNNAME_C_BPartner_ID, MQuery.EQUAL, DictionaryIDs.C_BPartner.JOE_BLOCK.id);
for(int i = 0; i < gridWindow.getTabCount(); i++) {
gridWindow.initTab(i);
@ -84,14 +79,14 @@ public class GridTabTest extends AbstractTestCase {
assertTrue(gTab.getRowCount()==1, "GridTab Row Count is not 1. GridTab="+gTab.getName());
String name = (String) gTab.getValue("Name");
MBPartner bpartner = new MBPartner(Env.getCtx(), BP_JOE_BLOCK, getTrxName());
MBPartner bpartner = new MBPartner(Env.getCtx(), DictionaryIDs.C_BPartner.JOE_BLOCK.id, getTrxName());
assertTrue(bpartner.getName().equals(name), "GridTab Name != MBPartner.getName(). GridTab.Name="+name + " MBPartner.getName="+bpartner.getName());
}
@Test
public void testCallout() {
//Sales Order
int AD_Window_ID = SO_WINDOW_ID;
int AD_Window_ID = SystemIDs.WINDOW_SALES_ORDER;
var gWindowVO = GridWindowVO.create (Env.getCtx(), 1, AD_Window_ID);
var gridWindow = new GridWindow(gWindowVO, true);
int tabCount = gridWindow.getTabCount();
@ -116,12 +111,12 @@ public class GridTabTest extends AbstractTestCase {
//initial value of Bill_BPartner_ID should be null
assertNull(gTab.getValue(MOrder.COLUMNNAME_Bill_BPartner_ID), "Bill_BPartner_ID not null");
gTab.setValue(MOrder.COLUMNNAME_C_BPartner_ID, BP_JOE_BLOCK);
gTab.setValue(MOrder.COLUMNNAME_C_BPartner_ID, DictionaryIDs.C_BPartner.JOE_BLOCK.id);
//set C_BPartner_ID to BP_JOE_BLOCK
Object value = gTab.getValue(MOrder.COLUMNNAME_C_BPartner_ID);
assertNotNull(value, "C_BPartner_ID is null");
assertEquals(BP_JOE_BLOCK, ((Number)value).intValue(), "C_BPartner_ID not equals to " + BP_JOE_BLOCK);
assertEquals(DictionaryIDs.C_BPartner.JOE_BLOCK.id, ((Number)value).intValue(), "C_BPartner_ID not equals to " + DictionaryIDs.C_BPartner.JOE_BLOCK.id);
//invoke org.compiere.model.CalloutOrder.bPartner
GridField mField = gTab.getField(MOrder.COLUMNNAME_C_BPartner_ID);
@ -130,13 +125,13 @@ public class GridTabTest extends AbstractTestCase {
//org.compiere.model.CalloutOrder.bPartner should set Bill_BPartner_ID to BP_JOE_BLOCK
value = gTab.getValue(MOrder.COLUMNNAME_Bill_BPartner_ID);
assertNotNull(value, "Bill_BPartner_ID is null");
assertEquals(BP_JOE_BLOCK, ((Number)value).intValue(), "Bill_BPartner_ID not equals to " + BP_JOE_BLOCK);
assertEquals(DictionaryIDs.C_BPartner.JOE_BLOCK.id, ((Number)value).intValue(), "Bill_BPartner_ID not equals to " + DictionaryIDs.C_BPartner.JOE_BLOCK.id);
}
@Test
public void testUpdate() {
//Business Partner
int AD_Window_ID = BP_WINDOW_ID;
int AD_Window_ID = SystemIDs.WINDOW_BUSINESS_PARTNER;
var gWindowVO = GridWindowVO.create (Env.getCtx(), 1, AD_Window_ID);
var gridWindow = new GridWindow(gWindowVO, true);
int tabCount = gridWindow.getTabCount();
@ -144,7 +139,7 @@ public class GridTabTest extends AbstractTestCase {
//retrieve for update
MQuery query = new MQuery(MBPartner.Table_Name);
query.addRestriction(MBPartner.COLUMNNAME_C_BPartner_ID, MQuery.EQUAL, BP_JOE_BLOCK);
query.addRestriction(MBPartner.COLUMNNAME_C_BPartner_ID, MQuery.EQUAL, DictionaryIDs.C_BPartner.JOE_BLOCK.id);
for(int i = 0; i < gridWindow.getTabCount(); i++) {
gridWindow.initTab(i);
@ -162,7 +157,7 @@ public class GridTabTest extends AbstractTestCase {
assertTrue(gTab.getRowCount()==1, "GridTab Row Count is not 1. GridTab="+gTab.getName());
String name = (String) gTab.getValue("Name");
MBPartner bpartner = new MBPartner(Env.getCtx(), BP_JOE_BLOCK, getTrxName());
MBPartner bpartner = new MBPartner(Env.getCtx(), DictionaryIDs.C_BPartner.JOE_BLOCK.id, getTrxName());
assertTrue(bpartner.getName().equals(name), "GridTab Name != MBPartner.getName(). GridTab.Name="+name + " MBPartner.getName="+bpartner.getName());
//use trx to perform update

View File

@ -34,8 +34,10 @@ import org.compiere.model.MDocumentStatusAccess;
import org.compiere.model.MEntityType;
import org.compiere.model.MInvoice;
import org.compiere.model.MOrder;
import org.compiere.model.SystemIDs;
import org.compiere.util.Env;
import org.idempiere.test.AbstractTestCase;
import org.idempiere.test.DictionaryIDs;
import org.junit.jupiter.api.Test;
/**
* Unit test cases for document status indicator
@ -47,19 +49,6 @@ public class DocumentStatusTest extends AbstractTestCase {
public DocumentStatusTest() {
}
private static final int USER_GARDENADMIN = 101;
private static final int USER_GARDENUSER = 102;
private static final int USER_SUPERUSER = 100;
private static final int ROLE_GARDENWORLDADMIN = 102;
private static final int ROLE_GARDENWORLDUSER = 103;
private static final int ROLE_GARDENWORLD_ADMIN_NOT_ADVANCED = 200001;
private static final int WINDOW_ID_INVOICE_CUSTOMER = 167;
private static final int WINDOW_ID_NOTICE = 193;
private static final int WINDOW_ID_REQUEST = 201;
private static final int WINDOW_ID_WF_ACTIVITIES = 298;
/**
* https://idempiere.atlassian.net/browse/IDEMPIERE-4836
* Unit testing for Document access test as per DocumentStatusAccess
@ -72,14 +61,14 @@ public class DocumentStatusTest extends AbstractTestCase {
invoiceDS.setName("Invoice Document Status Unit Test");
invoiceDS.setEntityType(MEntityType.ENTITYTYPE_Dictionary);
invoiceDS.setAD_Table_ID(MInvoice.Table_ID);
invoiceDS.setAD_Window_ID(WINDOW_ID_INVOICE_CUSTOMER);
invoiceDS.setAD_Window_ID(SystemIDs.WINDOW_INVOICE_CUSTOMER);
invoiceDS.setSeqNo(10);
invoiceDS.saveEx();
MDocumentStatusAccess invoiceDSAccess = new MDocumentStatusAccess(Env.getCtx(),0, getTrxName());
invoiceDSAccess.setPA_DocumentStatus_ID(invoiceDS.get_ID());
invoiceDSAccess.setAD_User_ID(USER_GARDENADMIN);
invoiceDSAccess.setAD_Role_ID(ROLE_GARDENWORLDADMIN);
invoiceDSAccess.setAD_User_ID(DictionaryIDs.AD_User.GARDEN_ADMIN.id);
invoiceDSAccess.setAD_Role_ID(DictionaryIDs.AD_Role.GARDEN_WORLD_ADMIN.id);
invoiceDSAccess.saveEx();
@ -88,7 +77,7 @@ public class DocumentStatusTest extends AbstractTestCase {
noticeDS.setName("Notice Document Status Unit Test");
noticeDS.setEntityType(MEntityType.ENTITYTYPE_Dictionary);
noticeDS.setAD_Table_ID(MOrder.Table_ID);
noticeDS.setAD_Window_ID(WINDOW_ID_NOTICE);
noticeDS.setAD_Window_ID(SystemIDs.WINDOW_NOTICE);
noticeDS.setSeqNo(20);
noticeDS.saveEx();
@ -97,13 +86,13 @@ public class DocumentStatusTest extends AbstractTestCase {
requestDS.setName("Request Document Status Unit Test");
requestDS.setEntityType(MEntityType.ENTITYTYPE_Dictionary);
requestDS.setAD_Table_ID(MInvoice.Table_ID);
requestDS.setAD_Window_ID(WINDOW_ID_REQUEST);
requestDS.setAD_Window_ID(SystemIDs.WINDOW_REQUEST);
requestDS.setSeqNo(30);
requestDS.saveEx();
MDocumentStatusAccess requestDSAccess = new MDocumentStatusAccess(Env.getCtx(),0, getTrxName());
requestDSAccess.setPA_DocumentStatus_ID(requestDS.get_ID());
requestDSAccess.setAD_Role_ID( ROLE_GARDENWORLDUSER);
requestDSAccess.setAD_Role_ID(DictionaryIDs.AD_Role.GARDEN_WORLD_USER.id);
requestDSAccess.saveEx();
/* Document Status with specific role access */
@ -111,18 +100,18 @@ public class DocumentStatusTest extends AbstractTestCase {
WorkflowActivitiesDS.setName("Workflow Activities Document Status Unit Test");
WorkflowActivitiesDS.setEntityType(MEntityType.ENTITYTYPE_Dictionary);
WorkflowActivitiesDS.setAD_Table_ID(MInvoice.Table_ID);
WorkflowActivitiesDS.setAD_Window_ID(WINDOW_ID_WF_ACTIVITIES);
WorkflowActivitiesDS.setAD_Window_ID(SystemIDs.WINDOW_WORKFLOW_ACTIVITIES);
WorkflowActivitiesDS.setSeqNo(40);
WorkflowActivitiesDS.saveEx();
MDocumentStatusAccess WorkflowActivitiesDSAccess = new MDocumentStatusAccess(Env.getCtx(),0, getTrxName());
WorkflowActivitiesDSAccess.setPA_DocumentStatus_ID(WorkflowActivitiesDS.get_ID());
WorkflowActivitiesDSAccess.setAD_User_ID(USER_GARDENADMIN);
WorkflowActivitiesDSAccess.setAD_User_ID(DictionaryIDs.AD_User.GARDEN_ADMIN.id);
WorkflowActivitiesDSAccess.saveEx();
// check document status accessibility with user- GardenAdmin and role- GardenWorld Admin
MDocumentStatus[] documentStatusIndicators = MDocumentStatus.getDocumentStatusIndicators(Env.getCtx(),
USER_GARDENADMIN, ROLE_GARDENWORLDADMIN, getTrxName());
DictionaryIDs.AD_User.GARDEN_ADMIN.id, DictionaryIDs.AD_Role.GARDEN_WORLD_ADMIN.id, getTrxName());
assertTrue(Arrays.asList(documentStatusIndicators).contains(invoiceDS), "Either User or Role Assignment matching");
assertTrue(Arrays.asList(documentStatusIndicators).contains(noticeDS), "No permission assigned, should visible to every one");
assertFalse(Arrays.asList(documentStatusIndicators).contains(requestDS),
@ -131,8 +120,8 @@ public class DocumentStatusTest extends AbstractTestCase {
"User is assigned, Should Visible");
// check document status accessibility with user- GardenAdmin and role- GardenWorld User
documentStatusIndicators = MDocumentStatus.getDocumentStatusIndicators(Env.getCtx(), USER_GARDENADMIN,
ROLE_GARDENWORLDUSER, getTrxName());
documentStatusIndicators = MDocumentStatus.getDocumentStatusIndicators(Env.getCtx(), DictionaryIDs.AD_User.GARDEN_ADMIN.id,
DictionaryIDs.AD_Role.GARDEN_WORLD_USER.id, getTrxName());
assertFalse(Arrays.asList(documentStatusIndicators).contains(invoiceDS),
"User Assignment Match but role do not");
assertTrue(Arrays.asList(documentStatusIndicators).contains(noticeDS), "No permission assigned, should visible to every one");
@ -141,8 +130,8 @@ public class DocumentStatusTest extends AbstractTestCase {
"User is assigned, Should Visible");
// check document status accessibility with user- GardenUser and role- GardenWorld User
documentStatusIndicators = MDocumentStatus.getDocumentStatusIndicators(Env.getCtx(), USER_GARDENUSER,
ROLE_GARDENWORLDUSER, getTrxName());
documentStatusIndicators = MDocumentStatus.getDocumentStatusIndicators(Env.getCtx(), DictionaryIDs.AD_User.GARDEN_USER.id,
DictionaryIDs.AD_Role.GARDEN_WORLD_USER.id, getTrxName());
assertFalse(Arrays.asList(documentStatusIndicators).contains(invoiceDS),
"Invoice Document Status Not Visible For User Garden Admin and Role GardenWorld User");
assertTrue(Arrays.asList(documentStatusIndicators).contains(noticeDS), "No permission assigned, should visible to every one");
@ -151,8 +140,8 @@ public class DocumentStatusTest extends AbstractTestCase {
"User is assigned, Should not Visible");
// check document status accessibility with user- SuperUser and role- GardenWorld Admin Not Advanced
documentStatusIndicators = MDocumentStatus.getDocumentStatusIndicators(Env.getCtx(), USER_SUPERUSER,
ROLE_GARDENWORLD_ADMIN_NOT_ADVANCED, getTrxName());
documentStatusIndicators = MDocumentStatus.getDocumentStatusIndicators(Env.getCtx(), SystemIDs.USER_SUPERUSER,
DictionaryIDs.AD_Role.GARDEN_WORLD_ADMIN_NOT_ADVANCED.id, getTrxName());
assertFalse(Arrays.asList(documentStatusIndicators).contains(invoiceDS),
"Niether User or Role Assignment match, Should not visible");
assertTrue(Arrays.asList(documentStatusIndicators).contains(noticeDS), "No permission assigned, should visible to every one");

View File

@ -55,6 +55,7 @@ import org.compiere.model.MShippingProcessor;
import org.compiere.model.MWarehouse;
import org.compiere.model.PO;
import org.compiere.model.Query;
import org.compiere.model.SystemIDs;
import org.compiere.model.X_C_BP_ShippingAcct;
import org.compiere.model.X_M_ShippingProcessorCfg;
import org.compiere.process.DocAction;
@ -64,6 +65,7 @@ import org.compiere.util.Env;
import org.compiere.util.TimeUtil;
import org.compiere.wf.MWorkflow;
import org.idempiere.test.AbstractTestCase;
import org.idempiere.test.DictionaryIDs;
import org.junit.jupiter.api.Test;
/**
@ -71,8 +73,6 @@ import org.junit.jupiter.api.Test;
*/
public class InOutTest extends AbstractTestCase {
private final static int BP_JOE_BLOCK_ID = 118;
public InOutTest() {
}
@ -81,22 +81,22 @@ public class InOutTest extends AbstractTestCase {
* https://idempiere.atlassian.net/browse/IDEMPIERE-4656
*/
public void testMatReceiptPosting() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 114); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), 124); // Elm Tree
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.TREE_FARM.id); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.ELM.id); // Elm Tree
Timestamp currentDate = Env.getContextAsDate(Env.getCtx(), "#Date");
int Spot_ConversionType_ID = 114; // Spot;
int Company_ConversionType_ID = 201; // Company
int Spot_ConversionType_ID = DictionaryIDs.C_ConversionType.SPOT.id; // Spot;
int Company_ConversionType_ID = DictionaryIDs.C_ConversionType.COMPANY.id; // Company
MPriceList priceList = new MPriceList(Env.getCtx(), 0, null);
priceList.setName("Purchase AUD " + System.currentTimeMillis());
MCurrency australianDollar = MCurrency.get("AUD"); // Australian Dollar (AUD)
MCurrency australianDollar = MCurrency.get(DictionaryIDs.C_Currency.AUD.id); // Australian Dollar (AUD)
priceList.setC_Currency_ID(australianDollar.getC_Currency_ID());
priceList.setPricePrecision(australianDollar.getStdPrecision());
priceList.saveEx();
MPriceListVersion plv = new MPriceListVersion(priceList);
plv.setM_DiscountSchema_ID(101); // Purchase 2001
plv.setM_DiscountSchema_ID(DictionaryIDs.M_DiscountSchema.PURCHASE_2001.id); // Purchase 2001
plv.setValidFrom(currentDate);
plv.saveEx();
@ -104,13 +104,13 @@ public class InOutTest extends AbstractTestCase {
MProductPrice pp = new MProductPrice(plv, product.getM_Product_ID(), priceInAud, priceInAud, Env.ZERO);
pp.saveEx();
MCurrency usd = MCurrency.get("USD"); // USD
MCurrency usd = MCurrency.get(DictionaryIDs.C_Currency.USD.id); // USD
BigDecimal audToUsdCompany = new BigDecimal(0.676234);
MConversionRate crUsdCompany = createConversionRate(australianDollar.getC_Currency_ID(), usd.getC_Currency_ID(), Company_ConversionType_ID, currentDate, audToUsdCompany);
BigDecimal audToUsdSpot = new BigDecimal(0.77);
MConversionRate crUsdSpot = createConversionRate(australianDollar.getC_Currency_ID(), usd.getC_Currency_ID(), Spot_ConversionType_ID, currentDate, audToUsdSpot);
MCurrency euro = MCurrency.get("EUR"); // EUR
MCurrency euro = MCurrency.get(DictionaryIDs.C_Currency.EUR.id); // EUR
BigDecimal audToEuroCompany = new BigDecimal(0.746234);
MConversionRate crEurCompany = createConversionRate(australianDollar.getC_Currency_ID(), euro.getC_Currency_ID(), Company_ConversionType_ID, currentDate, audToEuroCompany);
BigDecimal audToEuroSpot = new BigDecimal(0.64);
@ -216,21 +216,21 @@ public class InOutTest extends AbstractTestCase {
* https://idempiere.atlassian.net/browse/IDEMPIERE-4656
*/
public void testMatShipmentPosting() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 114); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), 124); // Elm Tree
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.TREE_FARM.id); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.ELM.id); // Elm Tree
Timestamp currentDate = Env.getContextAsDate(Env.getCtx(), "#Date");
int Company_ConversionType_ID = 201; // Company
int Company_ConversionType_ID = DictionaryIDs.C_ConversionType.COMPANY.id; // Company
MPriceList priceList = new MPriceList(Env.getCtx(), 0, null);
priceList.setName("Purchase AUD " + System.currentTimeMillis());
MCurrency australianDollar = MCurrency.get("AUD"); // Australian Dollar (AUD)
MCurrency australianDollar = MCurrency.get(DictionaryIDs.C_Currency.AUD.id); // Australian Dollar (AUD)
priceList.setC_Currency_ID(australianDollar.getC_Currency_ID());
priceList.setPricePrecision(australianDollar.getStdPrecision());
priceList.saveEx();
MPriceListVersion plv = new MPriceListVersion(priceList);
plv.setM_DiscountSchema_ID(101); // Purchase 2001
plv.setM_DiscountSchema_ID(DictionaryIDs.M_DiscountSchema.PURCHASE_2001.id); // Purchase 2001
plv.setValidFrom(currentDate);
plv.saveEx();
@ -238,11 +238,11 @@ public class InOutTest extends AbstractTestCase {
MProductPrice pp = new MProductPrice(plv, product.getM_Product_ID(), priceInAud, priceInAud, Env.ZERO);
pp.saveEx();
MCurrency usd = MCurrency.get("USD"); // USD
MCurrency usd = MCurrency.get(DictionaryIDs.C_Currency.USD.id); // USD
BigDecimal audToUsdCompany = new BigDecimal(0.676234);
MConversionRate crUsdCompany = createConversionRate(australianDollar.getC_Currency_ID(), usd.getC_Currency_ID(), Company_ConversionType_ID, currentDate, audToUsdCompany);
MCurrency euro = MCurrency.get("EUR"); // EUR
MCurrency euro = MCurrency.get(DictionaryIDs.C_Currency.EUR.id); // EUR
BigDecimal audToEuroCompany = new BigDecimal(0.746234);
MConversionRate crEurCompany = createConversionRate(australianDollar.getC_Currency_ID(), euro.getC_Currency_ID(), Company_ConversionType_ID, currentDate, audToEuroCompany);
try {
@ -290,11 +290,11 @@ public class InOutTest extends AbstractTestCase {
MRMA rma = new MRMA(Env.getCtx(), 0, getTrxName());
rma.setName(order.getDocumentNo());
rma.setC_DocType_ID(150); // Vendor Return Material
rma.setM_RMAType_ID(100); // Damaged on Arrival
rma.setC_DocType_ID(DictionaryIDs.C_DocType.VENDOR_RETURN_MATERIAL.id); // Vendor Return Material
rma.setM_RMAType_ID(DictionaryIDs.M_RMAType.DAMAGE_ON_ARRIVAL.id); // Damaged on Arrival
rma.setM_InOut_ID(receipt.get_ID());
rma.setIsSOTrx(false);
rma.setSalesRep_ID(100); // SuperUser
rma.setSalesRep_ID(SystemIDs.USER_SUPERUSER); // SuperUser
rma.saveEx();
MRMALine rmaLine = new MRMALine(Env.getCtx(), 0, getTrxName());
@ -311,7 +311,7 @@ public class InOutTest extends AbstractTestCase {
delivery.setBPartner(bpartner);
delivery.setIsSOTrx(false);
delivery.setMovementType(MInOut.MOVEMENTTYPE_VendorReturns);
delivery.setC_DocType_ID(151); // MM Vendor Return
delivery.setC_DocType_ID(DictionaryIDs.C_DocType.MM_VENDOR_RETURN.id); // MM Vendor Return
delivery.setDocStatus(DocAction.STATUS_Drafted);
delivery.setDocAction(DocAction.ACTION_Complete);
delivery.setM_Warehouse_ID(receipt.getM_Warehouse_ID());
@ -431,7 +431,7 @@ public class InOutTest extends AbstractTestCase {
}
private MInOut createMMReceipt(MOrder order, Timestamp date) {
MInOut receipt = new MInOut(order, 122, date); // MM Receipt
MInOut receipt = new MInOut(order, DictionaryIDs.C_DocType.MM_RECEIPT.id, date); // MM Receipt
receipt.saveEx();
return receipt;
}
@ -469,7 +469,7 @@ public class InOutTest extends AbstractTestCase {
@Test
public void testFreightCostRuleCustomerAccount() {
MOrder order = new MOrder(Env.getCtx(), 0, getTrxName());
order.setBPartner(MBPartner.get(Env.getCtx(), BP_JOE_BLOCK_ID));
order.setBPartner(MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.JOE_BLOCK.id));
order.setC_DocTypeTarget_ID(MOrder.DocSubTypeSO_Standard);
order.setDeliveryRule(MOrder.DELIVERYRULE_CompleteOrder);
order.setDocStatus(DocAction.STATUS_Drafted);
@ -500,7 +500,7 @@ public class InOutTest extends AbstractTestCase {
final String shipperAccount = "testFreightCostRuleCustomerAccount";
MBPartner bp = new MBPartner(Env.getCtx(), BP_JOE_BLOCK_ID, getTrxName());
MBPartner bp = new MBPartner(Env.getCtx(), DictionaryIDs.C_BPartner.JOE_BLOCK.id, getTrxName());
X_C_BP_ShippingAcct acct = new X_C_BP_ShippingAcct(Env.getCtx(), 0, getTrxName());
acct.setC_BPartner_ID(bp.getC_BPartner_ID());
acct.setShipperAccount(shipperAccount);

View File

@ -50,6 +50,7 @@ import org.compiere.util.Env;
import org.compiere.util.TimeUtil;
import org.compiere.wf.MWorkflow;
import org.idempiere.test.AbstractTestCase;
import org.idempiere.test.DictionaryIDs;
import org.junit.jupiter.api.Test;
/**
@ -59,15 +60,12 @@ import org.junit.jupiter.api.Test;
*/
public class MStorageTest extends AbstractTestCase {
private static final int BP_JOE_BLOCK = 118;
private static final int PRODUCT_AZALEA = 128;
public MStorageTest() {
}
@Test
public void testStorageOnHandAndReservation() {
MProduct azalea = MProduct.get(Env.getCtx(), PRODUCT_AZALEA);
MProduct azalea = MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.AZALEA_BUSH.id);
BigDecimal onhandForReservation = MStorageOnHand.getQtyOnHandForReservation(azalea.getM_Product_ID(), getM_Warehouse_ID(), 0, getTrxName());
BigDecimal onhandForShipping = MStorageOnHand.getQtyOnHandForShipping(azalea.getM_Product_ID(), getM_Warehouse_ID(), 0, getTrxName());
@ -76,7 +74,7 @@ public class MStorageTest extends AbstractTestCase {
MOrder order = new MOrder(Env.getCtx(), 0, getTrxName());
//Joe Block
order.setBPartner(MBPartner.get(Env.getCtx(), BP_JOE_BLOCK));
order.setBPartner(MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.JOE_BLOCK.id));
order.setC_DocTypeTarget_ID(MOrder.DocSubTypeSO_Standard);
order.setDeliveryRule(MOrder.DELIVERYRULE_CompleteOrder);
order.setDocStatus(DocAction.STATUS_Drafted);
@ -106,7 +104,7 @@ public class MStorageTest extends AbstractTestCase {
BigDecimal availableForReservation1 = MStorageReservation.getQtyAvailable(getM_Warehouse_ID(), azalea.getM_Product_ID(), 0, getTrxName());
assertTrue(availableForReservation1.compareTo(availableForReservation) < 0, "Qty available for reservation doesn't reduce as expected (Before=" + availableForReservation.toPlainString() + " After=" + availableForReservation1.toPlainString());
MInOut shipment = new MInOut(order, 120, order.getDateOrdered());
MInOut shipment = new MInOut(order, DictionaryIDs.C_DocType.MM_SHIPMENT.id, order.getDateOrdered());
shipment.setDocStatus(DocAction.STATUS_Drafted);
shipment.setDocAction(DocAction.ACTION_Complete);
shipment.saveEx();
@ -153,7 +151,7 @@ public class MStorageTest extends AbstractTestCase {
MMovement movement = new MMovement(Env.getCtx(), 0, getTrxName());
//143 | Material Movement
movement.setC_DocType_ID(143);
movement.setC_DocType_ID(DictionaryIDs.C_DocType.MATERIAL_MOVEMENT.id);
movement.setDocAction(DocAction.ACTION_Complete);
movement.saveEx();

View File

@ -66,6 +66,7 @@ import org.compiere.process.ProcessInfo;
import org.compiere.util.Env;
import org.compiere.wf.MWorkflow;
import org.idempiere.test.AbstractTestCase;
import org.idempiere.test.DictionaryIDs;
import org.junit.jupiter.api.Test;
/**
@ -85,19 +86,19 @@ public class MatchInv2ndAcctSchemaTest extends AbstractTestCase {
* https://idempiere.atlassian.net/browse/IDEMPIERE-4263
*/
public void testCreditMemoPosting_1() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 114); // Tree Farm Inc.
MProduct product1 = MProduct.get(Env.getCtx(), 124); // Elm Tree
MProduct product2 = MProduct.get(Env.getCtx(), 123); // Oak Tree
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.TREE_FARM.id); // Tree Farm Inc.
MProduct product1 = MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.ELM.id); // Elm Tree
MProduct product2 = MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.OAK.id); // Oak Tree
Timestamp currentDate = Env.getContextAsDate(Env.getCtx(), "#Date");
int C_ConversionType_ID = 201; // Company
int C_ConversionType_ID = DictionaryIDs.C_ConversionType.COMPANY.id; // Company
MCurrency usd = MCurrency.get(100); // USD
MCurrency euro = MCurrency.get("EUR"); // EUR
MCurrency usd = MCurrency.get(DictionaryIDs.C_Currency.USD.id); // USD
MCurrency euro = MCurrency.get(DictionaryIDs.C_Currency.EUR.id); // EUR
BigDecimal usdToEur = new BigDecimal(31.526248754713);
MConversionRate cr = createConversionRate(usd.getC_Currency_ID(), euro.getC_Currency_ID(), C_ConversionType_ID, currentDate, usdToEur);
BigDecimal eurToUsd = cr.getDivideRate();
int M_PriceList_ID = 103; // Export in EUR
int M_PriceList_ID = DictionaryIDs.M_PriceList.EXPORT.id; // Export in EUR
try {
MOrder order = createPurchaseOrder(bpartner, currentDate, M_PriceList_ID, C_ConversionType_ID);
@ -176,17 +177,17 @@ public class MatchInv2ndAcctSchemaTest extends AbstractTestCase {
* IV Qty=5
*/
public void testCreditMemoPosting_2() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 114); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), 124); // Elm Tree
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.TREE_FARM.id); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.ELM.id); // Elm Tree
Timestamp currentDate = Env.getContextAsDate(Env.getCtx(), "#Date");
int C_ConversionType_ID = 201; // Company
int C_ConversionType_ID = DictionaryIDs.C_ConversionType.COMPANY.id; // Company
MCurrency usd = MCurrency.get(100); // USD
MCurrency euro = MCurrency.get("EUR"); // EUR
MCurrency usd = MCurrency.get(DictionaryIDs.C_Currency.USD.id); // USD
MCurrency euro = MCurrency.get(DictionaryIDs.C_Currency.EUR.id); // EUR
BigDecimal eurToUsd = new BigDecimal(31.526248754713);
MConversionRate cr = createConversionRate(usd.getC_Currency_ID(), euro.getC_Currency_ID(), C_ConversionType_ID, currentDate, eurToUsd, false);
int M_PriceList_ID = 103; // Export in EUR
int M_PriceList_ID = DictionaryIDs.M_PriceList.EXPORT.id; // Export in EUR
try {
MOrder order = createPurchaseOrder(bpartner, currentDate, M_PriceList_ID, C_ConversionType_ID);
@ -291,8 +292,8 @@ public class MatchInv2ndAcctSchemaTest extends AbstractTestCase {
* CM Qty=2, Period 2
*/
public void testCreditMemoPosting_3() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 114); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), 124); // Elm Tree
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.TREE_FARM.id); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.ELM.id); // Elm Tree
Timestamp currentDate = Env.getContextAsDate(Env.getCtx(), "#Date");
Calendar cal = Calendar.getInstance();
@ -301,17 +302,17 @@ public class MatchInv2ndAcctSchemaTest extends AbstractTestCase {
Timestamp date1 = new Timestamp(cal.getTimeInMillis());
Timestamp date2 = currentDate;
int C_ConversionType_ID = 201; // Company
int C_ConversionType_ID = DictionaryIDs.C_ConversionType.COMPANY.id; // Company
MPriceList priceList = new MPriceList(Env.getCtx(), 0, null);
priceList.setName("Purchase GBP " + System.currentTimeMillis());
MCurrency britishPound = MCurrency.get("GBP"); // British Pound (GBP)
MCurrency britishPound = MCurrency.get(DictionaryIDs.C_Currency.GBP.id); // British Pound (GBP)
priceList.setC_Currency_ID(britishPound.getC_Currency_ID());
priceList.setPricePrecision(britishPound.getStdPrecision());
priceList.saveEx();
MPriceListVersion plv = new MPriceListVersion(priceList);
plv.setM_DiscountSchema_ID(101); // Purchase 2001
plv.setM_DiscountSchema_ID(DictionaryIDs.M_DiscountSchema.PURCHASE_2001.id); // Purchase 2001
plv.setValidFrom(date1);
plv.saveEx();
@ -319,7 +320,7 @@ public class MatchInv2ndAcctSchemaTest extends AbstractTestCase {
MProductPrice pp = new MProductPrice(plv, product.getM_Product_ID(), priceInPound, priceInPound, Env.ZERO);
pp.saveEx();
MCurrency usd = MCurrency.get("USD"); // USD
MCurrency usd = MCurrency.get(DictionaryIDs.C_Currency.USD.id); // USD
BigDecimal usdToPound1 = new BigDecimal(0.88917098794);
MConversionRate crUsd1 = createConversionRate(britishPound.getC_Currency_ID(), usd.getC_Currency_ID(), C_ConversionType_ID, date1, usdToPound1, false);
BigDecimal poundToUsd1 = crUsd1.getMultiplyRate();
@ -328,7 +329,7 @@ public class MatchInv2ndAcctSchemaTest extends AbstractTestCase {
MConversionRate crUsd2 = createConversionRate(britishPound.getC_Currency_ID(), usd.getC_Currency_ID(), C_ConversionType_ID, date2, usdToPound2, false);
BigDecimal poundToUsd2 = crUsd2.getMultiplyRate();
MCurrency euro = MCurrency.get("EUR"); // EUR
MCurrency euro = MCurrency.get(DictionaryIDs.C_Currency.EUR.id); // EUR
BigDecimal poundToEuro1 = new BigDecimal(34.7186);
MConversionRate crEur1 = createConversionRate(britishPound.getC_Currency_ID(), euro.getC_Currency_ID(), C_ConversionType_ID, date1, poundToEuro1, true);
@ -416,10 +417,10 @@ public class MatchInv2ndAcctSchemaTest extends AbstractTestCase {
* CM Qty1=200, Qty2=300, Period 3
*/
public void testCreditMemoPosting_4() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 114); // Tree Farm Inc.
MProduct product1 = MProduct.get(Env.getCtx(), 124); // Elm Tree
MProduct product2 = MProduct.get(Env.getCtx(), 123); // Oak Tree
MProduct product3 = MProduct.get(Env.getCtx(), 130); // Plum Tree
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.TREE_FARM.id); // Tree Farm Inc.
MProduct product1 = MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.ELM.id); // Elm Tree
MProduct product2 = MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.OAK.id); // Oak Tree
MProduct product3 = MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.PLUM_TREE.id); // Plum Tree
Timestamp currentDate = Env.getContextAsDate(Env.getCtx(), "#Date");
Calendar cal = Calendar.getInstance();
@ -431,10 +432,10 @@ public class MatchInv2ndAcctSchemaTest extends AbstractTestCase {
Timestamp date2 = new Timestamp(cal.getTimeInMillis());
Timestamp date3 = currentDate;
int C_ConversionType_ID = 201; // Company
int C_ConversionType_ID = DictionaryIDs.C_ConversionType.COMPANY.id; // Company
MCurrency usd = MCurrency.get(100); // USD
MCurrency euro = MCurrency.get("EUR"); // EUR
MCurrency usd = MCurrency.get(DictionaryIDs.C_Currency.USD.id); // USD
MCurrency euro = MCurrency.get(DictionaryIDs.C_Currency.EUR.id); // EUR
BigDecimal eurToUsd1 = new BigDecimal(30.212666962751);
MConversionRate cr1 = createConversionRate(usd.getC_Currency_ID(), euro.getC_Currency_ID(), C_ConversionType_ID, date1, eurToUsd1, false);
@ -444,7 +445,7 @@ public class MatchInv2ndAcctSchemaTest extends AbstractTestCase {
BigDecimal eurToUsd3 = new BigDecimal(29.326631220545);
MConversionRate cr3 = createConversionRate(usd.getC_Currency_ID(), euro.getC_Currency_ID(), C_ConversionType_ID, date3, eurToUsd3, false);
int M_PriceList_ID = 103; // Export in EUR
int M_PriceList_ID = DictionaryIDs.M_PriceList.EXPORT.id; // Export in EUR
try {
MOrder order = createPurchaseOrder(bpartner, date1, M_PriceList_ID, C_ConversionType_ID);
@ -589,17 +590,17 @@ public class MatchInv2ndAcctSchemaTest extends AbstractTestCase {
* CM Qty=1
*/
public void testCreditMemoPosting_5() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 114); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), 124); // Elm Tree
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.TREE_FARM.id); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.ELM.id); // Elm Tree
Timestamp currentDate = Env.getContextAsDate(Env.getCtx(), "#Date");
int C_ConversionType_ID = 201; // Company
int C_ConversionType_ID = DictionaryIDs.C_ConversionType.COMPANY.id; // Company
MCurrency usd = MCurrency.get(100); // USD
MCurrency euro = MCurrency.get("EUR"); // EUR
MCurrency usd = MCurrency.get(DictionaryIDs.C_Currency.USD.id); // USD
MCurrency euro = MCurrency.get(DictionaryIDs.C_Currency.EUR.id); // EUR
BigDecimal eurToUsd = new BigDecimal(30.870771861909);
MConversionRate cr = createConversionRate(usd.getC_Currency_ID(), euro.getC_Currency_ID(), C_ConversionType_ID, currentDate, eurToUsd, false);
int M_PriceList_ID = 103; // Export in EUR
int M_PriceList_ID = DictionaryIDs.M_PriceList.EXPORT.id; // Export in EUR
try {
MOrder order = createPurchaseOrder(bpartner, currentDate, M_PriceList_ID, C_ConversionType_ID);
@ -677,17 +678,17 @@ public class MatchInv2ndAcctSchemaTest extends AbstractTestCase {
* CM Qty=100
*/
public void testCreditMemoPosting_6() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 114); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), 124); // Elm Tree
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.TREE_FARM.id); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.ELM.id); // Elm Tree
Timestamp currentDate = Env.getContextAsDate(Env.getCtx(), "#Date");
int C_ConversionType_ID = 201; // Company
int C_ConversionType_ID = DictionaryIDs.C_ConversionType.COMPANY.id; // Company
MCurrency usd = MCurrency.get(100); // USD
MCurrency euro = MCurrency.get("EUR"); // EUR
MCurrency usd = MCurrency.get(DictionaryIDs.C_Currency.USD.id); // USD
MCurrency euro = MCurrency.get(DictionaryIDs.C_Currency.EUR.id); // EUR
BigDecimal eurToUsd = new BigDecimal(30.870771861909);
MConversionRate cr = createConversionRate(usd.getC_Currency_ID(), euro.getC_Currency_ID(), C_ConversionType_ID, currentDate, eurToUsd, false);
int M_PriceList_ID = 103; // Export in EUR
int M_PriceList_ID = DictionaryIDs.M_PriceList.EXPORT.id; // Export in EUR
try {
MOrder order = createPurchaseOrder(bpartner, currentDate, M_PriceList_ID, C_ConversionType_ID);
@ -765,17 +766,17 @@ public class MatchInv2ndAcctSchemaTest extends AbstractTestCase {
* CM Qty=44
*/
public void testCreditMemoPosting_7() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 114); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), 124); // Elm Tree
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.TREE_FARM.id); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.ELM.id); // Elm Tree
Timestamp currentDate = Env.getContextAsDate(Env.getCtx(), "#Date");
int C_ConversionType_ID = 201; // Company
int C_ConversionType_ID = DictionaryIDs.C_ConversionType.COMPANY.id; // Company
MCurrency usd = MCurrency.get(100); // USD
MCurrency euro = MCurrency.get("EUR"); // EUR
MCurrency usd = MCurrency.get(DictionaryIDs.C_Currency.USD.id); // USD
MCurrency euro = MCurrency.get(DictionaryIDs.C_Currency.EUR.id); // EUR
BigDecimal eurToUsd = new BigDecimal(30.870771861909);
MConversionRate cr = createConversionRate(usd.getC_Currency_ID(), euro.getC_Currency_ID(), C_ConversionType_ID, currentDate, eurToUsd, false);
int M_PriceList_ID = 103; // Export in EUR
int M_PriceList_ID = DictionaryIDs.M_PriceList.EXPORT.id; // Export in EUR
try {
MOrder order = createPurchaseOrder(bpartner, currentDate, M_PriceList_ID, C_ConversionType_ID);
@ -853,17 +854,17 @@ public class MatchInv2ndAcctSchemaTest extends AbstractTestCase {
* CM Qty=1
*/
public void testCreditMemoPosting_8() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 114); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), 124); // Elm Tree
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.TREE_FARM.id); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.ELM.id); // Elm Tree
Timestamp currentDate = Env.getContextAsDate(Env.getCtx(), "#Date");
int C_ConversionType_ID = 201; // Company
int C_ConversionType_ID = DictionaryIDs.C_ConversionType.COMPANY.id; // Company
MCurrency usd = MCurrency.get(100); // USD
MCurrency euro = MCurrency.get("EUR"); // EUR
MCurrency usd = MCurrency.get(DictionaryIDs.C_Currency.USD.id); // USD
MCurrency euro = MCurrency.get(DictionaryIDs.C_Currency.EUR.id); // EUR
BigDecimal eurToUsd = new BigDecimal(30.870771861909);
MConversionRate cr = createConversionRate(usd.getC_Currency_ID(), euro.getC_Currency_ID(), C_ConversionType_ID, currentDate, eurToUsd, false);
int M_PriceList_ID = 103; // Export in EUR
int M_PriceList_ID = DictionaryIDs.M_PriceList.EXPORT.id; // Export in EUR
try {
MOrder order = createPurchaseOrder(bpartner, currentDate, M_PriceList_ID, C_ConversionType_ID);
@ -984,17 +985,17 @@ public class MatchInv2ndAcctSchemaTest extends AbstractTestCase {
* MR Qty=1200
*/
public void testMatReceiptPosting_1() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 114); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), 124); // Elm Tree
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.TREE_FARM.id); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.ELM.id); // Elm Tree
Timestamp currentDate = Env.getContextAsDate(Env.getCtx(), "#Date");
int C_ConversionType_ID = 201; // Company
int C_ConversionType_ID = DictionaryIDs.C_ConversionType.COMPANY.id; // Company
MCurrency usd = MCurrency.get(100); // USD
MCurrency euro = MCurrency.get("EUR"); // EUR
MCurrency usd = MCurrency.get(DictionaryIDs.C_Currency.USD.id); // USD
MCurrency euro = MCurrency.get(DictionaryIDs.C_Currency.EUR.id); // EUR
BigDecimal eurToUsd = new BigDecimal(30.870771861909);
MConversionRate cr = createConversionRate(usd.getC_Currency_ID(), euro.getC_Currency_ID(), C_ConversionType_ID, currentDate, eurToUsd, false);
int M_PriceList_ID = 103; // Export in EUR
int M_PriceList_ID = DictionaryIDs.M_PriceList.EXPORT.id; // Export in EUR
try {
MOrder order = createPurchaseOrder(bpartner, currentDate, M_PriceList_ID, C_ConversionType_ID);
@ -1070,8 +1071,8 @@ public class MatchInv2ndAcctSchemaTest extends AbstractTestCase {
* MR Qty=44, Period 2
*/
public void testMatReceiptPosting_2() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 114); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), 124); // Elm Tree
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.TREE_FARM.id); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.ELM.id); // Elm Tree
Timestamp currentDate = Env.getContextAsDate(Env.getCtx(), "#Date");
Calendar cal = Calendar.getInstance();
@ -1080,17 +1081,17 @@ public class MatchInv2ndAcctSchemaTest extends AbstractTestCase {
Timestamp date1 = new Timestamp(cal.getTimeInMillis());
Timestamp date2 = currentDate;
int C_ConversionType_ID = 201; // Company
int C_ConversionType_ID = DictionaryIDs.C_ConversionType.COMPANY.id; // Company
MCurrency usd = MCurrency.get(100); // USD
MCurrency euro = MCurrency.get("EUR"); // EUR
MCurrency usd = MCurrency.get(DictionaryIDs.C_Currency.USD.id); // USD
MCurrency euro = MCurrency.get(DictionaryIDs.C_Currency.EUR.id); // EUR
BigDecimal eurToUsd1 = new BigDecimal(30.870771861909);
MConversionRate cr1 = createConversionRate(usd.getC_Currency_ID(), euro.getC_Currency_ID(), C_ConversionType_ID, date1, eurToUsd1, false);
BigDecimal eurToUsd2 = new BigDecimal(31.326259863856);
MConversionRate cr2 = createConversionRate(usd.getC_Currency_ID(), euro.getC_Currency_ID(), C_ConversionType_ID, date2, eurToUsd2, false);
int M_PriceList_ID = 103; // Export in EUR
int M_PriceList_ID = DictionaryIDs.M_PriceList.EXPORT.id; // Export in EUR
try {
MOrder order = createPurchaseOrder(bpartner, date1, M_PriceList_ID, C_ConversionType_ID);
@ -1169,17 +1170,17 @@ public class MatchInv2ndAcctSchemaTest extends AbstractTestCase {
* MR Qty=1
*/
public void testMatReceiptPosting_3() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 114); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), 124); // Elm Tree
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.TREE_FARM.id); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.ELM.id); // Elm Tree
Timestamp currentDate = Env.getContextAsDate(Env.getCtx(), "#Date");
int C_ConversionType_ID = 201; // Company
int C_ConversionType_ID = DictionaryIDs.C_ConversionType.COMPANY.id; // Company
MCurrency usd = MCurrency.get(100); // USD
MCurrency euro = MCurrency.get("EUR"); // EUR
MCurrency usd = MCurrency.get(DictionaryIDs.C_Currency.USD.id); // USD
MCurrency euro = MCurrency.get(DictionaryIDs.C_Currency.EUR.id); // EUR
BigDecimal eurToUsd = new BigDecimal(30.870771861909);
MConversionRate cr = createConversionRate(usd.getC_Currency_ID(), euro.getC_Currency_ID(), C_ConversionType_ID, currentDate, eurToUsd, false);
int M_PriceList_ID = 103; // Export in EUR
int M_PriceList_ID = DictionaryIDs.M_PriceList.EXPORT.id; // Export in EUR
try {
MOrder order = createPurchaseOrder(bpartner, currentDate, M_PriceList_ID, C_ConversionType_ID);
@ -1302,8 +1303,8 @@ public class MatchInv2ndAcctSchemaTest extends AbstractTestCase {
* MR Qty=1, Period 2
*/
public void testMatReceiptPosting_4() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 114); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), 124); // Elm Tree
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.TREE_FARM.id); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.ELM.id); // Elm Tree
Timestamp currentDate = Env.getContextAsDate(Env.getCtx(), "#Date");
Calendar cal = Calendar.getInstance();
@ -1312,17 +1313,17 @@ public class MatchInv2ndAcctSchemaTest extends AbstractTestCase {
Timestamp date1 = new Timestamp(cal.getTimeInMillis());
Timestamp date2 = currentDate;
int C_ConversionType_ID = 201; // Company
int C_ConversionType_ID = DictionaryIDs.C_ConversionType.COMPANY.id; // Company
MCurrency usd = MCurrency.get(100); // USD
MCurrency euro = MCurrency.get("EUR"); // EUR
MCurrency usd = MCurrency.get(DictionaryIDs.C_Currency.USD.id); // USD
MCurrency euro = MCurrency.get(DictionaryIDs.C_Currency.EUR.id); // EUR
BigDecimal eurToUsd1 = new BigDecimal(30.870771861909);
MConversionRate cr1 = createConversionRate(usd.getC_Currency_ID(), euro.getC_Currency_ID(), C_ConversionType_ID, date1, eurToUsd1, false);
BigDecimal eurToUsd2 = new BigDecimal(31.326259863856);
MConversionRate cr2 = createConversionRate(usd.getC_Currency_ID(), euro.getC_Currency_ID(), C_ConversionType_ID, date2, eurToUsd2, false);
int M_PriceList_ID = 103; // Export in EUR
int M_PriceList_ID = DictionaryIDs.M_PriceList.EXPORT.id; // Export in EUR
try {
MOrder order = createPurchaseOrder(bpartner, date1, M_PriceList_ID, C_ConversionType_ID);
@ -1444,21 +1445,21 @@ public class MatchInv2ndAcctSchemaTest extends AbstractTestCase {
* IV Qty=250
*/
public void testMatReceiptPosting_5() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 114); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), 124); // Elm Tree
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.TREE_FARM.id); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.ELM.id); // Elm Tree
Timestamp currentDate = Env.getContextAsDate(Env.getCtx(), "#Date");
int C_ConversionType_ID = 201; // Company
int C_ConversionType_ID = DictionaryIDs.C_ConversionType.COMPANY.id; // Company
MPriceList priceList = new MPriceList(Env.getCtx(), 0, null);
priceList.setName("Purchase GBP " + System.currentTimeMillis());
MCurrency britishPound = MCurrency.get("GBP"); // British Pound (GBP)
MCurrency britishPound = MCurrency.get(DictionaryIDs.C_Currency.GBP.id); // British Pound (GBP)
priceList.setC_Currency_ID(britishPound.getC_Currency_ID());
priceList.setPricePrecision(britishPound.getStdPrecision());
priceList.saveEx();
MPriceListVersion plv = new MPriceListVersion(priceList);
plv.setM_DiscountSchema_ID(101); // Purchase 2001
plv.setM_DiscountSchema_ID(DictionaryIDs.M_DiscountSchema.PURCHASE_2001.id); // Purchase 2001
plv.setValidFrom(currentDate);
plv.saveEx();
@ -1466,11 +1467,11 @@ public class MatchInv2ndAcctSchemaTest extends AbstractTestCase {
MProductPrice pp = new MProductPrice(plv, product.getM_Product_ID(), priceInPound, priceInPound, Env.ZERO);
pp.saveEx();
MCurrency usd = MCurrency.get("USD"); // USD
MCurrency usd = MCurrency.get(DictionaryIDs.C_Currency.USD.id); // USD
BigDecimal poundToUsd = new BigDecimal(0.676234);
MConversionRate crUsd = createConversionRate(britishPound.getC_Currency_ID(), usd.getC_Currency_ID(), C_ConversionType_ID, currentDate, poundToUsd);
MCurrency euro = MCurrency.get("EUR"); // EUR
MCurrency euro = MCurrency.get(DictionaryIDs.C_Currency.EUR.id); // EUR
BigDecimal poundToEuro = new BigDecimal(22.5062);
MConversionRate crEur = createConversionRate(britishPound.getC_Currency_ID(), euro.getC_Currency_ID(), C_ConversionType_ID, currentDate, poundToEuro);
@ -1557,21 +1558,21 @@ public class MatchInv2ndAcctSchemaTest extends AbstractTestCase {
* MR Qty=5 (Reversed)
*/
public void testMatReceiptPostingWithDiffCurrencyPrecision() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 114); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), 124); // Elm Tree
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.TREE_FARM.id); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.ELM.id); // Elm Tree
Timestamp currentDate = Env.getContextAsDate(Env.getCtx(), "#Date");
int C_ConversionType_ID = 201; // Company
int C_ConversionType_ID = DictionaryIDs.C_ConversionType.COMPANY.id; // Company
MPriceList priceList = new MPriceList(Env.getCtx(), 0, null);
priceList.setName("Purchase JPY " + System.currentTimeMillis());
MCurrency japaneseYen = MCurrency.get("JPY"); // Japanese Yen (JPY)
MCurrency japaneseYen = MCurrency.get(DictionaryIDs.C_Currency.JPY.id); // Japanese Yen (JPY)
priceList.setC_Currency_ID(japaneseYen.getC_Currency_ID());
priceList.setPricePrecision(japaneseYen.getStdPrecision());
priceList.saveEx();
MPriceListVersion plv = new MPriceListVersion(priceList);
plv.setM_DiscountSchema_ID(101); // Purchase 2001
plv.setM_DiscountSchema_ID(DictionaryIDs.M_DiscountSchema.PURCHASE_2001.id); // Purchase 2001
plv.setValidFrom(currentDate);
plv.saveEx();
@ -1579,11 +1580,11 @@ public class MatchInv2ndAcctSchemaTest extends AbstractTestCase {
MProductPrice pp = new MProductPrice(plv, product.getM_Product_ID(), priceInYen, priceInYen, Env.ZERO);
pp.saveEx();
MCurrency usd = MCurrency.get("USD"); // USD
MCurrency usd = MCurrency.get(DictionaryIDs.C_Currency.USD.id); // USD
BigDecimal yenToUsd = new BigDecimal(0.00956427);
MConversionRate crUsd = createConversionRate(japaneseYen.getC_Currency_ID(), usd.getC_Currency_ID(), C_ConversionType_ID, currentDate, yenToUsd);
MCurrency euro = MCurrency.get("EUR"); // EUR
MCurrency euro = MCurrency.get(DictionaryIDs.C_Currency.EUR.id); // EUR
BigDecimal yenToEuro = new BigDecimal(0.29);
MConversionRate crEur = createConversionRate(japaneseYen.getC_Currency_ID(), euro.getC_Currency_ID(), C_ConversionType_ID, currentDate, yenToEuro);
@ -1791,7 +1792,7 @@ public class MatchInv2ndAcctSchemaTest extends AbstractTestCase {
}
private MInOut createMMReceipt(MOrder order, Timestamp date) {
MInOut receipt = new MInOut(order, 122, date); // MM Receipt
MInOut receipt = new MInOut(order, DictionaryIDs.C_DocType.MM_RECEIPT.id, date); // MM Receipt
receipt.saveEx();
return receipt;
}

View File

@ -65,12 +65,14 @@ import org.compiere.model.MRMALine;
import org.compiere.model.MWarehouse;
import org.compiere.model.ProductCost;
import org.compiere.model.Query;
import org.compiere.model.SystemIDs;
import org.compiere.process.DocAction;
import org.compiere.process.DocumentEngine;
import org.compiere.process.ProcessInfo;
import org.compiere.util.Env;
import org.compiere.wf.MWorkflow;
import org.idempiere.test.AbstractTestCase;
import org.idempiere.test.DictionaryIDs;
import org.junit.jupiter.api.Test;
/**
@ -86,8 +88,8 @@ public class MatchInvTest extends AbstractTestCase {
* https://idempiere.atlassian.net/browse/IDEMPIERE-4173
*/
public void testMatShipmentPosting() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 114); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), 124); // Elm Tree
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.TREE_FARM.id); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.ELM.id); // Elm Tree
MOrder order = new MOrder(Env.getCtx(), 0, getTrxName());
order.setBPartner(bpartner);
@ -108,7 +110,7 @@ public class MatchInvTest extends AbstractTestCase {
assertFalse(info.isError());
assertEquals(DocAction.STATUS_Completed, order.getDocStatus());
MInOut receipt = new MInOut(order, 122, order.getDateOrdered()); // MM Receipt
MInOut receipt = new MInOut(order, DictionaryIDs.C_DocType.MM_RECEIPT.id, order.getDateOrdered()); // MM Receipt
receipt.saveEx();
MInOutLine receiptLine = new MInOutLine(receipt);
@ -135,11 +137,11 @@ public class MatchInvTest extends AbstractTestCase {
MRMA rma = new MRMA(Env.getCtx(), 0, getTrxName());
rma.setName(order.getDocumentNo());
rma.setC_DocType_ID(150); // Vendor Return Material
rma.setM_RMAType_ID(100); // Damaged on Arrival
rma.setC_DocType_ID(DictionaryIDs.C_DocType.VENDOR_RETURN_MATERIAL.id); // Vendor Return Material
rma.setM_RMAType_ID(DictionaryIDs.M_RMAType.DAMAGE_ON_ARRIVAL.id); // Damaged on Arrival
rma.setM_InOut_ID(receipt.get_ID());
rma.setIsSOTrx(false);
rma.setSalesRep_ID(100); // SuperUser
rma.setSalesRep_ID(SystemIDs.USER_SUPERUSER); // SuperUser
rma.saveEx();
MRMALine rmaLine = new MRMALine(Env.getCtx(), 0, getTrxName());
@ -159,7 +161,7 @@ public class MatchInvTest extends AbstractTestCase {
delivery.setBPartner(bpartner);
delivery.setIsSOTrx(false);
delivery.setMovementType(MInOut.MOVEMENTTYPE_VendorReturns);
delivery.setC_DocType_ID(151); // MM Vendor Return
delivery.setC_DocType_ID(DictionaryIDs.C_DocType.MM_VENDOR_RETURN.id); // MM Vendor Return
delivery.setDocStatus(DocAction.STATUS_Drafted);
delivery.setDocAction(DocAction.ACTION_Complete);
delivery.setM_Warehouse_ID(receipt.getM_Warehouse_ID());
@ -249,8 +251,8 @@ public class MatchInvTest extends AbstractTestCase {
* https://idempiere.atlassian.net/browse/IDEMPIERE-4173
*/
public void testMatReceiptPosting() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 114); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), 124); // Elm Tree
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.TREE_FARM.id); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.ELM.id); // Elm Tree
MOrder order = new MOrder(Env.getCtx(), 0, getTrxName());
order.setBPartner(bpartner);
@ -271,7 +273,7 @@ public class MatchInvTest extends AbstractTestCase {
assertFalse(info.isError());
assertEquals(DocAction.STATUS_Completed, order.getDocStatus());
MInOut receipt = new MInOut(order, 122, order.getDateOrdered()); // MM Receipt
MInOut receipt = new MInOut(order, DictionaryIDs.C_DocType.MM_RECEIPT.id, order.getDateOrdered()); // MM Receipt
receipt.saveEx();
MInOutLine receiptLine = new MInOutLine(receipt);
@ -373,19 +375,19 @@ public class MatchInvTest extends AbstractTestCase {
}
try {
int mulchId = 137; // Mulch product
int mulchId = DictionaryIDs.M_Product.MULCH.id; // Mulch product
MProduct mulch = new MProduct(Env.getCtx(), mulchId, getTrxName());
mulch.setM_Product_Category_ID(category.get_ID());
mulch.saveEx();
int purchaseId = 102; // Purchase Price List
MBPartner bpartner = MBPartner.get(Env.getCtx(), 120); // Seed Farm Inc.
int purchaseId = DictionaryIDs.M_PriceList.PURCHASE.id; // Purchase Price List
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.SEED_FARM.id); // Seed Farm Inc.
MAcctSchema as = MClient.get(getAD_Client_ID()).getAcctSchema();
BigDecimal mulchCost = MCost.getCurrentCost(mulch, 0, getTrxName()).setScale(as.getCostingPrecision(), RoundingMode.HALF_UP);
// Change standard cost of mulch product to 2.1234
int hqLocator = 101;
int costAdjustmentDocTypeId = 200004;
int hqLocator = DictionaryIDs.M_Locator.HQ.id;
int costAdjustmentDocTypeId = DictionaryIDs.C_DocType.COST_ADJUSTMENT.id;
MInventory inventory = new MInventory(Env.getCtx(), 0, getTrxName());
inventory.setCostingMethod(MAcctSchema.COSTINGMETHOD_StandardCosting);
inventory.setC_DocType_ID(costAdjustmentDocTypeId);
@ -542,8 +544,8 @@ public class MatchInvTest extends AbstractTestCase {
* PO Qty=10 > IV Qty=10 > MR Qty=9 > CM Qty=1
*/
public void testCreditMemoPosting() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 114); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), 124); // Elm Tree
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.TREE_FARM.id); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.ELM.id); // Elm Tree
MOrder order = new MOrder(Env.getCtx(), 0, getTrxName());
order.setBPartner(bpartner);
@ -595,7 +597,7 @@ public class MatchInvTest extends AbstractTestCase {
invoice.load(getTrxName());
assertTrue(invoice.isPosted());
MInOut receipt = new MInOut(order, 122, order.getDateOrdered()); // MM Receipt
MInOut receipt = new MInOut(order, DictionaryIDs.C_DocType.MM_RECEIPT.id, order.getDateOrdered()); // MM Receipt
receipt.saveEx();
MInOutLine receiptLine = new MInOutLine(receipt);
@ -729,19 +731,19 @@ public class MatchInvTest extends AbstractTestCase {
* https://idempiere.atlassian.net/browse/IDEMPIERE-4128
*/
public void testMatReceiptPostingWithDiffCurrencyPrecision() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 114); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), 124); // Elm Tree
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.TREE_FARM.id); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.ELM.id); // Elm Tree
Timestamp currentDate = Env.getContextAsDate(Env.getCtx(), Env.DATE);
MPriceList priceList = new MPriceList(Env.getCtx(), 0, null);
priceList.setName("Purchase JPY " + System.currentTimeMillis());
MCurrency japaneseYen = MCurrency.get("JPY"); // Japanese Yen (JPY)
MCurrency japaneseYen = MCurrency.get(DictionaryIDs.C_Currency.JPY.id); // Japanese Yen (JPY)
priceList.setC_Currency_ID(japaneseYen.getC_Currency_ID());
priceList.setPricePrecision(japaneseYen.getStdPrecision());
priceList.saveEx();
MPriceListVersion plv = new MPriceListVersion(priceList);
plv.setM_DiscountSchema_ID(101); // Purchase 2001
plv.setM_DiscountSchema_ID(DictionaryIDs.M_DiscountSchema.PURCHASE_2001.id); // Purchase 2001
plv.setValidFrom(currentDate);
plv.saveEx();
@ -752,8 +754,8 @@ public class MatchInvTest extends AbstractTestCase {
BigDecimal yenToUsd = new BigDecimal(0.277582);
MConversionRate cr1 = new MConversionRate(Env.getCtx(), 0, null);
cr1.setC_Currency_ID(japaneseYen.getC_Currency_ID());
cr1.setC_Currency_ID_To(100); // USD
cr1.setC_ConversionType_ID(114); // Spot
cr1.setC_Currency_ID_To(DictionaryIDs.C_Currency.USD.id); // USD
cr1.setC_ConversionType_ID(DictionaryIDs.C_ConversionType.SPOT.id); // Spot
cr1.setValidFrom(currentDate);
cr1.setValidTo(currentDate);
cr1.setMultiplyRate(yenToUsd);
@ -762,8 +764,8 @@ public class MatchInvTest extends AbstractTestCase {
BigDecimal euroToUsd = new BigDecimal(0.236675);
MConversionRate cr2 = new MConversionRate(Env.getCtx(), 0, null);
cr2.setC_Currency_ID(japaneseYen.getC_Currency_ID());
cr2.setC_Currency_ID_To(102); // EUR
cr2.setC_ConversionType_ID(114); // Spot
cr2.setC_Currency_ID_To(DictionaryIDs.C_Currency.EUR.id); // EUR
cr2.setC_ConversionType_ID(DictionaryIDs.C_ConversionType.SPOT.id); // Spot
cr2.setValidFrom(currentDate);
cr2.setValidTo(currentDate);
cr2.setMultiplyRate(euroToUsd);
@ -777,7 +779,7 @@ public class MatchInvTest extends AbstractTestCase {
order.setDateOrdered(currentDate);
order.setDateAcct(currentDate);
order.setM_PriceList_ID(priceList.getM_PriceList_ID());
order.setC_ConversionType_ID(114); // Spot
order.setC_ConversionType_ID(DictionaryIDs.C_ConversionType.SPOT.id); // Spot
order.setDocStatus(DocAction.STATUS_Drafted);
order.setDocAction(DocAction.ACTION_Complete);
order.saveEx();
@ -793,7 +795,7 @@ public class MatchInvTest extends AbstractTestCase {
assertFalse(info.isError());
assertEquals(DocAction.STATUS_Completed, order.getDocStatus());
MInOut receipt = new MInOut(order, 122, order.getDateOrdered()); // MM Receipt
MInOut receipt = new MInOut(order, DictionaryIDs.C_DocType.MM_RECEIPT.id, order.getDateOrdered()); // MM Receipt
receipt.saveEx();
MInOutLine receiptLine = new MInOutLine(receipt);
@ -920,8 +922,8 @@ public class MatchInvTest extends AbstractTestCase {
@Test
public void testIsReversal() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 114); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), 124); // Elm Tree
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.TREE_FARM.id); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.ELM.id); // Elm Tree
MOrder order = new MOrder(Env.getCtx(), 0, getTrxName());
order.setBPartner(bpartner);
@ -942,7 +944,7 @@ public class MatchInvTest extends AbstractTestCase {
assertFalse(info.isError());
assertEquals(DocAction.STATUS_Completed, order.getDocStatus());
MInOut receipt = new MInOut(order, 122, order.getDateOrdered()); // MM Receipt
MInOut receipt = new MInOut(order, DictionaryIDs.C_DocType.MM_RECEIPT.id, order.getDateOrdered()); // MM Receipt
receipt.saveEx();
MInOutLine receiptLine = new MInOutLine(receipt);
@ -1014,8 +1016,8 @@ public class MatchInvTest extends AbstractTestCase {
@Test
public void testIsReversalCM() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 114); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), 124); // Elm Tree
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.TREE_FARM.id); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.ELM.id); // Elm Tree
MOrder order = new MOrder(Env.getCtx(), 0, getTrxName());
order.setBPartner(bpartner);
@ -1036,7 +1038,7 @@ public class MatchInvTest extends AbstractTestCase {
assertFalse(info.isError());
assertEquals(DocAction.STATUS_Completed, order.getDocStatus());
MInOut receipt = new MInOut(order, 122, order.getDateOrdered()); // MM Receipt
MInOut receipt = new MInOut(order, DictionaryIDs.C_DocType.MM_RECEIPT.id, order.getDateOrdered()); // MM Receipt
receipt.saveEx();
MInOutLine receiptLine = new MInOutLine(receipt);
@ -1133,8 +1135,8 @@ public class MatchInvTest extends AbstractTestCase {
@Test
public void testReversalPosting() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 114); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), 124); // Elm Tree
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.TREE_FARM.id); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.ELM.id); // Elm Tree
MOrder order = new MOrder(Env.getCtx(), 0, getTrxName());
order.setBPartner(bpartner);
@ -1155,7 +1157,7 @@ public class MatchInvTest extends AbstractTestCase {
assertFalse(info.isError());
assertEquals(DocAction.STATUS_Completed, order.getDocStatus());
MInOut receipt = new MInOut(order, 122, order.getDateOrdered()); // MM Receipt
MInOut receipt = new MInOut(order, DictionaryIDs.C_DocType.MM_RECEIPT.id, order.getDateOrdered()); // MM Receipt
receipt.saveEx();
MInOutLine receiptLine = new MInOutLine(receipt);

View File

@ -48,6 +48,7 @@ import org.compiere.model.MProduct;
import org.compiere.model.MStorageOnHand;
import org.compiere.model.MStorageReservation;
import org.compiere.model.MWarehouse;
import org.compiere.model.SystemIDs;
import org.compiere.process.DocAction;
import org.compiere.process.ProcessInfo;
import org.compiere.process.ServerProcessCtl;
@ -56,6 +57,7 @@ import org.compiere.util.KeyNamePair;
import org.compiere.util.Msg;
import org.compiere.wf.MWorkflow;
import org.idempiere.test.AbstractTestCase;
import org.idempiere.test.DictionaryIDs;
import org.idempiere.test.ui.MiniTableImpl;
import org.junit.jupiter.api.Test;
@ -71,8 +73,8 @@ public class MatchPOTest extends AbstractTestCase {
@Test
public void testOrderInvoiceReceiptMatching() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 114); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), 124); // Elm Tree
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.TREE_FARM.id); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.ELM.id); // Elm Tree
MOrder order = new MOrder(Env.getCtx(), 0, getTrxName());
order.setBPartner(bpartner);
@ -110,7 +112,7 @@ public class MatchPOTest extends AbstractTestCase {
invoice.load(getTrxName());
assertEquals(DocAction.STATUS_Completed, invoice.getDocStatus());
MInOut receipt = new MInOut(invoice, 122, invoice.getDateInvoiced(), getM_Warehouse_ID()); // MM Receipt
MInOut receipt = new MInOut(invoice, DictionaryIDs.C_DocType.MM_RECEIPT.id, invoice.getDateInvoiced(), getM_Warehouse_ID()); // MM Receipt
receipt.saveEx();
MWarehouse wh = MWarehouse.get(Env.getCtx(), receipt.getM_Warehouse_ID());
@ -143,8 +145,8 @@ public class MatchPOTest extends AbstractTestCase {
@Test
public void testOrderReceiptInvoiceMatching() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 114); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), 124); // Elm Tree
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.TREE_FARM.id); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.ELM.id); // Elm Tree
MOrder order = new MOrder(Env.getCtx(), 0, getTrxName());
order.setBPartner(bpartner);
@ -165,7 +167,7 @@ public class MatchPOTest extends AbstractTestCase {
order.load(getTrxName());
assertEquals(DocAction.STATUS_Completed, order.getDocStatus());
MInOut receipt = new MInOut(order, 122, order.getDateOrdered()); // MM Receipt
MInOut receipt = new MInOut(order, DictionaryIDs.C_DocType.MM_RECEIPT.id, order.getDateOrdered()); // MM Receipt
receipt.saveEx();
MWarehouse wh = MWarehouse.get(Env.getCtx(), receipt.getM_Warehouse_ID());
@ -213,8 +215,8 @@ public class MatchPOTest extends AbstractTestCase {
* https://idempiere.atlassian.net/browse/IDEMPIERE-3212
*/
public void testOrderMultiInvoiceReceiptMatching() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 114); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), 124); // Elm Tree
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.TREE_FARM.id); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.ELM.id); // Elm Tree
MOrder order = new MOrder(Env.getCtx(), 0, getTrxName());
order.setBPartner(bpartner);
@ -252,7 +254,7 @@ public class MatchPOTest extends AbstractTestCase {
invoice.load(getTrxName());
assertEquals(DocAction.STATUS_Completed, invoice.getDocStatus());
MInOut receipt = new MInOut(invoice, 122, invoice.getDateInvoiced(), getM_Warehouse_ID()); // MM Receipt
MInOut receipt = new MInOut(invoice, DictionaryIDs.C_DocType.MM_RECEIPT.id, invoice.getDateInvoiced(), getM_Warehouse_ID()); // MM Receipt
receipt.saveEx();
MWarehouse wh = MWarehouse.get(Env.getCtx(), receipt.getM_Warehouse_ID());
@ -316,7 +318,7 @@ public class MatchPOTest extends AbstractTestCase {
invoice.load(getTrxName());
assertEquals(DocAction.STATUS_Completed, invoice.getDocStatus());
receipt = new MInOut(invoice, 122, invoice.getDateInvoiced(), getM_Warehouse_ID()); // MM Receipt
receipt = new MInOut(invoice, DictionaryIDs.C_DocType.MM_RECEIPT.id, invoice.getDateInvoiced(), getM_Warehouse_ID()); // MM Receipt
receipt.saveEx();
receiptLine = new MInOutLine(receipt);
@ -343,7 +345,7 @@ public class MatchPOTest extends AbstractTestCase {
matchPOs = MMatchPO.get(Env.getCtx(), invoiceLine.getC_OrderLine_ID(), invoiceLine.getC_InvoiceLine_ID(), getTrxName());
receipt = new MInOut(invoice, 122, invoice.getDateInvoiced(), getM_Warehouse_ID()); // MM Receipt
receipt = new MInOut(invoice, DictionaryIDs.C_DocType.MM_RECEIPT.id, invoice.getDateInvoiced(), getM_Warehouse_ID()); // MM Receipt
receipt.saveEx();
receiptLine = new MInOutLine(receipt);
@ -369,8 +371,8 @@ public class MatchPOTest extends AbstractTestCase {
@Test
public void testOrderMultiReceiptInvoiceMatching() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 114); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), 124); // Elm Tree
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.TREE_FARM.id); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.ELM.id); // Elm Tree
MOrder order = new MOrder(Env.getCtx(), 0, getTrxName());
order.setBPartner(bpartner);
@ -391,7 +393,7 @@ public class MatchPOTest extends AbstractTestCase {
order.load(getTrxName());
assertEquals(DocAction.STATUS_Completed, order.getDocStatus());
MInOut receipt = new MInOut(order, 122, order.getDateOrdered()); // MM Receipt
MInOut receipt = new MInOut(order, DictionaryIDs.C_DocType.MM_RECEIPT.id, order.getDateOrdered()); // MM Receipt
receipt.saveEx();
MWarehouse wh = MWarehouse.get(Env.getCtx(), receipt.getM_Warehouse_ID());
@ -432,7 +434,7 @@ public class MatchPOTest extends AbstractTestCase {
assertEquals(invoiceLine.getC_InvoiceLine_ID(), matchPOs[0].getC_InvoiceLine_ID());
assertTrue(matchPOs[0].getQty().compareTo(new BigDecimal("3"))==0);
receipt = new MInOut(order, 122, order.getDateOrdered()); // MM Receipt
receipt = new MInOut(order, DictionaryIDs.C_DocType.MM_RECEIPT.id, order.getDateOrdered()); // MM Receipt
receipt.saveEx();
receiptLine = new MInOutLine(receipt);
@ -497,8 +499,8 @@ public class MatchPOTest extends AbstractTestCase {
@Test
public void testReverseFullyMatchPO() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 114); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), 124); // Elm Tree
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.TREE_FARM.id); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.ELM.id); // Elm Tree
int initialOnHand = MStorageOnHand.getQtyOnHand(product.get_ID(), getM_Warehouse_ID(), 0, getTrxName()).intValue();
int initialOnOrdered = MStorageReservation.getQty(product.get_ID(), getM_Warehouse_ID(), 0, false, getTrxName()).intValue();
@ -527,7 +529,7 @@ public class MatchPOTest extends AbstractTestCase {
int newOnOrdered = MStorageReservation.getQty(product.get_ID(), getM_Warehouse_ID(), 0, false, getTrxName()).intValue();
assertEquals(initialOnOrdered+1, newOnOrdered, "Unexpected qty on ordered value");
MInOut receipt = new MInOut(order, 122, order.getDateOrdered()); // MM Receipt
MInOut receipt = new MInOut(order, DictionaryIDs.C_DocType.MM_RECEIPT.id, order.getDateOrdered()); // MM Receipt
receipt.saveEx();
MWarehouse wh = MWarehouse.get(Env.getCtx(), receipt.getM_Warehouse_ID());
@ -553,7 +555,7 @@ public class MatchPOTest extends AbstractTestCase {
MMatchPO[] matchPOs = MMatchPO.getOrderLine(Env.getCtx(), orderLine.get_ID(), getTrxName());
assertEquals(1, matchPOs.length, "Unexpected number of MatchPO for order line");
int matchedPOReverse = 200016;
int matchedPOReverse = SystemIDs.PROCESS_M_MATCHPO_REVERSAL;
info = new ProcessInfo("MatchPOReverse", matchedPOReverse, MMatchPO.Table_ID, matchPOs[0].get_ID());
ServerProcessCtl.process(info, getTrx(), false);
assertFalse(info.isError(), info.getSummary());
@ -693,8 +695,8 @@ public class MatchPOTest extends AbstractTestCase {
@Test
public void testReversePartialMatchPO() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 114); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), 124); // Elm Tree
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.TREE_FARM.id); // Tree Farm Inc.
MProduct product = MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.ELM.id); // Elm Tree
int initialOnHand = MStorageOnHand.getQtyOnHand(product.get_ID(), getM_Warehouse_ID(), 0, getTrxName()).intValue();
int initialOnOrdered = MStorageReservation.getQty(product.get_ID(), getM_Warehouse_ID(), 0, false, getTrxName()).intValue();
@ -723,7 +725,7 @@ public class MatchPOTest extends AbstractTestCase {
int newOnOrdered = MStorageReservation.getQty(product.get_ID(), getM_Warehouse_ID(), 0, false, getTrxName()).intValue();
assertEquals(initialOnOrdered+2, newOnOrdered, "Unexpected qty on ordered value");
MInOut receipt = new MInOut(order, 122, order.getDateOrdered()); // MM Receipt
MInOut receipt = new MInOut(order, DictionaryIDs.C_DocType.MM_RECEIPT.id, order.getDateOrdered()); // MM Receipt
receipt.saveEx();
MWarehouse wh = MWarehouse.get(Env.getCtx(), receipt.getM_Warehouse_ID());
@ -750,7 +752,7 @@ public class MatchPOTest extends AbstractTestCase {
MMatchPO[] matchPOs = MMatchPO.getOrderLine(Env.getCtx(), orderLine.get_ID(), getTrxName());
assertEquals(1, matchPOs.length, "Unexpected number of MatchPO for order line");
int matchedPOReverse = 200016;
int matchedPOReverse = SystemIDs.PROCESS_M_MATCHPO_REVERSAL;
info = new ProcessInfo("MatchPOReverse", matchedPOReverse, MMatchPO.Table_ID, matchPOs[0].get_ID());
ServerProcessCtl.process(info, getTrx(), false);
assertFalse(info.isError(), info.getSummary());

View File

@ -60,6 +60,7 @@ import org.compiere.process.ProcessInfo;
import org.compiere.util.Env;
import org.compiere.wf.MWorkflow;
import org.idempiere.test.AbstractTestCase;
import org.idempiere.test.DictionaryIDs;
import org.junit.jupiter.api.Test;
/**
@ -81,8 +82,8 @@ public class Allocation2ndAcctSchemaTest extends AbstractTestCase {
* https://idempiere.atlassian.net/browse/IDEMPIERE-5053
*/
public void testAllocateInvoicePaymentPosting_1() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 117); // C&W Construction
MCharge charge = MCharge.get(Env.getCtx(), 200000); // Freight Charges
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.C_AND_W.id); // C&W Construction
MCharge charge = MCharge.get(Env.getCtx(), DictionaryIDs.C_Charge.FREIGHT.id); // Freight Charges
Timestamp currentDate = Env.getContextAsDate(Env.getCtx(), "#Date");
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(currentDate.getTime());
@ -93,10 +94,10 @@ public class Allocation2ndAcctSchemaTest extends AbstractTestCase {
Timestamp date2 = new Timestamp(cal.getTimeInMillis());
Timestamp date3 = currentDate;
int C_ConversionType_ID = 201; // Company
int C_ConversionType_ID = DictionaryIDs.C_ConversionType.COMPANY.id; // Company
MCurrency usd = MCurrency.get(100); // USD
MCurrency euro = MCurrency.get("EUR"); // EUR
MCurrency usd = MCurrency.get(DictionaryIDs.C_Currency.USD.id); // USD
MCurrency euro = MCurrency.get(DictionaryIDs.C_Currency.EUR.id); // EUR
BigDecimal eurToUsd1 = new BigDecimal(32.458922422202);
MConversionRate cr1 = createConversionRate(euro.getC_Currency_ID(), usd.getC_Currency_ID(), C_ConversionType_ID, date1, eurToUsd1, false);
@ -106,7 +107,7 @@ public class Allocation2ndAcctSchemaTest extends AbstractTestCase {
BigDecimal eurToUsd3 = new BigDecimal(33.27812049435);
MConversionRate cr3 = createConversionRate(euro.getC_Currency_ID(), usd.getC_Currency_ID(), C_ConversionType_ID, date3, eurToUsd3, false);
int M_PriceList_ID = 103; // Export in EUR
int M_PriceList_ID = DictionaryIDs.M_PriceList.EXPORT.id; // Export in EUR
try {
MInvoice invoice1 = createInvoice(true, bpartner, date1, M_PriceList_ID, C_ConversionType_ID);
@ -186,19 +187,19 @@ public class Allocation2ndAcctSchemaTest extends AbstractTestCase {
* https://idempiere.atlassian.net/browse/IDEMPIERE-5053
*/
public void testAllocateInvoicePaymentPosting_2() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 117); // C&W Construction
MCharge charge = MCharge.get(Env.getCtx(), 200000); // Freight Charges
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.C_AND_W.id); // C&W Construction
MCharge charge = MCharge.get(Env.getCtx(), DictionaryIDs.C_Charge.FREIGHT.id); // Freight Charges
Timestamp currentDate = Env.getContextAsDate(Env.getCtx(), "#Date");
Timestamp date = currentDate;
int C_ConversionType_ID = 201; // Company
int C_ConversionType_ID = DictionaryIDs.C_ConversionType.COMPANY.id; // Company
MCurrency usd = MCurrency.get(100); // USD
MCurrency euro = MCurrency.get("EUR"); // EUR
MCurrency usd = MCurrency.get(DictionaryIDs.C_Currency.USD.id); // USD
MCurrency euro = MCurrency.get(DictionaryIDs.C_Currency.EUR.id); // EUR
BigDecimal eurToUsd = new BigDecimal(32.458922422202);
MConversionRate cr = createConversionRate(euro.getC_Currency_ID(), usd.getC_Currency_ID(), C_ConversionType_ID, date, eurToUsd, false);
int M_PriceList_ID = 103; // Export in EUR
int M_PriceList_ID = DictionaryIDs.M_PriceList.EXPORT.id; // Export in EUR
try {
MInvoice invoice1 = createInvoice(true, bpartner, date, M_PriceList_ID, C_ConversionType_ID);
@ -270,8 +271,8 @@ public class Allocation2ndAcctSchemaTest extends AbstractTestCase {
* https://idempiere.atlassian.net/browse/IDEMPIERE-4200
*/
public void testAllocateInvoicePaymentPosting_3() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 117); // C&W Construction
MCharge charge = MCharge.get(Env.getCtx(), 200000); // Freight Charges
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.C_AND_W.id); // C&W Construction
MCharge charge = MCharge.get(Env.getCtx(), DictionaryIDs.C_Charge.FREIGHT.id); // Freight Charges
Timestamp currentDate = Env.getContextAsDate(Env.getCtx(), "#Date");
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(currentDate.getTime());
@ -279,17 +280,17 @@ public class Allocation2ndAcctSchemaTest extends AbstractTestCase {
Timestamp date1 = new Timestamp(cal.getTimeInMillis());
Timestamp date2 = currentDate;
int C_ConversionType_ID = 201; // Company
int C_ConversionType_ID = DictionaryIDs.C_ConversionType.COMPANY.id; // Company
MCurrency usd = MCurrency.get(100); // USD
MCurrency euro = MCurrency.get("EUR"); // EUR
MCurrency usd = MCurrency.get(DictionaryIDs.C_Currency.USD.id); // USD
MCurrency euro = MCurrency.get(DictionaryIDs.C_Currency.EUR.id); // EUR
BigDecimal eurToUsd1 = new BigDecimal(30.212666962751);
MConversionRate cr1 = createConversionRate(euro.getC_Currency_ID(), usd.getC_Currency_ID(), C_ConversionType_ID, date1, eurToUsd1, false);
BigDecimal eurToUsd2 = new BigDecimal(29.905289946739);
MConversionRate cr2 = createConversionRate(euro.getC_Currency_ID(), usd.getC_Currency_ID(), C_ConversionType_ID, date2, eurToUsd2, false);
int M_PriceList_ID = 103; // Export in EUR
int M_PriceList_ID = DictionaryIDs.M_PriceList.EXPORT.id; // Export in EUR
try {
MBankAccount ba = getBankAccount(usd.getC_Currency_ID());
@ -341,19 +342,19 @@ public class Allocation2ndAcctSchemaTest extends AbstractTestCase {
* https://idempiere.atlassian.net/browse/IDEMPIERE-4200
*/
public void testAllocateInvoicePaymentPosting_4() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 117); // C&W Construction
MCharge charge = MCharge.get(Env.getCtx(), 200000); // Freight Charges
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.C_AND_W.id); // C&W Construction
MCharge charge = MCharge.get(Env.getCtx(), DictionaryIDs.C_Charge.FREIGHT.id); // Freight Charges
Timestamp currentDate = Env.getContextAsDate(Env.getCtx(), "#Date");
Timestamp date = currentDate;
int C_ConversionType_ID = 201; // Company
int C_ConversionType_ID = DictionaryIDs.C_ConversionType.COMPANY.id; // Company
MCurrency usd = MCurrency.get(100); // USD
MCurrency euro = MCurrency.get("EUR"); // EUR
MCurrency usd = MCurrency.get(DictionaryIDs.C_Currency.USD.id); // USD
MCurrency euro = MCurrency.get(DictionaryIDs.C_Currency.EUR.id); // EUR
BigDecimal eurToUsd = new BigDecimal(30.212666962751);
MConversionRate cr = createConversionRate(euro.getC_Currency_ID(), usd.getC_Currency_ID(), C_ConversionType_ID, date, eurToUsd, false);
int M_PriceList_ID = 103; // Export in EUR
int M_PriceList_ID = DictionaryIDs.M_PriceList.EXPORT.id; // Export in EUR
try {
MBankAccount ba = getBankAccount(usd.getC_Currency_ID());
@ -407,8 +408,8 @@ public class Allocation2ndAcctSchemaTest extends AbstractTestCase {
* https://idempiere.atlassian.net/browse/IDEMPIERE-4200
*/
public void testAllocateInvoicePaymentPosting_5() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 117); // C&W Construction
MCharge charge = MCharge.get(Env.getCtx(), 200000); // Freight Charges
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.C_AND_W.id); // C&W Construction
MCharge charge = MCharge.get(Env.getCtx(), DictionaryIDs.C_Charge.FREIGHT.id); // Freight Charges
Timestamp currentDate = Env.getContextAsDate(Env.getCtx(), "#Date");
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(currentDate.getTime());
@ -416,17 +417,17 @@ public class Allocation2ndAcctSchemaTest extends AbstractTestCase {
Timestamp date1 = new Timestamp(cal.getTimeInMillis());
Timestamp date2 = currentDate;
int C_ConversionType_ID = 201; // Company
int C_ConversionType_ID = DictionaryIDs.C_ConversionType.COMPANY.id; // Company
MCurrency usd = MCurrency.get(100); // USD
MCurrency euro = MCurrency.get("EUR"); // EUR
MCurrency usd = MCurrency.get(DictionaryIDs.C_Currency.USD.id); // USD
MCurrency euro = MCurrency.get(DictionaryIDs.C_Currency.EUR.id); // EUR
BigDecimal eurToUsd1 = new BigDecimal(29.905289946739);
MConversionRate cr1 = createConversionRate(euro.getC_Currency_ID(), usd.getC_Currency_ID(), C_ConversionType_ID, date1, eurToUsd1, false);
BigDecimal eurToUsd2 = new BigDecimal(31.526248754713);
MConversionRate cr2 = createConversionRate(euro.getC_Currency_ID(), usd.getC_Currency_ID(), C_ConversionType_ID, date2, eurToUsd2, false);
int M_PriceList_ID = 103; // Export in EUR
int M_PriceList_ID = DictionaryIDs.M_PriceList.EXPORT.id; // Export in EUR
try {
MInvoice invoice1 = createInvoice(true, bpartner, date1, M_PriceList_ID, C_ConversionType_ID);
@ -556,19 +557,19 @@ public class Allocation2ndAcctSchemaTest extends AbstractTestCase {
* https://idempiere.atlassian.net/browse/IDEMPIERE-4200
*/
public void testAllocateInvoicePaymentPosting_6() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 117); // C&W Construction
MCharge charge = MCharge.get(Env.getCtx(), 200000); // Freight Charges
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.C_AND_W.id); // C&W Construction
MCharge charge = MCharge.get(Env.getCtx(), DictionaryIDs.C_Charge.FREIGHT.id); // Freight Charges
Timestamp currentDate = Env.getContextAsDate(Env.getCtx(), "#Date");
Timestamp date = currentDate;
int C_ConversionType_ID = 201; // Company
int C_ConversionType_ID = DictionaryIDs.C_ConversionType.COMPANY.id; // Company
MCurrency usd = MCurrency.get(100); // USD
MCurrency euro = MCurrency.get("EUR"); // EUR
MCurrency usd = MCurrency.get(DictionaryIDs.C_Currency.USD.id); // USD
MCurrency euro = MCurrency.get(DictionaryIDs.C_Currency.EUR.id); // EUR
BigDecimal eurToUsd = new BigDecimal(29.905289946739);
MConversionRate cr = createConversionRate(euro.getC_Currency_ID(), usd.getC_Currency_ID(), C_ConversionType_ID, date, eurToUsd, false);
int M_PriceList_ID = 103; // Export in EUR
int M_PriceList_ID = DictionaryIDs.M_PriceList.EXPORT.id; // Export in EUR
try {
MInvoice invoice1 = createInvoice(true, bpartner, date, M_PriceList_ID, C_ConversionType_ID);
@ -689,8 +690,8 @@ public class Allocation2ndAcctSchemaTest extends AbstractTestCase {
* https://idempiere.atlassian.net/browse/IDEMPIERE-4127
*/
public void testAllocateInvoicePaymentPosting_7() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 117); // C&W Construction
MCharge charge = MCharge.get(Env.getCtx(), 200000); // Freight Charges
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.C_AND_W.id); // C&W Construction
MCharge charge = MCharge.get(Env.getCtx(), DictionaryIDs.C_Charge.FREIGHT.id); // Freight Charges
Timestamp currentDate = Env.getContextAsDate(Env.getCtx(), "#Date");
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(currentDate.getTime());
@ -698,17 +699,17 @@ public class Allocation2ndAcctSchemaTest extends AbstractTestCase {
Timestamp date1 = new Timestamp(cal.getTimeInMillis());
Timestamp date2 = currentDate;
int C_ConversionType_ID = 201; // Company
int C_ConversionType_ID = DictionaryIDs.C_ConversionType.COMPANY.id; // Company
MCurrency usd = MCurrency.get(100); // USD
MCurrency euro = MCurrency.get("EUR"); // EUR
MCurrency usd = MCurrency.get(DictionaryIDs.C_Currency.USD.id); // USD
MCurrency euro = MCurrency.get(DictionaryIDs.C_Currency.EUR.id); // EUR
BigDecimal eurToUsd1 = new BigDecimal(30.212666962751);
MConversionRate cr1 = createConversionRate(euro.getC_Currency_ID(), usd.getC_Currency_ID(), C_ConversionType_ID, date1, eurToUsd1, false);
BigDecimal eurToUsd2 = new BigDecimal(29.905289946739);
MConversionRate cr2 = createConversionRate(euro.getC_Currency_ID(), usd.getC_Currency_ID(), C_ConversionType_ID, date2, eurToUsd2, false);
int M_PriceList_ID = 103; // Export in EUR
int M_PriceList_ID = DictionaryIDs.M_PriceList.EXPORT.id; // Export in EUR
try {
MBankAccount ba = getBankAccount(usd.getC_Currency_ID());
@ -790,19 +791,19 @@ public class Allocation2ndAcctSchemaTest extends AbstractTestCase {
* https://idempiere.atlassian.net/browse/IDEMPIERE-4127
*/
public void testAllocateInvoicePaymentPosting_8() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 117); // C&W Construction
MCharge charge = MCharge.get(Env.getCtx(), 200000); // Freight Charges
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.C_AND_W.id); // C&W Construction
MCharge charge = MCharge.get(Env.getCtx(), DictionaryIDs.C_Charge.FREIGHT.id); // Freight Charges
Timestamp currentDate = Env.getContextAsDate(Env.getCtx(), "#Date");
Timestamp date = currentDate;
int C_ConversionType_ID = 201; // Company
int C_ConversionType_ID = DictionaryIDs.C_ConversionType.COMPANY.id; // Company
MCurrency usd = MCurrency.get(100); // USD
MCurrency euro = MCurrency.get("EUR"); // EUR
MCurrency usd = MCurrency.get(DictionaryIDs.C_Currency.USD.id); // USD
MCurrency euro = MCurrency.get(DictionaryIDs.C_Currency.EUR.id); // EUR
BigDecimal eurToUsd = new BigDecimal(30.212666962751);
MConversionRate cr = createConversionRate(euro.getC_Currency_ID(), usd.getC_Currency_ID(), C_ConversionType_ID, date, eurToUsd, false);
int M_PriceList_ID = 103; // Export in EUR
int M_PriceList_ID = DictionaryIDs.M_PriceList.EXPORT.id; // Export in EUR
try {
MBankAccount ba = getBankAccount(usd.getC_Currency_ID());
@ -880,8 +881,8 @@ public class Allocation2ndAcctSchemaTest extends AbstractTestCase {
* https://idempiere.atlassian.net/browse/IDEMPIERE-4127
*/
public void testAllocateInvoicePaymentPosting_9() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 117); // C&W Construction
MCharge charge = MCharge.get(Env.getCtx(), 200000); // Freight Charges
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.C_AND_W.id); // C&W Construction
MCharge charge = MCharge.get(Env.getCtx(), DictionaryIDs.C_Charge.FREIGHT.id); // Freight Charges
Timestamp currentDate = Env.getContextAsDate(Env.getCtx(), "#Date");
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(currentDate.getTime());
@ -889,17 +890,17 @@ public class Allocation2ndAcctSchemaTest extends AbstractTestCase {
Timestamp date1 = new Timestamp(cal.getTimeInMillis());
Timestamp date2 = currentDate;
int C_ConversionType_ID = 201; // Company
int C_ConversionType_ID = DictionaryIDs.C_ConversionType.COMPANY.id; // Company
MCurrency usd = MCurrency.get(100); // USD
MCurrency euro = MCurrency.get("EUR"); // EUR
MCurrency usd = MCurrency.get(DictionaryIDs.C_Currency.USD.id); // USD
MCurrency euro = MCurrency.get(DictionaryIDs.C_Currency.EUR.id); // EUR
BigDecimal eurToUsd1 = new BigDecimal(30.212666962751);
MConversionRate cr1 = createConversionRate(euro.getC_Currency_ID(), usd.getC_Currency_ID(), C_ConversionType_ID, date1, eurToUsd1, false);
BigDecimal eurToUsd2 = new BigDecimal(29.905289946739);
MConversionRate cr2 = createConversionRate(euro.getC_Currency_ID(), usd.getC_Currency_ID(), C_ConversionType_ID, date2, eurToUsd2, false);
int M_PriceList_ID = 103; // Export in EUR
int M_PriceList_ID = DictionaryIDs.M_PriceList.EXPORT.id; // Export in EUR
try {
MBankAccount ba = getBankAccount(usd.getC_Currency_ID());
@ -979,19 +980,19 @@ public class Allocation2ndAcctSchemaTest extends AbstractTestCase {
* https://idempiere.atlassian.net/browse/IDEMPIERE-4127
*/
public void testAllocateInvoicePaymentPosting_10() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 117); // C&W Construction
MCharge charge = MCharge.get(Env.getCtx(), 200000); // Freight Charges
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.C_AND_W.id); // C&W Construction
MCharge charge = MCharge.get(Env.getCtx(), DictionaryIDs.C_Charge.FREIGHT.id); // Freight Charges
Timestamp currentDate = Env.getContextAsDate(Env.getCtx(), "#Date");
Timestamp date = currentDate;
int C_ConversionType_ID = 201; // Company
int C_ConversionType_ID = DictionaryIDs.C_ConversionType.COMPANY.id; // Company
MCurrency usd = MCurrency.get(100); // USD
MCurrency euro = MCurrency.get("EUR"); // EUR
MCurrency usd = MCurrency.get(DictionaryIDs.C_Currency.USD.id); // USD
MCurrency euro = MCurrency.get(DictionaryIDs.C_Currency.EUR.id); // EUR
BigDecimal eurToUsd = new BigDecimal(30.212666962751);
MConversionRate cr = createConversionRate(euro.getC_Currency_ID(), usd.getC_Currency_ID(), C_ConversionType_ID, date, eurToUsd, false);
int M_PriceList_ID = 103; // Export in EUR
int M_PriceList_ID = DictionaryIDs.M_PriceList.EXPORT.id; // Export in EUR
try {
MBankAccount ba = getBankAccount(usd.getC_Currency_ID());
@ -1064,8 +1065,8 @@ public class Allocation2ndAcctSchemaTest extends AbstractTestCase {
* https://idempiere.atlassian.net/browse/IDEMPIERE-4696
*/
public void testAllocateInvoicePosting_1() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 114); // Tree Farm Inc.
MCharge charge = MCharge.get(Env.getCtx(), 200000); // Freight Charges
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.TREE_FARM.id); // Tree Farm Inc.
MCharge charge = MCharge.get(Env.getCtx(), DictionaryIDs.C_Charge.FREIGHT.id); // Freight Charges
Timestamp currentDate = Env.getContextAsDate(Env.getCtx(), "#Date");
Calendar cal = Calendar.getInstance();
@ -1074,17 +1075,17 @@ public class Allocation2ndAcctSchemaTest extends AbstractTestCase {
Timestamp date1 = new Timestamp(cal.getTimeInMillis());
Timestamp date2 = currentDate;
int C_ConversionType_ID = 201; // Company
int C_ConversionType_ID = DictionaryIDs.C_ConversionType.COMPANY.id; // Company
MCurrency usd = MCurrency.get(100); // USD
MCurrency euro = MCurrency.get("EUR"); // EUR
MCurrency usd = MCurrency.get(DictionaryIDs.C_Currency.USD.id); // USD
MCurrency euro = MCurrency.get(DictionaryIDs.C_Currency.EUR.id); // EUR
BigDecimal eurToUsd1 = new BigDecimal(30);
MConversionRate cr1 = createConversionRate(euro.getC_Currency_ID(), usd.getC_Currency_ID(), C_ConversionType_ID, date1, eurToUsd1);
BigDecimal eurToUsd2 = new BigDecimal(31);
MConversionRate cr2 = createConversionRate(euro.getC_Currency_ID(), usd.getC_Currency_ID(), C_ConversionType_ID, date2, eurToUsd2);
int M_PriceList_ID = 103; // Export in EUR
int M_PriceList_ID = DictionaryIDs.M_PriceList.EXPORT.id; // Export in EUR
try {
MInvoice invoice = createInvoice(true, bpartner, date1, M_PriceList_ID, C_ConversionType_ID);
@ -1127,19 +1128,19 @@ public class Allocation2ndAcctSchemaTest extends AbstractTestCase {
* https://idempiere.atlassian.net/browse/IDEMPIERE-4696
*/
public void testAllocateInvoicePosting_2() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 114); // Tree Farm Inc.
MCharge charge = MCharge.get(Env.getCtx(), 200000); // Freight Charges
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.TREE_FARM.id); // Tree Farm Inc.
MCharge charge = MCharge.get(Env.getCtx(), DictionaryIDs.C_Charge.FREIGHT.id); // Freight Charges
Timestamp currentDate = Env.getContextAsDate(Env.getCtx(), "#Date");
Timestamp date = currentDate;
int C_ConversionType_ID = 201; // Company
int C_ConversionType_ID = DictionaryIDs.C_ConversionType.COMPANY.id; // Company
MCurrency usd = MCurrency.get(100); // USD
MCurrency euro = MCurrency.get("EUR"); // EUR
MCurrency usd = MCurrency.get(DictionaryIDs.C_Currency.USD.id); // USD
MCurrency euro = MCurrency.get(DictionaryIDs.C_Currency.EUR.id); // EUR
BigDecimal eurToUsd = new BigDecimal(30);
MConversionRate cr = createConversionRate(euro.getC_Currency_ID(), usd.getC_Currency_ID(), C_ConversionType_ID, date, eurToUsd);
int M_PriceList_ID = 103; // Export in EUR
int M_PriceList_ID = DictionaryIDs.M_PriceList.EXPORT.id; // Export in EUR
try {
MInvoice invoice = createInvoice(true, bpartner, date, M_PriceList_ID, C_ConversionType_ID);
@ -1178,8 +1179,8 @@ public class Allocation2ndAcctSchemaTest extends AbstractTestCase {
* https://idempiere.atlassian.net/browse/IDEMPIERE-4696
*/
public void testAllocateInvoicePosting_3() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 114); // Tree Farm Inc.
MCharge charge = MCharge.get(Env.getCtx(), 200000); // Freight Charges
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.TREE_FARM.id); // Tree Farm Inc.
MCharge charge = MCharge.get(Env.getCtx(), DictionaryIDs.C_Charge.FREIGHT.id); // Freight Charges
Timestamp currentDate = Env.getContextAsDate(Env.getCtx(), "#Date");
Calendar cal = Calendar.getInstance();
@ -1188,17 +1189,17 @@ public class Allocation2ndAcctSchemaTest extends AbstractTestCase {
Timestamp date1 = new Timestamp(cal.getTimeInMillis());
Timestamp date2 = currentDate;
int C_ConversionType_ID = 201; // Company
int C_ConversionType_ID = DictionaryIDs.C_ConversionType.COMPANY.id; // Company
MCurrency usd = MCurrency.get(100); // USD
MCurrency euro = MCurrency.get("EUR"); // EUR
MCurrency usd = MCurrency.get(DictionaryIDs.C_Currency.USD.id); // USD
MCurrency euro = MCurrency.get(DictionaryIDs.C_Currency.EUR.id); // EUR
BigDecimal eurToUsd1 = new BigDecimal(30);
MConversionRate cr1 = createConversionRate(euro.getC_Currency_ID(), usd.getC_Currency_ID(), C_ConversionType_ID, date1, eurToUsd1);
BigDecimal eurToUsd2 = new BigDecimal(31);
MConversionRate cr2 = createConversionRate(euro.getC_Currency_ID(), usd.getC_Currency_ID(), C_ConversionType_ID, date2, eurToUsd2);
int M_PriceList_ID = 103; // Export in EUR
int M_PriceList_ID = DictionaryIDs.M_PriceList.EXPORT.id; // Export in EUR
try {
MInvoice invoice = createInvoice(true, bpartner, date1, M_PriceList_ID, C_ConversionType_ID);
@ -1250,19 +1251,19 @@ public class Allocation2ndAcctSchemaTest extends AbstractTestCase {
* https://idempiere.atlassian.net/browse/IDEMPIERE-4696
*/
public void testAllocateInvoicePosting_4() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 114); // Tree Farm Inc.
MCharge charge = MCharge.get(Env.getCtx(), 200000); // Freight Charges
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.TREE_FARM.id); // Tree Farm Inc.
MCharge charge = MCharge.get(Env.getCtx(), DictionaryIDs.C_Charge.FREIGHT.id); // Freight Charges
Timestamp currentDate = Env.getContextAsDate(Env.getCtx(), "#Date");
Timestamp date = currentDate;
int C_ConversionType_ID = 201; // Company
int C_ConversionType_ID = DictionaryIDs.C_ConversionType.COMPANY.id; // Company
MCurrency usd = MCurrency.get(100); // USD
MCurrency euro = MCurrency.get("EUR"); // EUR
MCurrency usd = MCurrency.get(DictionaryIDs.C_Currency.USD.id); // USD
MCurrency euro = MCurrency.get(DictionaryIDs.C_Currency.EUR.id); // EUR
BigDecimal eurToUsd = new BigDecimal(30);
MConversionRate cr = createConversionRate(euro.getC_Currency_ID(), usd.getC_Currency_ID(), C_ConversionType_ID, date, eurToUsd);
int M_PriceList_ID = 103; // Export in EUR
int M_PriceList_ID = DictionaryIDs.M_PriceList.EXPORT.id; // Export in EUR
try {
MInvoice invoice = createInvoice(true, bpartner, date, M_PriceList_ID, C_ConversionType_ID);
@ -1310,7 +1311,7 @@ public class Allocation2ndAcctSchemaTest extends AbstractTestCase {
* https://idempiere.atlassian.net/browse/IDEMPIERE-4696
*/
public void testAllocatePaymentPosting_1() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 114); // Tree Farm Inc.
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.TREE_FARM.id); // Tree Farm Inc.
Timestamp currentDate = Env.getContextAsDate(Env.getCtx(), "#Date");
Calendar cal = Calendar.getInstance();
@ -1319,10 +1320,10 @@ public class Allocation2ndAcctSchemaTest extends AbstractTestCase {
Timestamp date1 = new Timestamp(cal.getTimeInMillis());
Timestamp date2 = currentDate;
int C_ConversionType_ID = 201; // Company
int C_ConversionType_ID = DictionaryIDs.C_ConversionType.COMPANY.id; // Company
MCurrency usd = MCurrency.get(100); // USD
MCurrency euro = MCurrency.get("EUR"); // EUR
MCurrency usd = MCurrency.get(DictionaryIDs.C_Currency.USD.id); // USD
MCurrency euro = MCurrency.get(DictionaryIDs.C_Currency.EUR.id); // EUR
BigDecimal eurToUsd1 = new BigDecimal(30);
MConversionRate cr1 = createConversionRate(euro.getC_Currency_ID(), usd.getC_Currency_ID(), C_ConversionType_ID, date1, eurToUsd1);
@ -1369,14 +1370,14 @@ public class Allocation2ndAcctSchemaTest extends AbstractTestCase {
* https://idempiere.atlassian.net/browse/IDEMPIERE-4696
*/
public void testAllocatePaymentPosting_2() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 114); // Tree Farm Inc.
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.TREE_FARM.id); // Tree Farm Inc.
Timestamp currentDate = Env.getContextAsDate(Env.getCtx(), "#Date");
Timestamp date = currentDate;
int C_ConversionType_ID = 201; // Company
int C_ConversionType_ID = DictionaryIDs.C_ConversionType.COMPANY.id; // Company
MCurrency usd = MCurrency.get(100); // USD
MCurrency euro = MCurrency.get("EUR"); // EUR
MCurrency usd = MCurrency.get(DictionaryIDs.C_Currency.USD.id); // USD
MCurrency euro = MCurrency.get(DictionaryIDs.C_Currency.EUR.id); // EUR
BigDecimal eurToUsd = new BigDecimal(30);
MConversionRate cr = createConversionRate(euro.getC_Currency_ID(), usd.getC_Currency_ID(), C_ConversionType_ID, date, eurToUsd);
@ -1416,7 +1417,7 @@ public class Allocation2ndAcctSchemaTest extends AbstractTestCase {
* https://idempiere.atlassian.net/browse/IDEMPIERE-4696
*/
public void testAllocatePaymentPosting_3() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 114); // Tree Farm Inc.
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.TREE_FARM.id); // Tree Farm Inc.
Timestamp currentDate = Env.getContextAsDate(Env.getCtx(), "#Date");
Calendar cal = Calendar.getInstance();
@ -1425,10 +1426,10 @@ public class Allocation2ndAcctSchemaTest extends AbstractTestCase {
Timestamp date1 = new Timestamp(cal.getTimeInMillis());
Timestamp date2 = currentDate;
int C_ConversionType_ID = 201; // Company
int C_ConversionType_ID = DictionaryIDs.C_ConversionType.COMPANY.id; // Company
MCurrency usd = MCurrency.get(100); // USD
MCurrency euro = MCurrency.get("EUR"); // EUR
MCurrency usd = MCurrency.get(DictionaryIDs.C_Currency.USD.id); // USD
MCurrency euro = MCurrency.get(DictionaryIDs.C_Currency.EUR.id); // EUR
BigDecimal eurToUsd1 = new BigDecimal(30);
MConversionRate cr1 = createConversionRate(euro.getC_Currency_ID(), usd.getC_Currency_ID(), C_ConversionType_ID, date1, eurToUsd1);
@ -1481,14 +1482,14 @@ public class Allocation2ndAcctSchemaTest extends AbstractTestCase {
* https://idempiere.atlassian.net/browse/IDEMPIERE-4696
*/
public void testAllocatePaymentPosting_4() {
MBPartner bpartner = MBPartner.get(Env.getCtx(), 114); // Tree Farm Inc.
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.TREE_FARM.id); // Tree Farm Inc.
Timestamp currentDate = Env.getContextAsDate(Env.getCtx(), "#Date");
Timestamp date = currentDate;
int C_ConversionType_ID = 201; // Company
int C_ConversionType_ID = DictionaryIDs.C_ConversionType.COMPANY.id; // Company
MCurrency usd = MCurrency.get(100); // USD
MCurrency euro = MCurrency.get("EUR"); // EUR
MCurrency usd = MCurrency.get(DictionaryIDs.C_Currency.USD.id); // USD
MCurrency euro = MCurrency.get(DictionaryIDs.C_Currency.EUR.id); // EUR
BigDecimal eurToUsd = new BigDecimal(30);
MConversionRate cr = createConversionRate(euro.getC_Currency_ID(), usd.getC_Currency_ID(), C_ConversionType_ID, date, eurToUsd);

View File

@ -45,6 +45,7 @@ import org.compiere.util.Msg;
import org.compiere.util.TimeUtil;
import org.compiere.wf.MWorkflow;
import org.idempiere.test.AbstractTestCase;
import org.idempiere.test.DictionaryIDs;
import org.junit.jupiter.api.Test;
/**
@ -62,7 +63,7 @@ public class BankStatementTest extends AbstractTestCase {
@Test
public void testCompleteStatement() {
MBankStatement stmt = new MBankStatement(Env.getCtx(), 0, getTrxName());
stmt.setC_BankAccount_ID(100);
stmt.setC_BankAccount_ID(DictionaryIDs.C_BankAccount.ACCOUNT_1234.id);
Timestamp today = TimeUtil.getDay(System.currentTimeMillis());
stmt.setStatementDate(today);
stmt.setDateAcct(today);
@ -76,7 +77,7 @@ public class BankStatementTest extends AbstractTestCase {
line.setStatementLineDate(today);
line.setStmtAmt(new BigDecimal("10.00"));
line.setTrxAmt(new BigDecimal("10.00"));
line.setC_Currency_ID(100);
line.setC_Currency_ID(DictionaryIDs.C_Currency.USD.id);
line.saveEx();
ProcessInfo pi = MWorkflow.runDocumentActionWorkflow(stmt, DocAction.ACTION_Complete);
@ -107,14 +108,14 @@ public class BankStatementTest extends AbstractTestCase {
try {
MPayment payment1 = new MPayment(Env.getCtx(), 0, getTrxName());
payment1.setC_BPartner_ID(117); //C&W
payment1.setC_BPartner_ID(DictionaryIDs.C_BPartner.C_AND_W.id); //C&W
payment1.setC_DocType_ID(true); // Receipt
payment1.setDocStatus(DocAction.STATUS_Drafted);
payment1.setDocAction(DocAction.ACTION_Complete);
payment1.setPayAmt(Env.ONEHUNDRED);
payment1.setTenderType(MPayment.TENDERTYPE_Check);
payment1.setC_BankAccount_ID(100); // 1234_MoneyBank_123456789
payment1.setC_Currency_ID(100); // USD
payment1.setC_BankAccount_ID(DictionaryIDs.C_BankAccount.ACCOUNT_1234.id); // 1234_MoneyBank_123456789
payment1.setC_Currency_ID(DictionaryIDs.C_Currency.USD.id); // USD
payment1.setDateTrx(today);
payment1.setDateAcct(today);
payment1.saveEx();
@ -125,7 +126,7 @@ public class BankStatementTest extends AbstractTestCase {
assertEquals(DocAction.STATUS_Completed, payment1.getDocStatus(), "Payment document status is not completed: " + payment1.getDocStatus());
MBankStatement stmt = new MBankStatement(Env.getCtx(), 0, getTrxName());
stmt.setC_BankAccount_ID(100);
stmt.setC_BankAccount_ID(DictionaryIDs.C_BankAccount.ACCOUNT_1234.id);
stmt.setStatementDate(today);
stmt.setDateAcct(today);
stmt.setName(System.currentTimeMillis()+"");
@ -139,7 +140,7 @@ public class BankStatementTest extends AbstractTestCase {
line.setStmtAmt(payment1.getPayAmt());
line.setTrxAmt(payment1.getPayAmt());
line.setC_Payment_ID(payment1.getC_Payment_ID());
line.setC_Currency_ID(100);
line.setC_Currency_ID(DictionaryIDs.C_Currency.USD.id);
line.saveEx();
pi = MWorkflow.runDocumentActionWorkflow(stmt, DocAction.ACTION_Complete);
@ -187,14 +188,14 @@ public class BankStatementTest extends AbstractTestCase {
}
try {
MPayment payment1 = new MPayment(Env.getCtx(), 0, getTrxName());
payment1.setC_BPartner_ID(117); //C&W
payment1.setC_BPartner_ID(DictionaryIDs.C_BPartner.C_AND_W.id); //C&W
payment1.setC_DocType_ID(true); // Receipt
payment1.setDocStatus(DocAction.STATUS_Drafted);
payment1.setDocAction(DocAction.ACTION_Complete);
payment1.setPayAmt(Env.ONEHUNDRED);
payment1.setTenderType(MPayment.TENDERTYPE_Check);
payment1.setC_BankAccount_ID(100); // 1234_MoneyBank_123456789
payment1.setC_Currency_ID(100); // USD
payment1.setC_BankAccount_ID(DictionaryIDs.C_BankAccount.ACCOUNT_1234.id); // 1234_MoneyBank_123456789
payment1.setC_Currency_ID(DictionaryIDs.C_Currency.USD.id); // USD
payment1.setDateTrx(today);
payment1.setDateAcct(today);
payment1.saveEx();
@ -205,7 +206,7 @@ public class BankStatementTest extends AbstractTestCase {
assertEquals(DocAction.STATUS_Completed, payment1.getDocStatus(), "Payment document status is not completed: " + payment1.getDocStatus());
MBankStatement stmt = new MBankStatement(Env.getCtx(), 0, getTrxName());
stmt.setC_BankAccount_ID(100);
stmt.setC_BankAccount_ID(DictionaryIDs.C_BankAccount.ACCOUNT_1234.id);
stmt.setStatementDate(today);
stmt.setDateAcct(today);
stmt.setName(System.currentTimeMillis()+"");
@ -219,7 +220,7 @@ public class BankStatementTest extends AbstractTestCase {
line.setStmtAmt(payment1.getPayAmt());
line.setTrxAmt(payment1.getPayAmt());
line.setC_Payment_ID(payment1.getC_Payment_ID());
line.setC_Currency_ID(100);
line.setC_Currency_ID(DictionaryIDs.C_Currency.USD.id);
line.saveEx();
pi = MWorkflow.runDocumentActionWorkflow(stmt, DocAction.ACTION_Complete);

View File

@ -62,6 +62,7 @@ import org.compiere.util.Env;
import org.compiere.util.TimeUtil;
import org.compiere.wf.MWorkflow;
import org.idempiere.test.AbstractTestCase;
import org.idempiere.test.DictionaryIDs;
import org.junit.jupiter.api.Test;
/**
@ -72,22 +73,6 @@ public class InventoryTest extends AbstractTestCase {
public InventoryTest() {
}
private static final int PRODCAT_BUSHES = 107;
private static final int TAXCAT_STANDARD = 107;
private static final int UOM_EACH = 100;
private static final int WAREHOUSE_HQ = 103;
private static final int LOCATOR_HQ = 101;
private static final int DOCTYPE_PHYSICAL_INV = 144;
private static final int DOCTYPE_COST_ADJUSTMENT = 200004;
private static final int DOCTYPE_PO = 126;
private static final int DOCTYPE_RECEIPT = 122;
private static final int BP_PATIO = 121;
private static final int USER_GARDENADMIN = 101;
private static final int MULCH_PRODUCT_ID = 137;
private final static int FERTILIZER_LOT_ATTRIBUTESET_ID = 101;
private static final int CHEMICALS_CATEGORY_ID = 109;
private static final int PURCHASE_PRICE_LIST_ID = 102;
/**
* https://idempiere.atlassian.net/browse/IDEMPIERE-4596
*/
@ -97,24 +82,24 @@ public class InventoryTest extends AbstractTestCase {
String trxName = getTrxName();
MProduct product = new MProduct(ctx, 0, trxName);
product.setM_Product_Category_ID(PRODCAT_BUSHES);
product.setM_Product_Category_ID(DictionaryIDs.M_Product_Category.BUSH.id);
product.setName("Test 4596");
product.setValue("T4596");
product.setProductType(MProduct.PRODUCTTYPE_Item);
product.setIsStocked(true);
product.setIsSold(true);
product.setIsPurchased(true);
product.setC_UOM_ID(UOM_EACH);
product.setC_TaxCategory_ID(TAXCAT_STANDARD);
product.setC_UOM_ID(DictionaryIDs.C_UOM.EACH.id);
product.setC_TaxCategory_ID(DictionaryIDs.C_TaxCategory.STANDARD.id);
product.saveEx();
MInventory inventory = new MInventory(ctx, 0, trxName);
inventory.setM_Warehouse_ID(WAREHOUSE_HQ);
inventory.setC_DocType_ID(DOCTYPE_PHYSICAL_INV);
inventory.setM_Warehouse_ID(DictionaryIDs.M_Warehouse.HQ.id);
inventory.setC_DocType_ID(DictionaryIDs.C_DocType.MATERIAL_PHYSICAL_INVENTORY.id);
inventory.saveEx();
MInventoryLine iline = new MInventoryLine(inventory,
LOCATOR_HQ,
DictionaryIDs.M_Locator.HQ.id,
product.getM_Product_ID(),
0, // M_AttributeSetInstance_ID
Env.ZERO, // QtyBook
@ -131,22 +116,22 @@ public class InventoryTest extends AbstractTestCase {
public void testCostAdjustmentLineBeforeSave() {
MClient client = MClient.get(Env.getCtx());
MAcctSchema as = client.getAcctSchema();
MProduct product = new MProduct(Env.getCtx(), MULCH_PRODUCT_ID, getTrxName());
MProduct product = new MProduct(Env.getCtx(), DictionaryIDs.M_Product.MULCH.id, getTrxName());
MCost cost = product.getCostingRecord(as, getAD_Org_ID(), 0, as.getCostingMethod());
if (cost == null || cost.getCurrentCostPrice().signum() == 0) {
createPOAndMRForProduct(MULCH_PRODUCT_ID);
createPOAndMRForProduct(DictionaryIDs.M_Product.MULCH.id);
cost = product.getCostingRecord(as, getAD_Org_ID(), 0, as.getCostingMethod());
}
assertNotNull(cost);
MInventory inventory = new MInventory(Env.getCtx(), 0, getTrxName());
inventory.setC_DocType_ID(DOCTYPE_COST_ADJUSTMENT);
inventory.setC_DocType_ID(DictionaryIDs.C_DocType.COST_ADJUSTMENT.id);
inventory.setCostingMethod(as.getCostingMethod());
inventory.saveEx();
MInventoryLine line = new MInventoryLine(Env.getCtx(), 0, getTrxName());
line.setM_Inventory_ID(inventory.get_ID());
line.setM_Product_ID(MULCH_PRODUCT_ID);
line.setM_Product_ID(DictionaryIDs.M_Product.MULCH.id);
line.setNewCostPrice(cost.getCurrentCostPrice().add(new BigDecimal("0.5")));
line.saveEx();
@ -160,10 +145,10 @@ public class InventoryTest extends AbstractTestCase {
private void createPOAndMRForProduct(int productId, MAttributeSetInstance asi) {
MOrder order = new MOrder(Env.getCtx(), 0, getTrxName());
order.setBPartner(MBPartner.get(Env.getCtx(), BP_PATIO));
order.setC_DocTypeTarget_ID(DOCTYPE_PO);
order.setBPartner(MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.PATIO.id));
order.setC_DocTypeTarget_ID(DictionaryIDs.C_DocType.PURCHASE_ORDER.id);
order.setIsSOTrx(false);
order.setSalesRep_ID(USER_GARDENADMIN);
order.setSalesRep_ID(DictionaryIDs.AD_User.GARDEN_ADMIN.id);
order.setDocStatus(DocAction.STATUS_Drafted);
order.setDocAction(DocAction.ACTION_Complete);
Timestamp today = TimeUtil.getDay(System.currentTimeMillis());
@ -183,7 +168,7 @@ public class InventoryTest extends AbstractTestCase {
order.load(getTrxName());
assertEquals(DocAction.STATUS_Completed, order.getDocStatus());
MInOut receipt1 = new MInOut(order, DOCTYPE_RECEIPT, order.getDateOrdered());
MInOut receipt1 = new MInOut(order, DictionaryIDs.C_DocType.MM_RECEIPT.id, order.getDateOrdered());
receipt1.setDocStatus(DocAction.STATUS_Drafted);
receipt1.setDocAction(DocAction.ACTION_Complete);
receipt1.saveEx();
@ -210,11 +195,11 @@ public class InventoryTest extends AbstractTestCase {
Properties ctx = Env.getCtx();
String trxName = getTrxName();
MAttributeSet set = new MAttributeSet(Env.getCtx(), FERTILIZER_LOT_ATTRIBUTESET_ID, null);
MAttributeSet set = new MAttributeSet(Env.getCtx(), DictionaryIDs.M_AttributeSet.FERTILIZER_LOT.id, null);
set.setIsSerNo(true);
set.saveEx();
MWarehouse wh = new MWarehouse(Env.getCtx(), WAREHOUSE_HQ, null);
MWarehouse wh = new MWarehouse(Env.getCtx(), DictionaryIDs.M_Warehouse.HQ.id, null);
boolean disallow = wh.isDisallowNegativeInv();
MProduct product = null;
try {
@ -226,19 +211,19 @@ public class InventoryTest extends AbstractTestCase {
}
product = new MProduct(ctx, 0, null);
product.setM_Product_Category_ID(CHEMICALS_CATEGORY_ID);
product.setM_Product_Category_ID(DictionaryIDs.M_Product_Category.CHEMICALS.id);
product.setName("testSkipProductWithSerial");
product.setValue("testSkipProductWithSerial");
product.setProductType(MProduct.PRODUCTTYPE_Item);
product.setIsStocked(true);
product.setIsSold(true);
product.setIsPurchased(true);
product.setC_UOM_ID(UOM_EACH);
product.setC_TaxCategory_ID(TAXCAT_STANDARD);
product.setM_AttributeSet_ID(FERTILIZER_LOT_ATTRIBUTESET_ID);
product.setC_UOM_ID(DictionaryIDs.C_UOM.EACH.id);
product.setC_TaxCategory_ID(DictionaryIDs.C_TaxCategory.STANDARD.id);
product.setM_AttributeSet_ID(DictionaryIDs.M_AttributeSet.FERTILIZER_LOT.id);
product.saveEx();
MPriceListVersion plv = MPriceList.get(PURCHASE_PRICE_LIST_ID).getPriceListVersion(null);
MPriceListVersion plv = MPriceList.get(DictionaryIDs.M_PriceList.PURCHASE.id).getPriceListVersion(null);
MProductPrice pp = new MProductPrice(Env.getCtx(), 0, getTrxName());
pp.setM_PriceList_Version_ID(plv.getM_PriceList_Version_ID());
pp.setM_Product_ID(product.get_ID());
@ -247,7 +232,7 @@ public class InventoryTest extends AbstractTestCase {
pp.saveEx();
MAttributeSetInstance asi = new MAttributeSetInstance(Env.getCtx(), 0, getTrxName());
asi.setM_AttributeSet_ID(FERTILIZER_LOT_ATTRIBUTESET_ID);
asi.setM_AttributeSet_ID(DictionaryIDs.M_AttributeSet.FERTILIZER_LOT.id);
asi.setSerNo("testSkipProductWithSerial #1");
asi.saveEx();
@ -258,12 +243,12 @@ public class InventoryTest extends AbstractTestCase {
assertEquals(onhands[0].getM_AttributeSetInstance_ID(), asi.get_ID(), "Unexpected M_AttributeSetInstance_ID for on hand record");
MInventory inventory = new MInventory(ctx, 0, trxName);
inventory.setM_Warehouse_ID(WAREHOUSE_HQ);
inventory.setC_DocType_ID(DOCTYPE_PHYSICAL_INV);
inventory.setM_Warehouse_ID(DictionaryIDs.M_Warehouse.HQ.id);
inventory.setC_DocType_ID(DictionaryIDs.C_DocType.MATERIAL_PHYSICAL_INVENTORY.id);
inventory.saveEx();
MInventoryLine iline = new MInventoryLine(inventory,
LOCATOR_HQ,
DictionaryIDs.M_Locator.HQ.id,
product.getM_Product_ID(),
0, // M_AttributeSetInstance_ID
Env.ONE, // QtyBook
@ -294,11 +279,11 @@ public class InventoryTest extends AbstractTestCase {
Properties ctx = Env.getCtx();
String trxName = getTrxName();
MAttributeSet set = new MAttributeSet(Env.getCtx(), FERTILIZER_LOT_ATTRIBUTESET_ID, null);
MAttributeSet set = new MAttributeSet(Env.getCtx(), DictionaryIDs.M_AttributeSet.FERTILIZER_LOT.id, null);
set.setIsSerNo(true);
set.saveEx();
MWarehouse wh = new MWarehouse(Env.getCtx(), WAREHOUSE_HQ, null);
MWarehouse wh = new MWarehouse(Env.getCtx(), DictionaryIDs.M_Warehouse.HQ.id, null);
boolean disallow = wh.isDisallowNegativeInv();
MProduct product = null;
try {
@ -310,19 +295,19 @@ public class InventoryTest extends AbstractTestCase {
}
product = new MProduct(ctx, 0, null);
product.setM_Product_Category_ID(CHEMICALS_CATEGORY_ID);
product.setM_Product_Category_ID(DictionaryIDs.M_Product_Category.CHEMICALS.id);
product.setName("testSkipProductWithSerial");
product.setValue("testSkipProductWithSerial");
product.setProductType(MProduct.PRODUCTTYPE_Item);
product.setIsStocked(true);
product.setIsSold(true);
product.setIsPurchased(true);
product.setC_UOM_ID(UOM_EACH);
product.setC_TaxCategory_ID(TAXCAT_STANDARD);
product.setM_AttributeSet_ID(FERTILIZER_LOT_ATTRIBUTESET_ID);
product.setC_UOM_ID(DictionaryIDs.C_UOM.EACH.id);
product.setC_TaxCategory_ID(DictionaryIDs.C_TaxCategory.STANDARD.id);
product.setM_AttributeSet_ID(DictionaryIDs.M_AttributeSet.FERTILIZER_LOT.id);
product.saveEx();
MPriceListVersion plv = MPriceList.get(PURCHASE_PRICE_LIST_ID).getPriceListVersion(null);
MPriceListVersion plv = MPriceList.get(DictionaryIDs.M_PriceList.PURCHASE.id).getPriceListVersion(null);
MProductPrice pp = new MProductPrice(Env.getCtx(), 0, getTrxName());
pp.setM_PriceList_Version_ID(plv.getM_PriceList_Version_ID());
pp.setM_Product_ID(product.get_ID());
@ -331,7 +316,7 @@ public class InventoryTest extends AbstractTestCase {
pp.saveEx();
MAttributeSetInstance asi = new MAttributeSetInstance(Env.getCtx(), 0, getTrxName());
asi.setM_AttributeSet_ID(FERTILIZER_LOT_ATTRIBUTESET_ID);
asi.setM_AttributeSet_ID(DictionaryIDs.M_AttributeSet.FERTILIZER_LOT.id);
asi.setSerNo("testSkipProductWithSerial #1");
asi.saveEx();
@ -342,7 +327,7 @@ public class InventoryTest extends AbstractTestCase {
assertEquals(onhands[0].getM_AttributeSetInstance_ID(), asi.get_ID(), "Unexpected M_AttributeSetInstance_ID for on hand record");
MAttributeSetInstance asi1 = new MAttributeSetInstance(Env.getCtx(), 0, getTrxName());
asi1.setM_AttributeSet_ID(FERTILIZER_LOT_ATTRIBUTESET_ID);
asi1.setM_AttributeSet_ID(DictionaryIDs.M_AttributeSet.FERTILIZER_LOT.id);
asi1.saveEx();
createPOAndMRForProduct(product.get_ID(), asi1);
@ -354,12 +339,12 @@ public class InventoryTest extends AbstractTestCase {
assertEquals(onhands[1].getM_AttributeSetInstance_ID(), asi1.get_ID(), "Unexpected M_AttributeSetInstance_ID for second on hand record");
MInventory inventory = new MInventory(ctx, 0, trxName);
inventory.setM_Warehouse_ID(WAREHOUSE_HQ);
inventory.setC_DocType_ID(DOCTYPE_PHYSICAL_INV);
inventory.setM_Warehouse_ID(DictionaryIDs.M_Warehouse.HQ.id);
inventory.setC_DocType_ID(DictionaryIDs.C_DocType.MATERIAL_PHYSICAL_INVENTORY.id);
inventory.saveEx();
MInventoryLine iline = new MInventoryLine(inventory,
LOCATOR_HQ,
DictionaryIDs.M_Locator.HQ.id,
product.getM_Product_ID(),
0, // M_AttributeSetInstance_ID
new BigDecimal("2"), // QtyBook

View File

@ -46,6 +46,7 @@ import org.compiere.util.Env;
import org.compiere.util.TimeUtil;
import org.compiere.wf.MWorkflow;
import org.idempiere.test.AbstractTestCase;
import org.idempiere.test.DictionaryIDs;
import org.junit.jupiter.api.Test;
/**
@ -70,11 +71,11 @@ public class InvoiceCustomerTest extends AbstractTestCase {
// Invoice $200 today
MInvoice invoice = new MInvoice(Env.getCtx(), 0, getTrxName());
invoice.setBPartner(MBPartner.get(Env.getCtx(), 117)); // C&W
invoice.setBPartner(MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.C_AND_W.id)); // C&W
invoice.setC_DocTypeTarget_ID(MDocType.DOCBASETYPE_ARInvoice);
invoice.setC_DocType_ID(invoice.getC_DocTypeTarget_ID()); // required to avoid runDocumentActionWorkflow exception
invoice.setPaymentRule(MInvoice.PAYMENTRULE_Check);
invoice.setC_PaymentTerm_ID(105); // Immediate
invoice.setC_PaymentTerm_ID(DictionaryIDs.C_PaymentTerm.IMMEDIATE.id); // Immediate
Timestamp today = TimeUtil.getDay(System.currentTimeMillis());
invoice.setDateInvoiced(today);
invoice.setDateAcct(today);
@ -84,14 +85,14 @@ public class InvoiceCustomerTest extends AbstractTestCase {
MInvoiceLine line1 = new MInvoiceLine(invoice);
line1.setLine(10);
line1.setC_Charge_ID(100); // Bank Charge
line1.setC_Charge_ID(DictionaryIDs.C_Charge.BANK.id); // Bank Charge
line1.setQty(new BigDecimal("1"));
line1.setPrice(Env.ONEHUNDRED);
line1.saveEx();
MInvoiceLine line2 = new MInvoiceLine(invoice);
line2.setLine(20);
line2.setC_Charge_ID(101); // Commissions Paid
line2.setC_Charge_ID(DictionaryIDs.C_Charge.COMMISSIONS.id); // Commissions Paid
line2.setQty(new BigDecimal("1"));
line2.setPrice(Env.ONEHUNDRED);
line2.saveEx();
@ -112,8 +113,8 @@ public class InvoiceCustomerTest extends AbstractTestCase {
payment1.setDocAction(DocAction.ACTION_Complete);
payment1.setPayAmt(Env.ONEHUNDRED);
payment1.setTenderType(MPayment.TENDERTYPE_Check);
payment1.setC_BankAccount_ID(100); // 1234_MoneyBank_123456789
payment1.setC_Currency_ID(100); // USD
payment1.setC_BankAccount_ID(DictionaryIDs.C_BankAccount.ACCOUNT_1234.id); // 1234_MoneyBank_123456789
payment1.setC_Currency_ID(DictionaryIDs.C_Currency.USD.id); // USD
Timestamp nextweek = TimeUtil.addDays(today, 7);
payment1.setDateTrx(nextweek);
payment1.setDateAcct(nextweek);
@ -140,8 +141,8 @@ public class InvoiceCustomerTest extends AbstractTestCase {
payment2.setDocAction(DocAction.ACTION_Complete);
payment2.setPayAmt(Env.ONEHUNDRED);
payment2.setTenderType(MPayment.TENDERTYPE_Check);
payment2.setC_BankAccount_ID(100); // 1234_MoneyBank_123456789
payment2.setC_Currency_ID(100); // USD
payment2.setC_BankAccount_ID(DictionaryIDs.C_BankAccount.ACCOUNT_1234.id); // 1234_MoneyBank_123456789
payment2.setC_Currency_ID(DictionaryIDs.C_Currency.USD.id); // USD
Timestamp next2weeks = TimeUtil.addDays(today, 14);
payment2.setDateTrx(next2weeks);
payment2.setDateAcct(next2weeks);

View File

@ -34,6 +34,7 @@ import org.compiere.model.MAttributeSet;
import org.compiere.model.MAttributeUse;
import org.compiere.util.Env;
import org.idempiere.test.AbstractTestCase;
import org.idempiere.test.DictionaryIDs;
import org.junit.jupiter.api.Test;
/**
@ -43,14 +44,12 @@ import org.junit.jupiter.api.Test;
*/
public class MAttributeSetTest extends AbstractTestCase {
private final static int PATIO_Chair_AttributeSet = 102;
public MAttributeSetTest() {
}
@Test
public void testGetMAttributeUse() {
MAttributeSet as = MAttributeSet.get(PATIO_Chair_AttributeSet);
MAttributeSet as = MAttributeSet.get(DictionaryIDs.M_AttributeSet.PATIO_CHAIR.id);
MAttributeUse[] use = as.getMAttributeUse();
assertNotNull(use);
assertTrue(use.length > 0);
@ -58,7 +57,7 @@ public class MAttributeSetTest extends AbstractTestCase {
@Test
public void testGetMAttributes() {
MAttributeSet as = MAttributeSet.get(PATIO_Chair_AttributeSet);
MAttributeSet as = MAttributeSet.get(DictionaryIDs.M_AttributeSet.PATIO_CHAIR.id);
MAttributeUse[] uses = as.getMAttributeUse();
int instance = 0;
int nonInstance = 0;

View File

@ -45,6 +45,7 @@ import org.compiere.util.CacheMgt;
import org.compiere.util.Env;
import org.compiere.util.TimeUtil;
import org.idempiere.test.AbstractTestCase;
import org.idempiere.test.DictionaryIDs;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
@ -55,10 +56,6 @@ import org.junit.jupiter.api.Test;
*/
public class MDiscountSchemaTest extends AbstractTestCase {
private static final int FIVE_PERCENT_IF_100_ID=102;
private static final int PRODUCT_MULCH_ID = 137;
private static final int BP_JOE_BLOCK_ID = 118;
public MDiscountSchemaTest() {
}
@ -67,7 +64,7 @@ public class MDiscountSchemaTest extends AbstractTestCase {
public void testPercentageDiscount() {
MOrder order = new MOrder(Env.getCtx(), 0, getTrxName());
//Joe Block
order.setBPartner(MBPartner.get(Env.getCtx(), BP_JOE_BLOCK_ID));
order.setBPartner(MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.JOE_BLOCK.id));
order.setC_DocTypeTarget_ID(MOrder.DocSubTypeSO_Standard);
order.setDeliveryRule(MOrder.DELIVERYRULE_CompleteOrder);
order.setDocStatus(DocAction.STATUS_Drafted);
@ -78,19 +75,18 @@ public class MDiscountSchemaTest extends AbstractTestCase {
MOrderLine line1 = new MOrderLine(order);
line1.setLine(10);
//Azalea Bush
line1.setProduct(MProduct.get(Env.getCtx(), PRODUCT_MULCH_ID));
line1.setProduct(MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.MULCH.id));
line1.setQty(new BigDecimal("100"));
line1.setDatePromised(today);
line1.saveEx();
MDiscountSchema schema = new MDiscountSchema(Env.getCtx(), FIVE_PERCENT_IF_100_ID, getTrxName());
MDiscountSchema schema = new MDiscountSchema(Env.getCtx(), DictionaryIDs.M_DiscountSchema.FIVE_PERCENT_DISCOUNT.id, getTrxName());
MDiscountSchemaBreak[] breaks = schema.getBreaks(false);
assertTrue(breaks.length > 0, "No discount schema breaks");
MPriceList priceList = MPriceList.get(order.getM_PriceList_ID());
MPriceListVersion priceListVersion = priceList.getPriceListVersion(order.getDateOrdered());
MProductPrice[] productPrice = priceListVersion.getProductPrice(" AND M_Product_ID="+PRODUCT_MULCH_ID);
MProductPrice[] productPrice = priceListVersion.getProductPrice(" AND M_Product_ID="+DictionaryIDs.M_Product.MULCH.id);
assertEquals(1, productPrice.length, "Unexpected number of ProductPrice record");
BigDecimal discounted = MDiscountSchema.calculateDiscountedPrice(productPrice[0].getPriceStd(), breaks[0].getBreakDiscount());
assertEquals(discounted.setScale(2, RoundingMode.HALF_UP), line1.getPriceActual().setScale(2, RoundingMode.HALF_UP), "Unexpected Order Line price");
@ -100,7 +96,7 @@ public class MDiscountSchemaTest extends AbstractTestCase {
@Order(2)
public void testFixedPriceDiscount() {
BigDecimal fixedPrice = new BigDecimal("1.00");
MDiscountSchema schema = new MDiscountSchema(Env.getCtx(), FIVE_PERCENT_IF_100_ID, getTrxName());
MDiscountSchema schema = new MDiscountSchema(Env.getCtx(), DictionaryIDs.M_DiscountSchema.FIVE_PERCENT_DISCOUNT.id, getTrxName());
MDiscountSchemaBreak discountBreak = null;
try {
@ -109,7 +105,7 @@ public class MDiscountSchemaTest extends AbstractTestCase {
discountBreak.setBreakDiscount(new BigDecimal("0.00"));
discountBreak.setBreakValue(new BigDecimal("10"));
discountBreak.setFixedPrice(fixedPrice);
discountBreak.setM_Product_ID(PRODUCT_MULCH_ID);
discountBreak.setM_Product_ID(DictionaryIDs.M_Product.MULCH.id);
discountBreak.setIsBPartnerFlatDiscount(false);
discountBreak.setIsActive(true);
discountBreak.setSeqNo(20);
@ -119,7 +115,7 @@ public class MDiscountSchemaTest extends AbstractTestCase {
MOrder order = new MOrder(Env.getCtx(), 0, getTrxName());
//Joe Block
order.setBPartner(MBPartner.get(Env.getCtx(), BP_JOE_BLOCK_ID));
order.setBPartner(MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.JOE_BLOCK.id));
order.setC_DocTypeTarget_ID(MOrder.DocSubTypeSO_Standard);
order.setDeliveryRule(MOrder.DELIVERYRULE_CompleteOrder);
order.setDocStatus(DocAction.STATUS_Drafted);
@ -131,7 +127,7 @@ public class MDiscountSchemaTest extends AbstractTestCase {
MOrderLine line1 = new MOrderLine(order);
line1.setLine(10);
//Azalea Bush
line1.setProduct(MProduct.get(Env.getCtx(), PRODUCT_MULCH_ID));
line1.setProduct(MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.MULCH.id));
line1.setQty(new BigDecimal("10"));
line1.setDatePromised(today);
line1.saveEx();

View File

@ -61,6 +61,7 @@ import org.compiere.wf.MWorkflow;
import org.eevolution.model.MPPProductBOM;
import org.eevolution.model.MPPProductBOMLine;
import org.idempiere.test.AbstractTestCase;
import org.idempiere.test.DictionaryIDs;
import org.junit.jupiter.api.Test;
/**
@ -70,27 +71,15 @@ import org.junit.jupiter.api.Test;
*/
public class MProductTest extends AbstractTestCase {
private static final int BP_PATIO = 121;
private static final int DOCTYPE_PO = 126;
private static final int DOCTYPE_RECEIPT = 122;
private static final int USER_GARDENADMIN = 101;
private static final int MULCH_PRODUCT_ID = 137;
private static final int TSHIRT_GL_PRODUCT_ID = 148;
private static final int COLOR_ATTRIBUTE_ID = 101;
private final static int HOUR_UOM_ID = 101;
private final static int FERTILIZER_LOT_ATTRIBUTESET_ID = 101;
private final static int PATIO_CHAIR_ATTRIBUTESET_ID = 102;
private static final int CHEMICALS_CATEGORY_ID = 109;
public MProductTest() {
}
private void createPOAndMRForProduct(int productId) {
MOrder order = new MOrder(Env.getCtx(), 0, getTrxName());
order.setBPartner(MBPartner.get(Env.getCtx(), BP_PATIO));
order.setC_DocTypeTarget_ID(DOCTYPE_PO);
order.setBPartner(MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.PATIO.id));
order.setC_DocTypeTarget_ID(DictionaryIDs.C_DocType.PURCHASE_ORDER.id);
order.setIsSOTrx(false);
order.setSalesRep_ID(USER_GARDENADMIN);
order.setSalesRep_ID(DictionaryIDs.AD_User.GARDEN_ADMIN.id);
order.setDocStatus(DocAction.STATUS_Drafted);
order.setDocAction(DocAction.ACTION_Complete);
Timestamp today = TimeUtil.getDay(System.currentTimeMillis());
@ -110,7 +99,7 @@ public class MProductTest extends AbstractTestCase {
order.load(getTrxName());
assertEquals(DocAction.STATUS_Completed, order.getDocStatus());
MInOut receipt1 = new MInOut(order, DOCTYPE_RECEIPT, order.getDateOrdered());
MInOut receipt1 = new MInOut(order, DictionaryIDs.C_DocType.MM_RECEIPT.id, order.getDateOrdered());
receipt1.setDocStatus(DocAction.STATUS_Drafted);
receipt1.setDocAction(DocAction.ACTION_Complete);
receipt1.saveEx();
@ -132,10 +121,10 @@ public class MProductTest extends AbstractTestCase {
@Test
public void testIsAndGetMethods() {
MProduct product = MProduct.get(TSHIRT_GL_PRODUCT_ID);
MProduct product = MProduct.get(DictionaryIDs.M_Product.TSHIRT_GL.id);
MAttributeInstance attributeInstance = product.getAttributeInstance("Color (R-G-B)", getTrxName());
assertNotNull(attributeInstance);
assertEquals(COLOR_ATTRIBUTE_ID, attributeInstance.getM_Attribute_ID());
assertEquals(DictionaryIDs.M_Attribute.COLOR.id, attributeInstance.getM_Attribute_ID());
assertEquals("Green", attributeInstance.getValue());
MAcctSchema as = MClient.get(Env.getCtx()).getAcctSchema();
@ -144,8 +133,8 @@ public class MProductTest extends AbstractTestCase {
String costingMethod = product.getCostingMethod(as);
assertEquals(as.getCostingMethod(), costingMethod);
createPOAndMRForProduct(MULCH_PRODUCT_ID);
product = new MProduct(Env.getCtx(), MULCH_PRODUCT_ID, getTrxName());
createPOAndMRForProduct(DictionaryIDs.M_Product.MULCH.id);
product = new MProduct(Env.getCtx(), DictionaryIDs.M_Product.MULCH.id, getTrxName());
MCost mcost = product.getCostingRecord(as, getAD_Org_ID(), 0);
assertNotNull(mcost);
assertEquals(product.get_ID(), mcost.getM_Product_ID());
@ -154,15 +143,15 @@ public class MProductTest extends AbstractTestCase {
assertEquals(mcost.getM_Cost_UU(), mcost1.getM_Cost_UU());
product = new MProduct(Env.getCtx(), 0, getTrxName());
product.setC_UOM_ID(HOUR_UOM_ID);
product.setM_Product_Category_ID(CHEMICALS_CATEGORY_ID);
assertEquals(MUOM.get(HOUR_UOM_ID).getStdPrecision(), product.getUOMPrecision());
assertEquals(MUOM.get(HOUR_UOM_ID).getUOMSymbol(), product.getUOMSymbol());
product.setC_UOM_ID(DictionaryIDs.C_UOM.HOUR.id);
product.setM_Product_Category_ID(DictionaryIDs.M_Product_Category.CHEMICALS.id);
assertEquals(MUOM.get(DictionaryIDs.C_UOM.HOUR.id).getStdPrecision(), product.getUOMPrecision());
assertEquals(MUOM.get(DictionaryIDs.C_UOM.HOUR.id).getUOMSymbol(), product.getUOMSymbol());
assertFalse(product.isInstanceAttribute());
product.setM_AttributeSet_ID(FERTILIZER_LOT_ATTRIBUTESET_ID);
product.setM_AttributeSet_ID(DictionaryIDs.M_AttributeSet.FERTILIZER_LOT.id);
assertTrue(product.isInstanceAttribute());
assertFalse(product.isSerial());
product.setM_AttributeSet_ID(PATIO_CHAIR_ATTRIBUTESET_ID);
product.setM_AttributeSet_ID(DictionaryIDs.M_AttributeSet.PATIO_CHAIR.id);
assertTrue(product.isSerial());
product.setIsStocked(true);
product.setProductType(MProduct.PRODUCTTYPE_Item);
@ -178,7 +167,7 @@ public class MProductTest extends AbstractTestCase {
assertTrue(product.isService());
assertFalse(product.isStocked());
MAttributeSet attributeSet = new MAttributeSet(Env.getCtx(), PATIO_CHAIR_ATTRIBUTESET_ID, null);
MAttributeSet attributeSet = new MAttributeSet(Env.getCtx(), DictionaryIDs.M_AttributeSet.PATIO_CHAIR.id, null);
String mandatoryType = attributeSet.getMandatoryType();
try {
attributeSet.setMandatoryType(MAttributeSet.MANDATORYTYPE_NotMandatory);
@ -218,7 +207,7 @@ public class MProductTest extends AbstractTestCase {
int count = 0;
//make sure there's on hand and reservation records
MProduct product = new MProduct(Env.getCtx(), MULCH_PRODUCT_ID, getTrxName());
MProduct product = new MProduct(Env.getCtx(), DictionaryIDs.M_Product.MULCH.id, getTrxName());
createPOAndMRForProduct(product.get_ID());
Query query = new Query(Env.getCtx(), MStorageOnHand.Table_Name, "M_Product_ID=?", getTrxName());
count = query.setParameters(product.get_ID()).count();

View File

@ -32,6 +32,7 @@ import org.compiere.model.MProjectTypePhase;
import org.compiere.model.MProjectTypeTask;
import org.compiere.util.Env;
import org.idempiere.test.AbstractTestCase;
import org.idempiere.test.DictionaryIDs;
import org.junit.jupiter.api.Test;
/**
@ -41,22 +42,19 @@ import org.junit.jupiter.api.Test;
*/
public class MProjectTypeTest extends AbstractTestCase {
private final static int IMPLEMENTATION_TYPE_ID = 100;
private final static int EVALUATION_PHASE_ID = 100;
public MProjectTypeTest() {
}
@Test
public void testGetTasks() {
MProjectType type = new MProjectType(Env.getCtx(), IMPLEMENTATION_TYPE_ID, getTrxName());
assertEquals(IMPLEMENTATION_TYPE_ID, type.get_ID());
MProjectType type = new MProjectType(Env.getCtx(), DictionaryIDs.C_ProjectType.IMPLEMENTATION.id, getTrxName());
assertEquals(DictionaryIDs.C_ProjectType.IMPLEMENTATION.id, type.get_ID());
MProjectTypePhase[] phases = type.getPhases();
assertEquals(2, phases.length);
MProjectTypeTask[] tasks = null;
for (MProjectTypePhase phase : phases) {
if (phase.get_ID() == EVALUATION_PHASE_ID) {
if (phase.get_ID() == DictionaryIDs.C_Phase.INITIAL_NEED_EVALUATION.id) {
tasks = phase.getTasks();
}
}
@ -64,7 +62,7 @@ public class MProjectTypeTest extends AbstractTestCase {
assertEquals(2, tasks.length);
for (MProjectTypePhase phase : phases) {
if (phase.get_ID() != EVALUATION_PHASE_ID) {
if (phase.get_ID() != DictionaryIDs.C_Phase.INITIAL_NEED_EVALUATION.id) {
phase.setIsActive(false);
phase.saveEx();
}
@ -72,8 +70,8 @@ public class MProjectTypeTest extends AbstractTestCase {
tasks[0].setIsActive(false);
tasks[0].saveEx();
type = new MProjectType(Env.getCtx(), IMPLEMENTATION_TYPE_ID, getTrxName());
assertEquals(IMPLEMENTATION_TYPE_ID, type.get_ID());
type = new MProjectType(Env.getCtx(), DictionaryIDs.C_ProjectType.IMPLEMENTATION.id, getTrxName());
assertEquals(DictionaryIDs.C_ProjectType.IMPLEMENTATION.id, type.get_ID());
phases = type.getPhases();
assertEquals(1, phases.length);
tasks = phases[0].getTasks();

View File

@ -41,6 +41,7 @@ import org.compiere.model.MProcess;
import org.compiere.model.MProduct;
import org.compiere.model.MStorageOnHand;
import org.compiere.model.Query;
import org.compiere.model.SystemIDs;
import org.compiere.process.ProcessInfo;
import org.compiere.process.ServerProcessCtl;
import org.compiere.util.CacheMgt;
@ -48,6 +49,7 @@ import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.TimeUtil;
import org.idempiere.test.AbstractTestCase;
import org.idempiere.test.DictionaryIDs;
import org.junit.jupiter.api.Test;
/**
@ -57,15 +59,6 @@ import org.junit.jupiter.api.Test;
*/
public class MStorageOnHandTest extends AbstractTestCase {
private final static int FERTILIZER_LOT_ATTRIBUTESET_ID = 101;
private final static int HQ_LOCATOR_ID = 101;
private final static int STORE_LOCATOR_ID = 102;
private static final int TAX_CATEGORY_STANDARD_ID = 107;
private static final int CHEMICALS_CATEGORY_ID = 109;
private static final int UOM_EACH_ID = 100;
private static final int STORAGE_CLEANUP_PROCESS_ID = 325;
private static final int MATERIAL_MOVEMENT_DOCTYPE_ID = 143;
public MStorageOnHandTest() {
}
@ -74,30 +67,30 @@ public class MStorageOnHandTest extends AbstractTestCase {
//storageonhand api doesn't use trx to retrieve product
MProduct product = new MProduct(Env.getCtx(), 0, null);
product.setName("testGetAll");
product.setM_AttributeSet_ID(FERTILIZER_LOT_ATTRIBUTESET_ID);
product.setM_AttributeSet_ID(DictionaryIDs.M_AttributeSet.FERTILIZER_LOT.id);
product.setIsStocked(true);
product.setProductType(MProduct.PRODUCTTYPE_Item);
product.setC_UOM_ID(UOM_EACH_ID);
product.setM_Product_Category_ID(CHEMICALS_CATEGORY_ID);
product.setC_TaxCategory_ID(TAX_CATEGORY_STANDARD_ID);
product.setC_UOM_ID(DictionaryIDs.C_UOM.EACH.id);
product.setM_Product_Category_ID(DictionaryIDs.M_Product_Category.CHEMICALS.id);
product.setC_TaxCategory_ID(DictionaryIDs.C_TaxCategory.STANDARD.id);
product.saveEx();
try {
Timestamp today = TimeUtil.getDay(null);
Timestamp tomorrow = TimeUtil.addDays(today, 1);
MStorageOnHand.add(Env.getCtx(), HQ_LOCATOR_ID, product.get_ID(), 0, new BigDecimal("1"), today, getTrxName());
MStorageOnHand.add(Env.getCtx(), STORE_LOCATOR_ID, product.get_ID(), 0, new BigDecimal("2"), tomorrow, getTrxName());
MStorageOnHand.add(Env.getCtx(), DictionaryIDs.M_Locator.HQ.id, product.get_ID(), 0, new BigDecimal("1"), today, getTrxName());
MStorageOnHand.add(Env.getCtx(), DictionaryIDs.M_Locator.STORE.id, product.get_ID(), 0, new BigDecimal("2"), tomorrow, getTrxName());
MStorageOnHand[] onhands = MStorageOnHand.getAll(Env.getCtx(), product.get_ID(), HQ_LOCATOR_ID, getTrxName(), false, 0);
MStorageOnHand[] onhands = MStorageOnHand.getAll(Env.getCtx(), product.get_ID(), DictionaryIDs.M_Locator.HQ.id, getTrxName(), false, 0);
assertNotNull(onhands);
assertEquals(1, onhands.length);
assertEquals(HQ_LOCATOR_ID, onhands[0].getM_Locator_ID());
assertEquals(DictionaryIDs.M_Locator.HQ.id, onhands[0].getM_Locator_ID());
assertEquals(1, onhands[0].getQtyOnHand().intValue());
onhands = MStorageOnHand.getAll(Env.getCtx(), product.get_ID(), STORE_LOCATOR_ID, getTrxName(), false, 0);
onhands = MStorageOnHand.getAll(Env.getCtx(), product.get_ID(), DictionaryIDs.M_Locator.STORE.id, getTrxName(), false, 0);
assertNotNull(onhands);
assertEquals(1, onhands.length);
assertEquals(STORE_LOCATOR_ID, onhands[0].getM_Locator_ID());
assertEquals(DictionaryIDs.M_Locator.STORE.id, onhands[0].getM_Locator_ID());
assertEquals(2, onhands[0].getQtyOnHand().intValue());
onhands = MStorageOnHand.getAll(Env.getCtx(), product.get_ID(), 0, getTrxName(), false, 0);
@ -105,51 +98,51 @@ public class MStorageOnHandTest extends AbstractTestCase {
assertEquals(2, onhands.length);
//test locator priority
MLocator locator = new MLocator(Env.getCtx(), STORE_LOCATOR_ID, getTrxName());
MLocator locator = new MLocator(Env.getCtx(), DictionaryIDs.M_Locator.STORE.id, getTrxName());
locator.setPriorityNo(Integer.MAX_VALUE);
locator.saveEx();
onhands = MStorageOnHand.getAll(Env.getCtx(), product.get_ID(), 0, true, true, getTrxName(), false, 0);
assertNotNull(onhands);
assertEquals(2, onhands.length);
assertEquals(STORE_LOCATOR_ID, onhands[0].getM_Locator_ID());
assertEquals(DictionaryIDs.M_Locator.STORE.id, onhands[0].getM_Locator_ID());
assertEquals(2, onhands[0].getQtyOnHand().intValue());
//test fifo
onhands = MStorageOnHand.getAll(Env.getCtx(), product.get_ID(), 0, false, true, getTrxName(), false, 0);
assertNotNull(onhands);
assertEquals(2, onhands.length);
assertEquals(HQ_LOCATOR_ID, onhands[0].getM_Locator_ID());
assertEquals(DictionaryIDs.M_Locator.HQ.id, onhands[0].getM_Locator_ID());
assertEquals(1, onhands[0].getQtyOnHand().intValue());
//test lifo
onhands = MStorageOnHand.getAll(Env.getCtx(), product.get_ID(), 0, false, false, getTrxName(), false, 0);
assertNotNull(onhands);
assertEquals(2, onhands.length);
assertEquals(STORE_LOCATOR_ID, onhands[0].getM_Locator_ID());
assertEquals(DictionaryIDs.M_Locator.STORE.id, onhands[0].getM_Locator_ID());
assertEquals(2, onhands[0].getQtyOnHand().intValue());
//test UseGuaranteeDateForMPolicy
onhands = MStorageOnHand.getAll(Env.getCtx(), product.get_ID(), 0, false, true, getTrxName(), false, 0);
assertEquals(HQ_LOCATOR_ID, onhands[0].getM_Locator_ID());
assertEquals(DictionaryIDs.M_Locator.HQ.id, onhands[0].getM_Locator_ID());
assertEquals(1, onhands[0].getQtyOnHand().intValue());
MAttributeSet as = new MAttributeSet(Env.getCtx(), FERTILIZER_LOT_ATTRIBUTESET_ID, null);
MAttributeSet as = new MAttributeSet(Env.getCtx(), DictionaryIDs.M_AttributeSet.FERTILIZER_LOT.id, null);
try {
as.setUseGuaranteeDateForMPolicy(true);
as.saveEx();
MAttributeSetInstance asi1 = new MAttributeSetInstance(Env.getCtx(), 0, getTrxName());
asi1.setM_AttributeSet_ID(FERTILIZER_LOT_ATTRIBUTESET_ID);
asi1.setM_AttributeSet_ID(DictionaryIDs.M_AttributeSet.FERTILIZER_LOT.id);
asi1.setGuaranteeDate(tomorrow);
asi1.saveEx();
DB.executeUpdateEx("UPDATE M_StorageOnHand SET M_AttributeSetInstance_ID=? WHERE M_StorageOnHand_UU=?", new Object[] {asi1.get_ID(), onhands[0].getM_StorageOnHand_UU()}, getTrxName());
MAttributeSetInstance asi2 = new MAttributeSetInstance(Env.getCtx(), 0, getTrxName());
asi2.setM_AttributeSet_ID(FERTILIZER_LOT_ATTRIBUTESET_ID);
asi2.setM_AttributeSet_ID(DictionaryIDs.M_AttributeSet.FERTILIZER_LOT.id);
asi2.setGuaranteeDate(today);
asi2.saveEx();
DB.executeUpdateEx("UPDATE M_StorageOnHand SET M_AttributeSetInstance_ID=? WHERE M_StorageOnHand_UU=?", new Object[] {asi2.get_ID(), onhands[1].getM_StorageOnHand_UU()}, getTrxName());
CacheMgt.get().reset(MProduct.Table_Name, product.get_ID());
onhands = MStorageOnHand.getAll(Env.getCtx(), product.get_ID(), 0, false, true, getTrxName(), false, 0);
assertEquals(asi2.get_ID(), onhands[0].getM_AttributeSetInstance_ID());
assertEquals(STORE_LOCATOR_ID, onhands[0].getM_Locator_ID());
assertEquals(DictionaryIDs.M_Locator.STORE.id, onhands[0].getM_Locator_ID());
assertEquals(2, onhands[0].getQtyOnHand().intValue());
} finally {
as.setUseGuaranteeDateForMPolicy(false);
@ -162,7 +155,7 @@ public class MStorageOnHandTest extends AbstractTestCase {
@Test
public void testGetM_Locator_ID() {
MLocator hqLocator = new MLocator(Env.getCtx(), HQ_LOCATOR_ID, getTrxName());
MLocator hqLocator = new MLocator(Env.getCtx(), DictionaryIDs.M_Locator.HQ.id, getTrxName());
MLocator hqLocator1 = new MLocator(Env.getCtx(), 0, getTrxName());
hqLocator1.setM_Warehouse_ID(hqLocator.getM_Warehouse_ID());
hqLocator1.setValue("HQ Locator 1");
@ -174,31 +167,31 @@ public class MStorageOnHandTest extends AbstractTestCase {
MProduct product = new MProduct(Env.getCtx(), 0, getTrxName());
product.setName("testGetM_Locator_ID");
product.setM_AttributeSet_ID(FERTILIZER_LOT_ATTRIBUTESET_ID);
product.setM_AttributeSet_ID(DictionaryIDs.M_AttributeSet.FERTILIZER_LOT.id);
product.setIsStocked(true);
product.setProductType(MProduct.PRODUCTTYPE_Item);
product.setC_UOM_ID(UOM_EACH_ID);
product.setM_Product_Category_ID(CHEMICALS_CATEGORY_ID);
product.setC_TaxCategory_ID(TAX_CATEGORY_STANDARD_ID);
product.setC_UOM_ID(DictionaryIDs.C_UOM.EACH.id);
product.setM_Product_Category_ID(DictionaryIDs.M_Product_Category.CHEMICALS.id);
product.setC_TaxCategory_ID(DictionaryIDs.C_TaxCategory.STANDARD.id);
product.saveEx();
Timestamp today = TimeUtil.getDay(null);
MStorageOnHand.add(Env.getCtx(), HQ_LOCATOR_ID, product.get_ID(), 0, new BigDecimal("2"), today, getTrxName());
MStorageOnHand.add(Env.getCtx(), DictionaryIDs.M_Locator.HQ.id, product.get_ID(), 0, new BigDecimal("2"), today, getTrxName());
MAttributeSetInstance asi1 = new MAttributeSetInstance(Env.getCtx(), 0, getTrxName());
asi1.setM_AttributeSet_ID(FERTILIZER_LOT_ATTRIBUTESET_ID);
asi1.setM_AttributeSet_ID(DictionaryIDs.M_AttributeSet.FERTILIZER_LOT.id);
asi1.setLot("Lot1");
asi1.saveEx();
MStorageOnHand.add(Env.getCtx(), hqLocator1.get_ID(), product.get_ID(), asi1.get_ID(), new BigDecimal("1"), today, getTrxName());
//get asi=0
int M_Locator_ID = MStorageOnHand.getM_Locator_ID(hqLocator.getM_Warehouse_ID(), product.get_ID(), 0, new BigDecimal("1"), getTrxName());
assertEquals(HQ_LOCATOR_ID, M_Locator_ID);
assertEquals(DictionaryIDs.M_Locator.HQ.id, M_Locator_ID);
//get asi>0
M_Locator_ID = MStorageOnHand.getM_Locator_ID(hqLocator.getM_Warehouse_ID(), product.get_ID(), asi1.get_ID(), new BigDecimal("1"), getTrxName());
assertEquals(hqLocator1.get_ID(), M_Locator_ID);
//check all asi and get locator with highest onhand
M_Locator_ID = MStorageOnHand.getM_Locator_ID(hqLocator.getM_Warehouse_ID(), product.get_ID(), -1, new BigDecimal("1"), getTrxName());
assertEquals(HQ_LOCATOR_ID, M_Locator_ID);
assertEquals(DictionaryIDs.M_Locator.HQ.id, M_Locator_ID);
MStorageOnHand.add(Env.getCtx(), hqLocator1.get_ID(), product.get_ID(), asi1.get_ID(), new BigDecimal("2"), today, getTrxName());
M_Locator_ID = MStorageOnHand.getM_Locator_ID(hqLocator.getM_Warehouse_ID(), product.get_ID(), -1, new BigDecimal("1"), getTrxName());
assertEquals(hqLocator1.get_ID(), M_Locator_ID);
@ -208,21 +201,21 @@ public class MStorageOnHandTest extends AbstractTestCase {
public void testStorageCleanUp() {
MProduct product = new MProduct(Env.getCtx(), 0, getTrxName());
product.setName("testStorageCleanUp");
product.setM_AttributeSet_ID(FERTILIZER_LOT_ATTRIBUTESET_ID);
product.setM_AttributeSet_ID(DictionaryIDs.M_AttributeSet.FERTILIZER_LOT.id);
product.setIsStocked(true);
product.setProductType(MProduct.PRODUCTTYPE_Item);
product.setC_UOM_ID(UOM_EACH_ID);
product.setM_Product_Category_ID(CHEMICALS_CATEGORY_ID);
product.setC_TaxCategory_ID(TAX_CATEGORY_STANDARD_ID);
product.setC_UOM_ID(DictionaryIDs.C_UOM.EACH.id);
product.setM_Product_Category_ID(DictionaryIDs.M_Product_Category.CHEMICALS.id);
product.setC_TaxCategory_ID(DictionaryIDs.C_TaxCategory.STANDARD.id);
product.saveEx();
Timestamp today = TimeUtil.getDay(null);
MStorageOnHand.add(Env.getCtx(), HQ_LOCATOR_ID, product.get_ID(), 0, new BigDecimal("2"), today, getTrxName());
MStorageOnHand.add(Env.getCtx(), DictionaryIDs.M_Locator.HQ.id, product.get_ID(), 0, new BigDecimal("2"), today, getTrxName());
Query query = new Query(Env.getCtx(), MStorageOnHand.Table_Name, "M_Product_ID=?", getTrxName());
int count = query.setParameters(product.get_ID()).count();
assertEquals(1, count);
MStorageOnHand.add(Env.getCtx(), HQ_LOCATOR_ID, product.get_ID(), 0, new BigDecimal("-2"), today, getTrxName());
MStorageOnHand.add(Env.getCtx(), DictionaryIDs.M_Locator.HQ.id, product.get_ID(), 0, new BigDecimal("-2"), today, getTrxName());
DB.executeUpdateEx("UPDATE M_StorageOnHand SET Created=? WHERE M_Product_ID=?", new Object[] {TimeUtil.addDays(today, -7), product.get_ID()}, getTrxName());
query = new Query(Env.getCtx(), MStorageOnHand.Table_Name, "M_Product_ID=?", getTrxName());
count = query.setParameters(product.get_ID()).count();
@ -232,21 +225,21 @@ public class MStorageOnHandTest extends AbstractTestCase {
MProduct product1 = new MProduct(Env.getCtx(), 0, null);
product1.setName("testStorageCleanUp#1");
product1.setValue(product1.getName());
product1.setM_AttributeSet_ID(FERTILIZER_LOT_ATTRIBUTESET_ID);
product1.setM_AttributeSet_ID(DictionaryIDs.M_AttributeSet.FERTILIZER_LOT.id);
product1.setIsStocked(true);
product1.setProductType(MProduct.PRODUCTTYPE_Item);
product1.setC_UOM_ID(UOM_EACH_ID);
product1.setM_Product_Category_ID(CHEMICALS_CATEGORY_ID);
product1.setC_TaxCategory_ID(TAX_CATEGORY_STANDARD_ID);
product1.setC_UOM_ID(DictionaryIDs.C_UOM.EACH.id);
product1.setM_Product_Category_ID(DictionaryIDs.M_Product_Category.CHEMICALS.id);
product1.setC_TaxCategory_ID(DictionaryIDs.C_TaxCategory.STANDARD.id);
product1.saveEx();
try {
MAttributeSetInstance asi1 = new MAttributeSetInstance(Env.getCtx(), 0, getTrxName());
asi1.setM_AttributeSet_ID(FERTILIZER_LOT_ATTRIBUTESET_ID);
asi1.setM_AttributeSet_ID(DictionaryIDs.M_AttributeSet.FERTILIZER_LOT.id);
asi1.setLot("Lot1");
asi1.saveEx();
MStorageOnHand.add(Env.getCtx(), HQ_LOCATOR_ID, product1.get_ID(), asi1.get_ID(), new BigDecimal("-1"), today, getTrxName());
MStorageOnHand.add(Env.getCtx(), HQ_LOCATOR_ID, product1.get_ID(), 0, new BigDecimal("1"), today, getTrxName());
MStorageOnHand.add(Env.getCtx(), DictionaryIDs.M_Locator.HQ.id, product1.get_ID(), asi1.get_ID(), new BigDecimal("-1"), today, getTrxName());
MStorageOnHand.add(Env.getCtx(), DictionaryIDs.M_Locator.HQ.id, product1.get_ID(), 0, new BigDecimal("1"), today, getTrxName());
query = new Query(Env.getCtx(), MStorageOnHand.Table_Name, "M_Product_ID=? AND M_AttributeSetInstance_ID=?", getTrxName());
MStorageOnHand onhand = query.setParameters(product1.get_ID(), asi1.get_ID()).first();
@ -261,25 +254,25 @@ public class MStorageOnHandTest extends AbstractTestCase {
MProduct product2 = new MProduct(Env.getCtx(), 0, getTrxName());
product2.setName("testStorageCleanUp#2");
product2.setValue(product2.getName());
product2.setM_AttributeSet_ID(FERTILIZER_LOT_ATTRIBUTESET_ID);
product2.setM_AttributeSet_ID(DictionaryIDs.M_AttributeSet.FERTILIZER_LOT.id);
product2.setIsStocked(true);
product2.setProductType(MProduct.PRODUCTTYPE_Item);
product2.setC_UOM_ID(UOM_EACH_ID);
product2.setM_Product_Category_ID(CHEMICALS_CATEGORY_ID);
product2.setC_TaxCategory_ID(TAX_CATEGORY_STANDARD_ID);
product2.setC_UOM_ID(DictionaryIDs.C_UOM.EACH.id);
product2.setM_Product_Category_ID(DictionaryIDs.M_Product_Category.CHEMICALS.id);
product2.setC_TaxCategory_ID(DictionaryIDs.C_TaxCategory.STANDARD.id);
product2.saveEx();
MAttributeSetInstance asi2 = new MAttributeSetInstance(Env.getCtx(), 0, getTrxName());
asi2.setM_AttributeSet_ID(FERTILIZER_LOT_ATTRIBUTESET_ID);
asi2.setM_AttributeSet_ID(DictionaryIDs.M_AttributeSet.FERTILIZER_LOT.id);
asi2.setLot("LotX");
asi2.saveEx();
MStorageOnHand.add(Env.getCtx(), HQ_LOCATOR_ID, product2.get_ID(), asi2.get_ID(), new BigDecimal("-1"), today, getTrxName());
MStorageOnHand.add(Env.getCtx(), DictionaryIDs.M_Locator.HQ.id, product2.get_ID(), asi2.get_ID(), new BigDecimal("-1"), today, getTrxName());
MAttributeSetInstance asi3 = new MAttributeSetInstance(Env.getCtx(), 0, getTrxName());
asi3.setM_AttributeSet_ID(FERTILIZER_LOT_ATTRIBUTESET_ID);
asi3.setM_AttributeSet_ID(DictionaryIDs.M_AttributeSet.FERTILIZER_LOT.id);
asi3.setLot("LotY");
asi3.saveEx();
MStorageOnHand.add(Env.getCtx(), HQ_LOCATOR_ID, product2.get_ID(), asi3.get_ID(), new BigDecimal("1"), today, getTrxName());
MStorageOnHand.add(Env.getCtx(), DictionaryIDs.M_Locator.HQ.id, product2.get_ID(), asi3.get_ID(), new BigDecimal("1"), today, getTrxName());
query = new Query(Env.getCtx(), MStorageOnHand.Table_Name, "M_Product_ID=? AND M_AttributeSetInstance_ID=?", getTrxName());
onhand = query.setParameters(product2.get_ID(), asi2.get_ID()).first();
@ -293,37 +286,37 @@ public class MStorageOnHandTest extends AbstractTestCase {
MProduct product3 = new MProduct(Env.getCtx(), 0, getTrxName());
product3.setName("testStorageCleanUp#3");
product3.setM_AttributeSet_ID(FERTILIZER_LOT_ATTRIBUTESET_ID);
product3.setM_AttributeSet_ID(DictionaryIDs.M_AttributeSet.FERTILIZER_LOT.id);
product3.setIsStocked(true);
product3.setProductType(MProduct.PRODUCTTYPE_Item);
product3.setC_UOM_ID(UOM_EACH_ID);
product3.setM_Product_Category_ID(CHEMICALS_CATEGORY_ID);
product3.setC_TaxCategory_ID(TAX_CATEGORY_STANDARD_ID);
product3.setC_UOM_ID(DictionaryIDs.C_UOM.EACH.id);
product3.setM_Product_Category_ID(DictionaryIDs.M_Product_Category.CHEMICALS.id);
product3.setC_TaxCategory_ID(DictionaryIDs.C_TaxCategory.STANDARD.id);
product3.saveEx();
MAttributeSetInstance asi4 = new MAttributeSetInstance(Env.getCtx(), 0, getTrxName());
asi4.setM_AttributeSet_ID(FERTILIZER_LOT_ATTRIBUTESET_ID);
asi4.setM_AttributeSet_ID(DictionaryIDs.M_AttributeSet.FERTILIZER_LOT.id);
asi4.setSerNo(product3.getName()+"SerialNo#1");
asi4.saveEx();
MStorageOnHand.add(Env.getCtx(), HQ_LOCATOR_ID, product3.get_ID(), asi4.get_ID(), new BigDecimal("1"), today, getTrxName());
MStorageOnHand.add(Env.getCtx(), DictionaryIDs.M_Locator.HQ.id, product3.get_ID(), asi4.get_ID(), new BigDecimal("1"), today, getTrxName());
query = new Query(Env.getCtx(), MStorageOnHand.Table_Name, "M_Product_ID=?", getTrxName());
count = query.setParameters(product3.get_ID()).count();
assertEquals(1, count);
MStorageOnHand.add(Env.getCtx(), HQ_LOCATOR_ID, product3.get_ID(), asi4.get_ID(), new BigDecimal("-1"), today, getTrxName());
MStorageOnHand.add(Env.getCtx(), DictionaryIDs.M_Locator.HQ.id, product3.get_ID(), asi4.get_ID(), new BigDecimal("-1"), today, getTrxName());
DB.executeUpdateEx("UPDATE M_StorageOnHand SET Created=? WHERE M_Product_ID=?", new Object[] {TimeUtil.addDays(today, -7), product3.get_ID()}, getTrxName());
query = new Query(Env.getCtx(), MStorageOnHand.Table_Name, "M_Product_ID=?", getTrxName());
count = query.setParameters(product3.get_ID()).count();
assertEquals(1, count);
MPInstance instance = new MPInstance(Env.getCtx(), STORAGE_CLEANUP_PROCESS_ID, 0);
MPInstance instance = new MPInstance(Env.getCtx(), SystemIDs.PROCESS_M_StorageCleanup, 0);
instance.saveEx();
MPInstancePara para = new MPInstancePara(instance, 10);
para.setParameterName("C_DocType_ID");
para.setP_Number(MATERIAL_MOVEMENT_DOCTYPE_ID);
para.setP_Number(DictionaryIDs.C_DocType.MATERIAL_MOVEMENT.id);
para.saveEx();
MProcess process = MProcess.get(Env.getCtx(), STORAGE_CLEANUP_PROCESS_ID);
MProcess process = MProcess.get(Env.getCtx(), SystemIDs.PROCESS_M_StorageCleanup);
ProcessInfo pi = new ProcessInfo(process.getName(), process.get_ID());
pi.setAD_PInstance_ID(instance.get_ID());
pi.setAD_Client_ID(getAD_Client_ID());

View File

@ -64,6 +64,7 @@ import org.compiere.util.Env;
import org.compiere.util.TimeUtil;
import org.compiere.wf.MWorkflow;
import org.idempiere.test.AbstractTestCase;
import org.idempiere.test.DictionaryIDs;
import org.junit.jupiter.api.Test;
/**
@ -73,15 +74,6 @@ import org.junit.jupiter.api.Test;
*/
public class MTaxTest extends AbstractTestCase {
private static final int STANDARD_TAX_ID = 104;
private static final int STANDARD_TAX_CATEGORY_ID=107;
private static final int BP_JOE_BLOCK_ID = 118;
private static final int PRODUCT_MULCH_ID = 137;
private static final int PURCHASE_PRICE_LIST_ID = 102;
private static final int BP_PATIO_ID = 121;
private static final int MM_RECEIPT_DOCTYPE_ID = 122;
public MTaxTest() {
}
@ -89,12 +81,12 @@ public class MTaxTest extends AbstractTestCase {
public void testClearParentTaxId() {
MTax tax = new MTax(Env.getCtx(), 0, getTrxName());
tax.setName("testClearParentTaxId");
tax.setParent_Tax_ID(STANDARD_TAX_ID);
tax.setParent_Tax_ID(DictionaryIDs.C_Tax.STANDARD.id);
tax.setValidFrom(TimeUtil.getDay(null));
tax.setIsSummary(false);
tax.setC_TaxCategory_ID(STANDARD_TAX_CATEGORY_ID);
tax.setC_TaxCategory_ID(DictionaryIDs.C_TaxCategory.STANDARD.id);
tax.saveEx();
assertEquals(STANDARD_TAX_ID, tax.getParent_Tax_ID(), "Unexpected parent tax id");
assertEquals(DictionaryIDs.C_Tax.STANDARD.id, tax.getParent_Tax_ID(), "Unexpected parent tax id");
tax.setIsSummary(true);
tax.saveEx();
@ -106,21 +98,21 @@ public class MTaxTest extends AbstractTestCase {
int taxExemptId = Tax.getExemptTax(Env.getCtx(), getAD_Org_ID(), getTrxName());
assertTrue(taxExemptId>0, "Fail to get tax exempt Id");
MBPartner bp = new MBPartner(Env.getCtx(), BP_JOE_BLOCK_ID, getTrxName());
MBPartner bp = new MBPartner(Env.getCtx(), DictionaryIDs.C_BPartner.JOE_BLOCK.id, getTrxName());
bp.setIsTaxExempt(true);
bp.saveEx();
int id = Core.getTaxLookup().get(Env.getCtx(), PRODUCT_MULCH_ID, 0, getLoginDate(), getLoginDate(), getAD_Org_ID(), getM_Warehouse_ID(),
int id = Core.getTaxLookup().get(Env.getCtx(), DictionaryIDs.M_Product.MULCH.id, 0, getLoginDate(), getLoginDate(), getAD_Org_ID(), getM_Warehouse_ID(),
bp.getPrimaryC_BPartner_Location_ID(), bp.getPrimaryC_BPartner_Location_ID(), true, null, getTrxName());
assertEquals(taxExemptId, id, "Unexpected tax id");
bp.setIsTaxExempt(false);
bp.saveEx();
id = Core.getTaxLookup().get(Env.getCtx(), PRODUCT_MULCH_ID, 0, getLoginDate(), getLoginDate(), getAD_Org_ID(), getM_Warehouse_ID(),
id = Core.getTaxLookup().get(Env.getCtx(), DictionaryIDs.M_Product.MULCH.id, 0, getLoginDate(), getLoginDate(), getAD_Org_ID(), getM_Warehouse_ID(),
bp.getPrimaryC_BPartner_Location_ID(), bp.getPrimaryC_BPartner_Location_ID(), true, null, getTrxName());
assertTrue(id != taxExemptId, "Unexpected tax id: " + id);
assertEquals(STANDARD_TAX_ID, id, "Unexpected tax id");
assertEquals(DictionaryIDs.C_Tax.STANDARD.id, id, "Unexpected tax id");
}
@Test
@ -146,7 +138,7 @@ public class MTaxTest extends AbstractTestCase {
CacheMgt.get().reset();
//need to create product with trx as order line get product from cache
MProduct p = MProduct.get(PRODUCT_MULCH_ID);
MProduct p = MProduct.get(DictionaryIDs.M_Product.MULCH.id);
product = new MProduct(Env.getCtx(), 0, null);
product.setM_Product_Category_ID(p.getM_Product_Category_ID());
product.setC_TaxCategory_ID(category.get_ID());
@ -159,7 +151,7 @@ public class MTaxTest extends AbstractTestCase {
product.setC_UOM_ID(p.getC_UOM_ID());
product.saveEx();
MPriceList priceList = MPriceList.get(PURCHASE_PRICE_LIST_ID);
MPriceList priceList = MPriceList.get(DictionaryIDs.M_PriceList.PURCHASE.id);
MPriceListVersion priceListVersion = priceList.getPriceListVersion(null);
MProductPrice productPrice = new MProductPrice(Env.getCtx(), 0, getTrxName());
productPrice.setM_PriceList_Version_ID(priceListVersion.get_ID());
@ -170,7 +162,7 @@ public class MTaxTest extends AbstractTestCase {
//purchase price of 2 + 5% tax
BigDecimal expectedCost = new BigDecimal("2.00").add(new BigDecimal("2.00").multiply(new BigDecimal("0.05"))).setScale(2, RoundingMode.HALF_EVEN);
MBPartner bpartner = MBPartner.get(Env.getCtx(), BP_PATIO_ID);
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.PATIO.id);
MOrder order = new MOrder(Env.getCtx(), 0, getTrxName());
order.setBPartner(bpartner);
order.setIsSOTrx(false);
@ -194,7 +186,7 @@ public class MTaxTest extends AbstractTestCase {
assertEquals(DocAction.STATUS_Completed, order.getDocStatus());
assertEquals(expectedCost, order.getGrandTotal().setScale(2, RoundingMode.HALF_EVEN), "Un-expected order grand total");
MInOut receipt = new MInOut(order, MM_RECEIPT_DOCTYPE_ID, order.getDateOrdered()); // MM Receipt
MInOut receipt = new MInOut(order, DictionaryIDs.C_DocType.MM_RECEIPT.id, order.getDateOrdered()); // MM Receipt
receipt.saveEx();
MWarehouse wh = MWarehouse.get(Env.getCtx(), receipt.getM_Warehouse_ID());
@ -289,7 +281,7 @@ public class MTaxTest extends AbstractTestCase {
CacheMgt.get().reset();
//need to create product with trx as order line get product from cache
MProduct p = MProduct.get(PRODUCT_MULCH_ID);
MProduct p = MProduct.get(DictionaryIDs.M_Product.MULCH.id);
product = new MProduct(Env.getCtx(), 0, null);
product.setM_Product_Category_ID(p.getM_Product_Category_ID());
product.setC_TaxCategory_ID(category.get_ID());
@ -302,7 +294,7 @@ public class MTaxTest extends AbstractTestCase {
product.setC_UOM_ID(p.getC_UOM_ID());
product.saveEx();
MPriceList priceList = MPriceList.get(PURCHASE_PRICE_LIST_ID);
MPriceList priceList = MPriceList.get(DictionaryIDs.M_PriceList.PURCHASE.id);
MPriceListVersion priceListVersion = priceList.getPriceListVersion(null);
MProductPrice productPrice = new MProductPrice(Env.getCtx(), 0, getTrxName());
productPrice.setM_PriceList_Version_ID(priceListVersion.get_ID());
@ -315,7 +307,7 @@ public class MTaxTest extends AbstractTestCase {
//purchase price of 2 + 5% tax
BigDecimal expectedTotal = new BigDecimal("2.00").add(new BigDecimal("2.00").multiply(new BigDecimal("0.05"))).setScale(2, RoundingMode.HALF_EVEN);
MBPartner bpartner = MBPartner.get(Env.getCtx(), BP_PATIO_ID);
MBPartner bpartner = MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.PATIO.id);
MOrder order = new MOrder(Env.getCtx(), 0, getTrxName());
order.setBPartner(bpartner);
order.setIsSOTrx(false);
@ -339,7 +331,7 @@ public class MTaxTest extends AbstractTestCase {
assertEquals(DocAction.STATUS_Completed, order.getDocStatus());
assertEquals(expectedTotal, order.getGrandTotal().setScale(2, RoundingMode.HALF_EVEN), "Un-expected order grand total");
MInOut receipt = new MInOut(order, MM_RECEIPT_DOCTYPE_ID, order.getDateOrdered()); // MM Receipt
MInOut receipt = new MInOut(order, DictionaryIDs.C_DocType.MM_RECEIPT.id, order.getDateOrdered()); // MM Receipt
receipt.saveEx();
MWarehouse wh = MWarehouse.get(Env.getCtx(), receipt.getM_Warehouse_ID());

View File

@ -36,6 +36,7 @@ import org.compiere.util.CacheMgt;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.idempiere.test.AbstractTestCase;
import org.idempiere.test.DictionaryIDs;
import org.junit.jupiter.api.Test;
/**
@ -45,23 +46,19 @@ import org.junit.jupiter.api.Test;
*/
public class MUOMConversionTest extends AbstractTestCase {
private final static int EACH_ID = 100;
private final static int HOUR_ID = 101;
private static final int PRODUCT_OAK_TREE = 123;
public MUOMConversionTest() {
}
@Test
public void testConversion() {
MUOM each = new MUOM(Env.getCtx(), EACH_ID, getTrxName());
MUOM hour = new MUOM(Env.getCtx(), HOUR_ID, getTrxName());
MUOM each = new MUOM(Env.getCtx(), DictionaryIDs.C_UOM.EACH.id, getTrxName());
MUOM hour = new MUOM(Env.getCtx(), DictionaryIDs.C_UOM.HOUR.id, getTrxName());
//conversion1 at system level
MUOMConversion conv1 = new MUOMConversion(each);
conv1.set_TrxName(null);
conv1.setC_UOM_To_ID(HOUR_ID);
conv1.setC_UOM_To_ID(DictionaryIDs.C_UOM.HOUR.id);
conv1.setMultiplyRate(new BigDecimal("1.15"));
conv1.setDivideRate(BigDecimal.ZERO);
try {
@ -74,59 +71,59 @@ public class MUOMConversionTest extends AbstractTestCase {
MUOMConversion conv2 = null;
MUOMConversion conv3 = null;
try {
BigDecimal converted = MUOMConversion.convertProductTo(Env.getCtx(), PRODUCT_OAK_TREE, HOUR_ID, new BigDecimal("1"));
BigDecimal converted = MUOMConversion.convertProductTo(Env.getCtx(), DictionaryIDs.M_Product.OAK.id, DictionaryIDs.C_UOM.HOUR.id, new BigDecimal("1"));
assertEquals(new BigDecimal("1.15"), converted);
converted = MUOMConversion.convertProductTo(Env.getCtx(), PRODUCT_OAK_TREE, HOUR_ID, new BigDecimal("1"), -1);
converted = MUOMConversion.convertProductTo(Env.getCtx(), DictionaryIDs.M_Product.OAK.id, DictionaryIDs.C_UOM.HOUR.id, new BigDecimal("1"), -1);
assertEquals(new BigDecimal("1.15"), converted);
converted = MUOMConversion.convertProductTo(Env.getCtx(), PRODUCT_OAK_TREE, HOUR_ID, new BigDecimal("1"), 1);
converted = MUOMConversion.convertProductTo(Env.getCtx(), DictionaryIDs.M_Product.OAK.id, DictionaryIDs.C_UOM.HOUR.id, new BigDecimal("1"), 1);
assertEquals(new BigDecimal("1.2"), converted);
//conversion2 at tenant level
conv2 = new MUOMConversion(Env.getCtx(), 0, null);
conv2.setC_UOM_ID(EACH_ID);
conv2.setC_UOM_To_ID(HOUR_ID);
conv2.setC_UOM_ID(DictionaryIDs.C_UOM.EACH.id);
conv2.setC_UOM_To_ID(DictionaryIDs.C_UOM.HOUR.id);
conv2.setMultiplyRate(new BigDecimal("1.35"));
conv2.saveEx();
converted = MUOMConversion.convertProductTo(Env.getCtx(), PRODUCT_OAK_TREE, HOUR_ID, new BigDecimal("1"));
converted = MUOMConversion.convertProductTo(Env.getCtx(), DictionaryIDs.M_Product.OAK.id, DictionaryIDs.C_UOM.HOUR.id, new BigDecimal("1"));
assertEquals(new BigDecimal("1.35"), converted);
converted = MUOMConversion.convertProductTo(Env.getCtx(), PRODUCT_OAK_TREE, HOUR_ID, new BigDecimal("1"), -1);
converted = MUOMConversion.convertProductTo(Env.getCtx(), DictionaryIDs.M_Product.OAK.id, DictionaryIDs.C_UOM.HOUR.id, new BigDecimal("1"), -1);
assertEquals(new BigDecimal("1.35"), converted);
converted = MUOMConversion.convertProductTo(Env.getCtx(), PRODUCT_OAK_TREE, HOUR_ID, new BigDecimal("1"), 1);
converted = MUOMConversion.convertProductTo(Env.getCtx(), DictionaryIDs.M_Product.OAK.id, DictionaryIDs.C_UOM.HOUR.id, new BigDecimal("1"), 1);
assertEquals(new BigDecimal("1.4"), converted);
//conversion3 at tenant and product level
conv3 = new MUOMConversion(Env.getCtx(), 0, null);
conv3.setM_Product_ID(PRODUCT_OAK_TREE);
conv3.setC_UOM_ID(EACH_ID);
conv3.setC_UOM_To_ID(HOUR_ID);
conv3.setM_Product_ID(DictionaryIDs.M_Product.OAK.id);
conv3.setC_UOM_ID(DictionaryIDs.C_UOM.EACH.id);
conv3.setC_UOM_To_ID(DictionaryIDs.C_UOM.HOUR.id);
conv3.setMultiplyRate(new BigDecimal("0.75"));
conv3.saveEx();
CacheMgt.get().reset();
converted = MUOMConversion.convertProductTo(Env.getCtx(), PRODUCT_OAK_TREE, HOUR_ID, new BigDecimal("1"));
converted = MUOMConversion.convertProductTo(Env.getCtx(), DictionaryIDs.M_Product.OAK.id, DictionaryIDs.C_UOM.HOUR.id, new BigDecimal("1"));
assertEquals(new BigDecimal("0.75"), converted);
converted = MUOMConversion.convertProductTo(Env.getCtx(), PRODUCT_OAK_TREE, HOUR_ID, new BigDecimal("1"), -1);
converted = MUOMConversion.convertProductTo(Env.getCtx(), DictionaryIDs.M_Product.OAK.id, DictionaryIDs.C_UOM.HOUR.id, new BigDecimal("1"), -1);
assertEquals(new BigDecimal("0.75"), converted);
converted = MUOMConversion.convertProductTo(Env.getCtx(), PRODUCT_OAK_TREE, HOUR_ID, new BigDecimal("1"), 1);
converted = MUOMConversion.convertProductTo(Env.getCtx(), DictionaryIDs.M_Product.OAK.id, DictionaryIDs.C_UOM.HOUR.id, new BigDecimal("1"), 1);
assertEquals(new BigDecimal("0.8"), converted);
converted = MUOMConversion.convertProductFrom(Env.getCtx(), PRODUCT_OAK_TREE, HOUR_ID, new BigDecimal("1"));
converted = MUOMConversion.convertProductFrom(Env.getCtx(), DictionaryIDs.M_Product.OAK.id, DictionaryIDs.C_UOM.HOUR.id, new BigDecimal("1"));
assertEquals(hour.round(conv3.getDivideRate(),true), converted);
conv3.deleteEx(true);
conv3 = null;
CacheMgt.get().reset();
converted = MUOMConversion.convertProductFrom(Env.getCtx(), PRODUCT_OAK_TREE, HOUR_ID, new BigDecimal("1"));
converted = MUOMConversion.convertProductFrom(Env.getCtx(), DictionaryIDs.M_Product.OAK.id, DictionaryIDs.C_UOM.HOUR.id, new BigDecimal("1"));
assertEquals(hour.round(conv2.getDivideRate(),true), converted);
converted = MUOMConversion.convertProductFrom(Env.getCtx(), PRODUCT_OAK_TREE, HOUR_ID, new BigDecimal("1"), 1);
converted = MUOMConversion.convertProductFrom(Env.getCtx(), DictionaryIDs.M_Product.OAK.id, DictionaryIDs.C_UOM.HOUR.id, new BigDecimal("1"), 1);
assertEquals(conv2.getDivideRate().setScale(1, RoundingMode.HALF_UP), converted);
conv2.deleteEx(true);
conv2 = null;
converted = MUOMConversion.convertProductFrom(Env.getCtx(), PRODUCT_OAK_TREE, HOUR_ID, new BigDecimal("1"));
converted = MUOMConversion.convertProductFrom(Env.getCtx(), DictionaryIDs.M_Product.OAK.id, DictionaryIDs.C_UOM.HOUR.id, new BigDecimal("1"));
assertEquals(hour.round(conv1.getDivideRate(),true), converted);
converted = MUOMConversion.convertProductFrom(Env.getCtx(), PRODUCT_OAK_TREE, HOUR_ID, new BigDecimal("1"), 1);
converted = MUOMConversion.convertProductFrom(Env.getCtx(), DictionaryIDs.M_Product.OAK.id, DictionaryIDs.C_UOM.HOUR.id, new BigDecimal("1"), 1);
assertEquals(conv1.getDivideRate().setScale(1, RoundingMode.HALF_UP), converted);
} finally {
DB.executeUpdateEx("DELETE FROM C_UOM_Conversion WHERE C_UOM_Conversion_ID=?", new Object[] {conv1.get_ID()}, null);

View File

@ -32,6 +32,7 @@ import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Util;
import org.idempiere.test.AbstractTestCase;
import org.idempiere.test.DictionaryIDs;
import org.junit.jupiter.api.Test;
/**
@ -41,8 +42,6 @@ import org.junit.jupiter.api.Test;
*/
public class PaymentTest extends AbstractTestCase {
private final static int BP_JOE_BLOCK = 118;
public PaymentTest() {
}
@ -50,7 +49,7 @@ public class PaymentTest extends AbstractTestCase {
public void testClearCreditCardFields() {
MPayment payment = new MPayment(Env.getCtx(), 0, getTrxName());
payment.setC_DocType_ID(true);
payment.setC_BPartner_ID(BP_JOE_BLOCK);
payment.setC_BPartner_ID(DictionaryIDs.C_BPartner.JOE_BLOCK.id);
payment.setTenderType(MPayment.TENDERTYPE_CreditCard);
payment.setCreditCard(MPayment.TRXTYPE_Sales, MPayment.CREDITCARDTYPE_MasterCard, "5555555555554444", "123", "0122");
int C_BankAccount_ID = DB.getSQLValueEx(getTrxName(), "SELECT C_BankAccount_ID FROM C_BankAccount WHERE IsActive='Y' AND AD_Client_ID=? "

View File

@ -43,6 +43,7 @@ import org.compiere.model.MOrderLine;
import org.compiere.model.MProcess;
import org.compiere.model.MProduct;
import org.compiere.model.Query;
import org.compiere.model.SystemIDs;
import org.compiere.process.DocAction;
import org.compiere.process.ProcessCall;
import org.compiere.process.ProcessInfo;
@ -55,6 +56,7 @@ import org.compiere.wf.MWFNodeNext;
import org.compiere.wf.MWFNodePara;
import org.compiere.wf.MWorkflow;
import org.idempiere.test.AbstractTestCase;
import org.idempiere.test.DictionaryIDs;
import org.junit.jupiter.api.Test;
/**
@ -74,7 +76,7 @@ public class ProcessTest extends AbstractTestCase {
//first test, using MProcess.processIt
MOrder order = new MOrder(Env.getCtx(), 0, getTrxName());
//Joe Block
order.setBPartner(MBPartner.get(Env.getCtx(), 118));
order.setBPartner(MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.JOE_BLOCK.id));
order.setC_DocTypeTarget_ID(MOrder.DocSubTypeSO_Standard);
order.setDeliveryRule(MOrder.DELIVERYRULE_CompleteOrder);
order.setDocStatus(DocAction.STATUS_Drafted);
@ -87,12 +89,12 @@ public class ProcessTest extends AbstractTestCase {
MOrderLine line1 = new MOrderLine(order);
line1.setLine(10);
//Azalea Bush
line1.setProduct(MProduct.get(Env.getCtx(), 128));
line1.setProduct(MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.AZALEA_BUSH.id));
line1.setQty(new BigDecimal("1"));
line1.setDatePromised(today);
line1.saveEx();
int Process_Order=104;
int Process_Order=SystemIDs.PROCESS_C_ORDER_PROCESS;
MProcess process = MProcess.get(Env.getCtx(), Process_Order);
ProcessInfo pi = new ProcessInfo(process.getName(), process.get_ID());
pi.setAD_Client_ID(getAD_Client_ID());
@ -122,8 +124,8 @@ public class ProcessTest extends AbstractTestCase {
@Test
public void testJavaProcess() {
int Verify_BOM=136;
int Patio_Chair=133;
int Verify_BOM=SystemIDs.PROCESS_PP_PRODUCT_BOM;
int Patio_Chair=DictionaryIDs.M_Product.P_CHAIR.id;
//first, test MProcess.processIt
MProcess process = MProcess.get(Env.getCtx(), Verify_BOM);

View File

@ -74,6 +74,7 @@ import org.compiere.wf.MWorkflow;
import org.eevolution.model.MPPProductBOM;
import org.eevolution.model.MPPProductBOMLine;
import org.idempiere.test.AbstractTestCase;
import org.idempiere.test.DictionaryIDs;
import org.junit.jupiter.api.Test;
/**
@ -83,15 +84,6 @@ import org.junit.jupiter.api.Test;
*/
public class ProductionTest extends AbstractTestCase {
private static final int BP_PATIO = 121;
private static final int DOCTYPE_PO = 126;
private static final int DOCTYPE_RECEIPT = 122;
private static final int USER_GARDENADMIN = 101;
private static final int FERTILIZER_LOT_ATTRIBUTESET_ID = 101;
private static final int UOM_EACH_ID = 100;
private static final int TAX_CATEGORY_STANDARD_ID = 107;
private static final int HQ_LOCATOR_ID = 101;
@Test
public void testAverageCostingProduction() {
int mulchId = 137;
@ -185,10 +177,10 @@ public class ProductionTest extends AbstractTestCase {
// creates an order and material receipt for qty 25 at special price of 2.60 each
private void createPOAndMRForProduct(int mulchId) {
MOrder order = new MOrder(Env.getCtx(), 0, getTrxName());
order.setBPartner(MBPartner.get(Env.getCtx(), BP_PATIO));
order.setC_DocTypeTarget_ID(DOCTYPE_PO);
order.setBPartner(MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.PATIO.id));
order.setC_DocTypeTarget_ID(DictionaryIDs.C_DocType.PURCHASE_ORDER.id);
order.setIsSOTrx(false);
order.setSalesRep_ID(USER_GARDENADMIN);
order.setSalesRep_ID(DictionaryIDs.AD_User.GARDEN_ADMIN.id);
order.setDocStatus(DocAction.STATUS_Drafted);
order.setDocAction(DocAction.ACTION_Complete);
Timestamp today = TimeUtil.getDay(System.currentTimeMillis());
@ -209,7 +201,7 @@ public class ProductionTest extends AbstractTestCase {
order.load(getTrxName());
assertEquals(DocAction.STATUS_Completed, order.getDocStatus());
MInOut receipt1 = new MInOut(order, DOCTYPE_RECEIPT, order.getDateOrdered());
MInOut receipt1 = new MInOut(order, DictionaryIDs.C_DocType.MM_RECEIPT.id, order.getDateOrdered());
receipt1.setDocStatus(DocAction.STATUS_Drafted);
receipt1.setDocAction(DocAction.ACTION_Complete);
receipt1.saveEx();
@ -594,12 +586,12 @@ public class ProductionTest extends AbstractTestCase {
//storageonhand api doesn't use trx to retrieve product
MProduct component = new MProduct(Env.getCtx(), 0, null);
component.setName("testMultipleASI_Child");
component.setM_AttributeSet_ID(FERTILIZER_LOT_ATTRIBUTESET_ID);
component.setM_AttributeSet_ID(DictionaryIDs.M_AttributeSet.FERTILIZER_LOT.id);
component.setIsStocked(true);
component.setProductType(MProduct.PRODUCTTYPE_Item);
component.setC_UOM_ID(UOM_EACH_ID);
component.setC_UOM_ID(DictionaryIDs.C_UOM.EACH.id);
component.setM_Product_Category_ID(category.get_ID());
component.setC_TaxCategory_ID(TAX_CATEGORY_STANDARD_ID);
component.setC_TaxCategory_ID(DictionaryIDs.C_TaxCategory.STANDARD.id);
component.saveEx();
try {
@ -633,20 +625,20 @@ public class ProductionTest extends AbstractTestCase {
parent.saveEx();
MAttributeSetInstance asi1 = new MAttributeSetInstance(Env.getCtx(), 0, getTrxName());
asi1.setM_AttributeSet_ID(FERTILIZER_LOT_ATTRIBUTESET_ID);
asi1.setM_AttributeSet_ID(DictionaryIDs.M_AttributeSet.FERTILIZER_LOT.id);
asi1.setLot("Lot1");
asi1.saveEx();
MStorageOnHand.add(Env.getCtx(), HQ_LOCATOR_ID, component.get_ID(), asi1.get_ID(), new BigDecimal("1"), today, getTrxName());
MStorageOnHand.add(Env.getCtx(), DictionaryIDs.M_Locator.HQ.id, component.get_ID(), asi1.get_ID(), new BigDecimal("1"), today, getTrxName());
MAttributeSetInstance asi2 = new MAttributeSetInstance(Env.getCtx(), 0, getTrxName());
asi2.setM_AttributeSet_ID(FERTILIZER_LOT_ATTRIBUTESET_ID);
asi2.setM_AttributeSet_ID(DictionaryIDs.M_AttributeSet.FERTILIZER_LOT.id);
asi2.setLot("Lot2");
asi2.saveEx();
MStorageOnHand.add(Env.getCtx(), HQ_LOCATOR_ID, component.get_ID(), asi2.get_ID(), new BigDecimal("1"), today, getTrxName());
MStorageOnHand.add(Env.getCtx(), DictionaryIDs.M_Locator.HQ.id, component.get_ID(), asi2.get_ID(), new BigDecimal("1"), today, getTrxName());
MProduction production = new MProduction(Env.getCtx(), 0, getTrxName());
production.setM_Product_ID(parent.get_ID());
production.setM_Locator_ID(HQ_LOCATOR_ID);
production.setM_Locator_ID(DictionaryIDs.M_Locator.HQ.id);
production.setIsUseProductionPlan(false);
production.setMovementDate(getLoginDate());
production.setDocAction(DocAction.ACTION_Complete);
@ -708,12 +700,12 @@ public class ProductionTest extends AbstractTestCase {
//storageonhand api doesn't use trx to retrieve product
MProduct component = new MProduct(Env.getCtx(), 0, null);
component.setName("testMultipleDateMPolicy_Child");
component.setM_AttributeSet_ID(FERTILIZER_LOT_ATTRIBUTESET_ID);
component.setM_AttributeSet_ID(DictionaryIDs.M_AttributeSet.FERTILIZER_LOT.id);
component.setIsStocked(true);
component.setProductType(MProduct.PRODUCTTYPE_Item);
component.setC_UOM_ID(UOM_EACH_ID);
component.setC_UOM_ID(DictionaryIDs.C_UOM.EACH.id);
component.setM_Product_Category_ID(category.get_ID());
component.setC_TaxCategory_ID(TAX_CATEGORY_STANDARD_ID);
component.setC_TaxCategory_ID(DictionaryIDs.C_TaxCategory.STANDARD.id);
component.saveEx();
try {
@ -747,15 +739,15 @@ public class ProductionTest extends AbstractTestCase {
parent.saveEx();
MAttributeSetInstance asi1 = new MAttributeSetInstance(Env.getCtx(), 0, getTrxName());
asi1.setM_AttributeSet_ID(FERTILIZER_LOT_ATTRIBUTESET_ID);
asi1.setM_AttributeSet_ID(DictionaryIDs.M_AttributeSet.FERTILIZER_LOT.id);
asi1.setLot("Lot1");
asi1.saveEx();
MStorageOnHand.add(Env.getCtx(), HQ_LOCATOR_ID, component.get_ID(), asi1.get_ID(), new BigDecimal("1"), TimeUtil.addDays(today, -1), getTrxName());
MStorageOnHand.add(Env.getCtx(), HQ_LOCATOR_ID, component.get_ID(), asi1.get_ID(), new BigDecimal("1"), today, getTrxName());
MStorageOnHand.add(Env.getCtx(), DictionaryIDs.M_Locator.HQ.id, component.get_ID(), asi1.get_ID(), new BigDecimal("1"), TimeUtil.addDays(today, -1), getTrxName());
MStorageOnHand.add(Env.getCtx(), DictionaryIDs.M_Locator.HQ.id, component.get_ID(), asi1.get_ID(), new BigDecimal("1"), today, getTrxName());
MProduction production = new MProduction(Env.getCtx(), 0, getTrxName());
production.setM_Product_ID(parent.get_ID());
production.setM_Locator_ID(HQ_LOCATOR_ID);
production.setM_Locator_ID(DictionaryIDs.M_Locator.HQ.id);
production.setIsUseProductionPlan(false);
production.setMovementDate(getLoginDate());
production.setDocAction(DocAction.ACTION_Complete);
@ -817,12 +809,12 @@ public class ProductionTest extends AbstractTestCase {
//storageonhand api doesn't use trx to retrieve product
MProduct component = new MProduct(Env.getCtx(), 0, null);
component.setName("testMultipleDateMPolicy_Child");
component.setM_AttributeSet_ID(FERTILIZER_LOT_ATTRIBUTESET_ID);
component.setM_AttributeSet_ID(DictionaryIDs.M_AttributeSet.FERTILIZER_LOT.id);
component.setIsStocked(true);
component.setProductType(MProduct.PRODUCTTYPE_Item);
component.setC_UOM_ID(UOM_EACH_ID);
component.setC_UOM_ID(DictionaryIDs.C_UOM.EACH.id);
component.setM_Product_Category_ID(category.get_ID());
component.setC_TaxCategory_ID(TAX_CATEGORY_STANDARD_ID);
component.setC_TaxCategory_ID(DictionaryIDs.C_TaxCategory.STANDARD.id);
component.saveEx();
try {
@ -856,20 +848,20 @@ public class ProductionTest extends AbstractTestCase {
parent.saveEx();
MAttributeSetInstance asi1 = new MAttributeSetInstance(Env.getCtx(), 0, getTrxName());
asi1.setM_AttributeSet_ID(FERTILIZER_LOT_ATTRIBUTESET_ID);
asi1.setM_AttributeSet_ID(DictionaryIDs.M_AttributeSet.FERTILIZER_LOT.id);
asi1.setLot("Lot1");
asi1.saveEx();
MStorageOnHand.add(Env.getCtx(), HQ_LOCATOR_ID, component.get_ID(), asi1.get_ID(), new BigDecimal("2"), today, getTrxName());
MStorageOnHand.add(Env.getCtx(), DictionaryIDs.M_Locator.HQ.id, component.get_ID(), asi1.get_ID(), new BigDecimal("2"), today, getTrxName());
MAttributeSetInstance asi2 = new MAttributeSetInstance(Env.getCtx(), 0, getTrxName());
asi2.setM_AttributeSet_ID(FERTILIZER_LOT_ATTRIBUTESET_ID);
asi2.setM_AttributeSet_ID(DictionaryIDs.M_AttributeSet.FERTILIZER_LOT.id);
asi2.setLot("Lot2");
asi2.saveEx();
MStorageOnHand.add(Env.getCtx(), HQ_LOCATOR_ID, component.get_ID(), asi2.get_ID(), new BigDecimal("2"), today, getTrxName());
MStorageOnHand.add(Env.getCtx(), DictionaryIDs.M_Locator.HQ.id, component.get_ID(), asi2.get_ID(), new BigDecimal("2"), today, getTrxName());
MProduction production1 = new MProduction(Env.getCtx(), 0, getTrxName());
production1.setM_Product_ID(parent.get_ID());
production1.setM_Locator_ID(HQ_LOCATOR_ID);
production1.setM_Locator_ID(DictionaryIDs.M_Locator.HQ.id);
production1.setIsUseProductionPlan(false);
production1.setMovementDate(getLoginDate());
production1.setDocAction(DocAction.ACTION_Complete);
@ -896,7 +888,7 @@ public class ProductionTest extends AbstractTestCase {
MProduction production2 = new MProduction(Env.getCtx(), 0, getTrxName());
production2.setM_Product_ID(parent.get_ID());
production2.setM_Locator_ID(HQ_LOCATOR_ID);
production2.setM_Locator_ID(DictionaryIDs.M_Locator.HQ.id);
production2.setIsUseProductionPlan(false);
production2.setMovementDate(getLoginDate());
production2.setDocAction(DocAction.ACTION_Complete);

View File

@ -56,6 +56,7 @@ import org.compiere.util.Env;
import org.compiere.util.TimeUtil;
import org.compiere.wf.MWorkflow;
import org.idempiere.test.AbstractTestCase;
import org.idempiere.test.DictionaryIDs;
import org.junit.jupiter.api.Test;
/**
@ -66,21 +67,9 @@ public class PurchaseOrderTest extends AbstractTestCase {
public PurchaseOrderTest() {
}
private static final int BP_PATIO = 121;
private static final int DOCTYPE_PO = 126;
private static final int DOCTYPE_RECEIPT = 122;
private static final int DOCTYPE_AP_INVOICE = 123;
private static final int PRODUCT_FERT50 = 136;
private static final int PRODUCT_MULCH = 137;
private static final int PRODUCT_SEEDER = 143;
private static final int PRODUCT_WEEDER = 141;
private static final int USER_GARDENADMIN = 101;
private static final BigDecimal THREE = new BigDecimal("3");
private static final BigDecimal MINUS_THREE = new BigDecimal("-3");
private static final int ORG_FERTILIZER = 50001;
private static final int WAREHOUSE_FERTILIZER = 50002;
/**
* https://idempiere.atlassian.net/browse/IDEMPIERE-4575
*/
@ -90,10 +79,10 @@ public class PurchaseOrderTest extends AbstractTestCase {
String trxName = getTrxName();
MOrder order = new MOrder(ctx, 0, trxName);
order.setBPartner(MBPartner.get(ctx, BP_PATIO));
order.setC_DocTypeTarget_ID(DOCTYPE_PO);
order.setBPartner(MBPartner.get(ctx, DictionaryIDs.C_BPartner.PATIO.id));
order.setC_DocTypeTarget_ID(DictionaryIDs.C_DocType.PURCHASE_ORDER.id);
order.setIsSOTrx(false);
order.setSalesRep_ID(USER_GARDENADMIN);
order.setSalesRep_ID(DictionaryIDs.AD_User.GARDEN_ADMIN.id);
order.setDocStatus(DocAction.STATUS_Drafted);
order.setDocAction(DocAction.ACTION_Complete);
Timestamp today = TimeUtil.getDay(System.currentTimeMillis());
@ -103,7 +92,7 @@ public class PurchaseOrderTest extends AbstractTestCase {
MOrderLine line1 = new MOrderLine(order);
line1.setLine(10);
line1.setProduct(MProduct.get(ctx, PRODUCT_SEEDER));
line1.setProduct(MProduct.get(ctx, DictionaryIDs.M_Product.SEEDER.id));
line1.setQty(new BigDecimal("-1"));
line1.setDatePromised(today);
line1.saveEx();
@ -115,7 +104,7 @@ public class PurchaseOrderTest extends AbstractTestCase {
line1.load(trxName);
assertEquals(0, line1.getQtyReserved().intValue());
MInOut receipt = new MInOut(order, DOCTYPE_RECEIPT, order.getDateOrdered());
MInOut receipt = new MInOut(order, DictionaryIDs.C_DocType.MM_RECEIPT.id, order.getDateOrdered());
receipt.setDocStatus(DocAction.STATUS_Drafted);
receipt.setDocAction(DocAction.ACTION_Complete);
receipt.saveEx();
@ -144,10 +133,10 @@ public class PurchaseOrderTest extends AbstractTestCase {
String trxName = getTrxName();
MOrder order = new MOrder(ctx, 0, trxName);
order.setBPartner(MBPartner.get(ctx, BP_PATIO));
order.setC_DocTypeTarget_ID(DOCTYPE_PO);
order.setBPartner(MBPartner.get(ctx, DictionaryIDs.C_BPartner.PATIO.id));
order.setC_DocTypeTarget_ID(DictionaryIDs.C_DocType.PURCHASE_ORDER.id);
order.setIsSOTrx(false);
order.setSalesRep_ID(USER_GARDENADMIN);
order.setSalesRep_ID(DictionaryIDs.AD_User.GARDEN_ADMIN.id);
order.setDocStatus(DocAction.STATUS_Drafted);
order.setDocAction(DocAction.ACTION_Complete);
Timestamp today = TimeUtil.getDay(System.currentTimeMillis());
@ -157,14 +146,14 @@ public class PurchaseOrderTest extends AbstractTestCase {
MOrderLine line1 = new MOrderLine(order);
line1.setLine(10);
line1.setProduct(MProduct.get(ctx, PRODUCT_WEEDER));
line1.setProduct(MProduct.get(ctx, DictionaryIDs.M_Product.WEEDER.id));
line1.setQty(new BigDecimal("10"));
line1.setDatePromised(today);
line1.saveEx();
MOrderLine line2 = new MOrderLine(order);
line2.setLine(20);
line2.setProduct(MProduct.get(ctx, PRODUCT_SEEDER));
line2.setProduct(MProduct.get(ctx, DictionaryIDs.M_Product.SEEDER.id));
line2.setQty(new BigDecimal("-1"));
line2.setDatePromised(today);
line2.saveEx();
@ -174,7 +163,7 @@ public class PurchaseOrderTest extends AbstractTestCase {
order.load(trxName);
assertEquals(DocAction.STATUS_Completed, order.getDocStatus());
MInOut receipt = new MInOut(order, DOCTYPE_RECEIPT, order.getDateOrdered());
MInOut receipt = new MInOut(order, DictionaryIDs.C_DocType.MM_RECEIPT.id, order.getDateOrdered());
receipt.setDocStatus(DocAction.STATUS_Drafted);
receipt.setDocAction(DocAction.ACTION_Complete);
receipt.saveEx();
@ -194,7 +183,7 @@ public class PurchaseOrderTest extends AbstractTestCase {
receipt.load(trxName);
assertEquals(DocAction.STATUS_Completed, receipt.getDocStatus());
MInvoice invoice = new MInvoice(order, DOCTYPE_AP_INVOICE, order.getDateOrdered());
MInvoice invoice = new MInvoice(order, DictionaryIDs.C_DocType.AP_INVOICE.id, order.getDateOrdered());
invoice.setDocStatus(DocAction.STATUS_Drafted);
invoice.setDocAction(DocAction.ACTION_Complete);
invoice.saveEx();
@ -224,13 +213,13 @@ public class PurchaseOrderTest extends AbstractTestCase {
Properties ctx = Env.getCtx();
String trxName = getTrxName();
BigDecimal qtyOrderedOriginal = getQtyOrdered(ctx, PRODUCT_MULCH, trxName);
BigDecimal qtyOrderedOriginal = getQtyOrdered(ctx, DictionaryIDs.M_Product.MULCH.id, trxName);
MOrder order = new MOrder(ctx, 0, trxName);
order.setBPartner(MBPartner.get(ctx, BP_PATIO));
order.setC_DocTypeTarget_ID(DOCTYPE_PO);
order.setBPartner(MBPartner.get(ctx, DictionaryIDs.C_BPartner.PATIO.id));
order.setC_DocTypeTarget_ID(DictionaryIDs.C_DocType.PURCHASE_ORDER.id);
order.setIsSOTrx(false);
order.setSalesRep_ID(USER_GARDENADMIN);
order.setSalesRep_ID(DictionaryIDs.AD_User.GARDEN_ADMIN.id);
order.setDocStatus(DocAction.STATUS_Drafted);
order.setDocAction(DocAction.ACTION_Complete);
Timestamp today = TimeUtil.getDay(System.currentTimeMillis());
@ -240,7 +229,7 @@ public class PurchaseOrderTest extends AbstractTestCase {
MOrderLine line1 = new MOrderLine(order);
line1.setLine(10);
line1.setProduct(MProduct.get(ctx, PRODUCT_MULCH));
line1.setProduct(MProduct.get(ctx, DictionaryIDs.M_Product.MULCH.id));
line1.setQty(THREE);
line1.setDatePromised(today);
line1.saveEx();
@ -252,10 +241,10 @@ public class PurchaseOrderTest extends AbstractTestCase {
line1.load(trxName);
assertEquals(0, line1.getQtyReserved().compareTo(THREE));
BigDecimal newQtyOrdered = getQtyOrdered(ctx, PRODUCT_MULCH, trxName);
BigDecimal newQtyOrdered = getQtyOrdered(ctx, DictionaryIDs.M_Product.MULCH.id, trxName);
assertEquals(0, qtyOrderedOriginal.add(THREE).compareTo(newQtyOrdered));
MInOut receipt1 = new MInOut(order, DOCTYPE_RECEIPT, order.getDateOrdered());
MInOut receipt1 = new MInOut(order, DictionaryIDs.C_DocType.MM_RECEIPT.id, order.getDateOrdered());
receipt1.setDocStatus(DocAction.STATUS_Drafted);
receipt1.setDocAction(DocAction.ACTION_Complete);
receipt1.saveEx();
@ -273,7 +262,7 @@ public class PurchaseOrderTest extends AbstractTestCase {
line1.load(trxName);
assertEquals(0, line1.getQtyReserved().compareTo(Env.ZERO));
newQtyOrdered = getQtyOrdered(ctx, PRODUCT_MULCH, trxName);
newQtyOrdered = getQtyOrdered(ctx, DictionaryIDs.M_Product.MULCH.id, trxName);
assertEquals(0, qtyOrderedOriginal.compareTo(newQtyOrdered));
// reactivate the purchase order
@ -296,11 +285,11 @@ public class PurchaseOrderTest extends AbstractTestCase {
// IDEMPIERE-5039 - when reservations go negative they are changed to zero
assertEquals(0, line1.getQtyReserved().compareTo(Env.ZERO));
newQtyOrdered = getQtyOrdered(ctx, PRODUCT_MULCH, trxName);
newQtyOrdered = getQtyOrdered(ctx, DictionaryIDs.M_Product.MULCH.id, trxName);
assertEquals(0, qtyOrderedOriginal.compareTo(newQtyOrdered));
// create a new material receipt for the -3 reversed
MInOut receipt2 = new MInOut(order, DOCTYPE_RECEIPT, order.getDateOrdered());
MInOut receipt2 = new MInOut(order, DictionaryIDs.C_DocType.MM_RECEIPT.id, order.getDateOrdered());
receipt2.setDocStatus(DocAction.STATUS_Drafted);
receipt2.setDocAction(DocAction.ACTION_Complete);
receipt2.saveEx();
@ -318,7 +307,7 @@ public class PurchaseOrderTest extends AbstractTestCase {
line1.load(trxName);
assertEquals(0, line1.getQtyReserved().compareTo(Env.ZERO));
newQtyOrdered = getQtyOrdered(ctx, PRODUCT_MULCH, trxName);
newQtyOrdered = getQtyOrdered(ctx, DictionaryIDs.M_Product.MULCH.id, trxName);
assertEquals(0, qtyOrderedOriginal.compareTo(newQtyOrdered));
}
@ -338,7 +327,7 @@ public class PurchaseOrderTest extends AbstractTestCase {
public void testMultiDateMaterialReceipt() {
Properties ctx = Env.getCtx();
String trxName = getTrxName();
MProduct fert50 = new MProduct(ctx, PRODUCT_FERT50, trxName);
MProduct fert50 = new MProduct(ctx, DictionaryIDs.M_Product.FERTILIZER_50.id, trxName);
Timestamp today = TimeUtil.getDay(System.currentTimeMillis());
Timestamp past_month = TimeUtil.addMonths(today, -1);
@ -350,13 +339,13 @@ public class PurchaseOrderTest extends AbstractTestCase {
asi.saveEx();
MOrder order = new MOrder(ctx, 0, trxName);
order.setAD_Org_ID(ORG_FERTILIZER);
order.setBPartner(MBPartner.get(ctx, BP_PATIO));
order.setAD_Org_ID(DictionaryIDs.AD_Org.FERTILIZER.id);
order.setBPartner(MBPartner.get(ctx, DictionaryIDs.C_BPartner.PATIO.id));
order.setIsSOTrx(false);
order.setC_DocTypeTarget_ID(MOrder.DocSubTypeSO_Warehouse);
// ?? why setC_DocTypeTarget_ID sets back IsSOTrx=true
order.setIsSOTrx(false);
order.setM_Warehouse_ID(WAREHOUSE_FERTILIZER);
order.setM_Warehouse_ID(DictionaryIDs.M_Warehouse.FERTILIZER.id);
order.setDocStatus(DocAction.STATUS_Drafted);
order.setDocAction(DocAction.ACTION_Complete);
order.setPaymentRule(MOrder.PAYMENTRULE_OnCredit); // this is the default, just making it explicit
@ -365,7 +354,7 @@ public class PurchaseOrderTest extends AbstractTestCase {
MOrderLine line1 = new MOrderLine(order);
line1.setLine(10);
line1.setProduct(MProduct.get(ctx, PRODUCT_FERT50));
line1.setProduct(MProduct.get(ctx, DictionaryIDs.M_Product.FERTILIZER_50.id));
line1.setM_AttributeSetInstance_ID(asi.getM_AttributeSetInstance_ID());
line1.setQty(new BigDecimal("1"));
line1.setDatePromised(past_month);
@ -381,13 +370,13 @@ public class PurchaseOrderTest extends AbstractTestCase {
assertEquals(0, line1.getQtyInvoiced().intValue());
MOrder order2 = new MOrder(ctx, 0, trxName);
order2.setAD_Org_ID(ORG_FERTILIZER);
order2.setBPartner(MBPartner.get(ctx, BP_PATIO));
order2.setAD_Org_ID(DictionaryIDs.AD_Org.FERTILIZER.id);
order2.setBPartner(MBPartner.get(ctx, DictionaryIDs.C_BPartner.PATIO.id));
order2.setIsSOTrx(false);
order2.setC_DocTypeTarget_ID(MOrder.DocSubTypeSO_Warehouse);
// ?? why setC_DocTypeTarget_ID sets back IsSOTrx=true
order2.setIsSOTrx(false);
order2.setM_Warehouse_ID(WAREHOUSE_FERTILIZER);
order2.setM_Warehouse_ID(DictionaryIDs.M_Warehouse.FERTILIZER.id);
order2.setDocStatus(DocAction.STATUS_Drafted);
order2.setDocAction(DocAction.ACTION_Complete);
order2.setPaymentRule(MOrder.PAYMENTRULE_OnCredit); // this is the default, just making it explicit
@ -396,7 +385,7 @@ public class PurchaseOrderTest extends AbstractTestCase {
MOrderLine line2 = new MOrderLine(order2);
line2.setLine(10);
line2.setProduct(MProduct.get(ctx, PRODUCT_FERT50));
line2.setProduct(MProduct.get(ctx, DictionaryIDs.M_Product.FERTILIZER_50.id));
line2.setM_AttributeSetInstance_ID(asi.getM_AttributeSetInstance_ID());
line2.setQty(new BigDecimal("1"));
line2.setDatePromised(today);
@ -412,8 +401,8 @@ public class PurchaseOrderTest extends AbstractTestCase {
assertEquals(0, line2.getQtyInvoiced().intValue());
// Expected to create two entries in storage because of the different dates
MStorageOnHand[] storages = MStorageOnHand.getWarehouse(ctx, WAREHOUSE_FERTILIZER,
PRODUCT_FERT50, asi.getM_AttributeSetInstance_ID(), null,
MStorageOnHand[] storages = MStorageOnHand.getWarehouse(ctx, DictionaryIDs.M_Warehouse.FERTILIZER.id,
DictionaryIDs.M_Product.FERTILIZER_50.id, asi.getM_AttributeSetInstance_ID(), null,
MClient.MMPOLICY_FiFo.equals(fert50.getMMPolicy()), false,
0, trxName);
assertEquals(2, storages.length);
@ -433,10 +422,10 @@ public class PurchaseOrderTest extends AbstractTestCase {
String trxName = getTrxName();
MOrder order = new MOrder(ctx, 0, trxName);
order.setBPartner(MBPartner.get(ctx, BP_PATIO));
order.setC_DocTypeTarget_ID(DOCTYPE_PO);
order.setBPartner(MBPartner.get(ctx, DictionaryIDs.C_BPartner.PATIO.id));
order.setC_DocTypeTarget_ID(DictionaryIDs.C_DocType.PURCHASE_ORDER.id);
order.setIsSOTrx(false);
order.setSalesRep_ID(USER_GARDENADMIN);
order.setSalesRep_ID(DictionaryIDs.AD_User.GARDEN_ADMIN.id);
order.setDocStatus(DocAction.STATUS_Drafted);
order.setDocAction(DocAction.ACTION_Complete);
Timestamp today = TimeUtil.getDay(System.currentTimeMillis());
@ -446,7 +435,7 @@ public class PurchaseOrderTest extends AbstractTestCase {
MOrderLine line1 = new MOrderLine(order);
line1.setLine(10);
line1.setProduct(MProduct.get(ctx, PRODUCT_WEEDER));
line1.setProduct(MProduct.get(ctx, DictionaryIDs.M_Product.WEEDER.id));
line1.setQty(new BigDecimal("1"));
line1.setDatePromised(today);
line1.saveEx();
@ -458,13 +447,13 @@ public class PurchaseOrderTest extends AbstractTestCase {
Query query = new Query(Env.getCtx(), MStorageReservationLog.Table_Name, "M_Product_ID=? AND IsSOTrx='N' AND M_Warehouse_ID=?", getTrxName());
MStorageReservationLog log = query.setOrderBy(MStorageReservationLog.COLUMNNAME_M_StorageReservationLog_ID+" Desc")
.setParameters(PRODUCT_WEEDER, line1.getM_Warehouse_ID()).first();
.setParameters(DictionaryIDs.M_Product.WEEDER.id, line1.getM_Warehouse_ID()).first();
assertNotNull(log, "MStorageReservationLog not created after completion of purchase order");
assertTrue(log.getDeltaQty().intValue() == 1, "Delta quantity of MStorageReservationLog != 1 ("+log.getDeltaQty().toPlainString()+")");
MStorageReservation ordered = MStorageReservation.get(Env.getCtx(), line1.getM_Warehouse_ID(), PRODUCT_WEEDER, 0, false, getTrxName());
MStorageReservation ordered = MStorageReservation.get(Env.getCtx(), line1.getM_Warehouse_ID(), DictionaryIDs.M_Product.WEEDER.id, 0, false, getTrxName());
assertTrue(log.getNewQty().equals(ordered.getQty()), "New Qty from MStorageReservationLog != Qty from MStorageReservation");
MInOut receipt = new MInOut(order, DOCTYPE_RECEIPT, order.getDateOrdered());
MInOut receipt = new MInOut(order, DictionaryIDs.C_DocType.MM_RECEIPT.id, order.getDateOrdered());
receipt.setDocStatus(DocAction.STATUS_Drafted);
receipt.setDocAction(DocAction.ACTION_Complete);
receipt.saveEx();
@ -482,7 +471,7 @@ public class PurchaseOrderTest extends AbstractTestCase {
log = query.first();
assertNotNull(log, "MStorageReservationLog not created after completion of material receipt");
assertTrue(log.getDeltaQty().intValue() == -1, "Delta quantity of MStorageReservationLog != -1 ("+log.getDeltaQty().toPlainString()+")");
ordered = MStorageReservation.get(Env.getCtx(), line1.getM_Warehouse_ID(), PRODUCT_WEEDER, 0, false, getTrxName());
ordered = MStorageReservation.get(Env.getCtx(), line1.getM_Warehouse_ID(), DictionaryIDs.M_Product.WEEDER.id, 0, false, getTrxName());
assertTrue(log.getNewQty().equals(ordered.getQty()), "New Qty from MStorageReservationLog != Qty from MStorageReservation");
}
@ -495,13 +484,13 @@ public class PurchaseOrderTest extends AbstractTestCase {
new Object[] {MSysConfig.VALIDATE_MATCHING_TO_ORDERED_QTY}, null);
CacheMgt.get().reset();
BigDecimal initialQtyOrdered = getQtyOrdered(Env.getCtx(), PRODUCT_MULCH, getTrxName());
BigDecimal initialQtyOrdered = getQtyOrdered(Env.getCtx(), DictionaryIDs.M_Product.MULCH.id, getTrxName());
try {
MOrder order = new MOrder(ctx, 0, trxName);
order.setBPartner(MBPartner.get(ctx, BP_PATIO));
order.setC_DocTypeTarget_ID(DOCTYPE_PO);
order.setBPartner(MBPartner.get(ctx, DictionaryIDs.C_BPartner.PATIO.id));
order.setC_DocTypeTarget_ID(DictionaryIDs.C_DocType.PURCHASE_ORDER.id);
order.setIsSOTrx(false);
order.setSalesRep_ID(USER_GARDENADMIN);
order.setSalesRep_ID(DictionaryIDs.AD_User.GARDEN_ADMIN.id);
order.setDocStatus(DocAction.STATUS_Drafted);
order.setDocAction(DocAction.ACTION_Complete);
Timestamp today = TimeUtil.getDay(System.currentTimeMillis());
@ -511,7 +500,7 @@ public class PurchaseOrderTest extends AbstractTestCase {
MOrderLine line1 = new MOrderLine(order);
line1.setLine(10);
line1.setProduct(MProduct.get(ctx, PRODUCT_MULCH));
line1.setProduct(MProduct.get(ctx, DictionaryIDs.M_Product.MULCH.id));
line1.setQty(new BigDecimal("1"));
line1.setDatePromised(today);
line1.saveEx();
@ -522,10 +511,10 @@ public class PurchaseOrderTest extends AbstractTestCase {
assertEquals(DocAction.STATUS_Completed, order.getDocStatus(), "Order not completed");
line1.load(trxName);
assertEquals(1, line1.getQtyReserved().intValue(), "Wrong Order line qty reserved value");
BigDecimal newQtyOrdered = getQtyOrdered(Env.getCtx(), PRODUCT_MULCH, getTrxName());
BigDecimal newQtyOrdered = getQtyOrdered(Env.getCtx(), DictionaryIDs.M_Product.MULCH.id, getTrxName());
assertEquals(initialQtyOrdered.intValue()+1, newQtyOrdered.intValue(), "Quantiy Ordered not updated as expected");
MInOut receipt1 = new MInOut(order, DOCTYPE_RECEIPT, order.getDateOrdered());
MInOut receipt1 = new MInOut(order, DictionaryIDs.C_DocType.MM_RECEIPT.id, order.getDateOrdered());
receipt1.setDocStatus(DocAction.STATUS_Drafted);
receipt1.setDocAction(DocAction.ACTION_Complete);
receipt1.saveEx();
@ -542,7 +531,7 @@ public class PurchaseOrderTest extends AbstractTestCase {
line1.load(trxName);
assertEquals(0, line1.getQtyReserved().intValue(), "Wrong order line qty reserved value");
newQtyOrdered = getQtyOrdered(Env.getCtx(), PRODUCT_MULCH, getTrxName());
newQtyOrdered = getQtyOrdered(Env.getCtx(), DictionaryIDs.M_Product.MULCH.id, getTrxName());
assertEquals(initialQtyOrdered.intValue(), newQtyOrdered.intValue(), "Quantiy Ordered not updated as expected");
// reactivate the purchase order
@ -564,7 +553,7 @@ public class PurchaseOrderTest extends AbstractTestCase {
line1.load(trxName);
assertEquals(0, line1.getQtyReserved().intValue(), "Wrong order line qty reserved value");
assertEquals(2, line1.getQtyOrdered().intValue(), "Wrong order line qty ordered value");
newQtyOrdered = getQtyOrdered(Env.getCtx(), PRODUCT_MULCH, getTrxName());
newQtyOrdered = getQtyOrdered(Env.getCtx(), DictionaryIDs.M_Product.MULCH.id, getTrxName());
assertEquals(initialQtyOrdered.intValue(), newQtyOrdered.intValue(), "Quantiy Ordered not updated as expected");
//reverse MR
@ -579,7 +568,7 @@ public class PurchaseOrderTest extends AbstractTestCase {
line1.load(trxName);
assertEquals(2, line1.getQtyReserved().intValue(), "Wrong order line qty reserved value");
assertEquals(0, line1.getQtyDelivered().intValue(), "Wrong order line qty delivered value");
newQtyOrdered = getQtyOrdered(Env.getCtx(), PRODUCT_MULCH, getTrxName());
newQtyOrdered = getQtyOrdered(Env.getCtx(), DictionaryIDs.M_Product.MULCH.id, getTrxName());
assertEquals(initialQtyOrdered.intValue()+2, newQtyOrdered.intValue(), "Quantiy Ordered not updated as expected");
} finally {
DB.executeUpdateEx("UPDATE AD_SysConfig SET Value='Y' WHERE AD_Client_ID=0 AND Name=?",

View File

@ -38,6 +38,7 @@ import org.compiere.util.Env;
import org.compiere.util.TimeUtil;
import org.compiere.wf.MWorkflow;
import org.idempiere.test.AbstractTestCase;
import org.idempiere.test.DictionaryIDs;
import org.junit.jupiter.api.Test;
/**
@ -54,8 +55,8 @@ public class RequisitionTest extends AbstractTestCase {
@Test
public void testComplete() {
int purchaseRequisition = 127;
int standardPriceList = 101;
int purchaseRequisition = DictionaryIDs.C_DocType.PURCHASE_REQUISITION.id;
int standardPriceList = DictionaryIDs.M_PriceList.STANDARD.id;
Timestamp today = TimeUtil.getDay(System.currentTimeMillis());
MRequisition requisition = new MRequisition(Env.getCtx(), 0, getTrxName());
requisition.setC_DocType_ID(purchaseRequisition);
@ -70,8 +71,8 @@ public class RequisitionTest extends AbstractTestCase {
requisition.setPriorityRule(MRequisition.PRIORITYRULE_Medium);
requisition.saveEx();
int seeder = 143;
int each = 100;
int seeder = DictionaryIDs.M_Product.SEEDER.id;
int each = DictionaryIDs.C_UOM.EACH.id;
MRequisitionLine line = new MRequisitionLine(requisition);
line.setM_Product_ID(seeder);
line.setC_UOM_ID(each);

View File

@ -67,6 +67,7 @@ import org.compiere.util.Env;
import org.compiere.util.TimeUtil;
import org.compiere.wf.MWorkflow;
import org.idempiere.test.AbstractTestCase;
import org.idempiere.test.DictionaryIDs;
import org.junit.jupiter.api.Test;
/**
@ -77,23 +78,6 @@ public class SalesOrderTest extends AbstractTestCase {
public SalesOrderTest() {
}
private static final int BP_PATIO = 121;
private static final int DOCTYPE_PO = 126;
private static final int DOCTYPE_RECEIPT = 122;
private final static int BP_JOE_BLOCK = 118;
private static final int PRODUCT_OAK_TREE = 123;
private static final int PRODUCT_AZALEA = 128;
private static final int PRODUCT_FERT50 = 136;
private static final int PRODUCT_MARY = 132;
private static final int PRODUCT_PCHAIR = 133;
private static final int ORG_FERTILIZER = 50001;
private static final int WAREHOUSE_FERTILIZER = 50002;
private static final int WAREHOUSE_HQ_TRANSIT = 50000;
private static final int WAREHOUSE_HQ = 103;
private static final int LOCATOR_FERTILIZER = 50001;
private static final int UOM_HOUR = 101;
private static final int USER_GARDENADMIN = 101;
@Test
/**
* https://idempiere.atlassian.net/browse/IDEMPIERE-235
@ -102,7 +86,7 @@ public class SalesOrderTest extends AbstractTestCase {
//first test - invalid with completeorder and multiple datepromised
MOrder order = new MOrder(Env.getCtx(), 0, getTrxName());
//Joe Block
order.setBPartner(MBPartner.get(Env.getCtx(), BP_JOE_BLOCK));
order.setBPartner(MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.JOE_BLOCK.id));
order.setC_DocTypeTarget_ID(MOrder.DocSubTypeSO_Standard);
order.setDeliveryRule(MOrder.DELIVERYRULE_CompleteOrder);
order.setDocStatus(DocAction.STATUS_Drafted);
@ -114,7 +98,7 @@ public class SalesOrderTest extends AbstractTestCase {
MOrderLine line1 = new MOrderLine(order);
line1.setLine(10);
//Azalea Bush
line1.setProduct(MProduct.get(Env.getCtx(), PRODUCT_AZALEA));
line1.setProduct(MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.AZALEA_BUSH.id));
line1.setQty(new BigDecimal("1"));
line1.setDatePromised(today);
line1.saveEx();
@ -122,7 +106,7 @@ public class SalesOrderTest extends AbstractTestCase {
MOrderLine line2 = new MOrderLine(order);
line2.setLine(20);
//Oak Tree
line2.setProduct(MProduct.get(Env.getCtx(), PRODUCT_OAK_TREE));
line2.setProduct(MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.OAK.id));
line2.setQty(new BigDecimal("1"));
line2.setDatePromised(TimeUtil.addDays(today, 1));
line2.saveEx();
@ -137,7 +121,7 @@ public class SalesOrderTest extends AbstractTestCase {
//second test - ok with completeorder and 1 datepromised
order = new MOrder(Env.getCtx(), 0, getTrxName());
//Joe Block
order.setBPartner(MBPartner.get(Env.getCtx(), BP_JOE_BLOCK));
order.setBPartner(MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.JOE_BLOCK.id));
order.setC_DocTypeTarget_ID(MOrder.DocSubTypeSO_Standard);
order.setDeliveryRule(MOrder.DELIVERYRULE_CompleteOrder);
order.setDocStatus(DocAction.STATUS_Drafted);
@ -148,7 +132,7 @@ public class SalesOrderTest extends AbstractTestCase {
line1 = new MOrderLine(order);
line1.setLine(10);
//Azalea Bush
line1.setProduct(MProduct.get(Env.getCtx(), PRODUCT_AZALEA));
line1.setProduct(MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.AZALEA_BUSH.id));
line1.setQty(new BigDecimal("1"));
line1.setDatePromised(today);
line1.saveEx();
@ -156,7 +140,7 @@ public class SalesOrderTest extends AbstractTestCase {
line2 = new MOrderLine(order);
line2.setLine(20);
//Oak Tree
line2.setProduct(MProduct.get(Env.getCtx(), PRODUCT_OAK_TREE));
line2.setProduct(MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.OAK.id));
line2.setQty(new BigDecimal("1"));
line2.setDatePromised(today);
line2.saveEx();
@ -171,7 +155,7 @@ public class SalesOrderTest extends AbstractTestCase {
//test 3 - ok with !completeorder and multiple datepromised
order = new MOrder(Env.getCtx(), 0, getTrxName());
//Joe Block
order.setBPartner(MBPartner.get(Env.getCtx(), BP_JOE_BLOCK));
order.setBPartner(MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.JOE_BLOCK.id));
order.setC_DocTypeTarget_ID(MOrder.DocSubTypeSO_Standard);
order.setDeliveryRule(MOrder.DELIVERYRULE_Availability);
order.setDocStatus(DocAction.STATUS_Drafted);
@ -182,7 +166,7 @@ public class SalesOrderTest extends AbstractTestCase {
line1 = new MOrderLine(order);
line1.setLine(10);
//Azalea Bush
line1.setProduct(MProduct.get(Env.getCtx(), PRODUCT_AZALEA));
line1.setProduct(MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.AZALEA_BUSH.id));
line1.setQty(new BigDecimal("1"));
line1.setDatePromised(today);
line1.saveEx();
@ -190,7 +174,7 @@ public class SalesOrderTest extends AbstractTestCase {
line2 = new MOrderLine(order);
line2.setLine(20);
//Oak Tree
line2.setProduct(MProduct.get(Env.getCtx(), PRODUCT_OAK_TREE));
line2.setProduct(MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.OAK.id));
line2.setQty(new BigDecimal("1"));
line2.setDatePromised(TimeUtil.addDays(today, 1));
line2.saveEx();
@ -207,7 +191,7 @@ public class SalesOrderTest extends AbstractTestCase {
public void testQtyReservedForOverAndNegativeShipment() {
MOrder order = new MOrder(Env.getCtx(), 0, getTrxName());
//Joe Block
order.setBPartner(MBPartner.get(Env.getCtx(), BP_JOE_BLOCK));
order.setBPartner(MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.JOE_BLOCK.id));
order.setC_DocTypeTarget_ID(MOrder.DocSubTypeSO_Standard);
order.setDeliveryRule(MOrder.DELIVERYRULE_CompleteOrder);
order.setDocStatus(DocAction.STATUS_Drafted);
@ -220,7 +204,7 @@ public class SalesOrderTest extends AbstractTestCase {
MOrderLine line1 = new MOrderLine(order);
line1.setLine(10);
//Azalea Bush
line1.setProduct(MProduct.get(Env.getCtx(), PRODUCT_AZALEA));
line1.setProduct(MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.AZALEA_BUSH.id));
line1.setQty(new BigDecimal("1"));
line1.setDatePromised(today);
line1.saveEx();
@ -232,7 +216,7 @@ public class SalesOrderTest extends AbstractTestCase {
line1.load(getTrxName());
assertEquals(1, line1.getQtyReserved().intValue());
MInOut shipment = new MInOut(order, 120, order.getDateOrdered());
MInOut shipment = new MInOut(order, DictionaryIDs.C_DocType.MM_SHIPMENT.id, order.getDateOrdered());
shipment.setDocStatus(DocAction.STATUS_Drafted);
shipment.setDocAction(DocAction.ACTION_Complete);
shipment.saveEx();
@ -251,7 +235,7 @@ public class SalesOrderTest extends AbstractTestCase {
line1.load(getTrxName());
assertEquals(0, line1.getQtyReserved().intValue());
shipment = new MInOut(order, 120, order.getDateOrdered());
shipment = new MInOut(order, DictionaryIDs.C_DocType.MM_SHIPMENT.id, order.getDateOrdered());
shipment.setDocStatus(DocAction.STATUS_Drafted);
shipment.setDocAction(DocAction.ACTION_Complete);
shipment.saveEx();
@ -275,7 +259,7 @@ public class SalesOrderTest extends AbstractTestCase {
public void testQtyReservedForNegativeOrderAndShipment() {
MOrder order = new MOrder(Env.getCtx(), 0, getTrxName());
//Joe Block
order.setBPartner(MBPartner.get(Env.getCtx(), BP_JOE_BLOCK));
order.setBPartner(MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.JOE_BLOCK.id));
order.setC_DocTypeTarget_ID(MOrder.DocSubTypeSO_Standard);
order.setDeliveryRule(MOrder.DELIVERYRULE_CompleteOrder);
order.setDocStatus(DocAction.STATUS_Drafted);
@ -288,7 +272,7 @@ public class SalesOrderTest extends AbstractTestCase {
MOrderLine line1 = new MOrderLine(order);
line1.setLine(10);
//Azalea Bush
line1.setProduct(MProduct.get(Env.getCtx(), PRODUCT_AZALEA));
line1.setProduct(MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.AZALEA_BUSH.id));
line1.setQty(new BigDecimal("-1"));
line1.setDatePromised(today);
line1.saveEx();
@ -300,7 +284,7 @@ public class SalesOrderTest extends AbstractTestCase {
line1.load(getTrxName());
assertEquals(0, line1.getQtyReserved().intValue());
MInOut shipment = new MInOut(order, 120, order.getDateOrdered());
MInOut shipment = new MInOut(order, DictionaryIDs.C_DocType.MM_SHIPMENT.id, order.getDateOrdered());
shipment.setDocStatus(DocAction.STATUS_Drafted);
shipment.setDocAction(DocAction.ACTION_Complete);
shipment.saveEx();
@ -326,11 +310,11 @@ public class SalesOrderTest extends AbstractTestCase {
String trxName = getTrxName();
// Get the OpenBalance of Joe Block
MBPartner bpartner = new MBPartner(ctx, BP_JOE_BLOCK, trxName);
MBPartner bpartner = new MBPartner(ctx, DictionaryIDs.C_BPartner.JOE_BLOCK.id, trxName);
BigDecimal initialBalance = bpartner.getTotalOpenBalance();
MOrder order = new MOrder(ctx, 0, trxName);
order.setBPartner(MBPartner.get(ctx, BP_JOE_BLOCK));
order.setBPartner(MBPartner.get(ctx, DictionaryIDs.C_BPartner.JOE_BLOCK.id));
order.setC_DocTypeTarget_ID(MOrder.DocSubTypeSO_POS);
order.setDeliveryRule(MOrder.DELIVERYRULE_CompleteOrder);
order.setDocStatus(DocAction.STATUS_Drafted);
@ -342,7 +326,7 @@ public class SalesOrderTest extends AbstractTestCase {
MOrderLine line1 = new MOrderLine(order);
line1.setLine(10);
line1.setProduct(MProduct.get(ctx, PRODUCT_AZALEA));
line1.setProduct(MProduct.get(ctx, DictionaryIDs.M_Product.AZALEA_BUSH.id));
line1.setQty(new BigDecimal("1"));
line1.setDatePromised(today);
line1.saveEx();
@ -376,11 +360,11 @@ public class SalesOrderTest extends AbstractTestCase {
String trxName = getTrxName();
// Get the OpenBalance of Joe Block
MBPartner bpartner = new MBPartner(ctx, BP_JOE_BLOCK, trxName);
MBPartner bpartner = new MBPartner(ctx, DictionaryIDs.C_BPartner.JOE_BLOCK.id, trxName);
BigDecimal initialBalance = bpartner.getTotalOpenBalance();
MOrder order = new MOrder(ctx, 0, trxName);
order.setBPartner(MBPartner.get(ctx, BP_JOE_BLOCK));
order.setBPartner(MBPartner.get(ctx, DictionaryIDs.C_BPartner.JOE_BLOCK.id));
order.setC_DocTypeTarget_ID(MOrder.DocSubTypeSO_POS);
order.setDeliveryRule(MOrder.DELIVERYRULE_CompleteOrder);
order.setDocStatus(DocAction.STATUS_Drafted);
@ -392,7 +376,7 @@ public class SalesOrderTest extends AbstractTestCase {
MOrderLine line1 = new MOrderLine(order);
line1.setLine(10);
line1.setProduct(MProduct.get(ctx, PRODUCT_AZALEA));
line1.setProduct(MProduct.get(ctx, DictionaryIDs.M_Product.AZALEA_BUSH.id));
line1.setQty(new BigDecimal("1"));
line1.setDatePromised(today);
line1.saveEx();
@ -435,7 +419,7 @@ public class SalesOrderTest extends AbstractTestCase {
//test1 with CompleteOrder
MOrder order = new MOrder(Env.getCtx(), 0, getTrxName());
//Joe Block
order.setBPartner(MBPartner.get(Env.getCtx(), BP_JOE_BLOCK));
order.setBPartner(MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.JOE_BLOCK.id));
order.setC_DocTypeTarget_ID(MOrder.DocSubTypeSO_Standard);
order.setDeliveryRule(MOrder.DELIVERYRULE_CompleteOrder);
order.setDocStatus(DocAction.STATUS_Drafted);
@ -448,7 +432,7 @@ public class SalesOrderTest extends AbstractTestCase {
MOrderLine line1 = new MOrderLine(order);
line1.setLine(10);
//Azalea Bush
line1.setProduct(MProduct.get(Env.getCtx(), PRODUCT_AZALEA));
line1.setProduct(MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.AZALEA_BUSH.id));
line1.setQty(new BigDecimal("1"));
line1.setDatePromised(today);
line1.saveEx();
@ -680,17 +664,17 @@ public class SalesOrderTest extends AbstractTestCase {
Properties ctx = Env.getCtx();
String trxName = getTrxName();
MProduct fert50 = new MProduct(ctx, PRODUCT_FERT50, trxName);
MProduct fert50 = new MProduct(ctx, DictionaryIDs.M_Product.FERTILIZER_50.id, trxName);
Timestamp today = TimeUtil.getDay(System.currentTimeMillis());
Timestamp past_month = TimeUtil.addMonths(today, -1);
MWarehouse wh = new MWarehouse(ctx, WAREHOUSE_FERTILIZER, trxName);
MWarehouse wh = new MWarehouse(ctx, DictionaryIDs.M_Warehouse.FERTILIZER.id, trxName);
wh.setIsDisallowNegativeInv(true);
wh.saveEx();
CacheMgt.get().reset(MWarehouse.Table_Name, WAREHOUSE_FERTILIZER);
CacheMgt.get().reset(MWarehouse.Table_Name, DictionaryIDs.M_Warehouse.FERTILIZER.id);
// Put the modified record into cache
MWarehouse.get(ctx, WAREHOUSE_FERTILIZER, trxName);
MWarehouse.get(ctx, DictionaryIDs.M_Warehouse.FERTILIZER.id, trxName);
// create an ASI for Fertilizer Lot with Lot 1010
MAttributeSetInstance asi = new MAttributeSetInstance(ctx, 0, trxName);
@ -698,12 +682,12 @@ public class SalesOrderTest extends AbstractTestCase {
asi.setLot("1010");
asi.saveEx();
MStorageOnHand.add(ctx, LOCATOR_FERTILIZER, PRODUCT_FERT50, asi.getM_AttributeSetInstance_ID(), Env.ONE, past_month, trxName);
MStorageOnHand.add(ctx, LOCATOR_FERTILIZER, PRODUCT_FERT50, asi.getM_AttributeSetInstance_ID(), Env.ONE, today, trxName);
MStorageOnHand.add(ctx, DictionaryIDs.M_Locator.FERTILIZER.id, DictionaryIDs.M_Product.FERTILIZER_50.id, asi.getM_AttributeSetInstance_ID(), Env.ONE, past_month, trxName);
MStorageOnHand.add(ctx, DictionaryIDs.M_Locator.FERTILIZER.id, DictionaryIDs.M_Product.FERTILIZER_50.id, asi.getM_AttributeSetInstance_ID(), Env.ONE, today, trxName);
// Expected to create two entries in storage because of the different dates
MStorageOnHand[] storages = MStorageOnHand.getWarehouse(ctx, WAREHOUSE_FERTILIZER,
PRODUCT_FERT50, asi.getM_AttributeSetInstance_ID(), null,
MStorageOnHand[] storages = MStorageOnHand.getWarehouse(ctx, DictionaryIDs.M_Warehouse.FERTILIZER.id,
DictionaryIDs.M_Product.FERTILIZER_50.id, asi.getM_AttributeSetInstance_ID(), null,
MClient.MMPOLICY_FiFo.equals(fert50.getMMPolicy()), false,
0, trxName);
assertEquals(2, storages.length);
@ -717,11 +701,11 @@ public class SalesOrderTest extends AbstractTestCase {
}
MOrder order = new MOrder(ctx, 0, trxName);
order.setAD_Org_ID(ORG_FERTILIZER);
order.setBPartner(MBPartner.get(ctx, BP_JOE_BLOCK));
order.setAD_Org_ID(DictionaryIDs.AD_Org.FERTILIZER.id);
order.setBPartner(MBPartner.get(ctx, DictionaryIDs.C_BPartner.JOE_BLOCK.id));
order.setC_DocTypeTarget_ID(MOrder.DocSubTypeSO_Standard);
order.setDeliveryRule(MOrder.DELIVERYRULE_CompleteOrder);
order.setM_Warehouse_ID(WAREHOUSE_FERTILIZER);
order.setM_Warehouse_ID(DictionaryIDs.M_Warehouse.FERTILIZER.id);
order.setDocStatus(DocAction.STATUS_Drafted);
order.setDocAction(DocAction.ACTION_Complete);
order.setPaymentRule(MOrder.PAYMENTRULE_OnCredit); // this is the default, just making it explicit
@ -730,7 +714,7 @@ public class SalesOrderTest extends AbstractTestCase {
MOrderLine line1 = new MOrderLine(order);
line1.setLine(10);
line1.setProduct(MProduct.get(ctx, PRODUCT_FERT50));
line1.setProduct(MProduct.get(ctx, DictionaryIDs.M_Product.FERTILIZER_50.id));
line1.setM_AttributeSetInstance_ID(asi.getM_AttributeSetInstance_ID());
line1.setQty(new BigDecimal("2"));
line1.setDatePromised(today);
@ -764,7 +748,7 @@ public class SalesOrderTest extends AbstractTestCase {
ip.saveEx();
// Add Parameter - M_Warehouse_ID=x
ip = new MPInstancePara(instance, 30);
ip.setParameter("M_Warehouse_ID", WAREHOUSE_FERTILIZER);
ip.setParameter("M_Warehouse_ID", DictionaryIDs.M_Warehouse.FERTILIZER.id);
ip.saveEx();
ServerProcessCtl processCtl = new ServerProcessCtl(pi, getTrx());
@ -778,8 +762,8 @@ public class SalesOrderTest extends AbstractTestCase {
assertEquals(2, line1.getQtyDelivered().intValue());
// Expected to have cleared both storage entries on shipment
storages = MStorageOnHand.getWarehouse(ctx, WAREHOUSE_FERTILIZER,
PRODUCT_FERT50, asi.getM_AttributeSetInstance_ID(), null,
storages = MStorageOnHand.getWarehouse(ctx, DictionaryIDs.M_Warehouse.FERTILIZER.id,
DictionaryIDs.M_Product.FERTILIZER_50.id, asi.getM_AttributeSetInstance_ID(), null,
MClient.MMPOLICY_FiFo.equals(fert50.getMMPolicy()), false,
0, trxName);
assertEquals(0, storages.length);
@ -793,7 +777,7 @@ public class SalesOrderTest extends AbstractTestCase {
assertEquals(line1.getQtyOrdered(), ilines[0].getMovementQty(), "Shipment line doesn't has the expected movement quantity");
assertEquals(line1.getM_Product_ID(), ilines[0].getM_Product_ID(), "Shipment line doesn't has the expected product ID");
assertEquals(line1.getM_AttributeSetInstance_ID(), ilines[0].getM_AttributeSetInstance_ID(), "Shipment line doesn't has the expected ASI ID");
assertEquals(LOCATOR_FERTILIZER, ilines[0].getM_Locator_ID(), "Shipment line doesn't has the expected Locator ID");
assertEquals(DictionaryIDs.M_Locator.FERTILIZER.id, ilines[0].getM_Locator_ID(), "Shipment line doesn't has the expected Locator ID");
}
@Test
@ -802,17 +786,17 @@ public class SalesOrderTest extends AbstractTestCase {
*/
public void testUOMDefault() {
MOrder order = new MOrder(Env.getCtx(), 0, getTrxName());
order.setBPartner(MBPartner.get(Env.getCtx(), BP_JOE_BLOCK));
order.setBPartner(MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.JOE_BLOCK.id));
order.saveEx();
MOrderLine line1 = new MOrderLine(order);
line1.setLine(10);
//Assembly Area with default UOM = Hour
line1.setProduct(MProduct.get(Env.getCtx(), PRODUCT_MARY));
line1.setProduct(MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.MARY.id));
line1.setQty(new BigDecimal("1"));
line1.saveEx();
assertEquals(UOM_HOUR, line1.getC_UOM_ID());
assertEquals(DictionaryIDs.C_UOM.HOUR.id, line1.getC_UOM_ID());
MOrderLine line2 = new MOrderLine(order);
line2.setLine(20);
@ -826,7 +810,7 @@ public class SalesOrderTest extends AbstractTestCase {
public void testQtyReservedLog() {
MOrder order = new MOrder(Env.getCtx(), 0, getTrxName());
//Joe Block
order.setBPartner(MBPartner.get(Env.getCtx(), BP_JOE_BLOCK));
order.setBPartner(MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.JOE_BLOCK.id));
order.setC_DocTypeTarget_ID(MOrder.DocSubTypeSO_Standard);
order.setDeliveryRule(MOrder.DELIVERYRULE_CompleteOrder);
order.setDocStatus(DocAction.STATUS_Drafted);
@ -839,7 +823,7 @@ public class SalesOrderTest extends AbstractTestCase {
MOrderLine line1 = new MOrderLine(order);
line1.setLine(10);
//Azalea Bush
line1.setProduct(MProduct.get(Env.getCtx(), PRODUCT_AZALEA));
line1.setProduct(MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.AZALEA_BUSH.id));
line1.setQty(new BigDecimal("1"));
line1.setDatePromised(today);
line1.saveEx();
@ -853,13 +837,13 @@ public class SalesOrderTest extends AbstractTestCase {
Query query = new Query(Env.getCtx(), MStorageReservationLog.Table_Name, "M_Product_ID=? AND IsSOTrx='Y' AND M_Warehouse_ID=?", getTrxName());
MStorageReservationLog log = query.setOrderBy(MStorageReservationLog.COLUMNNAME_M_StorageReservationLog_ID+" Desc")
.setParameters(PRODUCT_AZALEA, line1.getM_Warehouse_ID()).first();
.setParameters(DictionaryIDs.M_Product.AZALEA_BUSH.id, line1.getM_Warehouse_ID()).first();
assertNotNull(log, "MStorageReservationLog not created after completion of sales order");
assertTrue(log.getDeltaQty().intValue() == 1, "Delta quantity of MStorageReservationLog != 1 ("+log.getDeltaQty().toPlainString()+")");
MStorageReservation reservation = MStorageReservation.get(Env.getCtx(), line1.getM_Warehouse_ID(), PRODUCT_AZALEA, 0, true, getTrxName());
MStorageReservation reservation = MStorageReservation.get(Env.getCtx(), line1.getM_Warehouse_ID(), DictionaryIDs.M_Product.AZALEA_BUSH.id, 0, true, getTrxName());
assertTrue(log.getNewQty().equals(reservation.getQty()), "New Qty from MStorageReservationLog != Qty from MStorageReservation");
MInOut shipment = new MInOut(order, 120, order.getDateOrdered());
MInOut shipment = new MInOut(order, DictionaryIDs.C_DocType.MM_SHIPMENT.id, order.getDateOrdered());
shipment.setDocStatus(DocAction.STATUS_Drafted);
shipment.setDocAction(DocAction.ACTION_Complete);
shipment.saveEx();
@ -878,14 +862,14 @@ public class SalesOrderTest extends AbstractTestCase {
log = query.first();
assertNotNull(log, "MStorageReservationLog not created after completion of shipment");
assertTrue(log.getDeltaQty().intValue() == -1, "Delta quantity of MStorageReservationLog != -1 ("+log.getDeltaQty().toPlainString()+")");
reservation = MStorageReservation.get(Env.getCtx(), line1.getM_Warehouse_ID(), PRODUCT_AZALEA, 0, true, getTrxName());
reservation = MStorageReservation.get(Env.getCtx(), line1.getM_Warehouse_ID(), DictionaryIDs.M_Product.AZALEA_BUSH.id, 0, true, getTrxName());
assertTrue(log.getNewQty().equals(reservation.getQty()), "New Qty from MStorageReservationLog != Qty from MStorageReservation");
}
@Test
public void testQtyLostSales() {
MOrder order = new MOrder(Env.getCtx(), 0, getTrxName());
order.setBPartner(MBPartner.get(Env.getCtx(), BP_JOE_BLOCK));
order.setBPartner(MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.JOE_BLOCK.id));
order.setC_DocTypeTarget_ID(MOrder.DocSubTypeSO_Standard);
order.setDeliveryRule(MOrder.DELIVERYRULE_CompleteOrder);
order.setDocStatus(DocAction.STATUS_Drafted);
@ -897,7 +881,7 @@ public class SalesOrderTest extends AbstractTestCase {
MOrderLine line1 = new MOrderLine(order);
line1.setLine(10);
line1.setProduct(MProduct.get(Env.getCtx(), PRODUCT_AZALEA));
line1.setProduct(MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.AZALEA_BUSH.id));
line1.setQty(new BigDecimal("1"));
line1.setDatePromised(today);
line1.saveEx();
@ -909,7 +893,7 @@ public class SalesOrderTest extends AbstractTestCase {
line1.load(getTrxName());
assertEquals(1, line1.getQtyReserved().intValue());
MInOut shipment = new MInOut(order, 120, order.getDateOrdered());
MInOut shipment = new MInOut(order, DictionaryIDs.C_DocType.MM_SHIPMENT.id, order.getDateOrdered());
shipment.setDocStatus(DocAction.STATUS_Drafted);
shipment.setDocAction(DocAction.ACTION_Complete);
shipment.saveEx();
@ -934,7 +918,7 @@ public class SalesOrderTest extends AbstractTestCase {
assertEquals(0, line1.getQtyLostSales().intValue());
order = new MOrder(Env.getCtx(), 0, getTrxName());
order.setBPartner(MBPartner.get(Env.getCtx(), BP_JOE_BLOCK));
order.setBPartner(MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.JOE_BLOCK.id));
order.setC_DocTypeTarget_ID(MOrder.DocSubTypeSO_Standard);
order.setDeliveryRule(MOrder.DELIVERYRULE_CompleteOrder);
order.setDocStatus(DocAction.STATUS_Drafted);
@ -945,7 +929,7 @@ public class SalesOrderTest extends AbstractTestCase {
line1 = new MOrderLine(order);
line1.setLine(10);
line1.setProduct(MProduct.get(Env.getCtx(), PRODUCT_AZALEA));
line1.setProduct(MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.AZALEA_BUSH.id));
line1.setQty(new BigDecimal("2"));
line1.setDatePromised(today);
line1.saveEx();
@ -957,7 +941,7 @@ public class SalesOrderTest extends AbstractTestCase {
line1.load(getTrxName());
assertEquals(2, line1.getQtyReserved().intValue());
shipment = new MInOut(order, 120, order.getDateOrdered());
shipment = new MInOut(order, DictionaryIDs.C_DocType.MM_SHIPMENT.id, order.getDateOrdered());
shipment.setDocStatus(DocAction.STATUS_Drafted);
shipment.setDocAction(DocAction.ACTION_Complete);
shipment.saveEx();
@ -987,25 +971,25 @@ public class SalesOrderTest extends AbstractTestCase {
public void testWarehouseChange() {
MOrder order = new MOrder(Env.getCtx(), 0, getTrxName());
//Joe Block
order.setBPartner(MBPartner.get(Env.getCtx(), BP_JOE_BLOCK));
order.setBPartner(MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.JOE_BLOCK.id));
order.setC_DocTypeTarget_ID(MOrder.DocSubTypeSO_Standard);
order.setDocStatus(DocAction.STATUS_Drafted);
order.setDocAction(DocAction.ACTION_Prepare);
Timestamp today = TimeUtil.getDay(System.currentTimeMillis());
order.setDateOrdered(today);
order.setDatePromised(today);
order.setM_Warehouse_ID(WAREHOUSE_HQ);
order.setM_Warehouse_ID(DictionaryIDs.M_Warehouse.HQ.id);
order.saveEx();
MOrderLine line1 = new MOrderLine(order);
line1.setLine(10);
//Azalea Bush
line1.setProduct(MProduct.get(Env.getCtx(), PRODUCT_AZALEA));
line1.setProduct(MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.AZALEA_BUSH.id));
line1.setQty(new BigDecimal("1"));
line1.setDatePromised(today);
line1.saveEx();
order.setM_Warehouse_ID(WAREHOUSE_HQ_TRANSIT);
order.setM_Warehouse_ID(DictionaryIDs.M_Warehouse.HQT.id);
boolean success = order.save();
assertEquals(true, success);
@ -1014,7 +998,7 @@ public class SalesOrderTest extends AbstractTestCase {
assertFalse(info.isError());
// No change on warehouse allowed if QtyDelivered, QtyInvoice or QtyReserved != 0 on any line
order.setM_Warehouse_ID(WAREHOUSE_HQ);
order.setM_Warehouse_ID(DictionaryIDs.M_Warehouse.HQ.id);
success = order.save();
assertEquals(false, success);
}
@ -1022,7 +1006,7 @@ public class SalesOrderTest extends AbstractTestCase {
@Test
public void testSetASIWhenShipping() {
MOrder order = new MOrder(Env.getCtx(), 0, getTrxName());
order.setBPartner(MBPartner.get(Env.getCtx(), BP_JOE_BLOCK));
order.setBPartner(MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.JOE_BLOCK.id));
order.setC_DocTypeTarget_ID(MOrder.DocSubTypeSO_Standard);
order.setDeliveryRule(MOrder.DELIVERYRULE_CompleteOrder);
order.setDocStatus(DocAction.STATUS_Drafted);
@ -1034,7 +1018,7 @@ public class SalesOrderTest extends AbstractTestCase {
MOrderLine line1 = new MOrderLine(order);
line1.setLine(10);
line1.setProduct(MProduct.get(Env.getCtx(), PRODUCT_PCHAIR));
line1.setProduct(MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.P_CHAIR.id));
line1.setQty(new BigDecimal("1"));
line1.setDatePromised(today);
line1.saveEx();
@ -1046,9 +1030,9 @@ public class SalesOrderTest extends AbstractTestCase {
line1.load(getTrxName());
assertEquals(1, line1.getQtyReserved().intValue(), "Unexpected order line qty reserved value");
int originalOnHand = MStorageOnHand.getQtyOnHandWithASIZero(PRODUCT_PCHAIR, getM_Warehouse_ID(), getTrxName()).intValue();
int originalOnHand = MStorageOnHand.getQtyOnHandWithASIZero(DictionaryIDs.M_Product.P_CHAIR.id, getM_Warehouse_ID(), getTrxName()).intValue();
MInOut shipment = new MInOut(order, 120, order.getDateOrdered());
MInOut shipment = new MInOut(order, DictionaryIDs.C_DocType.MM_SHIPMENT.id, order.getDateOrdered());
shipment.setDocStatus(DocAction.STATUS_Drafted);
shipment.setDocAction(DocAction.ACTION_Complete);
shipment.saveEx();
@ -1057,7 +1041,7 @@ public class SalesOrderTest extends AbstractTestCase {
shipmentLine.setOrderLine(line1, 0, new BigDecimal("1"));
shipmentLine.setQty(new BigDecimal("1"));
MAttributeSetInstance asi = new MAttributeSetInstance(Env.getCtx(), 0, getTrxName());
asi.setM_AttributeSet_ID(MProduct.get(PRODUCT_PCHAIR).getM_AttributeSet_ID());
asi.setM_AttributeSet_ID(MProduct.get(DictionaryIDs.M_Product.P_CHAIR.id).getM_AttributeSet_ID());
asi.setSerNo("PChair Serial #1000000");
asi.saveEx();
shipmentLine.setM_AttributeSetInstance_ID(asi.getM_AttributeSetInstance_ID());
@ -1068,12 +1052,12 @@ public class SalesOrderTest extends AbstractTestCase {
shipment.load(getTrxName());
assertEquals(DocAction.STATUS_Completed, shipment.getDocStatus(), "Unexpected Shipment document status");
int newOnHand = MStorageOnHand.getQtyOnHandWithASIZero(PRODUCT_PCHAIR, getM_Warehouse_ID(), getTrxName()).intValue();
int newOnHand = MStorageOnHand.getQtyOnHandWithASIZero(DictionaryIDs.M_Product.P_CHAIR.id, getM_Warehouse_ID(), getTrxName()).intValue();
assertEquals(originalOnHand-1, newOnHand, "Unexpected on hand quantity");
int asiOnHand = MStorageOnHand.getQtyOnHand(PRODUCT_PCHAIR, getM_Warehouse_ID(), asi.get_ID(), getTrxName()).intValue();
int asiOnHand = MStorageOnHand.getQtyOnHand(DictionaryIDs.M_Product.P_CHAIR.id, getM_Warehouse_ID(), asi.get_ID(), getTrxName()).intValue();
int asiRecords = 0;
MStorageOnHand[] storages = MStorageOnHand.getOfProduct(Env.getCtx(), PRODUCT_PCHAIR, getTrxName());
MStorageOnHand[] storages = MStorageOnHand.getOfProduct(Env.getCtx(), DictionaryIDs.M_Product.P_CHAIR.id, getTrxName());
for (MStorageOnHand storage : storages) {
if (storage.getM_Warehouse_ID()==getM_Warehouse_ID() && storage.getM_AttributeSetInstance_ID()==asi.get_ID()) {
asiRecords++;
@ -1103,11 +1087,11 @@ public class SalesOrderTest extends AbstractTestCase {
assertFalse(info.isError(), info.getSummary());
shipment.load(getTrxName());
assertEquals(DocAction.STATUS_Reversed, shipment.getDocStatus(), "Unexpected Shipment document status");
newOnHand = MStorageOnHand.getQtyOnHandWithASIZero(PRODUCT_PCHAIR, getM_Warehouse_ID(), getTrxName()).intValue();
newOnHand = MStorageOnHand.getQtyOnHandWithASIZero(DictionaryIDs.M_Product.P_CHAIR.id, getM_Warehouse_ID(), getTrxName()).intValue();
assertEquals(originalOnHand, newOnHand, "Unexpected on hand quantity no ASI");
asiOnHand = MStorageOnHand.getQtyOnHand(PRODUCT_PCHAIR, getM_Warehouse_ID(), asi.get_ID(), getTrxName()).intValue();
asiOnHand = MStorageOnHand.getQtyOnHand(DictionaryIDs.M_Product.P_CHAIR.id, getM_Warehouse_ID(), asi.get_ID(), getTrxName()).intValue();
assertEquals(0, asiOnHand, "Unexpected on hand quantity for Serial ASI");
storages = MStorageOnHand.getOfProduct(Env.getCtx(), PRODUCT_PCHAIR, getTrxName());
storages = MStorageOnHand.getOfProduct(Env.getCtx(), DictionaryIDs.M_Product.P_CHAIR.id, getTrxName());
for (MStorageOnHand storage : storages) {
if (storage.getM_Warehouse_ID() == getM_Warehouse_ID()) {
if (storage.getM_AttributeSetInstance_ID() == asi.get_ID()) {
@ -1137,7 +1121,7 @@ public class SalesOrderTest extends AbstractTestCase {
@Test
public void testSetASIWhenShipping2() {
MOrder order = new MOrder(Env.getCtx(), 0, getTrxName());
order.setBPartner(MBPartner.get(Env.getCtx(), BP_JOE_BLOCK));
order.setBPartner(MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.JOE_BLOCK.id));
order.setC_DocTypeTarget_ID(MOrder.DocSubTypeSO_Standard);
order.setDeliveryRule(MOrder.DELIVERYRULE_CompleteOrder);
order.setDocStatus(DocAction.STATUS_Drafted);
@ -1149,7 +1133,7 @@ public class SalesOrderTest extends AbstractTestCase {
MOrderLine line1 = new MOrderLine(order);
line1.setLine(10);
line1.setProduct(MProduct.get(Env.getCtx(), PRODUCT_PCHAIR));
line1.setProduct(MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.P_CHAIR.id));
line1.setQty(new BigDecimal("2"));
line1.setDatePromised(today);
line1.saveEx();
@ -1161,9 +1145,9 @@ public class SalesOrderTest extends AbstractTestCase {
line1.load(getTrxName());
assertEquals(2, line1.getQtyReserved().intValue(), "Unexpected order line qty reserved value");
int originalOnHand = MStorageOnHand.getQtyOnHandWithASIZero(PRODUCT_PCHAIR, getM_Warehouse_ID(), getTrxName()).intValue();
int originalOnHand = MStorageOnHand.getQtyOnHandWithASIZero(DictionaryIDs.M_Product.P_CHAIR.id, getM_Warehouse_ID(), getTrxName()).intValue();
MInOut shipment = new MInOut(order, 120, order.getDateOrdered());
MInOut shipment = new MInOut(order, DictionaryIDs.C_DocType.MM_SHIPMENT.id, order.getDateOrdered());
shipment.setDocStatus(DocAction.STATUS_Drafted);
shipment.setDocAction(DocAction.ACTION_Complete);
shipment.saveEx();
@ -1174,11 +1158,11 @@ public class SalesOrderTest extends AbstractTestCase {
shipmentLine.saveEx();
MAttributeSetInstance asi1 = new MAttributeSetInstance(Env.getCtx(), 0, getTrxName());
asi1.setM_AttributeSet_ID(MProduct.get(PRODUCT_PCHAIR).getM_AttributeSet_ID());
asi1.setM_AttributeSet_ID(MProduct.get(DictionaryIDs.M_Product.P_CHAIR.id).getM_AttributeSet_ID());
asi1.setSerNo("PChair Serial #1000000");
asi1.saveEx();
MAttributeSetInstance asi2 = new MAttributeSetInstance(Env.getCtx(), 0, getTrxName());
asi2.setM_AttributeSet_ID(MProduct.get(PRODUCT_PCHAIR).getM_AttributeSet_ID());
asi2.setM_AttributeSet_ID(MProduct.get(DictionaryIDs.M_Product.P_CHAIR.id).getM_AttributeSet_ID());
asi2.setSerNo("PChair Serial #1000000");
asi2.saveEx();
MInOutLineMA ma1 = new MInOutLineMA(Env.getCtx(), 0, getTrxName());
@ -1201,12 +1185,12 @@ public class SalesOrderTest extends AbstractTestCase {
shipment.load(getTrxName());
assertEquals(DocAction.STATUS_Completed, shipment.getDocStatus(), "Unexpected Shipment document status");
int newOnHand = MStorageOnHand.getQtyOnHandWithASIZero(PRODUCT_PCHAIR, getM_Warehouse_ID(), getTrxName()).intValue();
int newOnHand = MStorageOnHand.getQtyOnHandWithASIZero(DictionaryIDs.M_Product.P_CHAIR.id, getM_Warehouse_ID(), getTrxName()).intValue();
assertEquals(originalOnHand-2, newOnHand, "Unexpected on hand quantity");
int asiOnHand = MStorageOnHand.getQtyOnHand(PRODUCT_PCHAIR, getM_Warehouse_ID(), asi1.get_ID(), getTrxName()).intValue();
int asiOnHand = MStorageOnHand.getQtyOnHand(DictionaryIDs.M_Product.P_CHAIR.id, getM_Warehouse_ID(), asi1.get_ID(), getTrxName()).intValue();
int asiRecords = 0;
MStorageOnHand[] storages = MStorageOnHand.getOfProduct(Env.getCtx(), PRODUCT_PCHAIR, getTrxName());
MStorageOnHand[] storages = MStorageOnHand.getOfProduct(Env.getCtx(), DictionaryIDs.M_Product.P_CHAIR.id, getTrxName());
for (MStorageOnHand storage : storages) {
if (storage.getM_Warehouse_ID()==getM_Warehouse_ID() && storage.getM_AttributeSetInstance_ID()==asi1.get_ID()) {
asiRecords++;
@ -1215,9 +1199,9 @@ public class SalesOrderTest extends AbstractTestCase {
assertEquals(0, asiOnHand, "Unexpected on hand quantity for Serial ASI 1");
assertEquals(1, asiRecords, "Unexpected number of Serial ASI 1 Storage records");
asiOnHand = MStorageOnHand.getQtyOnHand(PRODUCT_PCHAIR, getM_Warehouse_ID(), asi2.get_ID(), getTrxName()).intValue();
asiOnHand = MStorageOnHand.getQtyOnHand(DictionaryIDs.M_Product.P_CHAIR.id, getM_Warehouse_ID(), asi2.get_ID(), getTrxName()).intValue();
asiRecords = 0;
storages = MStorageOnHand.getOfProduct(Env.getCtx(), PRODUCT_PCHAIR, getTrxName());
storages = MStorageOnHand.getOfProduct(Env.getCtx(), DictionaryIDs.M_Product.P_CHAIR.id, getTrxName());
for (MStorageOnHand storage : storages) {
if (storage.getM_Warehouse_ID()==getM_Warehouse_ID() && storage.getM_AttributeSetInstance_ID()==asi2.get_ID()) {
asiRecords++;
@ -1255,12 +1239,12 @@ public class SalesOrderTest extends AbstractTestCase {
assertFalse(info.isError(), info.getSummary());
shipment.load(getTrxName());
assertEquals(DocAction.STATUS_Reversed, shipment.getDocStatus(), "Unexpected Shipment document status");
newOnHand = MStorageOnHand.getQtyOnHandWithASIZero(PRODUCT_PCHAIR, getM_Warehouse_ID(), getTrxName()).intValue();
newOnHand = MStorageOnHand.getQtyOnHandWithASIZero(DictionaryIDs.M_Product.P_CHAIR.id, getM_Warehouse_ID(), getTrxName()).intValue();
assertEquals(originalOnHand, newOnHand, "Unexpected on hand quantity no ASI");
asiOnHand = MStorageOnHand.getQtyOnHand(PRODUCT_PCHAIR, getM_Warehouse_ID(), asi1.get_ID(), getTrxName()).intValue();
asiOnHand = MStorageOnHand.getQtyOnHand(DictionaryIDs.M_Product.P_CHAIR.id, getM_Warehouse_ID(), asi1.get_ID(), getTrxName()).intValue();
assertEquals(0, asiOnHand, "Unexpected on hand quantity for Serial ASI 1");
storages = MStorageOnHand.getOfProduct(Env.getCtx(), PRODUCT_PCHAIR, getTrxName());
storages = MStorageOnHand.getOfProduct(Env.getCtx(), DictionaryIDs.M_Product.P_CHAIR.id, getTrxName());
for (MStorageOnHand storage : storages) {
if (storage.getM_Warehouse_ID() == getM_Warehouse_ID()) {
if (storage.getM_AttributeSetInstance_ID() == asi1.get_ID()) {
@ -1269,9 +1253,9 @@ public class SalesOrderTest extends AbstractTestCase {
}
}
asiOnHand = MStorageOnHand.getQtyOnHand(PRODUCT_PCHAIR, getM_Warehouse_ID(), asi2.get_ID(), getTrxName()).intValue();
asiOnHand = MStorageOnHand.getQtyOnHand(DictionaryIDs.M_Product.P_CHAIR.id, getM_Warehouse_ID(), asi2.get_ID(), getTrxName()).intValue();
assertEquals(0, asiOnHand, "Unexpected on hand quantity for Serial ASI 2");
storages = MStorageOnHand.getOfProduct(Env.getCtx(), PRODUCT_PCHAIR, getTrxName());
storages = MStorageOnHand.getOfProduct(Env.getCtx(), DictionaryIDs.M_Product.P_CHAIR.id, getTrxName());
for (MStorageOnHand storage : storages) {
if (storage.getM_Warehouse_ID() == getM_Warehouse_ID()) {
if (storage.getM_AttributeSetInstance_ID() == asi2.get_ID()) {
@ -1312,17 +1296,17 @@ public class SalesOrderTest extends AbstractTestCase {
Timestamp today = TimeUtil.getDay(System.currentTimeMillis());
Timestamp tomorrow = TimeUtil.addDays(today, 1);
MOrder order = new MOrder(Env.getCtx(), 0, getTrxName());
order.setBPartner(MBPartner.get(Env.getCtx(), BP_PATIO));
order.setC_DocTypeTarget_ID(DOCTYPE_PO);
order.setBPartner(MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.PATIO.id));
order.setC_DocTypeTarget_ID(DictionaryIDs.C_DocType.PURCHASE_ORDER.id);
order.setIsSOTrx(false);
order.setSalesRep_ID(USER_GARDENADMIN);
order.setSalesRep_ID(DictionaryIDs.AD_User.GARDEN_ADMIN.id);
order.setDocStatus(DocAction.STATUS_Drafted);
order.setDocAction(DocAction.ACTION_Complete);
order.setDateOrdered(today);
order.setDatePromised(today);
order.saveEx();
MProduct fert = MProduct.get(Env.getCtx(), PRODUCT_FERT50);
MProduct fert = MProduct.get(Env.getCtx(), DictionaryIDs.M_Product.FERTILIZER_50.id);
MOrderLine line1 = new MOrderLine(order);
line1.setLine(10);
line1.setProduct(fert);
@ -1335,7 +1319,7 @@ public class SalesOrderTest extends AbstractTestCase {
order.load(getTrxName());
assertEquals(DocAction.STATUS_Completed, order.getDocStatus(), "Order not completed");
MInOut receipt = new MInOut(order, DOCTYPE_RECEIPT, order.getDateOrdered());
MInOut receipt = new MInOut(order, DictionaryIDs.C_DocType.MM_RECEIPT.id, order.getDateOrdered());
receipt.setDocStatus(DocAction.STATUS_Drafted);
receipt.setDocAction(DocAction.ACTION_Complete);
receipt.saveEx();
@ -1369,10 +1353,10 @@ public class SalesOrderTest extends AbstractTestCase {
assertEquals(DocAction.STATUS_Completed, receipt.getDocStatus());
order = new MOrder(Env.getCtx(), 0, getTrxName());
order.setBPartner(MBPartner.get(Env.getCtx(), BP_PATIO));
order.setC_DocTypeTarget_ID(DOCTYPE_PO);
order.setBPartner(MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.PATIO.id));
order.setC_DocTypeTarget_ID(DictionaryIDs.C_DocType.PURCHASE_ORDER.id);
order.setIsSOTrx(false);
order.setSalesRep_ID(USER_GARDENADMIN);
order.setSalesRep_ID(DictionaryIDs.AD_User.GARDEN_ADMIN.id);
order.setDocStatus(DocAction.STATUS_Drafted);
order.setDocAction(DocAction.ACTION_Complete);
order.setDateOrdered(tomorrow);
@ -1391,7 +1375,7 @@ public class SalesOrderTest extends AbstractTestCase {
order.load(getTrxName());
assertEquals(DocAction.STATUS_Completed, order.getDocStatus(), "Order not completed");
receipt = new MInOut(order, DOCTYPE_RECEIPT, order.getDateOrdered());
receipt = new MInOut(order, DictionaryIDs.C_DocType.MM_RECEIPT.id, order.getDateOrdered());
receipt.setDocStatus(DocAction.STATUS_Drafted);
receipt.setDocAction(DocAction.ACTION_Complete);
receipt.saveEx();
@ -1431,7 +1415,7 @@ public class SalesOrderTest extends AbstractTestCase {
//sales and shipment
order = new MOrder(Env.getCtx(), 0, getTrxName());
order.setBPartner(MBPartner.get(Env.getCtx(), BP_JOE_BLOCK));
order.setBPartner(MBPartner.get(Env.getCtx(), DictionaryIDs.C_BPartner.JOE_BLOCK.id));
order.setC_DocTypeTarget_ID(MOrder.DocSubTypeSO_Standard);
order.setDeliveryRule(MOrder.DELIVERYRULE_CompleteOrder);
order.setDocStatus(DocAction.STATUS_Drafted);
@ -1454,7 +1438,7 @@ public class SalesOrderTest extends AbstractTestCase {
line1.load(getTrxName());
assertEquals(2, line1.getQtyReserved().intValue());
MInOut shipment = new MInOut(order, 120, order.getDateOrdered());
MInOut shipment = new MInOut(order, DictionaryIDs.C_DocType.MM_SHIPMENT.id, order.getDateOrdered());
shipment.setDocStatus(DocAction.STATUS_Drafted);
shipment.setDocAction(DocAction.ACTION_Prepare);
shipment.saveEx();

View File

@ -49,6 +49,7 @@ import org.compiere.wf.MWFNodeNext;
import org.compiere.wf.MWFProcess;
import org.compiere.wf.MWorkflow;
import org.idempiere.test.AbstractTestCase;
import org.idempiere.test.DictionaryIDs;
import org.junit.jupiter.api.Test;
/**
@ -59,17 +60,11 @@ public class WFMaterialReceiptTest extends AbstractTestCase {
public WFMaterialReceiptTest() {
}
private static final int BP_PATIO = 121;
private static final int LOCATION_FROM_PATIO = 115;
private static final int WAREHOUSE_HQ = 103;
private static final int DOCTYPE_RECEIPT = 122;
private static final int PRODUCT_SEEDER = 143;
private static final int WF_PROCESS_SHIPMENT = 117;
private static final int WF_PROCESS_SHIPMENT_NODE_COMPLETE = 190;
private static final int PROCESS_SYNC_DOC_TRL = 321;
private static final int COLUMN_M_INOUT_ISSOTRX = 3790;
private static final int TABLE_M_INOUT = 319;
private static final int LOCATOR_HQ = 101;
/**
* https://idempiere.atlassian.net/browse/IDEMPIERE-4186
@ -152,10 +147,10 @@ public class WFMaterialReceiptTest extends AbstractTestCase {
CacheMgt.get().reset();
MInOut mr = new MInOut(ctx, 0, trxName);
mr.setBPartner(MBPartner.get(ctx, BP_PATIO));
mr.setBPartner(MBPartner.get(ctx, DictionaryIDs.C_BPartner.PATIO.id));
mr.setC_BPartner_Location_ID (LOCATION_FROM_PATIO);
mr.setM_Warehouse_ID(WAREHOUSE_HQ);
mr.setC_DocType_ID(DOCTYPE_RECEIPT);
mr.setM_Warehouse_ID(DictionaryIDs.M_Warehouse.HQ.id);
mr.setC_DocType_ID(DictionaryIDs.C_DocType.MM_RECEIPT.id);
mr.setIsSOTrx(false);
mr.setMovementType(MInOut.MOVEMENTTYPE_VendorReceipts);
mr.setDocStatus(DocAction.STATUS_Drafted);
@ -166,9 +161,9 @@ public class WFMaterialReceiptTest extends AbstractTestCase {
MInOutLine line1 = new MInOutLine(mr);
line1.setLine(10);
line1.setProduct(MProduct.get(ctx, PRODUCT_SEEDER));
line1.setProduct(MProduct.get(ctx, DictionaryIDs.M_Product.SEEDER.id));
line1.setQty(new BigDecimal("1"));
line1.setM_Locator_ID(LOCATOR_HQ);
line1.setM_Locator_ID(DictionaryIDs.M_Locator.HQ.id);
line1.saveEx();
ProcessInfo info = MWorkflow.runDocumentActionWorkflow(mr, DocAction.ACTION_Complete);
@ -177,7 +172,7 @@ public class WFMaterialReceiptTest extends AbstractTestCase {
assertEquals(DocAction.STATUS_Completed, mr.getDocStatus());
MWFProcess proc = new Query(ctx, MWFProcess.Table_Name, "AD_Table_ID=? AND Record_ID=?", trxName)
.setParameters(TABLE_M_INOUT, mr.getM_InOut_ID())
.setParameters(MInOut.Table_ID, mr.getM_InOut_ID())
.firstOnly();
MWFActivity[] acts = proc.getActivities(true, false, trxName);