borutus 0.2.1 → 0.2.2

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.
@@ -7,7 +7,7 @@ module Borutus
7
7
  it { is_expected.to delegate_method(:name).to(:account).with_prefix }
8
8
  end
9
9
 
10
- subject { FactoryGirl.build(:amount) }
10
+ subject { FactoryBot.build(:amount) }
11
11
  it { is_expected.not_to be_valid } # construct a child class instead
12
12
  end
13
13
  end
@@ -1,14 +1,14 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  module Borutus
4
4
  describe Entry do
5
- let(:entry) { FactoryGirl.build(:entry) }
5
+ let(:entry) { FactoryBot.build(:entry) }
6
6
  subject { entry }
7
7
 
8
8
  it { is_expected.not_to be_valid }
9
9
 
10
10
  context "with credit and debit" do
11
- let(:entry) { FactoryGirl.build(:entry_with_credit_and_debit) }
11
+ let(:entry) { FactoryBot.build(:entry_with_credit_and_debit) }
12
12
  it { is_expected.to be_valid }
13
13
 
14
14
  it "should require a description" do
@@ -18,35 +18,35 @@ module Borutus
18
18
  end
19
19
 
20
20
  context "with a debit" do
21
- before {
22
- entry.debit_amounts << FactoryGirl.build(:debit_amount, entry: entry)
23
- }
21
+ before do
22
+ entry.debit_amounts << FactoryBot.build(:debit_amount, entry: entry)
23
+ end
24
24
  it { is_expected.not_to be_valid }
25
25
 
26
26
  context "with an invalid credit" do
27
27
  before {
28
- entry.credit_amounts << FactoryGirl.build(:credit_amount, entry: entry, amount: nil)
28
+ entry.credit_amounts << FactoryBot.build(:credit_amount, entry: entry, amount: nil)
29
29
  }
30
30
  it { is_expected.not_to be_valid }
31
31
  end
32
32
  end
33
33
 
34
34
  context "with a credit" do
35
- before {
36
- entry.credit_amounts << FactoryGirl.build(:credit_amount, entry: entry)
37
- }
35
+ before do
36
+ entry.credit_amounts << FactoryBot.build(:credit_amount, entry: entry)
37
+ end
38
38
  it { is_expected.not_to be_valid }
39
39
 
40
40
  context "with an invalid debit" do
41
- before {
42
- entry.debit_amounts << FactoryGirl.build(:debit_amount, entry: entry, amount: nil)
43
- }
41
+ before do
42
+ entry.debit_amounts << FactoryBot.build(:debit_amount, entry: entry, amount: nil)
43
+ end
44
44
  it { is_expected.not_to be_valid }
45
45
  end
46
46
  end
47
47
 
48
48
  context "without a date" do
49
- let(:entry) { FactoryGirl.build(:entry_with_credit_and_debit, date: nil) }
49
+ let(:entry) { FactoryBot.build(:entry_with_credit_and_debit, date: nil) }
50
50
 
51
51
  context "should assign a default date before being saved" do
52
52
  before { entry.save! }
@@ -55,44 +55,50 @@ module Borutus
55
55
  end
56
56
 
57
57
  it "should require the debit and credit amounts to cancel" do
58
- entry.credit_amounts << FactoryGirl.build(:credit_amount, :amount => 100, :entry => entry)
59
- entry.debit_amounts << FactoryGirl.build(:debit_amount, :amount => 200, :entry => entry)
58
+ entry.credit_amounts << FactoryBot.build(:credit_amount, amount: 100, entry: entry)
59
+ entry.debit_amounts << FactoryBot.build(:debit_amount, amount: 200, entry: entry)
60
60
  expect(entry).not_to be_valid
61
- expect(entry.errors['base']).to eq(["The credit and debit amounts are not equal"])
61
+ expect(entry.errors["base"]).to eq(["The credit and debit amounts are not equal"])
62
62
  end
63
63
 
64
64
  it "should require the debit and credit amounts to cancel even with fractions" do
