Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed show auction action issue #1299

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/controllers/english_offers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ def show
# GET /english_offers/aa450f1a-45e2-4f22-b2c3-f5f46b5f906b/edit
def edit
@auction = @offer.auction
redirect_to auction_path(@auction.uuid) and return if update_not_allowed(@auction)
redirect_to root_path and return if update_not_allowed(@auction)
end

# PUT /english_offers/aa450f1a-45e2-4f22-b2c3-f5f46b5f906b
def update
@auction = Auction.english.with_user_offers(current_user.id).find_by(uuid: @offer.auction.uuid)
redirect_to auction_path(@auction.uuid) and return if update_not_allowed(@auction)
redirect_to root_path and return if update_not_allowed(@auction)
inform_invalid_captcha and return unless recaptcha_valid

if update_predicate(@auction)
Expand Down
18 changes: 11 additions & 7 deletions app/models/billing_profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class BillingProfile < ApplicationRecord
has_many :domain_offer_histories
has_many :invoices

scope :with_search_scope, ->(origin) {
scope :with_search_scope, lambda { |origin|
if origin.present?
joins(:user)
.includes(:user)
Expand All @@ -39,10 +39,12 @@ def self.search(params = {})

def vat_code_must_be_registered_in_vies
# Vat code validation only for EU countries
vat_rate = Countries.vat_rate_from_alpha2_code(self.country_code)
vat_rate = Countries.vat_rate_from_alpha2_code(country_code)
return if vat_code.blank? || vat_rate == BigDecimal(0)

errors.add(:vat_code, I18n.t('billing_profiles.vat_validation_error')) unless Valvat.new(self.vat_code).exists?
errors.add(:vat_code, I18n.t('billing_profiles.vat_validation_error')) unless Valvat.new(vat_code).exists?
rescue Valvat::RateLimitError
errors.add(:vat_code, I18n.t('billing_profiles.vat_validation_rate_limit_error'))
end

def issued_invoices
Expand All @@ -67,7 +69,7 @@ def vat_rate
# if Time.zone.now.year < 2024
# return BigDecimal(OLD_EST_RATE_VAT)
# else
return BigDecimal(Setting.find_by(code: :estonian_vat_rate).retrieve, 2)
return BigDecimal(Setting.find_by(code: :estonian_vat_rate).retrieve, 2)
# end
end

Expand All @@ -77,11 +79,11 @@ def vat_rate
end

def self.create_default_for_user(user_id)
return if find_by(user_id: user_id)
return if find_by(user_id:)

user = User.find(user_id)

billing_profile = new(user: user, country_code: user.country_code, name: user.display_name)
billing_profile = new(user:, country_code: user.country_code, name: user.display_name)
billing_profile.save!

billing_profile
Expand Down Expand Up @@ -116,11 +118,13 @@ def mirror_address_to_attached_invoices
private

def update_billing_information_for_invoices
return unless name_changed? || street_changed? || city_changed? || postal_code_changed? || country_code_changed?

issued_invoices.update_all(
billing_name: name,
billing_address: address,
billing_vat_code: vat_code,
billing_alpha_two_country_code: alpha_two_country_code
) if name_changed? || street_changed? || city_changed? || postal_code_changed? || country_code_changed?
)
end
end
1 change: 1 addition & 0 deletions config/locales/billing_profiles.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ en:
updated: "Billing profile successfully updated!"
deleted: "Billing profile successfully deleted!"
vat_validation_error: "VAT code is not registered or not valid according to VIES"
vat_validation_rate_limit_error: "VAT code validation rate limit exceeded"
vat_code_already_exists: "VAT code is already in use"

edit:
Expand Down
1 change: 1 addition & 0 deletions config/locales/billing_profiles.et.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ et:
updated: "Arveldusprofiil edukalt uuendatud!"
deleted: "Arveldusprofiil edukalt kustutatud!"
vat_validation_error: "Käibemaksukood ei ole registreeritud või ei ole VIESi kohaselt kehtiv."
vat_validation_rate_limit_error: "Käibemaksukoodi valideerimise kiiruse limiit on ületatud."
vat_code_already_exists: "Käibemaksukood on juba kasutusel."

edit:
Expand Down
10 changes: 5 additions & 5 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@

namespace :admin, constraints: Constraints::Administrator.new do
resources :auctions, concerns: %i[auditable] do
collection do
post 'bulk_starts_at', to: 'auctions#bulk_starts_at', as: 'bulk_starts_at'
post 'apply_auction_participants', to: 'auctions#apply_auction_participants', as: 'apply_auction_participants'
collection do
post 'bulk_starts_at', to: 'auctions#bulk_starts_at', as: 'bulk_starts_at'
post 'apply_auction_participants', to: 'auctions#apply_auction_participants', as: 'apply_auction_participants'
end
end
end

resources :bans, except: %i[new show edit update], concerns: %i[auditable]
resources :statistics, only: :index
Expand Down Expand Up @@ -82,7 +82,7 @@
devise_for :users, path: 'sessions',
controllers: { confirmations: 'email_confirmations', sessions: 'auth/sessions', passwords: 'passwords' }

resources :auctions, only: %i[index show], param: :uuid do
resources :auctions, only: %i[index], param: :uuid do
resources :offers, only: %i[new show create edit update destroy], shallow: true, param: :uuid do
get 'delete'
end
Expand Down
Loading