Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please add createInvoice, createCreditNote functions #734

Open
caub opened this issue Nov 29, 2024 · 4 comments
Open

Please add createInvoice, createCreditNote functions #734

caub opened this issue Nov 29, 2024 · 4 comments

Comments

@caub
Copy link

caub commented Nov 29, 2024

Because using createInvoices for one document is not practical

Copy link

PETOSS-678

Copy link

Thanks for raising an issue, a ticket has been created to track your request

@tsdevau
Copy link

tsdevau commented Nov 30, 2024

@caub I don't understand why you find it impractical? Maybe you have a special use-case I've not encountered? I use it for single document creation in several functions. You just submit an Invoices array of one Invoice object instead of multiple.

Seems totally reasonable to me to have a single endpoint cater for one or many in preference to 2 dedicated endpoints.

@caub
Copy link
Author

caub commented Dec 1, 2024

It's working, but it's not super practical:

const { body: r } = await xero.accountingApi[isCreditNote ? 'createCreditNotes' : 'createInvoices'](
    addon.customFields.xero_tenantId,
    { [isCreditNote ? 'creditNotes' : 'invoices']: [formattedInvoice] },
    `${invoice.id}-${invoice.version || 0}`, // idempotencyKey
  );
const createdDoc = r[isCreditNote ? 'creditNotes' : 'invoices'][0];

With this proposal:

const { body: r } = await xero.accountingApi[isCreditNote ? 'createCreditNote' : 'createInvoice'](
    addon.customFields.xero_tenantId,
    formattedInvoice,
    `${invoice.id}-${invoice.version || 0}`, // idempotencyKey
  );
const createdDoc = r[isCreditNote ? 'creditNote' : 'invoice'];

Asking because there's a similar createPayment() function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants