Invoice API has DueDate field as Optional but gives validation error when not supplied - invoice

I have an application that posts invoices to Xero.
In the Xero API spec for invoices it lists Due Date as an 'optional' field - see here:
https://developer.xero.com/documentation/api/accounting/invoices
However if I exclude the invoice field from my API JSON Request, I get the following error.
"ValidationErrors": [ { "Message": "Due Date cannot be empty" }
Doesn't appear that the Xero API behaves according to the API spec.
My solution, is to capture and store the payments terms when creating/updating contacts. Here is a sample of the payments terms that are returned when using the Contacts API:
"PaymentTerms": { "Sales": { "Day": 15, "Type": "OFFOLLOWINGMONTH" } }
I will also have to use the Organisation API to return the default PaymentTerms.
I then have to build some logic in my app something to the effect of:
IF MyStoredContact PaymentTerms = BLANK, THEN Use OrgPaymentTerms, ELSE Calculate DueDate from InvoiceDate using Contact PaymentTerms
This is not ideal, as I have to update my database, store additional information, testing etc.
My questions are:
Is there a better way of doing this?
If DueDate is a mandatory field in the invoices API, then why does this logic not already exist within Xero?
Any help would be appreciated.
As above, I tried to exclude the DueDate field from my API Request, however I get the following validation error back from Xero API:
"ValidationErrors": [ { "Message": "Due Date cannot be empty" }

DueDate is optional for DRAFT status but required for SUBMITTED and AUTHORISED statuses

Related

Query Rails Wildcard Enum Type

Trying to figure out how to utilize a "wildcard" feature with rails enums, where I don't want to have a dedicated int/symbol mapping for a number of variations of types.
For example, I have a ticketing system, where the majority of tickets are unanswered or answered, but the user can also set a custom status in special cases.
class Ticket
enum status: { unanswered: 0, answered: 1, *wildcard: 2 }
end
I'd like to be able to query for Ticket.where(status: :wildcard) and return all tickets with a status value of 2. Digging into the rails source code, I think I want to override.
I figure I can skip the assert_valid_value validations by having a before_save callback that converts any non-existent strings to the right status code, but how would I query?

graph api me/messages endpoint doesn't allow start and end DateTime in select list

I am trying to list down all my meetings with a certain email id. I only want to select few things out of the huge response. Duration is one of the main insight and it won't allow to return the start and end datetime.
URL:
https://graph.microsoft.com/v1.0/me/messages?$select=startDateTime,subject,from,sender,toRecipients&$search="participants:xyz#contoso.com and kind:meetings"
Error I am getting is
"message": "Could not find a property named 'startDateTime' on type 'Microsoft.OutlookServices.Message'
Is this expected?
Are you looking for how to query all meetings ? but your query is for messages. Can you please clarify?
If you are looking for help with messages from specific person along with created data time you can update your query like this -
https://graph.microsoft.com/v1.0/me/messages?$select=createdDateTime,Id,lastModifiedDateTime,from,subject&$filter=from/emailAddress/name eq 'XYZ A'

querying mails without categories not supported

We are trying to use Microsoft graph to query a mailbox and return us all uncategorized mails.
Following the OData spec here: https://docs.oasis-open.org/odata/odata/v4.0/errata03/os/complete/part2-url-conventions/odata-v4.0-errata03-os-part2-url-conventions-complete.html#_Toc453752358
We should be able to do something like this:
$filter=Categories/$count eq 0
But the call returns an operation not supported exception.
Is there another way to query for uncategorized Mail messages?
Querying mails without categories doesn't appear to be supported at this time. Please add a feature request to Microsoft Graph User Voice. I might as well share what I found in case it is useful to someone.
Unfortunately, the following doesn't work:
https://graph.microsoft.com/v1.0/me/mailFolders/inbox/messages?$filter=not categories/any()&$select=categories
https://graph.microsoft.com/v1.0/me/mailFolders/inbox/messages?$filter=categories/$count eq 0
This will return all mail with categories:
https://graph.microsoft.com/v1.0/me/mailFolders/inbox/messages?$filter=categories/any()&$select=categories
This will return all mail of a particular category:
https://graph.microsoft.com/v1.0/me/mailFolders/inbox/messages?$filter=categories/any(x:x eq 'particular category')&$select=categories

Multiple POST requests using Jmeter

I have to do a stress test on my application to create 1000 users. In order to create a user I do a POST request using a json:
{
"code": "string",
"domainName": "string",
"enabled": true,
"name": "string"
}
I can't figure out how I am going to create more than one user with jmeter. Is there a for loop? Also how do I get around the fact that code has to be unique so each user would need a unique code?
To create more virtual users just define as many as you like under Thread Group
To send unique data you can replace your code value with i.e. JMeter Function, something like:
{
"code": "${__threadNum}",
"domainName": "string",
"enabled": true,
"name": "string"
}
The above example uses __threadNum() function which basically returns current virtual user number, so code will be 1 for first user, 2 for second user, etc. You can also consider the following alternatives:
__Random() - generates a random string within the given range
__RandomString() - generates a random string from given source data
__UUID() - generates an unique GUI structure
counter() - generates an incrementing number each time being called
See Apache JMeter Functions - An Introduction for more information on JMeter Functions concept.
Yes, there is a Loop Controller and you can load data from CSV within that loop - have a look at this StackOverflow answer
Although using a loop would create your 1000 users, they would not execute at the same time. Assuming your intention is to execute a stress test with 1000 users doing requests concurrently a normal Thread Group would suffice.
You can use the CSV controller (http://jmeter.apache.org/usermanual/component_reference.html#CSV_Data_Set_Config) to set up the different users so each thread has its own user variables. There are other Thread group controllers that you can use if you want more elaborate behavior.

Quickbooks Online API Explorer only returns some Purchase

In QBO API explorer, for the Purchase API V3, when I tried to get all credit card transaction. The query I used was "select * from Purchase where PaymentType = 'CreditCard'". This only returned 4 transactions whose value for is true, in other words, they are refunds. My most recent charges were not returned. The default value for this attribute is False. When I manually made those as true then they showed up.
Is there a way around this? I don't understand why by default only the refunds were returned by my query. I want all credit card transactions, not just refunds.
https://developer.intuit.com/apiexplorer?apiname=V3QBO#Purchase
https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/030_entity_services_reference/purchase
Purchase entity query on PaymentType gives incorrect results. This is a known bug and will be resolved in our upcoming releases.
Bug number-QBO-35066
Refer-
https://developer.intuit.com/docs/0025_quickbooksapi/0058_faq/qbo_v3_known_issues

Resources