vesr 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3450d3a9a5cc6153eb7f5a327971bd3895d6147b
4
- data.tar.gz: cb623ffa96b02ec15ace1c46247be069ec64d2ca
3
+ metadata.gz: ae7e408a671168464173f8f975352930137d89ef
4
+ data.tar.gz: b558c3cc6bdd0373587246fb5a6dfe656c707895
5
5
  SHA512:
6
- metadata.gz: 7f9fe0c6f727d99c6484475e42b382b1cbab3730767a417e1364fc85e59ddf5846f4c27467dae96fc71aa76cc76dcb98e89faea64b5f81ae18166640064585e4
7
- data.tar.gz: 7ee38e929b480680b258f60ca3690fe06fdefc6013001c6ac2c6bc24b2d8e14fa0b35f79ef8f44e7279c7b32a5ae3b6f92a5778f11868c60b1760b5b29937aae
6
+ metadata.gz: ee0ce7d1edb35a4ec9662dcfc52bf79ba5231190dfbc96650ba1020623132cad60bdacf437e6f85f68999322937c833e0ffe77ff7a35147eafb76fe72410ae08
7
+ data.tar.gz: 73f57511a7651bb6d3fbb05ed9d643d22af65aff458ed570534681fe6f3b27235d54528c6361a39109eade3eea301ca0178d110eb14dfc5f948230826ed95979
File without changes
@@ -0,0 +1,18 @@
1
+ module EsrRecordHelper
2
+ def event_image(event)
3
+ html_class = case event.to_s
4
+ when 'book_extra_earning'
5
+ 'icon-circle-arrow-up'
6
+ when 'reactivate'
7
+ 'icon-refresh'
8
+ when 'resolve'
9
+ 'icon-ok'
10
+ when 'show_all'
11
+ 'icon-list-alt'
12
+ when 'write_off'
13
+ 'icon-circle-arrow-down'
14
+ end
15
+
16
+ content_tag :span, '', class: html_class
17
+ end
18
+ end
@@ -31,8 +31,19 @@ class EsrFile < ActiveRecord::Base
31
31
 
32
32
  private
33
33
  def create_records
34
- File.new(file.current_path).each {|line|
35
- self.esr_records << EsrRecord.new.parse(line) unless line[0..2] == '999'
36
- }
34
+ File.new(file.current_path).each do |line|
35
+ if EsrRecord.supported_line?(line)
36
+ esr_records << create_esr_record(line)
37
+ else
38
+ Rails.logger.info "VESR: Ignoring line #{line}"
39
+ end
40
+ end
41
+ end
42
+
43
+ def create_esr_record(line)
44
+ record = EsrRecord.new.parse(line)
45
+ record.save
46
+ Rails.logger.error "VESR: Record #{record.inspect} is invalid: #{record.errors.inspect}" unless record.valid?
47
+ record
37
48
  end
38
49
  end
@@ -1,6 +1,10 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  class EsrRecord < ActiveRecord::Base
4
+ SUPPORTED_RECORD_TYPES = [
5
+ :lsv_credit
6
+ ]
7
+
4
8
  # Access restrictions
5
9
  attr_accessible :file, :remarks
6
10
 
@@ -40,6 +44,11 @@ class EsrRecord < ActiveRecord::Base
40
44
  scope :unsolved, where(:state => ['overpaid', 'underpaid', 'missing'])
41
45
  scope :valid, where(:state => 'paid')
42
46
 
47
+ def self.supported_line?(line)
48
+ record_type_code = line[0..2]
49
+ record_type = EsrRecordTypes.lookup_code record_type_code
50
+ SUPPORTED_RECORD_TYPES.include?(record_type)
51
+ end
43
52
 
44
53
  private
45
54
  def parse_date(value)
@@ -196,16 +205,16 @@ class EsrRecord < ActiveRecord::Base
196
205
 
197
206
  if invoice
198
207
  esr_booking = invoice.bookings.build
199
- debit_account = invoice.balance_account
208
+ credit_account = invoice.balance_account
200
209
  else
201
210
  esr_booking = Booking.new
202
- debit_account = DebitInvoice.balance_account
211
+ credit_account = DebitInvoice.balance_account
203
212
  end
204
213
 
205
214
  esr_booking.update_attributes(
206
215
  :amount => amount,
207
- :debit_account => debit_account,
208
- :credit_account => vesr_account,
216
+ :debit_account => vesr_account,
217
+ :credit_account => credit_account,
209
218
  :value_date => value_date,
210
219
  :title => "VESR Zahlung",
211
220
  :comments => remarks
@@ -240,8 +249,8 @@ class EsrRecord < ActiveRecord::Base
240
249
  Booking.create(:title => "Ausserordentlicher Ertrag",
241
250
  :comments => comments || "Zahlung kann keiner Rechnung zugewiesen werden",
242
251
  :amount => self.amount,
243
- :debit_account => Account.find_by_code(Invoice.settings['invoices.extra_earnings_account_code']),
244
- :credit_account => Account.find_by_code(Invoice.settings['invoices.balance_account_code']),
252
+ :debit_account => vesr_account,
253
+ :credit_account => Account.find_by_tag('vesr:extra-earnings'),
245
254
  :value_date => Date.today)
246
255
  end
247
256
  end
@@ -0,0 +1,29 @@
1
+ module EsrRecordTypes
2
+ RECORD_TYPES = {
3
+ esr_e_banking_credit: '002',
4
+ esr_e_banking_cancellation: '005',
5
+ esr_e_banking_correction: '008',
6
+ esr_post_office_counter_credit: '012',
7
+ esr_post_office_counter_cancellation: '015',
8
+ esr_post_office_counter_correction: '018',
9
+
10
+ esr_plus_e_banking_credit: '102',
11
+ esr_plus_e_banking_cancellation: '105',
12
+ esr_plus_e_banking_correction: '108',
13
+ esr_plus_post_office_counter_credit: '112',
14
+ esr_plus_post_office_counter_cancellation: '115',
15
+ esr_plus_post_office_counter_correction: '118',
16
+
17
+ lsv_credit: '202',
18
+ lsv_cancellation: '205',
19
+
20
+ total_record_credit: '999',
21
+ total_record_cancellation: '995',
22
+ }
23
+
24
+ def self.lookup_code(lookup_code)
25
+ RECORD_TYPES.each do |name, code|
26
+ return name if code == lookup_code
27
+ end
28
+ end
29
+ end
@@ -7,4 +7,4 @@
7
7
  %td.currency= currency_fmt(esr_record.invoice.balance.currency_round) if esr_record.invoice
8
8
  %td.action-links
9
9
  - esr_record.aasm.events.each do |event|
10
- = link_to image_tag("16x16/#{event}.png"), polymorphic_url([event, esr_record]), :remote => true, :method => :post, :title => t_action(event)
10
+ = link_to event_image(event.name), polymorphic_url([event.name, esr_record]), :remote => true, :method => :post, :title => t_action(event.name)
@@ -1,3 +1,3 @@
1
1
  module Vesr
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
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: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roman Simecek
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-09-10 00:00:00.000000000 Z
12
+ date: 2016-01-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aasm
@@ -25,6 +25,20 @@ dependencies:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
27
  version: '4.1'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rspec
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: 3.4.0
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: 3.4.0
28
42
  description: VESR provides support for ESR number calculations and gives ready to
29
43
  use Rails components.
30
44
  email:
@@ -38,16 +52,14 @@ extra_rdoc_files:
38
52
  files:
39
53
  - LICENSE.txt
40
54
  - README.rdoc
41
- - app/assets/images/16x16/book_extra_earning.png
42
- - app/assets/images/16x16/reactivate.png
43
- - app/assets/images/16x16/resolve.png
44
- - app/assets/images/16x16/show_all.png
45
- - app/assets/images/16x16/write_off.png
55
+ - app/assets/images/.gitkeep
46
56
  - app/assets/stylesheets/vesr.scss
47
57
  - app/controllers/esr_files_controller.rb
48
58
  - app/controllers/esr_records_controller.rb
59
+ - app/helpers/esr_record_helper.rb
49
60
  - app/models/esr_file.rb
50
61
  - app/models/esr_record.rb
62
+ - app/models/esr_record_types.rb
51
63
  - app/uploaders/esr_file_uploader.rb
52
64
  - app/views/esr_files/_esr_file.html.haml
53
65
  - app/views/esr_files/_form.html.haml