Need list of cancelled/voided/deleted transactions - intuit-partner-platform

I have an ETL set up to pull SalesReceipts, Invoices, and CreditMemos into our own data warehouse. However, if a transaction in the past has been voided/deleted this will cause our numbers to be off. I have not found a way to get a list of invalidated transactions and I'd prefer not to have to pull all transactions for all time for each invocation of the ETL.
More details:
Our data is in QBO and I am using the Java API provided by Intuit.
I have reviewed the API (both the online endpoint API as well as the Java API) and I have not found much to work with.
Here is an example of a query for Invoice data:
<page loop>
{
Invoice invoice = GenerateQuery.createQueryEntity(Invoice.class);
String query = select($(invoice)).skip(page * PAGE_SIZE).take(PAGE_SIZE).generate();
QueryResult result = dataService.executeQuery(query);
for (IEntity entity : result.getEntities())
{
Transaction t = (Transaction) entity;
System.out.println(t.getStatus());
}
}
However I never encounter any of our cancelled/voided/deleted transactions with this query and the transaction status may not be used in the where filter.
EDIT #2
I believe I have found what I need in the Change Data Capture service.
https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/020_key_concepts/00600_changedata_operation
Some code:
List<IEntity> entities = new ArrayList();
entities.add(new SalesReceipt());
entities.add(new Invoice());
entities.add(new CreditMemo());
List<CDCQueryResult> cresult = dataService.executeCDCQuery(entities, "2011-12-01T00:00:00Z");
...
This will return all transactions that have changed (modified, added, deleted) since the date specified, though what's VERY odd to me is that if I use the date string "2011-12-01T0:0:0Z" I get only transactions with the DELETED state.
For reference:
"2011-12-01T00:00:00Z": all added, modified, deleted transactions.
"2011-12-01T0:0:0Z": only deleted transactions.
Thanks

Preston,
If you are using QuickBooks Desktop you need to use the QBXML SDK v13 to access transactions, if you are using QuickBooks Online you can use QBO v3 REST API.
QBO:
https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services
QBD:
https://developer.intuit.com/docs/0250_qb
regards,
Jarred

Related

How to avoid customer's order history being changed in MongoDB?

