Author Topic: Create multiple line items  (Read 209 times)

mearsb

  • Newbie
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Create multiple line items
« on: February 18, 2018, 08:00:20 PM »
Hi,
I am using powershell to create an invoice in xero using ChilkatDotNet2.dll.  The Invoice creates successfully but I need to add multiple line items to it. The XML is:

<Invoices>
  <Invoice>
    <LineItems>
      <LineItem>
        <Description>3 copies of OS X 10.6 Snow Leopard</Description>
        <Quantity>3.0000</Quantity>
        <UnitAmount>59.00</UnitAmount>
        <TaxType>OUTPUT</TaxType>
        <TaxAmount>19.67</TaxAmount>
        <LineAmount>177.00</LineAmount>
        <AccountCode>200</AccountCode>
      </LineItem>
      <LineItem>
        <Description>Returned Apple Keyboard with Numeric Keypad (faulty)</Description>
        <Quantity>1.0000</Quantity>
        <UnitAmount>-79.00</UnitAmount>
        <TaxType>OUTPUT</TaxType>
        <TaxAmount>-8.78</TaxAmount>
        <LineAmount>-79.00</LineAmount>
        <AccountCode>200</AccountCode>
        <Tracking />
      </LineItem>
    </LineItems>
  </Invoice>
</Invoices>



Adding one line item works using:
$xml.NewChild2("Invoice|LineItems|LineItem|Description","3 copies of OS X 10.6 Snow Leopard")
$xml.NewChild2("Invoice|LineItems|LineItem|Quantity","3.0000")
$xml.NewChild2("Invoice|LineItems|LineItem|UnitAmount","59.00")
$xml.NewChild2("Invoice|LineItems|LineItem|TaxType","OUTPUT")
$xml.NewChild2("Invoice|LineItems|LineItem|TaxAmount","19.67")
$xml.NewChild2("Invoice|LineItems|LineItem|LineAmount","177.00")
$xml.NewChild2("Invoice|LineItems|LineItem|AccountCode","200")

But if I add a second one it fails:
<Message>The element 'Description' was not recognised. Ensure the element name has the correct case and that there are no duplicate elements of the same name.</Message>

What is the correct syntax to add multiple items that are all under the same element?

Thanks
Ben