@fye/aec-client
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -192,1 +192,45 @@ const test = require('ava'); | ||
}); | ||
test('createShipOrderRequest handles 400 series skus', t => { | ||
const { po, availabiltyResponse } = t.context; | ||
const testPo = { | ||
...po, | ||
items: [ | ||
{ | ||
...po.items[0], | ||
productId: 'fye.000000400397336391', | ||
sku: '000000400397336391', | ||
}, | ||
], | ||
}; | ||
const testAvailabilityResponse = { | ||
...availabiltyResponse, | ||
ID: '400397336391', | ||
}; | ||
t.notThrows(() => AecClient.createShipOrderRequest(testPo, [testAvailabilityResponse])); | ||
}); | ||
test('createShipOrderRequest throws matching error when no matching FYE to AEC availability is found', t => { | ||
const { po, availabiltyResponse } = t.context; | ||
const testPo = { | ||
...po, | ||
items: [ | ||
{ | ||
...po.items[0], | ||
productId: 'fye.000000400397336391', | ||
sku: '000000400397336391', | ||
}, | ||
], | ||
}; | ||
const testAvailabilityResponse = { | ||
...availabiltyResponse, | ||
ID: '400397336392', | ||
}; | ||
t.throws(() => | ||
AecClient.createShipOrderRequest( | ||
testPo, | ||
[testAvailabilityResponse], | ||
'Could not match FYE items to AEC Availibility result', | ||
), | ||
); | ||
}); |
@@ -91,5 +91,10 @@ const got = require('got'); | ||
return items.map(item => { | ||
const { QtyAdj, QtyBO, Qty } = availabilityResult.find(result => result.ID === item.sku); | ||
const id = item.productId.includes('fye.') ? `${Number(item.sku)}` : item.sku; | ||
const availability = availabilityResult.find(result => result.ID === id); | ||
if (!availability) { | ||
throw new Error('Could not match FYE items to AEC Availibility result'); | ||
} | ||
const { QtyAdj, QtyBO, Qty } = availability; | ||
return { | ||
ID: item.sku, | ||
ID: id, | ||
Status: QtyBO || QtyAdj ? 0 : undefined, | ||
@@ -96,0 +101,0 @@ QtyAdj, |
{ | ||
"name": "@fye/aec-client", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"main": "aec.js", | ||
@@ -5,0 +5,0 @@ "author": "Brian Kurtz <bkurtz@fye.com>", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15543
567