erp_orders 4.0.0 → 4.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/app/models/charge_line.rb +31 -13
  3. data/app/models/charge_type.rb +7 -0
  4. data/app/models/extensions/party.rb +13 -0
  5. data/app/models/order_line_item.rb +150 -14
  6. data/app/models/order_line_item_rel_type.rb +6 -0
  7. data/app/models/order_line_item_relationship.rb +8 -0
  8. data/app/models/order_txn.rb +314 -61
  9. data/app/models/sales_tax_line.rb +15 -0
  10. data/app/models/sales_tax_policy.rb +7 -0
  11. data/db/data_migrations/20141214150732_add_order_tracked_statues.rb +25 -0
  12. data/db/data_migrations/20150309004308_add_base_charge_types.rb +19 -0
  13. data/db/migrate/20080805000060_base_orders.rb +119 -111
  14. data/db/migrate/20150309003812_add_charge_type_to_charge_lines.rb +5 -0
  15. data/db/migrate/20150309004440_create_charge_types.rb +18 -0
  16. data/db/migrate/20150311160005_add_unit_price_to_order_line_items.rb +5 -0
  17. data/db/migrate/20150622151009_add_tax_policy.rb +42 -0
  18. data/db/migrate/20150622170438_update_taxation_for_orders.rb +58 -0
  19. data/db/migrate/20150624000721_add_internal_identifier_to_charge_type.rb +5 -0
  20. data/db/migrate/20160310163060_add_created_by_updated_by_to_erp_orders.rb +35 -0
  21. data/lib/erp_orders.rb +2 -0
  22. data/lib/erp_orders/engine.rb +0 -4
  23. data/lib/erp_orders/extensions/active_record/acts_as_order_line_item.rb +2 -1
  24. data/lib/erp_orders/extensions/active_record/acts_as_order_txn.rb +1 -1
  25. data/lib/erp_orders/taxation.rb +49 -0
  26. data/lib/erp_orders/version.rb +1 -1
  27. metadata +24 -15
  28. data/app/models/charge_line_payment_txn.rb +0 -7
  29. data/db/migrate/20130620203217_add_quantity_to_order_line_items.rb +0 -13
  30. data/db/migrate/20131005232344_update_order_line_pty_role_indexes.erp_orders.rb +0 -19
  31. data/db/migrate/20131005232611_remove_order_line_specific_rtype.rb +0 -32
  32. data/db/migrate/20140129200040_add_uom_to_order_line_item.rb +0 -13
  33. data/db/migrate/20140930152140_add_custom_fields_to_order_txn.rb +0 -12
@@ -0,0 +1,5 @@
1
+ class AddInternalIdentifierToChargeType < ActiveRecord::Migration
2
+ def change
3
+ add_column :charge_types, :internal_identifier, :string unless column_exists? :charge_types, :internal_identifier
4
+ end
5
+ end
@@ -0,0 +1,35 @@
1
+ class AddCreatedByUpdatedByToErpOrders < ActiveRecord::Migration
2
+ def up
3
+ %w{charge_lines order_line_items}.each do |table|
4
+
5
+ unless column_exists? table.to_sym, :created_by_party_id
6
+ add_column table.to_sym, :created_by_party_id, :integer
7
+
8
+ add_index table.to_sym, :created_by_party_id, name: "#{table}_created_by_pty_idx"
9
+ end
10
+
11
+ unless column_exists? table.to_sym, :updated_by_party_id
12
+ add_column table.to_sym, :updated_by_party_id, :integer
13
+
14
+ add_index table.to_sym, :updated_by_party_id, name: "#{table}_updated_by_pty_idx"
15
+ end
16
+
17
+ end
18
+
19
+ end
20
+
21
+ def down
22
+ %w{charge_lines order_line_items}.each do |table|
23
+
24
+ if column_exists? table.to_sym, :created_by_party_id
25
+ remove_column table.to_sym, :created_by_party_id
26
+ end
27
+
28
+ if column_exists? table.to_sym, :updated_by_party_id
29
+ remove_column table.to_sym, :updated_by_party_id
30
+ end
31
+ end
32
+
33
+ end
34
+
35
+ end
@@ -1,5 +1,7 @@
1
1
  require 'erp_base_erp_svcs'
