Merge pull request #2075 from internetee/1788-undefined-method-for-invoice-binding

fix bind_invoice method
This commit is contained in:
Alex Sherman 2021-07-15 10:59:43 +05:00 committed by GitHub
commit ed65989dbe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View file

@ -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