mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 09:57:23 +02:00
Fix valid_to #2741
This commit is contained in:
parent
1a10b1400b
commit
0ea07de2d1
5 changed files with 23 additions and 2 deletions
|
@ -1,7 +1,7 @@
|
||||||
class Pricelist < ActiveRecord::Base
|
class Pricelist < ActiveRecord::Base
|
||||||
include Versions # version/pricelist_version.rb
|
include Versions # version/pricelist_version.rb
|
||||||
|
|
||||||
scope :valid, -> { where("valid_from <= ? AND valid_to >= ? OR valid_to IS NULL", Time.zone.now, Time.zone.now) }
|
scope :valid, -> { where("valid_from <= ? AND valid_to >= ? OR valid_to IS NULL", Time.zone.now.end_of_day, Time.zone.now.beginning_of_day) }
|
||||||
|
|
||||||
monetize :price_cents
|
monetize :price_cents
|
||||||
|
|
||||||
|
|
|
@ -2,5 +2,13 @@
|
||||||
.col-sm-6
|
.col-sm-6
|
||||||
%h2.text-center-xs= "#{t(:edit)}: #{@pricelist.name}"
|
%h2.text-center-xs= "#{t(:edit)}: #{@pricelist.name}"
|
||||||
|
|
||||||
|
- if @pricelist.persisted? && @pricelist.errors.none?
|
||||||
|
%hr
|
||||||
|
- active_pricelist = Pricelist.pricelist_for(@pricelist.category, @pricelist.operation_category, @pricelist.duration)
|
||||||
|
- if active_pricelist
|
||||||
|
= t('active_price_for_this_operation_is', price: "#{active_pricelist.price.amount.to_s} #{active_pricelist.price_currency}")
|
||||||
|
- else
|
||||||
|
= t('active_price_missing_for_this_operation')
|
||||||
|
|
||||||
%hr
|
%hr
|
||||||
= render 'form'
|
= render 'form'
|
||||||
|
|
|
@ -877,3 +877,5 @@ en:
|
||||||
api_user_not_found: 'API user not found'
|
api_user_not_found: 'API user not found'
|
||||||
domain_already_belongs_to_the_querying_registrar: 'Domain already belongs to the querying registrar'
|
domain_already_belongs_to_the_querying_registrar: 'Domain already belongs to the querying registrar'
|
||||||
notes: Notes
|
notes: Notes
|
||||||
|
active_price_for_this_operation_is: 'Active price for this operation is %{price}'
|
||||||
|
active_price_missing_for_this_operation: 'Active price missing for this operation!'
|
||||||
|
|
|
@ -160,6 +160,17 @@ describe Pricelist do
|
||||||
|
|
||||||
Pricelist.pricelist_for('ee', 'create', '1year').price.amount.should == 1.10
|
Pricelist.pricelist_for('ee', 'create', '1year').price.amount.should == 1.10
|
||||||
|
|
||||||
|
Fabricate.create(:pricelist, {
|
||||||
|
category: 'ee',
|
||||||
|
operation_category: 'create',
|
||||||
|
duration: '1year',
|
||||||
|
price: 2.10,
|
||||||
|
valid_from: Time.zone.now.to_date,
|
||||||
|
valid_to: Time.zone.now.to_date
|
||||||
|
})
|
||||||
|
|
||||||
|
Pricelist.pricelist_for('ee', 'create', '1year').price.amount.should == 2.10
|
||||||
|
|
||||||
Fabricate.create(:pricelist, {
|
Fabricate.create(:pricelist, {
|
||||||
category: 'ee',
|
category: 'ee',
|
||||||
operation_category: 'create',
|
operation_category: 'create',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue