mirror of
https://github.com/internetee/registry.git
synced 2025-08-05 17:28:18 +02:00
Fix double binding issue
This commit is contained in:
parent
fe6804ab11
commit
18a2e27c19
3 changed files with 10 additions and 1 deletions
|
@ -30,6 +30,8 @@ class BankTransaction < ActiveRecord::Base
|
|||
invoice = registrar.invoices.find_by(id: invoice_id)
|
||||
return unless invoice
|
||||
|
||||
return if invoice.binded?
|
||||
|
||||
return if invoice.sum != sum
|
||||
create_account_activity(
|
||||
account: registrar.cash_account,
|
||||
|
|
|
@ -2,11 +2,17 @@ class Invoice < ActiveRecord::Base
|
|||
belongs_to :seller, class_name: 'Registrar'
|
||||
belongs_to :buyer, class_name: 'Registrar'
|
||||
has_many :invoice_items
|
||||
has_one :account_activity
|
||||
|
||||
accepts_nested_attributes_for :invoice_items
|
||||
|
||||
validates :invoice_type, :due_date, :currency, :seller_name,
|
||||
:seller_iban, :buyer_name, :invoice_items, :vat_prc, presence: true
|
||||
|
||||
def binded?
|
||||
account_activity.present?
|
||||
end
|
||||
|
||||
def to_s
|
||||
I18n.t('invoice_no', no: id)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue