Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/credit_mutation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class CreditMutation < ApplicationRecord
belongs_to :created_by, class_name: 'User'

validates :description, presence: true
validates :amount, presence: true, numericality: { less_than_or_equal_to: 1000 }
validates :amount, presence: true, numericality: { less_than_or_equal_to: 5000 }
Comment thread
lodewiges marked this conversation as resolved.

validate :activity_not_locked

Expand Down
10 changes: 10 additions & 0 deletions app/models/payment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class << self

validate :user_xor_invoice
validate :user_amount
validate :invoice_amount

scope :not_completed, -> { where.not(status: COMPLETE_STATUSES) }

Expand Down Expand Up @@ -78,6 +79,15 @@ def user_amount
return unless user

min_amount = Rails.application.config.x.min_payment_amount
max_amount = 1000
errors.add(:amount, "must be bigger than or equal to €#{format('%.2f', min_amount)}") unless amount && (amount >= min_amount)
errors.add(:amount, "must be less than or equal to €#{format('%.2f', max_amount)}") unless amount && (amount <= max_amount)
Comment thread
lodewiges marked this conversation as resolved.
Comment thread
lodewiges marked this conversation as resolved.
Outdated
end
Comment thread
coderabbitai[bot] marked this conversation as resolved.

def invoice_amount
return unless invoice

min_amount = 1
errors.add(:amount, "must be bigger than or equal to €#{format('%.2f', min_amount)}") unless amount && (amount >= min_amount)
Comment thread
lodewiges marked this conversation as resolved.
Outdated
end
end
Loading