Correção da data do dash principal
This commit is contained in:
@@ -27,6 +27,14 @@ class Entrega < ApplicationRecord
|
||||
where(planned_date: inicio.to_date.beginning_of_day..fim.to_date.end_of_day)
|
||||
}
|
||||
|
||||
# Período pela DATA REAL da entrega (checkout) — usada nas análises financeiras
|
||||
# ("quando a entrega foi concluída"). Comparação naïve com Date (intervalo
|
||||
# meio-aberto: >= início e < fim+1), SEM conversão de fuso — bate com a análise
|
||||
# feita direto no banco. Só faz sentido sobre entregas .pagas (checkout != nil).
|
||||
scope :no_periodo_checkout, ->(inicio, fim) {
|
||||
where('checkout >= ? AND checkout < ?', inicio.to_date, fim.to_date + 1)
|
||||
}
|
||||
|
||||
scope :do_motorista, ->(nome) {
|
||||
where(driver: nome)
|
||||
}
|
||||
@@ -98,9 +106,10 @@ class Entrega < ApplicationRecord
|
||||
base.distinct.order(:vehicle).pluck(:vehicle).compact.reject(&:empty?)
|
||||
end
|
||||
|
||||
# Contagem de entregas pagas para cálculo estimado
|
||||
# Contagem de entregas pagas para cálculo estimado.
|
||||
# Período pela DATA REAL da entrega (checkout) — ver no_periodo_checkout.
|
||||
def self.contar_pagas(inicio:, fim:, motorista: nil, vehicle: nil, operacoes: nil)
|
||||
base = pagas.da_conta_gade.no_periodo(inicio, fim)
|
||||
base = pagas.da_conta_gade.no_periodo_checkout(inicio, fim)
|
||||
base = base.do_motorista(motorista) if motorista.present?
|
||||
base = base.da_veiculo(vehicle) if vehicle.present?
|
||||
base = base.da_operacoes(operacoes) if operacoes.present?
|
||||
|
||||
Reference in New Issue
Block a user