Remove stale classes

This commit is contained in:
David Bomba 2020-11-10 08:04:57 +11:00
parent af39d5e50c
commit 7977b2a1e7
12 changed files with 3 additions and 388 deletions

View File

@ -355,8 +355,6 @@ class CheckData extends Command
$wrong_balances = 0;
$wrong_paid_to_dates = 0;
//todo reversing an invoice breaks the check data at this point;
Client::cursor()->each(function ($client) use ($wrong_balances) {
$client->invoices->where('is_deleted', false)->each(function ($invoice) use ($wrong_balances, $client) {
$total_amount = $invoice->payments->sum('pivot.amount');

View File

@ -28,7 +28,6 @@ class DefaultSettings extends BaseSettings
/**
* @return stdClass
*
* //todo user specific settings / preferences.
*/
public static function userSettings() : stdClass
{

View File

@ -1,173 +0,0 @@
<?php
namespace App\Helpers\Email;
use App\Models\Invoice;
use App\Models\Payment;
use App\Models\Quote;
use League\CommonMark\CommonMarkConverter;
class EmailBuilder
{
public $subject;
public $body;
public $recipients;
public $attachments;
public $footer;
public $template_style;
public $variables = [];
public $contact = null;
public $view_link;
public $view_text;
/**
* @param $footer
* @return $this
*/
public function setFooter($footer)
{
$this->footer = $footer;
return $this;
}
public function setVariables($variables)
{
$this->variables = $variables;
return $this;
}
/**
* @param $contact
* @return $this
*/
public function setContact($contact)
{
$this->contact = $contact;
return $this;
}
/**
* @param $subject
* @return $this
*/
public function setSubject($subject)
{
if (! empty($this->variables)) {
$subject = str_replace(array_keys($this->variables), array_values($this->variables), $subject);
}
$this->subject = $subject;
return $this;
}
/**
* @param $body
* @return $this
*/
public function setBody($body)
{
//todo move this to use HTMLEngine
if (! empty($this->variables)) {
$body = str_replace(array_keys($this->variables), array_values($this->variables), $body);
}
$this->body = $body;
return $this;
}
/**
* @param $template_style
* @return $this
*/
public function setTemplate($template_style)
{
$this->template_style = $template_style;
return $this;
}
public function setAttachments($attachments)
{
$this->attachments[] = $attachments;
return $this;
}
public function setViewLink($link)
{
$this->view_link = $link;
return $this;
}
public function setViewText($text)
{
$this->view_text = $text;
return $this;
}
/**
* @return mixed
*/
public function getSubject()
{
return $this->subject;
}
/**
* @return mixed
*/
public function getBody()
{
return $this->body;
}
/**
* @return mixed
*/
public function getRecipients()
{
return $this->recipients;
}
/**
* @return mixed
*/
public function getAttachments()
{
return $this->attachments;
}
/**
* @return mixed
*/
public function getFooter()
{
return $this->footer;
}
/**
* @return mixed
*/
public function getTemplate()
{
return $this->template_style;
}
public function getViewLink()
{
return $this->view_link;
}
public function getViewText()
{
return $this->view_text;
}
}

View File

@ -1,86 +0,0 @@
<?php
/**
* Created by PhpStorm.
* User: michael.hampton
* Date: 14/02/2020
* Time: 19:51.
*/
namespace App\Helpers\Email;
use App\Helpers\Email\EntityEmailInterface;
use App\Models\Invoice;
use App\Models\InvoiceInvitation;
use App\Utils\HtmlEngine;
use App\Utils\Number;
class InvoiceEmail extends EmailBuilder
{
public function build(InvoiceInvitation $invitation, $reminder_template = null)
{
$client = $invitation->contact->client;
$invoice = $invitation->invoice;
$contact = $invitation->contact;
if (! $reminder_template) {
$reminder_template = $invoice->calculateTemplate('invoice');
}
$body_template = $client->getSetting('email_template_'.$reminder_template);
/* Use default translations if a custom message has not been set*/
if (iconv_strlen($body_template) == 0) {
$body_template = trans(
'texts.invoice_message',
[
'invoice' => $invoice->number,
'company' => $invoice->company->present()->name(),
'amount' => Number::formatMoney($invoice->balance, $invoice->client),
],
null,
$invoice->client->locale()
);
}
$subject_template = $client->getSetting('email_subject_'.$reminder_template);
if (iconv_strlen($subject_template) == 0) {
if ($reminder_template == 'quote') {
$subject_template = trans(
'texts.quote_subject',
[
'number' => $invoice->number,
'account' => $invoice->company->present()->name(),
],
null,
$invoice->client->locale()
);
} else {
$subject_template = trans(
'texts.invoice_subject',
[
'number' => $invoice->number,
'account' => $invoice->company->present()->name(),
],
null,
$invoice->client->locale()
);
}
}
$this->setTemplate($client->getSetting('email_style'))
->setContact($contact)
->setVariables((new HtmlEngine($invitation))->makeValues())
->setSubject($subject_template)
->setBody($body_template)
->setFooter("<a href='{$invitation->getLink()}'>".ctrans('texts.view_invoice').'</a>')
->setViewLink($invitation->getLink())
->setViewText(ctrans('texts.view_invoice'));
if ($client->getSetting('pdf_email_attachment') !== false) {
$this->setAttachments($invitation->pdf_file_path());
}
return $this;
}
}

View File

@ -1,48 +0,0 @@
<?php
/**
* Created by PhpStorm.
* User: michael.hampton
* Date: 14/02/2020
* Time: 19:51.
*/
namespace App\Helpers\Email;
use App\Models\Payment;
class PaymentEmail extends EmailBuilder
{
public function build(Payment $payment, $contact = null)
{
$client = $payment->client;
$body_template = $client->getSetting('email_template_payment');
/* Use default translations if a custom message has not been set*/
if (iconv_strlen($body_template) == 0) {
$body_template = trans(
'texts.payment_message',
['amount' => $payment->amount, 'company' => $payment->company->present()->name()],
null,
$this->client->locale()
);
}
$subject_template = $client->getSetting('email_subject_payment');
if (iconv_strlen($subject_template) == 0) {
$subject_template = trans(
'texts.payment_subject',
['number' => $payment->number, 'company' => $payment->company->present()->name()],
null,
$payment->client->locale()
);
}
$this->setTemplate($payment->client->getSetting('email_style'))
->setSubject($subject_template)
->setBody($body_template);
return $this;
}
}

View File

@ -1,70 +0,0 @@
<?php
/**
* Created by PhpStorm.
* User: michael.hampton
* Date: 14/02/2020
* Time: 19:51.
*/
namespace App\Helpers\Email;
use App\Models\Quote;
use App\Models\QuoteInvitation;
use App\Utils\HtmlEngine;
class QuoteEmail extends EmailBuilder
{
public function build(QuoteInvitation $invitation, $reminder_template)
{
$client = $invitation->contact->client;
$quote = $invitation->quote;
$contact = $invitation->contact;
$this->template_style = $client->getSetting('email_style');
$body_template = $client->getSetting('email_template_'.$reminder_template);
/* Use default translations if a custom message has not been set*/
if (iconv_strlen($body_template) == 0) {
$body_template = trans(
'texts.quote_message',
['amount' => $quote->amount, 'company' => $quote->company->present()->name()],
null,
$quote->client->locale()
);
}
$subject_template = $client->getSetting('email_subject_'.$reminder_template);
if (iconv_strlen($subject_template) == 0) {
if ($reminder_template == 'quote') {
$subject_template = trans(
'texts.quote_subject',
['number' => $quote->number, 'company' => $quote->company->present()->name()],
null,
$quote->client->locale()
);
} else {
$subject_template = trans(
'texts.reminder_subject',
['number' => $quote->number, 'company' => $quote->company->present()->name()],
null,
$quote->client->locale()
);
}
}
$this->setTemplate($quote->client->getSetting('email_style'))
->setContact($contact)
->setFooter("<a href='{$invitation->getLink()}'>Quote Link</a>")
->setVariables((new HtmlEngine($invitation))->makeValues())
->setSubject($subject_template)
->setBody($body_template);
if ($client->getSetting('pdf_email_attachment') !== false) {
$this->attachments = $invitation->pdf_file_path();
}
return $this;
}
}

View File

@ -63,7 +63,7 @@ class GmailTransport extends Transport
$this->gmail->cc($message->getCc());
$this->gmail->bcc($message->getBcc());
Log::error(print_r($message->getChildren(), 1));
info(print_r($message->getChildren(), 1));
foreach ($message->getChildren() as $child) {
$this->gmail->attach($child);

View File

@ -23,6 +23,8 @@
function ctrans(string $string, $replace = [], $locale = null) : string
{
//todo pass through the cached version of the custom strings here else return trans();
//note** This may no longer be required as we are injecting the custom translations
//into the singleton now?
return trans($string, $replace, $locale);
}

View File

@ -12,7 +12,6 @@
namespace App\Jobs\Util;
use App\Events\Invoice\InvoiceWasEmailed;
use App\Helpers\Email\InvoiceEmail;
use App\Jobs\Invoice\EmailInvoice;
use App\Libraries\MultiDB;
use App\Models\Account;

View File

@ -11,7 +11,6 @@
namespace App\Jobs\Util;
use App\Helpers\Email\InvoiceEmail;
use App\Jobs\Entity\EmailEntity;
use App\Libraries\MultiDB;
use App\Models\SystemLog;

View File

@ -12,7 +12,6 @@
namespace App\Services\Payment;
use App\Events\Invoice\InvoiceWasUpdated;
use App\Helpers\Email\PaymentEmail;
use App\Jobs\Payment\EmailPayment;
use App\Jobs\Util\SystemLogger;
use App\Models\Invoice;

View File

@ -11,7 +11,6 @@
namespace App\Services\Quote;
use App\Helpers\Email\QuoteEmail;
use App\Jobs\Entity\EmailEntity;
use App\Jobs\Quote\EmailQuote;
use App\Models\ClientContact;
@ -46,9 +45,6 @@ class SendEmail
$this->quote->invitations->each(function ($invitation) {
if ($invitation->contact->send_email && $invitation->contact->email) {
$email_builder = (new QuoteEmail())->build($invitation, $this->reminder_template);
// EmailQuote::dispatchNow($email_builder, $invitation, $invitation->company);
EmailEntity::dispatchNow($invitation, $invitation->company, $this->reminder_template);
}