QBFC and VBA - changing multiple employee earnings items via QBFC employeemod API - vba

I'm attempting to modify quickbooks desktop employees via the employeemod API. Everything is working except I can't make multiple pay rate updates for an employee. The documentation states that making one change will wipe out all current earnings items - which is fine, but only if I can add multiple pay rates back in. Instead it is only showing the last update when I run the code below. Is there a way to pass multiple pay rates for an employee using QBFC?
Set EmployeeMod = setRequest.AppendEmployeeModRq()
EmployeeMod.ListID.SetValue rsWageRates!EmployeeExternalReferenceKey '"80000001-1512843728"
EmployeeMod.EditSequence.SetValue "1654178687"
Dim vQBstr As IEarnings
Set vQBstr = EmployeeMod.EmployeePayrollInfoMod.OREarnings.EarningsList.Append()
vQBstr.PayrollItemWageRef.ListID.SetValue "8000000C-1204061990"
vQBstr.ORRate.Rate.SetValue "18.2"
vQBstr.PayrollItemWageRef.ListID.SetValue "8000000D-1204061990"
vQBstr.ORRate.Rate.SetValue "27.3"
Set setResponse = smgr.DoRequests(setRequest)

Related

QlikView set analysis with date: nothing result

I have a problem with a set analysis in QlikView with the date.
I have created a table that contains the sales order.
One field contains the dates of requesting products.
Now if I use a set analysis to filter the data, I receive 0.
The code used that is not working is below.
If I use a set analysis with one date (see below) I receive the orders that have that date in Ord.Original.Req.Date.
Any suggestion?
code not working:
sum({$< Ord.Campain={$(=(max(Ord.Campain)-1))},
Ord.Original.Req.Date = {"$(='<=' & Date(monthend($(vMaxDateAP)), 'DD/MM/YYYY')"}>}
Ord.T.Amm)
code working but with one date:
sum({$<[Ord.Original.Req.Date] ={'31/01/2018'}>}Ord.T.Amm)
try this
sum({$< Ord.Campain={"$(=max(Ord.Campain)-1)"}, Ord.Original.Req.Date = {"<=$(=Date(monthend($(vMaxDateAP)), 'DD/MM/YYYY'))"}>}Ord.T.Amm)

Use API to gather statistics on my followers

I am very new to this and would like to know how to start gathering statistics on my followers as I am currently growing my follower base. I am subscribed to several statistic tracking apps but none are really good.
I wish to track things such as:
Follower count by Location
Frequency distribution of followers and tags
Follower growth rate by Hour, Day, week, etc..
Follower Loss
Is this at all possible using APIs? Can anyone tell me how to get started?
There is no direct API call to get follower growth by hour and week, you have to get all followers every hour and store it in database and analyze for growth or loss every hour compared to previous hour and save it on the server.
You cannot get location of followers from API, you can may be estimate the location by checking for location in bio or analyzing all user posts and finding most posted location (this is expensive on API side and will have to make a lot of API calls to get analyze)
Yes, all this is possible to do using API, but it is a lot of work on backend, so if some service does this, it will cost you money cause they cannot do it for free, my guess is that you have checked all free or cheap services and they cannot do all this analysis for cheap.
You can get a broad breakdown of follower count in Google Sheets. This doesn't require API access so you won't get all of the data you are looking for, such as GEO. But, if you would like to see your follower increase by the hour, do this -
Open up a new Google Sheet
Go to Tools > Script Editor
Name your script 'IGFollowers'
In the code box, copy and paste this code below, but make sure to write this replace 'AccountName' with your username
var sheetName = "IGFollowers";
var instagramAccountName = "AccountName";
function insertFollowerCount() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("IGFollowers");
sheet.appendRow([Utilities.formatDate(new Date(), "PST", "yyyy-MM-dd"),
Utilities.formatDate(new Date(), "PST", "hh:mm"),
getInstagramFollowerCount(this.instagramAccountName)]);
};
function getInstagramFollowerCount(username) {
var url = "https://www.instagram.com/" + username + "/?__a=1";
var response = UrlFetchApp.fetch(url).getContentText();
return JSON.parse(response).user.followed_by.count;
}
Go to Run > InsertFollowerCount
NOTE: You may need to do a bit of formatting with the main Google Sheet, but this will get you some very long columns showing an increase in followers by the hour.

How can I set the pricelist discount to a product when I create a sale order line? In Odoo 9

