Merge pull request #7464 from turbo124/v5-stable

v5.3.91
This commit is contained in:
David Bomba 2022-05-25 18:42:21 +10:00 committed by GitHub
commit b563115d7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 425677 additions and 424395 deletions

View File

@ -1 +1 @@
5.3.90
5.3.91

View File

@ -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);
}
}

View File

@ -124,6 +124,8 @@ class PaymentNotification implements ShouldQueue
*/
private function sendAnalytics($data)
{
nlog($data);
$data = utf8_encode($data);
$curl = curl_init();

View File

@ -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);

View File

@ -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 = [

View File

@ -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;

View File

@ -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
}
*/

View File

@ -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,
];
}

View File

@ -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')];

View File

@ -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', ''),

View File

@ -0,0 +1,36 @@
<?php
use App\Utils\Traits\AppSetup;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class DropRedundantColumnShowProductionDescriptionDropdown extends Migration
{
use AppSetup;
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('companies', function (Blueprint $table) {
$table->dropColumn('show_production_description_dropdown');
});
$this->buildCache(true);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}

View File

@ -3,13 +3,13 @@ const MANIFEST = 'flutter-app-manifest';
const TEMP = 'flutter-temp-cache';
const CACHE_NAME = 'flutter-app-cache';
const RESOURCES = {
"main.dart.js": "364188203aa14bd63e2bc6012e03dca0",
"main.dart.js": "01650cf247d1b2ef31e4bb84a76b28fd",
"canvaskit/canvaskit.wasm": "4b83d89d9fecbea8ca46f2f760c5a9ba",
"canvaskit/profiling/canvaskit.wasm": "95e736ab31147d1b2c7b25f11d4c32cd",
"canvaskit/profiling/canvaskit.js": "ae2949af4efc61d28a4a80fffa1db900",
"canvaskit/canvaskit.js": "c2b4e5f3d7a3d82aed024e7249a78487",
"flutter.js": "0816e65a103ba8ba51b174eeeeb2cb67",
"/": "981a36b4c01bd0159f59c3f0b234ce5c",
"/": "eea3dd0db9e972492cf345e1d6676daf",
"favicon.png": "dca91c54388f52eded692718d5a98b8b",
"version.json": "3afb81924daf4f751571755436069115",
"assets/AssetManifest.json": "38d9aea341601f3a5c6fa7b5a1216ea5",

188428
public/main.dart.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

230386
public/main.foss.dart.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

184768
public/main.html.dart.js vendored

File diff suppressed because one or more lines are too long

233712
public/main.next.dart.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -3,7 +3,7 @@
@endphp
@push('head')
<meta name="pdf-url" content="{{ $url ?? $entity->pdf_file_path(null, 'url', true) }}">
<meta name="pdf-url" content="{{ $url ?? $entity->pdf_file_path(null, 'url', true) }}?cache_buster={{time()}}">
<script src="{{ asset('js/vendor/pdf.js/pdf.min.js') }}"></script>
@endpush
@ -86,7 +86,7 @@
<canvas id="pdf-placeholder" class="shadow rounded-lg bg-white"></canvas>
</div>
@else
<iframe id="pdf-iframe" src="{{ $url ?? $entity->pdf_file_path(null, 'url', true) }}" class="h-screen w-full border-0 mt-4"></iframe>
<iframe id="pdf-iframe" src="{{ $url ?? $entity->pdf_file_path(null, 'url', true) }}?cache_buster={{time()}}" class="h-screen w-full border-0 mt-4"></iframe>
@endif

View File

@ -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');

View File

@ -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([