wbase 0.2.8 → 0.2.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ef0ad31f15c84d78f5113eb63b7d2849bc9ae680
4
- data.tar.gz: b37283ce30e2c15f0ba438cc187f5ee54198840e
3
+ metadata.gz: 1bb278209387a6e44cfc1a8a2f5d15d78acc0281
4
+ data.tar.gz: d7ece99defd6938a780905f252740eb0ab5209fb
5
5
  SHA512:
6
- metadata.gz: d4ae14b177bc99c66b09da0658833ea52ebb6463bb31173ede9779e8c8acf89be29df32fd24ca1fcb90d44cba200c3585bf06eb752f2c91710b0eefeee579c1b
7
- data.tar.gz: 22d404c2eef2f9fe0c7facd521af4cadde702b7e352165aed6e86d3c9107a27f3a63fd963729a42ca3bc17df46a9020ee217d08782ad880b404dba4c3a5c5264
6
+ metadata.gz: 5228b38ea63e37b204dbf6c5fd1f24fd42ed59f627509320642f9bc5f20e44fba5bbbd7bd9d8d87332dbcdad83d5c31d4177788b5f78eac7cbc7eac41ef3a93d
7
+ data.tar.gz: 647bf7555982e18f024a06442235f3722c9a0a55c1a31a58c4c297447ede084d56667c16254cfb7ca9e9b64920b2dc46cf3d6cb745f955f92e00d56a205ab278
@@ -22,5 +22,13 @@
22
22
  module Wbase
23
23
  class Plan < ActiveRecord::Base
24
24
  has_many :subscriptions
25
+
26
+ def self.monthly
27
+ where("interval LIKE '%month%'")
28
+ end
29
+
30
+ def self.annual
31
+ where("interval LIKE '%yearly%'")
32
+ end
25
33
  end
26
34
  end
@@ -35,6 +35,19 @@ module Wbase
35
35
  @stripe_customer ||= Stripe::Customer.retrieve(stripe_id)
36
36
  end
37
37
 
38
+ def self.monthly_value
39
+ current.where(plan: Plan.monthly).sum(:current_price) +
40
+ current.where(plan: Plan.annual).sum(:current_price).fdiv(12)
41
+ end
42
+
43
+ def monthly_value
44
+ if plan.interval.include?("month")
45
+ current_price
46
+ else
47
+ current_price.fdiv(12)
48
+ end
49
+ end
50
+
38
51
  def current?
39
52
  paid_thru && paid_thru > 7.days.ago
40
53
  end
data/lib/wbase/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Wbase
2
- VERSION = "0.2.8"
2
+ VERSION = "0.2.9"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wbase
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.8
4
+ version: 0.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - CJ Avilla
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-03 00:00:00.000000000 Z
11
+ date: 2017-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails