billingly 0.1.4 → 0.1.5

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.
@@ -289,5 +289,15 @@ module Billingly
289
289
  return false if debtor?
290
290
  return true
291
291
  end
292
+
293
+ # Some customers do not want to be bothered via email, which is understandable.
294
+ # You can override this method to decide which customers should never be emailed
295
+ # with invoices, receipts or when their trial is over.
296
+ #
297
+ # It is false by default, this means all of your customers will be emailed.
298
+ # @return [Boolean] whether this customer opted out from receiving emails.
299
+ def do_not_email?
300
+ false
301
+ end
292
302
  end
293
303
  end
@@ -155,6 +155,7 @@ module Billingly
155
155
  return unless trial?
156
156
  return unless terminated? && unsubscribed_because == 'trial_expired'
157
157
  return unless notified_trial_expired_on.nil?
158
+ return if customer.do_not_email?
158
159
  Billingly::Mailer.trial_expired_notification(self).deliver!
159
160
  update_attribute(:notified_trial_expired_on, Time.now)
160
161
  return self
@@ -59,6 +59,7 @@ module Billingly
59
59
  return unless notified_pending_on.nil?
60
60
  return if paid?
61
61
  return if deleted?
62
+ return if customer.do_not_email?
62
63
  return if due_on > subscription.grace_period.from_now
63
64
  Billingly::Mailer.pending_notification(self).deliver!
64
65
  update_attribute(:notified_pending_on, Time.now)
@@ -69,6 +70,7 @@ module Billingly
69
70
  return if paid?
70
71
  return if deleted?
71
72
  return if due_on > Time.now
73
+ return if customer.do_not_email?
72
74
  Billingly::Mailer.overdue_notification(self).deliver!
73
75
  update_attribute(:notified_overdue_on, Time.now)
74
76
  end
@@ -77,6 +79,7 @@ module Billingly
77
79
  return unless paid?
78
80
  return unless notified_paid_on.nil?
79
81
  return if deleted?
82
+ return if customer.do_not_email?
80
83
  Billingly::Mailer.paid_notification(self).deliver!
81
84
  update_attribute(:notified_paid_on, Time.now)
82
85
  end
@@ -1,6 +1,6 @@
1
1
  <%=t 'billingly.make_sure_to_pay' %>
2
2
 
3
- <%=t 'billingly.you_can_reactivate_your_account_by_visiting' %> http://payments_page
3
+ <%=t 'billingly.you_can_reactivate_your_account_by_visiting' %> <%= url_for subscriptions_path %>
4
4
 
5
5
  ----- <%=t 'billingly.your_overdue_invoice_is_detailed_below' %> -----
6
6
 
@@ -2,7 +2,8 @@
2
2
 
3
3
  <%=t 'billingly.receipt_text' %>
4
4
 
5
- <%= '-' * 70 %>
5
+ <hr/>
6
+
6
7
  <%=t 'billingly.invoice_number' %>: <%= '%.10i' % @invoice.id %>
7
8
  <%=t 'billingly.paid_on' %>: <%= @invoice.paid_on.to_date %>
8
9
  <%=t 'billingly.plan' %>: <%= @invoice.subscription.description %>
@@ -13,5 +13,5 @@
13
13
 
14
14
  <%= '%-55s%15s' % [t('billingly.you_should_pay'), "$#{@invoice.amount - @cash} USD"] %>
15
15
 
16
- <%=t 'billingly.you_can_pay_this_invoice_by_visiting' %> http://payments_page
16
+ <%=t 'billingly.you_can_pay_this_invoice_by_visiting' %> <%= link_to(subscriptions_url, subscriptions_url) %>
17
17
 
@@ -1,3 +1,3 @@
1
1
  module Billingly
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
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.1.4
4
+ version: 0.1.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-16 00:00:00.000000000 Z
12
+ date: 2012-10-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &70310037569740 !ruby/object:Gem::Requirement
16
+ requirement: &70208173997740 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.2.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70310037569740
24
+ version_requirements: *70208173997740
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: validates_email_format_of
27
- requirement: &70310037569280 !ruby/object:Gem::Requirement
27
+ requirement: &70208173997260 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70310037569280
35
+ version_requirements: *70208173997260
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: has_duration
38
- requirement: &70310037568740 !ruby/object:Gem::Requirement
38
+ requirement: &70208173996740 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70310037568740
46
+ version_requirements: *70208173996740
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: timecop
49
- requirement: &70310037568220 !ruby/object:Gem::Requirement
49
+ requirement: &70208173996260 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70310037568220
57
+ version_requirements: *70208173996260
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: sqlite3
60
- requirement: &70310037608420 !ruby/object:Gem::Requirement
60
+ requirement: &70208174030440 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70310037608420
68
+ version_requirements: *70208174030440
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec-rails
71
- requirement: &70310037607540 !ruby/object:Gem::Requirement
71
+ requirement: &70208174028660 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70310037607540
79
+ version_requirements: *70208174028660
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: factory_girl_rails
82
- requirement: &70310037607120 !ruby/object:Gem::Requirement
82
+ requirement: &70208174028200 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70310037607120
90
+ version_requirements: *70208174028200
91
91
  description: Rails Engine for SaaS subscription management. Manage subscriptions,
92
92
  plan changes, free trials and more!!!
93
93
  email:
@@ -104,22 +104,16 @@ files:
104
104
  - app/models/billingly/base_subscription.rb
105
105
  - app/models/billingly/customer.rb
106
106
  - app/models/billingly/invoice.rb
107
- - app/models/billingly/invoice_item.rb
108
107
  - app/models/billingly/journal_entry.rb
109
- - app/models/billingly/ledger_entry.rb
110
- - app/models/billingly/one_time_charge.rb
111
108
  - app/models/billingly/payment.rb
112
109
  - app/models/billingly/plan.rb
113
- - app/models/billingly/receipt.rb
114
110
  - app/models/billingly/subscription.rb
115
111
  - app/models/billingly/tasks.rb
116
112
  - app/views/billingly/mailer/overdue_notification.html.erb
117
113
  - app/views/billingly/mailer/paid_notification.html.erb
118
114
  - app/views/billingly/mailer/pending_notification.html.erb
119
- - app/views/billingly/mailer/pending_notification.plain.erb
120
- - app/views/billingly/mailer/pending_notification.text.erb
121
- - app/views/billingly/mailer/task_results.text.erb
122
- - app/views/billingly/mailer/trial_expired_notification.text.erb
115
+ - app/views/billingly/mailer/task_results.html.erb
116
+ - app/views/billingly/mailer/trial_expired_notification.html.erb
123
117
  - app/views/billingly/subscriptions/_current_subscription.html.haml
124
118
  - app/views/billingly/subscriptions/_deactivation_notice.html.haml
125
119
  - app/views/billingly/subscriptions/_invoice_details.html.haml
@@ -145,18 +139,18 @@ files:
145
139
  - TUTORIAL.rdoc
146
140
  homepage: http://billing.ly
147
141
  licenses: []
