Repository navigation
UpdateRepeatingInvoice failed to update the repeatingInvoiceId provided in method but created a new repeating invoice #341
Copy link
Copy link
Open
Description
// Create a repeating invoice
@Test
void testAddXeroRepeatingInvoice() throws Exception {
String accessToken = xeroService.getToken();
ApiClient defaultClient = new ApiClient();
AccountingApi apiInstance = AccountingApi.getInstance(defaultClient);
String xeroTenantId = xeroService.getTenantId();
Boolean summarizeErrors = true;
RepeatingInvoices repeatingInvoices = new RepeatingInvoices();
RepeatingInvoice repeatingInvoice = new RepeatingInvoice();
UUID invoiceId = UUID.randomUUID();
System.out.println(invoiceId);
repeatingInvoice.setRepeatingInvoiceID(invoiceId);
Contact contact = new Contact();
contact.setContactID(UUID.fromString("fe6f61ee-e6f1-4f32-b6fe-3486c6bac13c"));
Schedule schedule = new Schedule();
schedule.setUnit(Schedule.UnitEnum.WEEKLY);
schedule.setStartDate(org.threeten.bp.LocalDate.now());
schedule.setEndDate(org.threeten.bp.LocalDate.now().plusDays(3L));
schedule.setPeriod(5);
schedule.setDueDate(3);
LineItem lineItem = new LineItem();
lineItem.setQuantity(1.0);
lineItem.setDescription("test");
lineItem.setAccountCode("123456");
lineItem.setUnitAmount(108.8);
repeatingInvoice.setContact(contact);
repeatingInvoice.setLineItems(List.of(lineItem));
repeatingInvoice.setSchedule(schedule);
repeatingInvoice.setType(RepeatingInvoice.TypeEnum.ACCREC);
repeatingInvoice.setStatus(RepeatingInvoice.StatusEnum.AUTHORISED);
repeatingInvoices.setRepeatingInvoices(List.of(repeatingInvoice));
try {
RepeatingInvoices result = apiInstance.createRepeatingInvoices(accessToken, xeroTenantId, repeatingInvoices, summarizeErrors);
System.out.println(result);
} catch (XeroException e) {
System.err.println("Exception when calling AccountingApi#createRepeatingInvoices");
e.printStackTrace();
}
}
// Update the repeating invoice based on the returned repeating invoice Id
@Test
void testUpdateXeroRepeatingInvoice() throws IOException {
String accessToken = xeroService.getToken();
ApiClient defaultClient = new ApiClient();
UUID repeatingInvoiceID = RETURNED REPEATING INVOICE ID
AccountingApi apiInstance = AccountingApi.getInstance(defaultClient);
String xeroTenantId = xeroService.getTenantId();
RepeatingInvoices repeatingInvoices = new RepeatingInvoices();
RepeatingInvoice repeatingInvoice = new RepeatingInvoice();
Contact contact = new Contact();
contact.setContactID(UUID.fromString("fe6f61ee-e6f1-4f32-b6fe-3486c6bac13c"));
Schedule schedule = new Schedule();
schedule.setUnit(Schedule.UnitEnum.MONTHLY);
schedule.setStartDate(org.threeten.bp.LocalDate.now());
schedule.setEndDate(org.threeten.bp.LocalDate.now().plusDays(10L));
schedule.setPeriod(5);
schedule.setDueDate(3);
LineItem lineItem = new LineItem();
lineItem.setQuantity(1.0);
lineItem.setDescription("test");
lineItem.setAccountCode("123456");
lineItem.setUnitAmount(109.9);
repeatingInvoice.setContact(contact);
repeatingInvoice.setLineItems(List.of(lineItem));
repeatingInvoice.setSchedule(schedule);
repeatingInvoice.setType(RepeatingInvoice.TypeEnum.ACCREC);
repeatingInvoice.setStatus(RepeatingInvoice.StatusEnum.AUTHORISED);
repeatingInvoices.setRepeatingInvoices(List.of(repeatingInvoice));
try {
RepeatingInvoices result = apiInstance.updateRepeatingInvoices(accessToken, xeroTenantId, repeatingInvoiceID, repeatingInvoices);
System.out.println(result);
} catch (XeroException e) {
System.err.println("Exception when calling AccountingApi#updateRepeatingInvoice");
e.printStackTrace();
}
}
What I got in my Demo company is, every time I do updating, a new invoice will be created instead of replacing the previous one. But I can literally do updating repeating invoices mannually in Xero Demo company.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
icomputeUK commentedon Sep 3, 2024
Been trying to do similar by updating due dates in bulk.
But, I think UpdateRepeatingInvoice only creates new invoices or deletes them. As per the documentation here:
https://developer.xero.com/documentation/api/accounting/repeatinginvoices#overview
And the API Explorer here:
https://api-explorer.xero.com/accounting/repeatinginvoices/updaterepeatinginvoice?path-repeatinginvoiceid=