Skip to content

Commit

Permalink
fix(update-stock): fix update stock, not update when price event
Browse files Browse the repository at this point in the history
  • Loading branch information
wisley7l committed Jun 5, 2024
1 parent 37722e9 commit 712d2ce
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions functions/lib/integration/imports/products-to-ecom.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,9 @@ module.exports = async ({ appSdk, storeId, auth }, productHorus, opts) => {
}
const product = await getProductByCodItem({ appSdk, storeId, auth }, COD_ITEM)
const isUpdatePriceOrStock = !opts.queueEntry?.mustUpdateAppQueue && (updatePrice || updateStock)
const isUpdateStock = updateStock && (SALDO_DISPONIVEL >= 0 || SALDO >= 0)

console.log('>> isUpdatePriceOrStock ', isUpdatePriceOrStock)
console.log('>> isUpdatePriceOrStock ', isUpdatePriceOrStock, ' isUpdateStock: ', isUpdateStock)

if ((isUpdatePriceOrStock || (product && !updateProduct))) {
if (!product && isUpdatePriceOrStock) {
Expand All @@ -132,7 +133,7 @@ module.exports = async ({ appSdk, storeId, auth }, productHorus, opts) => {
}
}

if (quantity !== product.quantity && updateStock) {
if (quantity !== product.quantity && isUpdateStock) {
body.quantity = quantity
}

Expand Down

0 comments on commit 712d2ce

Please sign in to comment.