148
- post_install_message: ! " Add the following migration:\n \n class CreateBillinglyTables
149
- < ActiveRecord::Migration\n def up\n add_column :billingly_subscriptions,
150
- :notified_trial_will_expire_on, :datetime\n add_column :billingly_subscriptions,
151
- :notified_trial_expired_on, :datetime\n add_column :billingly_subscriptions,
152
- :unsubscribed_because, :string\n \n Billingly::Subscription.where('unsubscribed_on
153
- IS NOT NULL').find_each do |s|\n # Notice: You should pre-populate unsubscribed
154
- because\n # with an appropriate value for each terminated subscription.\n
155
- \ # \n reason = if s == s.customer.subscriptions.last && s.customer.deactivation_reason\n
156
- \ s.deactivation_reason\n elsif s.trial? && s.is_trial_expiring_on
157
- <= s.unsubscribed_on\n 'trial_expired'\n else\n 'changed_subscription'\n
158
- \ end\n s.update_attribute(unsubscribed_because: reason)\n end\n
159
- \ end\n \n def down\n remove_column :billingly_subscriptions,
142
+ post_install_message: ! " If migrating from before 0.1.1 (unlikely), add the following
143
+ migration:\n \n class UpdateSubscriptionFields < ActiveRecord::Migration\n
144
+ \ def up\n add_column :billingly_subscriptions, :notified_trial_will_expire_on,
145
+ :datetime\n add_column :billingly_subscriptions, :notified_trial_expired_on,
146
+ :datetime\n add_column :billingly_subscriptions, :unsubscribed_because, :string\n
147
+ \ \n Billingly::Subscription.where('unsubscribed_on IS NOT NULL').find_each
148
+ do |s|\n # Notice: You should pre-populate unsubscribed because\n #
149
+ with an appropriate value for each terminated subscription.\n # \n reason
150
+ = if s == s.customer.subscriptions.last && s.customer.deactivation_reason\n s.deactivation_reason\n
151
+ \ elsif s.trial? && s.is_trial_expiring_on <= s.unsubscribed_on\n 'trial_expired'\n
152
+ \ else\n 'changed_subscription'\n end\n s.update_attribute(unsubscribed_because:
153
+ reason)\n end\n end\n \n def down\n remove_column :billingly_subscriptions,
160
154
  :notified_trial_will_expire_on\n remove_column :billingly_subscriptions,
161
155
  :notified_trial_expired_on\n remove_column :billingly_subscriptions, :unsubscribed_because\n
162
156
  \ end\n end\n"
@@ -1,4 +0,0 @@
1
- module Billingly
2
- class InvoiceItem < ActiveRecord::Base
3
- end
4
- end
@@ -1,15 +0,0 @@
1
- module Billingly
2
- class JournalEntry < ActiveRecord::Base
3
- belongs_to :customer
4
- belongs_to :invoice
5
- belongs_to :payment
6
- belongs_to :subscription
7
-
8
- validates :amount, presence: true
9
- validates :customer, presence: true
10
- validates :account, presence: true, inclusion: %w(paid cash spent)
11
-
12
- attr_accessible :customer, :account, :invoice, :payment, :subscription, :amount
13
-
14
- end
15
- end
@@ -1,5 +0,0 @@
1
- module Billingly
2
- class OneTimeCharge < ActiveRecord::Base
3
- attr_accessible :charge_on, :amount, :description
4
- end
5
- end
@@ -1,9 +0,0 @@
1
- module Billingly
2
- class Receipt < ActiveRecord::Base
3
- belongs_to :customer
4
- has_one :invoice
5
- has_many :ledger_entries
6
-
7
- attr_accessible :customer, :paid_on
8
- end
9
- end
@@ -1,17 +0,0 @@
1
- <%=t 'billingly.invoice_number' %>: <%= '%.10i' % @invoice.id %>
2
-
3
- <%=t 'billingly.due_date' %>: <%= @invoice.due_on.to_date %>
4
-
5
- <%= "#{t('billingly.covering_from')} #{@invoice.period_start.to_date} #{t('billingly.until')} #{@invoice.period_end.to_date}" %>
6
-
7
- <%=t 'billingly.detail' %>
8
- <%= '-' * 70 %>
9
- <%= '%-55s%15s' % [@invoice.subscription.description, "$#{@invoice.amount} USD"] %>
10
- <% if @cash > 0 %>
11
- <%= '%-55s%15s' % [t('billingly.balance_in_your_favour'), "-$#{@cash} USD"] %>
12
- <% end %>
13
-
14
- <%= '%-55s%15s' % [t('billingly.you_should_pay'), "$#{@invoice.amount - @cash} USD"] %>
15
-
16
- <%=t 'billingly.you_can_pay_this_invoice_by_visiting' %> http://payments_page
17
-
@@ -1,17 +0,0 @@
1
- <%=t 'billingly.invoice_number' %>: <%= '%.10i' % @invoice.id %>
2
-
3
- <%=t 'billingly.due_date' %>: <%= @invoice.due_on.to_date %>
4
-
5
- <%= "#{t('billingly.covering_from')} #{@invoice.period_start.to_date} #{t('billingly.until')} #{@invoice.period_end.to_date}" %>
6
-
7
- <%=t 'billingly.detail' %>
8
- <%= '-' * 70 %>
9
- <%= '%-55s%15s' % [@invoice.subscription.description, "$#{@invoice.amount} USD"] %>
10
- <% if @cash > 0 %>
11
- <%= '%-55s%15s' % [t('billingly.balance_in_your_favour'), "-$#{@cash} USD"] %>
12
- <% end %>
13
-
14
- <%= '%-55s%15s' % [t('billingly.you_should_pay'), "$#{@invoice.amount - @cash} USD"] %>
15
-
16
- <%=t 'billingly.you_can_pay_this_invoice_by_visiting' %> http://payments_page
17
-