vesr 0.11.6 → 0.11.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -93,27 +93,29 @@ class EsrRecord < ActiveRecord::Base
93
93
  end
94
94
 
95
95
  def update_remarks
96
- if invoice.nil?
96
+ # Invoice not found
97
+ if self.state == 'missing'
97
98
  self.remarks += ", Rechnung ##{invoice_id} nicht gefunden"
98
- elsif invoice.state == 'paid'
99
- # already paid
100
- if invoice.amount == self.amount
101
- # paid twice
102
- self.remarks += ", doppelt bezahlt"
103
- else
104
- self.remarks += ", bereits bezahlt"
105
- end
106
- elsif !(invoice.active)
107
- # canceled invoice
99
+ return
100
+ end
101
+
102
+ # Remark if invoice should not get payment according to state
103
+ if !(invoice.active)
108
104
  self.remarks += ", wurde bereits #{invoice.state_adverb}"
109
- elsif invoice.amount == self.amount
110
- # TODO much too open condition (issue #804)
111
- # reminder fee not paid
112
- self.remarks += ", Mahnspesen nicht bezahlt"
113
- else
114
- # bad amount
115
- self.remarks += ", falscher Betrag"
105
+ return
106
+ end
107
+
108
+ # Perfect payment
109
+ return if invoice.balance == 0
110
+
111
+ # Paid more than once
112
+ if (self.state == 'overpaid') and (invoice.amount == self.amount)
113
+ self.remarks += ", mehrfach bezahlt"
114
+ return
116
115
  end
116
+
117
+ # Simply mark bad amount otherwise
118
+ self.remarks += ", falscher Betrag"
117
119
  end
118
120
 
119
121
  def update_state
@@ -140,7 +142,7 @@ class EsrRecord < ActiveRecord::Base
140
142
  end
141
143
 
142
144
  # Invoices
143
- before_create :assign_invoice, :create_esr_booking, :update_remarks, :update_state
145
+ before_create :assign_invoice, :create_esr_booking, :update_state, :update_remarks, :update_invoice_state
144
146
 
145
147
  private
146
148
  def assign_invoice
@@ -185,6 +187,12 @@ class EsrRecord < ActiveRecord::Base
185
187
  return esr_booking
186
188
  end
187
189
 
190
+ def update_invoice_state
191
+ if invoice
192
+ invoice.calculate_state
193
+ end
194
+ end
195
+
188
196
  public
189
197
  def create_extra_earning_booking(comments = nil)
190
198
  Booking.create(:title => "Ausserordentlicher Ertrag",
data/lib/vesr/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Vesr
2
- VERSION = "0.11.6"
2
+ VERSION = "0.11.7"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vesr
3
3
  version: !ruby/object:Gem::Version
4
- hash: 63
4
+ hash: 61
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 11
9
- - 6
10
- version: 0.11.6
9
+ - 7
10
+ version: 0.11.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Roman Simecek
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2012-03-20 00:00:00 Z
19
+ date: 2012-03-23 00:00:00 Z
20
20
  dependencies: []
21
21
 
22
22
  description: VESR provides support for ESR number calculations and gives ready to use Rails components.
@@ -95,9 +95,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
95
  requirements: []
96
96
 
97
97
  rubyforge_project:
98
- rubygems_version: 1.8.16
98
+ rubygems_version: 1.8.10
99
99
  signing_key:
100
100
  specification_version: 3
101
101
  summary: VESR invoice support library.
102
102
  test_files: []
103
103
 
104
+ has_rdoc: