Only send one payment email receipt

This commit is contained in:
David Bomba 2023-02-22 20:13:50 +11:00
parent 57cbbd0a42
commit e302b9f9cb
6 changed files with 11 additions and 15 deletions

View File

@ -60,7 +60,6 @@ class EmailPayment implements ShouldQueue
/**
* Execute the job.
*
*
* @return void
*/
public function handle()

View File

@ -26,7 +26,7 @@ class UnlinkFile implements ShouldQueue
protected $disk;
public function __construct(string $disk, string $file_path)
public function __construct(string $disk, ?string $file_path)
{
$this->file_path = $file_path;
$this->disk = $disk;
@ -40,7 +40,7 @@ class UnlinkFile implements ShouldQueue
public function handle()
{
/* Do not delete files if we are on the sync queue*/
if (config('queue.default') == 'sync') {
if (config('queue.default') == 'sync' || ! $this->file_path) {
return;
}

View File

@ -114,7 +114,7 @@ class ApplyPaymentAmount extends AbstractService
$exchange_rate = new CurrencyApi();
$payment->exchange_rate = $exchange_rate->exchangeRate($client_currency, $company_currency, Carbon::parse($payment->date));
//$payment->exchange_currency_id = $client_currency; // 23/06/2021
$payment->exchange_currency_id = $company_currency;
$payment->saveQuietly();

View File

@ -103,7 +103,6 @@ class InvoiceService
* @param Payment $payment The Payment
* @param float $payment_amount The Payment amount
* @return InvoiceService Parent class object
* @deprecated 24-11-2022 - cannot find any references to this method anywhere
*/
public function applyPayment(Payment $payment, float $payment_amount)
{

View File

@ -36,12 +36,12 @@ class SendEmail
$contact = $this->payment->client->contacts()->first();
$this->payment->invoices->sortByDesc('id')->first(function ($invoice) {
$invoice->invitations->each(function ($invitation) {
if (!$invitation->contact->trashed() && $invitation->contact->email) {
EmailPayment::dispatch($this->payment, $this->payment->company, $invitation->contact);
}
});
});
// $this->payment->invoices->sortByDesc('id')->first(function ($invoice) {
// $invoice->invitations->each(function ($invitation) {
// if (!$invitation->contact->trashed() && $invitation->contact->email) {
EmailPayment::dispatch($this->payment, $this->payment->company, $contact);
// }
// });
// });
}
}

View File

@ -22,9 +22,7 @@ trait Uploadable
{
public function removeLogo($company)
{
//if (Storage::disk(config('filesystems.default'))->exists($company->settings->company_logo)) {
(new UnlinkFile(config('filesystems.default'), $company->settings->company_logo))->handle();
//}
(new UnlinkFile(config('filesystems.default'), $company?->settings?->company_logo))->handle();
}
public function uploadLogo($file, $company, $entity)