Show/Hide Toolbars

The following example shows how to adjust an invoice line item by changing the line item rate by a specified amount. In the example, it is assumed there is an existing invoice with one or more line items. To access an existing invoice, use the InvoiceRepository's updateInvoice method. To perform the line item adjustment, use the type class, LineItemAdjustmentUpdate.

Note: You can also adjust line items at the time you add line items to an invoice. In this case, you can use either the InvoiceRepository's insertInvoice or updateInvoice method. Since you are adjusting the line item and creating it at the same time, use the type class, LineItemAdjustmentCreate.

When performing a line item adjustment, you must use the following set methods to populate required fields: .

Code Snippet for adjusting invoice line items on invoice update

protected InvoiceRepository invoice = new InvoiceRepository();

InvoiceUpdate invoice = updateInvoice();

invoice.updateInvoice(invoice);

private InvoiceUpdate updateInvoice() throws Exception {

Date date = new Date();

InvoiceUpdate invoice = new InvoiceUpdate();

//these 3 lines are used to ID the invoice to update

invoice.setNumberString("inv100-2053");

invoice.setInvoiceDate(date);

invoice.setVendorUniqueKey("ven2345");

//these lines are used to adjust an invoice line item

invoice.getLineItemCreates().add(createLineItemAdjustment());

return invoice;

}

private LineItemAdjustmentCreate createLineItemAdjustment() throws Exception {

String userUniqueKey = "user_101";

LineItemAdjustmentCreate lineItemAdjustment = new LineItemAdjustmentCreate();

lineItemAdjustment.setAdjustingUserUniqueKey(userUniqueKey);

lineItemAdjustment.setAdjustmentDate(date);

lineItemAdjustment.setAdjustmentTarget(LineItemAdjustmentTarget.RATE);

lineItemAdjustment.setAdjustmentValue(45.5);

lineItemAdjustment.setAdjustmentMethod(AdjustmentMethod.REDUCE_BY_AMOUNT);

lineItemAdjustment.setInHouseComments("Rejected invoice because the timekeeper rate exceeds our agreement. Adjusting the rate down.");

lineItemAdjustment.setCommentsToVendor("Rejected invoice because the timekeeper rate exceeds our agreement. Adjusting the line item rate.");

return lineItemAdjustment;

}