From cdf1ee1338dc70a4bdcbab86cb3670d10e278ea8 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 5 Oct 2024 10:20:18 +1000 Subject: [PATCH] minor fixes for molli --- app/Exceptions/Handler.php | 2 +- app/Jobs/Util/VersionCheck.php | 2 +- app/PaymentDrivers/Mollie/IDEAL.php | 2 +- app/Services/Chart/ChartQueries.php | 47 ++++++++++++----------------- app/Services/Chart/ChartService.php | 4 +-- app/Utils/HostedPDF/NinjaPdf.php | 3 +- lang/en/texts.php | 2 +- 7 files changed, 27 insertions(+), 35 deletions(-) diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 3c823140af..61a4d17830 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -55,6 +55,7 @@ class Handler extends ExceptionHandler // ModelNotFoundException::class, NotFoundHttpException::class, RelationNotFoundException::class, + NoNodeAvailableException::class, ]; protected $selfHostDontReport = [ @@ -79,7 +80,6 @@ class Handler extends ExceptionHandler ModelNotFoundException::class, NotFoundHttpException::class, RelationNotFoundException::class, - NoNodeAvailableException::class, ]; /** diff --git a/app/Jobs/Util/VersionCheck.php b/app/Jobs/Util/VersionCheck.php index e829c41f55..1f4ab79536 100644 --- a/app/Jobs/Util/VersionCheck.php +++ b/app/Jobs/Util/VersionCheck.php @@ -119,4 +119,4 @@ class VersionCheck implements ShouldQueue } } -} +} \ No newline at end of file diff --git a/app/PaymentDrivers/Mollie/IDEAL.php b/app/PaymentDrivers/Mollie/IDEAL.php index 5645a23e78..e9f115a871 100644 --- a/app/PaymentDrivers/Mollie/IDEAL.php +++ b/app/PaymentDrivers/Mollie/IDEAL.php @@ -210,7 +210,7 @@ class IDEAL implements MethodInterface, LivewireMethodInterface $this->mollie->client->company, ); - return redirect()->route('client.payments.show', ['payment' => $this->mollie->encodePrimaryKey($payment_record->id)]); + return redirect()->route('client.payments.show', ['payment' => $payment_record->hashed_id]); } /** diff --git a/app/Services/Chart/ChartQueries.php b/app/Services/Chart/ChartQueries.php index f1c2dbf9f1..df345e348f 100644 --- a/app/Services/Chart/ChartQueries.php +++ b/app/Services/Chart/ChartQueries.php @@ -54,7 +54,6 @@ trait ChartQueries AND expenses.company_id = :company_id AND (expenses.date BETWEEN :start_date AND :end_date) {$user_filter} - GROUP BY expenses.company_id ", ['company_currency' => $this->company->settings->currency_id, 'company_id' => $this->company->id, 'start_date' => $start_date, 'end_date' => $end_date]); } @@ -70,7 +69,7 @@ trait ChartQueries WHEN expenses.currency_id = :company_currency THEN amount ELSE expenses.amount * expenses.exchange_rate END - ) AS amount, + ) AS total, expenses.date FROM expenses WHERE (expenses.date BETWEEN :start_date AND :end_date) @@ -143,12 +142,13 @@ trait ChartQueries $user_filter = $this->is_admin ? '' : 'AND payments.user_id = '.$this->user->id; return DB::select(" - SELECT sum(payments.amount / payments.exchange_rate) as amount, + SELECT sum((payments.amount - payments.refunded) / payments.exchange_rate) as amount, IFNULL(payments.currency_id, :company_currency) as currency_id FROM payments - WHERE payments.is_deleted = 0 + WHERE payments.company_id = :company_id + AND payments.is_deleted = 0 {$user_filter} - AND payments.company_id = :company_id + AND payments.status_id IN (4,5,6) AND (payments.date BETWEEN :start_date AND :end_date) GROUP BY currency_id ", [ @@ -166,9 +166,8 @@ trait ChartQueries return DB::select(" SELECT - sum((payments.amount - payments.refunded) / payments.exchange_rate) as total, - payments.date, - IFNULL(payments.currency_id, :company_currency) AS currency_id + sum((payments.amount - payments.refunded) * payments.exchange_rate) as total, + payments.date FROM payments WHERE payments.company_id = :company_id AND payments.is_deleted = 0 @@ -177,7 +176,6 @@ trait ChartQueries AND (payments.date BETWEEN :start_date AND :end_date) GROUP BY payments.date ", [ - 'company_currency' => $this->company->settings->currency_id, 'company_id' => $this->company->id, 'start_date' => $start_date, 'end_date' => $end_date, @@ -245,9 +243,8 @@ trait ChartQueries return DB::select(" SELECT - sum(invoices.balance / IFNULL(CAST(JSON_UNQUOTE(JSON_EXTRACT(clients.settings, '$.currency_id')) AS SIGNED), :company_currency2)) as amount, - COUNT(invoices.id) as outstanding_count, - IFNULL(CAST(JSON_UNQUOTE(JSON_EXTRACT( clients.settings, '$.currency_id' )) AS SIGNED), :company_currency) AS currency_id + sum(invoices.balance / invoices.exchange_rate) as amount, + COUNT(invoices.id) as outstanding_count FROM clients JOIN invoices on invoices.client_id = clients.id @@ -259,8 +256,6 @@ trait ChartQueries AND invoices.balance > 0 AND (invoices.date BETWEEN :start_date AND :end_date) ", [ - 'company_currency2' => $this->company->settings->currency_id, - 'company_currency' => $this->company->settings->currency_id, 'company_id' => $this->company->id, 'start_date' => $start_date, 'end_date' => $end_date]); @@ -273,7 +268,7 @@ trait ChartQueries return DB::select(" SELECT - sum((payments.amount - payments.refunded) / payments.exchange_rate) as paid_to_date + sum((payments.amount - payments.refunded) * payments.exchange_rate) as paid_to_date FROM payments JOIN clients ON payments.client_id=clients.id @@ -316,11 +311,9 @@ trait ChartQueries return DB::select(" SELECT - sum(invoices.amount / IFNULL(CAST(JSON_UNQUOTE(JSON_EXTRACT(clients.settings, '$.currency_id')) AS SIGNED), :company_currency2)) as invoiced_amount, - IFNULL(CAST(JSON_UNQUOTE(JSON_EXTRACT( clients.settings, '$.currency_id' )) AS SIGNED), :company_currency) AS currency_id + SUM(invoices.amount / invoices.exchange_rate) as invoiced_amount FROM clients - JOIN invoices - on invoices.client_id = clients.id + JOIN invoices ON invoices.client_id = clients.id WHERE invoices.status_id IN (2,3,4) AND invoices.company_id = :company_id {$user_filter} @@ -328,8 +321,12 @@ trait ChartQueries AND clients.is_deleted = 0 AND invoices.is_deleted = 0 AND (invoices.date BETWEEN :start_date AND :end_date) - GROUP BY invoices.company_id - ", ['company_currency2' => $this->company->settings->currency_id, 'company_currency' => $this->company->settings->currency_id, 'company_id' => $this->company->id, 'start_date' => $start_date, 'end_date' => $end_date]); + ", [ + 'company_id' => $this->company->id, + 'start_date' => $start_date, + 'end_date' => $end_date + ]); + } @@ -361,7 +358,7 @@ trait ChartQueries return DB::select(" SELECT - sum(invoices.balance / IFNULL(CAST(JSON_UNQUOTE(JSON_EXTRACT(clients.settings, '$.currency_id')) AS SIGNED), :company_currency)) as total, + SUM(invoices.balance / invoices.exchange_rate) as total, invoices.date FROM clients JOIN invoices @@ -372,9 +369,7 @@ trait ChartQueries AND invoices.is_deleted = 0 {$user_filter} AND (invoices.date BETWEEN :start_date AND :end_date) - GROUP BY invoices.company_id ", [ - 'company_currency' => (int) $this->company->settings->currency_id, 'company_id' => $this->company->id, 'start_date' => $start_date, 'end_date' => $end_date, @@ -417,7 +412,7 @@ trait ChartQueries return DB::select(" SELECT - sum(invoices.amount / IFNULL(CAST(JSON_UNQUOTE(JSON_EXTRACT(clients.settings, '$.currency_id')) AS SIGNED), :company_currency)) as total, + SUM(invoices.amount / invoices.exchange_rate) as total, invoices.date FROM clients JOIN invoices @@ -428,9 +423,7 @@ trait ChartQueries {$user_filter} AND invoices.status_id IN (2,3,4) AND (invoices.date BETWEEN :start_date AND :end_date) - GROUP BY invoices.company_id ", [ - 'company_currency' => (int) $this->company->settings->currency_id, 'company_id' => $this->company->id, 'start_date' => $start_date, 'end_date' => $end_date, diff --git a/app/Services/Chart/ChartService.php b/app/Services/Chart/ChartService.php index a342addfbf..0e6698bbe1 100644 --- a/app/Services/Chart/ChartService.php +++ b/app/Services/Chart/ChartService.php @@ -138,9 +138,9 @@ class ChartService $aggregate_outstanding = $this->getAggregateOutstandingQuery($start_date, $end_date); $aggregate_expenses = $this->getAggregateExpenseQuery($start_date, $end_date); $aggregate_invoices = $this->getAggregateInvoicesQuery($start_date, $end_date); - + $data[999]['invoices'] = $aggregate_invoices !== false ? reset($aggregate_invoices) : new \stdClass(); - $data[999]['expense'] = $aggregate_expenses !== false ? reset($aggregate_expenses) : new \stdClass(); + $data[999]['expenses'] = $aggregate_expenses !== false ? reset($aggregate_expenses) : new \stdClass(); $data[999]['outstanding'] = $aggregate_outstanding !== false ? reset($aggregate_outstanding) : new \stdClass(); $data[999]['revenue'] = $aggregate_revenue !== false ? reset($aggregate_revenue) : new \stdClass(); diff --git a/app/Utils/HostedPDF/NinjaPdf.php b/app/Utils/HostedPDF/NinjaPdf.php index d63fb8467f..cc62daa89b 100644 --- a/app/Utils/HostedPDF/NinjaPdf.php +++ b/app/Utils/HostedPDF/NinjaPdf.php @@ -33,5 +33,4 @@ class NinjaPdf return $response->getBody()->getContents(); } -} - +} \ No newline at end of file diff --git a/lang/en/texts.php b/lang/en/texts.php index 8a737f50b9..db85d38641 100644 --- a/lang/en/texts.php +++ b/lang/en/texts.php @@ -2364,7 +2364,7 @@ $lang = array( 'currency_gold_troy_ounce' => 'Gold Troy Ounce', 'currency_nicaraguan_córdoba' => 'Nicaraguan Córdoba', 'currency_malagasy_ariary' => 'Malagasy ariary', - "currency_tongan_paanga" => "Tongan Pa'anga", + "currency_tongan_pa_anga" => "Tongan Pa'anga", 'review_app_help' => 'We hope you\'re enjoying using the app.
If you\'d consider :link we\'d greatly appreciate it!', 'writing_a_review' => 'writing a review',