diff --git a/app/models/p_product_ref.rb b/app/models/p_product_ref.rb index 07926e6..106fce6 100644 --- a/app/models/p_product_ref.rb +++ b/app/models/p_product_ref.rb @@ -48,6 +48,7 @@ class PProductRef < ApplicationRecord :actions => {:name => "Actions", :reorder => false} } + acts_as_caching :fields => [:sorecop] def not_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}" end + def ca_sorecop + if self.cc_sorecop + return self.cc_sorecop + else + "TODO Calcul sorecop" + end + end + end diff --git a/db/migrate/20210917115613_add_sorecop_to_p_product_refs.rb b/db/migrate/20210917115613_add_sorecop_to_p_product_refs.rb new file mode 100644 index 0000000..83162ee --- /dev/null +++ b/db/migrate/20210917115613_add_sorecop_to_p_product_refs.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index 077818c..b4d95e9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # 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| t.string "name" @@ -1793,6 +1793,9 @@ ActiveRecord::Schema.define(version: 2021_09_14_071847) do t.boolean "stocked", default: true t.text "description" 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 create_table "p_product_specs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|