2
2
 
3
+ require "erp_orders/taxation"
4
+
3
5
  require "erp_orders/version"
4
6
  require "erp_orders/extensions"
5
7
  require "erp_orders/engine"
@@ -1,10 +1,6 @@
1
1
  module ErpOrders
2
2
  class Engine < Rails::Engine
3
3
  isolate_namespace ErpOrders
4
-
5
- initializer "erp_orders_assets.merge_public" do |app|
6
- app.middleware.insert_before Rack::Runtime, ::ActionDispatch::Static, "#{root}/public"
7
- end
8
4
 
9
5
  ActiveSupport.on_load(:active_record) do
10
6
  include ErpOrders::Extensions::ActiveRecord::ActsAsOrderTxn
@@ -38,7 +38,8 @@ module ErpOrders
38
38
  :quantity,
39
39
  :quantity=,
40
40
  :unit_of_measurement,
41
- :unit_of_measurement=
41
+ :unit_of_measurement=,
42
+ :dba_organization
42
43
  ].each do |m|
43
44
  delegate m, :to => :order_line_item
44
45
  end
@@ -68,7 +68,7 @@ module ErpOrders
68
68
  :authorize_payments,
69
69
  :capture_payments,
70
70
  :rollback_authorizations,
71
- :submit, :get_total_charges
71
+ :submit, :total_amount
72
72
  ].each { |m| delegate m, :to => :order_txn }
73
73
 
74
74
  #from OrderTxn And BizTxnEvent
@@ -0,0 +1,49 @@
1
+ require 'yaml'
2
+
3
+ module ErpOrders
4
+ class Taxation
5
+
6
+ def calculate_tax(taxed_record, ctx)
7
+
8
+ if ctx[:is_online_sale]
9
+ calculate_online_tax(taxed_record, ctx)
10
+ end
11
+
12
+ end
13
+
14
+ # for online sales tax is only applied if the item purchased is being shipped to the
15
+ # same state the product is being shipped from
16
+ def calculate_online_tax(taxed_record, ctx)
17
+ # use yaml file for now, eventually needs to be updated to use tax service
18
+ tax_service = YAML.load_file(File.join(Rails.root, 'config', 'taxes.yml')).symbolize_keys
19
+
20
+ # if the origin state is the same as the destination state
21
+ # determine taxes else taxes are 0
22
+ if ctx[:origin_address][:state] == ctx[:destination_address][:state]
23
+ taxes = (tax_service[:state_tax_rate] * ctx[:amount]).round(2)
24
+ taxed_record.taxed = true
25
+ taxed_record.sales_tax = taxes
26
+ taxed_record.save!
27
+
28
+ # create a tax line to record the tax rate
29
+ if taxed_record.sales_tax_lines.empty?
30
+ sales_tax_line = SalesTaxLine.new
31
+ sales_tax_line.taxed_record = taxed_record
32
+ else
33
+ sales_tax_line = taxed_record.sales_tax_lines.first
34
+ end
35
+
36
+ sales_tax_line.rate = tax_service[:state_tax_rate]
37
+ sales_tax_line.save!
38
+ else
39
+ taxes = 0
40
+ taxed_record.taxed = false
41
+ taxed_record.sales_tax = taxes
42
+ taxed_record.save
43
+ end
44
+
45
+ taxes
46
+ end
47
+
48
+ end # Taxation
49
+ end # ErpOrders
@@ -1,7 +1,7 @@
1
1
  module ErpOrders
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 4
4
- MINOR = 0
4
+ MINOR = 2
5
5
  TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].compact.join('.')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: erp_orders
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rick Koloski, Russell Holmes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-19 00:00:00.000000000 Z
11
+ date: 2016-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: erp_products
@@ -16,42 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '4.0'
19
+ version: '4.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '4.0'
26
+ version: '4.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: erp_txns_and_accts
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '4.0'
33
+ version: '4.2'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '4.0'
40
+ version: '4.2'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: erp_dev_svcs
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '4.0'
47
+ version: '4.2'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '4.0'
54
+ version: '4.2'
55
55
  description: The Orders Engine in CompassAE implements models for Orders, Order Items
56
56
  and Order status tracking. It also houses models for charge lines associated with
57
57
  Orders (although it could be argued that this functionality should reside in Commerce).
@@ -65,7 +65,7 @@ files:
65
65
  - README.rdoc
66
66
  - Rakefile
67
67
  - app/models/charge_line.rb
68
- - app/models/charge_line_payment_txn.rb
68
+ - app/models/charge_type.rb
69
69
  - app/models/extensions/agreement.rb
70
70
  - app/models/extensions/money.rb
71
71
  - app/models/extensions/party.rb
@@ -73,22 +73,31 @@ files:
73
73
  - app/models/extensions/product_type.rb
74
74
  - app/models/order_line_item.rb
75
75
  - app/models/order_line_item_pty_role.rb
76
+ - app/models/order_line_item_rel_type.rb
77
+ - app/models/order_line_item_relationship.rb
76
78
  - app/models/order_line_item_type.rb
77
79
  - app/models/order_txn.rb
78
80
  - app/models/order_txn_type.rb
81
+ - app/models/sales_tax_line.rb
82
+ - app/models/sales_tax_policy.rb
79
83
  - config/routes.rb
80
84
  - db/data_migrations/20110605231556_create_order_party_roles.rb
85
+ - db/data_migrations/20141214150732_add_order_tracked_statues.rb
86
+ - db/data_migrations/20150309004308_add_base_charge_types.rb
81
87
  - db/migrate/20080805000060_base_orders.rb
82
- - db/migrate/20130620203217_add_quantity_to_order_line_items.rb
83
- - db/migrate/20131005232344_update_order_line_pty_role_indexes.erp_orders.rb
84
- - db/migrate/20131005232611_remove_order_line_specific_rtype.rb
85
- - db/migrate/20140129200040_add_uom_to_order_line_item.rb
86
- - db/migrate/20140930152140_add_custom_fields_to_order_txn.rb
88
+ - db/migrate/20150309003812_add_charge_type_to_charge_lines.rb
89
+ - db/migrate/20150309004440_create_charge_types.rb
90
+ - db/migrate/20150311160005_add_unit_price_to_order_line_items.rb
91
+ - db/migrate/20150622151009_add_tax_policy.rb
92
+ - db/migrate/20150622170438_update_taxation_for_orders.rb
93
+ - db/migrate/20150624000721_add_internal_identifier_to_charge_type.rb
94
+ - db/migrate/20160310163060_add_created_by_updated_by_to_erp_orders.rb
87
95
  - lib/erp_orders.rb
88
96
  - lib/erp_orders/engine.rb
89
97
  - lib/erp_orders/extensions.rb
90
98
  - lib/erp_orders/extensions/active_record/acts_as_order_line_item.rb
91
99
  - lib/erp_orders/extensions/active_record/acts_as_order_txn.rb
100
+ - lib/erp_orders/taxation.rb
92
101
  - lib/erp_orders/version.rb
93
102
  - lib/tasks/erp_orders_tasks.rake
94
103
  - spec/dummy/Rakefile
@@ -145,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
154
  version: '0'
146
155
  requirements: []
147
156
  rubyforge_project:
148
- rubygems_version: 2.2.2
157
+ rubygems_version: 2.4.8
149
158
  signing_key:
150
159
  specification_version: 4
151
160
  summary: The Orders Engine in CompassAE implements models for Orders, Order Items
