billingly 0.0.0 → 0.1.1
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.
- data/README.md +36 -0
- data/TUTORIAL.rdoc +158 -0
- data/app/controllers/billingly/subscriptions_controller.rb +33 -13
- data/app/models/billingly/base_customer.rb +306 -0
- data/app/models/billingly/base_plan.rb +16 -0
- data/app/models/billingly/base_subscription.rb +118 -0
- data/app/models/billingly/customer.rb +2 -115
- data/app/models/billingly/invoice.rb +20 -21
- data/app/models/billingly/journal_entry.rb +15 -0
- data/app/models/billingly/ledger_entry.rb +2 -3
- data/app/models/billingly/payment.rb +1 -1
- data/app/models/billingly/plan.rb +2 -4
- data/app/models/billingly/subscription.rb +2 -81
- data/app/views/billingly/subscriptions/_current_subscription.html.haml +22 -0
- data/app/views/billingly/subscriptions/_deactivation_notice.html.haml +12 -0
- data/app/views/billingly/subscriptions/_invoice_details.html.haml +9 -0
- data/app/views/billingly/subscriptions/_invoices.html.haml +30 -0
- data/app/views/billingly/subscriptions/_plans.html.haml +30 -0
- data/app/views/billingly/subscriptions/index.html.haml +10 -0
- data/app/views/billingly/subscriptions/invoice.html.haml +8 -0
- data/app/views/billingly/subscriptions/new.html.erb +1 -1
- data/app/views/billingly_mailer/paid_notification.html.erb +1 -1
- data/lib/billingly/engine.rb +1 -3
- data/lib/billingly/rails/routes.rb +3 -1
- data/lib/billingly/version.rb +1 -1
- data/lib/generators/billingly_mailer_views_generator.rb +9 -0
- data/lib/generators/billingly_views_generator.rb +9 -0
- data/lib/generators/templates/create_billingly_tables.rb +11 -16
- data/lib/tasks/billingly_tasks.rake +2 -0
- metadata +46 -22
- data/README.rdoc +0 -3
- data/app/views/billingly/subscriptions/index.html.erb +0 -2
@@ -0,0 +1,22 @@
|
|
1
|
+
- unless current_customer.deactivated?
|
2
|
+
- if current_customer.doing_trial?
|
3
|
+
%p
|
4
|
+
You are currently on a trial period, your trial expires in
|
5
|
+
= current_customer.trial_days_left
|
6
|
+
days.
|
7
|
+
|
8
|
+
- if subscription
|
9
|
+
%p
|
10
|
+
Your subscription is for:
|
11
|
+
%strong= subscription.description
|
12
|
+
%p
|
13
|
+
You are subscribed since:
|
14
|
+
= subscription.subscribed_on.to_date
|
15
|
+
|
16
|
+
- else
|
17
|
+
%p You are not subscribed yet, please choose one of the plans below:
|
18
|
+
|
19
|
+
- if current_customer.ledger[:cash]
|
20
|
+
%p
|
21
|
+
Your current balance is:
|
22
|
+
%strong $ #{current_customer.ledger[:cash]}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
- if current_customer.deactivated?
|
2
|
+
.alert.alert-warning
|
3
|
+
- if current_customer.deactivation_reason == 'trial_expired'
|
4
|
+
%h2 Your trial period is over
|
5
|
+
%p Please choose a plan to continue using the service.
|
6
|
+
- elsif current_customer.deactivation_reason == 'debtor'
|
7
|
+
%h2 Your account has been momentarily deactivated
|
8
|
+
%p It will be reactivated once your outstanding invoices are settled.
|
9
|
+
- else
|
10
|
+
%h2 Your account is not active.
|
11
|
+
%p Choose a plan below and it will be reactivated.
|
12
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
- if @invoices.size > 0
|
2
|
+
%h2 Your invoices
|
3
|
+
%table.table.table-striped
|
4
|
+
%thead
|
5
|
+
%tr
|
6
|
+
%td #
|
7
|
+
%td From
|
8
|
+
%td To
|
9
|
+
%td Due Date
|
10
|
+
%td Amount
|
11
|
+
%td
|
12
|
+
- @invoices.each do |invoice|
|
13
|
+
%tr.invoice
|
14
|
+
%td= invoice.id
|
15
|
+
%td= invoice.period_start.to_date
|
16
|
+
%td= invoice.period_end.to_date
|
17
|
+
%td= invoice.due_on.to_date
|
18
|
+
%td= "$%.2f" % invoice.amount
|
19
|
+
%td
|
20
|
+
|
21
|
+
- if invoice.paid?
|
22
|
+
%span.label.label-success Settled
|
23
|
+
- elsif invoice.deleted?
|
24
|
+
%span.label Waived
|
25
|
+
- elsif invoice.due_on < Time.now
|
26
|
+
%span.label.label-warning Overdue
|
27
|
+
- else
|
28
|
+
%span.label.label-warning Pending
|
29
|
+
|
30
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
.row
|
2
|
+
- plans.sort_by(&:amount).reverse.each do |plan|
|
3
|
+
.span3
|
4
|
+
.well.plan-container
|
5
|
+
%h1
|
6
|
+
= plan.name
|
7
|
+
|
8
|
+
%h4 Pay $#{plan.amount.to_i} every #{plan.periodicity.inspect}
|
9
|
+
|
10
|
+
%p
|
11
|
+
%span.badge.badge-info #{plan.awesomeness_level} points.
|
12
|
+
|
13
|
+
%p.description= plan.description
|
14
|
+
|
15
|
+
- if current_customer.can_subscribe_to?(plan)
|
16
|
+
- if current_customer.deactivated?
|
17
|
+
= form_tag(reactivate_subscriptions_path, :action => :post) do
|
18
|
+
= hidden_field_tag :plan_id, plan.id
|
19
|
+
= submit_tag 'Subscribe', class: 'btn btn-large btn-success',
|
20
|
+
disable_with: 'subscribing'
|
21
|
+
- else
|
22
|
+
= form_tag(subscriptions_path, :action => :post) do
|
23
|
+
= hidden_field_tag :plan_id, plan.id
|
24
|
+
= submit_tag 'Subscribe', class: 'btn btn-large btn-success',
|
25
|
+
disable_with: 'subscribing'
|
26
|
+
- elsif subscription && subscription.plan == plan
|
27
|
+
%button.btn.btn-large(disabled=true) Your plan
|
28
|
+
- else
|
29
|
+
%button.btn.btn-large(disabled=true) Subscribe
|
30
|
+
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
|
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
<%= '-' * 70 %>
|
6
6
|
<%=t 'billingly.invoice_number' %>: <%= '%.10i' % @invoice.id %>
|
7
|
-
<%=t 'billingly.paid_on' %>: <%= @invoice.
|
7
|
+
<%=t 'billingly.paid_on' %>: <%= @invoice.paid_on.to_date %>
|
8
8
|
<%=t 'billingly.plan' %>: <%= @invoice.subscription.description %>
|
9
9
|
<%=t 'billingly.amount' %>: $<%= @invoice.amount %> USD
|
10
10
|
|
data/lib/billingly/engine.rb
CHANGED
@@ -4,7 +4,6 @@ module Billingly
|
|
4
4
|
end
|
5
5
|
|
6
6
|
class Engine < Rails::Engine
|
7
|
-
|
8
7
|
# Extends the ApplicationController with all the
|
9
8
|
# billingly before_filters and helper methods
|
10
9
|
initializer 'billingly.app_controller' do |app|
|
@@ -31,7 +30,7 @@ module Billingly
|
|
31
30
|
# use it in your own controllers too.
|
32
31
|
def requires_active_customer
|
33
32
|
if requires_customer.nil? && current_customer.deactivated?
|
34
|
-
redirect_to(
|
33
|
+
redirect_to(subscriptions_path)
|
35
34
|
end
|
36
35
|
end
|
37
36
|
end
|
@@ -42,4 +41,3 @@ module Billingly
|
|
42
41
|
end
|
43
42
|
end
|
44
43
|
|
45
|
-
|
@@ -1,9 +1,11 @@
|
|
1
1
|
class ActionDispatch::Routing::Mapper
|
2
2
|
def add_billingly_routes(skope=nil, controller='billingly/subscriptions')
|
3
3
|
route = lambda do
|
4
|
-
resources :subscriptions, controller: controller do
|
4
|
+
resources :subscriptions, controller: controller, only: [:index, :create] do
|
5
5
|
collection do
|
6
|
+
match 'invoice/:invoice_id' => :invoice, as: :invoice
|
6
7
|
post :reactivate
|
8
|
+
post :deactivate
|
7
9
|
end
|
8
10
|
end
|
9
11
|
end
|
data/lib/billingly/version.rb
CHANGED
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
class BillinglyMailerViewsGenerator < Rails::Generators::Base
|
4
|
+
self.source_root([File.expand_path("../../../app/views", __FILE__)])
|
5
|
+
|
6
|
+
def create_billingly_mailer_views
|
7
|
+
directory 'billingly_mailer', 'app/views/billingly_mailer'
|
8
|
+
end
|
9
|
+
end
|
@@ -1,15 +1,16 @@
|
|
1
1
|
class CreateBillinglyTables < ActiveRecord::Migration
|
2
|
-
def
|
2
|
+
def change
|
3
3
|
create_table :billingly_customers do |t|
|
4
4
|
t.datetime 'deactivated_since'
|
5
|
+
t.string 'deactivation_reason'
|
5
6
|
t.string 'email', null: false
|
6
7
|
end
|
7
8
|
|
8
9
|
create_table :billingly_invoices do |t|
|
9
10
|
t.references :customer, null: false
|
10
|
-
t.references :receipt
|
11
11
|
t.references :subscription
|
12
12
|
t.decimal 'amount', precision: 11, scale: 2, default: 0.0, null: false
|
13
|
+
t.datetime 'paid_on'
|
13
14
|
t.datetime 'due_on', null: false
|
14
15
|
t.datetime 'period_start', null: false
|
15
16
|
t.datetime 'period_end', null: false
|
@@ -26,20 +27,13 @@ class CreateBillinglyTables < ActiveRecord::Migration
|
|
26
27
|
t.decimal 'amount', precision: 11, scale: 2, default: 0.0, null: false
|
27
28
|
end
|
28
29
|
|
29
|
-
create_table :
|
30
|
-
t.references :customer, null: false
|
31
|
-
t.datetime 'paid_on'
|
32
|
-
t.timestamps
|
33
|
-
end
|
34
|
-
|
35
|
-
create_table :billingly_ledger_entries do |t|
|
30
|
+
create_table :billingly_journal_entries do |t|
|
36
31
|
t.references :customer, null: false
|
37
32
|
t.string :account, null: false
|
38
33
|
t.decimal 'amount', precision: 11, scale: 2, default: 0.0, null: false
|
39
34
|
t.references :subscription
|
40
35
|
t.references :invoice
|
41
36
|
t.references :payment
|
42
|
-
t.references :receipt
|
43
37
|
t.timestamps
|
44
38
|
end
|
45
39
|
|
@@ -48,9 +42,12 @@ class CreateBillinglyTables < ActiveRecord::Migration
|
|
48
42
|
t.string 'description', null: false
|
49
43
|
t.datetime 'subscribed_on', null: false
|
50
44
|
t.string 'periodicity', null: false
|
45
|
+
t.string 'grace_period', null: false
|
46
|
+
t.boolean 'payable_upfront', null: false, default: false
|
51
47
|
t.decimal 'amount', precision: 11, scale: 2, default: 0.0, null: false
|
52
48
|
t.datetime 'unsubscribed_on'
|
53
|
-
t.
|
49
|
+
t.datetime 'is_trial_expiring_on'
|
50
|
+
t.references :plan
|
54
51
|
t.timestamps
|
55
52
|
end
|
56
53
|
|
@@ -59,13 +56,11 @@ class CreateBillinglyTables < ActiveRecord::Migration
|
|
59
56
|
t.string 'description' # 50GB for 9,99 a month.
|
60
57
|
t.string 'periodicity'
|
61
58
|
t.decimal 'amount', precision: 11, scale: 2, default: 0.0, null: false # 9.99
|
62
|
-
t.boolean 'payable_upfront'
|
59
|
+
t.boolean 'payable_upfront', null: false
|
60
|
+
t.string 'grace_period', null: false
|
61
|
+
t.boolean 'hidden_on'
|
63
62
|
t.timestamps
|
64
63
|
end
|
65
|
-
|
66
|
-
end
|
67
|
-
|
68
|
-
def self.down
|
69
64
|
end
|
70
65
|
end
|
71
66
|
|
@@ -11,6 +11,8 @@ namespace :billingly do
|
|
11
11
|
Billingly::Invoice.charge_all
|
12
12
|
puts 'Deactivating debtors'
|
13
13
|
Billingly::Customer.deactivate_all_debtors
|
14
|
+
puts 'Deactivating all expired trials'
|
15
|
+
Billingly::Customer.deactivate_all_expired_trials
|
14
16
|
puts 'Sending payment receipts'
|
15
17
|
Billingly::Invoice.notify_all_paid
|
16
18
|
puts 'Notifying pending invoices'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: billingly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,22 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &70322875786160 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 3.2.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70322875786160
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: validates_email_format_of
|
27
|
-
requirement: &
|
27
|
+
requirement: &70322875785740 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,21 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70322875785740
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: has_duration
|
38
|
+
requirement: &70322875785280 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70322875785280
|
36
47
|
- !ruby/object:Gem::Dependency
|
37
48
|
name: timecop
|
38
|
-
requirement: &
|
49
|
+
requirement: &70322875784860 !ruby/object:Gem::Requirement
|
39
50
|
none: false
|
40
51
|
requirements:
|
41
52
|
- - ! '>='
|
@@ -43,10 +54,10 @@ dependencies:
|
|
43
54
|
version: '0'
|
44
55
|
type: :development
|
45
56
|
prerelease: false
|
46
|
-
version_requirements: *
|
57
|
+
version_requirements: *70322875784860
|
47
58
|
- !ruby/object:Gem::Dependency
|
48
59
|
name: sqlite3
|
49
|
-
requirement: &
|
60
|
+
requirement: &70322875784440 !ruby/object:Gem::Requirement
|
50
61
|
none: false
|
51
62
|
requirements:
|
52
63
|
- - ! '>='
|
@@ -54,10 +65,10 @@ dependencies:
|
|
54
65
|
version: '0'
|
55
66
|
type: :development
|
56
67
|
prerelease: false
|
57
|
-
version_requirements: *
|
68
|
+
version_requirements: *70322875784440
|
58
69
|
- !ruby/object:Gem::Dependency
|
59
70
|
name: rspec-rails
|
60
|
-
requirement: &
|
71
|
+
requirement: &70322875784020 !ruby/object:Gem::Requirement
|
61
72
|
none: false
|
62
73
|
requirements:
|
63
74
|
- - ! '>='
|
@@ -65,10 +76,10 @@ dependencies:
|
|
65
76
|
version: '0'
|
66
77
|
type: :development
|
67
78
|
prerelease: false
|
68
|
-
version_requirements: *
|
79
|
+
version_requirements: *70322875784020
|
69
80
|
- !ruby/object:Gem::Dependency
|
70
81
|
name: factory_girl_rails
|
71
|
-
requirement: &
|
82
|
+
requirement: &70322875783600 !ruby/object:Gem::Requirement
|
72
83
|
none: false
|
73
84
|
requirements:
|
74
85
|
- - ! '>='
|
@@ -76,9 +87,9 @@ dependencies:
|
|
76
87
|
version: '0'
|
77
88
|
type: :development
|
78
89
|
prerelease: false
|
79
|
-
version_requirements: *
|
80
|
-
description: Engine for
|
81
|
-
|
90
|
+
version_requirements: *70322875783600
|
91
|
+
description: Rails Engine for SaaS subscription management. Manage subscriptions,
|
92
|
+
plan changes, free trials and more!!!
|
82
93
|
email:
|
83
94
|
- nubis@woobiz.com.ar
|
84
95
|
executables: []
|
@@ -87,17 +98,27 @@ extra_rdoc_files: []
|
|
87
98
|
files:
|
88
99
|
- app/controllers/billingly/subscriptions_controller.rb
|
89
100
|
- app/mailers/billingly_mailer.rb
|
101
|
+
- app/models/billingly/base_customer.rb
|
102
|
+
- app/models/billingly/base_plan.rb
|
103
|
+
- app/models/billingly/base_subscription.rb
|
90
104
|
- app/models/billingly/customer.rb
|
91
105
|
- app/models/billingly/invoice.rb
|
92
106
|
- app/models/billingly/invoice_item.rb
|
107
|
+
- app/models/billingly/journal_entry.rb
|
93
108
|
- app/models/billingly/ledger_entry.rb
|
94
109
|
- app/models/billingly/one_time_charge.rb
|
95
110
|
- app/models/billingly/payment.rb
|
96
111
|
- app/models/billingly/plan.rb
|
97
112
|
- app/models/billingly/receipt.rb
|
98
113
|
- app/models/billingly/subscription.rb
|
114
|
+
- app/views/billingly/subscriptions/_current_subscription.html.haml
|
115
|
+
- app/views/billingly/subscriptions/_deactivation_notice.html.haml
|
116
|
+
- app/views/billingly/subscriptions/_invoice_details.html.haml
|
117
|
+
- app/views/billingly/subscriptions/_invoices.html.haml
|
118
|
+
- app/views/billingly/subscriptions/_plans.html.haml
|
99
119
|
- app/views/billingly/subscriptions/create.html.erb
|
100
|
-
- app/views/billingly/subscriptions/index.html.
|
120
|
+
- app/views/billingly/subscriptions/index.html.haml
|
121
|
+
- app/views/billingly/subscriptions/invoice.html.haml
|
101
122
|
- app/views/billingly/subscriptions/new.html.erb
|
102
123
|
- app/views/billingly_mailer/overdue_notification.html.erb
|
103
124
|
- app/views/billingly_mailer/paid_notification.html.erb
|
@@ -109,13 +130,16 @@ files:
|
|
109
130
|
- lib/billingly/rails/routes.rb
|
110
131
|
- lib/billingly/version.rb
|
111
132
|
- lib/billingly.rb
|
133
|
+
- lib/generators/billingly_mailer_views_generator.rb
|
112
134
|
- lib/generators/billingly_migration_generator.rb
|
135
|
+
- lib/generators/billingly_views_generator.rb
|
113
136
|
- lib/generators/templates/create_billingly_tables.rb
|
114
137
|
- lib/tasks/billingly_tasks.rake
|
115
138
|
- MIT-LICENSE
|
116
139
|
- Rakefile
|
117
|
-
- README.
|
118
|
-
|
140
|
+
- README.md
|
141
|
+
- TUTORIAL.rdoc
|
142
|
+
homepage: http://billing.ly
|
119
143
|
licenses: []
|
120
144
|
post_install_message:
|
121
145
|
rdoc_options: []
|
@@ -138,6 +162,6 @@ rubyforge_project:
|
|
138
162
|
rubygems_version: 1.8.15
|
139
163
|
signing_key:
|
140
164
|
specification_version: 3
|
141
|
-
summary: Engine for
|
142
|
-
use it
|
165
|
+
summary: Rails Engine for SaaS subscription management
|
143
166
|
test_files: []
|
167
|
+
has_rdoc:
|