65
- entry = FactoryGirl.build(:entry)
66
- entry.credit_amounts << FactoryGirl.build(:credit_amount, :amount => 100.1, :entry => entry)
67
- entry.debit_amounts << FactoryGirl.build(:debit_amount, :amount => 100.2, :entry => entry)
65
+ entry = FactoryBot.build(:entry)
66
+ entry.credit_amounts << FactoryBot.build(:credit_amount, amount: 100.1, entry: entry)
67
+ entry.debit_amounts << FactoryBot.build(:debit_amount, amount: 100.2, entry: entry)
68
68
  expect(entry).not_to be_valid
69
- expect(entry.errors['base']).to eq(["The credit and debit amounts are not equal"])
69
+ expect(entry.errors["base"]).to eq(["The credit and debit amounts are not equal"])
70
70
  end
71
71
 
72
72
  it "should ignore debit and credit amounts marked for destruction to cancel" do
73
- entry.credit_amounts << FactoryGirl.build(:credit_amount, :amount => 100, :entry => entry)
74
- debit_amount = FactoryGirl.build(:debit_amount, :amount => 100, :entry => entry)
73
+ entry.credit_amounts << FactoryBot.build(:credit_amount, amount: 100, entry: entry)
74
+ debit_amount = FactoryBot.build(:debit_amount, amount: 100, entry: entry)
75
75
  debit_amount.mark_for_destruction
76
76
  entry.debit_amounts << debit_amount
77
77
  expect(entry).not_to be_valid
78
- expect(entry.errors['base']).to eq(["The credit and debit amounts are not equal"])
78
+ expect(entry.errors["base"]).to eq(["The credit and debit amounts are not equal"])
79
79
  end
80
80
 
81
81
  it "should have a polymorphic commercial document associations" do
82
- mock_document = FactoryGirl.create(:asset) # one would never do this, but it allows us to not require a migration for the test
83
- entry = FactoryGirl.build(:entry_with_credit_and_debit, commercial_document: mock_document)
82
+ mock_document = FactoryBot.create(:asset) # one would never do this, but it allows us to not require a migration for the test
83
+ entry = FactoryBot.build(:entry_with_credit_and_debit, commercial_document: mock_document)
84
84
  entry.save!
85
85
  saved_entry = Entry.find(entry.id)
86
86
  expect(saved_entry.commercial_document).to eq(mock_document)
87
87
  end
88
88
 
89
89
  context "given a set of accounts" do
90
- let(:mock_document) { FactoryGirl.create(:asset) }
91
- let!(:accounts_receivable) { FactoryGirl.create(:asset, name: "Accounts Receivable") }
92
- let!(:sales_revenue) { FactoryGirl.create(:revenue, name: "Sales Revenue") }
93
- let!(:sales_tax_payable) { FactoryGirl.create(:liability, name: "Sales Tax Payable") }
90
+ let(:mock_document) { FactoryBot.create(:asset) }
91
+ let!(:accounts_receivable) do
92
+ FactoryBot.create(:asset, name: "Accounts Receivable")
93
+ end
94
+ let!(:sales_revenue) do
95
+ FactoryBot.create(:revenue, name: "Sales Revenue")
96
+ end
97
+ let!(:sales_tax_payable) do
98
+ FactoryBot.create(:liability, name: "Sales Tax Payable")
99
+ end
94
100
 
95
- shared_examples_for 'a built-from-hash Borutus::Entry' do
101
+ shared_examples_for "a built-from-hash Borutus::Entry" do
96
102
  its(:credit_amounts) { is_expected.not_to be_empty }
97
103
  its(:debit_amounts) { is_expected.not_to be_empty }
98
104
  it { is_expected.to be_valid }
@@ -118,31 +124,31 @@ module Borutus
118
124
  context "when given a credit/debits hash with :account => Account" do
119
125
  let(:hash) {
120
126
  {
121
- description: "Sold some widgets",
122
- commercial_document: mock_document,
123
- debits: [{account: accounts_receivable, amount: 50}],
124
- credits: [
125
- {account: sales_revenue, amount: 45},
126
- {account: sales_tax_payable, amount: 5}
127
- ]
127
+ description: "Sold some widgets",
128
+ commercial_document: mock_document,
129
+ debits: [{ account: accounts_receivable, amount: 50 }],
130
+ credits: [
131
+ { account: sales_revenue, amount: 45 },
132
+ { account: sales_tax_payable, amount: 5 },
133
+ ],
128
134
  }
129
135
  }
