vesr 0.12.7 → 0.13.0
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/app/assets/stylesheets/{vesr.css → vesr.scss} +8 -0
- data/app/models/esr_file.rb +2 -1
- data/app/models/esr_record.rb +27 -13
- data/app/views/esr_files/_esr_file.html.haml +4 -4
- data/app/views/esr_files/_form.html.haml +3 -4
- data/app/views/esr_files/_list.html.haml +4 -4
- data/app/views/esr_records/_list.html.haml +1 -1
- data/lib/vesr/version.rb +1 -1
- metadata +3 -3
data/app/models/esr_file.rb
CHANGED
data/app/models/esr_record.rb
CHANGED
@@ -5,10 +5,10 @@ class EsrRecord < ActiveRecord::Base
|
|
5
5
|
attr_accessible :file, :remarks
|
6
6
|
|
7
7
|
belongs_to :esr_file
|
8
|
-
|
8
|
+
|
9
9
|
belongs_to :booking, :dependent => :destroy, :autosave => true
|
10
10
|
belongs_to :invoice
|
11
|
-
|
11
|
+
|
12
12
|
# State Machine
|
13
13
|
include AASM
|
14
14
|
aasm_column :state
|
@@ -21,6 +21,7 @@ class EsrRecord < ActiveRecord::Base
|
|
21
21
|
aasm_state :overpaid
|
22
22
|
aasm_state :underpaid
|
23
23
|
aasm_state :resolved
|
24
|
+
aasm_state :duplicate
|
24
25
|
|
25
26
|
aasm_event :write_off do
|
26
27
|
transitions :from => :underpaid, :to => :resolved
|
@@ -34,10 +35,11 @@ class EsrRecord < ActiveRecord::Base
|
|
34
35
|
transitions :from => [:overpaid, :missing], :to => :resolved
|
35
36
|
end
|
36
37
|
|
37
|
-
scope :invalid, where(:state => ['overpaid', 'underpaid', 'resolved'])
|
38
|
+
scope :invalid, where(:state => ['overpaid', 'underpaid', 'resolved', 'duplicate'])
|
38
39
|
scope :unsolved, where(:state => ['overpaid', 'underpaid', 'missing'])
|
39
40
|
scope :valid, where(:state => 'paid')
|
40
41
|
|
42
|
+
|
41
43
|
private
|
42
44
|
def parse_date(value)
|
43
45
|
year = value[0..1].to_i + 2000
|
@@ -50,15 +52,15 @@ class EsrRecord < ActiveRecord::Base
|
|
50
52
|
def payment_date=(value)
|
51
53
|
write_attribute(:payment_date, parse_date(value))
|
52
54
|
end
|
53
|
-
|
55
|
+
|
54
56
|
def transaction_date=(value)
|
55
57
|
write_attribute(:transaction_date, parse_date(value))
|
56
58
|
end
|
57
|
-
|
59
|
+
|
58
60
|
def value_date=(value)
|
59
61
|
write_attribute(:value_date, parse_date(value))
|
60
62
|
end
|
61
|
-
|
63
|
+
|
62
64
|
def reference=(value)
|
63
65
|
write_attribute(:reference, value[0..-2])
|
64
66
|
end
|
@@ -130,6 +132,11 @@ class EsrRecord < ActiveRecord::Base
|
|
130
132
|
end
|
131
133
|
|
132
134
|
def update_state
|
135
|
+
if duplicate_of.present?
|
136
|
+
self.state = 'duplicate'
|
137
|
+
return
|
138
|
+
end
|
139
|
+
|
133
140
|
if self.invoice.nil?
|
134
141
|
self.state = 'missing'
|
135
142
|
return
|
@@ -154,7 +161,7 @@ class EsrRecord < ActiveRecord::Base
|
|
154
161
|
|
155
162
|
# Invoices
|
156
163
|
before_create :assign_invoice, :create_esr_booking, :update_state, :update_remarks, :update_invoice_state
|
157
|
-
|
164
|
+
|
158
165
|
private
|
159
166
|
def assign_invoice
|
160
167
|
# Prepare remarks to not be null
|
@@ -168,12 +175,19 @@ class EsrRecord < ActiveRecord::Base
|
|
168
175
|
self.invoice = imported_invoice
|
169
176
|
end
|
170
177
|
end
|
171
|
-
|
178
|
+
|
172
179
|
def vesr_account
|
173
180
|
BankAccount.find_by_esr_id(client_id)
|
174
181
|
end
|
175
182
|
|
183
|
+
# Tries to find a record this would duplicate
|
184
|
+
def duplicate_of
|
185
|
+
EsrRecord.where(:reference => reference, :bank_pc_id => bank_pc_id, :amount => amount, :payment_date => payment_date, :transaction_date => transaction_date).first
|
186
|
+
end
|
187
|
+
|
176
188
|
def create_esr_booking
|
189
|
+
return if duplicate_of.present?
|
190
|
+
|
177
191
|
if invoice
|
178
192
|
esr_booking = invoice.bookings.build
|
179
193
|
debit_account = invoice.balance_account
|
@@ -181,7 +195,7 @@ class EsrRecord < ActiveRecord::Base
|
|
181
195
|
esr_booking = Booking.new
|
182
196
|
debit_account = Invoice.direct_account
|
183
197
|
end
|
184
|
-
|
198
|
+
|
185
199
|
esr_booking.update_attributes(
|
186
200
|
:amount => amount,
|
187
201
|
:credit_account => vesr_account,
|
@@ -190,11 +204,11 @@ class EsrRecord < ActiveRecord::Base
|
|
190
204
|
:title => "VESR Zahlung",
|
191
205
|
:comments => remarks
|
192
206
|
)
|
193
|
-
|
207
|
+
|
194
208
|
esr_booking.save
|
195
|
-
|
209
|
+
|
196
210
|
self.booking = esr_booking
|
197
|
-
|
211
|
+
|
198
212
|
return esr_booking
|
199
213
|
end
|
200
214
|
|
@@ -208,7 +222,7 @@ class EsrRecord < ActiveRecord::Base
|
|
208
222
|
end
|
209
223
|
end
|
210
224
|
|
211
|
-
public
|
225
|
+
public
|
212
226
|
def create_write_off_booking
|
213
227
|
invoice.write_off("Korrektur nach VESR Zahlung").save
|
214
228
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
%tr[esr_file]
|
2
2
|
%td= link_to l(esr_file.updated_at), esr_file, 'data-href-container' => 'tr'
|
3
|
-
%td.
|
4
|
-
%td.
|
5
|
-
%td.
|
6
|
-
%td.
|
3
|
+
%td.currency= esr_file.esr_records.paid.count
|
4
|
+
%td.currency= esr_file.esr_records.invalid.count
|
5
|
+
%td.currency= esr_file.esr_records.missing.count
|
6
|
+
%td.currency= currency_fmt(esr_file.esr_records.sum(:amount) || 0.0)
|
@@ -2,10 +2,10 @@
|
|
2
2
|
%thead
|
3
3
|
%tr
|
4
4
|
%th= t_attr :updated_at, EsrFile
|
5
|
-
%th.
|
6
|
-
%th.
|
7
|
-
%th.
|
8
|
-
%th.
|
5
|
+
%th.currency= t_attr :bookings, EsrFile
|
6
|
+
%th.currency= t_attr :invalid_bookings, EsrFile
|
7
|
+
%th.currency= t_attr :missing_bookings, EsrFile
|
8
|
+
%th.currency= t_attr :total_amount, EsrFile
|
9
9
|
%th.action-links
|
10
10
|
%tbody
|
11
11
|
= render @esr_files
|
data/lib/vesr/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vesr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.13.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2014-04-29 00:00:00.000000000 Z
|
14
14
|
dependencies: []
|
15
15
|
description: VESR provides support for ESR number calculations and gives ready to
|
16
16
|
use Rails components.
|
@@ -28,7 +28,7 @@ files:
|
|
28
28
|
- app/assets/images/16x16/resolve.png
|
29
29
|
- app/assets/images/16x16/show_all.png
|
30
30
|
- app/assets/images/16x16/write_off.png
|
31
|
-
- app/assets/stylesheets/vesr.
|
31
|
+
- app/assets/stylesheets/vesr.scss
|
32
32
|
- app/controllers/esr_files_controller.rb
|
33
33
|
- app/controllers/esr_records_controller.rb
|
34
34
|
- app/models/esr_file.rb
|