mirror of
https://github.com/internetee/registry.git
synced 2025-06-08 05:34:46 +02:00
Reduce complexity of autobindable?() conditional
This commit is contained in:
parent
be960457e6
commit
5991ea6be7
2 changed files with 8 additions and 11 deletions
|
@ -32,12 +32,9 @@ class BankTransaction < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def autobindable?
|
def autobindable?
|
||||||
return false if binded?
|
binded? && registrar.present && invoice.payable? ? true : false
|
||||||
return false unless registrar
|
rescue NoMethodError
|
||||||
return false unless invoice
|
false
|
||||||
return false unless invoice.payable?
|
|
||||||
|
|
||||||
true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# For successful binding, reference number, invoice id and sum must match with the invoice
|
# For successful binding, reference number, invoice id and sum must match with the invoice
|
||||||
|
@ -113,6 +110,10 @@ class BankTransaction < ApplicationRecord
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def parsed_ref_number
|
||||||
|
reference_no || ref_number_from_description
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def reset_pending_registrar_balance_reload
|
def reset_pending_registrar_balance_reload
|
||||||
|
@ -122,10 +123,6 @@ class BankTransaction < ApplicationRecord
|
||||||
registrar.save!
|
registrar.save!
|
||||||
end
|
end
|
||||||
|
|
||||||
def parsed_ref_number
|
|
||||||
reference_no || ref_number_from_description
|
|
||||||
end
|
|
||||||
|
|
||||||
def ref_number_from_description
|
def ref_number_from_description
|
||||||
/(\d{7})/.match(description)[0]
|
/(\d{7})/.match(description)[0]
|
||||||
end
|
end
|
||||||
|
|
|
@ -113,7 +113,7 @@ class Invoice < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.create_from_transaction!(transaction)
|
def self.create_from_transaction!(transaction)
|
||||||
registrar_user = Registrar.find_by(reference_no: transasction.parsed_ref_number)
|
registrar_user = Registrar.find_by(reference_no: transaction.parsed_ref_number)
|
||||||
return unless registrar_user
|
return unless registrar_user
|
||||||
|
|
||||||
registrar_user.issue_prepayment_invoice(amount: transaction.sum,
|
registrar_user.issue_prepayment_invoice(amount: transaction.sum,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue