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 logic for reminder generation #219

Merged
merged 31 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
29e947e
first commit
Mar 11, 2024
5ed3972
make class parameers optional / change classnames
Mar 11, 2024
f745895
add ability to distinguish between attachments
Mar 20, 2024
4489eb6
repair shemadb_default
Mar 20, 2024
000e1aa
remove superflous line
Mar 20, 2024
adccafb
remove lacalization
Mar 20, 2024
e76d759
add "create_reminder" to localization
Mar 20, 2024
2d2e6ad
remove lacalization from admin folder
Mar 20, 2024
ef788ca
repaired midgard l10n
Mar 20, 2024
1bcc255
make class name dynamic
Mar 21, 2024
e12885a
add typehint to get_attachment
Mar 21, 2024
7a6b8ed
hide button, when not needed / codingstyle
Mar 21, 2024
6374582
reminder button appers after 14 days
Mar 22, 2024
e2c5b00
use overdue for status
Mar 22, 2024
d49b802
remove $invoice variable /change reminder classname
Mar 25, 2024
6b24e4c
change seccess / error message reminder pdf creation
Mar 25, 2024
c059462
change config /remove lacalization
Mar 25, 2024
9072a3a
change dialog window on reminder re-creation
Mar 25, 2024
ff1df3e
remove 'kind switch'
Mar 25, 2024
7b987a9
remove "has alredy sent" message for overdue reminder
Mar 26, 2024
f0c7a80
include reminder view
Mar 26, 2024
58753de
remove nested if from populate_toolbar()
Mar 26, 2024
0329955
add l10n to filename
Mar 27, 2024
3553315
coding style / remove $kind variable / change l10n
Apr 2, 2024
4179a8c
change label name to reminder
Apr 2, 2024
1d20f78
remove bracelets
Apr 2, 2024
a2445c6
add reminder to l10n
Apr 3, 2024
630d85a
change Mahnung to mahnung.
Apr 4, 2024
764d7a9
change: title/spelling/logic
Apr 8, 2024
428c193
change mahnung lcfirst
Apr 8, 2024
e7dab81
add test
Apr 9, 2024
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
4 changes: 4 additions & 0 deletions lib/org/openpsa/invoices/config/routes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ create_pdf:
path: /invoice/action/create_pdf/
defaults: { _controller: 'org_openpsa_invoices_handler_invoice_action::create_pdf' }

create_reminder:
path: /invoice/action/create_reminder/
defaults: { _controller: 'org_openpsa_invoices_handler_invoice_action::create_pdf_reminder' }

recalc_invoice:
path: /invoice/recalculation/{guid}/
defaults: { _controller: 'org_openpsa_invoices_handler_invoice_items::recalculation' }
Expand Down
13 changes: 12 additions & 1 deletion lib/org/openpsa/invoices/handler/invoice/action.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,24 @@ public function _handler_create_pdf()
{
$pdf_helper = new org_openpsa_invoices_invoice_pdf($this->invoice);
try {
$pdf_helper->render_and_attach();
$pdf_helper->render_and_attach('bill');
return $this->reply(true, $this->_l10n->get('pdf created'));
} catch (midcom_error $e) {
return $this->reply(false, $this->_l10n->get('pdf creation failed') . ': ' . $e->getMessage());
}
}

public function _handler_create_pdf_reminder()
{
$pdf_helper = new org_openpsa_invoices_invoice_pdf($this->invoice);
try {
$pdf_helper->render_and_attach('reminder');
return $this->reply(true, $this->_l10n->get('pdf created'));
SimonRautenberg marked this conversation as resolved.
Show resolved Hide resolved
} catch (midcom_error $e) {
return $this->reply(false, $this->_l10n->get('pdf creation failed') . ': ' . $e->getMessage());
}
}

public function _handler_send_by_mail()
{
$customerCard = org_openpsa_widgets_contact::get($this->invoice->customerContact);
Expand Down
8 changes: 7 additions & 1 deletion lib/org/openpsa/invoices/handler/invoice/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private function populate_toolbar()
$buttons[] = $this->build_button('mark_paid', 'check');
}

