Skip to content

Commit

Permalink
member receipt with notes and things
Browse files Browse the repository at this point in the history
  • Loading branch information
baldarn committed Sep 18, 2024
1 parent 978308e commit 4035d14
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 30 deletions.
2 changes: 1 addition & 1 deletion app/controllers/payments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def send_receipt
private

def payment_params
params.require(:payment).permit(:amount, :number, :kind, :payment_reason_id)
params.require(:payment).permit(:amount, :number, :kind, :note, :payment_reason_id)
end

def set_member
Expand Down
3 changes: 1 addition & 2 deletions app/models/club.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ def full_name_and_address_for_receipt
[name, full_address, email].join('<br/>')
end

# TODO
def full_address
'via Roma 139, Livorno'
[address, municipality, postal_code, province].join(', ')
end
end
1 change: 1 addition & 0 deletions app/views/payments/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
<% if payment.created_at %>
<%= f.input :created_at, disabled: true, as: :date %>
<% end %>
<%= f.input :note %>
<%= f.button :submit, 'Salva pagamento' %>
<% end %>
2 changes: 2 additions & 0 deletions app/views/payments/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<th scope="col"><%= I18n.t('activerecord.attributes.payment.amount') %></th>
<th scope="col"><%= I18n.t('activerecord.attributes.payment.payment_reason') %></th>
<th scope="col"><%= I18n.t('activerecord.attributes.payment.created_at') %></th>
<th scope="col"><%= I18n.t('activerecord.attributes.payment.note') %></th>
<th scope="col"><%= I18n.t('actions') %></th>
</tr>
</thead>
Expand All @@ -63,6 +64,7 @@
<td><%= number_to_currency(payment.amount) %></td>
<td><%= payment.payment_reason.reason %></td>
<td><%= payment.created_at %></td>
<td><%= truncate(payment.note, length: 25) %></td>
<td>
<%= link_to club_payment_send_receipt_path(@club, payment), data: { turbo_method: :get, turbo_confirm: I18n.t('payments.confirm_send')}, class: 'text-decoration-none' do %>
<%= image_tag "send.svg", aria: { hidden: true }, size: 24 %>
Expand Down
45 changes: 20 additions & 25 deletions app/views/pdf/payments/receipt.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,6 @@
margin: auto;
border: 1px solid #ccc;
}
.header {
text-align: center;
margin-bottom: 30px;
}
.header h1 {
font-size: 24px;
margin-bottom: 5px;
}
.header p {
margin: 5px 0;
}
.content {
margin-bottom: 20px;
}
Expand All @@ -41,18 +30,21 @@
</head>
<body>
<div class="container">
<div class="header">
<h1>JAKU KAI</h1>
<p>ASSOCIAZIONE SPORTIVA DILETTANTISTICA CULTURALE</p>
<p>Cod. Fisc. 95084300102</p>
<p>Via Fieschi 20° canc., 16128 GENOVA</p>
<p>Tel. 010 9845366</p>
<p>e-mail: [email protected] | www.jakukai.it</p>
</div>
<table style="width: 100%;">
<tr>
<td style="width: 200px; text-align: left;">
<% if club.errors[:picture].blank? && club.picture.present? %>
<img src="data:<%= club.picture_blob.content_type %>;base64,<%= Base64.encode64(club.picture.download) %>" style="max-width: 200px;">
<% end %>
</td>
<td style="text-align: center; font-size: 2em; font-weight: bold;">RICEVUTA NOTA SPESE</td>
<td style="width: 200px; text-align: right;"><%= club.full_name_and_address_for_receipt %></td>
</tr>
</table>
<hr/>
<div class="content">
<p><strong>RICEVUTA n.°</strong></p>
<p><strong>Genova</strong></p>
<p><strong>RICEVUTA n.°<%= payment.number %></strong></p>
<p><strong><%= club.municipality %></strong></p>
<p>Riceviamo da: <strong><%= member.full_name %></strong></p>
<p>CF: <strong><%= member.tax_code %></strong></p>
<p>La somma di: <strong><%= payment.in_eur %></strong></p>
Expand All @@ -64,8 +56,11 @@
<p><strong>VERSAMENTO ESEGUITO DA:</strong> <%= member.full_name %></p>
<p><strong>CODICE FISCALE:</strong> <%= member.tax_code %></p>
<p><strong>Tipo di Pagamento:</strong> <%= payment.kind %></p>
<p>Nota:</p>
<% if payment.note? %>
<p>Nota:</p>
<p><%= payment.note %>
<% end %>
</div>
</div>
</div>
</body>
</html>
</body>
</html>
2 changes: 1 addition & 1 deletion config/initializers/rucaptcha.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# If you wants disable `cache_store` check warning, you can do it, default: false
# 如果想要 disable cache_store 的 warning,就设置为 true,default false
# self.skip_cache_store_check = true
self.skip_cache_store_check = true

# Chars length, default: 5, allows: [3 - 7]
# self.length = 5
Expand Down
1 change: 1 addition & 0 deletions config/locales/it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ it:
payment:
amount: Quota
payment_reason: Causale
note: Note
created_at: Data
payment/kind:
cash: Contanti
Expand Down
7 changes: 7 additions & 0 deletions db/migrate/20240916085436_add_note_to_payment.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

class AddNoteToPayment < ActiveRecord::Migration[7.2]
def change
add_column :payments, :note, :text
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.2].define(version: 2024_09_04_123152) do
ActiveRecord::Schema[7.2].define(version: 2024_09_16_085436) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"

Expand Down Expand Up @@ -193,6 +193,7 @@
t.datetime "updated_at", null: false
t.integer "number", default: 0, null: false
t.integer "kind", default: 0, null: false
t.text "note"
t.index ["member_id"], name: "index_payments_on_member_id"
t.index ["payment_reason_id"], name: "index_payments_on_payment_reason_id"
end
Expand Down

0 comments on commit 4035d14

Please sign in to comment.