intuit partner platform - How to read UnitPrice from invoice line in QBO API v3 .NET -
the bizarre properties in .net sdk continue baffle me. how read unitprice invoice line?
if this:
sild = (salesitemlinedetail)line.anyintuitobject; ln = new qbinvoiceline(); // internal line item class ln.description = line.description; ln.itemref = new qbref() { id = sild.itemref.value, name = sild.itemref.name }; if (sild.qtyspecified) ln.quantity = sild.qty; else ln.quantity = 0; if (sild.itemelementname == itemchoicetype.unitprice) ln.rate = (decimal)sild.anyintuitobject; // exception thrown here
the last line throws invalid cast exception, though debugger shows value 20. i've tried other types same exception no matter do. punted , calculating rate so:
ln.rate = line.amount / ln.quantity;
(with proper rounding , checking divide zero, of course)
while we're on subject... noticed in many cases itemelementname == itemchoicetype.pricelevelref. what's that? far know, qbo doesn't support price levels, , wasn't using price level invoice or customer. in case able needed amount property.
try this-
salesitemlinedetail a1 = (salesitemlinedetail)invoice11.line[0].anyintuitobject; object unitprice = a1.anyintuitobject; decimal quantity = a1.qty;
pricelevelref 'entity' not supported. means crud operations not supported on entity. service might returning readonly values in transactions sometimes, since not mentioned in docs, please consider unsupported.
check both request/response in either json or xml format- can use following code set that-
servicecontext context = new servicecontext(apptoken, realmid, intuitservicetype, reqvalidator); context.ippconfiguration.message.request.serializationformat = intuit.ipp.core.configuration.serializationformat.json; context.ippconfiguration.message.response.serializationformat = intuit.ipp.core.configuration.serializationformat.json;
also, in qbo ui, check if company->sales settings has track quantity , price/rate turned on.
Comments
Post a Comment