Fix: cast json amount to Number in portal logic to ensure strict equality comparison works for recovering corrupted double discount
This commit is contained in:
parent
58182ff53c
commit
e7ded2df80
|
|
@ -275,8 +275,8 @@ app.get('/api/portal/financeiro', authMiddleware, async (req, res) => {
|
|||
}
|
||||
}
|
||||
|
||||
let amountOriginal = jsonP.amount || Number(db.valor) || 0;
|
||||
const discount = jsonP.amount ? (jsonP.discount || 0) : 0;
|
||||
let amountOriginal = Number(jsonP.amount) || Number(db.valor) || 0;
|
||||
const discount = jsonP.amount ? Number(jsonP.discount || 0) : 0;
|
||||
|
||||
// [Bugfix]: Recupera o valor bruto corrompido pelo webhook antigo
|
||||
if (amountOriginal === Number(db.valor) && discount > 0) {
|
||||
|
|
|
|||
|
|
@ -279,8 +279,8 @@ app.get('/api/portal/financeiro', authMiddleware, async (req, res) => {
|
|||
}
|
||||
|
||||
// amount_original = valor bruto (ex: 170), db.valor = valor líquido Asaas (ex: 150)
|
||||
let amountOriginal = Number(db.amount_original) || jsonP.amount || Number(db.valor) || 0;
|
||||
const discount = Number(db.discount) || (jsonP.amount ? (jsonP.discount || 0) : 0);
|
||||
let amountOriginal = Number(db.amount_original) || Number(jsonP.amount) || Number(db.valor) || 0;
|
||||
const discount = Number(db.discount) || (jsonP.amount ? Number(jsonP.discount || 0) : 0);
|
||||
|
||||
// [Bugfix]: Se o amountOriginal for igual ao valor líquido (db.valor) e houver desconto,
|
||||
// significa que o webhook antigo sobrescreveu o valor bruto pelo líquido no JSON.
|
||||
|
|
|
|||
Loading…
Reference in New Issue