piggybak 0.6.22 → 0.6.23

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.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- piggybak (0.6.22)
4
+ piggybak (0.6.23)
5
5
  activemerchant
6
6
  countries
7
7
  devise
data/README.md CHANGED
@@ -63,13 +63,9 @@ Visit the project website [here][project-website] to see more documentation and
63
63
  TODO
64
64
  ========
65
65
 
66
- * Ensure that changes in nested addresses are recorded on order notes.
67
-
68
- * Add/check validation to ensure sufficient inventory
66
+ * Fix tax calculation when coupon / discounts applied.
69
67
 
70
- * Add copy from billing above shipping address section button in admin
71
-
72
- * Re-add order logging / masking payment parameters
68
+ * Ensure that changes in nested addresses are recorded on order notes.
73
69
 
74
70
  Copyright
75
71
  ========
@@ -98,6 +98,10 @@ var piggybak = {
98
98
  },
99
99
  update_tax: function(field) {
100
100
  var billing_data = {};
101
+ billing_data['reduce_tax_subtotal'] = 0;
102
+ $('.reduce_tax_subtotal:visible').each(function(i, j) {
103
+ billing_data['reduce_tax_subtotal'] += parseFloat($(j).html().replace('$', ''));
104
+ });
101
105
  $('#billing_address input, #billing_address select').each(function(i, j) {
102
106
  var id = $(j).attr('id');
103
107
  id = id.replace("piggybak_order_billing_address_attributes_", '');
@@ -19,7 +19,17 @@ module Piggybak
19
19
  end
20
20
 
21
21
  def self.rate(method, object)
22
- (method.metadata.detect { |m| m.key == "rate" }.value.to_f * object.subtotal).to_c
22
+ taxable_total = object.subtotal
23
+ if object.is_a?(::Piggybak::Order)
24
+ Piggybak.config.line_item_types.each do |k, v|
25
+ if v.has_key?(:reduce_tax_subtotal) && v[:reduce_tax_subtotal]
26
+ taxable_total += object.send("#{k}_charge")
27
+ end
28
+ end
29
+ else
30
+ taxable_total += object.extra_data[:reduce_tax_subtotal].to_f
31
+ end
32
+ (method.metadata.detect { |m| m.key == "rate" }.value.to_f * taxable_total).to_c
23
33
  end
24
34
  end
25
35
  end
@@ -40,7 +40,7 @@
40
40
  <% if page != "cart" -%>
41
41
  <tr>
42
42
  <td colspan="<%= page == "cart" ? "3" : "2" %>"></td>
43
- <td>Tax</td>
43
+ <td>Estimated Tax</td>
44
44
  <td id="tax_total"></td>
45
45
  </tr>
46
46
  <tr>
@@ -53,7 +53,7 @@
53
53
  <tr id="<%= "#{k}_row" %>" style="display:none;">
54
54
  <td colspan="<%= page == "cart" ? "3" : "2" %>"></td>
55
55
  <td><%= v[:display_in_cart] %></td>
56
- <td class="extra_totals" id="<%= k %>_total">$0.00</td>
56
+ <td class="extra_totals <%= 'reduce_tax_subtotal' if v.has_key?(:reduce_tax_subtotal) && v[:reduce_tax_subtotal] %>" id="<%= k %>_total">$0.00</td>
57
57
  </tr>
58
58
  <% end -%>
59
59
  <% end -%>
@@ -7,12 +7,11 @@ Phone: <%= @order.phone %>
7
7
  <%= line_item.quantity %> x <%= raw line_item.description %> (<%= number_to_currency line_item.price %>)
8
8
  <% end -%>
9
9
 
10
- Subtotal: <%= number_to_currency @order.line_items.sellables.inject(0) { |subtotal, li| subtotal + li.price } %>
11
- Shipping & Handling: <%= number_to_currency @order.line_items.shipments.inject(0) { |shipping, shipment| shipping + shipment.price } %>
12
- Tax: <%= number_to_currency @order.tax_charge %>
10
+ <% Piggybak::LineItem.sorted_line_item_types.each do |type| -%>
11
+ <%= type.to_s.pluralize.titleize %>: <%= number_to_currency @order.send("#{type}_charge") %>
12
+ <% end -%>
13
+
13
14
  Total: <%= number_to_currency @order.total %>
14
- Less Payment: <%= number_to_currency(@order.line_items.payments.inject(0) { |total, p| total + p.price if p.payment.status == "paid" }) %>
15
- Adjustments: <%= number_to_currency(@order.line_items.adjustments.inject(0) { |total, adj| total + adj.price }) %>
16
15
  Balance Due: <%= number_to_currency @order.total_due %>
17
16
 
18
17
  Billing Information
@@ -82,7 +82,7 @@ module Piggybak
82
82
  # e.g. self.line_items.sellables
83
83
  # e.g. self.line_items.taxes
84
84
  define_method "#{k.to_s.pluralize}" do
85
- proxy_association.proxy.select { |li| li.line_item_type == "#{k}" }.select { |li| !li.marked_for_destruction? }
85
+ proxy_association.proxy.select { |li| li.line_item_type == "#{k}" && !li.marked_for_destruction? }
86
86
  end
87
87
  end
88
88
  end
@@ -1,3 +1,3 @@
1
1
  module Piggybak
2
- VERSION = "0.6.22"
2
+ VERSION = "0.6.23"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: piggybak
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.22
4
+ version: 0.6.23
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-11-15 00:00:00.000000000 Z
14
+ date: 2012-11-16 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rails
@@ -234,7 +234,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
234
234
  version: '0'
235
235
  segments:
236
236
  - 0
237
- hash: -3911161906514988357
237
+ hash: -2079213283630134630
238
238
  required_rubygems_version: !ruby/object:Gem::Requirement
239
239
  none: false
240
240
  requirements:
@@ -243,7 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
243
243
  version: '0'
244
244
  segments:
245
245
  - 0
246
- hash: -3911161906514988357
246
+ hash: -2079213283630134630
247
247
  requirements: []
248
248
  rubyforge_project:
249
249
  rubygems_version: 1.8.23