mirror of
https://github.com/internetee/registry.git
synced 2025-08-06 01:35:10 +02:00
Refactor debit and credit registrar to include pricelist id #2741
This commit is contained in:
parent
9fd38f161a
commit
75a6c27221
11 changed files with 80 additions and 123 deletions
|
@ -23,10 +23,10 @@ class Pricelist < ActiveRecord::Base
|
|||
end
|
||||
|
||||
class << self
|
||||
def price_for(zone, operation, period)
|
||||
def pricelist_for(zone, operation, period)
|
||||
lists = valid.where(category: zone, operation_category: operation, duration: period)
|
||||
return lists.first.price if lists.count == 1
|
||||
lists.where('valid_to IS NOT NULL').order(valid_from: :desc).first.price
|
||||
return lists.first if lists.count == 1
|
||||
lists.where('valid_to IS NOT NULL').order(valid_from: :desc).first
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue