Class: Billing::Factory::Base
- Inherits:
-
Object
- Object
- Billing::Factory::Base
show all
- Includes:
- ActiveModel::Model
- Defined in:
- app/models/billing/factory/base.rb
Overview
rubocop:todo Style/Documentation
Constant Summary
collapse
- NO_PROJECT_COST_CODE =
'S0755'.freeze
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(attributes = {}) ⇒ Base
Returns a new instance of Base.
15
16
17
18
19
20
|
# File 'app/models/billing/factory/base.rb', line 15
def initialize(attributes = {})
super
self.passed_date = request
self.billing_product = request
end
|
Instance Attribute Details
#billing_product ⇒ Object
Returns the value of attribute billing_product
9
10
11
|
# File 'app/models/billing/factory/base.rb', line 9
def billing_product
@billing_product
end
|
#request ⇒ Object
Returns the value of attribute request
8
9
10
|
# File 'app/models/billing/factory/base.rb', line 8
def request
@request
end
|
Instance Method Details
#billing_product_code ⇒ Object
billing_product_code will be received from Agresso based on billing_product name
45
46
47
48
49
50
|
# File 'app/models/billing/factory/base.rb', line 45
def billing_product_code
rescue
nil
end
|
#billing_product_description ⇒ Object
52
53
54
|
# File 'app/models/billing/factory/base.rb', line 52
def billing_product_description
billing_product.name
end
|
#create! ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'app/models/billing/factory/base.rb', line 60
def create!
return unless valid?
Billing::Item.create!(
request: request,
project_cost_code: project_cost_code,
units: units,
billing_product_code: billing_product_code,
billing_product_name: billing_product_name,
billing_product_description: billing_product_description,
request_passed_date: passed_date
)
end
|
#passed_date ⇒ Object
28
29
30
31
32
|
# File 'app/models/billing/factory/base.rb', line 28
def passed_date
return if @passed_date.nil?
@passed_date.strftime('%Y%m%d')
end
|
#passed_date=(request) ⇒ Object
22
23
24
25
26
|
# File 'app/models/billing/factory/base.rb', line 22
def passed_date=(request)
return if request.blank?
@passed_date = request.date_for_state('passed')
end
|
#project_cost_code(cost_code = nil) ⇒ Object
40
41
42
|
# File 'app/models/billing/factory/base.rb', line 40
def project_cost_code(cost_code = nil)
cost_code || NO_PROJECT_COST_CODE
end
|
#units(*_args) ⇒ Object
56
57
58
|
# File 'app/models/billing/factory/base.rb', line 56
def units(*_args)
100
end
|