mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-13 04:00:21 +00:00
Fix error handling when creating a voucher adjustment
I wrongly assumed that `voucher.create_adjustment` would return nil if failing to create an adjustment. I will in fact return an adjustment object with errors.
This commit is contained in:
committed by
Maikel Linke
parent
ccff3379ea
commit
5eb6097101
@@ -226,8 +226,9 @@ class SplitCheckoutController < ::BaseController
|
||||
|
||||
adjustment = voucher.create_adjustment(voucher.code, @order)
|
||||
|
||||
if adjustment.nil?
|
||||
if !adjustment.valid?
|
||||
@order.errors.add(:voucher, I18n.t('split_checkout.errors.add_voucher_error'))
|
||||
adjustment.errors.each { |error| @order.errors.import(error) }
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user