plutus 0.11.0 → 0.16
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 +5 -5
- data/README.markdown +66 -40
- data/app/assets/javascripts/plutus/application.js +5 -4
- data/app/assets/javascripts/plutus/reports.js +5 -0
- data/app/assets/stylesheets/bootstrap-theme.min.css +5 -0
- data/app/assets/stylesheets/bootstrap.min.css +5 -0
- data/app/assets/stylesheets/plutus/application.css +11 -5
- data/app/controllers/plutus/accounts_controller.rb +1 -16
- data/app/controllers/plutus/application_controller.rb +4 -0
- data/app/controllers/plutus/entries_controller.rb +7 -17
- data/app/controllers/plutus/reports_controller.rb +40 -0
- data/app/models/plutus/account.rb +92 -7
- data/app/models/plutus/amount.rb +2 -11
- data/app/models/plutus/amounts_extension.rb +31 -6
- data/app/models/plutus/asset.rb +21 -18
- data/app/models/plutus/entry.rb +15 -3
- data/app/models/plutus/equity.rb +22 -19
- data/app/models/plutus/expense.rb +21 -18
- data/app/models/plutus/liability.rb +27 -19
- data/app/models/plutus/revenue.rb +22 -19
- data/app/models/plutus/tenancy.rb +5 -1
- data/app/views/layouts/plutus/_messages.html.erb +9 -0
- data/app/views/layouts/plutus/_navigation.html.erb +19 -0
- data/app/views/layouts/plutus/_navigation_links.html.erb +5 -0
- data/app/views/layouts/plutus/application.html.erb +19 -0
- data/app/views/plutus/accounts/index.html.erb +9 -12
- data/app/views/plutus/entries/index.html.erb +22 -11
- data/app/views/plutus/reports/_account.html.erb +28 -0
- data/app/views/plutus/reports/balance_sheet.html.erb +21 -0
- data/app/views/plutus/reports/income_statement.html.erb +24 -0
- data/config/routes.rb +6 -3
- data/{lib/generators/plutus/templates/migration.rb → db/migrate/20160422010135_create_plutus_tables.rb} +6 -10
- data/lib/generators/plutus/add_date_upgrade_generator.rb +11 -0
- data/lib/generators/plutus/base_generator.rb +19 -0
- data/lib/generators/plutus/plutus_generator.rb +8 -22
- data/lib/generators/plutus/templates/add_date_migration.rb +12 -0
- data/lib/generators/plutus/templates/tenant_migration.rb +1 -1
- data/lib/generators/plutus/templates/update_migration.rb +2 -2
- data/lib/generators/plutus/tenancy_generator.rb +2 -17
- data/lib/generators/plutus/upgrade_plutus_generator.rb +6 -22
- data/lib/plutus.rb +2 -5
- data/lib/plutus/engine.rb +5 -0
- data/lib/plutus/version.rb +1 -1
- data/spec/controllers/accounts_controller_spec.rb +11 -20
- data/spec/controllers/entries_controller_spec.rb +11 -20
- data/spec/controllers/reports_controller_spec.rb +24 -0
- data/spec/factories/account_factory.rb +6 -6
- data/spec/factories/amount_factory.rb +3 -3
- data/spec/factories/entry_factory.rb +1 -1
- data/spec/factories/tenant_factory.rb +12 -0
- data/spec/models/account_spec.rb +71 -8
- data/spec/models/amount_spec.rb +6 -1
- data/spec/models/entry_spec.rb +35 -63
- data/spec/models/tenancy_spec.rb +26 -8
- data/spec/routing/accounts_routing_spec.rb +6 -25
- data/spec/routing/entries_routing_spec.rb +6 -25
- data/spec/spec_helper.rb +4 -2
- data/spec/support/account_shared_examples.rb +14 -10
- data/spec/support/amount_shared_examples.rb +4 -4
- data/spec/support/shoulda_matchers.rb +8 -0
- metadata +100 -28
- data/app/views/plutus/accounts/show.html.erb +0 -59
- data/app/views/plutus/entries/show.html.erb +0 -46
- data/spec/schema.rb +0 -31
@@ -5,7 +5,11 @@ module Plutus
|
|
5
5
|
included do
|
6
6
|
validates :name, presence: true, uniqueness: { scope: :tenant_id }
|
7
7
|
|
8
|
-
|
8
|
+
if ActiveRecord::VERSION::MAJOR > 4
|
9
|
+
belongs_to :tenant, class_name: Plutus.tenant_class, optional: true
|
10
|
+
else
|
11
|
+
belongs_to :tenant, class_name: Plutus.tenant_class
|
12
|
+
end
|
9
13
|
end
|
10
14
|
end
|
11
15
|
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<%# Rails flash messages styled for Bootstrap 3.0 %>
|
2
|
+
<% flash.each do |name, msg| %>
|
3
|
+
<% if msg.is_a?(String) %>
|
4
|
+
<div class="alert alert-<%= name.to_s == 'notice' ? 'success' : 'danger' %>">
|
5
|
+
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
6
|
+
<%= content_tag :div, msg, :id => "flash_#{name}" %>
|
7
|
+
</div>
|
8
|
+
<% end %>
|
9
|
+
<% end %>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<%# navigation styled for Bootstrap 3.0 %>
|
2
|
+
<nav class="navbar navbar-default navbar-fixed-top">
|
3
|
+
<div class="container">
|
4
|
+
<div class="navbar-header">
|
5
|
+
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
|
6
|
+
<span class="sr-only">Toggle navigation</span>
|
7
|
+
<span class="icon-bar"></span>
|
8
|
+
<span class="icon-bar"></span>
|
9
|
+
<span class="icon-bar"></span>
|
10
|
+
</button>
|
11
|
+
<a class="navbar-brand" href="/"> Plutus</a>
|
12
|
+
</div>
|
13
|
+
<div class="collapse navbar-collapse">
|
14
|
+
<ul class="nav navbar-nav">
|
15
|
+
<%= render 'layouts/plutus/navigation_links' %>
|
16
|
+
</ul>
|
17
|
+
</div>
|
18
|
+
</div>
|
19
|
+
</nav>
|
@@ -0,0 +1,5 @@
|
|
1
|
+
<%# add navigation links to this file %>
|
2
|
+
<li><%= link_to "Balance Sheet", reports_balance_sheet_path%></li>
|
3
|
+
<li><%= link_to "Income Statement", reports_income_statement_path%></li>
|
4
|
+
<li><%= link_to "General Ledger", accounts_path%></li>
|
5
|
+
<li><%= link_to "Journal", entries_path%></li>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
5
|
+
<title>Plutus</title>
|
6
|
+
<%= stylesheet_link_tag "plutus/application", media: "all" %>
|
7
|
+
<%= javascript_include_tag "plutus/application" %>
|
8
|
+
<%= csrf_meta_tags %>
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
<header>
|
12
|
+
<%= render 'layouts/plutus/navigation' %>
|
13
|
+
</header>
|
14
|
+
<main role="main">
|
15
|
+
<%= render 'layouts/plutus/messages' %>
|
16
|
+
<%= yield %>
|
17
|
+
</main>
|
18
|
+
</body>
|
19
|
+
</html>
|
@@ -1,9 +1,11 @@
|
|
1
|
-
<div class="
|
2
|
-
<
|
1
|
+
<div class="container">
|
2
|
+
<center>
|
3
|
+
<h1>General Ledger</h1>
|
4
|
+
<br>
|
5
|
+
</center>
|
3
6
|
|
4
|
-
<table>
|
7
|
+
<table class="table table-striped table-hover">
|
5
8
|
<tr>
|
6
|
-
<th class="nobg">ID</th>
|
7
9
|
<th>Name</th>
|
8
10
|
<th>Type</th>
|
9
11
|
<th>Credit Balance</th>
|
@@ -13,17 +15,12 @@
|
|
13
15
|
|
14
16
|
<% @accounts.each do |account| %>
|
15
17
|
<tr class="<%= cycle("even", "odd") -%>">
|
16
|
-
<td><%=link_to(account.id, account_path(account.id)) %></td>
|
17
18
|
<td><%=h account.name %></td>
|
18
19
|
<td><%=h account.type.sub('Plutus::','') %></td>
|
19
|
-
<td><%=h account.credits_balance %></td>
|
20
|
-
<td><%=h account.debits_balance %></td>
|
21
|
-
<td><%=h account.balance %></td>
|
20
|
+
<td><%=h account.credits_balance.round(2) %></td>
|
21
|
+
<td><%=h account.debits_balance.round(2) %></td>
|
22
|
+
<td><%=h account.balance.round(2) %></td>
|
22
23
|
</tr>
|
23
24
|
<% end %>
|
24
25
|
</table>
|
25
|
-
|
26
|
-
<br />
|
27
|
-
|
28
|
-
<h3>Go to <%= link_to 'Entries', entries_path %></h3>
|
29
26
|
</div>
|
@@ -1,10 +1,19 @@
|
|
1
|
-
<div class="
|
2
|
-
<
|
1
|
+
<div class="container">
|
2
|
+
<center>
|
3
|
+
<h1>Journal</h1>
|
4
|
+
<br>
|
5
|
+
<%= form_tag({:action => 'index'}, {:method => :get, :class => 'form-inline'}) do%>
|
6
|
+
<div class="form-group">
|
7
|
+
Per page: <%= select_tag :limit, options_for_select([25, 100, 200, 300], selected: params[:limit]), class: 'form-control' %>
|
8
|
+
Order: <%= select_tag :order, options_for_select(['descending', 'ascending'], selected: params[:order]), class: 'form-control' %>
|
9
|
+
</div>
|
10
|
+
<button type="submit" class="btn btn-default">Refresh</button>
|
11
|
+
<% end %>
|
12
|
+
</center>
|
3
13
|
|
4
|
-
<table
|
14
|
+
<table class="table table-striped table-hover">
|
5
15
|
<thead>
|
6
16
|
<tr>
|
7
|
-
<th class="nobg">ID</th>
|
8
17
|
<th>Description</th>
|
9
18
|
<th>Debits</th>
|
10
19
|
<th>Credits</th>
|
@@ -14,7 +23,6 @@
|
|
14
23
|
<tbody>
|
15
24
|
<% @entries.each do |entry| %>
|
16
25
|
<tr class="<%= cycle("even", "odd") -%>">
|
17
|
-
<td><%=link_to(entry.id, entry_path(entry)) %></td>
|
18
26
|
<td><%=h entry.description %></td>
|
19
27
|
<td></td>
|
20
28
|
<td></td>
|
@@ -22,27 +30,30 @@
|
|
22
30
|
</tr>
|
23
31
|
<% entry.debit_amounts.each do |debit_amount| %>
|
24
32
|
<tr class="<%= cycle("odd", "odd") -%>">
|
25
|
-
<td></td>
|
26
33
|
<td> <%=h "#{debit_amount.account.name}" %></td>
|
27
|
-
<td><%=h debit_amount.amount %></td>
|
34
|
+
<td><%=h debit_amount.amount.round(2) %></td>
|
28
35
|
<td></td>
|
29
36
|
<td></td>
|
30
37
|
</tr>
|
31
38
|
<% end %>
|
32
39
|
<% entry.credit_amounts.each do |credit_amount| %>
|
33
40
|
<tr class="<%= cycle("odd", "odd") -%>">
|
34
|
-
<td></td>
|
35
41
|
<td> <%=h "#{credit_amount.account.name}" %></td>
|
36
42
|
<td></td>
|
37
|
-
<td><%=h credit_amount.amount %></td>
|
43
|
+
<td><%=h credit_amount.amount.round(2) %></td>
|
38
44
|
<td></td>
|
39
45
|
</tr>
|
40
46
|
<% end %>
|
47
|
+
<tr class="<%= cycle("odd", "odd") -%>">
|
48
|
+
<td></td>
|
49
|
+
<td></td>
|
50
|
+
<td></td>
|
51
|
+
<td></td>
|
52
|
+
</tr>
|
41
53
|
<% end %>
|
42
54
|
</tbody>
|
43
55
|
</table>
|
44
56
|
|
45
|
-
|
57
|
+
<%= paginate @entries %>
|
46
58
|
|
47
|
-
<h3>Go to <%= link_to 'Accounts', accounts_path %></h3>
|
48
59
|
</div>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<table class="table table-striped table-hover">
|
2
|
+
<caption class="text-left"><b><%=name%></b></caption>
|
3
|
+
<thead>
|
4
|
+
<tr>
|
5
|
+
<th></th>
|
6
|
+
<th></th>
|
7
|
+
</tr>
|
8
|
+
</thead>
|
9
|
+
<% if accounts.count > 0%>
|
10
|
+
<tbody>
|
11
|
+
<% running_total = 0 %>
|
12
|
+
<% accounts.each do |account| %>
|
13
|
+
<% balance = account.balance(:from_date => @from_date, :to_date => @to_date) %>
|
14
|
+
<tr class="<%= cycle("even", "odd") -%>">
|
15
|
+
<td><%=h account.name %></td>
|
16
|
+
<td><%=h balance.round(2) %></td>
|
17
|
+
<% running_total += balance %>
|
18
|
+
</tr>
|
19
|
+
<% end %>
|
20
|
+
<tr class="<%= cycle("even", "odd") -%>">
|
21
|
+
<strong>
|
22
|
+
<td>Total <%= name %></td>
|
23
|
+
<td><%= running_total.round(2) %></td>
|
24
|
+
</strong>
|
25
|
+
</tr>
|
26
|
+
</tbody>
|
27
|
+
<% end %>
|
28
|
+
</table>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<div class="container">
|
2
|
+
<center>
|
3
|
+
<h1>Balance Sheet</h1>
|
4
|
+
|
5
|
+
<%= form_tag({:action => 'balance_sheet'}, {:method => :get, :class => 'form-inline'}) do%>
|
6
|
+
<div class="form-group">
|
7
|
+
<%= label_tag :date, nil, class: 'sr-only'%>
|
8
|
+
<%= text_field_tag :date, @to_date, :class => 'datepicker form-control' %>
|
9
|
+
</div>
|
10
|
+
<button type="submit" class="btn btn-default">Get Report</button>
|
11
|
+
<% end %>
|
12
|
+
</center>
|
13
|
+
|
14
|
+
<br>
|
15
|
+
|
16
|
+
<%= render 'account', :name => "Assets", :accounts => @assets %>
|
17
|
+
<%= render 'account', :name => "Liabilities", :accounts => @liabilities %>
|
18
|
+
<%= render 'account', :name => "Equity", :accounts => @equity %>
|
19
|
+
|
20
|
+
|
21
|
+
</div>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<div class="container">
|
2
|
+
<center>
|
3
|
+
<h1>Income Statement</h1>
|
4
|
+
|
5
|
+
<%= form_tag({:action => 'income_statement'}, {:method => :get, :class => 'form-inline'}) do%>
|
6
|
+
<div class="form-group">
|
7
|
+
<%= label_tag :from_date, nil, class: 'sr-only'%>
|
8
|
+
<%= text_field_tag :from_date, @from_date, :class => 'datepicker form-control', :placeholder => "Date" %>
|
9
|
+
</div>
|
10
|
+
<div class="form-group">
|
11
|
+
<%= label_tag :to_date, nil, class: 'sr-only'%>
|
12
|
+
<%= text_field_tag :to_date, @to_date, :class => 'datepicker form-control', :placeholder => "Date" %>
|
13
|
+
</div>
|
14
|
+
<button type="submit" class="btn btn-default">Get Report</button>
|
15
|
+
<% end %>
|
16
|
+
</center>
|
17
|
+
|
18
|
+
<br>
|
19
|
+
|
20
|
+
<%= render 'account', :name => "Revenues", :accounts => @revenues %>
|
21
|
+
<%= render 'account', :name => "Expenses", :accounts => @expenses %>
|
22
|
+
|
23
|
+
|
24
|
+
</div>
|
data/config/routes.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
Plutus::Engine.routes.draw do
|
2
|
-
root :to =>
|
2
|
+
root :to => 'reports#balance_sheet'
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
get 'reports/balance_sheet' => 'reports#balance_sheet'
|
5
|
+
get 'reports/income_statement' => 'reports#income_statement'
|
6
|
+
|
7
|
+
resources :accounts, only: [:index]
|
8
|
+
resources :entries, only: [:index]
|
6
9
|
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
class CreatePlutusTables < ActiveRecord::Migration
|
2
|
-
def
|
1
|
+
class CreatePlutusTables < ActiveRecord::Migration[4.2]
|
2
|
+
def change
|
3
3
|
create_table :plutus_accounts do |t|
|
4
4
|
t.string :name
|
5
5
|
t.string :type
|
6
|
-
t.boolean :contra
|
6
|
+
t.boolean :contra, default: false
|
7
7
|
|
8
8
|
t.timestamps
|
9
9
|
end
|
@@ -11,11 +11,13 @@ class CreatePlutusTables < ActiveRecord::Migration
|
|
11
11
|
|
12
12
|
create_table :plutus_entries do |t|
|
13
13
|
t.string :description
|
14
|
+
t.date :date
|
14
15
|
t.integer :commercial_document_id
|
15
16
|
t.string :commercial_document_type
|
16
17
|
|
17
18
|
t.timestamps
|
18
19
|
end
|
20
|
+
add_index :plutus_entries, :date
|
19
21
|
add_index :plutus_entries, [:commercial_document_id, :commercial_document_type], :name => "index_entries_on_commercial_doc"
|
20
22
|
|
21
23
|
create_table :plutus_amounts do |t|
|
@@ -23,15 +25,9 @@ class CreatePlutusTables < ActiveRecord::Migration
|
|
23
25
|
t.references :account
|
24
26
|
t.references :entry
|
25
27
|
t.decimal :amount, :precision => 20, :scale => 10
|
26
|
-
end
|
28
|
+
end
|
27
29
|
add_index :plutus_amounts, :type
|
28
30
|
add_index :plutus_amounts, [:account_id, :entry_id]
|
29
31
|
add_index :plutus_amounts, [:entry_id, :account_id]
|
30
32
|
end
|
31
|
-
|
32
|
-
def self.down
|
33
|
-
drop_table :plutus_accounts
|
34
|
-
drop_table :plutus_entries
|
35
|
-
drop_table :plutus_amounts
|
36
|
-
end
|
37
33
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require 'rails/generators/migration'
|
3
|
+
require_relative 'base_generator'
|
4
|
+
|
5
|
+
module Plutus
|
6
|
+
class AddDateUpgradeGenerator < BaseGenerator
|
7
|
+
def create_migration_file
|
8
|
+
migration_template 'add_date_migration.rb', 'db/migrate/add_date_to_plutus_entries.rb'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Plutus
|
2
|
+
class BaseGenerator < Rails::Generators::Base
|
3
|
+
include Rails::Generators::Migration
|
4
|
+
|
5
|
+
def self.source_root
|
6
|
+
@source_root ||= File.join(File.dirname(__FILE__), 'templates')
|
7
|
+
end
|
8
|
+
|
9
|
+
# Implement the required interface for Rails::Generators::Migration.
|
10
|
+
# See http://apidock.com/rails/ActiveRecord/Generators/Base/next_migration_number/class
|
11
|
+
def self.next_migration_number(dirname)
|
12
|
+
if ActiveRecord::Base.timestamped_migrations
|
13
|
+
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
14
|
+
else
|
15
|
+
"%.3d" % (current_migration_number(dirname) + 1)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -1,26 +1,12 @@
|
|
1
1
|
# lib/generators/plutus/plutus_generator.rb
|
2
2
|
require 'rails/generators'
|
3
3
|
require 'rails/generators/migration'
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
# Implement the required interface for Rails::Generators::Migration.
|
13
|
-
# taken from http://github.com/rails/rails/blob/master/activerecord/lib/generators/active_record.rb
|
14
|
-
def self.next_migration_number(dirname)
|
15
|
-
if ActiveRecord::Base.timestamped_migrations
|
16
|
-
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
17
|
-
else
|
18
|
-
"%.3d" % (current_migration_number(dirname) + 1)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def create_migration_file
|
23
|
-
migration_template 'migration.rb', 'db/migrate/create_plutus_tables.rb'
|
24
|
-
end
|
25
|
-
|
4
|
+
require_relative 'base_generator'
|
5
|
+
|
6
|
+
module Plutus
|
7
|
+
class PlutusGenerator < BaseGenerator
|
8
|
+
def create_migration_file
|
9
|
+
migration_template 'migration.rb', 'db/migrate/create_plutus_tables.rb'
|
10
|
+
end
|
11
|
+
end
|
26
12
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class AddDateToPlutusEntries < ActiveRecord::Migration[4.2]
|
2
|
+
def change
|
3
|
+
add_column :plutus_entries, :date, :date
|
4
|
+
add_index :plutus_entries, :date
|
5
|
+
|
6
|
+
execute <<-SQL
|
7
|
+
UPDATE plutus_entries
|
8
|
+
SET date = created_at
|
9
|
+
WHERE date is null
|
10
|
+
SQL
|
11
|
+
end
|
12
|
+
end
|
@@ -5,10 +5,10 @@ class UpdatePlutusTables < ActiveRecord::Migration
|
|
5
5
|
remove_index :plutus_amounts, [:account_id, :transaction_id]
|
6
6
|
remove_index :plutus_amounts, [:transaction_id, :account_id]
|
7
7
|
remove_index :plutus_transactions, column: [:commercial_document_id, :commercial_document_type], :name => "index_transactions_on_commercial_doc"
|
8
|
-
|
8
|
+
|
9
9
|
rename_table :plutus_transactions, :plutus_entries
|
10
10
|
rename_column :plutus_amounts, :transaction_id, :entry_id
|
11
|
-
|
11
|
+
|
12
12
|
# adding the indexes back
|
13
13
|
add_index :plutus_amounts, [:account_id, :entry_id]
|
14
14
|
add_index :plutus_amounts, [:entry_id, :account_id]
|
@@ -1,25 +1,10 @@
|
|
1
1
|
# lib/generators/plutus/plutus_generator.rb
|
2
2
|
require 'rails/generators'
|
3
3
|
require 'rails/generators/migration'
|
4
|
+
require_relative 'base_generator'
|
4
5
|
|
5
6
|
module Plutus
|
6
|
-
class TenancyGenerator <
|
7
|
-
include Rails::Generators::Migration
|
8
|
-
|
9
|
-
def self.source_root
|
10
|
-
@source_root ||= File.join(File.dirname(__FILE__), 'templates')
|
11
|
-
end
|
12
|
-
|
13
|
-
# Implement the required interface for Rails::Generators::Migration.
|
14
|
-
# taken from http://github.com/rails/rails/blob/master/activerecord/lib/generators/active_record.rb
|
15
|
-
def self.next_migration_number(dirname)
|
16
|
-
if ActiveRecord::Base.timestamped_migrations
|
17
|
-
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
18
|
-
else
|
19
|
-
"%.3d" % (current_migration_number(dirname) + 1)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
7
|
+
class TenancyGenerator < BaseGenerator
|
23
8
|
def create_migration_file
|
24
9
|
migration_template 'tenant_migration.rb', 'db/migrate/tenant_plutus_tables.rb'
|
25
10
|
end
|
@@ -1,28 +1,12 @@
|
|
1
1
|
# lib/generators/plutus/plutus_generator.rb
|
2
2
|
require 'rails/generators'
|
3
3
|
require 'rails/generators/migration'
|
4
|
+
require_relative 'base_generator'
|
4
5
|
|
5
6
|
module Plutus
|
6
|
-
class UpgradePlutusGenerator <
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
end
|
12
|
-
|
13
|
-
# Implement the required interface for Rails::Generators::Migration.
|
14
|
-
# taken from http://github.com/rails/rails/blob/master/activerecord/lib/generators/active_record.rb
|
15
|
-
def self.next_migration_number(dirname)
|
16
|
-
if ActiveRecord::Base.timestamped_migrations
|
17
|
-
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
18
|
-
else
|
19
|
-
"%.3d" % (current_migration_number(dirname) + 1)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def create_migration_file
|
24
|
-
migration_template 'update_migration.rb', 'db/migrate/update_plutus_tables.rb'
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
7
|
+
class UpgradePlutusGenerator < BaseGenerator
|
8
|
+
def create_migration_file
|
9
|
+
migration_template 'update_migration.rb', 'db/migrate/update_plutus_tables.rb'
|
10
|
+
end
|
11
|
+
end
|
28
12
|
end
|