-
Notifications
You must be signed in to change notification settings - Fork 19
Reminder mails for not billed times in past month for order responsibles (64086) #263
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
Draft
svenwey
wants to merge
3
commits into
master
Choose a base branch
from
feature/64086-reminders-for-not-billed-times
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright (c) 2006-2022, Puzzle ITC GmbH. This file is part of | ||
# PuzzleTime and licensed under the Affero General Public License version 3 | ||
# or later. See the COPYING file at the top-level directory or at | ||
# https://github.com/puzzle/puzzletime. | ||
|
||
class NotBilledTimesReminderJob < CronJob | ||
self.cron_expression = '0 5 10 * *' | ||
|
||
def perform | ||
Employee.active_employed_last_month.each do |employee| | ||
accounting_posts = employee.managed_orders | ||
.collect(&:accounting_posts) | ||
.flatten | ||
.filter { |ap| ap.billing_reminder_active == true } | ||
EmployeeMailer.not_billed_times_reminder_mail(employee).deliver_now if accounting_posts.any?(&:unbilled_billable_times_exist_in_past_month?) | ||
end | ||
end | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
app/views/employee_mailer/not_billed_times_reminder_mail.html.haml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
%h1.h3{:style => "box-sizing: border-box; margin: 0.67em 0; font-family: inherit; font-weight: 400; line-height: 1.1; color: inherit; margin-top: 20px; font-size: 24px; margin-bottom: 20px;"} | ||
Hallo | ||
= @employee.firstname | ||
%div{:style => "box-sizing: border-box;"} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [HAML-Lint] reported by reviewdog 🐶 |
||
.lead | ||
Beim einem der Aufträge, bei welchen du Auftragsverantwortliche:r bist, wurden im vergangenen Monat verrechenbare Leistungen gebucht, welche noch keiner Rechnung zugeteilt wurden. | ||
%br | ||
Bitte überprüfe die Leistungen im | ||
= link_to 'Verrechnungs-Controlling', root_url | ||
%br | ||
.lead | ||
Liebe Grüsse | ||
%br | ||
Dein PuzzleTime | ||
%br | ||
Möchtest du zu einer Buchungsposition künftig keine Erinnerungsmail mehr erhalten, deaktiviere in den Einstellungen der Position die Checkbox "Erinnerung bei unverrechneten Leistungen senden". |
10 changes: 10 additions & 0 deletions
10
app/views/employee_mailer/not_billed_times_reminder_mail.text.erb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Hallo <%= @employee.firstname %> | ||
|
||
Beim einem der Aufträge, bei welchen du Auftragsverantwortliche:r bist, wurden im vergangenen Monat verrechenbare Leistungen gebucht, welche noch keiner Rechnung zugeteilt wurden. | ||
|
||
Bitte überprüfe die Leistungen im 'Verrechnungs-Controlling' im PuzzleTime. | ||
|
||
Möchtest du zu einer Buchungsposition künftig keine Erinnerungsmail mehr erhalten, deaktiviere in den Einstellungen der Position die Checkbox "Erinnerung bei unverrechneten Leistungen senden". | ||
|
||
Liebe Grüsse | ||
Dein PuzzleTime |
7 changes: 7 additions & 0 deletions
7
db/migrate/20250501075712_add_billing_reminder_active_to_accounting_posts.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
class AddBillingReminderActiveToAccountingPosts < ActiveRecord::Migration[7.1] | ||
def change | ||
add_column :accounting_posts, :billing_reminder_active, :boolean, default: true, null: false | ||
end | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'test_helper' | ||
|
||
class EmployeeMailerTest < ActionMailer::TestCase | ||
attr_reader :order, :accounting_post1, :accounting_post2 | ||
|
||
setup do | ||
@order = Fabricate(:order, | ||
responsible: employees(:next_year_pablo)) | ||
@accounting_post1 = Fabricate(:accounting_post, | ||
work_item: Fabricate(:work_item, parent_id: order.work_item_id), | ||
offered_hours: 100, | ||
offered_rate: 100, | ||
billing_reminder_active: true) | ||
@accounting_post2 = Fabricate(:accounting_post, | ||
work_item: Fabricate(:work_item, parent_id: order.work_item_id), | ||
offered_hours: 100, | ||
offered_rate: 0, | ||
billing_reminder_active: false) | ||
end | ||
|
||
test 'sends a reminder for an order responsible with active employment' do | ||
order_responsible = employees(:next_year_pablo) | ||
Fabricate(:ordertime, work_item: accounting_post1.work_item, employee: employees(:long_time_john), hours: 5, billable: true, work_date: Period.parse('-1m').end_date) | ||
|
||
assert_emails 1 do | ||
NotBilledTimesReminderJob.new.perform | ||
end | ||
mail = ActionMailer::Base.deliveries.last | ||
|
||
assert_equal [order_responsible.email], mail.to | ||
end | ||
|
||
test 'setting `billing_reminder_active: false` deactivates mails for an accounting_post' do | ||
Fabricate(:ordertime, work_item: accounting_post2.work_item, employee: employees(:long_time_john), hours: 7, billable: true, work_date: Period.parse('-1m').end_date) | ||
|
||
assert_emails 0 do | ||
NotBilledTimesReminderJob.new.perform | ||
end | ||
end | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,4 +18,9 @@ def worktime_commit_reminder_mail | |
employee = Employee.new(email: '[email protected]', firstname: 'Peter', lastname: 'Puzzler') | ||
EmployeeMailer.worktime_commit_reminder_mail(employee) | ||
end | ||
|
||
def not_billed_times_reminder_mail | ||
employee = Employee.new(email: '[email protected]', firstname: 'Peter', lastname: 'Puzzler') | ||
EmployeeMailer.not_billed_times_reminder_mail(employee) | ||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[HAML-Lint] reported by reviewdog 🐶
[W] InlineStyles: Do not use inline style attributes