mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-30 19:52:20 +01:00
fix creation of prices with float values
This commit is contained in:
parent
a9e593a840
commit
82fa5416ce
@ -83,7 +83,7 @@ class API::CouponsController < API::ApiController
|
||||
@parameters
|
||||
else
|
||||
@parameters = params
|
||||
@parameters[:coupon][:amount_off] = @parameters[:coupon][:amount_off].to_i * 100.0 if @parameters[:coupon][:amount_off]
|
||||
@parameters[:coupon][:amount_off] = @parameters[:coupon][:amount_off].to_f * 100.0 if @parameters[:coupon][:amount_off]
|
||||
|
||||
@parameters = @parameters.require(:coupon).permit(:name, :code, :percent_off, :amount_off, :validity_per_user, :valid_until, :max_usages, :active)
|
||||
end
|
||||
|
@ -86,12 +86,12 @@ class API::EventsController < API::ApiController
|
||||
event_preparams.merge!(availability_attributes: {id: event_preparams[:availability_id], start_at: start_at, end_at: end_at, available_type: 'event'})
|
||||
.except!(:start_date, :end_date, :start_time, :end_time, :all_day)
|
||||
# convert main price to centimes
|
||||
event_preparams.merge!(amount: (event_preparams[:amount].to_i * 100 if event_preparams[:amount].present?))
|
||||
event_preparams.merge!(amount: (event_preparams[:amount].to_f * 100 if event_preparams[:amount].present?))
|
||||
# delete non-complete "other" prices and convert them to centimes
|
||||
unless event_preparams[:event_price_categories_attributes].nil?
|
||||
event_preparams[:event_price_categories_attributes].delete_if { |price_cat| price_cat[:price_category_id].empty? or price_cat[:amount].empty? }
|
||||
event_preparams[:event_price_categories_attributes].each do |price_cat|
|
||||
price_cat[:amount] = price_cat[:amount].to_i * 100
|
||||
price_cat[:amount] = price_cat[:amount].to_f * 100
|
||||
end
|
||||
end
|
||||
# return the resulting params object
|
||||
|
@ -81,9 +81,9 @@
|
||||
@parameters
|
||||
else
|
||||
@parameters = params
|
||||
@parameters[:plan][:amount] = @parameters[:plan][:amount].to_i * 100.0 if @parameters[:plan][:amount]
|
||||
@parameters[:plan][:amount] = @parameters[:plan][:amount].to_f * 100.0 if @parameters[:plan][:amount]
|
||||
@parameters[:plan][:prices_attributes] = @parameters[:plan][:prices_attributes].map do |price|
|
||||
{ amount: price[:amount].to_i * 100.0, id: price[:id] }
|
||||
{ amount: price[:amount].to_f * 100.0, id: price[:id] }
|
||||
end if @parameters[:plan][:prices_attributes]
|
||||
|
||||
@parameters = @parameters.require(:plan).permit(:base_name, :type, :group_id, :amount, :interval, :interval_count, :is_rolling,
|
||||
|
Loading…
x
Reference in New Issue
Block a user