waynerobinson / xeroizer

Xero accounting system API library.
http://waynerobinson.github.com/xeroizer
Other
238 stars 311 forks source link

BankAccount Model Not Available? #560

Open frasermayfield opened 1 year ago

frasermayfield commented 1 year ago

Using xeroizer 3.0.1 with Rails 6.1.4

I am trying to use the BankAccount model as part of creating BankTransactions. In the documentation it states to use:

bank_account = xero.Account.first(:where => {:type => 'BANK'})

Which works but it returns an instance of the Account class as follows:

<Xeroizer::Record::Account :account_id: "7018f80e-5d4e-4323-8c98-2beed1e9c437", :name: "ACCOUNT NAME", :status: "ACTIVE", :type: "BANK", :tax_type: "NONE", :class: "ASSET", :enable_payments_to_account: false, :show_in_expense_claims: false, :bank_account_number: "20202020304050", :currency_code: "GBP", :reporting_code: "ASS", :reporting_code_name: "Assets", :updated_date_utc: 2022-11-03 14:08:18 UTC>

However when you then create a new BankTransaction using the following:

contact = xero.Contact.first xero_spend = xero.BankTransaction.build(:date => '01/01/2022', :contact => contact, :bank_account => bank_account, :type => "SPEND")

It returns an error:

Xeroizer::AssociationTypeMismatch: Xeroizer::Record::BankAccount expected, got Xeroizer::Record::Account

As such I have tried running the following instead:

bank_account = xero.BankAccount.first

But this returns the following error:

NoMethodError: undefined method `BankAccount' for #

Is there something I need to do to enable querying the BankAccount model directly?