Add sorecop to p_product_ref

This commit is contained in:
Barnabé 2021-09-17 14:08:08 +02:00
parent f3246d0209
commit d6640ded5a
3 changed files with 20 additions and 1 deletions

View File

@ -48,6 +48,7 @@ class PProductRef < ApplicationRecord
:actions => {:name => "Actions", :reorder => false} :actions => {:name => "Actions", :reorder => false}
} }
acts_as_caching :fields => [:sorecop]
def not_imported? def not_imported?
if !self.p_product or !self.p_product.imported if !self.p_product or !self.p_product.imported
@ -150,4 +151,12 @@ class PProductRef < ApplicationRecord
"#{self.ref} | #{self.p_product.name} - #{self.ct_sub_name} - #{self.p_product_color.name if self.p_product_color} | #{self.cat_name}" "#{self.ref} | #{self.p_product.name} - #{self.ct_sub_name} - #{self.p_product_color.name if self.p_product_color} | #{self.cat_name}"
end end
def ca_sorecop
if self.cc_sorecop
return self.cc_sorecop
else
"TODO Calcul sorecop"
end
end
end end

View File

@ -0,0 +1,7 @@
class AddSorecopToPProductRefs < ActiveRecord::Migration[6.0]
def change
add_column :p_product_refs, :ca_sorecop, :decimal
add_column :p_product_refs, :cc_sorecop, :decimal
add_column :p_product_refs, :ct_sorecop, :decimal
end
end

View File

@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2021_09_14_071847) do ActiveRecord::Schema.define(version: 2021_09_17_115613) do
create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
t.string "name" t.string "name"
@ -1793,6 +1793,9 @@ ActiveRecord::Schema.define(version: 2021_09_14_071847) do
t.boolean "stocked", default: true t.boolean "stocked", default: true
t.text "description" t.text "description"
t.integer "p_product_color_id" t.integer "p_product_color_id"
t.decimal "ca_sorecop", precision: 10
t.decimal "cc_sorecop", precision: 10
t.decimal "ct_sorecop", precision: 10
end end
create_table "p_product_specs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| create_table "p_product_specs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|