Search.../

updateInvoice( )

Update an existing invoice.

Description

The updateInvoice() function returns a Promise that resolves to the updated invoice's ID when the invoice is updated.

Note: The customer listed on the invoice must be an existing site contact or member.

Syntax

function updateInvoice(id: IdAndVersion, invoiceFields: InvoiceFields, [fieldMask: Array<string>]): Promise<Response>

updateInvoice Parameters

NAME
TYPE
DESCRIPTION
id
IdAndVersion

ID and version of the invoice to update.

invoiceFields
InvoiceFields

The data used to update the invoice.

fieldMask
Optional
Array<string>

Fields to update in the invoice. If not specified, all fields update.

One of:

  • "customer"
  • "lineItems"
  • "number"
  • "locale"
  • "discount"
  • "title"
  • "currency"
  • "issueDate"
  • "dueDate"
  • "taxes"
  • "totals.total"
  • "totals.subtotal"
  • "totals.subtotal"
  • "totals.fees"
  • "metadata.notes"
  • "metadata.legalTerms"
  • "metadata.sourceUrl"
  • "metadata.sourceProperties"
  • "metadata.source"
  • "metadata.sourceRefId"

Returns

Fulfilled - ID and version of the updated invoice.

Return Type:

Promise<Response>
NAME
TYPE
DESCRIPTION
id
IdAndVersion

ID and version information.

Was this helpful?

Update an existing invoice

Copy Code
1import {invoices} from 'wix-billing-backend';
2
3export function updateInvoice(id) {
4 return invoices.getInvoice(id)
5 .then( (result) => {
6 //make some changes
7 result.metadata.notes = "An updated note.";
8
9 let updateFields = {
10 "title": result.title,
11 "customer": result.customer,
12 "currency": result.currency,
13 "lineItems": result.lineItems,
14 "discount": result.discount,
15 "payments": result.payments,
16 "metadata": result.metadata,
17 "dates": result.dates
18 };
19 return invoices.updateInvoice(result.id, updateFields);
20 } );
21}
22
23/* Promise resolves to:
24 * {
25 * {
26 * "id": {
27 * "id": "1ed3a515-24f9-4039-8937-2e69b6a2f33a",
28 * "version": 31
29 * }
30 * }
31 * }
32 */