Skip to content

Commit

Permalink
Fixes #1124
Browse files Browse the repository at this point in the history
  • Loading branch information
lentschi committed Mar 9, 2025
1 parent a8ab5d8 commit 0c95df4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion db/migrate/20240726083740_alter_articles_add_versioning.rb
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def down
t.string :origin
t.string :order_number
t.datetime :updated_at
t.decimal :price, precision: 8, scale: 2
t.decimal :price, precision: 8, scale: 2, default: '0.0'
t.float :tax
t.decimal :deposit, precision: 8, scale: 2, default: '0.0'
t.integer :unit_quantity, null: false, default: 0
Expand Down
20 changes: 10 additions & 10 deletions db/migrate/20240726083741_alter_articles_add_more_unit_logic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def up
t.column :group_order_unit, :string, length: 3
t.column :group_order_granularity, :decimal, precision: 8, scale: 3, null: false, default: 1
t.column :minimum_order_quantity, :float
t.change :price, :decimal, precision: 11, scale: 6, null: false, comment: 'stored in `article_versions.supplier_order_unit`'
t.change :price, :decimal, precision: 11, scale: 6, null: false, default: '0.0', comment: 'stored in `article_versions.supplier_order_unit`'
t.change :unit, :string, null: true, default: nil
end

Expand Down Expand Up @@ -49,21 +49,21 @@ def up
end

change_table :order_articles do |t|
t.change :quantity, :decimal, precision: 8, scale: 3, null: false, comment: 'stored in `article_versions.group_order_unit`'
t.change :tolerance, :decimal, precision: 8, scale: 3, null: false, comment: 'stored in `article_versions.group_order_unit`'
t.change :units_to_order, :decimal, precision: 11, scale: 6, null: false, comment: 'stored in `article_versions.supplier_order_unit`'
t.change :units_billed, :decimal, precision: 11, scale: 6, null: true, comment: 'stored in `article_versions.supplier_order_unit`'
t.change :units_received, :decimal, precision: 11, scale: 6, null: true, comment: 'stored in `article_versions.supplier_order_unit`'
t.change :quantity, :decimal, precision: 8, scale: 3, null: false, default: '0.0', comment: 'stored in `article_versions.group_order_unit`'
t.change :tolerance, :decimal, precision: 8, scale: 3, null: false, default: '0.0', comment: 'stored in `article_versions.group_order_unit`'
t.change :units_to_order, :decimal, precision: 11, scale: 6, null: false, default: '0.0', comment: 'stored in `article_versions.supplier_order_unit`'
t.change :units_billed, :decimal, precision: 11, scale: 6, null: true, default: nil, comment: 'stored in `article_versions.supplier_order_unit`'
t.change :units_received, :decimal, precision: 11, scale: 6, null: true, default: nil, comment: 'stored in `article_versions.supplier_order_unit`'
end

change_table :group_order_articles do |t|
t.change :quantity, :decimal, precision: 8, scale: 3, null: false
t.change :tolerance, :decimal, precision: 8, scale: 3, null: false
t.change :quantity, :decimal, precision: 8, scale: 3, null: false, default: '0.0'
t.change :tolerance, :decimal, precision: 8, scale: 3, null: false, default: '0.0'
end

change_table :group_order_article_quantities do |t|
t.change :quantity, :decimal, precision: 8, scale: 3, null: false
t.change :tolerance, :decimal, precision: 8, scale: 3, null: false
t.change :quantity, :decimal, precision: 8, scale: 3, null: false, default: '0.0'
t.change :tolerance, :decimal, precision: 8, scale: 3, null: false, default: '0.0'
end
end

Expand Down
6 changes: 4 additions & 2 deletions db/migrate/20240726083743_create_article_units.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ def up

unit_codes += ArticleUnitsLib::DEFAULT_IMPERIAL_SCALAR_UNIT_CODES if imperial_plain_text_units_exist?

now_sql_str = ActiveRecord::Base.connection.quoted_date(Time.now)

unit_codes.each do |unit_code|
insert(%{
INSERT INTO article_units (unit, created_at, updated_at)
VALUES (
#{quote unit_code},
NOW(),
NOW()
#{quote now_sql_str},
#{quote now_sql_str}
)
})
end
Expand Down

0 comments on commit 0c95df4

Please sign in to comment.