refactor backend and persist stock campaign queue
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 2m32s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 2m32s
This commit is contained in:
19
backend/mappers/stockMapper.js
Normal file
19
backend/mappers/stockMapper.js
Normal file
@@ -0,0 +1,19 @@
|
||||
const getBaseProductName = (name) => String(name || 'Unknown').split(' TAMANHO')[0].trim();
|
||||
|
||||
const normalizeStockPayload = (item) => {
|
||||
const produtoId = item.idProduto || item.ID_Produto || '';
|
||||
const nome = item.nome || item.Descricao_Produto || 'Unknown';
|
||||
|
||||
return {
|
||||
produtoId: String(produtoId),
|
||||
nome,
|
||||
baseProductName: getBaseProductName(nome),
|
||||
saldo: parseInt(item.saldo, 10) || 0,
|
||||
deltaEstoque: parseInt(item.delta_estoque, 10) || 0
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
getBaseProductName,
|
||||
normalizeStockPayload
|
||||
};
|
||||
Reference in New Issue
Block a user