GithubHelp home page GithubHelp logo

Comments (2)

sarava77 avatar sarava77 commented on June 17, 2024

I want allocate the created Credit Notes to invoice

<Allocations>
 <Allocation>
   <AppliedAmount>60.50</AppliedAmount>
   <Invoice>
     <InvoiceID>f5832195-5cd3-4660-ad3f-b73d9c64f263</InvoiceID>
   </Invoice>
 </Allocation>
</Allocations>

So I have created the class below structure

public class JSON2Apex {

public Allocation Allocation=new Allocation();

public class Allocation {
public String AppliedAmount;
public Invoice Invoice=new Invoice();
}

public class Invoice {
public String InvoiceID;
}

}

This is the code I am executing in Salesforce developer console

String consumerKey;
HttpResponse response;
Xero_Settings__c xeroSettings=Xero_Settings__c.getInstance('UKINC');
consumerKey = xeroSettings.Consumer_Key__c;
JSON2Apex js=new JSON2Apex ();
JSON2Apex.Allocation alt=new JSON2Apex.Allocation();
alt.AppliedAmount='1.0';
alt.Invoice.InvoiceID='test';
js.Allocation=alt;String xmlInvoiceString = XeroXmlUtility.serialize(js, 'Allocations');
System.debug('*****************'+xmlInvoiceString);

And the Output structure is coming like below


<?xml version="1.0" encoding="UTF-8"?>
<Allocations>
  <Allocation>
     <AppliedAmount>1.0</AppliedAmount>
  </Allocation>
  <Invoice>
     <InvoiceID>test</InvoiceID>
  </Invoice>
</Allocations>

This Structure is not as expected there is some issue , Can any one know how to fix this.

from apex-for-xero.

danielbprobert avatar danielbprobert commented on June 17, 2024

i'm doing something similar but using

have you public class for allocation like this:

public class Allocation {
public String AppliedAmount;
public XeroInvoice Invoice;
}

from apex-for-xero.

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.