130
- include_examples 'a built-from-hash Borutus::Entry'
136
+ include_examples "a built-from-hash Borutus::Entry"
131
137
  end
132
138
 
133
139
  context "when given a credit/debits hash with :account_name => String" do
134
140
  let(:hash) {
135
141
  {
136
- description: "Sold some widgets",
137
- commercial_document: mock_document,
138
- debits: [{account_name: accounts_receivable.name, amount: 50}],
139
- credits: [
140
- {account_name: sales_revenue.name, amount: 45},
141
- {account_name: sales_tax_payable.name, amount: 5}
142
- ]
142
+ description: "Sold some widgets",
143
+ commercial_document: mock_document,
144
+ debits: [{ account_name: accounts_receivable.name, amount: 50 }],
145
+ credits: [
146
+ { account_name: sales_revenue.name, amount: 45 },
147
+ { account_name: sales_tax_payable.name, amount: 5 },
148
+ ],
143
149
  }
144
150
  }
145
- include_examples 'a built-from-hash Borutus::Entry'
151
+ include_examples "a built-from-hash Borutus::Entry"
146
152
  end
147
153
  end
148
154
 
@@ -154,7 +160,7 @@ module Borutus
154
160
  after { ::ActiveSupport::Deprecation.silenced = false }
155
161
 
156
162
  context "when used at all" do
157
- let(:hash) { Hash.new }
163
+ let(:hash) { {} }
158
164
 
159
165
  it("should be deprecated") {
160
166
  # .build is the only thing deprecated
@@ -162,9 +168,7 @@ module Borutus
162
168
  entry
163
169
  }
164
170
  end
165
-
166
171
  end
167
172
  end
168
-
169
173
  end
170
174
  end
@@ -10,7 +10,7 @@ module Borutus
10
10
  Borutus.enable_tenancy = true
11
11
  Borutus.tenant_class = 'Borutus::Entry'
12
12
 
13
- FactoryGirlHelpers.reload()
13
+ FactoryBotHelpers.reload()
14
14
  Borutus::Asset.new
15
15
  end
16
16
 
@@ -23,21 +23,21 @@ module Borutus
23
23
  Borutus.enable_tenancy = false
24
24
  Borutus.tenant_class = nil
25
25
 
26
- FactoryGirlHelpers.reload()
26
+ FactoryBotHelpers.reload()
27
27
  end
28
28
 
29
29
  it 'validate uniqueness of name scoped to tenant' do
30
- account = FactoryGirl.create(:asset, tenant_id: 10)
30
+ account = FactoryBot.create(:asset, tenant_id: 10)
31
31
 
32
- record = FactoryGirl.build(:asset, name: account.name, tenant_id: 10)
32
+ record = FactoryBot.build(:asset, name: account.name, tenant_id: 10)
33
33
  expect(record).not_to be_valid
34
34
  expect(record.errors[:name]).to eq(['has already been taken'])
35
35
  end
36
36
 
37
37
  it 'allows same name scoped under a different tenant' do
38
- account = FactoryGirl.create(:asset, tenant_id: 10)
38
+ account = FactoryBot.create(:asset, tenant_id: 10)
39
39
 
40
- record = FactoryGirl.build(:asset, name: account.name, tenant_id: 11)
40
+ record = FactoryBot.build(:asset, name: account.name, tenant_id: 11)
41
41
  expect(record).to be_valid
42
42
  end
43
43
  end
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  module Borutus
4
4
  describe EntriesController do
@@ -1,38 +1,40 @@
1
- require 'coveralls'
1
+ require "coveralls"
2
2
  Coveralls.wear!
3
3
 
4
- require 'pry'
4
+ require "pry"
5
5
 
6
- ENV["RAILS_ENV"] ||= 'test'
6
+ ENV["RAILS_ENV"] ||= "test"
7
7
 
8
- require File.expand_path(File.dirname(__FILE__) + "/../fixture_rails_root/config/environment")
9
- require Rails.root.join('db/schema').to_s
8
+ require File.expand_path(
9
+ File.dirname(__FILE__) + "/../fixture_rails_root/config/environment",
10
+ )
11
+ require Rails.root.join("db/schema").to_s
10
12
 
11
- require 'rspec/rails'
13
+ require "rspec/rails"
12
14
 
13
- $: << File.expand_path(File.dirname(__FILE__) + '/../lib/')
15
+ $LOAD_PATH << File.expand_path(File.dirname(__FILE__) + "/../lib/")
14
16
 
15
- require 'borutus'
16
- require 'kaminari'
17
+ require "borutus"
18
+ require "kaminari"
17
19
 
18
20
  Dir[
19
21
  File.expand_path(
20
- File.join(File.dirname(__FILE__), 'support', '**', '*.rb')
22
+ File.join(File.dirname(__FILE__), "support", "**", "*.rb"),
21
23
  )
22
24
  ].each do |f|
23
25
  require f
24
26
  end
25
27
 
26
- require 'factory_girl'
28
+ require "factory_bot"
27
29
 
28
30
  borutus_definitions = File.expand_path(
29
- File.join(File.dirname(__FILE__), 'factories')
31
+ File.join(File.dirname(__FILE__), "factories"),
30
32
  )
31
- FactoryGirl.definition_file_paths << borutus_definitions
33
+ FactoryBot.definition_file_paths << borutus_definitions
32
34
 
33
35
  RSpec.configure do |config|
34
36
  config.use_transactional_fixtures = true
35
37
  config.infer_spec_type_from_file_location!
36
38
  end
37
39
 
38
- FactoryGirlHelpers.reload()
40
+ FactoryBotHelpers.reload
@@ -1,6 +1,6 @@
1
1
  shared_examples_for 'a Borutus::Account subtype' do |elements|
2
2
  let(:contra) { false }
3
- let(:account) { FactoryGirl.create(elements[:kind], contra: contra)}
3
+ let(:account) { FactoryBot.create(elements[:kind], contra: contra)}
4
4
  subject { account }
5
5
 
6
6
  describe "class methods" do
@@ -39,7 +39,7 @@ shared_examples_for 'a Borutus::Account subtype' do |elements|
39
39
  end
40
40
 
41
41
  describe "when given a debit" do
42
- before { FactoryGirl.create(:debit_amount, account: account) }
42
+ before { FactoryBot.create(:debit_amount, account: account) }
43
43
  its(:balance) { is_expected.to be.send(debit_condition, 0) }
44
44
 
45
45
  describe "on a contra account" do
@@ -49,7 +49,7 @@ shared_examples_for 'a Borutus::Account subtype' do |elements|
49
49
  end
50
50
 
51
51
  describe "when given a credit" do
52
- before { FactoryGirl.create(:credit_amount, account: account) }
52
+ before { FactoryBot.create(:credit_amount, account: account) }
53
53
  its(:balance) { is_expected.to be.send(credit_condition, 0) }
54
54
 
55
55
  describe "on a contra account" do
@@ -1,5 +1,5 @@
1
1
  shared_examples_for 'a Borutus::Amount subtype' do |elements|
2
- let(:amount) { FactoryGirl.build(elements[:kind]) }
2
+ let(:amount) { FactoryBot.build(elements[:kind]) }
3
3
  subject { amount }
4
4
 
5
5
  it { is_expected.to be_valid }
@@ -0,0 +1,8 @@
1
+ module FactoryBotHelpers
2
+ def self.reload
3
+ FactoryBot.factories.clear
4
+ FactoryBot.sequences.clear
5
+ FactoryBot.traits.clear
6
+ FactoryBot.find_definitions
7
+ end
8
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: borutus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ramon Tayag
@@ -9,22 +9,8 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-01-04 00:00:00.000000000 Z
12
+ date: 2019-10-25 00:00:00.000000000 Z
13
13
  dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: rails
16
- requirement: !ruby/object:Gem::Requirement
17
- requirements:
18
- - - ">"
19
- - !ruby/object:Gem::Version
20
- version: '4.0'
21
- type: :runtime
22
- prerelease: false
23
- version_requirements: !ruby/object:Gem::Requirement
24
- requirements:
25
- - - ">"
26
- - !ruby/object:Gem::Version
27
- version: '4.0'
28
14
  - !ruby/object:Gem::Dependency
29
15
  name: jquery-rails
30
16
  requirement: !ruby/object:Gem::Requirement
@@ -68,7 +54,35 @@ dependencies:
68
54
  - !ruby/object:Gem::Version
69
55
  version: '1.0'
70
56
  - !ruby/object:Gem::Dependency
71
- name: yard
57
+ name: light-service
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 0.11.0
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 0.11.0
70
+ - !ruby/object:Gem::Dependency
71
+ name: rails
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">"
75
+ - !ruby/object:Gem::Version
76
+ version: '4.0'
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">"
82
+ - !ruby/object:Gem::Version
83
+ version: '4.0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: shoulda-matchers
72
86
  requirement: !ruby/object:Gem::Requirement
73
87
  requirements:
74
88
  - - ">="
@@ -82,7 +96,7 @@ dependencies:
82
96
  - !ruby/object:Gem::Version
83
97
  version: '0'
84
98
  - !ruby/object:Gem::Dependency
85
- name: shoulda-matchers
99
+ name: yard
86
100
  requirement: !ruby/object:Gem::Requirement
87
101
  requirements:
88
102
  - - ">="
@@ -95,11 +109,14 @@ dependencies:
95
109
  - - ">="
96
110
  - !ruby/object:Gem::Version
97
111
  version: '0'
98
- description: The borutus plugin provides a complete double entry accounting system
99
- for use in any Ruby on Rails application. The plugin follows general Double Entry
100
- Bookkeeping practices. All calculations are done using BigDecimal in order to prevent
101
- floating point rounding errors. The plugin requires a decimal type on your database
102
- as well.
112
+ description: |2-
113
+
114
+ The borutus plugin provides a complete double entry accounting system for
115
+ use in any Ruby on Rails application. The plugin follows general Double
116
+ Entry Bookkeeping practices. All calculations are done using BigDecimal
117
+ in order to prevent floating point rounding errors. The plugin requires
118
+ a decimal type on your database as well.
119
+ %
103
120
  email:
104
121
  - ramon.tayag@gmail.com
105
122
  - ace.subido@gmail.com
@@ -134,6 +151,7 @@ files:
134
151
  - app/models/borutus/no_tenancy.rb
135
152
  - app/models/borutus/revenue.rb
136
153
  - app/models/borutus/tenancy.rb
154
+ - app/services/borutus/accounts/build_running_balance_query.rb
137
155
  - app/views/borutus/accounts/index.html.erb
138
156
  - app/views/borutus/entries/index.html.erb
139
157
  - app/views/borutus/reports/_account.html.erb
@@ -151,6 +169,7 @@ files:
151
169
  - config/secret_token.rb
152
170
  - config/session_store.rb
153
171
  - db/migrate/20160422010135_create_borutus_tables.rb
172
+ - db/migrate/20191025095830_add_borutus_amount_counter_cache.rb
154
173
  - lib/borutus.rb
155
174
  - lib/borutus/engine.rb
156
175
  - lib/borutus/version.rb
@@ -186,7 +205,7 @@ files:
186
205
  - spec/support/account_shared_examples.rb
187
206
  - spec/support/active_support_helpers.rb
188
207
  - spec/support/amount_shared_examples.rb
189
- - spec/support/factory_girl_helpers.rb
208
+ - spec/support/factory_bot_helpers.rb
190
209
  - spec/support/shoulda_matchers.rb
191
210
  homepage: http://github.com/bloom-solutions/borutus
192
211
  licenses: []
@@ -237,5 +256,5 @@ test_files:
237
256
  - spec/support/account_shared_examples.rb
238
257
  - spec/support/active_support_helpers.rb
239
258
  - spec/support/amount_shared_examples.rb
240
- - spec/support/factory_girl_helpers.rb
259
+ - spec/support/factory_bot_helpers.rb
241
260
  - spec/support/shoulda_matchers.rb