diff --git a/VERSION.txt b/VERSION.txt
index 903cb9a06740..fb2688fbd9e6 100644
--- a/VERSION.txt
+++ b/VERSION.txt
@@ -1 +1 @@
-5.3.90
\ No newline at end of file
+5.3.91
\ No newline at end of file
diff --git a/app/Http/Requests/Report/GenericReportRequest.php b/app/Http/Requests/Report/GenericReportRequest.php
index 95d5a04ac0d8..208e53aac682 100644
--- a/app/Http/Requests/Report/GenericReportRequest.php
+++ b/app/Http/Requests/Report/GenericReportRequest.php
@@ -31,9 +31,20 @@ class GenericReportRequest extends Request
'start_date' => 'string|date',
'end_date' => 'string|date',
'date_key' => 'string',
- 'date_range' => 'string',
+ 'date_range' => 'required|string',
'report_keys' => 'present|array',
- 'send_email' => 'bool',
+ 'send_email' => 'required|bool',
];
}
+
+ public function prepareForValidation()
+ {
+ $input = $this->all();
+
+
+ if(!array_key_exists('report_keys', $input))
+ $input['report_keys'] = [];
+
+ $this->replace($input);
+ }
}
diff --git a/app/Listeners/Payment/PaymentNotification.php b/app/Listeners/Payment/PaymentNotification.php
index 3dd580cd2e63..8ce34c221f4f 100644
--- a/app/Listeners/Payment/PaymentNotification.php
+++ b/app/Listeners/Payment/PaymentNotification.php
@@ -124,6 +124,8 @@ class PaymentNotification implements ShouldQueue
*/
private function sendAnalytics($data)
{
+ nlog($data);
+
$data = utf8_encode($data);
$curl = curl_init();
diff --git a/app/Mail/MigrationCompleted.php b/app/Mail/MigrationCompleted.php
index ced994b6f2ae..52aafec22291 100644
--- a/app/Mail/MigrationCompleted.php
+++ b/app/Mail/MigrationCompleted.php
@@ -47,6 +47,28 @@ class MigrationCompleted extends Mailable
$data['check_data'] = $this->check_data ?: '';
$data['logo'] = $this->company->present()->logo();
+ $data = array_merge($data, [
+ 'logo' => $this->company->present()->logo(),
+ 'settings' => $this->company->settings,
+ 'company' => $this->company,
+ 'client_count' => $this->company->clients()->count(),
+ 'product_count' => $this->company->products()->count(),
+ 'invoice_count' => $this->company->invoices()->count(),
+ 'quote_count' => $this->company->quotes()->count(),
+ 'credit_count' => $this->company->credits()->count(),
+ 'project_count' => $this->company->projects()->count(),
+ 'task_count' => $this->company->tasks()->count(),
+ 'vendor_count' => $this->company->vendors()->count(),
+ 'payment_count' => $this->company->payments()->count(),
+ 'recurring_invoice_count' => $this->company->recurring_invoices()->count(),
+ 'expense_count' => $this->company->expenses()->count(),
+ 'company_gateway_count' => $this->company->company_gateways()->count(),
+ 'client_gateway_token_count' => $this->company->client_gateway_tokens()->count(),
+ 'tax_rate_count' => $this->company->tax_rates()->count(),
+ 'document_count' => $this->company->documents()->count(),
+
+ ]);
+
$result = $this->from(config('mail.from.address'), config('mail.from.name'))
->text('email.import.completed_text', $data)
->view('email.import.completed', $data);
diff --git a/app/Models/Company.php b/app/Models/Company.php
index 64b4a712e21c..40300ae8972b 100644
--- a/app/Models/Company.php
+++ b/app/Models/Company.php
@@ -102,7 +102,6 @@ class Company extends BaseModel
'markdown_email_enabled',
'stop_on_unpaid_recurring',
'use_quote_terms_on_conversion',
- 'show_production_description_dropdown',
];
protected $hidden = [
diff --git a/app/PaymentDrivers/MolliePaymentDriver.php b/app/PaymentDrivers/MolliePaymentDriver.php
index ed333f259c40..6e08cbe3482a 100644
--- a/app/PaymentDrivers/MolliePaymentDriver.php
+++ b/app/PaymentDrivers/MolliePaymentDriver.php
@@ -353,6 +353,10 @@ class MolliePaymentDriver extends BaseDriver
$response = SystemLog::EVENT_GATEWAY_FAILURE;
if($record){
+
+ if(in_array($payment->status, ['canceled','expired','failed']))
+ $record->service()->deletePayment();
+
$record->status_id = $codes[$payment->status];
$record->save();
$response = SystemLog::EVENT_GATEWAY_SUCCESS;
diff --git a/app/Services/Chart/ChartQueries.php b/app/Services/Chart/ChartQueries.php
index 6224f98d3c53..b05f3d3f1042 100644
--- a/app/Services/Chart/ChartQueries.php
+++ b/app/Services/Chart/ChartQueries.php
@@ -22,11 +22,119 @@ use Illuminate\Support\Facades\DB;
trait ChartQueries
{
- // $currencies = Payment::withTrashed()
- // ->where('company_id', $this->company->id)
- // ->where('is_deleted', 0)
- // ->distinct()
- // ->get(['currency_id']);
+ /**
+ * Expenses
+ */
+ public function getExpenseQuery($start_date, $end_date)
+ {
+
+ return DB::select( DB::raw("
+ SELECT sum(expenses.amount) as amount,
+ IFNULL(expenses.currency_id, :company_currency) as currency_id
+ FROM expenses
+ WHERE expenses.is_deleted = 0
+ AND expenses.company_id = :company_id
+ AND (expenses.date BETWEEN :start_date AND :end_date)
+ GROUP BY currency_id
+ "), ['company_currency' => $this->company->settings->currency_id, 'company_id' => $this->company->id, 'start_date' => $start_date, 'end_date' => $end_date] );
+
+ }
+
+ public function getExpenseChartQuery($start_date, $end_date, $currency_id)
+ {
+
+ return DB::select( DB::raw("
+ SELECT
+ sum(expenses.amount) as total,
+ expenses.date,
+ IFNULL(expenses.currency_id, :company_currency) AS currency_id
+ FROM expenses
+ WHERE (expenses.date BETWEEN :start_date AND :end_date)
+ AND expenses.company_id = :company_id
+ AND expenses.is_deleted = 0
+ GROUP BY expenses.date
+ HAVING currency_id = :currency_id
+ "), [
+ 'company_currency' => $this->company->settings->currency_id,
+ 'currency_id' => $currency_id,
+ 'company_id' => $this->company->id,
+ 'start_date' => $start_date,
+ 'end_date' => $end_date
+ ]);
+
+ }
+
+ /**
+ * Payments
+ */
+ public function getPaymentQuery($start_date, $end_date)
+ {
+
+ return DB::select( DB::raw("
+ SELECT sum(payments.amount) as amount,
+ IFNULL(payments.currency_id, :company_currency) as currency_id
+ FROM payments
+ WHERE payments.is_deleted = 0
+ AND payments.company_id = :company_id
+ AND (payments.date BETWEEN :start_date AND :end_date)
+ GROUP BY currency_id
+ "), [
+ 'company_currency' => $this->company->settings->currency_id,
+ 'company_id' => $this->company->id,
+ 'start_date' => $start_date,
+ 'end_date' => $end_date
+ ]);
+
+ }
+
+ public function getPaymentChartQuery($start_date, $end_date, $currency_id)
+ {
+
+ return DB::select( DB::raw("
+ SELECT
+ sum(payments.amount - payments.refunded) as total,
+ payments.date,
+ IFNULL(payments.currency_id, :company_currency) AS currency_id
+ FROM payments
+ WHERE payments.status_id IN (4,5,6)
+ AND (payments.date BETWEEN :start_date AND :end_date)
+ AND payments.company_id = :company_id
+ AND payments.is_deleted = 0
+ GROUP BY payments.date
+ HAVING currency_id = :currency_id
+ "), [
+ 'company_currency' => $this->company->settings->currency_id,
+ 'currency_id' => $currency_id,
+ 'company_id' => $this->company->id,
+ 'start_date' => $start_date,
+ 'end_date' => $end_date
+ ]);
+
+ }
+
+ /**
+ * Invoices
+ */
+ public function getOutstandingQuery($start_date, $end_date)
+ {
+
+ return DB::select( DB::raw("
+ SELECT
+ sum(invoices.balance) as amount,
+ IFNULL(JSON_EXTRACT( settings, '$.currency_id' ), :company_currency) AS currency_id
+ FROM clients
+ JOIN invoices
+ on invoices.client_id = clients.id
+ WHERE invoices.status_id IN (2,3)
+ AND invoices.company_id = :company_id
+ AND invoices.balance > 0
+ AND clients.is_deleted = 0
+ AND invoices.is_deleted = 0
+ AND (invoices.date BETWEEN :start_date AND :end_date)
+ GROUP BY currency_id
+ "), ['company_currency' => $this->company->settings->currency_id, 'company_id' => $this->company->id, 'start_date' => $start_date, 'end_date' => $end_date] );
+
+ }
public function getRevenueQuery($start_date, $end_date)
{
@@ -49,55 +157,6 @@ trait ChartQueries
}
- public function getOutstandingQuery($start_date, $end_date)
- {
-
- return DB::select( DB::raw("
- SELECT
- sum(invoices.balance) as balance,
- IFNULL(JSON_EXTRACT( settings, '$.currency_id' ), :company_currency) AS currency_id
- FROM clients
- JOIN invoices
- on invoices.client_id = clients.id
- WHERE invoices.status_id IN (2,3)
- AND invoices.company_id = :company_id
- AND invoices.balance > 0
- AND clients.is_deleted = 0
- AND invoices.is_deleted = 0
- AND (invoices.due_date BETWEEN :start_date AND :end_date)
- GROUP BY currency_id
- "), ['company_currency' => $this->company->settings->currency_id, 'company_id' => $this->company->id, 'start_date' => $start_date, 'end_date' => $end_date] );
-
- }
-
- public function getExpenseQuery($start_date, $end_date)
- {
-
- return DB::select( DB::raw("
- SELECT sum(expenses.amount) as amount,
- IFNULL(expenses.currency_id, :company_currency) as currency_id
- FROM expenses
- WHERE expenses.is_deleted = 0
- AND expenses.company_id = :company_id
- AND (expenses.date BETWEEN :start_date AND :end_date)
- GROUP BY currency_id
- "), ['company_currency' => $this->company->settings->currency_id, 'company_id' => $this->company->id, 'start_date' => $start_date, 'end_date' => $end_date] );
-
- }
-
- public function getPaymentQuery($start_date, $end_date)
- {
- return DB::select( DB::raw("
- SELECT sum(expenses.amount) as amount,
- IFNULL(expenses.currency_id, :company_currency) as currency_id
- FROM expenses
- WHERE expenses.is_deleted = 0
- AND expenses.company_id = :company_id
- AND (expenses.date BETWEEN :start_date AND :end_date)
- GROUP BY currency_id
- "), ['company_currency' => $this->company->settings->currency_id, 'company_id' => $this->company->id, 'start_date' => $start_date, 'end_date' => $end_date] );
- }
-
public function getInvoiceChartQuery($start_date, $end_date, $currency_id)
{
@@ -123,118 +182,7 @@ trait ChartQueries
'start_date' => $start_date,
'end_date' => $end_date
]);
+
}
- public function getPaymentChartQuery($start_date, $end_date, $currency_id)
- {
-
- return DB::select( DB::raw("
- SELECT
- sum(payments.amount - payments.refunded) as total,
- payments.date,
- IFNULL(payments.currency_id, :company_currency) AS currency_id
- FROM payments
- WHERE payments.status_id IN (4,5,6)
- AND (payments.date BETWEEN :start_date AND :end_date)
- AND payments.company_id = :company_id
- AND payments.is_deleted = 0
- GROUP BY payments.date
- HAVING currency_id = :currency_id
- "), [
- 'company_currency' => $this->company->settings->currency_id,
- 'currency_id' => $currency_id,
- 'company_id' => $this->company->id,
- 'start_date' => $start_date,
- 'end_date' => $end_date
- ]);
- }
-
- public function getExpenseChartQuery($start_date, $end_date, $currency_id)
- {
-
- return DB::select( DB::raw("
- SELECT
- sum(expenses.amount) as total,
- expenses.date,
- IFNULL(expenses.currency_id, :company_currency) AS currency_id
- FROM expenses
- WHERE (expenses.date BETWEEN :start_date AND :end_date)
- AND expenses.company_id = :company_id
- AND expenses.is_deleted = 0
- GROUP BY expenses.date
- HAVING currency_id = :currency_id
- "), [
- 'company_currency' => $this->company->settings->currency_id,
- 'currency_id' => $currency_id,
- 'company_id' => $this->company->id,
- 'start_date' => $start_date,
- 'end_date' => $end_date
- ]);
- }
-
-
}
-
-
-
-
-/*
- public function payments($accountId, $userId, $viewAll)
- {
- $payments = DB::table('payments')
- ->leftJoin('clients', 'clients.id', '=', 'payments.client_id')
- ->leftJoin('contacts', 'contacts.client_id', '=', 'clients.id')
- ->leftJoin('invoices', 'invoices.id', '=', 'payments.invoice_id')
- ->where('payments.account_id', '=', $accountId)
- ->where('payments.is_deleted', '=', false)
- ->where('invoices.is_deleted', '=', false)
- ->where('clients.is_deleted', '=', false)
- ->where('contacts.deleted_at', '=', null)
- ->where('contacts.is_primary', '=', true)
- ->whereNotIn('payments.payment_status_id', [PAYMENT_STATUS_VOIDED, PAYMENT_STATUS_FAILED]);
-
- if (! $viewAll) {
- $payments = $payments->where('payments.user_id', '=', $userId);
- }
-
- return $payments->select(['payments.payment_date', DB::raw('(payments.amount - payments.refunded) as amount'), 'invoices.public_id', 'invoices.invoice_number', 'clients.name as client_name', 'contacts.email', 'contacts.first_name', 'contacts.last_name', 'clients.currency_id', 'clients.public_id as client_public_id', 'clients.user_id as client_user_id'])
- ->orderBy('payments.payment_date', 'desc')
- ->take(100)
- ->get();
- }
-
- public function oustanding($start_date, $end_date)
- {
-
- $company_currency = (int) $this->company->settings->currency_id;
-
- $results = \DB::select( \DB::raw("
- SELECT
- sum(invoices.balance) as balance,
- JSON_EXTRACT( settings, '$.currency_id' ) AS currency_id
- FROM clients
- JOIN invoices
- on invoices.client_id = clients.id
- WHERE invoices.status_id IN (2,3)
- AND invoices.company_id = :company_id
- AND invoices.balance > 0
- AND clients.is_deleted = 0
- AND invoices.is_deleted = 0
- AND (invoices.due_date BETWEEN :start_date AND :end_date)
- GROUP BY currency_id
- "), ['company_id' => $this->company->id, 'start_date' => $start_date, 'end_date' => $end_date] );
-
- //return $results;
-
- //the output here will most likely contain a currency_id = null value - we need to merge this value with the company currency
-
- }
-
-
-
-
-
-
-
-
- */
\ No newline at end of file
diff --git a/app/Transformers/CompanyTransformer.php b/app/Transformers/CompanyTransformer.php
index 549365f4a4cb..5de5a837e850 100644
--- a/app/Transformers/CompanyTransformer.php
+++ b/app/Transformers/CompanyTransformer.php
@@ -169,7 +169,6 @@ class CompanyTransformer extends EntityTransformer
'convert_rate_to_client' => (bool) $company->convert_rate_to_client,
'markdown_email_enabled' => (bool) $company->markdown_email_enabled,
'stop_on_unpaid_recurring' => (bool) $company->stop_on_unpaid_recurring,
- 'show_production_description_dropdown' => (bool)$company->show_production_description_dropdown,
'use_quote_terms_on_conversion' => (bool) $company->use_quote_terms_on_conversion,
];
}
diff --git a/app/Utils/HtmlEngine.php b/app/Utils/HtmlEngine.php
index 711677dc3c8a..160198d1d61b 100644
--- a/app/Utils/HtmlEngine.php
+++ b/app/Utils/HtmlEngine.php
@@ -332,6 +332,10 @@ class HtmlEngine
$data['$country'] = ['value' => isset($this->client->country->name) ? ctrans('texts.country_' . $this->client->country->name) : '', 'label' => ctrans('texts.country')];
$data['$country_2'] = ['value' => isset($this->client->country) ? $this->client->country->iso_3166_2 : '', 'label' => ctrans('texts.country')];
$data['$email'] = ['value' => isset($this->contact) ? $this->contact->email : 'no contact email on record', 'label' => ctrans('texts.email')];
+
+ if(str_contains($data['$email']['value'], 'example.com'))
+ $data['$email'] = ['value' => '', 'label' => ctrans('texts.email')];
+
$data['$client_name'] = ['value' => $this->entity->present()->clientName() ?: ' ', 'label' => ctrans('texts.client_name')];
$data['$client.name'] = &$data['$client_name'];
$data['$client'] = &$data['$client_name'];
@@ -382,7 +386,7 @@ class HtmlEngine
$data['$contact.full_name'] = ['value' => $this->contact->present()->name(), 'label' => ctrans('texts.name')];
$data['$contact'] = &$data['$contact.full_name'];
- $data['$contact.email'] = ['value' => $this->contact->email, 'label' => ctrans('texts.email')];
+ $data['$contact.email'] = &$data['$email'];
$data['$contact.phone'] = ['value' => $this->contact->phone, 'label' => ctrans('texts.phone')];
$data['$contact.name'] = ['value' => isset($this->contact) ? $this->contact->present()->name() : $this->client->present()->name(), 'label' => ctrans('texts.contact_name')];
diff --git a/config/ninja.php b/config/ninja.php
index 0e3c0c69f12c..12f9b93bbf76 100644
--- a/config/ninja.php
+++ b/config/ninja.php
@@ -14,8 +14,8 @@ return [
'require_https' => env('REQUIRE_HTTPS', true),
'app_url' => rtrim(env('APP_URL', ''), '/'),
'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
- 'app_version' => '5.3.90',
- 'app_tag' => '5.3.90',
+ 'app_version' => '5.3.91',
+ 'app_tag' => '5.3.91',
'minimum_client_version' => '5.0.16',
'terms_version' => '1.0.1',
'api_secret' => env('API_SECRET', ''),
diff --git a/database/migrations/2022_05_23_050754_drop_redundant_column_show_production_description_dropdown.php b/database/migrations/2022_05_23_050754_drop_redundant_column_show_production_description_dropdown.php
new file mode 100644
index 000000000000..507b64d2b996
--- /dev/null
+++ b/database/migrations/2022_05_23_050754_drop_redundant_column_show_production_description_dropdown.php
@@ -0,0 +1,36 @@
+dropColumn('show_production_description_dropdown');
+ });
+
+ $this->buildCache(true);
+
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ //
+ }
+}
diff --git a/resources/views/portal/ninja2020/components/pdf-viewer.blade.php b/resources/views/portal/ninja2020/components/pdf-viewer.blade.php
index 6812bfcbb0e5..ef1bcef4ec0d 100644
--- a/resources/views/portal/ninja2020/components/pdf-viewer.blade.php
+++ b/resources/views/portal/ninja2020/components/pdf-viewer.blade.php
@@ -3,7 +3,7 @@
@endphp
@push('head')
-
+
@endpush
@@ -86,7 +86,7 @@
@else
-
+
@endif
diff --git a/routes/api.php b/routes/api.php
index fe04fbe3c2bf..158fe34c2fa3 100644
--- a/routes/api.php
+++ b/routes/api.php
@@ -153,7 +153,7 @@ Route::group(['middleware' => ['throttle:100,1', 'api_db', 'token_auth', 'locale
Route::post('recurring_quotes/bulk', 'RecurringQuoteController@bulk')->name('recurring_quotes.bulk');
Route::put('recurring_quotes/{recurring_quote}/upload', 'RecurringQuoteController@upload');
- Route::post('refresh', 'Auth\LoginController@refresh')->middleware('throttle:30,1');
+ Route::post('refresh', 'Auth\LoginController@refresh')->middleware('throttle:50,1');
Route::post('reports/clients', 'Reports\ClientReportController');
Route::post('reports/contacts', 'Reports\ClientContactReportController');
diff --git a/tests/Feature/Export/ClientCsvTest.php b/tests/Feature/Export/ClientCsvTest.php
index 0708848505c1..3002facc8095 100644
--- a/tests/Feature/Export/ClientCsvTest.php
+++ b/tests/Feature/Export/ClientCsvTest.php
@@ -45,6 +45,7 @@ class ClientCsvTest extends TestCase
$data = [
"date_range" => "this_year",
"report_keys" => [],
+ "send_email" => false
];
$response = $this->withHeaders([
@@ -62,6 +63,7 @@ class ClientCsvTest extends TestCase
$data = [
"date_range" => "this_year",
"report_keys" => [],
+ "send_email" => false
];
$response = $this->withHeaders([