IDEMPIERE-5602 : Adding PriceEntered in Expense report (#1759)
This commit is contained in:
parent
1441b9095a
commit
5199247a1e
|
@ -0,0 +1,29 @@
|
||||||
|
SET SQLBLANKLINES ON
|
||||||
|
SET DEFINE OFF
|
||||||
|
|
||||||
|
-- Added Price field in Expense Report Line
|
||||||
|
-- 07-Mar-2023, 12:49:49 PM IST
|
||||||
|
INSERT INTO AD_Column (AD_Column_ID,Version,Name,Description,Help,AD_Table_ID,ColumnName,DefaultValue,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,Callout,AD_Element_ID,IsUpdateable,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,SeqNoSelection,IsToolbarButton,IsSecure,IsHtml) VALUES (215777,0,'Price','Price Entered - the price based on the selected price list on header','Price Entered - the price based on the selected price list on header',488,'PriceEntered','0',22,'N','N','N','N','N',0,'N',37,0,0,'Y',TO_DATE('2023-03-07 12:49:48','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2023-03-07 12:49:48','YYYY-MM-DD HH24:MI:SS'),100,'org.compiere.model.CalloutTimeExpense.priceOrQty',2588,'Y','N','D','N','N','N','Y','0d4f6687-ec2e-46a7-977a-fbb44ac8f4d3','N',0,'N','N','N')
|
||||||
|
;
|
||||||
|
|
||||||
|
-- 07-Mar-2023, 12:50:01 PM IST
|
||||||
|
ALTER TABLE S_TimeExpenseLine ADD PriceEntered NUMBER DEFAULT 0
|
||||||
|
;
|
||||||
|
|
||||||
|
-- 07-Mar-2023, 12:50:35 PM IST
|
||||||
|
INSERT INTO AD_Field (AD_Field_ID,Name,Description,Help,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 (207572,'Price','Price Entered - the price based on the selected price list on header','Price Entered - the price based on the selected price list on header',413,215777,'Y',22,95,'N','N','N','N',0,0,'Y',TO_DATE('2023-03-07 12:50:34','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2023-03-07 12:50:34','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','e39cabde-90c0-4bac-a32a-0ac84f2cb15a','Y',95,2)
|
||||||
|
;
|
||||||
|
|
||||||
|
-- 07-Mar-2023, 9:23:37 PM IST
|
||||||
|
UPDATE AD_Column SET Callout='org.compiere.model.CalloutTimeExpense.priceOrQty',Updated=TO_DATE('2023-03-07 21:23:37','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=6875
|
||||||
|
;
|
||||||
|
|
||||||
|
-- 07-Mar-2023, 10:13:18 PM IST
|
||||||
|
UPDATE AD_Field SET AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=4, IsToolbarButton=NULL,Updated=TO_DATE('2023-03-07 22:13:18','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5463
|
||||||
|
;
|
||||||
|
|
||||||
|
-- 07-Mar-2023, 9:34:04 PM IST
|
||||||
|
UPDATE AD_Field SET IsReadOnly='Y', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2023-03-07 21:34:04','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5462
|
||||||
|
;
|
||||||
|
|
||||||
|
SELECT register_migration_script('202303071543_IDEMPIERE-5602.sql') FROM dual;
|
|
@ -0,0 +1,26 @@
|
||||||
|
-- Added Price field in Expense Report Line
|
||||||
|
-- 07-Mar-2023, 12:49:49 PM IST
|
||||||
|
INSERT INTO AD_Column (AD_Column_ID,Version,Name,Description,Help,AD_Table_ID,ColumnName,DefaultValue,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,Callout,AD_Element_ID,IsUpdateable,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,SeqNoSelection,IsToolbarButton,IsSecure,IsHtml) VALUES (215777,0,'Price','Price Entered - the price based on the selected price list on header','Price Entered - the price based on the selected price list on header',488,'PriceEntered','0',22,'N','N','N','N','N',0,'N',37,0,0,'Y',TO_TIMESTAMP('2023-03-07 12:49:48','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-03-07 12:49:48','YYYY-MM-DD HH24:MI:SS'),100,'org.compiere.model.CalloutTimeExpense.priceOrQty',2588,'Y','N','D','N','N','N','Y','0d4f6687-ec2e-46a7-977a-fbb44ac8f4d3','N',0,'N','N','N')
|
||||||
|
;
|
||||||
|
|
||||||
|
-- 07-Mar-2023, 12:50:01 PM IST
|
||||||
|
ALTER TABLE S_TimeExpenseLine ADD COLUMN PriceEntered NUMERIC DEFAULT '0'::numeric
|
||||||
|
;
|
||||||
|
|
||||||
|
-- 07-Mar-2023, 12:50:35 PM IST
|
||||||
|
INSERT INTO AD_Field (AD_Field_ID,Name,Description,Help,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 (207572,'Price','Price Entered - the price based on the selected price list on header','Price Entered - the price based on the selected price list on header',413,215777,'Y',22,95,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2023-03-07 12:50:34','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-03-07 12:50:34','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','e39cabde-90c0-4bac-a32a-0ac84f2cb15a','Y',95,2)
|
||||||
|
;
|
||||||
|
|
||||||
|
-- 07-Mar-2023, 9:23:37 PM IST
|
||||||
|
UPDATE AD_Column SET Callout='org.compiere.model.CalloutTimeExpense.priceOrQty',Updated=TO_TIMESTAMP('2023-03-07 21:23:37','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=6875
|
||||||
|
;
|
||||||
|
|
||||||
|
-- 07-Mar-2023, 10:13:18 PM IST
|
||||||
|
UPDATE AD_Field SET AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=4, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2023-03-07 22:13:18','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5463
|
||||||
|
;
|
||||||
|
|
||||||
|
-- 07-Mar-2023, 9:34:04 PM IST
|
||||||
|
UPDATE AD_Field SET IsReadOnly='Y', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2023-03-07 21:34:04','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5462
|
||||||
|
;
|
||||||
|
|
||||||
|
SELECT register_migration_script('202303071543_IDEMPIERE-5602.sql') FROM dual;
|
|
@ -39,7 +39,7 @@ public class CalloutTimeExpense extends CalloutEngine
|
||||||
/**
|
/**
|
||||||
* Expense Report Line
|
* Expense Report Line
|
||||||
* - called from M_Product_ID, S_ResourceAssignment_ID
|
* - called from M_Product_ID, S_ResourceAssignment_ID
|
||||||
* - set ExpenseAmt
|
* - set Price
|
||||||
* @param ctx context
|
* @param ctx context
|
||||||
* @param WindowNo current Window No
|
* @param WindowNo current Window No
|
||||||
* @param mTab Grid Tab
|
* @param mTab Grid Tab
|
||||||
|
@ -163,7 +163,7 @@ public class CalloutTimeExpense extends CalloutEngine
|
||||||
// finish
|
// finish
|
||||||
if (priceActual == null)
|
if (priceActual == null)
|
||||||
priceActual = Env.ZERO;
|
priceActual = Env.ZERO;
|
||||||
mTab.setValue("ExpenseAmt", priceActual);
|
mTab.setValue("PriceEntered", priceActual);
|
||||||
return "";
|
return "";
|
||||||
} // Expense_Product
|
} // Expense_Product
|
||||||
|
|
||||||
|
@ -206,5 +206,49 @@ public class CalloutTimeExpense extends CalloutEngine
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
} // Expense_Amount
|
} // Expense_Amount
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Price or Quantity.
|
||||||
|
* - called from Price, Quantity
|
||||||
|
* - calculates Expense Amount
|
||||||
|
* @param ctx context
|
||||||
|
* @param WindowNo current Window No
|
||||||
|
* @param mTab Grid Tab
|
||||||
|
* @param mField Grid Field
|
||||||
|
* @param value New Value
|
||||||
|
* @return null or error message
|
||||||
|
*/
|
||||||
|
public String priceOrQty(Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value)
|
||||||
|
{
|
||||||
|
BigDecimal qty = Env.ZERO;
|
||||||
|
BigDecimal price = Env.ZERO;
|
||||||
|
|
||||||
|
String columnName = mField.getColumnName();
|
||||||
|
if (MTimeExpenseLine.COLUMNNAME_Qty.equals(columnName))
|
||||||
|
{
|
||||||
|
qty = (BigDecimal) value;
|
||||||
|
price = (BigDecimal) mTab.getValue(MTimeExpenseLine.COLUMNNAME_PriceEntered);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
price = (BigDecimal) value;
|
||||||
|
qty = (BigDecimal) mTab.getValue(MTimeExpenseLine.COLUMNNAME_Qty);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(qty == null)
|
||||||
|
{
|
||||||
|
qty = Env.ZERO;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(price == null)
|
||||||
|
{
|
||||||
|
price = Env.ZERO;
|
||||||
|
}
|
||||||
|
|
||||||
|
BigDecimal expenseAmt = price.multiply(qty);
|
||||||
|
mTab.setValue(MTimeExpenseLine.COLUMNNAME_ExpenseAmt, expenseAmt);
|
||||||
|
|
||||||
|
return "";
|
||||||
|
} // Price or Quantity
|
||||||
|
|
||||||
} // CalloutTimeExpense
|
} // CalloutTimeExpense
|
||||||
|
|
|
@ -372,6 +372,19 @@ public interface I_S_TimeExpenseLine
|
||||||
* Optional additional user defined information
|
* Optional additional user defined information
|
||||||
*/
|
*/
|
||||||
public String getNote();
|
public String getNote();
|
||||||
|
|
||||||
|
/** Column name PriceEntered */
|
||||||
|
public static final String COLUMNNAME_PriceEntered = "PriceEntered";
|
||||||
|
|
||||||
|
/** Set Price.
|
||||||
|
* Price Entered - the price based on the selected price list on header
|
||||||
|
*/
|
||||||
|
public void setPriceEntered (BigDecimal PriceEntered);
|
||||||
|
|
||||||
|
/** Get Price.
|
||||||
|
* Price Entered - the price based on the selected price list on header
|
||||||
|
*/
|
||||||
|
public BigDecimal getPriceEntered();
|
||||||
|
|
||||||
/** Column name PriceInvoiced */
|
/** Column name PriceInvoiced */
|
||||||
public static final String COLUMNNAME_PriceInvoiced = "PriceInvoiced";
|
public static final String COLUMNNAME_PriceInvoiced = "PriceInvoiced";
|
||||||
|
|
|
@ -152,7 +152,7 @@ public class MTimeExpenseLine extends X_S_TimeExpenseLine
|
||||||
*/
|
*/
|
||||||
public BigDecimal getApprovalAmt()
|
public BigDecimal getApprovalAmt()
|
||||||
{
|
{
|
||||||
return getQty().multiply(getConvertedAmt());
|
return getConvertedAmt();
|
||||||
} // getApprovalAmt
|
} // getApprovalAmt
|
||||||
|
|
||||||
|
|
||||||
|
@ -192,6 +192,20 @@ public class MTimeExpenseLine extends X_S_TimeExpenseLine
|
||||||
log.saveError("ParentComplete", Msg.translate(getCtx(), "S_TimeExpense_ID"));
|
log.saveError("ParentComplete", Msg.translate(getCtx(), "S_TimeExpense_ID"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//calculate expense amount
|
||||||
|
if(newRecord || is_ValueChanged(COLUMNNAME_Qty) || is_ValueChanged(COLUMNNAME_PriceEntered))
|
||||||
|
{
|
||||||
|
BigDecimal price = getPriceEntered();
|
||||||
|
if(price == null)
|
||||||
|
{
|
||||||
|
price = Env.ZERO;
|
||||||
|
}
|
||||||
|
|
||||||
|
BigDecimal expenseAmt = price.multiply(getQty());
|
||||||
|
setExpenseAmt(expenseAmt);
|
||||||
|
}
|
||||||
|
|
||||||
// Calculate Converted Amount
|
// Calculate Converted Amount
|
||||||
if (newRecord || is_ValueChanged("ExpenseAmt") || is_ValueChanged("C_Currency_ID"))
|
if (newRecord || is_ValueChanged("ExpenseAmt") || is_ValueChanged("C_Currency_ID"))
|
||||||
{
|
{
|
||||||
|
@ -297,7 +311,7 @@ public class MTimeExpenseLine extends X_S_TimeExpenseLine
|
||||||
{
|
{
|
||||||
String sql = "UPDATE S_TimeExpense te"
|
String sql = "UPDATE S_TimeExpense te"
|
||||||
+ " SET ApprovalAmt = "
|
+ " SET ApprovalAmt = "
|
||||||
+ "(SELECT SUM(Qty*ConvertedAmt) FROM S_TimeExpenseLine tel "
|
+ "(SELECT SUM(ConvertedAmt) FROM S_TimeExpenseLine tel "
|
||||||
+ "WHERE te.S_TimeExpense_ID=tel.S_TimeExpense_ID) "
|
+ "WHERE te.S_TimeExpense_ID=tel.S_TimeExpense_ID) "
|
||||||
+ "WHERE S_TimeExpense_ID=" + getS_TimeExpense_ID();
|
+ "WHERE S_TimeExpense_ID=" + getS_TimeExpense_ID();
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
|
|
|
@ -586,6 +586,26 @@ public class X_S_TimeExpenseLine extends PO implements I_S_TimeExpenseLine, I_Pe
|
||||||
return (String)get_Value(COLUMNNAME_Note);
|
return (String)get_Value(COLUMNNAME_Note);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Set Price.
|
||||||
|
@param PriceEntered
|
||||||
|
Price Entered - the price based on the selected price list on header
|
||||||
|
*/
|
||||||
|
public void setPriceEntered (BigDecimal PriceEntered)
|
||||||
|
{
|
||||||
|
set_Value (COLUMNNAME_PriceEntered, PriceEntered);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get Price.
|
||||||
|
@return Price Entered - the price based on the selected price list on header
|
||||||
|
*/
|
||||||
|
public BigDecimal getPriceEntered ()
|
||||||
|
{
|
||||||
|
BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_PriceEntered);
|
||||||
|
if (bd == null)
|
||||||
|
return Env.ZERO;
|
||||||
|
return bd;
|
||||||
|
}
|
||||||
|
|
||||||
/** Set Price Invoiced.
|
/** Set Price Invoiced.
|
||||||
@param PriceInvoiced The priced invoiced to the customer (in the currency of the customer's AR price list) - 0 for default price
|
@param PriceInvoiced The priced invoiced to the customer (in the currency of the customer's AR price list) - 0 for default price
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue