Coder Social home page Coder Social logo

Comments (8)

tjschuck avatar tjschuck commented on July 18, 2024

Just to clarify the issue, that XML sample:

<Invoice>
  <Invoice>
    <ContactID>ac565f9c-9829-4f51-8a5b-0400de972bbb</ContactID>;
    <Name>PowerDirect</Name>
  </Invoice>
 [...]
</Invoice>

should have Contact as its first child instead of Invoice repeated:

<Invoice>
  <Contact>
    <ContactID>ac565f9c-9829-4f51-8a5b-0400de972bbb</ContactID>;
    <Name>PowerDirect</Name>
  </Contact>
 [...]
</Invoice>

from xeroizer.

waynerobinson avatar waynerobinson commented on July 18, 2024

Could you please show me the code that you're using to generate this? I've not encountered this issue before with code like:

invoice = gw.Invoice.build(type: "ACCREC", contact: {name: "Contact Name"})
invoice.save

from xeroizer.

zmoazeni avatar zmoazeni commented on July 18, 2024

I'm getting this from client.Invoice.first.to_xml. Where the client is the appropriate application. In this case a PartnerApplication

from xeroizer.

waynerobinson avatar waynerobinson commented on July 18, 2024

That is… interesting. I will have a look and get back to you. You're right, loading the invoice initialises this as Invoice instead of Contact.

from xeroizer.

fimmtiu avatar fimmtiu commented on July 18, 2024

I'm running into this now, too... when I do something like this:

invoice = xeroizer.Invoice.first
contact = invoice.contact
puts xeroizer.CreditNote.build(contact: contact).to_xml

...it serializes as <CreditNote><Invoice>(contact data...)</Invoice></CreditNote>. But if I change it to this:

contact = xeroizer.Contact.first

...it works fine. Something about the fact that it's being pulled from the invoice makes it serialize improperly.

from xeroizer.

waynerobinson avatar waynerobinson commented on July 18, 2024

Xeroizer was never really intended to have it's sub-elements re-used in other record types and this is obviously showing through here.

In the meantime, the easiest way to refer to a contact elsewhere is to actually use its unique ID. E.g.

invoice = xeroizer.Invoice.first
contact = invoice.contact
puts xeroizer.CreditNote.build(contact: {id: contact.id}).to_xml

from xeroizer.

fimmtiu avatar fimmtiu commented on July 18, 2024

Doesn't work in any case where the model does a validates_associated on the contact association (i.e., credit notes). Just saying {id: contact_id} isn't enough to satisfy validates_associated.

from xeroizer.

waynerobinson avatar waynerobinson commented on July 18, 2024

Fixed by @fimmtiu in #96.

from xeroizer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.