Adição das casas decimais
This commit is contained in:
@@ -17,9 +17,9 @@ module ApplicationHelper
|
|||||||
link_to label, path, class: css
|
link_to label, path, class: css
|
||||||
end
|
end
|
||||||
|
|
||||||
# Formata moeda BR
|
# Formata moeda BR (milhar com ".", decimais com ","): R$ 1.234,56
|
||||||
def moeda(valor)
|
def moeda(valor)
|
||||||
"R$ #{"%.2f" % valor.to_f}".gsub('.', ',')
|
number_to_currency(valor.to_f, unit: 'R$ ', separator: ',', delimiter: '.', precision: 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Badge de status de consolidação
|
# Badge de status de consolidação
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ export default class extends Controller {
|
|||||||
|
|
||||||
const valor = dados.valor_total || 0
|
const valor = dados.valor_total || 0
|
||||||
this.valorTotalTarget.textContent =
|
this.valorTotalTarget.textContent =
|
||||||
"R$ " + valor.toFixed(2).replace(".", ",")
|
"R$ " + valor.toLocaleString("pt-BR", { minimumFractionDigits: 2, maximumFractionDigits: 2 })
|
||||||
|
|
||||||
const classificadas = dados.classificadas || 0
|
const classificadas = dados.classificadas || 0
|
||||||
this.contadorClassificadasTarget.textContent = classificadas
|
this.contadorClassificadasTarget.textContent = classificadas
|
||||||
|
|||||||
@@ -99,7 +99,11 @@ class Configuracao < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def valor_formatado
|
def valor_formatado
|
||||||
return "R$ #{format('%.2f', valor.to_f).gsub('.', ',')}" if moeda?
|
if moeda?
|
||||||
|
inteiro, decimais = format('%.2f', valor.to_f).split('.')
|
||||||
|
inteiro = inteiro.reverse.gsub(/(\d{3})(?=\d)/, '\1.').reverse
|
||||||
|
return "R$ #{inteiro},#{decimais}"
|
||||||
|
end
|
||||||
valor
|
valor
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -47,8 +47,15 @@ class NotificacaoService
|
|||||||
Configuracao.valor('notificacao_email') == 'true'
|
Configuracao.valor('notificacao_email') == 'true'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Moeda BR com separador de milhar: R$ 1.234,56
|
||||||
|
def moeda(v)
|
||||||
|
inteiro, decimais = format('%.2f', v.to_f).split('.')
|
||||||
|
inteiro = inteiro.reverse.gsub(/(\d{3})(?=\d)/, '\1.').reverse
|
||||||
|
"R$ #{inteiro},#{decimais}"
|
||||||
|
end
|
||||||
|
|
||||||
def mensagem(user, cm)
|
def mensagem(user, cm)
|
||||||
valor = "R$ #{format('%.2f', cm.valor_total)}".gsub('.', ',')
|
valor = moeda(cm.valor_total)
|
||||||
"Olá #{user.nome.split.first}! 🚚\n" \
|
"Olá #{user.nome.split.first}! 🚚\n" \
|
||||||
"Seu pagamento de entregas foi fechado.\n" \
|
"Seu pagamento de entregas foi fechado.\n" \
|
||||||
"📋 #{@consolidacao.nome}\n" \
|
"📋 #{@consolidacao.nome}\n" \
|
||||||
@@ -81,7 +88,7 @@ class NotificacaoService
|
|||||||
|
|
||||||
# ── Aviso de pagamento efetuado ─────────────────────────────
|
# ── Aviso de pagamento efetuado ─────────────────────────────
|
||||||
def mensagem_pagamento(user, cm)
|
def mensagem_pagamento(user, cm)
|
||||||
valor = "R$ #{format('%.2f', cm.valor_total)}".gsub('.', ',')
|
valor = moeda(cm.valor_total)
|
||||||
"Olá #{user.nome.split.first}! ✅\n" \
|
"Olá #{user.nome.split.first}! ✅\n" \
|
||||||
"Seu pagamento foi efetuado.\n" \
|
"Seu pagamento foi efetuado.\n" \
|
||||||
"📋 #{@consolidacao.nome}\n" \
|
"📋 #{@consolidacao.nome}\n" \
|
||||||
|
|||||||
@@ -82,8 +82,11 @@ module Pdf
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Moeda BR com separador de milhar: R$ 1.234,56
|
||||||
def moeda(v)
|
def moeda(v)
|
||||||
"R$ #{format('%.2f', v.to_f)}".gsub('.', ',')
|
inteiro, decimais = format('%.2f', v.to_f).split('.')
|
||||||
|
inteiro = inteiro.reverse.gsub(/(\d{3})(?=\d)/, '\1.').reverse
|
||||||
|
"R$ #{inteiro},#{decimais}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Bloco de assinaturas lado a lado: motorista (esquerda) e administrador
|
# Bloco de assinaturas lado a lado: motorista (esquerda) e administrador
|
||||||
|
|||||||
@@ -530,7 +530,7 @@
|
|||||||
label: (ctx) => {
|
label: (ctx) => {
|
||||||
const idx = ctx.dataIndex;
|
const idx = ctx.dataIndex;
|
||||||
return [
|
return [
|
||||||
` Valor: R$ ${ctx.parsed.y.toFixed(2).replace('.', ',')}`,
|
` Valor: R$ ${ctx.parsed.y.toLocaleString('pt-BR', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`,
|
||||||
` Entregas: ${qtds[idx]}`
|
` Entregas: ${qtds[idx]}`
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -591,7 +591,7 @@
|
|||||||
bodyColor: '#ffffff',
|
bodyColor: '#ffffff',
|
||||||
padding: 12,
|
padding: 12,
|
||||||
callbacks: {
|
callbacks: {
|
||||||
label: (c) => ` ${c.label}: R$ ${c.parsed.toFixed(2).replace('.', ',')}`
|
label: (c) => ` ${c.label}: R$ ${c.parsed.toLocaleString('pt-BR', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user