Skip to content

Commit

Permalink
renamed payment_for to payee, refs #425
Browse files Browse the repository at this point in the history
  • Loading branch information
bihorco36 committed Dec 12, 2017
1 parent 9ae3800 commit b9b6df5
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 24 deletions.
2 changes: 1 addition & 1 deletion app/controllers/invoice_configs_controller.rb
Expand Up @@ -9,7 +9,7 @@ class InvoiceConfigsController < CrudController

self.nesting = Group
self.permitted_attrs = [:payment_information, :address, :iban, :account_number,
:contact_id, :payment_slip, :beneficiary, :payment_for]
:contact_id, :payment_slip, :beneficiary, :payee]

private

Expand Down
2 changes: 1 addition & 1 deletion app/domain/export/pdf/invoice/payment_slip.rb
Expand Up @@ -30,7 +30,7 @@ def invoice_address
def bank_invoice_address
[-50, 125].each do |x|
bounding_box([x, 220], width: 150, height: 80) do
text invoice.payment_for
text invoice.payee
end
bounding_box([x, 180], width: 150, height: 80) do
pdf.font('Courier', size: 9) { text invoice.iban }
Expand Down
2 changes: 1 addition & 1 deletion app/models/invoice.rb
Expand Up @@ -178,7 +178,7 @@ def set_esr_number

def set_payment_attributes
[:address, :account_number, :iban,
:payment_slip, :beneficiary, :payment_for].each do |at|
:payment_slip, :beneficiary, :payee].each do |at|
assign_attributes(at => invoice_config.send(at))
end
end
Expand Down
6 changes: 3 additions & 3 deletions app/models/invoice_config.rb
Expand Up @@ -28,7 +28,7 @@ class InvoiceConfig < ActiveRecord::Base

validates :group_id, uniqueness: true
validates :address, presence: true, on: :update
validates :payment_for, presence: true, on: :update
validates :payee, presence: true, on: :update
validates :beneficiary, presence: true, on: :update, if: proc { |ic| ic.ch_bes? || ic.ch_besr? }


Expand Down Expand Up @@ -60,7 +60,7 @@ def to_s
private

def correct_address_wordwrap
return if payment_for.split(/\n/).length <= 2
errors.add(:payment_for, :to_long)
return if payee.split(/\n/).length <= 2
errors.add(:payee, :to_long)
end
end
2 changes: 1 addition & 1 deletion app/views/invoice_configs/_attrs.html.haml
Expand Up @@ -10,7 +10,7 @@
= labeled_attr(entry, :payment_information)

= labeled(captionize(:payment_slip, object_class(entry)), entry.payment_slip_label)
= labeled_attr(entry, :payment_for)
= labeled_attr(entry, :payee)
= labeled_attr(entry, :beneficiary)
= labeled_attr(entry, :address)
= labeled_attr(entry, :account_number)
Expand Down
2 changes: 1 addition & 1 deletion app/views/invoice_configs/_form.html.haml
Expand Up @@ -11,7 +11,7 @@
%hr
= f.labeled(:payment_slip) do
= f.collection_select(:payment_slip, InvoiceConfig.payment_slip_labels.to_a, :first, :second, {}, class: 'span6')
= f.labeled_input_field :payment_for
= f.labeled_input_field :payee
= f.labeled_input_field :beneficiary
= f.labeled_input_field :address
= f.labeled_input_field :account_number, help: t('.account_number_example')
Expand Down
2 changes: 1 addition & 1 deletion app/views/invoices/_infos.html.haml
Expand Up @@ -12,7 +12,7 @@

.invoice-payment
= labeled(captionize(:payment_slip, object_class(entry)), entry.payment_slip_label)
= labeled_attr(entry, :payment_for)
= labeled_attr(entry, :payee)
= labeled_attr(entry, :beneficiary) if entry.ch_besr? || entry.ch_bes?
= labeled_attr(entry, :address)
= labeled_attr(entry, :account_number)
Expand Down
6 changes: 3 additions & 3 deletions config/locales/models.de.yml
Expand Up @@ -119,7 +119,7 @@ de:
required: 'muss ausgefüllt werden'
account_number:
required: 'muss ausgefüllt werden'
payment_for:
payee:
to_long: 'darf höchstens 2 Zeilen enthalten'

models:
Expand Down Expand Up @@ -637,7 +637,7 @@ de:
payment_purpose: Zahlungszweck
address: Absender Adresse
beneficiary: Zugunsten von
payment_for: Einzahlung für
payee: Einzahlung für
account_number: Kontonummer
iban: IBAN
payment_slip: Einzahlungsschein
Expand All @@ -661,7 +661,7 @@ de:
contact: Kontaktperson
contact_id: Kontaktperson
beneficiary: Zugunsten von
payment_for: Einzahlung für
payee: Einzahlung für
payment_slip: Einzahlungsschein
payment_slips:
ch_es: Roter Einzahlungsschein Post (CH)
Expand Down
6 changes: 6 additions & 0 deletions db/migrate/20171212113638_renamed_payment_for_to_payee.rb
@@ -0,0 +1,6 @@
class RenamedPaymentForToPayee < ActiveRecord::Migration
def change
rename_column :invoices, :payment_for, :payee
rename_column :invoice_configs, :payment_for, :payee
end
end
6 changes: 3 additions & 3 deletions db/schema.rb
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20171211085054) do
ActiveRecord::Schema.define(version: 20171212113638) do

create_table "additional_emails", force: :cascade do |t|
t.integer "contactable_id", limit: 4, null: false
Expand Down Expand Up @@ -260,7 +260,7 @@
t.string "iban"
t.string "payment_slip", default: "ch_es", null: false
t.text "beneficiary"
t.text "payment_for"
t.text "payee"
end

add_index "invoice_configs", ["contact_id"], name: "index_invoice_configs_on_contact_id"
Expand Down Expand Up @@ -300,7 +300,7 @@
t.text "payment_information"
t.string "payment_slip", default: "ch_es", null: false
t.text "beneficiary"
t.text "payment_for"
t.text "payee"
end

add_index "invoices", ["esr_number"], name: "index_invoices_on_esr_number"
Expand Down
6 changes: 3 additions & 3 deletions spec/fixtures/invoice_configs.yml
Expand Up @@ -15,7 +15,7 @@ top_layer:
group: top_layer
sequence_number: 1
beneficiary: 'Hitobito AG'
payment_for: 'Hans Gerber'
payee: 'Hans Gerber'
address: 'top layer address'
iban: 'CH93 0076 2011 6238 5295 7'
account_number: '10-5318-01'
Expand All @@ -24,7 +24,7 @@ bottom_layer_one:
group: bottom_layer_one
sequence_number: 1
beneficiary: 'Hitobito AG'
payment_for: 'Fritz von Gunten'
payee: 'Fritz von Gunten'
address: 'bottom layer one address'
iban: 'CH93 0076 2011 6238 5295 8'
account_number: '10-3991-803'
Expand All @@ -33,7 +33,7 @@ bottom_layer_two:
group: bottom_layer_two
sequence_number: 1
beneficiary: 'Hitobito AG'
payment_for: 'Anna Streit'
payee: 'Anna Streit'
address: 'bottom layer two address'
iban: 'CH84 0221 1981 6169 5329 8'
account_number: '10-3991-803'
8 changes: 4 additions & 4 deletions spec/models/invoice_config_spec.rb
Expand Up @@ -28,14 +28,14 @@
expect(invoice_config.errors.full_messages).to include('Kontonummer ist nicht gültig')
end

it 'validates presence of payment_for' do
invoice_config.update(payment_for: '')
it 'validates presence of payee' do
invoice_config.update(payee: '')

expect(invoice_config).not_to be_valid
end

it 'validates wordwrap of payment_for if bank payment' do
invoice_config.update(payment_for: "line1 \n line2 \n \line 3", payment_slip: 'ch_bes')
it 'validates wordwrap of payee if bank payment' do
invoice_config.update(payee: "line1 \n line2 \n \line 3", payment_slip: 'ch_bes')

expect(invoice_config).not_to be_valid
expect(invoice_config.errors.full_messages).
Expand Down
4 changes: 2 additions & 2 deletions spec/models/invoice_spec.rb
Expand Up @@ -189,7 +189,7 @@
it 'soft deleting group does not delete invoices' do
other = Group::BottomLayer.create!(name: 'x', parent: group)
other.invoice_config.update(iban: 'CH12 2134 1234 1234 1234',
payment_for: 'fuu',
payee: 'fuu',
address: 'fuu',
account_number: 123_443)

Expand All @@ -200,7 +200,7 @@
it 'hard deleting group does delete invoices' do
other = Group::BottomLayer.create!(name: 'x', parent: group)
other.invoice_config.update(iban: 'CH12 2134 1234 1234 1234',
payment_for: 'fuu',
payee: 'fuu',
address: 'fuu',
account_number: 123_443)

Expand Down

0 comments on commit b9b6df5

Please sign in to comment.