invoicing 1.0.1 → 1.1.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.
- checksums.yaml +4 -4
- data/lib/invoicing/currency_value.rb +2 -2
- data/lib/invoicing/find_subclasses.rb +0 -37
- data/lib/invoicing/taxable.rb +2 -2
- data/lib/invoicing/time_dependent.rb +1 -1
- data/lib/invoicing/version.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b3b02e1ae4b997cffc4823f0f96fb5d1fbe74d1
|
4
|
+
data.tar.gz: 5b5e0c157a51d75596479c1dd2d64a7b5eed7018
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a79dc673daa8e55e12b143c4b88f26ac6c6e57e8a8149780995fef4249cb20b294a9634e1c674c5cdf1f7759486ae4afc0bd314f669f4966705de85de4c1a52a
|
7
|
+
data.tar.gz: 8548ee48d350d046bd1b36eeb26d59ab5f671a1c5887d70e6694eb27ec1d51c33a4de31892765fd377b4912e983354c84820200a961512af90c0fe2cfa4dd2f7
|
@@ -119,7 +119,7 @@ module Invoicing
|
|
119
119
|
|
120
120
|
included do
|
121
121
|
# Register callback if this is the first time acts_as_currency_value has been called
|
122
|
-
before_save :write_back_currency_values, :
|
122
|
+
before_save :write_back_currency_values, if: currency_value_class_info.previous_info.nil?
|
123
123
|
end
|
124
124
|
|
125
125
|
# Format a numeric monetary value into a human-readable string, in the currency of the
|
@@ -286,7 +286,7 @@ module Invoicing
|
|
286
286
|
|
287
287
|
unless value
|
288
288
|
raw_value = object.read_attribute(attr)
|
289
|
-
value = BigDecimal
|
289
|
+
value = BigDecimal(raw_value.to_s) unless raw_value.nil?
|
290
290
|
end
|
291
291
|
value
|
292
292
|
end
|
@@ -89,43 +89,6 @@ module Invoicing
|
|
89
89
|
# to be on the safe side you can ensure all subclasses are loaded when your application
|
90
90
|
# initialises -- but that's not completely DRY ;-)
|
91
91
|
module FindSubclasses
|
92
|
-
|
93
|
-
# Overrides <tt>ActiveRecord::Base.sanitize_sql_hash_for_conditions</tt> since this is the method
|
94
|
-
# used to transform a hash of conditions into an SQL query fragment. This overriding method
|
95
|
-
# searches for class method conditions in the hash and transforms them into a condition on the
|
96
|
-
# class name. All further work is delegated back to the superclass method.
|
97
|
-
#
|
98
|
-
# Condition formats are very similar to those accepted by +ActiveRecord+:
|
99
|
-
# {:my_class_method => 'value'} # known_subclasses.select{|cls| cls.my_class_method == 'value' }
|
100
|
-
# {:my_class_method => [1, 2]} # known_subclasses.select{|cls| [1, 2].include?(cls.my_class_method) }
|
101
|
-
# {:my_class_method => 3..6} # known_subclasses.select{|cls| (3..6).include?(cls.my_class_method) }
|
102
|
-
# {:my_class_method => true} # known_subclasses.select{|cls| cls.my_class_method }
|
103
|
-
# {:my_class_method => false} # known_subclasses.reject{|cls| cls.my_class_method }
|
104
|
-
def sanitize_sql_hash_for_conditions(attrs, table_name = quoted_table_name)
|
105
|
-
new_attrs = {}
|
106
|
-
|
107
|
-
attrs.each_pair do |attr, value|
|
108
|
-
attr = attr_base = attr.to_s
|
109
|
-
attr_table_name = table_name
|
110
|
-
|
111
|
-
# Extract table name from qualified attribute names
|
112
|
-
attr_table_name, attr_base = attr.split('.', 2) if attr.include?('.')
|
113
|
-
|
114
|
-
if columns_hash.include?(attr_base) || ![self.table_name, quoted_table_name].include?(attr_table_name)
|
115
|
-
new_attrs[attr] = value # Condition on a table column, or another table -- pass through unmodified
|
116
|
-
else
|
117
|
-
begin
|
118
|
-
matching_classes = select_matching_subclasses(attr_base, value)
|
119
|
-
new_attrs["#{self.table_name}.#{inheritance_column}"] = matching_classes.map{|cls| cls.name.to_s}
|
120
|
-
rescue NoMethodError
|
121
|
-
new_attrs[attr] = value # If the class method doesn't exist, fall back to passing condition through unmodified
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
super(new_attrs, table_name)
|
127
|
-
end
|
128
|
-
|
129
92
|
def expand_hash_conditions_for_aggregates(attrs)
|
130
93
|
new_attrs = {}
|
131
94
|
|
data/lib/invoicing/taxable.rb
CHANGED
@@ -296,7 +296,7 @@ module Invoicing
|
|
296
296
|
original_value = read_attribute("#{method_name}_taxed")
|
297
297
|
return nil if original_value.nil? # Can only have a rounding error if the taxed attr was assigned
|
298
298
|
|
299
|
-
original_value = BigDecimal
|
299
|
+
original_value = BigDecimal(original_value.to_s)
|
300
300
|
converted_value = send("#{method_name}_taxed")
|
301
301
|
|
302
302
|
return nil if converted_value.nil?
|
@@ -350,7 +350,7 @@ module Invoicing
|
|
350
350
|
# +to_status+ must each be either <tt>:taxed</tt> or <tt>:untaxed</tt>.
|
351
351
|
def convert(object, attr_without_suffix, value, from_status, to_status)
|
352
352
|
return nil if value.nil?
|
353
|
-
value = BigDecimal
|
353
|
+
value = BigDecimal(value.to_s)
|
354
354
|
return value if from_status == to_status
|
355
355
|
|
356
356
|
if to_status == :taxed
|
@@ -195,7 +195,7 @@ module Invoicing
|
|
195
195
|
# Create replaced_by association if it doesn't exist yet
|
196
196
|
replaced_by_id = time_dependent_class_info.method(:replaced_by_id)
|
197
197
|
unless respond_to? :replaced_by
|
198
|
-
belongs_to :replaced_by, :
|
198
|
+
belongs_to :replaced_by, class_name: name, foreign_key: replaced_by_id
|
199
199
|
end
|
200
200
|
|
201
201
|
# Create value_at and value_now method aliases
|
data/lib/invoicing/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: invoicing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Kleppmann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -126,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
126
|
version: '0'
|
127
127
|
requirements: []
|
128
128
|
rubyforge_project:
|
129
|
-
rubygems_version: 2.
|
129
|
+
rubygems_version: 2.6.14
|
130
130
|
signing_key:
|
131
131
|
specification_version: 4
|
132
132
|
summary: Ruby Invoicing Framework
|