@@ -76,11 +76,11 @@ module.exports = async (tinyProduct, storeId, auth, isNew = true, tipo, appData)
7676 const sku = tinyProduct . codigo || String ( tinyProduct . id )
7777 const name = ( tinyProduct . nome || sku ) . trim ( )
7878 const isProduct = tipo === 'produto'
79- const fixTinyPrice = ( price ) => {
79+ const fixToNumber = ( price ) => {
8080 return Number ( price ) > 0 ? Number ( price ) : 0
8181 }
82- const price = fixTinyPrice ( tinyProduct . preco_promocional || tinyProduct . precoPromocional ) ||
83- fixTinyPrice ( tinyProduct . preco )
82+ const price = fixToNumber ( tinyProduct . preco_promocional || tinyProduct . precoPromocional ) ||
83+ fixToNumber ( tinyProduct . preco )
8484 const product = {
8585 available : tinyProduct . situacao === 'A' ,
8686 sku,
@@ -89,7 +89,7 @@ module.exports = async (tinyProduct, storeId, auth, isNew = true, tipo, appData)
8989 base_price : Number ( tinyProduct . preco ) ,
9090 body_html : tinyProduct . descricao_complementar || tinyProduct . descricaoComplementar
9191 }
92- const costPrice = fixTinyPrice ( tinyProduct . preco_custo || tinyProduct . precoCusto )
92+ const costPrice = fixToNumber ( tinyProduct . preco_custo || tinyProduct . precoCusto )
9393 if ( costPrice ) {
9494 product . cost_price = costPrice
9595 }
@@ -131,7 +131,10 @@ module.exports = async (tinyProduct, storeId, auth, isNew = true, tipo, appData)
131131 product . warranty = tinyProduct . garantia
132132 }
133133 if ( tinyProduct . unidade_por_caixa || tinyProduct . unidadePorCaixa ) {
134- product . min_quantity = ! isProduct ? Number ( tinyProduct . unidade_por_caixa ) : Number ( tinyProduct . unidadePorCaixa )
134+ const minQuantity = fixToNumber ( tinyProduct . unidade_por_caixa || tinyProduct . unidadePorCaixa )
135+ if ( minQuantity > 0 ) {
136+ product . min_quantity = minQuantity
137+ }
135138 }
136139 if ( tinyProduct . ncm ) {
137140 product . mpn = [ tinyProduct . ncm ]
0 commit comments