if ($this->_config->get('invoice_pdfbuilder_class')) {
if ($this->_config->get('invoice_pdfbuilder_class_bill')) {
SimonRautenberg marked this conversation as resolved.
Show resolved Hide resolved
$button = $this->build_button('create_pdf', 'file-pdf-o');
$pdf_helper = new org_openpsa_invoices_invoice_pdf($this->invoice);
$button[MIDCOM_TOOLBAR_OPTIONS] = $pdf_helper->get_button_options();
Expand All @@ -96,6 +96,11 @@ private function populate_toolbar()
&& intval($billing_data->sendingoption) == 2) {
$buttons[] = $this->build_button('send_by_mail', 'paper-plane');
}

$button = $this->build_button('create_reminder', 'file-pdf-o');
$pdf_helper = new org_openpsa_invoices_invoice_pdf($this->invoice);
$button[MIDCOM_TOOLBAR_OPTIONS] = $pdf_helper->get_button_options();
$buttons[] = $button;
SimonRautenberg marked this conversation as resolved.
Show resolved Hide resolved
}

if ($this->invoice->is_cancelable()) {
Expand All @@ -104,6 +109,7 @@ private function populate_toolbar()

$this->_view_toolbar->add_items($buttons);
$this->add_next_previous($this->invoice, 'invoice/');

SimonRautenberg marked this conversation as resolved.
Show resolved Hide resolved
}

private function build_button(string $action, string $icon) : array
Expand Down
11 changes: 8 additions & 3 deletions lib/org/openpsa/invoices/invoice/pdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function get_attachment(bool $autocreate = false) : ?midcom_db_attachment
if (!$autocreate) {
return null;
}
return $this->render_and_attach();
return $this->render_and_attach('bill');
SimonRautenberg marked this conversation as resolved.
Show resolved Hide resolved
}

public function get_button_options() : array
Expand Down Expand Up @@ -63,9 +63,14 @@ public function get_button_options() : array
];
}

public function render_and_attach() : midcom_db_attachment
public function render_and_attach($kind) : midcom_db_attachment
SimonRautenberg marked this conversation as resolved.
Show resolved Hide resolved
{
$client_class = midcom_baseclasses_components_configuration::get('org.openpsa.invoices', 'config')->get('invoice_pdfbuilder_class');
if($kind == 'bill') {
$client_class = midcom_baseclasses_components_configuration::get('org.openpsa.invoices', 'config')->get('invoice_pdfbuilder_class_bill');
}else {
SimonRautenberg marked this conversation as resolved.
Show resolved Hide resolved
$client_class = midcom_baseclasses_components_configuration::get('org.openpsa.invoices', 'config')->get('invoice_pdfbuilder_class_reminder');
}

SimonRautenberg marked this conversation as resolved.
Show resolved Hide resolved
if (!class_exists($client_class)) {
throw new midcom_error('Could not find PDF renderer ' . $client_class);
}
Expand Down
4 changes: 4 additions & 0 deletions lib/org/openpsa/invoices/locale/default.de.txt
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,10 @@ Die derzeitige PDF-Datei wurde manuell hochgeladen. Soll diese Datei wirklich er
PDF erzeugen
---STRINGEND

---STRING create_reminder
Mahnung erzeugen
---STRINGEND

---STRING pdf created
PDF-Datei wurde erfolgreich erzeugt
---STRINGEND
Expand Down
4 changes: 4 additions & 0 deletions lib/org/openpsa/invoices/locale/default.en.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ Billing data
Create invoice
---STRINGEND

---STRING create_reminder
Create reminder
---STRINGEND

---STRING customer
Customer
---STRINGEND
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [413-414]

Consider revising the punctuation and spacing around the question marks to maintain consistency and adhere to standard English grammar rules. Specifically, remove the space before the question mark and consider adding a comma for clarity if intended to indicate a pause in casual speech.

- shall it be replaced ? The current PDF file was manually uploaded. So shall it really be replaced ?
+ shall it be replaced? The current PDF file was manually uploaded. So, shall it really be replaced?

Expand Down