From 6ff5fed0ec3b0f8bb4ca225b1e060142c91eb40e Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Mon, 28 Sep 2020 14:50:58 +0200 Subject: [PATCH] IDEMPIERE-4474 Automatic calculation of freight charges (#277) * IDEMPIERE-4474 Automatic calculation of freight charges * IDEMPIERE-4474 Keep the getShippingProcessor private - avoid NPE in all getters * IDEMPIERE-4474 Improve error messages and error management --- .../oracle/202009251357_IDEMPIERE-4474.sql | 203 ++++++++++++++++++ .../202009251357_IDEMPIERE-4474.sql | 200 +++++++++++++++++ .../src/org/adempiere/base/Core.java | 2 +- .../model/MFreightShipmentProcessor.java | 143 ++++++++++++ .../org/adempiere/model/MShipperFacade.java | 30 +-- .../process/OnlineShipmentProcess.java | 4 +- .../process/SalesOrderRateInquiryProcess.java | 4 +- .../src/org/compiere/model/MFreight.java | 101 +++++++++ .../compiere/model/MShippingTransaction.java | 9 +- 9 files changed, 673 insertions(+), 23 deletions(-) create mode 100644 migration/i7.1/oracle/202009251357_IDEMPIERE-4474.sql create mode 100644 migration/i7.1/postgresql/202009251357_IDEMPIERE-4474.sql create mode 100644 org.adempiere.base/src/org/adempiere/model/MFreightShipmentProcessor.java create mode 100644 org.adempiere.base/src/org/compiere/model/MFreight.java diff --git a/migration/i7.1/oracle/202009251357_IDEMPIERE-4474.sql b/migration/i7.1/oracle/202009251357_IDEMPIERE-4474.sql new file mode 100644 index 0000000000..6324b9ca2b --- /dev/null +++ b/migration/i7.1/oracle/202009251357_IDEMPIERE-4474.sql @@ -0,0 +1,203 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- IDEMPIERE-4474 Automatic calculation of freight charges +-- Sep 25, 2020, 1:14:14 PM CEST +INSERT INTO AD_Element (AD_Element_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,ColumnName,Name,Description,Help,PrintName,EntityType,AD_Element_UU) VALUES (203440,0,0,'Y',TO_DATE('2020-09-25 13:13:58','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-09-25 13:13:58','YYYY-MM-DD HH24:MI:SS'),100,'MaxWeight','Max Weight',NULL,NULL,'Max Weight','D','cb6c78ea-eff8-431e-a693-212a8ae1bec9') +; + +-- Sep 25, 2020, 1:15:20 PM CEST +INSERT INTO AD_Column (AD_Column_ID,Version,Name,AD_Table_ID,ColumnName,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Element_ID,IsUpdateable,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,SeqNoSelection,IsToolbarButton,IsSecure,FKConstraintType,IsHtml) VALUES (214319,0,'Max Weight',596,'MaxWeight',22,'N','N','N','N','N',0,'N',12,0,0,'Y',TO_DATE('2020-09-25 13:15:19','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-09-25 13:15:19','YYYY-MM-DD HH24:MI:SS'),100,203440,'Y','N','D','N','N','N','Y','f2efc63c-3424-4872-9f0f-1ca4166b3e5e','Y',0,'N','N','N','N') +; + +-- Sep 25, 2020, 1:15:52 PM CEST +ALTER TABLE M_Freight ADD MaxWeight NUMBER DEFAULT NULL +; + +-- Sep 25, 2020, 1:16:33 PM CEST +INSERT INTO AD_Element (AD_Element_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,ColumnName,Name,Description,Help,PrintName,EntityType,AD_Element_UU) VALUES (203441,0,0,'Y',TO_DATE('2020-09-25 13:16:22','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-09-25 13:16:22','YYYY-MM-DD HH24:MI:SS'),100,'MaxDimension','Max Dimension',NULL,NULL,'Max Dimension','D','4916f1d7-5192-4007-a3e6-8987923a9806') +; + +-- Sep 25, 2020, 1:16:40 PM CEST +INSERT INTO AD_Column (AD_Column_ID,Version,Name,AD_Table_ID,ColumnName,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Element_ID,IsUpdateable,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,SeqNoSelection,IsToolbarButton,IsSecure,FKConstraintType,IsHtml) VALUES (214320,0,'Max Dimension',596,'MaxDimension',22,'N','N','N','N','N',0,'N',12,0,0,'Y',TO_DATE('2020-09-25 13:16:39','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-09-25 13:16:39','YYYY-MM-DD HH24:MI:SS'),100,203441,'Y','N','D','N','N','N','Y','c3e76f59-2117-413d-ac63-200280af944c','Y',0,'N','N','N','N') +; + +-- Sep 25, 2020, 1:16:44 PM CEST +ALTER TABLE M_Freight ADD MaxDimension NUMBER DEFAULT NULL +; + +-- Sep 25, 2020, 1:17:02 PM CEST +INSERT INTO AD_Field (AD_Field_ID,Name,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,ColumnSpan) VALUES (206511,'Max Weight',513,214319,'Y',22,140,'N','N','N','N',0,0,'Y',TO_DATE('2020-09-25 13:17:01','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-09-25 13:17:01','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','fd2b8a36-61a5-4588-842e-bfbd4b0e6fb5','Y',140,2) +; + +-- Sep 25, 2020, 1:17:02 PM CEST +INSERT INTO AD_Field (AD_Field_ID,Name,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,ColumnSpan) VALUES (206512,'Max Dimension',513,214320,'Y',22,150,'N','N','N','N',0,0,'Y',TO_DATE('2020-09-25 13:17:02','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-09-25 13:17:02','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','065672c7-55d8-4f92-a706-cd42a15033f6','Y',150,2) +; + +-- Sep 25, 2020, 1:17:44 PM CEST +UPDATE AD_Field SET SeqNo=10, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2020-09-25 13:17:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=7052 +; + +-- Sep 25, 2020, 1:17:44 PM CEST +UPDATE AD_Field SET SeqNo=20, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2020-09-25 13:17:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=7063 +; + +-- Sep 25, 2020, 1:17:44 PM CEST +UPDATE AD_Field SET SeqNo=30, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2020-09-25 13:17:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=7055 +; + +-- Sep 25, 2020, 1:17:44 PM CEST +UPDATE AD_Field SET SeqNo=40, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2020-09-25 13:17:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=7058 +; + +-- Sep 25, 2020, 1:17:44 PM CEST +UPDATE AD_Field SET SeqNo=50, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2020-09-25 13:17:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=7053 +; + +-- Sep 25, 2020, 1:17:44 PM CEST +UPDATE AD_Field SET SeqNo=60, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2020-09-25 13:17:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=7059 +; + +-- Sep 25, 2020, 1:17:44 PM CEST +UPDATE AD_Field SET IsDisplayed='Y', SeqNo=70, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=1, IsToolbarButton=NULL,Updated=TO_DATE('2020-09-25 13:17:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206511 +; + +-- Sep 25, 2020, 1:17:44 PM CEST +UPDATE AD_Field SET IsDisplayed='Y', SeqNo=80, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=4, IsToolbarButton=NULL,Updated=TO_DATE('2020-09-25 13:17:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206512 +; + +-- Sep 25, 2020, 1:17:44 PM CEST +UPDATE AD_Field SET IsDisplayed='Y', SeqNo=90, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=1, IsToolbarButton=NULL,Updated=TO_DATE('2020-09-25 13:17:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=7061 +; + +-- Sep 25, 2020, 1:17:44 PM CEST +UPDATE AD_Field SET IsDisplayed='Y', SeqNo=100, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=4, IsToolbarButton=NULL,Updated=TO_DATE('2020-09-25 13:17:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=7062 +; + +-- Sep 25, 2020, 1:17:44 PM CEST +UPDATE AD_Field SET IsDisplayed='Y', SeqNo=110, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=1, IsToolbarButton=NULL,Updated=TO_DATE('2020-09-25 13:17:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=7054 +; + +-- Sep 25, 2020, 1:17:44 PM CEST +UPDATE AD_Field SET IsDisplayed='Y', SeqNo=120, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=4, IsToolbarButton=NULL,Updated=TO_DATE('2020-09-25 13:17:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=7060 +; + +-- Sep 25, 2020, 1:17:44 PM CEST +UPDATE AD_Field SET SeqNo=130, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2020-09-25 13:17:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=7056 +; + +-- Sep 25, 2020, 1:17:44 PM CEST +UPDATE AD_Field SET SeqNo=140, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2020-09-25 13:17:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=7057 +; + +-- Sep 25, 2020, 1:17:44 PM CEST +UPDATE AD_Field SET SeqNo=0, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2020-09-25 13:17:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=7051 +; + +-- Sep 25, 2020, 1:17:44 PM CEST +UPDATE AD_Field SET SeqNo=0, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2020-09-25 13:17:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=204893 +; + +-- Sep 25, 2020, 1:20:28 PM CEST +INSERT INTO C_UOM (C_UOM_ID,Name,StdPrecision,CostingPrecision,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,UOMSymbol,X12DE355,IsDefault,UOMType,C_UOM_UU) VALUES (200001,'Centimeter',2,0,11,0,'Y',TO_DATE('2020-09-25 13:20:28','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-09-25 13:20:28','YYYY-MM-DD HH24:MI:SS'),100,'cm','CM','N','LE','f058dfd3-89f5-46e8-b2b8-11df0505dffa') +; + +-- Sep 25, 2020, 1:20:41 PM CEST +UPDATE C_UOM SET UOMType='WE',Updated=TO_DATE('2020-09-25 13:20:41','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE C_UOM_ID=50001 +; + +-- Sep 25, 2020, 1:21:15 PM CEST +UPDATE C_UOM SET UOMType='WE',Updated=TO_DATE('2020-09-25 13:21:15','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE C_UOM_ID=50002 +; + +-- Sep 25, 2020, 1:21:22 PM CEST +UPDATE C_UOM SET UOMType='VL',Updated=TO_DATE('2020-09-25 13:21:22','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE C_UOM_ID=50000 +; + +-- Sep 25, 2020, 1:21:26 PM CEST +UPDATE C_UOM SET UOMType='VL',Updated=TO_DATE('2020-09-25 13:21:26','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE C_UOM_ID=50003 +; + +-- Sep 25, 2020, 1:21:59 PM CEST +UPDATE C_UOM SET UOMType='OT',Updated=TO_DATE('2020-09-25 13:21:59','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE C_UOM_ID=109 +; + +-- Sep 25, 2020, 1:23:53 PM CEST +INSERT INTO C_Charge (C_Charge_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,Name,ChargeAmt,IsSameTax,C_TaxCategory_ID,IsSameCurrency,IsTaxIncluded,C_Charge_UU) VALUES (200000,11,0,'Y',TO_DATE('2020-09-25 13:23:53','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-09-25 13:23:53','YYYY-MM-DD HH24:MI:SS'),100,'Freight Charges',0,'N',107,'N','N','82f26cd9-a60a-49c9-aeeb-3a4d33648d5d') +; + +-- Sep 25, 2020, 1:23:53 PM CEST +INSERT INTO C_Charge_Acct (C_Charge_ID, C_AcctSchema_ID, AD_Client_ID,AD_Org_ID,IsActive, Created,CreatedBy,Updated,UpdatedBy ,Ch_Expense_Acct,C_Charge_Acct_UU) SELECT 200000, p.C_AcctSchema_ID, p.AD_Client_ID,0,'Y', SysDate,100,SysDate,100,p.Ch_Expense_Acct,generate_uuid() FROM C_AcctSchema_Default p WHERE p.AD_Client_ID=11 AND NOT EXISTS (SELECT * FROM C_Charge_Acct e WHERE e.C_AcctSchema_ID=p.C_AcctSchema_ID AND e.C_Charge_ID=200000) +; + +-- Sep 25, 2020, 1:24:44 PM CEST +INSERT INTO C_ValidCombination (C_ValidCombination_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,C_AcctSchema_ID,Account_ID,Combination,IsFullyQualified,Description,C_ValidCombination_UU) VALUES (200017,11,0,'Y',TO_DATE('2020-09-25 13:24:44','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-09-25 13:24:44','YYYY-MM-DD HH24:MI:SS'),100,101,434,'*-54000-_-_-_-_','Y','*-Freight in-_-_-_-_','6302914b-7148-4bf7-b41f-efbd07698430') +; + +-- Sep 25, 2020, 1:24:47 PM CEST +UPDATE C_Charge_Acct SET Ch_Expense_Acct=200017,Updated=TO_DATE('2020-09-25 13:24:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE C_Charge_ID=200000 AND C_AcctSchema_ID=101 +; + +-- Sep 25, 2020, 1:25:07 PM CEST +UPDATE AD_ClientInfo SET C_UOM_Weight_ID=50001, C_UOM_Length_ID=200001, M_ProductFreight_ID=NULL, C_ChargeFreight_ID=200000,Updated=TO_DATE('2020-09-25 13:25:07','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Client_ID=11 +; + +-- Sep 25, 2020, 1:27:00 PM CEST +UPDATE M_Product SET Weight=10.00, ShelfWidth=15, ShelfHeight=50, ShelfDepth=15,Updated=TO_DATE('2020-09-25 13:27:00','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE M_Product_ID=128 +; + +-- Sep 25, 2020, 1:27:45 PM CEST +UPDATE M_Product SET Weight=1, ShelfWidth=30, ShelfHeight=5, ShelfDepth=20,Updated=TO_DATE('2020-09-25 13:27:45','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE M_Product_ID=50008 +; + +-- Sep 25, 2020, 1:29:40 PM CEST +UPDATE M_Product SET Weight=1, ShelfWidth=30, ShelfHeight=20, ShelfDepth=100,Updated=TO_DATE('2020-09-25 13:29:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE M_Product_ID=138 +; + +-- Sep 25, 2020, 1:30:34 PM CEST +UPDATE C_AcctSchema SET C_Period_ID=200104,Updated=TO_DATE('2020-09-25 13:30:34','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE C_AcctSchema_ID=101 +; + +-- Sep 25, 2020, 1:47:01 PM CEST +UPDATE M_Freight SET C_Country_ID=100, To_Country_ID=100, MaxWeight=19.958, MaxDimension=419.1,Updated=TO_DATE('2020-09-25 13:47:01','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE M_Freight_ID=100 +; + +-- Sep 25, 2020, 1:48:04 PM CEST +INSERT INTO M_Freight (M_Freight_ID,AD_Client_ID,M_FreightCategory_ID,CreatedBy,UpdatedBy,Created,M_Shipper_ID,C_Currency_ID,Updated,FreightAmt,IsActive,ValidFrom,C_Country_ID,To_Country_ID,AD_Org_ID,M_Freight_UU,MaxWeight,MaxDimension) VALUES (200000,11,100,100,100,TO_DATE('2020-09-25 13:48:03','YYYY-MM-DD HH24:MI:SS'),100,100,TO_DATE('2020-09-25 13:48:03','YYYY-MM-DD HH24:MI:SS'),14.21,'Y',TO_DATE('2003-06-01','YYYY-MM-DD'),100,100,11,'82a6f1c5-5ea8-4ad2-9413-4e0cf02f5f32',9.979,419.1) +; + +-- Sep 25, 2020, 1:48:49 PM CEST +INSERT INTO M_Freight (M_Freight_ID,AD_Client_ID,M_FreightCategory_ID,CreatedBy,UpdatedBy,Created,M_Shipper_ID,C_Currency_ID,Updated,FreightAmt,IsActive,ValidFrom,C_Country_ID,To_Country_ID,AD_Org_ID,M_Freight_UU,MaxWeight,MaxDimension) VALUES (200001,11,100,100,100,TO_DATE('2020-09-25 13:48:48','YYYY-MM-DD HH24:MI:SS'),100,100,TO_DATE('2020-09-25 13:48:48','YYYY-MM-DD HH24:MI:SS'),23.90,'Y',TO_DATE('2003-06-01','YYYY-MM-DD'),100,100,11,'ba69860f-4f9e-4040-8fe1-dfdbc3e2c37f',29.937,419.1) +; + +-- Sep 25, 2020, 1:53:32 PM CEST +INSERT INTO M_ShippingProcessorCfg (AD_Client_ID,AD_Org_ID,Created,CreatedBy,Description,HostAddress,HostPort,IsActive,M_ShippingProcessorCfg_ID,M_ShippingProcessorCfg_UU,Name,ProxyPort,ShippingProcessorClass,Updated,UpdatedBy) VALUES (11,0,TO_DATE('2020-09-25 13:53:31','YYYY-MM-DD HH24:MI:SS'),100,'Based on data from M_Freight table','0.0.0.0',0,'Y',200000,'c086fbe0-773b-481d-9171-8eb95e1c78d5','Freight Table Shipment Processor',0,'org.adempiere.model.MFreightShipmentProcessor',TO_DATE('2020-09-25 13:53:31','YYYY-MM-DD HH24:MI:SS'),100) +; + +-- Sep 25, 2020, 1:54:14 PM CEST +INSERT INTO M_ShipperCfg (AD_Client_ID,AD_Org_ID,Created,CreatedBy,IsActive,IsInternational,IsOnline,IsResidential,IsSaturdayDelivery,M_ShipperCfg_ID,M_ShipperCfg_UU,Name,Updated,UpdatedBy,M_ShippingProcessorCfg_ID,CopyFrom) VALUES (11,0,TO_DATE('2020-09-25 13:54:14','YYYY-MM-DD HH24:MI:SS'),100,'Y','N','N','N','N',200000,'9c303cda-94c4-446d-8328-7806818817c5','Freight Table Shipment Processor',TO_DATE('2020-09-25 13:54:14','YYYY-MM-DD HH24:MI:SS'),100,200000,'N') +; + +-- Sep 25, 2020, 1:54:36 PM CEST +UPDATE M_Shipper SET M_ShipperCfg_ID=200000, Updated=TO_DATE('2020-09-25 13:54:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE M_Shipper_ID=100 +; + +-- Sep 25, 2020, 1:56:24 PM CEST +INSERT INTO M_ShippingProcessor (AD_Client_ID,AD_Org_ID,Created,CreatedBy,IsActive,M_ShippingProcessor_ID,M_ShippingProcessor_UU,Updated,UpdatedBy,ConnectionPassword,UserID,M_ShippingProcessorCfg_ID,Name) VALUES (11,0,TO_DATE('2020-09-25 13:56:23','YYYY-MM-DD HH24:MI:SS'),100,'Y',200000,'99a1cb04-2aa7-4a89-b051-2bbdc0f5943f',TO_DATE('2020-09-25 13:56:23','YYYY-MM-DD HH24:MI:SS'),100,'n/r','n/r',200000,'Freight Table Shipment Processor') +; + +-- Sep 25, 2020, 1:56:33 PM CEST +UPDATE M_Shipper SET M_ShippingProcessor_ID=200000,Updated=TO_DATE('2020-09-25 13:56:33','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE M_Shipper_ID=100 +; + +-- Sep 25, 2020, 9:06:35 PM CEST +INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('E','COULD NOT FIND FREIGHT DEFINED FOR: Shipper {0} - Freight Category {1} - Date {2,date,short} - Weight {3,number,#,##0.00} - Dimension {4,number,#,##0.00} - Origin Country {5} - Destination Country {6} - Origin Region {7} - Destination Region {8}',0,0,'Y',TO_DATE('2020-09-25 21:06:34','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-09-25 21:06:34','YYYY-MM-DD HH24:MI:SS'),100,200639,'FreightNotFound','D','03990c13-c085-4d1b-bb6f-6ff0c69ef2bc') +; + +-- Sep 25, 2020, 9:06:55 PM CEST +INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('I','Found freight record [{9}] with price {10,number,#,##0.00} for: Shipper {0} - Freight Category {1} - Date {2,date,short} - Weight {3,number,#,##0.00} - Dimension {4,number,#,##0.00} - Origin Country {5} - Destination Country {6} - Origin Region {7} - Destination Region {8}',0,0,'Y',TO_DATE('2020-09-25 21:06:55','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-09-25 21:06:55','YYYY-MM-DD HH24:MI:SS'),100,200640,'FreightFound','D','4c399b7e-b1b8-49a3-892d-55e9469094f6') +; + +SELECT register_migration_script('202009251357_IDEMPIERE-4474.sql') FROM dual +; + diff --git a/migration/i7.1/postgresql/202009251357_IDEMPIERE-4474.sql b/migration/i7.1/postgresql/202009251357_IDEMPIERE-4474.sql new file mode 100644 index 0000000000..641c56da91 --- /dev/null +++ b/migration/i7.1/postgresql/202009251357_IDEMPIERE-4474.sql @@ -0,0 +1,200 @@ +-- IDEMPIERE-4474 Automatic calculation of freight charges +-- Sep 25, 2020, 1:14:14 PM CEST +INSERT INTO AD_Element (AD_Element_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,ColumnName,Name,Description,Help,PrintName,EntityType,AD_Element_UU) VALUES (203440,0,0,'Y',TO_TIMESTAMP('2020-09-25 13:13:58','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-09-25 13:13:58','YYYY-MM-DD HH24:MI:SS'),100,'MaxWeight','Max Weight',NULL,NULL,'Max Weight','D','cb6c78ea-eff8-431e-a693-212a8ae1bec9') +; + +-- Sep 25, 2020, 1:15:20 PM CEST +INSERT INTO AD_Column (AD_Column_ID,Version,Name,AD_Table_ID,ColumnName,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Element_ID,IsUpdateable,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,SeqNoSelection,IsToolbarButton,IsSecure,FKConstraintType,IsHtml) VALUES (214319,0,'Max Weight',596,'MaxWeight',22,'N','N','N','N','N',0,'N',12,0,0,'Y',TO_TIMESTAMP('2020-09-25 13:15:19','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-09-25 13:15:19','YYYY-MM-DD HH24:MI:SS'),100,203440,'Y','N','D','N','N','N','Y','f2efc63c-3424-4872-9f0f-1ca4166b3e5e','Y',0,'N','N','N','N') +; + +-- Sep 25, 2020, 1:15:52 PM CEST +ALTER TABLE M_Freight ADD COLUMN MaxWeight NUMERIC DEFAULT NULL +; + +-- Sep 25, 2020, 1:16:33 PM CEST +INSERT INTO AD_Element (AD_Element_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,ColumnName,Name,Description,Help,PrintName,EntityType,AD_Element_UU) VALUES (203441,0,0,'Y',TO_TIMESTAMP('2020-09-25 13:16:22','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-09-25 13:16:22','YYYY-MM-DD HH24:MI:SS'),100,'MaxDimension','Max Dimension',NULL,NULL,'Max Dimension','D','4916f1d7-5192-4007-a3e6-8987923a9806') +; + +-- Sep 25, 2020, 1:16:40 PM CEST +INSERT INTO AD_Column (AD_Column_ID,Version,Name,AD_Table_ID,ColumnName,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Element_ID,IsUpdateable,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,SeqNoSelection,IsToolbarButton,IsSecure,FKConstraintType,IsHtml) VALUES (214320,0,'Max Dimension',596,'MaxDimension',22,'N','N','N','N','N',0,'N',12,0,0,'Y',TO_TIMESTAMP('2020-09-25 13:16:39','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-09-25 13:16:39','YYYY-MM-DD HH24:MI:SS'),100,203441,'Y','N','D','N','N','N','Y','c3e76f59-2117-413d-ac63-200280af944c','Y',0,'N','N','N','N') +; + +-- Sep 25, 2020, 1:16:44 PM CEST +ALTER TABLE M_Freight ADD COLUMN MaxDimension NUMERIC DEFAULT NULL +; + +-- Sep 25, 2020, 1:17:02 PM CEST +INSERT INTO AD_Field (AD_Field_ID,Name,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,ColumnSpan) VALUES (206511,'Max Weight',513,214319,'Y',22,140,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2020-09-25 13:17:01','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-09-25 13:17:01','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','fd2b8a36-61a5-4588-842e-bfbd4b0e6fb5','Y',140,2) +; + +-- Sep 25, 2020, 1:17:02 PM CEST +INSERT INTO AD_Field (AD_Field_ID,Name,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,ColumnSpan) VALUES (206512,'Max Dimension',513,214320,'Y',22,150,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2020-09-25 13:17:02','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-09-25 13:17:02','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','065672c7-55d8-4f92-a706-cd42a15033f6','Y',150,2) +; + +-- Sep 25, 2020, 1:17:44 PM CEST +UPDATE AD_Field SET SeqNo=10, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-09-25 13:17:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=7052 +; + +-- Sep 25, 2020, 1:17:44 PM CEST +UPDATE AD_Field SET SeqNo=20, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-09-25 13:17:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=7063 +; + +-- Sep 25, 2020, 1:17:44 PM CEST +UPDATE AD_Field SET SeqNo=30, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-09-25 13:17:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=7055 +; + +-- Sep 25, 2020, 1:17:44 PM CEST +UPDATE AD_Field SET SeqNo=40, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-09-25 13:17:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=7058 +; + +-- Sep 25, 2020, 1:17:44 PM CEST +UPDATE AD_Field SET SeqNo=50, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-09-25 13:17:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=7053 +; + +-- Sep 25, 2020, 1:17:44 PM CEST +UPDATE AD_Field SET SeqNo=60, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-09-25 13:17:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=7059 +; + +-- Sep 25, 2020, 1:17:44 PM CEST +UPDATE AD_Field SET IsDisplayed='Y', SeqNo=70, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=1, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-09-25 13:17:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206511 +; + +-- Sep 25, 2020, 1:17:44 PM CEST +UPDATE AD_Field SET IsDisplayed='Y', SeqNo=80, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=4, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-09-25 13:17:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206512 +; + +-- Sep 25, 2020, 1:17:44 PM CEST +UPDATE AD_Field SET IsDisplayed='Y', SeqNo=90, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=1, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-09-25 13:17:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=7061 +; + +-- Sep 25, 2020, 1:17:44 PM CEST +UPDATE AD_Field SET IsDisplayed='Y', SeqNo=100, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=4, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-09-25 13:17:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=7062 +; + +-- Sep 25, 2020, 1:17:44 PM CEST +UPDATE AD_Field SET IsDisplayed='Y', SeqNo=110, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=1, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-09-25 13:17:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=7054 +; + +-- Sep 25, 2020, 1:17:44 PM CEST +UPDATE AD_Field SET IsDisplayed='Y', SeqNo=120, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=4, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-09-25 13:17:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=7060 +; + +-- Sep 25, 2020, 1:17:44 PM CEST +UPDATE AD_Field SET SeqNo=130, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-09-25 13:17:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=7056 +; + +-- Sep 25, 2020, 1:17:44 PM CEST +UPDATE AD_Field SET SeqNo=140, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-09-25 13:17:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=7057 +; + +-- Sep 25, 2020, 1:17:44 PM CEST +UPDATE AD_Field SET SeqNo=0, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-09-25 13:17:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=7051 +; + +-- Sep 25, 2020, 1:17:44 PM CEST +UPDATE AD_Field SET SeqNo=0, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-09-25 13:17:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=204893 +; + +-- Sep 25, 2020, 1:20:28 PM CEST +INSERT INTO C_UOM (C_UOM_ID,Name,StdPrecision,CostingPrecision,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,UOMSymbol,X12DE355,IsDefault,UOMType,C_UOM_UU) VALUES (200001,'Centimeter',2,0,11,0,'Y',TO_TIMESTAMP('2020-09-25 13:20:28','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-09-25 13:20:28','YYYY-MM-DD HH24:MI:SS'),100,'cm','CM','N','LE','f058dfd3-89f5-46e8-b2b8-11df0505dffa') +; + +-- Sep 25, 2020, 1:20:41 PM CEST +UPDATE C_UOM SET UOMType='WE',Updated=TO_TIMESTAMP('2020-09-25 13:20:41','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE C_UOM_ID=50001 +; + +-- Sep 25, 2020, 1:21:15 PM CEST +UPDATE C_UOM SET UOMType='WE',Updated=TO_TIMESTAMP('2020-09-25 13:21:15','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE C_UOM_ID=50002 +; + +-- Sep 25, 2020, 1:21:22 PM CEST +UPDATE C_UOM SET UOMType='VL',Updated=TO_TIMESTAMP('2020-09-25 13:21:22','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE C_UOM_ID=50000 +; + +-- Sep 25, 2020, 1:21:26 PM CEST +UPDATE C_UOM SET UOMType='VL',Updated=TO_TIMESTAMP('2020-09-25 13:21:26','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE C_UOM_ID=50003 +; + +-- Sep 25, 2020, 1:21:59 PM CEST +UPDATE C_UOM SET UOMType='OT',Updated=TO_TIMESTAMP('2020-09-25 13:21:59','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE C_UOM_ID=109 +; + +-- Sep 25, 2020, 1:23:53 PM CEST +INSERT INTO C_Charge (C_Charge_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,Name,ChargeAmt,IsSameTax,C_TaxCategory_ID,IsSameCurrency,IsTaxIncluded,C_Charge_UU) VALUES (200000,11,0,'Y',TO_TIMESTAMP('2020-09-25 13:23:53','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-09-25 13:23:53','YYYY-MM-DD HH24:MI:SS'),100,'Freight Charges',0,'N',107,'N','N','82f26cd9-a60a-49c9-aeeb-3a4d33648d5d') +; + +-- Sep 25, 2020, 1:23:53 PM CEST +INSERT INTO C_Charge_Acct (C_Charge_ID, C_AcctSchema_ID, AD_Client_ID,AD_Org_ID,IsActive, Created,CreatedBy,Updated,UpdatedBy ,Ch_Expense_Acct,C_Charge_Acct_UU) SELECT 200000, p.C_AcctSchema_ID, p.AD_Client_ID,0,'Y', statement_timestamp(),100,statement_timestamp(),100,p.Ch_Expense_Acct,generate_uuid() FROM C_AcctSchema_Default p WHERE p.AD_Client_ID=11 AND NOT EXISTS (SELECT * FROM C_Charge_Acct e WHERE e.C_AcctSchema_ID=p.C_AcctSchema_ID AND e.C_Charge_ID=200000) +; + +-- Sep 25, 2020, 1:24:44 PM CEST +INSERT INTO C_ValidCombination (C_ValidCombination_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,C_AcctSchema_ID,Account_ID,Combination,IsFullyQualified,Description,C_ValidCombination_UU) VALUES (200017,11,0,'Y',TO_TIMESTAMP('2020-09-25 13:24:44','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-09-25 13:24:44','YYYY-MM-DD HH24:MI:SS'),100,101,434,'*-54000-_-_-_-_','Y','*-Freight in-_-_-_-_','6302914b-7148-4bf7-b41f-efbd07698430') +; + +-- Sep 25, 2020, 1:24:47 PM CEST +UPDATE C_Charge_Acct SET Ch_Expense_Acct=200017,Updated=TO_TIMESTAMP('2020-09-25 13:24:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE C_Charge_ID=200000 AND C_AcctSchema_ID=101 +; + +-- Sep 25, 2020, 1:25:07 PM CEST +UPDATE AD_ClientInfo SET C_UOM_Weight_ID=50001, C_UOM_Length_ID=200001, M_ProductFreight_ID=NULL, C_ChargeFreight_ID=200000,Updated=TO_TIMESTAMP('2020-09-25 13:25:07','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Client_ID=11 +; + +-- Sep 25, 2020, 1:27:00 PM CEST +UPDATE M_Product SET Weight=10.00, ShelfWidth=15, ShelfHeight=50, ShelfDepth=15,Updated=TO_TIMESTAMP('2020-09-25 13:27:00','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE M_Product_ID=128 +; + +-- Sep 25, 2020, 1:27:45 PM CEST +UPDATE M_Product SET Weight=1, ShelfWidth=30, ShelfHeight=5, ShelfDepth=20,Updated=TO_TIMESTAMP('2020-09-25 13:27:45','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE M_Product_ID=50008 +; + +-- Sep 25, 2020, 1:29:40 PM CEST +UPDATE M_Product SET Weight=1, ShelfWidth=30, ShelfHeight=20, ShelfDepth=100,Updated=TO_TIMESTAMP('2020-09-25 13:29:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE M_Product_ID=138 +; + +-- Sep 25, 2020, 1:30:34 PM CEST +UPDATE C_AcctSchema SET C_Period_ID=200104,Updated=TO_TIMESTAMP('2020-09-25 13:30:34','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE C_AcctSchema_ID=101 +; + +-- Sep 25, 2020, 1:47:01 PM CEST +UPDATE M_Freight SET C_Country_ID=100, To_Country_ID=100, MaxWeight=19.958, MaxDimension=419.1,Updated=TO_TIMESTAMP('2020-09-25 13:47:01','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE M_Freight_ID=100 +; + +-- Sep 25, 2020, 1:48:04 PM CEST +INSERT INTO M_Freight (M_Freight_ID,AD_Client_ID,M_FreightCategory_ID,CreatedBy,UpdatedBy,Created,M_Shipper_ID,C_Currency_ID,Updated,FreightAmt,IsActive,ValidFrom,C_Country_ID,To_Country_ID,AD_Org_ID,M_Freight_UU,MaxWeight,MaxDimension) VALUES (200000,11,100,100,100,TO_TIMESTAMP('2020-09-25 13:48:03','YYYY-MM-DD HH24:MI:SS'),100,100,TO_TIMESTAMP('2020-09-25 13:48:03','YYYY-MM-DD HH24:MI:SS'),14.21,'Y',TO_TIMESTAMP('2003-06-01','YYYY-MM-DD'),100,100,11,'82a6f1c5-5ea8-4ad2-9413-4e0cf02f5f32',9.979,419.1) +; + +-- Sep 25, 2020, 1:48:49 PM CEST +INSERT INTO M_Freight (M_Freight_ID,AD_Client_ID,M_FreightCategory_ID,CreatedBy,UpdatedBy,Created,M_Shipper_ID,C_Currency_ID,Updated,FreightAmt,IsActive,ValidFrom,C_Country_ID,To_Country_ID,AD_Org_ID,M_Freight_UU,MaxWeight,MaxDimension) VALUES (200001,11,100,100,100,TO_TIMESTAMP('2020-09-25 13:48:48','YYYY-MM-DD HH24:MI:SS'),100,100,TO_TIMESTAMP('2020-09-25 13:48:48','YYYY-MM-DD HH24:MI:SS'),23.90,'Y',TO_TIMESTAMP('2003-06-01','YYYY-MM-DD'),100,100,11,'ba69860f-4f9e-4040-8fe1-dfdbc3e2c37f',29.937,419.1) +; + +-- Sep 25, 2020, 1:53:32 PM CEST +INSERT INTO M_ShippingProcessorCfg (AD_Client_ID,AD_Org_ID,Created,CreatedBy,Description,HostAddress,HostPort,IsActive,M_ShippingProcessorCfg_ID,M_ShippingProcessorCfg_UU,Name,ProxyPort,ShippingProcessorClass,Updated,UpdatedBy) VALUES (11,0,TO_TIMESTAMP('2020-09-25 13:53:31','YYYY-MM-DD HH24:MI:SS'),100,'Based on data from M_Freight table','0.0.0.0',0,'Y',200000,'c086fbe0-773b-481d-9171-8eb95e1c78d5','Freight Table Shipment Processor',0,'org.adempiere.model.MFreightShipmentProcessor',TO_TIMESTAMP('2020-09-25 13:53:31','YYYY-MM-DD HH24:MI:SS'),100) +; + +-- Sep 25, 2020, 1:54:14 PM CEST +INSERT INTO M_ShipperCfg (AD_Client_ID,AD_Org_ID,Created,CreatedBy,IsActive,IsInternational,IsOnline,IsResidential,IsSaturdayDelivery,M_ShipperCfg_ID,M_ShipperCfg_UU,Name,Updated,UpdatedBy,M_ShippingProcessorCfg_ID,CopyFrom) VALUES (11,0,TO_TIMESTAMP('2020-09-25 13:54:14','YYYY-MM-DD HH24:MI:SS'),100,'Y','N','N','N','N',200000,'9c303cda-94c4-446d-8328-7806818817c5','Freight Table Shipment Processor',TO_TIMESTAMP('2020-09-25 13:54:14','YYYY-MM-DD HH24:MI:SS'),100,200000,'N') +; + +-- Sep 25, 2020, 1:54:36 PM CEST +UPDATE M_Shipper SET M_ShipperCfg_ID=200000, Updated=TO_TIMESTAMP('2020-09-25 13:54:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE M_Shipper_ID=100 +; + +-- Sep 25, 2020, 1:56:24 PM CEST +INSERT INTO M_ShippingProcessor (AD_Client_ID,AD_Org_ID,Created,CreatedBy,IsActive,M_ShippingProcessor_ID,M_ShippingProcessor_UU,Updated,UpdatedBy,ConnectionPassword,UserID,M_ShippingProcessorCfg_ID,Name) VALUES (11,0,TO_TIMESTAMP('2020-09-25 13:56:23','YYYY-MM-DD HH24:MI:SS'),100,'Y',200000,'99a1cb04-2aa7-4a89-b051-2bbdc0f5943f',TO_TIMESTAMP('2020-09-25 13:56:23','YYYY-MM-DD HH24:MI:SS'),100,'n/r','n/r',200000,'Freight Table Shipment Processor') +; + +-- Sep 25, 2020, 1:56:33 PM CEST +UPDATE M_Shipper SET M_ShippingProcessor_ID=200000,Updated=TO_TIMESTAMP('2020-09-25 13:56:33','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE M_Shipper_ID=100 +; + +-- Sep 25, 2020, 9:06:35 PM CEST +INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('E','COULD NOT FIND FREIGHT DEFINED FOR: Shipper {0} - Freight Category {1} - Date {2,date,short} - Weight {3,number,#,##0.00} - Dimension {4,number,#,##0.00} - Origin Country {5} - Destination Country {6} - Origin Region {7} - Destination Region {8}',0,0,'Y',TO_TIMESTAMP('2020-09-25 21:06:34','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-09-25 21:06:34','YYYY-MM-DD HH24:MI:SS'),100,200639,'FreightNotFound','D','03990c13-c085-4d1b-bb6f-6ff0c69ef2bc') +; + +-- Sep 25, 2020, 9:06:55 PM CEST +INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('I','Found freight record [{9}] with price {10,number,#,##0.00} for: Shipper {0} - Freight Category {1} - Date {2,date,short} - Weight {3,number,#,##0.00} - Dimension {4,number,#,##0.00} - Origin Country {5} - Destination Country {6} - Origin Region {7} - Destination Region {8}',0,0,'Y',TO_TIMESTAMP('2020-09-25 21:06:55','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-09-25 21:06:55','YYYY-MM-DD HH24:MI:SS'),100,200640,'FreightFound','D','4c399b7e-b1b8-49a3-892d-55e9469094f6') +; + +SELECT register_migration_script('202009251357_IDEMPIERE-4474.sql') FROM dual +; + diff --git a/org.adempiere.base/src/org/adempiere/base/Core.java b/org.adempiere.base/src/org/adempiere/base/Core.java index c9203939e8..1a01e5feda 100644 --- a/org.adempiere.base/src/org/adempiere/base/Core.java +++ b/org.adempiere.base/src/org/adempiere/base/Core.java @@ -319,7 +319,7 @@ public class Core { String className = sf.getShippingProcessorClass(); if (className == null || className.length() == 0) { - s_log.log(Level.SEVERE, "Shipment processor class not define for shipper " + sf); + s_log.log(Level.SEVERE, "Shipment processor or class not defined for shipper " + sf); return null; } diff --git a/org.adempiere.base/src/org/adempiere/model/MFreightShipmentProcessor.java b/org.adempiere.base/src/org/adempiere/model/MFreightShipmentProcessor.java new file mode 100644 index 0000000000..d430086ce2 --- /dev/null +++ b/org.adempiere.base/src/org/adempiere/model/MFreightShipmentProcessor.java @@ -0,0 +1,143 @@ +/*********************************************************************** + * This file is part of iDempiere ERP Open Source * + * http://www.idempiere.org * + * * + * Copyright (C) Contributors * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * + * MA 02110-1301, USA. * + * * + * Contributors: * + * - Carlos Ruiz * + **********************************************************************/ + +package org.adempiere.model; + +import java.math.BigDecimal; +import java.sql.Timestamp; +import java.util.Properties; + +import org.compiere.model.MBPartnerLocation; +import org.compiere.model.MConversionRate; +import org.compiere.model.MConversionRateUtil; +import org.compiere.model.MCountry; +import org.compiere.model.MFreight; +import org.compiere.model.MFreightCategory; +import org.compiere.model.MLocation; +import org.compiere.model.MOrder; +import org.compiere.model.MOrderLine; +import org.compiere.model.MProduct; +import org.compiere.model.MRegion; +import org.compiere.model.MShipper; +import org.compiere.model.MShippingTransaction; +import org.compiere.model.MWarehouse; +import org.compiere.util.AdempiereUserError; +import org.compiere.util.Env; +import org.compiere.util.Msg; + +public class MFreightShipmentProcessor implements IShipmentProcessor { + + @Override + public boolean rateInquiry(Properties ctx, MShippingTransaction st, boolean isPriviledgedRate, String trxName) { + // st.setShippingRespMessage("In case of error set the message here"); + MOrder order = new MOrder(ctx, st.getC_Order_ID(), trxName); + int freightCategoryId = order.getM_FreightCategory_ID(); + Timestamp dateOrder = order.getDateOrdered(); + BigDecimal weight = st.getWeight(); + BigDecimal maxProductDimension = Env.ZERO; + for (MOrderLine ol : order.getLines()) { + if (ol.getM_Product_ID() > 0) { + MProduct product = MProduct.get(ctx, ol.getM_Product_ID()); + // Product Dimension = ShelfHeight + ShelfDepth + ShelfWidth + BigDecimal productDimension = product.getShelfHeight() + .add(BigDecimal.valueOf(product.getShelfDepth())) + .add(BigDecimal.valueOf(product.getShelfWidth())); + if (productDimension.compareTo(maxProductDimension) > 0) { + maxProductDimension = productDimension; + } + } + } + MWarehouse w = MWarehouse.get(ctx, order.getM_Warehouse_ID()); + MLocation wl = MLocation.get(ctx, w.getC_Location_ID(), trxName); + int countryFrom = wl.getC_Country_ID(); + int regionFrom = wl.getC_Region_ID(); + MBPartnerLocation bpl = new MBPartnerLocation(ctx, order.getC_BPartner_Location_ID(), trxName); + MLocation bl = MLocation.get(ctx, bpl.getC_Location_ID(), trxName); + int countryTo = bl.getC_Country_ID(); + int regionTo = bl.getC_Region_ID(); + MFreight freight = MFreight.get(ctx, st.getM_Shipper_ID(), freightCategoryId, dateOrder, weight, maxProductDimension, + countryFrom, countryTo, regionFrom, regionTo, trxName); + if (freight == null) { + String errorMsg = getMsg(ctx, "FreightNotFound", st.getM_Shipper_ID(), freightCategoryId, dateOrder, weight, maxProductDimension, + countryFrom, countryTo, regionFrom, regionTo, 0, null, trxName); + st.setShippingRespMessage(errorMsg); + return false; + } else { + BigDecimal price = freight.getFreightAmt(); + if (order.getC_Currency_ID() != freight.getC_Currency_ID()) { + price = MConversionRate.convert(ctx, price, freight.getC_Currency_ID(), order.getC_Currency_ID(), dateOrder, + order.getC_ConversionType_ID(), order.getAD_Client_ID(), order.getAD_Org_ID()); + if (price == null) { + String errorMsg = MConversionRateUtil.getErrorMessage(ctx, "ErrorConvertingCurrencyToBaseCurrency", + freight.getC_Currency_ID(), order.getC_Currency_ID(), order.getC_ConversionType_ID(), dateOrder, trxName); + st.setShippingRespMessage(errorMsg); + return false; + } + } + String msg = getMsg(ctx, "FreightFound", st.getM_Shipper_ID(), freightCategoryId, dateOrder, weight, maxProductDimension, + countryFrom, countryTo, regionFrom, regionTo, freight.getM_Freight_ID(), freight.getFreightAmt(), trxName); + st.setShippingRespMessage(msg); + st.setPrice(price); + } + return true; + } + + private String getMsg(Properties ctx, String adMessage, int shipperId, int freightCategoryId, Timestamp dateOrder, + BigDecimal weight, BigDecimal maxProductDimension, int countryFrom, int countryTo, int regionFrom, + int regionTo, int freightId, BigDecimal price, String trxName) { + String msg; + String shipperName = new MShipper(ctx, shipperId, trxName).getName(); + String freightCategoryName = new MFreightCategory(ctx, freightCategoryId, trxName).getName(); + String countryFromName = MCountry.get(ctx, countryFrom).getName(); + String countryToName = MCountry.get(ctx, countryFrom).getName(); + String regionFromName = ""; + if (regionFrom > 0) + regionFromName = MRegion.get(ctx, regionFrom).getName(); + String regionToName = ""; + if (regionTo > 0) + regionToName = MRegion.get(ctx, regionTo).getName(); + if (freightId > 0) { + msg = Msg.getMsg(ctx, adMessage, + new Object[] {shipperName, freightCategoryName, dateOrder, weight, maxProductDimension, + countryFromName, countryToName, regionFromName, regionToName, freightId, price}); + } else { + msg = Msg.getMsg(ctx, adMessage, + new Object[] {shipperName, freightCategoryName, dateOrder, weight, maxProductDimension, + countryFromName, countryToName, regionFromName, regionToName}); + } + return msg; + } + + @Override + public boolean processShipment(Properties ctx, MShippingTransaction st, String trxName) { + throw new AdempiereUserError("Not implemented"); + } + + @Override + public boolean voidShipment(Properties ctx, MShippingTransaction st, String get_TrxName) { + throw new AdempiereUserError("Not implemented"); + } + +} diff --git a/org.adempiere.base/src/org/adempiere/model/MShipperFacade.java b/org.adempiere.base/src/org/adempiere/model/MShipperFacade.java index f95cd010cf..680e329fe3 100644 --- a/org.adempiere.base/src/org/adempiere/model/MShipperFacade.java +++ b/org.adempiere.base/src/org/adempiere/model/MShipperFacade.java @@ -48,57 +48,57 @@ public class MShipperFacade public String getShippingProcessorClass() { - return m_processor.getShippingProcessorClass(); + return m_processor == null ? null : m_processor.getShippingProcessorClass(); } public String getConnectionKey() { - return m_processor.getConnectionKey(); + return m_processor == null ? null : m_processor.getConnectionKey(); } public String getConnectionPassword() { - return m_processor.getConnectionPassword(); + return m_processor == null ? null : m_processor.getConnectionPassword(); } public String getUserID() { - return m_processor.getUserID(); + return m_processor == null ? null : m_processor.getUserID(); } public String getHostAddress() { - return m_processor.getHostAddress(); + return m_processor == null ? null : m_processor.getHostAddress(); } public String getProxyAddress() { - return m_processor.getProxyAddress(); + return m_processor == null ? null : m_processor.getProxyAddress(); } public int getHostPort() { - return m_processor.getHostPort(); + return m_processor == null ? null : m_processor.getHostPort(); } public String getProxyLogon() - { - return m_processor.getProxyLogon(); + { + return m_processor == null ? null : m_processor.getProxyLogon(); } public String getProxyPassword() - { - return m_processor.getProxyPassword(); + { + return m_processor == null ? null : m_processor.getProxyPassword(); } public int getProxyPort() - { - return m_processor.getProxyPort(); + { + return m_processor == null ? null : m_processor.getProxyPort(); } public String getServicePath() - { - return m_processor.getServicePath(); + { + return m_processor == null ? null : m_processor.getServicePath(); } public String getShippingServiceCode() diff --git a/org.adempiere.base/src/org/adempiere/process/OnlineShipmentProcess.java b/org.adempiere.base/src/org/adempiere/process/OnlineShipmentProcess.java index 52f3246589..1a976e67db 100644 --- a/org.adempiere.base/src/org/adempiere/process/OnlineShipmentProcess.java +++ b/org.adempiere.base/src/org/adempiere/process/OnlineShipmentProcess.java @@ -55,11 +55,11 @@ public class OnlineShipmentProcess extends SvrProcess getProcessInfo().setError(true); getProcessInfo().addLog(new ProcessInfoLog(getProcessInfo().getAD_Process_ID(), new Timestamp(System.currentTimeMillis()), null, m_package.getErrorMessage())); - return m_package.getErrorMessage(); + return "@Error@"; } getProcessInfo().addLog(new ProcessInfoLog(getProcessInfo().getAD_Process_ID(), new Timestamp(System.currentTimeMillis()), null, m_package.getShippingRespMessage())); - return m_package.getShippingRespMessage(); + return "@OK"; } /* diff --git a/org.adempiere.base/src/org/adempiere/process/SalesOrderRateInquiryProcess.java b/org.adempiere.base/src/org/adempiere/process/SalesOrderRateInquiryProcess.java index 37962922c7..ad98f25900 100644 --- a/org.adempiere.base/src/org/adempiere/process/SalesOrderRateInquiryProcess.java +++ b/org.adempiere.base/src/org/adempiere/process/SalesOrderRateInquiryProcess.java @@ -176,12 +176,12 @@ public class SalesOrderRateInquiryProcess extends SvrProcess getProcessInfo().setError(true); getProcessInfo().addLog(new ProcessInfoLog(getProcessInfo().getAD_Process_ID(), new Timestamp(System.currentTimeMillis()), null, st.getErrorMessage())); - return st.getErrorMessage(); + return "@Error@"; } getProcessInfo().addLog(new ProcessInfoLog(getProcessInfo().getAD_Process_ID(), new Timestamp(System.currentTimeMillis()), null, st.getShippingRespMessage())); - return st.getShippingRespMessage(); + return "@OK@"; } public static MShippingTransaction createShippingTransaction(Properties ctx, MOrder m_order, String action, boolean isPriviledgedRate, String trxName) diff --git a/org.adempiere.base/src/org/compiere/model/MFreight.java b/org.adempiere.base/src/org/compiere/model/MFreight.java new file mode 100644 index 0000000000..69fab1263b --- /dev/null +++ b/org.adempiere.base/src/org/compiere/model/MFreight.java @@ -0,0 +1,101 @@ +/*********************************************************************** + * This file is part of iDempiere ERP Open Source * + * http://www.idempiere.org * + * * + * Copyright (C) Contributors * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * + * MA 02110-1301, USA. * + * * + * Contributors: * + * - Carlos Ruiz * + **********************************************************************/ + +package org.compiere.model; + +import java.math.BigDecimal; +import java.sql.ResultSet; +import java.sql.Timestamp; +import java.util.Properties; + +public class MFreight extends X_M_Freight { + /** + * + */ + private static final long serialVersionUID = -1280041173155194185L; + + /** + * Default constructor + * + * @param ctx Context + * @param M_Freight_ID If set to 0 a new category is created. + * @param trxName Name of database transaction + */ + public MFreight(Properties ctx, int M_Freight_ID, String trxName) { + super(ctx, M_Freight_ID, trxName); + } + + /** + * Constructor using a resultset. + * + * @param ctx Context + * @param rs ResultSet + * @param trxName Name of database transaction + */ + public MFreight(Properties ctx, ResultSet rs, String trxName) { + super(ctx, rs, trxName); + } + + /** + * Get a freight record based on the parameters + * Shipper, Freight Category are used as filters + * DateOrdered is used to get the most recent record that is valid for that date + * MaxDimension is used to get records that are valid for such dimensions + * Country/Region From/To are used to get the records, first valid is the more detailed defined + * + * @param ctx Context + * @param shipperId Shipper + * @param freightCategoryId Freight Category + * @param dateOrdered Date from the Order + * @param weight Weight of the order + * @param maxProductDimension Max Product Dimension from all products in the order + * @param countryFrom Country of origin + * @param countryTo Destination country + * @param regionFrom Region of origin + * @param regionTo Destination region + * @param trxName Transaction Name + * @return a freight record or null if not found + */ + public static MFreight get(Properties ctx, int shipperId, int freightCategoryId, Timestamp dateOrdered, BigDecimal weight, + BigDecimal maxProductDimension, int countryFrom, int countryTo, int regionFrom, int regionTo, String trxName) { + String whereClause = "M_Shipper_ID = ?" + + " AND M_FreightCategory_ID = ?" + + " AND ValidFrom <= ?" + + " AND (MaxDimension IS NULL OR MaxDimension = 0 OR MaxDimension >= ?)" + + " AND (C_Country_ID IS NULL OR C_Country_ID = ?)" + + " AND (To_Country_ID IS NULL OR To_Country_ID = ?)" + + " AND (C_Region_ID IS NULL OR C_Region_ID = ?)" + + " AND (To_Region_ID IS NULL OR To_Region_ID = ?)" + + " AND (MaxWeight IS NULL OR MaxWeight = 0 OR MaxWeight >= ?)"; + String orderBy = "ValidFrom DESC, MaxWeight, C_Country_ID, To_Country_ID, C_Region_ID, To_Region_ID"; + MFreight freight = new Query(ctx, Table_Name, whereClause, trxName) + .setOnlyActiveRecords(true) + .setOrderBy(orderBy) + .setParameters(shipperId, freightCategoryId, dateOrdered, maxProductDimension, countryFrom, countryTo, regionFrom, regionTo, weight) + .first(); + return freight; + } + +} diff --git a/org.adempiere.base/src/org/compiere/model/MShippingTransaction.java b/org.adempiere.base/src/org/compiere/model/MShippingTransaction.java index 6be13af42b..2576094906 100644 --- a/org.adempiere.base/src/org/compiere/model/MShippingTransaction.java +++ b/org.adempiere.base/src/org/compiere/model/MShippingTransaction.java @@ -69,7 +69,10 @@ public class MShippingTransaction extends X_M_ShippingTransaction MShipperFacade sf = new MShipperFacade(getMShipper()); IShipmentProcessor processor = Core.getShipmentProcessor(sf); if (processor == null) + { setErrorMessage(Msg.getMsg(Env.getCtx(), "ShippingNoProcessor")); + return false; + } else { if (getAction().equals(ACTION_ProcessShipment)) @@ -82,7 +85,7 @@ public class MShippingTransaction extends X_M_ShippingTransaction throw new AdempiereException(Msg.getMsg(Env.getCtx(), "ActionNotSupported")); if (!processed) - setErrorMessage("From " + getMShipper().getName() + ": " + getShippingRespMessage()); + setErrorMessage(Msg.parseTranslation(getCtx(), "** @Error@ ** @From@ ") + getMShipper().getName() + ": " + getShippingRespMessage()); } } catch (Exception e) @@ -91,7 +94,7 @@ public class MShippingTransaction extends X_M_ShippingTransaction setErrorMessage(Msg.getMsg(Env.getCtx(), "ShippingNotProcessed") + ":\n" + e.getMessage()); } - MOnlineTrxHistory history = new MOnlineTrxHistory(getCtx(), 0, get_TrxName()); + MOnlineTrxHistory history = new MOnlineTrxHistory(getCtx(), 0, null); // out of transaction - save history even if the process fails history.setAD_Table_ID(MShippingTransaction.Table_ID); history.setRecord_ID(getM_ShippingTransaction_ID()); history.setIsError(!processed); @@ -101,7 +104,7 @@ public class MShippingTransaction extends X_M_ShippingTransaction if (processed) msg.append(getShippingRespMessage()); else - msg.append("ERROR: " + getErrorMessage()); + msg.append(getErrorMessage()); msg.append("\nAction: " + getAction()); history.setTextMsg(msg.toString());