vfwcash 0.6.2 → 0.7.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9a923f7717546fa0ad5657bda35b1891027429b2
4
- data.tar.gz: 3e3cf60869b88e91c5f7a53d4f40caabbd6c7bb9
3
+ metadata.gz: 01cc5a2a237aac00aca7a215901eb9a4a50ae8be
4
+ data.tar.gz: c678096ccdc03dc9f812d54c7a6f3bd2647b2345
5
5
  SHA512:
6
- metadata.gz: 8f4d91e3635ba6448e9474cef074c359a280d841871f7c37d412b16303756d6c0ab0b2c1686fcfc8d7534239ae4fc6bc3098ac7384e25a52de87f86c3c30c869
7
- data.tar.gz: b97948c9aeb2f094d9e302f7e040812f93bdf35abc6cefaad7f58a5717087444dd48e962754d353c15758a4741d8f1af6cffc04b2e6093ef3a36a403ff645b70
6
+ metadata.gz: deae047d8fa465ddb45d29b0e19c446c13f3db7f434e49a1fb2124debb51046825717bb0803b8b22d3762331f5f734a910b9e74b7fe97fb00337197b83a3fa50
7
+ data.tar.gz: 56e56720a816258dbbfa67b6960eef57143edc5b936217bcf642a5f094eec7e2cd58934dc07ce644a1dfaa8af5e466d91debdc784d8bdc49f67ef57e0d0dcdb0
@@ -56,15 +56,13 @@ class CashAccount < SqliteBase
56
56
  end
57
57
 
58
58
  def balance_on(date)
59
- sp = self.splits.joins(:tran).where('transactions.post_date < ?',date.strftime('%Y%m%d')+'00')
59
+ sp = self.splits.joins(:tran).where(Tran.arel_table[:post_date].lt(date.to_s(:db)))
60
60
  b = sp.sum(:value_num)
61
61
  end
62
62
 
63
- def balances_between(first,last)
64
- fdate = first.strftime('%Y%m%d')+'00'
65
- ldate = last.strftime('%Y%m%d')+'24'
66
- bb = self.balance_on(first)
67
- sp = splits_by_month(fdate,ldate)
63
+ def balances_between(from,to)
64
+ bb = self.balance_on(from)
65
+ sp = splits_by_month(from,to)
68
66
  credits = sp.where('value_num < ?',0).sum(:value_num)
69
67
  debits = sp.where('value_num >= ?', 0).sum(:value_num)
70
68
  diff = debits + credits
@@ -72,7 +70,7 @@ class CashAccount < SqliteBase
72
70
  end
73
71
 
74
72
  def splits_by_month(bom,eom)
75
- self.splits.joins(:tran).where('transactions.post_date between ? and ?',bom,eom)
73
+ self.splits.joins(:tran).where(transactions:{post_date: Vfwcash.str_date_range(bom,eom)})
76
74
  end
77
75
 
78
76
  def children_balance(decimal=true)
data/lib/models/gcash.rb CHANGED
@@ -217,7 +217,10 @@ module Vfwcash
217
217
 
218
218
  def period_splits(acct)
219
219
  flipper = acct.account_type == 'INCOME' ? -1 : 1
220
- sp = acct.splits.joins(:tran).where('transactions.post_date between ? and ?',@from.strftime('%Y%m%d')+'00',@to.strftime('%Y%m%d')+'24')
220
+ # sp = acct.splits.joins(:tran).where('transactions.post_date between ? and ?',@from.strftime('%Y%m%d')+'00',@to.strftime('%Y%m%d')+'24')
221
+ sp = acct.splits.joins(:tran).where(transactions:{post_date: Vfwcash.str_date_range(@from,@to)})
222
+
223
+
221
224
  sp.sum(:value_num) * flipper
222
225
  end
223
226
 
data/lib/models/split.rb CHANGED
@@ -2,6 +2,13 @@ class Split < SqliteBase
2
2
  self.primary_key = 'guid'
