Automation API 3
Automation API 3:
AFE gives me a file with fields
MPN ( manufacturer part number)
Quantity On hand
Allocated Quantity
Item Name
My two question:
1. How do I calculate the proper stock value?
AFE told me today that the actual quantity is Quantity on Hand minus the Allocated Quantity. But the allocated values in the file are positive integers.
Example is MPN #10-10004:
The actual stock in this case is 2-1 = 1;
How do I use the API to achieve this?
2. There is no UPC in this file, so I would need to use the guid to match it to SD.
But the SureDone guid is AAIA Brand ID + MPN. Example : BKJC10-10004.
Question: how do I add BKJC front of the part number using the API?
I see the combine and API request , but I do not have the BKJC in the file, do I sue the "prefix" file_configs > identifier_prefix_vendor ??
Can you give an example?
this is what I have for now:
{
"name":"inv.csv",
"identifier":"guid",
"identifier_prefix_vendor":"BKJC",
"search":"guid:BKJC",
"diff_update": 1,
"diff_fields":["stock"],
"field_map":{
"stock":"HERE I NEED TO DO THE MATH",
},
"stock_field":"stock",
"stock_negative":true,
"missing_vendor_items":"zeroStock",
"update":"edit"
}
Any advise appreciated.
on question 2: SOLVED use "identifier_prefix_vendor":"BKJC";
on question 1: NOT SOLVED YET....
using this does not work:
"subtract": object: {key=field to apply function to: array list of fields and/or values to subtract}
Example code produces false results, IT WILL NOT SUBTRACT Allocated from Qty OH
"field_map":{
"stock":"Qty OH",
"guid":"Part #"
}
"field_run":{
"Part #":"Part #",
"Qty OH":"Qty OH",
"Allocated":"Allocated"
}
"vendor_actions":[{
"subtract":{. /* THIS WILL NOT SUBTRACT Allocated from Qty OH */
"Qty OH":[
"Allocated"
]
}
}],
"stock_sum_fields":[
"Qty OH",
"Allocated"
],
"stock_field":"stock",
"stock_negative":true,
"missing_vendor_items":"zeroStock",
"update":"relist"
Hey Erno!
The way that "subtract" works is that it takes each value from each field in the array and subtracts it from the target field (the key).
Also note that "stock_sum_fields" adds each value from each field in the array together, and then "sets" that result to the stock field. This happens after "vendor_actions".
So the config you posted is doing the following:
vendor_actions.subtract: Qty OH = Qty OH - Allocated
stock_sum_fields: Qty OH = Qty OH + Allocated
So those seem to be cancelling each other out.
You have two potential ways to fix this config:
Option 1: Remove "Allocated" from "stock_sum_fields"
Option 2: Since you already have "Qty OH" mapped to "stock", your config can look like this:
Two things:
1. Your correction does not work. See example file/data below. It sets the Allocated=STOCK
Source file
Result in SureDone:
See my full code here:
"file_configs":
{
"name":"afe-test-inv.csv",
"identifier":"guid",
"identifier_prefix_vendor":"BKJC",
"search":"guid:BKJC",
"diff_update": 1,
"diff_fields":["stock"],
"field_map":{
"stock":"Qty OH",
"guid":"Part #"
},
"field_run":{
"Part #":"Part #",
"Allocated":"Allocated"
},
"field_format":{
"guid":{
"combine":{
"fields":[
"Part #",
""
],
"delimiter":""
}
}
},
"vendor_actions":[{
"subtract":{
"stock":[
"Allocated"
]
}
}],
"stock_field":"stock",
"stock_negative":true,
"missing_vendor_items":"zeroStock",
"update":"edit"
}
2. You were right: many times Allocated is larger then Qty OH;
so the value of the stock can be negative.
I tried :"stock_negative":true and also "stock_negative":false, but the result is still Allocated = STOCK...
Please let me know what is the issue.
Hey Erno, my apologies! After testing, I realized I slightly mis-explained the feature. Let me correct myself with a clearer explanation:
The way that "subtract" works is that it subtracts each value in sequence and then "sets" the result to the target field.
So actually, to represent stock = stock - Allocated, you want this:
"vendor_actions": [
{
"subtract": {
"stock": [
"stock",
"Allocated"
]
}
}
]
So simply add "stock" before "Allocated" in the array as shown above and you should get expected results. Also note with "stock_negative" set to false your results should look like: 0, 0, 9
Let me know if that works and sorry again for the confusion there!
You know I did notice that:) Thank you very much!
When I was doing the below code the result was 1. So I was looking forward to your explanation:)
"vendor_actions": [
{
"subtract": {
"Allocated": [
1
]
}
}
]