Class: Vendors::Handlers::CreateOrUpdate
- Inherits:
-
Object
- Object
- Vendors::Handlers::CreateOrUpdate
- Defined in:
- app/models/vendors/handlers/create_or_update.rb
Constant Summary collapse
- COMPANY_CODE =
Rails.application.config.company_code
Instance Attribute Summary collapse
-
#active ⇒ Object
readonly
Returns the value of attribute active.
-
#address_line1 ⇒ Object
readonly
Returns the value of attribute address_line1.
-
#address_line2 ⇒ Object
readonly
Returns the value of attribute address_line2.
-
#category ⇒ Object
readonly
Returns the value of attribute category.
-
#city ⇒ Object
readonly
Returns the value of attribute city.
-
#commission_percent ⇒ Object
readonly
Returns the value of attribute commission_percent.
-
#company_code ⇒ Object
readonly
Returns the value of attribute company_code.
-
#country_id ⇒ Object
readonly
Returns the value of attribute country_id.
-
#currency_id ⇒ Object
readonly
Returns the value of attribute currency_id.
-
#default_ship_charges ⇒ Object
readonly
Returns the value of attribute default_ship_charges.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#fax_no ⇒ Object
readonly
Returns the value of attribute fax_no.
-
#gst_registration_no ⇒ Object
readonly
Returns the value of attribute gst_registration_no.
-
#hst_registration_no ⇒ Object
readonly
Returns the value of attribute hst_registration_no.
-
#industry ⇒ Object
readonly
Returns the value of attribute industry.
-
#language ⇒ Object
readonly
Returns the value of attribute language.
-
#matching_method ⇒ Object
readonly
Returns the value of attribute matching_method.
-
#memo ⇒ Object
readonly
Returns the value of attribute memo.
-
#mid_number ⇒ Object
readonly
Returns the value of attribute mid_number.
-
#modification_date ⇒ Object
readonly
Returns the value of attribute modification_date.
-
#modified_by ⇒ Object
readonly
Returns the value of attribute modified_by.
-
#other_phone_no ⇒ Object
readonly
Returns the value of attribute other_phone_no.
-
#our_code_at_supplier ⇒ Object
readonly
Returns the value of attribute our_code_at_supplier.
-
#payment_term_id ⇒ Object
readonly
Returns the value of attribute payment_term_id.
-
#pays_gst ⇒ Object
readonly
Returns the value of attribute pays_gst.
-
#pays_hst ⇒ Object
readonly
Returns the value of attribute pays_hst.
-
#pays_pst ⇒ Object
readonly
Returns the value of attribute pays_pst.
-
#phone_no ⇒ Object
readonly
Returns the value of attribute phone_no.
-
#postal_code ⇒ Object
readonly
Returns the value of attribute postal_code.
-
#province_id ⇒ Object
readonly
Returns the value of attribute province_id.
-
#pst_registration_no ⇒ Object
readonly
Returns the value of attribute pst_registration_no.
-
#sends_invoice_by ⇒ Object
readonly
Returns the value of attribute sends_invoice_by.
-
#ship_back_orders ⇒ Object
readonly
Returns the value of attribute ship_back_orders.
-
#supplier_code ⇒ Object
readonly
Returns the value of attribute supplier_code.
-
#supplier_id ⇒ Object
readonly
Returns the value of attribute supplier_id.
-
#supplier_on_hold ⇒ Object
readonly
Returns the value of attribute supplier_on_hold.
-
#system_date ⇒ Object
readonly
Returns the value of attribute system_date.
-
#system_record ⇒ Object
readonly
Returns the value of attribute system_record.
-
#system_user ⇒ Object
readonly
Returns the value of attribute system_user.
-
#website ⇒ Object
readonly
Returns the value of attribute website.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(country_id:, active: true, address_line1: nil, address_line2: nil, category: '1', city: nil, commission_percent: 0, company_code: COMPANY_CODE, currency_id: nil, default_ship_charges: nil, description: nil, email: nil, fax_no: nil, gst_registration_no: nil, hst_registration_no: nil, industry: nil, language: 'English', matching_method: nil, modification_date: nil, memo: nil, mid_number: nil, modified_by: 'IMPORT', our_code_at_supplier: nil, other_phone_no: nil, pays_gst: false, pays_hst: false, pays_pst: false, payment_term_id: nil, phone_no: nil, postal_code: nil, province_id: nil, pst_registration_no: nil, sends_invoice_by: nil, ship_back_orders: false, supplier_code: nil, supplier_id: nil, supplier_on_hold: false, system_date: nil, system_user: nil, system_record: false, website: nil) ⇒ CreateOrUpdate
constructor
A new instance of CreateOrUpdate.
Constructor Details
#initialize(country_id:, active: true, address_line1: nil, address_line2: nil, category: '1', city: nil, commission_percent: 0, company_code: COMPANY_CODE, currency_id: nil, default_ship_charges: nil, description: nil, email: nil, fax_no: nil, gst_registration_no: nil, hst_registration_no: nil, industry: nil, language: 'English', matching_method: nil, modification_date: nil, memo: nil, mid_number: nil, modified_by: 'IMPORT', our_code_at_supplier: nil, other_phone_no: nil, pays_gst: false, pays_hst: false, pays_pst: false, payment_term_id: nil, phone_no: nil, postal_code: nil, province_id: nil, pst_registration_no: nil, sends_invoice_by: nil, ship_back_orders: false, supplier_code: nil, supplier_id: nil, supplier_on_hold: false, system_date: nil, system_user: nil, system_record: false, website: nil) ⇒ CreateOrUpdate
Returns a new instance of CreateOrUpdate.
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 77 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 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'app/models/vendors/handlers/create_or_update.rb', line 50 def initialize( country_id:, active: true, address_line1: nil, address_line2: nil, category: '1', city: nil, commission_percent: 0, company_code: COMPANY_CODE, currency_id: nil, default_ship_charges: nil, description: nil, email: nil, fax_no: nil, gst_registration_no: nil, hst_registration_no: nil, industry: nil, language: 'English', matching_method: nil, modification_date: nil, memo: nil, mid_number: nil, modified_by: 'IMPORT', our_code_at_supplier: nil, other_phone_no: nil, pays_gst: false, pays_hst: false, pays_pst: false, payment_term_id: nil, phone_no: nil, postal_code: nil, province_id: nil, pst_registration_no: nil, sends_invoice_by: nil, ship_back_orders: false, supplier_code: nil, supplier_id: nil, supplier_on_hold: false, system_date: nil, system_user: nil, system_record: false, website: nil ) @active = active @address_line1 = address_line1 @address_line2 = address_line2 @category = category @city = city @commission_percent = commission_percent @company_code = company_code @country_id = country_id @currency_id = currency_id @default_ship_charges = default_ship_charges @description = description @email = email @fax_no = fax_no @gst_registration_no = gst_registration_no @hst_registration_no = hst_registration_no @industry = industry @language = language @matching_method = matching_method @modification_date = modification_date || Time.now @memo = memo @mid_number = mid_number @modified_by = modified_by @our_code_at_supplier = our_code_at_supplier @other_phone_no = other_phone_no @pays_gst = pays_gst @pays_hst = pays_hst @pays_pst = pays_pst @payment_term_id = payment_term_id @phone_no = phone_no @postal_code = postal_code @province_id = province_id @pst_registration_no = pst_registration_no @sends_invoice_by = sends_invoice_by @ship_back_orders = ship_back_orders @supplier_code = supplier_code @supplier_id = supplier_id @supplier_on_hold = supplier_on_hold @system_date = system_date @system_user = system_user @system_record = system_record @website = website end |
Instance Attribute Details
#active ⇒ Object (readonly)
Returns the value of attribute active.
6 7 8 |
# File 'app/models/vendors/handlers/create_or_update.rb', line 6 def active @active end |
#address_line1 ⇒ Object (readonly)
Returns the value of attribute address_line1.
6 7 8 |
# File 'app/models/vendors/handlers/create_or_update.rb', line 6 def address_line1 @address_line1 end |
#address_line2 ⇒ Object (readonly)
Returns the value of attribute address_line2.
6 7 8 |
# File 'app/models/vendors/handlers/create_or_update.rb', line 6 def address_line2 @address_line2 end |
#category ⇒ Object (readonly)
Returns the value of attribute category.
6 7 8 |
# File 'app/models/vendors/handlers/create_or_update.rb', line 6 def category @category end |
#city ⇒ Object (readonly)
Returns the value of attribute city.
6 7 8 |
# File 'app/models/vendors/handlers/create_or_update.rb', line 6 def city @city end |
#commission_percent ⇒ Object (readonly)
Returns the value of attribute commission_percent.
6 7 8 |
# File 'app/models/vendors/handlers/create_or_update.rb', line 6 def commission_percent @commission_percent end |
#company_code ⇒ Object (readonly)
Returns the value of attribute company_code.
6 7 8 |
# File 'app/models/vendors/handlers/create_or_update.rb', line 6 def company_code @company_code end |
#country_id ⇒ Object (readonly)
Returns the value of attribute country_id.
6 7 8 |
# File 'app/models/vendors/handlers/create_or_update.rb', line 6 def country_id @country_id end |
#currency_id ⇒ Object (readonly)
Returns the value of attribute currency_id.
6 7 8 |
# File 'app/models/vendors/handlers/create_or_update.rb', line 6 def currency_id @currency_id end |
#default_ship_charges ⇒ Object (readonly)
Returns the value of attribute default_ship_charges.
6 7 8 |
# File 'app/models/vendors/handlers/create_or_update.rb', line 6 def default_ship_charges @default_ship_charges end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
6 7 8 |
# File 'app/models/vendors/handlers/create_or_update.rb', line 6 def description @description end |
#email ⇒ Object (readonly)
Returns the value of attribute email.
6 7 8 |
# File 'app/models/vendors/handlers/create_or_update.rb', line 6 def email @email end |
#fax_no ⇒ Object (readonly)
Returns the value of attribute fax_no.
6 7 8 |
# File 'app/models/vendors/handlers/create_or_update.rb', line 6 def fax_no @fax_no end |
#gst_registration_no ⇒ Object (readonly)
Returns the value of attribute gst_registration_no.
6 7 8 |
# File 'app/models/vendors/handlers/create_or_update.rb', line 6 def gst_registration_no @gst_registration_no end |
#hst_registration_no ⇒ Object (readonly)
Returns the value of attribute hst_registration_no.
6 7 8 |
# File 'app/models/vendors/handlers/create_or_update.rb', line 6 def hst_registration_no @hst_registration_no end |
#industry ⇒ Object (readonly)
Returns the value of attribute industry.
6 7 8 |
# File 'app/models/vendors/handlers/create_or_update.rb', line 6 def industry @industry end |
#language ⇒ Object (readonly)
Returns the value of attribute language.
6 7 8 |
# File 'app/models/vendors/handlers/create_or_update.rb', line 6 def language @language end |
#matching_method ⇒ Object (readonly)
Returns the value of attribute matching_method.
6 7 8 |
# File 'app/models/vendors/handlers/create_or_update.rb', line 6 def matching_method @matching_method end |
#memo ⇒ Object (readonly)
Returns the value of attribute memo.
6 7 8 |
# File 'app/models/vendors/handlers/create_or_update.rb', line 6 def memo @memo end |
#mid_number ⇒ Object (readonly)
Returns the value of attribute mid_number.
6 7 8 |
# File 'app/models/vendors/handlers/create_or_update.rb', line 6 def mid_number @mid_number end |
#modification_date ⇒ Object (readonly)
Returns the value of attribute modification_date.
6 7 8 |
# File 'app/models/vendors/handlers/create_or_update.rb', line 6 def modification_date @modification_date end |
#modified_by ⇒ Object (readonly)
Returns the value of attribute modified_by.
6 7 8 |
# File 'app/models/vendors/handlers/create_or_update.rb', line 6 def modified_by @modified_by end |
#other_phone_no ⇒ Object (readonly)
Returns the value of attribute other_phone_no.
6 7 8 |
# File 'app/models/vendors/handlers/create_or_update.rb', line 6 def other_phone_no @other_phone_no end |
#our_code_at_supplier ⇒ Object (readonly)
Returns the value of attribute our_code_at_supplier.
6 7 8 |
# File 'app/models/vendors/handlers/create_or_update.rb', line 6 def our_code_at_supplier @our_code_at_supplier end |
#payment_term_id ⇒ Object (readonly)
Returns the value of attribute payment_term_id.
6 7 8 |
# File 'app/models/vendors/handlers/create_or_update.rb', line 6 def payment_term_id @payment_term_id end |
#pays_gst ⇒ Object (readonly)
Returns the value of attribute pays_gst.
6 7 8 |
# File 'app/models/vendors/handlers/create_or_update.rb', line 6 def pays_gst @pays_gst end |
#pays_hst ⇒ Object (readonly)
Returns the value of attribute pays_hst.
6 7 8 |
# File 'app/models/vendors/handlers/create_or_update.rb', line 6 def pays_hst @pays_hst end |
#pays_pst ⇒ Object (readonly)
Returns the value of attribute pays_pst.
6 7 8 |
# File 'app/models/vendors/handlers/create_or_update.rb', line 6 def pays_pst @pays_pst end |
#phone_no ⇒ Object (readonly)
Returns the value of attribute phone_no.
6 7 8 |
# File 'app/models/vendors/handlers/create_or_update.rb', line 6 def phone_no @phone_no end |
#postal_code ⇒ Object (readonly)
Returns the value of attribute postal_code.
6 7 8 |
# File 'app/models/vendors/handlers/create_or_update.rb', line 6 def postal_code @postal_code end |
#province_id ⇒ Object (readonly)
Returns the value of attribute province_id.
6 7 8 |
# File 'app/models/vendors/handlers/create_or_update.rb', line 6 def province_id @province_id end |
#pst_registration_no ⇒ Object (readonly)
Returns the value of attribute pst_registration_no.
6 7 8 |
# File 'app/models/vendors/handlers/create_or_update.rb', line 6 def pst_registration_no @pst_registration_no end |
#sends_invoice_by ⇒ Object (readonly)
Returns the value of attribute sends_invoice_by.
6 7 8 |
# File 'app/models/vendors/handlers/create_or_update.rb', line 6 def sends_invoice_by @sends_invoice_by end |
#ship_back_orders ⇒ Object (readonly)
Returns the value of attribute ship_back_orders.
6 7 8 |
# File 'app/models/vendors/handlers/create_or_update.rb', line 6 def ship_back_orders @ship_back_orders end |
#supplier_code ⇒ Object (readonly)
Returns the value of attribute supplier_code.
6 7 8 |
# File 'app/models/vendors/handlers/create_or_update.rb', line 6 def supplier_code @supplier_code end |
#supplier_id ⇒ Object (readonly)
Returns the value of attribute supplier_id.
6 7 8 |
# File 'app/models/vendors/handlers/create_or_update.rb', line 6 def supplier_id @supplier_id end |
#supplier_on_hold ⇒ Object (readonly)
Returns the value of attribute supplier_on_hold.
6 7 8 |
# File 'app/models/vendors/handlers/create_or_update.rb', line 6 def supplier_on_hold @supplier_on_hold end |
#system_date ⇒ Object (readonly)
Returns the value of attribute system_date.
6 7 8 |
# File 'app/models/vendors/handlers/create_or_update.rb', line 6 def system_date @system_date end |
#system_record ⇒ Object (readonly)
Returns the value of attribute system_record.
6 7 8 |
# File 'app/models/vendors/handlers/create_or_update.rb', line 6 def system_record @system_record end |
#system_user ⇒ Object (readonly)
Returns the value of attribute system_user.
6 7 8 |
# File 'app/models/vendors/handlers/create_or_update.rb', line 6 def system_user @system_user end |
#website ⇒ Object (readonly)
Returns the value of attribute website.
6 7 8 |
# File 'app/models/vendors/handlers/create_or_update.rb', line 6 def website @website end |
Instance Method Details
#call ⇒ Object
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'app/models/vendors/handlers/create_or_update.rb', line 135 def call ActiveRecord::Base.transaction do supplier = update_supplier supplier_by_company = update_supplier_by_company( supplier_id: supplier.id ) company = update_company(supplier_id: supplier.id) { supplier: supplier, supplier_by_company: supplier_by_company, company: company } end end |