Creating a Bill with .NET IPP Data Services SDK - intuit-partner-platform

I have a SaaS application that creates expenses within QuickBooks Online. In the the IPP documentation (https://ipp.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/0400_QuickBooks_Online/Bill) it shows that on a line object you can specify the AccountID (its the last field in the documentation) and that is required to create an account-based expense.
However, in the .NET object for BillLine, there appears to be no way to specify that data. Does anyone know how to create an "Account-based Bill Expense" using the .NET SDK?

Intuit.Ipp.Data.Qbo.BillLine billLine = new Intuit.Ipp.Data.Qbo.BillLine();
billLine.ItemsElementName = new ItemsChoiceType1[] {ItemsChoiceType1.AccountId, ItemsChoiceType1.AccountName};
billLine.Items = new object[] {new IdType() {idDomain = idDomainEnum.QB, Value = "123"}, "MyAccountName"};
Any properties that are not exposed directly are defined in the ItemsElementName property, and the value is passed in the respective index in the Items object array. You will see this across most entities in the .NET DevKit.

Related

Shopware 6 Plugin - Load and display ProductStream via id

I want to load ProductStream data via a given id and display it in the frontend, for example below the product cart.
The ProductStream is not linked to a ProductCrossSelling and therefore not linked to a product.
I loaded a ProductStream Collection via the repository.
$criteria = new Criteria($producStreamIds);
$productStreamResult = $this->productStreamRepository->search($criteria, $context);
$productStreams = $productStreamResult->getEntities();
Now I need the associated list of products, to include them via cms-element-product-slider.html.twig.
I found a post with a similar question:
How to get products from the product stream ID in Shopware 6?
The answer was, to use the function loadByStream of Core\Content\Product\SalesChannel\CrossSelling\ProductCrossSellingRoute.php, but this function is private.
The only public function is load and it needs a $productId as a parameter, which I do not have, because my ProductStream is not linked to a product.
Is there a clean way to load products of a ProductStream that is not linked to a ProductCrossSelling?
I have currently copied the code of the loadByStream function to load the products for the stream.
Or is there an other function in the shopware core that I can use for this case. I haven't found anything else.
It feels as if the current assumption is that ProductStreams are not used without connection to a ProductCrossSelling and thus to a product.
A product stream is really just a collection of criterium filters. You inject ProductStreamBuilder and call buildFilters with the id of your product stream to retrieve the filters. Then you use the filters as normal with your criteria, add a limit, sorting etc and fetch your product entities.
// <argument type="service" id="Shopware\Core\Content\ProductStream\Service\ProductStreamBuilder"/>
private ProductStreamBuilderInterface $productStreamBuilder;
// <argument type="service" id="sales_channel.product.repository"/>
private SalesChannelRepositoryInterface $productRepository;
// ..
$filters = $this->productStreamBuilder->buildFilters(
$productStreamId,
$salesChannelContext->getContext()
);
$criteria = new Criteria();
$criteria->addFilter(...$filters);
$products = $this->productRepository
->search($criteria, $salesChannelContext)
->getEntities();

QBO Queries and SpecifyOperatorOption

I'm trying to query QBO for, among other entities, Accounts, and am running into a couple of issues. I'm using the .Net Dev Kit v 2.1.10.0 (I used NuGet to update to the latest version) and when I use the following technique:
Intuit.Ipp.Data.Qbo.AccountQuery cquery = new Intuit.Ipp.Data.Qbo.AccountQuery();
IEnumerable<Intuit.Ipp.Data.Qbo.Account> qboAccounts = cquery.ExecuteQuery<Intuit.Ipp.Data.Qbo.Account>(context);
(i.e. just create a new AccountQuery of the appropriate type and call ExecuteQuery) I get an error. It seems that the request XML is not created properly, I just see one line in the XML file. I then looked at the online docs and tried to emulate the code there:
Intuit.Ipp.Data.Qbo.AccountQuery cquery = new Intuit.Ipp.Data.Qbo.AccountQuery();
cquery.CreateTime = DateTime.Now.Date.AddDays(-20);
cquery.SpecifyOperatorOption(Intuit.Ipp.Data.Qbo.FilterProperty.CreateTime,
Intuit.Ipp.Data.Qbo.FilterOperatorType.AFTER);
cquery.CreateTime = DateTime.Now.Date;
cquery.SpecifyOperatorOption(Intuit.Ipp.Data.Qbo.FilterProperty.CreateTime,
Intuit.Ipp.Data.Qbo.FilterOperatorType.BEFORE);
// Specify a Request validator
Intuit.Ipp.Data.Qbo.AccountQuery cquery = new Intuit.Ipp.Data.Qbo.AccountQuery();
IEnumerable<Intuit.Ipp.Data.Qbo.Account> qboAccounts = cquery.ExecuteQuery<Intuit.Ipp.Data.Qbo.Account>(context);
unfortunately, VS 2010 insists that AccountQuery doesn't contain a definition for SpecifyOperatorOption and there is no extension method by that name. So I'm stuck.
Any ideas how to resolve this would be appreciated.

CRM 2011 using organization.svc as a web reference

In CRM 4, I used to add web reference in my visual studio project of the CRMService.asmx and it would bring me all the entities (including custom entities) and all the services.
Now I've moved to CRM 2011 and I dont really understand complitely how it works over here..when I add the web reference of organization.svc it won't add my custom entities, when I use the crmSvcUtil.exe then it generates classes for all the entities (including the custom entities) but no services..So how do I work with organization.svc in CRM 2011? Do I just need to use crmSvcUtil or combine it with the web reference of organization.svc?
In CRM 2011 you dont add a reference to the webservice as you did in CRM 4. If you want early bound entity classes then you will have to generate this with the crmsvcutil.exe. If you are going to use LINQ to query your CRM data then add the /serviceContextName:contextname and a OrganizationServiceContext will be generated in the code file.
If you dont care about early bound entity classes then you can use the entity class. In 2011 you use the entity class insted of what was called DynamicEntity in CRM 4.
In order to do anything with CRM 2011 you will have to add some references to your project, you will find them in the bin folder where you have the sdk.
You will always add a reference to Microsoft.Xrm.Sdk. If you will use early bound you will also need a reference to Microsoft.Crm.Sdk.Proxy.
And from the standard .Net libraries you will have to add references to System.ServiceModel and System.Runtime.Serialization
To connect to CRM 2011 you will use the OrganizationServiceProxy.
var organizationUri = new Uri("http://<servername>/<organizationname>/XRMServices/2011/Organization.svc");
var credentials = new ClientCredentials();
var serviceProxy = new OrganizationServiceProxy(organizationUri, null, credentials, null);
// If you use early bound entity classes, you have to include the line below. Not needed on late bound
serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());
Then by using the serviceproxy already created I can start working with the CRM data.
For creating an account:
var account = new Account();
account.Name = "Testing";
serviceProxy.Create(account);
Some link for futher reading:
DiscoveryService
Using the IOrganizationService
Using Organization Service Context

