mirror of
https://github.com/internetee/registry.git
synced 2025-06-07 21:25:39 +02:00
Merge pull request #2075 from internetee/1788-undefined-method-for-invoice-binding
fix bind_invoice method
This commit is contained in:
commit
ed65989dbe
2 changed files with 11 additions and 1 deletions
|
@ -59,7 +59,6 @@ class BankTransaction < ApplicationRecord
|
|||
end
|
||||
|
||||
invoice = Invoice.find_by(number: invoice_no)
|
||||
errors.add(:base, I18n.t('invoice_was_not_found')) unless invoice
|
||||
validate_invoice_data(invoice)
|
||||
return if errors.any?
|
||||
|
||||
|
@ -68,6 +67,11 @@ class BankTransaction < ApplicationRecord
|
|||
end
|
||||
|
||||
def validate_invoice_data(invoice)
|
||||
unless invoice
|
||||
errors.add(:base, I18n.t('invoice_was_not_found'))
|
||||
return
|
||||
end
|
||||
|
||||
if invoice.paid?
|
||||
errors.add(:base, I18n.t('invoice_is_already_binded'))
|
||||
return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue