Show/Hide Toolbars

The following sample updates an expense record's expenseDate, projectUniqueKey, quantity, totalAmount, unitPrice values.

Code Snippet

//for this sample, it is assumed that an expense record already

exists with a unique key String equal to uniqueKey

protected ExpenseRepository expenseRepository;

public void test_updateExpense() throws Exception {

Date date = new Date();

ExpenseUpdate expenseUpdate = new ExpenseUpdate();

//use the setUniqueKey method to identify the target expense record to update by its unique key

expenseUpdate.setUniqueKey(uniqueKey);

expenseUpdate.setExpenseDate(date);

expenseUpdate.setProjectUniqueKey("DISP_2003");

expenseUpdate.setQuantity(15.0);

expenseUpdate.setUnitPrice(2.0);

//Note that the totalAmount property is calculated by the product of the quantity and unitPrice property values. In the expense update sample provided, the totalAmount property will automatically be updated to 30.0

expenseRepository.updateExpense(expenseUpdate);

}