3
3
  belongs_to :tran, foreign_key: 'tx_guid'
4
4
  belongs_to :cash_account, foreign_key: 'account_guid'
5
+
6
+ attribute :rdate, :date
7
+ after_find do |s|
8
+ if s.reconcile_date.present?
9
+ s.rdate = Date.parse(s.reconcile_date)
10
+ end
11
+ end
5
12
 
6
13
  def amount
7
14
  return "#{self.value_num / self.value_denom}.#{self.value_num % self.value_denom}"
data/lib/models/tran.rb CHANGED
@@ -4,9 +4,24 @@ class Tran < SqliteBase
4
4
 
5
5
  has_many :splits, foreign_key: 'tx_guid'
6
6
 
7
+ attribute :date, :date
8
+ after_find do |t|
9
+ if t.post_date.present?
10
+ t.date = Date.parse(t.post_date)
11
+ end
12
+ end
13
+
14
+
15
+ # def self.month_transactions(date)
16
+ # month = Vfwcash.yyyymm(date)
17
+ # trans = Tran.where('transactions.post_date BETWEEN ? and ?',month+"00",month+"32").order(:post_date,:num)
18
+ # end
19
+
7
20
  def self.month_transactions(date)
8
- month = Vfwcash.yyyymm(date)
9
- trans = Tran.where('transactions.post_date BETWEEN ? and ?',month+"00",month+"32").order(:post_date,:num)
21
+ bom = date.beginning_of_month.to_s(:db)
22
+ eom = date.end_of_month.to_s(:db)
23
+ trans = Tran.where(post_date:(bom..eom)).order(:post_date,:num)
10
24
  end
11
25
 
26
+
12
27
  end
data/lib/vfwcash.rb CHANGED
@@ -36,14 +36,30 @@ module Vfwcash
36
36
  date = Date.today
37
37
  elsif date.class == Date
38
38
  else
39
+ # has to be string
39
40
  if date.length == 6
40
41
  date += '01'
42
+ date = Date.parse(date)
43
+ else
44
+ date = Date.parse(date)
41
45
  end
42
- date = Date.parse(date)
43
46
  end
44
47
  date
45
48
  end
46
49
 
50
+ def self.str_date_range(from,to)
51
+ # used for
52
+ db = Tran.last.post_date.include?('-')
53
+ from = Vfwcash.set_date(from)
54
+ to = Vfwcash.set_date(to)
55
+ if db
56
+ return (from.to_s(:db))..(to.to_s(:db))
57
+ else
58
+ return (from.to_s(:number))..(to.to_s(:number))
59
+ end
60
+ end
61
+
62
+
47
63
  def self.money(int)
48
64
  dollars = int / 100
49
65
  cents = (int % 100) / 100.0
data/lib/vfwcash/api.rb CHANGED
@@ -3,7 +3,7 @@ module Vfwcash
3
3
  class Api
4
4
  attr_accessor :config, :cash
5
5
  def initialize(date=nil)
6
- @date = date
6
+ @date = Vfwcash.set_date(date)
7
7
  @config = Vfwcash.config
8
8
  require_relative './sqlite_base'
9
9
  Dir.glob(File.join(LibPath,'models/*')).each do |file|
@@ -1,3 +1,3 @@
1
1
  module Vfwcash
2
- VERSION = "0.6.2"
2
+ VERSION = "0.7.1"
3
3
  end
data/vfwcash-0.6.2.gem ADDED
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vfwcash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Alex
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-31 00:00:00.000000000 Z
11
+ date: 2018-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -172,6 +172,7 @@ files:
172
172
  - pdf_examples/views/checkbooks/split.html.slim
173
173
  - pdf_examples/views/checkbooks/summary.html.slim
174
174
  - vfwcash-0.6.1.gem
175
+ - vfwcash-0.6.2.gem
175
176
  - vfwcash.gemspec
176
177
  homepage: ''
177
178
  licenses: