erp_commerce 4.0.0 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +0 -1
  3. data/app/models/accepted_credit_card.rb +10 -0
  4. data/app/models/bank_account.rb +13 -0
  5. data/app/models/bank_account_type.rb +9 -0
  6. data/app/models/credit_card.rb +54 -19
  7. data/app/models/credit_card_account.rb +31 -9
  8. data/app/models/credit_card_account_party_role.rb +17 -0
  9. data/app/models/credit_card_account_purpose.rb +24 -0
  10. data/app/models/extensions/financial_txn.rb +62 -1
  11. data/app/models/extensions/order_txn.rb +48 -0
  12. data/app/models/extensions/party.rb +26 -13
  13. data/app/models/extensions/simple_product_offer.rb +3 -0
  14. data/app/models/payment.rb +21 -0
  15. data/app/models/payment_gateway.rb +12 -0
  16. data/app/models/payment_gateway_action.rb +12 -0
  17. data/app/models/pricing_plan.rb +29 -1
  18. data/db/data_migrations/20150125202814_add_payment_transaction_types.rb +14 -0
  19. data/db/migrate/20100823174238_erp_commerce_base.rb +196 -192
  20. data/db/migrate/20160310163057_add_created_by_updated_by_to_erp_commerce.rb +35 -0
  21. data/lib/erp_commerce.rb +1 -2
  22. data/lib/erp_commerce/config.rb +2 -3
  23. data/lib/erp_commerce/engine.rb +1 -5
  24. data/lib/erp_commerce/extensions/active_record/acts_as_priceable.rb +1 -2
  25. data/lib/erp_commerce/version.rb +1 -1
  26. metadata +12 -32
  27. data/app/mailers/checkout_mailer.rb +0 -9
  28. data/app/views/checkout_mailer/email_confirmation.html.erb +0 -15
  29. data/app/widgets/orders/base.rb +0 -36
  30. data/app/widgets/orders/javascript/orders.js +0 -12
  31. data/app/widgets/orders/views/index.html.erb +0 -63
  32. data/app/widgets/product_catalog/base.rb +0 -52
  33. data/app/widgets/product_catalog/javascript/product_catalog.js +0 -64
  34. data/app/widgets/product_catalog/views/add_to_cart.html.erb +0 -10
  35. data/app/widgets/product_catalog/views/index.html.erb +0 -69
  36. data/app/widgets/product_catalog/views/show.html.erb +0 -23
  37. data/app/widgets/shopping_cart/base.rb +0 -175
  38. data/app/widgets/shopping_cart/javascript/shopping_cart.js +0 -110
  39. data/app/widgets/shopping_cart/views/cart_items.html.erb +0 -83
  40. data/app/widgets/shopping_cart/views/confirmation.html.erb +0 -11
  41. data/app/widgets/shopping_cart/views/demographics.html.erb +0 -142
  42. data/app/widgets/shopping_cart/views/login.html.erb +0 -1
  43. data/app/widgets/shopping_cart/views/payment.html.erb +0 -81
  44. data/app/widgets/shopping_cart/views/price_summary.html.erb +0 -4
  45. data/lib/erp_commerce/active_merchant_wrappers.rb +0 -3
  46. data/lib/erp_commerce/active_merchant_wrappers/authorize_net_wrapper.rb +0 -66
  47. data/lib/erp_commerce/active_merchant_wrappers/brain_tree_gateway_wrapper.rb +0 -68
  48. data/lib/erp_commerce/active_merchant_wrappers/credit_card_validation.rb +0 -34
  49. data/lib/erp_commerce/order_helper.rb +0 -245
@@ -1,10 +0,0 @@
1
- <%= @product_type.description %>
2
- <br/>
3
- <p><%= raw @product_type.find_description_by_iid('long_description').description %></p>
4
- <br/>
5
- Added to cart
6
- <br/>
7
- <%=link_to_remote 'Continue Shopping', build_widget_url(:index)%> | <a href="<%=@cart_items_url%>">Go to Cart</a>
8
- <script type="text/javascript">
9
- Compass.ErpApp.Widgets.refreshWidget('shopping_cart', 'price_summary');
10
- </script>
@@ -1,69 +0,0 @@
1
- <style type="text/css">
2
- #products-view {
3
- font-family:'Lucida Grande','Lucida Sans Unicode',sans-serif;
4
- text-align:center;
5
- font-size:14px;
6
- width:100%;
7
- border-collapse: collapse;
8
- border: 2px solid #CCCCCC;
9
- }
10
-
11
- #products-view a {
12
- text-decoration:none;
13
- }
14
-
15
- #products-view img {
16
- height:60px;
17
- width:65px;
18
- padding-right:15px;
19
- }
20
-
21
- #products-view div
22
- {
23
- float:left;
24
- text-align:left;
25
- }
26
-
27
- #products-view th {
28
- padding: 0 0.5em;
29
- height:30px;
30
- text-align:center;
31
- background:url("/images/knitkit/footer.png") repeat-x scroll 0 0 #29425E;
32
- }
33
-
34
- .highlight:hover
35
- {
36
- background-color:#FFFFEE;
37
- }
38
-
39
- #products-view td+td {
40
- border-left: 1px solid #CCC;
41
- text-align: center;
42
- }
43
- </style>
44
- <div id="<%=widget_result_id%>">
45
- <table id="products-view">
46
- <thead>
47
- <tr>
48
- <th>Product</th>
49
- <th># Available</th>
50
- <th>Buy It</th>
51
- </tr>
52
- </thead>
53
- <tbody>
54
- <% ProductType.all.each do |product_type| %>
55
- <tr class="product-wrap highlight">
56
- <td>
57
- <div><img src="<%=product_type.images.empty? ? '/images/img_blank.png' : product_type.images.first.data.url%>" alt="Product Image" /></div>
58
- <div>
59
- <span><%=link_to_remote product_type.description, build_widget_url(:show, product_type.id) %></span><br/>
60
- <span><%=product_type.get_current_simple_amount_with_currency.nil? ? 'no price set' : product_type.get_current_simple_amount_with_currency%></span>
61
- </div>
62
- </td>
63
- <td><%=product_type.inventory_entries.first.number_available%></td>
64
- <td><%=link_to_remote 'Add To Cart', build_widget_url(:add_to_cart, product_type.id) %></td>
65
- </tr>
66
- <%end%>
67
- </tbody>
68
- </table>
69
- </div>
@@ -1,23 +0,0 @@
1
- <div id="<%=widget_result_id%>">
2
- <%=link_to_remote "<- Back To List", build_widget_url(:back_to_catalog) %>
3
- <br/><br/>
4
- <ul style="margin: 0;padding: 0;list-style-type: none;">
5
- <% @product_type.images.each do |image| %>
6
- <li style="display: inline;background:none;">
7
- <img src="<%=image.data.url%>" />
8
- </li>
9
- <% end %>
10
- </ul>
11
- <br/>
12
- <h2>
13
- <%=@product_type.get_current_simple_amount_with_currency.nil? ? 'no price set' : @product_type.get_current_simple_amount_with_currency%>
14
- <br/>
15
- <%=@product_type.inventory_entries.first.number_available%> Available
16
- </h2>
17
- <hr/>
18
- <p>
19
- <%=raw @product_type.find_description_by_iid('long_description').description%>
20
- </p>
21
- <br/>
22
- <%=link_to_remote 'Add To Cart', build_widget_url(:add_to_cart, @product_type.id) %>
23
- </div>
@@ -1,175 +0,0 @@
1
- module Widgets
2
- module ShoppingCart
3
- class Base < ErpApp::Widgets::Base
4
- class Helper
5
- include Singleton
6
- include ActionView::Helpers::NumberHelper
7
- end
8
-
9
- def help
10
- Helper.instance
11
- end
12
-
13
- def price_summary
14
- @item_count = 0
15
- @cart_items_url = params[:cart_items_url]
16
-
17
- #if we have an order started get all charges
18
- order = ErpCommerce::OrderHelper.new(self).get_order
19
- @item_count = order.line_items.count unless order.nil?
20
- set_total_price(order)
21
-
22
- render
23
- end
24
-
25
- def cart_items
26
- @price = 0
27
- @products_url = params[:products_url]
28
- @order = ErpCommerce::OrderHelper.new(self).get_order(true)
29
- set_total_price(@order)
30
-
31
- render
32
- end
33
-
34
- def remove_from_cart
35
- @products_url = params[:products_url]
36
- @order = ErpCommerce::OrderHelper.new(self).remove_from_cart(params[:id])
37
- set_total_price(@order)
38
-
39
- render :update => {:id => "#{@uuid}_result", :view => :cart_items}
40
- end
41
-
42
- def checkout_demographics
43
- unless self.current_user.nil?
44
- params[:ship_to_billing] = 'on'
45
- params[:bill_to_email] = current_user.email
46
- @products_url = params[:products_url]
47
- @order = ErpCommerce::OrderHelper.new(self).get_order
48
- set_total_price(@order)
49
-
50
- render :update => {:id => "#{@uuid}_result", :view => :demographics}
51
- else
52
- render :update => {:id => "#{@uuid}_result", :view => :login}
53
- end
54
- end
55
-
56
- def checkout_payment
57
- @products_url = params[:products_url]
58
- order_helper = ErpCommerce::OrderHelper.new(self)
59
- @order = order_helper.get_order
60
- set_total_price(@order)
61
-
62
- messages = validate_demographics
63
- unless messages.empty?
64
-
65
- @billing_error_message = '<ul>'
66
- messages.select{|item| item =~ /^B/}.collect{|item| "<li>#{item}</li>"}.each do |html| @billing_error_message << html end
67
- @billing_error_message << '</ul>'
68
-
69
- @shipping_error_message = '<ul>'
70
- messages.select{|item| item =~ /^S/}.collect{|item| "<li>#{item}</li>"}.each do |html| @shipping_error_message << html end
71
- @shipping_error_message << '</ul>'
72
-
73
- render :update => {:id => "#{@uuid}_result", :view => :demographics}
74
- else
75
- @order = order_helper.set_demographic_info(params)
76
-
77
- render :update => {:id => "#{@uuid}_result", :view => :payment}
78
- end
79
- end
80
-
81
- def checkout_finalize
82
- @products_url = params[:products_url]
83
- success, @message, @order, @payment = ErpCommerce::OrderHelper.new(self).complete_order(params)
84
- set_total_price(@order)
85
-
86
- if success
87
- CheckoutMailer.email_confirmation(self.current_user.party.billing_email_address.email_address, @order, @payment).deliver
88
- render :update => {:id => "#{@uuid}_result", :view => :confirmation}
89
- else
90
- render :update => {:id => "#{@uuid}_result", :view => :payment}
91
- end
92
- end
93
-
94
- private
95
-
96
- def set_total_price(order)
97
- @price = 0
98
-
99
- #if we have an order started get all charges
100
- unless order.nil?
101
- order.get_total_charges.each do |money|
102
- @price += money.amount
103
- end
104
- end
105
-
106
- #format it
107
- @price = help.number_to_currency(@price)
108
- end
109
-
110
- def validate_demographics
111
- messages = []
112
-
113
- fields = [
114
- {:param => '_to_first_name', :name => 'First Name'},
115
- {:param => '_to_last_name', :name => 'Last Name'},
116
- {:param => '_to_address_line_1', :name => 'Address Line 1'},
117
- {:param => '_to_city', :name => 'City'},
118
- {:param => '_to_state', :name => 'State'},
119
- {:param => '_to_postal_code', :name => 'Postal Code'},
120
- {:param => '_to_country', :name => 'Country'},
121
- {:param => '_to_phone', :name => 'Phone'},
122
- {:param => '_to_email', :name => 'Email'}
123
- ]
124
-
125
- #check billing fields
126
- fields.each do |field|
127
- param = ('bill'+field[:param]).to_sym
128
- if params[param].blank?
129
- messages << "Billing #{field[:name]} is required."
130
- end
131
- end
132
-
133
- #check if shipping is different than billing
134
- unless params[:ship_to_billing] == 'on'
135
- #check shipping fields
136
- fields.each do |field|
137
- next if (field[:param] == '_to_phone' or field[:param] == '_to_email')
138
- param = ('ship'+field[:param]).to_sym
139
- if params[param].blank?
140
- messages << "Shipping #{field[:name]} is required."
141
- end
142
- end
143
- end
144
-
145
- messages
146
- end
147
-
148
- #should not be modified
149
- #modify at your own risk
150
- def locate
151
- File.dirname(__FILE__)
152
- end
153
-
154
- class << self
155
- def title
156
- "Shopping Cart"
157
- end
158
-
159
- def widget_name
160
- File.basename(File.dirname(__FILE__))
161
- end
162
-
163
- def base_layout
164
- begin
165
- file = File.join(File.dirname(__FILE__),"/views/layouts/base.html.erb")
166
- IO.read(file)
167
- rescue
168
- return nil
169
- end
170
- end
171
- end
172
-
173
- end#Base
174
- end#ShoppingCart
175
- end#Widgets
@@ -1,110 +0,0 @@
1
- Compass.ErpApp.Widgets.ShoppingCart = {
2
- template: new Ext.Template("<%= render_widget :shopping_cart,\n",
3
- " :action => :{action},\n",
4
- " :params => {:{symbol} => '{url}'} %>"),
5
-
6
- addShoppingCart: function () {
7
- var addShoppingCartWidget = Ext.create("Ext.window.Window", {
8
- layout: 'fit',
9
- width: 300,
10
- title: 'Add Shopping Cart Widget',
11
- height: 130,
12
- buttonAlign: 'center',
13
- items: Ext.create("Ext.form.Panel", {
14
- labelWidth: 100,
15
- frame: false,
16
- bodyStyle: 'padding:5px 5px 0',
17
- defaults: {
18
- width: 225
19
- },
20
- items: [
21
- {
22
- xtype: 'combo',
23
- forceSelection: true,
24
- store: [
25
- ['price_summary', 'Price Summary'],
26
- ['cart_items', 'Cart Items']
27
- ],
28
- fieldLabel: 'Widget View',
29
- value: 'price_summary',
30
- name: 'widgetLayout',
31
- allowBlank: false,
32
- triggerAction: 'all',
33
- listeners: {
34
- change: function (field, newValue, oldValue) {
35
- var basicForm = field.findParentByType('form').getForm();
36
- var cartItemsUrlField = basicForm.findField('cartItemsUrl');
37
- var productsUrlField = basicForm.findField('productsUrl');
38
- if (newValue == 'price_summary') {
39
- cartItemsUrlField.show();
40
- productsUrlField.hide();
41
- cartItemsUrlField.setValue('/cart-summary');
42
- }
43
- else {
44
- productsUrlField.show();
45
- cartItemsUrlField.hide();
46
- productsUrlField.setValue('/products');
47
- }
48
- }
49
- }
50
- },
51
- {
52
- xtype: 'textfield',
53
- fieldLabel: 'Cart Items Url',
54
- name: 'cartItemsUrl',
55
- hidden: false,
56
- value: '/cart-items'
57
- },
58
- {
59
- xtype: 'textfield',
60
- fieldLabel: 'Products Url',
61
- name: 'productsUrl',
62
- value: '/products',
63
- hidden: true
64
- }
65
- ]
66
- }),
67
- buttons: [
68
- {
69
- text: 'Submit',
70
- listeners: {
71
- 'click': function (button) {
72
- var window = button.findParentByType('window');
73
- var formPanel = window.query('form')[0];
74
- var basicForm = formPanel.getForm();
75
- var action = basicForm.findField('widgetLayout').getValue();
76
-
77
- var data = {action: action};
78
- if (action == 'price_summary') {
79
- data.symbol = 'cart_items_url';
80
- data.url = basicForm.findField('cartItemsUrl').getValue();
81
- }
82
- else {
83
- data.symbol = 'products_url';
84
- data.url = basicForm.findField('productsUrl').getValue();
85
- }
86
-
87
- //add rendered template to center region editor
88
- Ext.getCmp('knitkitCenterRegion').addContentToActiveCodeMirror(Compass.ErpApp.Widgets.ShoppingCart.template.apply(data));
89
- addShoppingCartWidget.close();
90
- }
91
- }
92
- },
93
- {
94
- text: 'Close',
95
- handler: function () {
96
- addShoppingCartWidget.close();
97
- }
98
- }
99
- ]
100
-
101
- });
102
- addShoppingCartWidget.show();
103
- }
104
- };
105
-
106
- Compass.ErpApp.Widgets.AvailableWidgets.push({
107
- name: 'Shopping Cart',
108
- iconUrl: '/images/icons/shopping_cart/shopping_cart_48x48.png',
109
- onClick: Compass.ErpApp.Widgets.ShoppingCart.addShoppingCart
110
- });
@@ -1,83 +0,0 @@
1
- <style type="text/css">
2
- #products-view {
3
- font-family:'Lucida Grande','Lucida Sans Unicode',sans-serif;
4
- text-align:center;
5
- font-size:14px;
6
- width:100%;
7
- border-collapse: collapse;
8
- border: 2px solid #CCCCCC;
9
- }
10
-
11
- #products-view a {
12
- text-decoration:none;
13
- }
14
-
15
- #products-view img {
16
- height:60px;
17
- width:65px;
18
- padding-right:15px;
19
- }
20
-
21
- #products-view div
22
- {
23
- float:left;
24
- text-align:left;
25
- }
26
-
27
- #products-view th {
28
- padding: 0 0.5em;
29
- height:30px;
30
- text-align:center;
31
- background:url("/images/knitkit/footer.png") repeat-x scroll 0 0 #29425E;
32
- }
33
-
34
- .highlight:hover
35
- {
36
- background-color:#FFFFEE;
37
- }
38
-
39
- #products-view td+td {
40
- border-left: 1px solid #CCC;
41
- text-align: center;
42
- }
43
- </style>
44
- <div id="<%=widget_result_id%>">
45
- <h2>Cart Items</h2>
46
- <% unless @order.order_line_items.empty? %>
47
- <table id="products-view">
48
- <thead>
49
- <tr>
50
- <th>Product</th>
51
- <th>Description</th>
52
- <th>Quantity</th>
53
- <th>Remove</th>
54
- <th>Total</th>
55
- </tr>
56
- </thead>
57
- <tbody>
58
- <% @order.order_line_items.each do |order_line_item| %>
59
- <tr class="product-wrap highlight">
60
- <td>
61
- <div><img src="<%=order_line_item.product_type.images.empty? ? '/images/img_blank.png' : order_line_item.product_type.images.first.data.url%>" alt="Product Image" /></div>
62
- <div>
63
- <span><%= raw order_line_item.product_type.description %></span><br/>
64
- </div>
65
- </td>
66
- <td><%= raw order_line_item.product_type.descriptions.find_by_internal_identifier('long_description').description%></td>
67
- <td>1</td>
68
- <td><%=link_to_remote 'Remove', build_widget_url(:remove_from_cart, order_line_item.id)%></td>
69
- <td><span><%=order_line_item.product_type.get_current_simple_amount_with_currency.nil? ? 'no price set' : order_line_item.product_type.get_current_simple_amount_with_currency%></span></td>
70
- </tr>
71
- <%end%>
72
- </tbody>
73
- </table>
74
- <hr />
75
- <div style="float:right"><h2>Total <%=@price%></h2></div>
76
- <a href="<%=@products_url%>">Continue Shopping</a><%=link_to_remote ' | Check Out', build_widget_url(:checkout_demographics) unless @order.order_line_items.empty?%>
77
- <%else%>
78
- <h2>No items in cart.</h2>
79
- <%end%>
80
- </div>
81
- <script type="text/javascript">
82
- Compass.ErpApp.Widgets.refreshWidget('shopping_cart', 'price_summary');
83
- </script>