I have two collections
Customers
Products
I have a field called "orders" in each of my customer document and what this "orders" field does is that it stores a reference to the product Id which was ordered by a customer, now my question is since I'm referencing product Id and if I update the "title" of that product then it will also update in the customer's order history since I can't embed each order information since a customer may order thousands of products and it can hit 16mb mark in no time so what's the fix for this. Thanks.
Create an Orders Collection
Store ID of the user who made the order
Store ID of the product bought
I understand you are looking up the value of the product from the customer entity. You will always get the latest price if you are not storing the order/price historical transactions. Because your data model is designed this way to retrieve the latest price information.
My suggestion.
Orders place with product and price always need to be stored in history entity or like order lines and not allow any process to change it so that when you look up products that customers brought you can always get the historical price and price change of the product should not affect the previous order. Two options.
Store the order history in the current collection customers (or top say 50 order lines if you don't need all of history(write additional logic to handle this)
if "option1" is not feasible due to large no. of orders think of creating an order lines transaction table and refer order line for the product brought via DBref or lookup command.
Note: it would have helped if you have given no. of transactions in each collection currently and its expected rate of growth of documents in the collection QoQ.
You have orders and products. Orders are referencing products. Your problem is that the products get updated and now your orders reference the new product. The easiest way to combat this issue is to store full data in each order. Store all the key product-related information.
The advantage is that this kind of solution is extremely easy to visualize and implement. The disadvantage is that you have a lot of repetitive data since most of your products probably don't get updated.
If you store a product update history based on timestamps, then you could solve your problem. Products are identified now by 3 fields. The product ID, active start date and active end date. Or you could configure products in this way: product ID = product ID + "Version X" and store this version against each order.
If you use dates, then you will query for the product and find the product version that was active during the time period that the order occurred. If you use versions against the product, then you will simply query the database for the particular version of the product itself. I haven't used mongoDb so I'm not sure how you would achieve this in mongoDb exactly. Naively however, you can modify the product ID to include the version as well using # as a delimiter possibly.
The advantage of this solution is that you don't store too much of extra data. Considering that products won't be updated too often, I feel like this is the ideal solution to your problem

Azure Mobile app service & EF Table Column Restriction?

I am using an Azure Mobile app service with Odata and Entity Framework. I have table that has around 90 columns and it doesn't work unless i comment out some of the columns in the data model. It doesn't matter what columns I comment out a query won't work if with all the columns.
The azure mobile service debugger tells me:
"An unhandled exception of type 'System.StackOverflowException' occurred in EntityFramework.dll" The odata query works fine and returns 200 ok but then the EF talking to the SQL (it's an azure sql server) has a freakout and never returns anything... until i remove some columns from the datamodel.
This is just with the datamodels and tablecontrollers defined out of the box and i'm sending queries with Postman. I have 20 other tables in this service that work perfectly. I can't find a size limit or anything base on number of columns you can use with this. Any help is awesome.
Postman gives me:
"502 - Web server received an invalid response while acting as a gateway or proxy server" but that is too generic to trace. looked in all the azure logs that are possible and nothing. just said there was an error
I would recommend you Enable diagnostics logging for your mobile app to collection the detailed error message. Also, you could modify your TableController and log the detailed SQL statement as follows:
protected override void Initialize(HttpControllerContext controllerContext)
{
base.Initialize(controllerContext);
var context = new MobileServiceContext();
//add this line
context.Database.Log += (msg) =>
{
System.Diagnostics.Trace.TraceInformation($"{msg}{Environment.NewLine}");
};
DomainManager = new EntityDomainManager<Message>(context, Request);
}
Also, you could execute your relevant SQL statement via SSMS and check the query execution plan to narrow this issue. Moreover, for your mobile client, you could only retrieve the specific columns from your remote table. Here the code snippet for C#:
var query =
from r in table.CreateQuery()
select new { r.Text, r.Complete, r.UpdatedAt, r.Version };
After 8 months of randomly trying I actually got it working!
Instead of returning the IQueryable directly from the helper that's built into the AzureMobileServiceServer namespace convert it to an IEnumerable, then re-select everything then change it back to an IQueryable.
No idea why this works but it negates the stackoverflow problem that is happening otherwise. I think this adds a bit more time when syncing offline but if it works I'll take it.
public IQueryable<ItemLibrary> GetAllItemLibrarys()
{
// return Query(); // !! this is the original from the table controller
return Query().AsEnumerable()
.Select(s => s).AsQueryable(); // !! replace with this
}

Entity framework get customers by zip code

So I have by entity framework 5 set up. I have a Customers table in the database. What would be most efficient way to get customers of a given zip code for example 94023? I have this:
var customersOfLosAltos =
(myDbContext.CreateObjectSet<Customer>()).Where(c=>c.Zip == "94023");
But, intuitively, that seems pretty inefficient because as I understand it, it basically retrieves all customers from the data source, and then filter it out by the given zip. It might be OK if I only have a few hundred customers, what if I have a million customers?
Any thoughts? Thanks.
as I understand it, it basically retrieves all customers from the data source, and then filter it out by the given zip.
Your understanding is wrong. Entity framework turns your code in to a SQL query, so what the server actually returns is the result for the query
select * from Customer where Zip = '94023'
If you changed your code to
var customers = myDbContext.CreateObjectSet<Customer>().ToList();
var customersOfLosAltos= customers.Where(c=>c.Zip == "94023");
then because of that .ToList() it now does a unfiltered query to the database then in memory filters on the client it to just the customers you want. This is why you want to try to keep your query as a IQueryable for as long as possible before you get the results because any tweaks or changes you make to the query propagate back to the query performed on the server.
To make your query even more efficient you could add a Select clause
var lastNamesOfCustomersOfLosAltos = (myDbContext.CreateObjectSet<Customer>())
.Where(c=>c.Zip == "94023")
.Select(c=>c.LastName);
The SQL server now performs the query (when you retreive the results via a ToList(), or in a foreach, or via a .AsEnumerable(), ect.)
select LastName from Customer where Zip = '94023'

API V3 CustomSalesTax

I am currently testing V3 of the API with QBO.
Creating an invoice that includes tax is fine if the TxnTaxDetail includes a TxnTaxCodeRef that exists in QBO.
However I noticed when pulling the list of tax codes from QBO that there is a special one called CustomSalesTax.
Can this CustomSalesTax be used to add a custom sales tax to an invoice ?. For instance, I'd supply the TotalTax = 1000, TaxLine.Amount=1000, TaxLine.TaxLineDetail.PercentBased=false in order to add 1000 of tax to the invoice.
Thanks
Fernando
CustomSalesTax is a special id that represents the old US tax model. So this can be used to update any old transactions that are tied to old US tax model. Cannot create new transactions using this CustomSalesTax.
Thanks

Getting multiple invoices from intuit anywhere api at once

When I update an invoice in QB (after its been changed in my system), I want to avoid updating anything that the user has modified in QB. My plan was to use the filter API method and filter by Ids to get the list of invoices from QB that my app created. However, it doesn't look like InvoiceFilter accepts ListIdSet. It does have a TransactionIdSet, but I can't find a way to get ahold of that number (i.e., the TransactionId) via Data Services. It's certainly not in the response when invoices are read. So, how do I query for a specific set of invoices via the API?
The transaction id refers to the id of the invoice here.
For eg, the following invoice query will retrieve the invoice with Id 4 -
<InvoiceQuery xmlns="http://www.intuit.com/sb/cdm/v2">
<TransactionIdSet>
<Id idDomain="QB">4</Id>
</TransactionIdSet>
</InvoiceQuery>