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

When calling newBankTransactions #121

Closed
tallday opened this issue Oct 19, 2017 · 5 comments
Closed

When calling newBankTransactions #121

tallday opened this issue Oct 19, 2017 · 5 comments

Comments

@tallday
Copy link

tallday commented Oct 19, 2017

When calling xeroClient.core.bankTransactions.newBankTransactions(bankTransactions) I am receiving the following error TypeError: xeroClient.core.bankTransactions.newBankTransactions is not a function

@philals
Copy link
Contributor

philals commented Oct 21, 2017

Hi @tallday. Have you checked the source code of this module to make sure the function is there?

@tallday
Copy link
Author

tallday commented Oct 24, 2017

It doesnt look like the function is there to me. Thats why im confused as the documentation provides the example. @philals

@jordanwalsh23
Copy link
Contributor

Hi @tallday, if you check the tests files it's often more helpful (and potentially more correct) than the documentation:

  it('create multiple banktransactions', done => {
    const banktransactions = [];

    for (let i = 0; i < 2; i += 1) {
      banktransactions.push(
        currentApp.core.bankTransactions.newBankTransaction({
          Type: 'SPEND',
          Contact: {
            Name: 'Johnny McGibbons',
          },
          LineItems: [
            {
              Description: 'Annual Bank Account Fee',
              UnitAmount: 0.01,
              AccountCode: expenseAccountCode,
            },
          ],
          BankAccount: {
            AccountID: bankAccountId,
          },
        })
      );
    }

    currentApp.core.bankTransactions
      .saveBankTransactions(banktransactions)
      .then(response => {
        expect(response.entities).to.have.length.greaterThan(0);
        response.entities.forEach(bankTransaction => {
          expect(bankTransaction.BankTransactionID).to.not.equal('');
          expect(bankTransaction.BankTransactionID).to.not.equal(undefined);
        });
        done();
      })
      .catch(err => {
        console.error(util.inspect(err, null, null));
        done(wrapError(err));
      });
  });

In this case the function is actually saveBankTransactions() and it takes an array of banktransaction objects that were created from the newBankTransaction() constructor.

Hope that helps.

@tallday
Copy link
Author

tallday commented Oct 25, 2017

Thanks very much. This has help me a lot @jordanwalsh23.
I have since determined that I was actually wanting to create bank statements not transactions. Which then I discovered this https://xero.uservoice.com/forums/5528-xero-api/suggestions/340274-import-bank-statement-lines-via-the-api

@philals
Copy link
Contributor

philals commented Oct 26, 2017

Thanks for the help @jordanwalsh23

@philals philals closed this as completed Oct 26, 2017
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

3 participants