Vb.net 2010 Reading sub properties of an object in reportViewer - vb.net

I am creating some reports using object datasources.
I have the following scenario:
in my software the user can create a list of products specifying a code, the product name, the price and the vat rate (this last two attributes will be used as suggestions when the user will place the product inside an order).
When a user creates an order he can place products within it by specifying for each product the quantity and he can also override the suggested price and the vat rate.
So basically i have two models to represent the products:
ProductModel (used to define product name, product code and the default suggestion for price and vat rate)
OrderProductModel (used to place products within an order, specify the quantity and override the default product suggestion for price and vat number)
ProductModel:
id
code
name
price
vat
OrderProductModel:
id
order (reference to an OrderModel object)
product (reference to a ProductModel to read the code and the name and the suggestions for price and vat rate)
quantity
price
vat
Now what I need to do with my report is to fill a table of OrderProduct objects and show the following informations for each product:
code (orderProduct.product.code)
name (orderProduct.product.name)
price (orderProduct.price)
quantity (orderProduct.quantity)
(suppose orderProduct is an instance of OrderProductModel)
Now the question is "how to define the report rule to access to code and name?"...
I am using visual studio 2010 and by reading here: http://www.gotreportviewer.com/objectdatasources/index.html
they says that the syntax: =Fields!Object.Value.attribute no longer works...
I tought i could solve the problem by adding to the OrderProductModel some properties that will read the properties of the related ProductModel instance.
But i'm sure there are better way that does not break the model...

Just an update to this, its now fixed in SP1. The requirement to get it to work is to make sure ALL classes used in properties of the datasource are serializable.
more info at:
http://wraithnath.blogspot.com/2011/04/reportviewer-object-datasource-nested.html

I found that this is a bug...
if you make all your object serializable this should be fixed in the SP1 ...
read more here: http://blogs.msdn.com/b/brianhartman/archive/2010/10/27/nested-objects-in-local-mode.aspx

Related

PrestaShop add to cart from custom module

I ma working on PrestaShop module, where the user can select some parameters on front view.
I need to add product to cart, including custom price, and selected parameters.
How should I do this? I don't want to override deafult behavior, as not all products will use my component.
Any help would be awesome.
Have a nice day, Bartek.
adding a product to a cart is pretty simple :
First create an empty cart :
$cart=new Cart();
... here you can set your cart properties id_address / id_carrier etc...
$cart->add();
Or, if you already have a cart to use just load the Cart object with its ID and perform :
$cart->updateQty($quantity, $id_product, $id_product_attribute, false);
$cart->update();
You should repeate the updateQty() method for each product / qties you'd need to add to the cart.
In order to customize product prices in cart you have to create product "specific prices" using the SpecificPrice object and bind them to that id_cart :
$mySpecificPrice = new SpecificPrice();
$mySpecificPrice->id_cart = $cart->id;
... add your discount / id_product here on specific price here ...
$mySpecificPrice->add();
Note that you can only set price discounts with SpecificPrice , surcharges are not allowed and will trigger an exeception.
If you need to increase your prices without any core modification, you'll forced to generate an Order and edit the order prices afterward.

Prestashop Multistore - local product attributes cost overwritten by default shop

My question is related to already solved issue where saving product in "All shops" context made prices in all shops the same no matter the currency. So if product in Poland would cost for example 100 PLN, then in Germany 100 EUR and in Great Britain 100 GBP. Link to this topic:
Prestashop Multistore - local store prices are overwritten with price from default shop
Anyways the provided solution doesn't cover this very same problem of product combinations additional costs. So I want to ignore those fields when saving product in "All shops" context.
Does anyone know how to solve it??
I achieved it by editing overriden Product.php (from /classes/Product.php) - funtion updateAttribute (around line 1800+). I took it's body, except return, into an if statement:
public function updateAttribute(...) {
if (Shop::getContext() == Shop::CONTEXT_SHOP){
// function body here
}
return true;
}
Now when saving product with combinations in "All shops", it's not updating product attributes (additional price, stock etc.) - those can only be saved in context of specific/selected shop.

Bill Reference Number not populating in Xero API

I'm creating a bill (supplier invoice) in Xero API (C# .Net). Everything populates perfectly except for the Reference number which remains blank.
Excerpt:
var invoiceObject = new Invoice
{
Reference = "TEST123",
Contact = contact,
Date = DateTime.Now,
DueDate = DateTime.Now,
ExpectedPaymentDate = DateTime.Now,
Status = Xero.Api.Core.Model.Status.InvoiceStatus.Draft,
LineItems = lineItems,
Type = Xero.Api.Core.Model.Types.InvoiceType.AccountsPayable
};
var invoice = api.Invoices.Create(invoiceObject);
The following screenshot demonstrates the issue:
Every other field, lineitem, tax code, etc. populates perfectly.
I've tried different combinations of upper and lowercase characters, numbers, etc. but it doesn't work.
If I log in to Xero, open the Invoice and manually enter TEST123 an save the invoice, it works perfectly.
I've also tried saving the invoice, then editing it and re-saving in the API and the reference still does not populate.
How can I set the reference in the API?
Quick answer
Xero Invoice API docs indicate that you can't set the reference value for an ACCPAY invoice, but that whatever you put for the Invoice Number (which is a non-unique field on ACCPAY Invoices) will also appear in the reference field.
Explanation
I ran into this same issue. I found this comment on Xero's support forum:
https://community.xero.com/developer/discussion/40489223
... which says this:
Reference is presently slightly differently based on whether the
invoice is a sales invoice (ACCREC) or a purchase invoice/bill
(ACCPAY). For a bill the reference is presented in the InvoiceNumber
element, check our documentation on invoices here where we explain
this in more detail.
From the linked to docs
All that said, the screenshot you include in your post does have a "reference" input on it, but that's not an input for the invoice's reference value - that's an input for a possible reference value for a payment you enter against the invoice. The reference value for an invoice appears at the top next to the due date:
I have the exact same issue. I'm using Python Xero but hopefully, it is the same for Javascript.
In my case, I have to use InvoiceNumber instead of Reference for bills.

How to relate fields in Odoo 11 CE

I added a custom field in "account.payment" model, I also added it in "account.move.line" model (aka: Journal Item).
The value of the custom field is entered from account.payment and since the journal items are generated from a payment creation I want to do the following:
If account.move.line.id is created by account.payment.id
let account.move.line.custom_field = account.payment.custom_field
I appreciate your help
You have to find in account.move.line that represent the relation(foreign_key) with account.payment, let says payment_id, this field allows you to access to account.payment model, and for your case you just need to do:
field_in_account_move_line = payment_id.field_in_account_payment
I hope this answer can be helpful for you.

Finding products by Tags (Prestashop)

I'm doing some modifications in the way that customers explore products in Prestashop 1.6. So, I'd like to know if is there a function that works similar to the getProducts() function but gets products from a defined tag (or tags)?
Thanks for your help.
I have looked to product class and I couldn`t find any similar function. You can get product tags, all tags, add tags, del and etc..
But you could write an additional functio, yes? In ps_product_tag table you have: id_product and id_tag so:
1) Find id_tag by product name from ps_tag table
2) Get all products ID from ps_product_tag table where product has assigned ID TAG
Thats it. And also you should do it by overiding Product class. Now you have an array with products id. So now you can use cycle and catch all infformation from products or whatever: $product = new Product($id_product);