Author Topic: InventoryAdjustmentAdd  (Read 5789 times)

rjnelson

  • Member
  • *
  • Posts: 3
InventoryAdjustmentAdd
« on: October 24, 2012, 02:10:45 PM »
I am trying to send an Inventory Qty and Value Adjustment.  I am getting an error code of:  Code -1000 error Severity: Failed validation message: error at newvalue reason: element 'newvalue' is unexpected according to the content model of parent element 'valueadjustment'.  I can send in the ValueAdjustment::NewQuantity alone and it works fine, but I cannot get the NewValue to be passed into QB.

Here is what the code looks like:
Set Field(QB Inventory Adj::QB Prepare; PCBQ_RqNew("InventoryAdjustmentAdd")
Set Field(QB Inventory Adj::QB Prepare; PCBQ_RqAddFieldWithValue("AccountRef::FullName";QB Inventory Adj::QB_COGS Inventory Adj)
Set Field(QB Inventory Adj::QB Prepare; PCBQ_RqAddFieldWithValue("TxnDate";Inventory::Adjust Date_g)
Set Field(QB Inventory Adj::QB Prepare; PCBQ_RqAddRelatedRecord("InventoryAdjustmentLineAdd")
Set Field(QB Inventory Adj::QB Prepare; PCBQ_RqAddFieldWithValue("ItemRef::ListID";Inventory::QB List ID)
Set Field(QB Inventory Adj::QB Prepare; PCBQ_RqAddFieldWithValue("ValueAdjustment::NewQuantity";Inventory::QOH)
Set Field(QB Inventory Adj::QB Prepare; PCBQ_RqAddFieldWithValue("ValueAdjustment::NewValue";Inventory::Value)
Set Field(QB Inventory Adj::QB Prepare; PCBQ_RqCloseRelatedRecord

Thanks,
Robert

Geoffrey Gerhard

  • Guru
  • Member
  • ****
  • Posts: 470
Re: InventoryAdjustmentAdd
« Reply #1 on: October 24, 2012, 02:59:00 PM »
What's the value of the Inventory::Value field? It won't work if it's empty, negative, or malformed.

HTH!

Geoffrey Gerhard
Creative Solutions Incorporated
14000 Creekside Drive
Matthews, NC  28105
704) 814-6852

rjnelson

  • Member
  • *
  • Posts: 3
Re: InventoryAdjustmentAdd
« Reply #2 on: October 24, 2012, 03:13:48 PM »
Value is a Number field, and it is a calc field QTY * Cost, which on the first record was 8.64.  I still got the error.  I even tried to hardcode in the number 9, and still got the same error.  I am running FM 11 Advanced and Quickbooks Pro 2011 if that helps.

- Robert

rjnelson

  • Member
  • *
  • Posts: 3
Re: InventoryAdjustmentAdd
« Reply #3 on: October 24, 2012, 03:48:04 PM »
One more note:  When I disable the NewValue Line, leave everything else as is, it submits correctly.  However if I try to submit both NewQuantity and NewValue, or just the NewValue, I get the error above.

- Robert

Geoffrey Gerhard

  • Guru
  • Member
  • ****
  • Posts: 470
Re: InventoryAdjustmentAdd
« Reply #4 on: October 24, 2012, 04:03:07 PM »
It's been a long time since I visited the Inventory ValueAdjustment process.

IIRC, you cannot pass both a NewQuantity and NewValue in the same InventoryAdjustmentAdd Request. I believe you can pass the NewQuantity and, if you know the QB and FMP Quantity values on the TxnDate and do the math, pass the difference using "ValueAdjustment::ValueDifference" in a single InventoryAdjustmentAdd Request. You can always make two separate InventoryAdjustmentAdd Requests (one for NewQuantity, one for NewValue).

Know going in that every Item referenced in an InventoryAdjustmentAdd Request will impact ALL existing Transactions that have a date greater than the InventoryAdjustmentAdd Request's TxnDate. InventoryAdjustments are one of the most difficult processes to implement because of their impact on the rest of the system, and are very much like trying to change the tire on a moving vehicle. It's very easy to find yourself with negative inventory values and other unintended consequences that will crater the accuracy of your Balance Sheet and Income Statement.

HTH!

Geoffrey Gerhard
Creative Solutions Incorporated
14000 Creekside Drive
Matthews, NC  28105
704) 814-6852

scstock

  • Member
  • *
  • Posts: 10
Re: InventoryAdjustmentAdd
« Reply #5 on: June 11, 2014, 02:30:34 AM »
I am trying to send an Inventory Qty and Value Adjustment.  I am getting an error code of:  Code -1000 error Severity: Failed validation message: error at newvalue reason: element 'newvalue' is unexpected according to the content model of parent element 'valueadjustment'.  I can send in the ValueAdjustment::NewQuantity alone and it works fine, but I cannot get the NewValue to be passed into QB.

I have also just bumped into this exact issue.

Can anyone confirm that they have been able to successfully create a Value Adjustment?

Jerel Malong

  • Global Moderator
  • Member
  • *****
  • Posts: 97
Re: InventoryAdjustmentAdd
« Reply #6 on: June 17, 2014, 05:00:43 PM »
scstock, can you provide insight as to what you are doing. perhaps a screenshot?

scstock

  • Member
  • *
  • Posts: 10
Re: InventoryAdjustmentAdd
« Reply #7 on: June 22, 2014, 11:27:52 AM »
Here are the key lines from the Script:

Set Variable [ $$Result; Value:PCQB_RqAddRelatedRecord("InventoryAdjustmentLineAdd" ; "" ) ]
Set Variable [ $$Result; Value:PCQB_RqAddFieldWithValue("ItemRef:ListID" ; Products::QuickBooks List ID ) ]
Set Variable [ $$Result; Value:PCQB_RqAddFieldWithValue( "ValueAdjustment::QuantityDifference" ; 0 ) ]
Set Variable [ $$Result; Value:PCQB_RqAddFieldWithValue( "ValueAdjustment::ValueDifference" ; Invoice Lines::Freight Cost Allocated GBP ) ]

And the Error Message:

Error at ValueDifference
Reason:   Element 'ValueDifference' is unexpected according to content model of parent element 'ValueAdjustment'.

Field Value:   7.21


The reason for doing these adjustments is to incorporate Import Duty and Airfreight costs into the Cost of Goods Sold of items that I import. In this example I am attempting to add 7.21 to the value of the item in question.

Would be so handy to be able to script this, so thanks in advance for any input!

Geoffrey Gerhard

  • Guru
  • Member
  • ****
  • Posts: 470
Re: InventoryAdjustmentAdd
« Reply #8 on: June 22, 2014, 01:31:36 PM »
Omitting the...

Set Variable [ $$Result; Value:PCQB_RqAddFieldWithValue( "ValueAdjustment::QuantityDifference" ; 0 ) ]

...step should fix the error. An InventoryAdjustmentLineAdd uses an "OR" structure that allows a Quantity OR a Value OR a SerialNumber adjustment. IIRC, you can adjust both the Quantity and Value of an Item as long as each appears in its own LineAdd element within the InventoryAdjustmentAdd Request.

HTH!

Geoffrey Gerhard
Creative Solutions Incorporated
14000 Creekside Drive
Matthews, NC  28105
704) 814-6852

scstock

  • Member
  • *
  • Posts: 10
Re: InventoryAdjustmentAdd
« Reply #9 on: June 24, 2014, 02:43:36 AM »
Thank you, but if I omit that script step then I get the following error instead:

CODE: -1000
SEVERITY: failed validation
MESSAGE: Error at ValueDifference
Reason:   Element 'ValueDifference' is unexpected according to content model of parent element 'ValueAdjustment'.
Expecting: NewQuantity, QuantityDifference.

Field Value:   132.45


...which suggests that it needs a Quantity adjustment, even though I am trying to enter a Value adjustment.

Geoffrey Gerhard

  • Guru
  • Member
  • ****
  • Posts: 470
Re: InventoryAdjustmentAdd
« Reply #10 on: June 24, 2014, 10:27:16 AM »
That's kind of odd. The OSR says...

ValueAdjustment
Adjusts the total value of these inventory items by setting a new monetary value, and optionally by setting a new quantity.

...which I read as allowing the omission of NewQuantity/QuantityDifference. Another idea: A QuantityDiffrerence of 0 may be unacceptable. What happens if you Query QB for the current Qty of the item and pass it as NewQuantity? i.e., pass both the NewQuantity and QuantityDifference elements, but the value of NewQuantity effectively makes no change in QB.

If that doesn't do it, post back and I'll try to dig up a copy of a system that made heavy use of Inventory Adjustments.

HTH!

Geoffrey Gerhard
Creative Solutions Incorporated
14000 Creekside Drive
Matthews, NC  28105
704) 814-6852
« Last Edit: June 25, 2014, 10:26:14 AM by Geoffrey Gerhard »

Chris Turner

  • Administrator
  • Member
  • *****
  • Posts: 28
    • Productive Computing, Inc.
Re: InventoryAdjustmentAdd
« Reply #11 on: June 25, 2014, 08:46:03 AM »
I've taken a few moments to look into the validation schema / XSD files for qbXML (as provided from Intuit), and it appears that there may be some validation oversight in the XML schema.

In the sequence for defining a ValueAdjustment's "NewQuantity", "QuantityDifference", "NewValue", or "ValueDifference" fields, the OSR states that a valid request would define either a Quantity-based adjustment or a Value-based adjustment, or both, with the Quantity-based adjustment being either "NewQuantity" or "QuantityDifference" (and NEVER both), and the Value-based adjustment being either "NewValue" or "ValueDifference" (and NEVER both).

In the XSD file "qbxml100.xsd" (validation file for use with QuickBooks 2011), the Quantity-based adjustment section looks valid, however there is a "maxOccurs=0" attribute for the Value-based adjustment. I interpret this to mean that there can be no Value-based adjustments; only Quantity-based are allowed in the XML schema.

I will be reaching out to Intuit developer support to see if this was an intentional definition or some oversight, as well as how to get around it.

Thanks for bringing this to our attention!
Chris Turner
Product Support Specialist
Productive Computing, Inc.

Geoffrey Gerhard

  • Guru
  • Member
  • ****
  • Posts: 470
Re: InventoryAdjustmentAdd
« Reply #12 on: June 25, 2014, 11:23:33 AM »
I was sure I'd used ValueDifference successfully, but several years ago. Apparently, the Element is still supported if you tell QB that you're using the 10.0 version of qbxml, but not if you tell it you're using a newer version. Not sure there's any way to override the plug-in's default header with...

<?qbxml version="10.0"?>

...instead of...

<?qbxml version="13.0" ?>

Given that the InventoryAdjustmentAdd was expanded in qbxml versions 11 and 12, that's not a great solution, but neither is losing the ability to adjust an Inventory Item's Value.

HTH!

Geoffrey Gerhard
Creative Solutions Incorporated
14000 Creekside Drive
Matthews, NC  28105
704) 814-6852

Chris Turner

  • Administrator
  • Member
  • *****
  • Posts: 28
    • Productive Computing, Inc.
Re: InventoryAdjustmentAdd
« Reply #13 on: June 25, 2014, 12:25:50 PM »
Just heard back from Intuit support. Based on findings from my own testing with QB Pro 2014, it appears that this is a bug in the XSD. They have forwarded the issue to their development team to have a look at to verify if it is, in fact, a bug, and to address it as needed.
Chris Turner
Product Support Specialist
Productive Computing, Inc.

scstock

  • Member
  • *
  • Posts: 10
Re: InventoryAdjustmentAdd
« Reply #14 on: June 26, 2014, 06:41:08 AM »
Thank you so much for looking into this Geoffrey and Chris - I'll just have to manually adjust for now!