Remove voucher validation on code format

The code doesn't rely on label match any more so this restriction
is not necessary anymore
This commit is contained in:
Gaetan Craig-Riou
2023-09-25 09:49:55 +02:00
parent 097b775fa0
commit 02aaf6f692
3 changed files with 0 additions and 12 deletions

View File

@@ -13,9 +13,6 @@ class Voucher < ApplicationRecord
dependent: :nullify
validates :code, presence: true, uniqueness: { scope: :enterprise_id }
# We store the tax portion of a voucher in a separate adjustment with a label starting by "Tax"
# when tax are exluded from price. To avoid any issue we a code stating by Tax in not allowed
validates :code, format: { without: /\ATax/ }
TYPES = ["Vouchers::FlatRate", "Vouchers::PercentageRate"].freeze

View File

@@ -117,10 +117,6 @@ en:
using_producer_stock_settings_but_count_on_hand_set: "must be blank because using producer stock settings"
on_demand_but_count_on_hand_set: "must be blank if on demand"
limited_stock_but_no_count_on_hand: "must be specified because forcing limited stock"
voucher:
attributes:
code:
invalid: "can't start with 'Tax'"
messages:
confirmation: "doesn't match %{attribute}"
blank: "can't be blank"

View File

@@ -28,11 +28,6 @@ describe Voucher do
it { is_expected.to validate_presence_of(:code) }
it { is_expected.to validate_uniqueness_of(:code).scoped_to(:enterprise_id) }
it "doesn't accept code starting with 'Tax'" do
voucher = build(:voucher_flat_rate, code: 'Taxnew_code', enterprise: enterprise)
expect(voucher.valid?).to be(false)
end
end
describe '#display_value' do