fix(pecas): corrigir discrepancia no calculo de peso total da tabela e da importacao
This commit is contained in:
@@ -363,8 +363,8 @@ export function usePecas() {
|
||||
marca: item.marca || '',
|
||||
descricao: item.descricao || '',
|
||||
quantidade: Number(item.quantidade) || 0,
|
||||
peso_unitario: Math.round(Number(item.peso_unitario) || 0),
|
||||
peso_total: Math.round(Number(item.peso_total) || 0),
|
||||
peso_unitario: Number(item.peso_unitario) || 0,
|
||||
peso_total: Number(item.peso_total) || 0,
|
||||
tratamento_superficial: item.tratamento_superficial || '',
|
||||
material: item.material || '',
|
||||
perfil_principal: item.perfil_principal || '',
|
||||
|
||||
@@ -177,7 +177,10 @@ export const usePecasTable = (pecas: Peca[]) => {
|
||||
}
|
||||
|
||||
return pecasParaCalcular.reduce((total, peca) => {
|
||||
return total + (peca.peso_total || 0);
|
||||
const pTotal = (peca.peso_total && peca.peso_total > 0)
|
||||
? peca.peso_total
|
||||
: (peca.quantidade || 1) * (peca.peso_unitario || 0);
|
||||
return total + pTotal;
|
||||
}, 0);
|
||||
}, [filteredAndSortedPecas, selectedPecas]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user