maartenvanvliet / moneybird

Ruby gem for the Moneybird REST API
https://github.com/maartenvanvliet/moneybird
MIT License
6 stars 21 forks source link

Custom fields are not saved when creating an invoice #67

Closed mvanduijker closed 2 years ago

mvanduijker commented 2 years ago

reproduce:

client = Moneybird::Client.new('some token')
administration = client.administrations.find(administration_id).first
administration.sales_invoices.create({
  contact_id: some_contact_id,
  custom_fields: [
    {id: some_id, value: 'some value'}
  ]
})

After looking in Moneybird custom fields data does not appear to be filled in the invoice.

Building the invoice resource by hand, it does fill the custom_fields attribute but when calling the to_json method on the resulting object it gets serialised as custom_fields instead of custom_fields_attributes and ignored by Moneybird API.

invoice = administration.sales_invoices.build({
  contact_id: some_contact_id,
  custom_fields: [
    {id: some_id, value: 'some value'}
  ]
})

pp invoice
pp invoice.to_json

I guess we have to add a custom_field resource to solve this problem.

maartenvanvliet commented 2 years ago

Yes seems like it 🙂. PR welcome!

mvanduijker commented 2 years ago

I see it's already implemented by https://github.com/maartenvanvliet/moneybird/pull/59 could you make a release?

maartenvanvliet commented 2 years ago

done! 🎉