I have a function who retrieves sale orders from an external server.
Then, I insert each sale order with order lines in the odoo database.
Everything is inserted fine, except the discount.
I have the pricelist in the sale order, with a discount (for example, a discount of 10% in every product), but in all the sale order lines the discount is 0%.
If I add a sale order line manually, the discount appears correctly (10%).
This is my code:
vals = {}
vals['order_id'] = downloaded_sale_order_id
vals['product_id'] = downloaded_product_id
vals['product_uom'] = downloaded_product_uom
new_line_id = self.env['sale.order.line'].create(vals)
I have entered in debug mode and realized that if I call some of these functions after the creation, the discount is applied
Option 1:
new_line_id.product_id_change()
Option 2:
new_line_id.product_uom_change()
But... why they are not called when I launch the create order?
Am I missing something in the code?
You have following options for set discount inside the sale order line while creating it from external server source.
1) Just set discount as like other parameter like uom, product, price etc from the source data of external server if you got discount value from their.
2) You have to call product or uom onchange method to set the discount based on the onchange calling and this is the default and safe method to set most of the data according to the onchange. It will not miss any special fields which are inside any customization with onchange method. I specially recommend this method to use if any discount data is not coming from external server source.
3) You can manage manually calculation of discount based on the external server source like price and qty etc. And set it inside sale order line.
I hope this is very helpful to you. Do not hesitate to ask any thing if not clear.

Get all QuickBooks Online accounts regardless of active status

I'm trying to retrieve all the accounts from a company by using the DataService.FindAll(...) method but it only seems to be returning active accounts. Is there a way to get all the accounts regardless of the active status?
I know I've got inactive accounts because I purposely put them there to test and such.
My current line looks like this:
Dim accounts As List(Of Intuit.Ipp.Data.Account) = ds.FindAll(New Intuit.Ipp.Data.Account()).ToList()
I've also tried adding a ... With {.Active = False}... in there too just to see if that would find all that are inactive. Still nothing.
Am I overlooking something or should this work and get me all accounts?
Thanks for any help.
Also, I'm using Intuit's .NET SDK with VB.NET.
You can try this -
SELECT * FROM Account WHERE Active IN (true, false)
ApiExplorer - https://developer.intuit.com/apiexplorer?apiname=V3QBO#Account
JAVA Code
Account account = GenerateQuery.createQueryEntity(Account.class);
String accountQuery = select($(account)).where($(account.isActive()).in(new Boolean[]{true, false})).generate();
service.executeQuery(accountQuery);
Thanks

Can I use the the power of Generics to solve my issue

I have a wierd issue. I am loading 1k invoice objects, header first then details in my DAL. I am using VB.NET on this project. I am able to get the invoice headers just fine. When I get to loading the details for each invoice I am getting a timeout on SQL Server. I increased the timeout to 5 minutes but still the same thing. If I reduce the invoice count to 200 it works fine.
Here is what I am doing
//I already loaded the invoice headers. I am now iterating each invoice to get it's detail
For Each invoice As Invoice In invoices
drInvoiceItems = DBSqlHelperFactory.ExecuteReader(CONNECTION_STRING, CommandType.StoredProcedure, "dbo.getinvoiceitem", _
New SqlParameter("#invoicenumber", invoice.InvoiceNumber))
While drInvoiceItems.Read()
invoice.LineItems.Add(New InvoiceLine(drInvoiceItems("id"), drInvoiceItems("inv_id"), drInvoiceItems("prodid"), drInvoiceItems("name"), drInvoiceItems("barcode"), drInvoiceItems("quantity"), drInvoiceItems("costprice")))
End While
Next
Return invoices
I am aware that I am firing 1k connections to the DB due to the iterations. Can't I load all the line items with one select statement and then do something like
For Each invoice As Invoice In invoices
invoice.Items.Add(invoiceItems.Find(Function(i as InvoiceItem),i.InvoiceNumber = invoice.InvoiceNumber))
Next
I get the error whenusing the lambda funcion above
Error 1 Value of type 'System.Collections.Generic.List(Of BizComm.InvoiceLine)' cannot be converted to 'BizComm.InvoiceLine'. C:\Projects\BizComm\InvoiceDAL.vb 75 35 BizComm
One thing I have done when iterating through items in the past is use the same Connection object for all the necessary read activities. It seems to greatly enhance performance.
I'd also look at the database to see whether the dbo.getinvoiceitem procedure can be improved, or if another procedure can be written which will give you all the line items for a group of invoices (perhaps by date or customer/vendor) rather than just one header at a time. Then you can more effectively apply your iteration over the invoice collection and add the lines to the headers.
You can also check to see whether there is an effective index on column that the #invoicenumber parameter references.
From your code, it looks like you are not closing the connections and datareaders. See if you can place your connections and datareaders in a USING statement:
Using con As New SqlConnection(connectionString)
....
End Using
The DBSqlHelperFactory opens a connection, but can't close it since the connection is needed after its return. I'd modify the code, so that you open one connection and pass it to DBSqlHelperFactory as a parameter.
To quickly pick up these issues, I always debug with:
Max Pool Size=1;
added to the end of the connection string. That will quickly throw an error any time you forget to close a connection.
Why load InvoiceItems before hand? Can't you load it on demand?
i.e. when you need to get the Items, call a method on Invoice instance (myInvoice.GetItems)
EDIT: It will be better to understand the full picture of what you are trying to do.
Is it really required to get all Invoices as well?
Why not select all the line items for all the invoices you need in a single query. then split the results up into multiple invoice objects?
Re: how do I map between collections?
One implementation could be: create 1000 anemic Invoice object, chuck them in a Dictionary which goes from Id to Invoice. Then when you select the line items you include the invoice id, look up the anemic invoice and add the line to it.