-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple TrackingCategory Not Possible #31
Comments
It would appear using /**
* Created by psenger on 1/08/2016.
*/
const describe = require('mocha').describe,
it = require('mocha').it,
expect = require('chai').expect,
EasyXml = require('easyxml'),
inflect = require('inflect');
describe('EASYXML:', () => {
it('Should work', function ( ) {
let tc1 = {
Name: {"_": "Melbourne"},
Option: {"_": "e44c3446-b741-4717-9710-057c1fc14603"},
TrackingCategoryID: {"_": "bf8a9440-37bd-44fd-ab97-f207a2588ac1"}
};
let tc2 = {
Name: {"_": "Virtual Reality Design"},
Option: {"_": "c712bb31-2d5e-470f-90da-70f2cc6fe595"},
TrackingCategoryID: {"_": "2d002487-1540-442d-bb8a-b2d7d3ff11c7"}
};
let anInvoice = {
"Type": "ACCREC",
"Contact": {
"ContactID": "d0edfa00-7eab-4737-a8b2-bc1389b56a50"
},
"Reference": "UXE001-D189719D",
"DueDate": "2017-12-07",
"Status": "SUBMITTED",
"LineAmountTypes": "Inclusive",
"LineItems": {
"LineItem": [
{
"Description": "User Experience Elevate",
"Quantity": "1",
"UnitAmount": 1000,
"AccountCode": "200",
"TaxType": "OUTPUT",
"Tracking": {
"TrackingCategory": [
tc1,
tc2
]
}
},
{
"Description": "User Experience Elevate",
"Quantity": "1",
"UnitAmount": 2000,
"AccountCode": "200",
"TaxType": "OUTPUT",
"Tracking": {
"TrackingCategory": [
tc1,
tc2
]
}
}
]
}
};
let root = 'Invoices';
let desired = '<?xml version=\'1.0\' encoding=\'utf-8\'?>\n' +
'<Invoice>\n' +
' <Type>ACCREC</Type>\n' +
' <Contact>\n' +
' <ContactID>d0edfa00-7eab-4737-a8b2-bc1389b56a50</ContactID>\n' +
' </Contact>\n' +
' <Reference>UXE001-D189719D</Reference>\n' +
' <DueDate>2017-12-07</DueDate>\n' +
' <Status>SUBMITTED</Status>\n' +
' <LineAmountTypes>Inclusive</LineAmountTypes>\n' +
' <LineItems>\n' +
' <LineItem>\n' +
' <Description>User Experience Elevate</Description>\n' +
' <Quantity>1</Quantity>\n' +
' <UnitAmount>1000</UnitAmount>\n' +
' <AccountCode>200</AccountCode>\n' +
' <TaxType>OUTPUT</TaxType>\n' +
' <Tracking>\n' +
' <TrackingCategory>\n' +
' <Name>Melbourne</Name>\n' +
' <Option>e44c3446-b741-4717-9710-057c1fc14603</Option>\n' +
' <TrackingCategoryID>bf8a9440-37bd-44fd-ab97-f207a2588ac1</TrackingCategoryID>\n' +
' </TrackingCategory>\n' +
' <TrackingCategory>\n' +
' <Name>Virtual Reality Design</Name>\n' +
' <Option>c712bb31-2d5e-470f-90da-70f2cc6fe595</Option>\n' +
' <TrackingCategoryID>2d002487-1540-442d-bb8a-b2d7d3ff11c7</TrackingCategoryID>\n' +
' </TrackingCategory>\n' +
' </Tracking>\n' +
' </LineItem>\n' +
' <LineItem>\n' +
' <Description>User Experience Elevate</Description>\n' +
' <Quantity>1</Quantity>\n' +
' <UnitAmount>2000</UnitAmount>\n' +
' <AccountCode>200</AccountCode>\n' +
' <TaxType>OUTPUT</TaxType>\n' +
' <Tracking>\n' +
' <TrackingCategory>\n' +
' <Name>Melbourne</Name>\n' +
' <Option>e44c3446-b741-4717-9710-057c1fc14603</Option>\n' +
' <TrackingCategoryID>bf8a9440-37bd-44fd-ab97-f207a2588ac1</TrackingCategoryID>\n' +
' </TrackingCategory>\n' +
' <TrackingCategory>\n' +
' <Name>Virtual Reality Design</Name>\n' +
' <Option>c712bb31-2d5e-470f-90da-70f2cc6fe595</Option>\n' +
' <TrackingCategoryID>2d002487-1540-442d-bb8a-b2d7d3ff11c7</TrackingCategoryID>\n' +
' </TrackingCategory>\n' +
' </Tracking>\n' +
' </LineItem>\n' +
' </LineItems>\n' +
'</Invoice>\n' +
'';
let post_body = new EasyXml({rootElement: inflect.singularize(root), rootArray: 'Invoices', manifest: true, unwrappedArrays: true}).render(anInvoice);
expect(post_body).to.equal(desired)
});
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
According to the XERO Developer SDK Regarding TrackingCategory and thier support team. You should be able to submit up to Two Tracking Categories per Line Item in an Invoice. However, it would appear using
easyxml
actually prevents this API from properly forming the following valid XML:Attempt 1
Testing the following JSON to find it produces the following XML:
Attempt 2
Testing the following illegal JSON to find it produces the following XML:
Attempt 3
Testing the following JSON to find it produces the following XML:
Reviewing the docs at easyxml and the test cases. This api simply can not creat the require xml shape.
The text was updated successfully, but these errors were encountered: