Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a payment deadline #1160

Merged
merged 4 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/controllers/admin/activities_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def activity_post_params
:open_date,
:open_time,
:unenroll_date,
:payment_deadline,
:comments,
:price,
:location,
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/src/admin/activities.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ function addColumnClassToColumns() {
}

function addCollapseCallbackToTableHeader() {
$("#participants-table > thead > tr")
$("#participants-taunenrollble > thead > tr")
.find("td")
.each(function (_) {
$(this).append("✂️");
Expand Down
13 changes: 10 additions & 3 deletions app/models/activity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,13 @@ def content_type

scope :late_unpayable, lambda {
# All participants who will receive payment reminders
where('NOT activities.is_payable AND activities.start_date <= ?', Date.today).joins(:participants)
.where('participants.reservist IS FALSE
where(
'NOT activities.is_payable
AND activities.start_date <= ?
AND (activities.payment_deadline IS NULL OR activities.payment_deadline > ?)',
Date.today, Date.today
).joins(:participants)
.where('participants.reservist IS FALSE
AND
(
(activities.price IS NOT NULL
Expand Down Expand Up @@ -113,6 +118,8 @@ def self.debtors
joins(:participants).where('
activities.is_payable
AND
(activities.payment_deadline IS NULL OR activities.payment_deadline > ?)
AND
participants.reservist IS FALSE
AND
(
Expand All @@ -132,7 +139,7 @@ def self.debtors
AND
participants.price IS NOT NULL
)
)').distinct
)', Date.today).distinct
end

def payment_mail_recipients
Expand Down
5 changes: 5 additions & 0 deletions app/views/admin/activities/partials/_edit.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@
.col-md-12
= label(:activity, :unenroll_date)
= f.date_field :unenroll_date, :value => @activity.unenroll_date, :class => 'form-control'
.form-group
.row
.col-md-12
= label(:activity, :payment_deadline)
= f.date_field :payment_deadline, :value => @activity.payment_deadline, :class => 'form-control'
.form-group
.row
.col-md-12
Expand Down
4 changes: 4 additions & 0 deletions app/views/api/activities/show.rabl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ node :unenroll_date do |activity|
activity.unenroll_date&.iso8601
end

node :payment_deadline do |activity|
activity.payment_deadline&.iso8601
end

node :attendees do |activity|
activity.participant_filter(activity.ordered_attendees)
end
Expand Down
6 changes: 6 additions & 0 deletions app/views/members/activities/partials/_view.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@
%span.activity-unenroll
= l(activity.unenroll_date, format: "%A %d/%m/%Y")
23:59
<br/>
- if !activity.payment_deadline.nil?
%strong= I18n.t('activerecord.attributes.activity.payment_deadline')
%span.activity-payment-deadline
= l(activity.payment_deadline, format: "%A %d/%m/%Y")
23:59
<br/>
- if !activity.google_event().nil?
%a{href: activity.google_event(), target: "_blank"}
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ en:
notes_public: Public
organized_by: Organisator
participant_limit: Participant limit
payment_deadline: Payment deadline
price: Price
show_on_website: On website
show_participants: Show participants
Expand Down
1 change: 1 addition & 0 deletions config/locales/nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ nl:
notes_public: Publiek
organized_by: Organisator
participant_limit: Deelnemerslimiet
payment_date: Betalingsdeadline
price: Prijs
show_on_website: Toon op website
show_participants: Deelnemers zichtbaar
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddPaymentDeadlineToActivities < ActiveRecord::Migration[6.1]
def change
add_column :activities, :payment_deadline, :date
end
end
7 changes: 5 additions & 2 deletions db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ CREATE TABLE public.activities (
open_time time without time zone,
is_sophomores boolean,
is_seniors boolean,
payable_updated_at date
payable_updated_at date,
payment_deadline date
);


Expand Down Expand Up @@ -1737,6 +1738,8 @@ INSERT INTO "schema_migrations" (version) VALUES
('20220406092056'),
('20220524203723'),
('20240125003700'),
('20240809152416');
('20240809152416'),
('20250204130332'),
('20250204135006');


Loading