Import Unit Cost for Inventory Adjustments with the COM API

I'm trying to import the Unit Cost field among others for Inventory adjustments via the COM Interface. For some reason this one field likes to remain at 0.00 even when making a positive adjustment with a value greater than 0.00.

Here is an example of how I'm creating the Import object:

Import importer;
importer = (Import)ptApp.CreateImporter(PeachwIEObj.peachwIEObjAdjustmentsJournal);
importer.ClearImportFieldList();

importer.AddToImportFieldList((short)PeachwIEObjAdjustmentsJournalField.peachwIEObjAdjustmentsJournalField_ItemId);
importer.AddToImportFieldList((short)PeachwIEObjAdjustmentsJournalField.peachwIEObjAdjustmentsJournalField_Reference);
importer.AddToImportFieldList((short)PeachwIEObjAdjustmentsJournalField.peachwIEObjAdjustmentsJournalField_Date);
importer.AddToImportFieldList((short)PeachwIEObjAdjustmentsJournalField.peachwIEObjAdjustmentsJournalField_ReasonToAdjust);
importer.AddToImportFieldList((short)PeachwIEObjAdjustmentsJournalField.peachwIEObjAdjustmentsJournalField_NumberOfDistributions);
importer.AddToImportFieldList((short)PeachwIEObjAdjustmentsJournalField.peachwIEObjAdjustmentsJournalField_Amount);
importer.AddToImportFieldList((short)PeachwIEObjAdjustmentsJournalField.peachwIEObjAdjustmentsJournalField_GLAccountId);
importer.AddToImportFieldList((short)PeachwIEObjAdjustmentsJournalField.peachwIEObjAdjustmentsJournalField_Quantity);
importer.AddToImportFieldList((short)PeachwIEObjAdjustmentsJournalField.peachwIEObjAdjustmentsJournalField_UnitCost);

importer.SetFileIncludesHeadersFlag(1);
importer.SetFilename(sage50DTO.InventoryOutFileLocation + "\\" + sage50DTO.InventoryOutFileName + "_import.xml");
importer.SetFileType(PeachwIEFileType.peachwIEFileTypeXML);
importer.Import();

And this is an example of the xml file that I am importing:

<PAW_Items ...>
  <PAW_Item ...>
    <ID xsi:type="paw:id">2</ID>
    <Reference xsi:type="paw:id">111</Reference>
    <Date xsi:type="paw:date">9/16/2020 12:00:00 AM</Date>
    <ReasonToAdjust>Production</ReasonToAdjust>
    <Number_of_Distributions>1</Number_of_Distributions>
    <AdjustmentItems>
      <AdjustmentItem>
        <Amount>0.00</Amount>
        <GLSourceAccount xsi:type="paw:id">10400</GLSourceAccount>
        <Quantity>1.00000</Quantity>
        <UnitCost>10.00000</UnitCost>
      </AdjustmentItem>
    </AdjustmentItems>
  </PAW_Item>
</PAW_Items>
You can see that in the DUMMY company I created for testing, the Unit Cost field remains at 0.00:
I have found that although the Amount field doesn't need to be entered into this window, if I don't include it the import will fail. I have tried to leave the Unit Cost field off of the ImportFieldList altogether as well, thinking that the Unit Cost field will default to the Last Unit Cost of the item, but it still got set to 0.00. I'm not able to use the .Net API for this particular feature.
Any thoughts would be greatly appreciated.
  • I've solved it. For quantity adjustments > 0 the AmountAdjusted and Amount must also be included in the import xml. The AmountAdjusted will be the same value as the UnitCost and the Amount will be the same value as well except negative

    For quantity adjustments < 0, the UnitCost field is disabled, and so the AmountAdjusted and Amount can be 0.00. Here is an example of what the import xml will look like:

    <PAW_Item xsi:type="paw:item">
        <ID xsi:type="paw:id">1</ID>
        <Reference xsi:type="paw:id">23002</Reference>
        <Date xsi:type="paw:date">4/1/20</Date>
        <ReasonToAdjust>Testing</ReasonToAdjust>
        <InventoryAccount xsi:type="paw:id">1200</InventoryAccount>
        <AmountAdjusted>6.00</AmountAdjusted>
        <Number_of_Distributions>1</Number_of_Distributions>
        <AdjustmentItems>
            <AdjustmentItem>
                <GLSourceAccount xsi:type="paw:id">5000</GLSourceAccount>
                <UnitCost>6.00000</UnitCost>
                <Quantity>1.00000</Quantity>
                <Amount>-6.00</Amount>
            </AdjustmentItem>
        </AdjustmentItems>
        <Transaction_Period>18</Transaction_Period>
        <Transaction_Number>2</Transaction_Number>
    </PAW_Item>