Class: Products::Handlers::CreateOrUpdate
- Inherits:
-
Object
- Object
- Products::Handlers::CreateOrUpdate
- Defined in:
- app/models/products/handlers/create_or_update.rb
Constant Summary collapse
- COMPANY_CODE =
Rails.application.config.company_code
- DEFAULT_PRODUCT_FAMILY_ID =
1
Instance Attribute Summary collapse
-
#active ⇒ Object
readonly
Returns the value of attribute active.
-
#alternate_description ⇒ Object
readonly
Returns the value of attribute alternate_description.
-
#approved_to_purchase ⇒ Object
readonly
Returns the value of attribute approved_to_purchase.
-
#approved_to_sell ⇒ Object
readonly
Returns the value of attribute approved_to_sell.
-
#approved_to_sell_online ⇒ Object
readonly
Returns the value of attribute approved_to_sell_online.
-
#brand_category_description ⇒ Object
readonly
Returns the value of attribute brand_category_description.
-
#brand_description ⇒ Object
readonly
Returns the value of attribute brand_description.
-
#default_purchase_uom_description ⇒ Object
readonly
Returns the value of attribute default_purchase_uom_description.
-
#default_sales_uom_description ⇒ Object
readonly
Returns the value of attribute default_sales_uom_description.
-
#default_storage_uom_description ⇒ Object
readonly
Returns the value of attribute default_storage_uom_description.
-
#description_english ⇒ Object
readonly
Returns the value of attribute description_english.
-
#description_french ⇒ Object
readonly
Returns the value of attribute description_french.
-
#group_description ⇒ Object
readonly
Returns the value of attribute group_description.
-
#initiated_by_company ⇒ Object
readonly
Returns the value of attribute initiated_by_company.
-
#memo ⇒ Object
readonly
Returns the value of attribute memo.
-
#package_specs_header_id ⇒ Object
readonly
Returns the value of attribute package_specs_header_id.
-
#product_category_description ⇒ Object
readonly
Returns the value of attribute product_category_description.
-
#product_code ⇒ Object
readonly
Returns the value of attribute product_code.
-
#product_id ⇒ Object
readonly
Returns the value of attribute product_id.
-
#product_image_filepath ⇒ Object
readonly
Returns the value of attribute product_image_filepath.
-
#product_type ⇒ Object
readonly
Returns the value of attribute product_type.
-
#production_specs_description_english ⇒ Object
readonly
Returns the value of attribute production_specs_description_english.
-
#production_specs_header_id ⇒ Object
readonly
Returns the value of attribute production_specs_header_id.
-
#sales_order_multiplier ⇒ Object
readonly
Returns the value of attribute sales_order_multiplier.
-
#season_description ⇒ Object
readonly
Returns the value of attribute season_description.
-
#subgroup_description ⇒ Object
readonly
Returns the value of attribute subgroup_description.
-
#system_date ⇒ Object
readonly
Returns the value of attribute system_date.
-
#system_user ⇒ Object
readonly
Returns the value of attribute system_user.
-
#warranty_days ⇒ Object
readonly
Returns the value of attribute warranty_days.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(product_code:, description_english:, brand_description:, brand_category_description:, group_description:, subgroup_description:, production_specs_header_id:, production_specs_description_english:, package_specs_header_id:, default_storage_uom_description:, default_sales_uom_description:, default_purchase_uom_description:, initiated_by_company:, approved_to_sell:, approved_to_sell_online:, approved_to_purchase:, active:, product_category_description:, season_description:, memo:, system_date:, system_user:, product_id: 0, description_french: nil, product_type: nil, sales_order_multiplier: 1, alternate_description: nil, warranty_days: nil, product_image_filepath: nil) ⇒ CreateOrUpdate
constructor
A new instance of CreateOrUpdate.
Constructor Details
#initialize(product_code:, description_english:, brand_description:, brand_category_description:, group_description:, subgroup_description:, production_specs_header_id:, production_specs_description_english:, package_specs_header_id:, default_storage_uom_description:, default_sales_uom_description:, default_purchase_uom_description:, initiated_by_company:, approved_to_sell:, approved_to_sell_online:, approved_to_purchase:, active:, product_category_description:, season_description:, memo:, system_date:, system_user:, product_id: 0, description_french: nil, product_type: nil, sales_order_multiplier: 1, alternate_description: nil, warranty_days: nil, product_image_filepath: nil) ⇒ CreateOrUpdate
Returns a new instance of CreateOrUpdate.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'app/models/products/handlers/create_or_update.rb', line 39 def initialize( product_code:, description_english:, brand_description:, brand_category_description:, group_description:, subgroup_description:, production_specs_header_id:, production_specs_description_english:, package_specs_header_id:, default_storage_uom_description:, default_sales_uom_description:, default_purchase_uom_description:, initiated_by_company:, approved_to_sell:, approved_to_sell_online:, approved_to_purchase:, active:, product_category_description:, season_description:, memo:, system_date:, system_user:, product_id: 0, description_french: nil, product_type: nil, sales_order_multiplier: 1, alternate_description: nil, warranty_days: nil, product_image_filepath: nil ) @product_id = product_id @product_code = product_code @description_english = description_english @description_french = description_french @brand_description = brand_description @brand_category_description = brand_category_description @group_description = group_description @subgroup_description = subgroup_description @production_specs_header_id = production_specs_header_id @production_specs_description_english = production_specs_description_english @package_specs_header_id = package_specs_header_id @default_storage_uom_description = default_storage_uom_description @default_sales_uom_description = default_sales_uom_description @default_purchase_uom_description = default_purchase_uom_description @initiated_by_company = initiated_by_company @product_type = product_type @approved_to_sell = approved_to_sell @approved_to_sell_online = approved_to_sell_online @approved_to_purchase = approved_to_purchase @active = active @sales_order_multiplier = sales_order_multiplier @product_category_description = product_category_description @season_description = season_description @alternate_description = alternate_description @warranty_days = warranty_days @memo = memo @system_date = system_date @system_user = system_user end |
Instance Attribute Details
#active ⇒ Object (readonly)
Returns the value of attribute active.
7 8 9 |
# File 'app/models/products/handlers/create_or_update.rb', line 7 def active @active end |
#alternate_description ⇒ Object (readonly)
Returns the value of attribute alternate_description.
7 8 9 |
# File 'app/models/products/handlers/create_or_update.rb', line 7 def alternate_description @alternate_description end |
#approved_to_purchase ⇒ Object (readonly)
Returns the value of attribute approved_to_purchase.
7 8 9 |
# File 'app/models/products/handlers/create_or_update.rb', line 7 def approved_to_purchase @approved_to_purchase end |
#approved_to_sell ⇒ Object (readonly)
Returns the value of attribute approved_to_sell.
7 8 9 |
# File 'app/models/products/handlers/create_or_update.rb', line 7 def approved_to_sell @approved_to_sell end |
#approved_to_sell_online ⇒ Object (readonly)
Returns the value of attribute approved_to_sell_online.
7 8 9 |
# File 'app/models/products/handlers/create_or_update.rb', line 7 def approved_to_sell_online @approved_to_sell_online end |
#brand_category_description ⇒ Object (readonly)
Returns the value of attribute brand_category_description.
7 8 9 |
# File 'app/models/products/handlers/create_or_update.rb', line 7 def brand_category_description @brand_category_description end |
#brand_description ⇒ Object (readonly)
Returns the value of attribute brand_description.
7 8 9 |
# File 'app/models/products/handlers/create_or_update.rb', line 7 def brand_description @brand_description end |
#default_purchase_uom_description ⇒ Object (readonly)
Returns the value of attribute default_purchase_uom_description.
7 8 9 |
# File 'app/models/products/handlers/create_or_update.rb', line 7 def default_purchase_uom_description @default_purchase_uom_description end |
#default_sales_uom_description ⇒ Object (readonly)
Returns the value of attribute default_sales_uom_description.
7 8 9 |
# File 'app/models/products/handlers/create_or_update.rb', line 7 def default_sales_uom_description @default_sales_uom_description end |
#default_storage_uom_description ⇒ Object (readonly)
Returns the value of attribute default_storage_uom_description.
7 8 9 |
# File 'app/models/products/handlers/create_or_update.rb', line 7 def default_storage_uom_description @default_storage_uom_description end |
#description_english ⇒ Object (readonly)
Returns the value of attribute description_english.
7 8 9 |
# File 'app/models/products/handlers/create_or_update.rb', line 7 def description_english @description_english end |
#description_french ⇒ Object (readonly)
Returns the value of attribute description_french.
7 8 9 |
# File 'app/models/products/handlers/create_or_update.rb', line 7 def description_french @description_french end |
#group_description ⇒ Object (readonly)
Returns the value of attribute group_description.
7 8 9 |
# File 'app/models/products/handlers/create_or_update.rb', line 7 def group_description @group_description end |
#initiated_by_company ⇒ Object (readonly)
Returns the value of attribute initiated_by_company.
7 8 9 |
# File 'app/models/products/handlers/create_or_update.rb', line 7 def initiated_by_company @initiated_by_company end |
#memo ⇒ Object (readonly)
Returns the value of attribute memo.
7 8 9 |
# File 'app/models/products/handlers/create_or_update.rb', line 7 def memo @memo end |
#package_specs_header_id ⇒ Object (readonly)
Returns the value of attribute package_specs_header_id.
7 8 9 |
# File 'app/models/products/handlers/create_or_update.rb', line 7 def package_specs_header_id @package_specs_header_id end |
#product_category_description ⇒ Object (readonly)
Returns the value of attribute product_category_description.
7 8 9 |
# File 'app/models/products/handlers/create_or_update.rb', line 7 def product_category_description @product_category_description end |
#product_code ⇒ Object (readonly)
Returns the value of attribute product_code.
7 8 9 |
# File 'app/models/products/handlers/create_or_update.rb', line 7 def product_code @product_code end |
#product_id ⇒ Object (readonly)
Returns the value of attribute product_id.
7 8 9 |
# File 'app/models/products/handlers/create_or_update.rb', line 7 def product_id @product_id end |
#product_image_filepath ⇒ Object (readonly)
Returns the value of attribute product_image_filepath.
7 8 9 |
# File 'app/models/products/handlers/create_or_update.rb', line 7 def product_image_filepath @product_image_filepath end |
#product_type ⇒ Object (readonly)
Returns the value of attribute product_type.
7 8 9 |
# File 'app/models/products/handlers/create_or_update.rb', line 7 def product_type @product_type end |
#production_specs_description_english ⇒ Object (readonly)
Returns the value of attribute production_specs_description_english.
7 8 9 |
# File 'app/models/products/handlers/create_or_update.rb', line 7 def production_specs_description_english @production_specs_description_english end |
#production_specs_header_id ⇒ Object (readonly)
Returns the value of attribute production_specs_header_id.
7 8 9 |
# File 'app/models/products/handlers/create_or_update.rb', line 7 def production_specs_header_id @production_specs_header_id end |
#sales_order_multiplier ⇒ Object (readonly)
Returns the value of attribute sales_order_multiplier.
7 8 9 |
# File 'app/models/products/handlers/create_or_update.rb', line 7 def sales_order_multiplier @sales_order_multiplier end |
#season_description ⇒ Object (readonly)
Returns the value of attribute season_description.
7 8 9 |
# File 'app/models/products/handlers/create_or_update.rb', line 7 def season_description @season_description end |
#subgroup_description ⇒ Object (readonly)
Returns the value of attribute subgroup_description.
7 8 9 |
# File 'app/models/products/handlers/create_or_update.rb', line 7 def subgroup_description @subgroup_description end |
#system_date ⇒ Object (readonly)
Returns the value of attribute system_date.
7 8 9 |
# File 'app/models/products/handlers/create_or_update.rb', line 7 def system_date @system_date end |
#system_user ⇒ Object (readonly)
Returns the value of attribute system_user.
7 8 9 |
# File 'app/models/products/handlers/create_or_update.rb', line 7 def system_user @system_user end |
#warranty_days ⇒ Object (readonly)
Returns the value of attribute warranty_days.
7 8 9 |
# File 'app/models/products/handlers/create_or_update.rb', line 7 def warranty_days @warranty_days end |
Instance Method Details
#call ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'app/models/products/handlers/create_or_update.rb', line 78 def call Product.create_or_update( product_id: product_id, product_code: product_code, description_english: description_english, description_french: description_french || description_english, alternate_description: alternate_description, product_family_id: DEFAULT_PRODUCT_FAMILY_ID, brand_id: Brand.find_by(description: brand_description)&.id || '', brand_category_id: BrandCategory.find_by(description_english: brand_category_description)&.id || '', group_id: Group.find_by(description: group_description)&.id || '', sub_group_id: SubGroup.find_by(description: subgroup_description)&.id || '', season_id: Season.find_by(description: season_description)&.id || '', royalty_id: '', production_specs_header_id: production_specs_header_id || '', package_specs_header_id: package_specs_header_id || '', default_storage_uom_id: UnitOfMeasurement.find_by(description: default_storage_uom_description)&.id || '', default_purchase_uom_id: UnitOfMeasurement.find_by(description: default_purchase_uom_description)&.id || '', default_sales_uom_id: UnitOfMeasurement.find_by(description: default_sales_uom_description)&.id || '', initiated_by_company: COMPANY_CODE, product_category_id: ProductCategory.find_by(description_english: product_category_description)&.id, approved_to_sell: approved_to_sell, approved_to_sell_online: approved_to_sell_online, approved_to_purchase: approved_to_purchase, product_image_filepath: product_image_filepath, memo: memo, active: active, city_id: '', warranty_days: warranty_days, sales_order_multiplier: sales_order_multiplier, product_type: product_type, system_date: system_date, system_user: system_user ) end |