diff --git a/app/models/p_payment_document.rb b/app/models/p_payment_document.rb index 20c6efd..addb3a0 100644 --- a/app/models/p_payment_document.rb +++ b/app/models/p_payment_document.rb @@ -30,10 +30,10 @@ class PPaymentDocument < ActiveRecord::Base if self.p_document - sum = self.siblings_payments_total + self.amount.to_f + sum = self.siblings_payments_total.to_f + self.amount.to_f - if sum > self.p_document.totals[:total_ttc].to_f + if sum.round(2) > self.p_document.totals[:total_ttc].to_f.round(2) errors.add(:amount, "Ne doit pas dépasser le montant de la somme restant dues (#{self.p_document.totals[:total_ttc].to_f - siblings_payments_total})") end diff --git a/app/views/admin/p_payments/_form.html.haml b/app/views/admin/p_payments/_form.html.haml index db19302..06cbc75 100755 --- a/app/views/admin/p_payments/_form.html.haml +++ b/app/views/admin/p_payments/_form.html.haml @@ -1,7 +1,6 @@ #p_payment_form_wrapper .content - =debug @p_payment.errors.messages =semantic_form_for [:admin, @p_payment], :remote => true, :html => {:id => "p_payment_general_form",:onsubmit => "$this = $(this); if ($this.data().isSubmitted) { alert('La sauvegarde est en cours, merci de patienter.');return false; } $this.data().isSubmitted = true; return true;"} do |f| -@p_customer = @p_payment.p_customer if @p_payment.p_customer