2017-10-27 23:21:31 +02:00
|
|
|
require 'factory_bot'
|
2013-07-14 02:49:40 +02:00
|
|
|
|
2017-10-27 23:21:31 +02:00
|
|
|
FactoryBot.define do
|
2014-11-21 14:37:56 +01:00
|
|
|
factory :_article do
|
2013-07-14 02:49:40 +02:00
|
|
|
unit { Faker::Unit.unit }
|
2017-10-08 12:24:31 +02:00
|
|
|
price { rand(0.1..26.0).round(2) }
|
2013-07-14 02:49:40 +02:00
|
|
|
tax { [6, 21].sample }
|
|
|
|
deposit { rand(10) < 8 ? 0 : [0.0, 0.80, 1.20, 12.00].sample }
|
|
|
|
unit_quantity { rand(5) < 3 ? 1 : rand(1..20) }
|
2023-02-21 15:17:19 +01:00
|
|
|
price_per { rand(0.1..26.0).round(2) }
|
2014-11-21 14:37:56 +01:00
|
|
|
|
|
|
|
factory :article do
|
2019-10-28 09:40:43 +01:00
|
|
|
sequence(:name) { |n| Faker::Lorem.words(number: rand(2..4)).join(' ') + " ##{n}" }
|
2018-10-13 16:21:37 +02:00
|
|
|
supplier
|
|
|
|
article_category
|
2014-11-21 14:37:56 +01:00
|
|
|
end
|
|
|
|
|
2022-02-20 16:15:22 +01:00
|
|
|
factory :shared_article, class: 'SharedArticle' do
|
2019-10-28 09:40:43 +01:00
|
|
|
sequence(:name) { |n| Faker::Lorem.words(number: rand(2..4)).join(' ') + " s##{n}" }
|
|
|
|
order_number { Faker::Lorem.characters(number: rand(1..12)) }
|
2018-10-13 16:21:37 +02:00
|
|
|
shared_supplier
|
|
|
|
end
|
|
|
|
|
2022-02-20 16:15:22 +01:00
|
|
|
factory :stock_article, class: 'StockArticle' do
|
2018-10-13 16:21:37 +02:00
|
|
|
sequence(:name) { |n| Faker::Lorem.words(number: rand(2..4)).join(' ') + " ##{n}" }
|
|
|
|
unit_quantity { 1 }
|
|
|
|
supplier
|
|
|
|
article_category
|
2014-11-21 14:37:56 +01:00
|
|
|
end
|
2013-07-14 02:49:40 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
factory :article_category do
|
2019-10-28 09:40:43 +01:00
|
|
|
sequence(:name) { |n| Faker::Lorem.characters(number: rand(2..12)) + " ##{n}" }
|
2013-07-14 02:49:40 +02:00
|
|
|
end
|
|
|
|
end
|