How do I get the Resource Usage view using the PSI 2007

Please excuse me if I use incorrect terms or concepts. Seems I am in the mist of a crash course on MS Project, Project Server, and the PSI...
Project Professional provides the Resource Usage view that lists a given Resource, the Tasks they have been assigned to, and the amount of scheduled Work for a given day.
Is this information available in Project Server and how would I read it using the PSI?
Thanks.
Jason
If you're just getting started with PSI, I'd strongly recommend downloading and using the ProjTool app that is part of the Project 2007 SDK.
I haven't done too much work with Resources, but after taking a quick look.. here is how I'd approach it:
Reference the Project.asmx service (ex: http://servername/pwa/_vti_bin/psi/Project.asmx)
Use the ReadProjectEntities method to retrieve a DataSet and pass it a ProjectEntityType of Task, Assignment and Resource.
Define some entity types:
public const int ENT_TYPE_TASK = 2;
public const int ENT_TYPE_RESOURCE = 4;
public const int ENT_TYPE_ASSIGNMENT = 8;
Then you can read the data:
int entity = ENT_TYPE_TASK | ENT_TYPE_ASSIGNMENT | ENT_TYPE_RESOURCE;
ProjectDataSet dataSet = project.ReadProjectEntities(projectUid, entity, DataStoreEnum.PublishedStore);
// do stuff with these tables...
//dataSet.Task
//dataSet.Assignment
//dataSet.ProjectResource
ReadProjectEntities is nice because you can read only the part of the project you need... if you need more than the Task table then you can use a logical OR to get additional ProjectEntityTypes.
As for the assigned work, it looks like that is also in the Assignment table, but I think you'll have to do some calculating.

EF 4 Self Tracking Entities does not work as expected

I am using EF4 Self Tracking Entities (VS2010 Beta 2 CTP 2 plus new T4 generator). But when I try to update entity information it does not update to database as expected.
I setup 2 service calls. one for GetResource(int id) which return a resource object. the second call is SaveResource(Resource res); here is the code.
public Resource GetResource(int id)
{
using (var dc = new MyEntities())
{
return dc.Resources.Where(d => d.ResourceId == id).SingleOrDefault();
}
}
public void SaveResource(Resource res)
{
using (var dc = new MyEntities())
{
dc.Resources.ApplyChanges(res);
dc.SaveChanges();
// Nothing save to database.
}
}
//Windows Console Client Calls
var res = service.GetResource(1);
res.Description = "New Change"; // Not updating...
service.SaveResource(res);
// does not change anything.
It seems to me that ChangeTracker.State is always show as "Unchanged".
anything wrong in this code?
This is probably a long shot... but:
I assume your Service is actually in another Tier? If you are testing in the same tier you will have problems.
Self Tracking Entities (STEs) don't record changes until when they are connected to an ObjectContext, the idea is that if they are connected to a ObjectContext it can record changes for them and there is no point doing the same work twice.
STEs start tracking once they are deserialized on the client using WCF, i.e. once they are materialized to a tier without an ObjectContext.
If you look through the generated code you should be able to see how to turn tracking on manually too.
Hope this helps
Alex
You have to share assembly with STEs between client and service - that is the main point. Then when adding service reference make sure that "Reuse types in referenced assemblies" is checked.
The reason for this is that STEs contain logic which cannot be transfered by "Add service reference", so you have to share these types to have tracing logic on client as well.
After reading the following tip from Daniel Simmons, the STE starts tracking. Here is the link for the full article. http://msdn.microsoft.com/en-us/magazine/ee335715.aspx
Make certain to reuse the Self-Tracking Entity template’s generated entity code on your client. If you use proxy code generated by Add Service Reference in Visual Studio or some other tool, things look right for the most part, but you will discover that the entities don’t actually keep track of their changes on the client.
so in the client make sure you don't use add service reference to get the proxy instead access service through following code.
var svc = new ChannelFactory<IMyService>("BasicHttpBinding_IMyService").CreateChannel();
var res = svc.GetResource(1);
If you are using STEs without WCF you may have to call StartTracking() manually.
I had the same exact problem and found the solution.
It appears that for the self-tracking entities to automatically start tracking, you need to reference your STE project before adding the service reference.
This way Visual Studio generates some .datasource files which does the final trick.
I found the solution here:
http://blogs.u2u.be/diederik/post/2010/05/18/Self-Tracking-Entities-with-Validation-and-Tracking-State-Change-Notification.aspx
As for starting the tracking manually, it seems that you do not have these methods on the client-side.
Hope it helps...