@@ -1,7 +0,0 @@
1
- class ChargeLinePaymentTxn < ActiveRecord::Base
2
- attr_protected :created_at, :updated_at
3
-
4
- belongs_to :charge_line
5
- belongs_to :payment_txn, :polymorphic => true
6
- belongs_to :financial_txn, :class_name => "FinancialTxn",:foreign_key => "payment_txn_id"
7
- end
@@ -1,13 +0,0 @@
1
- class AddQuantityToOrderLineItems < ActiveRecord::Migration
2
- def up
3
- unless columns(:order_line_items).collect {|c| c.name}.include?('quantity')
4
- add_column :order_line_items, :quantity, :integer
5
- end
6
- end
7
-
8
- def down
9
- if columns(:order_line_items).collect {|c| c.name}.include?('quantity')
10
- remove_column :order_line_items, :quantity
11
- end
12
- end
13
- end
@@ -1,19 +0,0 @@
1
- # This migration comes from erp_orders (originally 20131005232344)
2
- class UpdateOrderLinePtyRoleIndexes < ActiveRecord::Migration
3
- def change
4
-
5
- execute 'DROP INDEX index_order_line_item_pty_roles_on_biz_txn_acct_root_id;'
6
- execute 'DROP INDEX index_order_line_item_pty_roles_on_order_line_item_id;'
7
- execute 'DROP INDEX index_order_line_item_pty_roles_on_line_item_role_type_id;'
8
-
9
- remove_column :order_line_item_pty_roles, :line_item_role_type_id
10
-
11
- add_column :order_line_item_pty_roles, :role_type_id, :integer
12
- add_index :order_line_item_pty_roles, :role_type_id, :name => 'order_line_item_pty_role_role_type_idx'
13
-
14
- add_index :order_line_item_pty_roles, :biz_txn_acct_root_id, :name => 'order_line_item_pty_role_biz_txn_acct_root_idx'
15
- add_index :order_line_item_pty_roles, :order_line_item_id, :name => 'order_line_item_pty_role_order_line_item_idx'
16
-
17
- end
18
-
19
- end
@@ -1,32 +0,0 @@
1
- class RemoveOrderLineSpecificRtype < ActiveRecord::Migration
2
- def up
3
-
4
- #this is being replaced with the standard role types
5
- if table_exists?(:line_item_role_types)
6
- drop_table :line_item_role_types
7
- end
8
- end
9
-
10
- def down
11
-
12
- #Put the old table back on the 'down' migration
13
-
14
- unless table_exists?(:line_item_role_types)
15
- create_table :line_item_role_types do |t|
16
- t.column :parent_id, :integer
17
- t.column :lft, :integer
18
- t.column :rgt, :integer
19
- #custom columns go here
20
- t.column :description, :string
21
- t.column :comments, :string
22
- t.column :internal_identifier, :string
23
- t.column :external_identifier, :string
24
- t.column :external_id_source, :string
25
- t.timestamps
26
- end
27
-
28
- add_index :line_item_role_types, :parent_id
29
- end
30
-
31
- end
32
- end
@@ -1,13 +0,0 @@
1
- class AddUomToOrderLineItem < ActiveRecord::Migration
2
- def up
3
- unless columns(:order_line_items).collect {|c| c.name}.include?('unit_of_measurement_id')
4
- add_column :order_line_items, :unit_of_measurement_id, :integer
5
- end
6
- end
7
-
8
- def self.down
9
- if columns(:order_line_items).collect {|c| c.name}.include?('unit_of_measurement_id')
10
- remove_column :order_line_items, :unit_of_measurement_id
11
- end
12
- end
13
- end
@@ -1,12 +0,0 @@
1
- class AddCustomFieldsToOrderTxn < ActiveRecord::Migration
2
- def change
3
- if ::ActiveRecord::Base.connection.instance_values["config"][:adapter] == 'postgresql'
4
- execute('CREATE EXTENSION IF NOT EXISTS hstore;')
5
-
6
- add_column :order_txns, :custom_fields, :hstore
7
- add_hstore_index :order_txns, :custom_fields
8
- else
9
- add_column :order_txns, :custom_fields, :text
10
- end
11
- end
12
- end