I am trying to insert a manual journal entry into Xero using below SQL insert statement. And I get the following error.
“A validation exception occurred: The total Debits (1.50) must equal total credits (0.00)" It suggests that cdata is not processing it as one API post but as 2 posts and Xero spits back an error because it expects both lines in the POST api.
Using a traditional insert in this case would result in a validation error. You’re correct to say that this is because the API calls for each insert are done individually and this results in an error since total debits =/= total credits
If I understand your use-case correctly, you need to insert multiple line items simultaneously. This can be done by using the JournalLineAggregate column. Please refer to this part of the driver’s documentation (under the INSERT sector)::
In your case, I believe you would need to use the following query:
INSERT INTO ManualJournals (Narration, JournalLineAggregate)VALUES ('Test1', '<JournalLine><LineAmount>1.50</LineAmount><AccountCode>620</AccountCode></JournalLine> <JournalLine><LineAmount>-1.50</LineAmount><AccountCode>611</AccountCode></JournalLine>');
This would issue an API request with the following POST body:
This website stores cookies on your computer. These cookies are used to collect information about how you interact with our website and allow us to remember you. We use this information in order to improve and customize your browsing experience and for analytics and metrics about our visitors both on this website and other media.
Review section III of our Privacy Policy for more information on cookies.
To opt out of “sale” or “sharing” of non-cookie data, visit our Privacy Rights Request Form.