1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-13 22:54:25 +01:00

Merge pull request #5769 from turbo124/v5-develop

v5.1.63
This commit is contained in:
David Bomba 2021-05-21 18:01:14 +10:00 committed by GitHub
commit 4183c1a2ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 61 additions and 19 deletions

View File

@ -1 +1 @@
5.1.62
5.1.63

View File

@ -107,6 +107,12 @@ class LicenseController extends BaseController
'errors' => new stdClass,
];
$account->plan_term = Account::PLAN_TERM_YEARLY;
$account->plan_paid = null;
$account->plan_expires = null;
$account->plan = Account::PLAN_FREE;
$account->save();
return response()->json($error, 400);
} else {
$account = auth()->user()->company()->account;

View File

@ -21,13 +21,18 @@ class PaymentWebhookController extends Controller
public function __invoke(PaymentWebhookRequest $request, string $company_key, string $company_gateway_id)
{
MultiDB::findAndSetDbByCompanyKey($company_key);
// MultiDB::findAndSetDbByCompanyKey($company_key);
$payment = $request->getPayment();
if(!$payment)
return response()->json(['message' => 'Payment record not found.'], 400);
$client = is_null($payment) ? $request->getClient() : $payment->client;
// $contact= $client->primary_contact()->first();
// Auth::guard('contact')->login($contact, true);
if(!$client)
return response()->json(['message' => 'Client record not found.'], 400);
return $request->getCompanyGateway()
->driver($client)

View File

@ -11,6 +11,7 @@
namespace App\Http\Middleware;
use App\Utils\Ninja;
use Closure;
use Illuminate\Http\Request;
use stdClass;
@ -26,7 +27,7 @@ class ApiSecretCheck
*/
public function handle($request, Closure $next)
{
if (! config('ninja.api_secret')) {
if (! config('ninja.api_secret') || Ninja::isHosted()) {
return $next($request);
}

View File

@ -27,7 +27,7 @@ class PaymentWebhookRequest extends Request
public function authorize()
{
MultiDB::findAndSetDbByCompanyKey($this->getCompany()->company_key);
MultiDB::findAndSetDbByCompanyKey($this->company_key);
return true;
}
@ -45,7 +45,7 @@ class PaymentWebhookRequest extends Request
* @param mixed $id
* @return null|\App\Models\CompanyGateway
*/
public function getCompanyGateway(): ?CompanyGateway
public function getCompanyGateway()
{
return CompanyGateway::findOrFail($this->decodePrimaryKey($this->company_gateway_id));
}
@ -56,13 +56,13 @@ class PaymentWebhookRequest extends Request
* @param string $hash
* @return null|\App\Models\PaymentHash
*/
public function getPaymentHash(): ?PaymentHash
public function getPaymentHash()
{
if ($this->query('hash')) {
return PaymentHash::where('hash', $this->query('hash'))->firstOrFail();
}
return null;
return false;
}
/**
@ -94,7 +94,7 @@ class PaymentWebhookRequest extends Request
// If none of previously done logics is correct, we'll just display
// not found page.
abort(404);
return false;
}
/**
@ -102,11 +102,14 @@ class PaymentWebhookRequest extends Request
*
* @return null|\App\Models\Client
*/
public function getClient(): ?Client
public function getClient()
{
$hash = $this->getPaymentHash();
return Client::find($hash->data->client_id)->firstOrFail();
if($hash)
return Client::find($hash->data->client_id)->firstOrFail();
return false;
}
/**

View File

@ -15,6 +15,7 @@ use App\Http\Requests\Request;
use App\Http\ValidationRules\ValidVendorGroupSettingsRule;
use App\Models\Vendor;
use App\Utils\Traits\MakesHash;
use Illuminate\Validation\Rule;
class StoreVendorRequest extends Request
{
@ -39,6 +40,9 @@ class StoreVendorRequest extends Request
//$rules['settings'] = new ValidVendorGroupSettingsRule();
$rules['contacts.*.email'] = 'nullable|distinct';
if (isset($this->number)) {
$rules['number'] = Rule::unique('vendors')->where('company_id', auth()->user()->company()->id);
}
return $rules;
}

View File

@ -116,10 +116,12 @@ class NinjaMailerJob implements ShouldQueue
} catch (\Exception $e) {
nlog("error failed with {$e->getMessage()}");
// nlog($e);
if($this->nmo->entity)
$this->entityEmailFailed($e->getMessage());
if(Ninja::isHosted())
app('sentry')->captureException($e);
}
}

View File

@ -1618,6 +1618,9 @@ class Import implements ShouldQueue
->batch();
info(print_r($exception->getMessage(), 1));
if(Ninja::isHosted())
app('sentry')->captureException($exception);
}
@ -1642,7 +1645,7 @@ class Import implements ShouldQueue
return $response->getBody();
}
private function buildNewUserPlan() :Client
private function buildNewUserPlan()
{
$local_company = Company::find($this->company->id);
$owner = $local_company->owner();
@ -1674,6 +1677,8 @@ class Import implements ShouldQueue
$ninja_client_contact->phone = $owner->phone;
$ninja_client_contact->save();
return $ninja_client;
}
private function processNinjaTokens(array $data)

View File

@ -139,7 +139,7 @@ class StartMigration implements ShouldQueue
$this->company->update_products = $update_product_flag;
$this->company->save();
Mail::to($this->user)->send(new MigrationFailed($e, $e->getMessage()));
Mail::to($this->user->email, $this->user->name())->send(new MigrationFailed($e, $e->getMessage()));
if (app()->environment() !== 'production') {
info($e->getMessage());

View File

@ -13,9 +13,13 @@ namespace App\Services\Invoice;
use App\Models\Invoice;
use App\Services\AbstractService;
use App\Utils\Ninja;
use App\Utils\Traits\GeneratesCounter;
class HandleRestore extends AbstractService
{
use GeneratesCounter;
private $invoice;
private $payment_total = 0;
@ -100,10 +104,22 @@ class HandleRestore extends AbstractService
}
try {
$exists = Invoice::where(['company_id' => $this->invoice->company_id, 'number' => $new_invoice_number])->exists();
if($exists)
$this->invoice->number = $this->getNextInvoiceNumber($this->invoice->client, $this->invoice, $this->invoice->recurring_id);
else
$this->invoice->number = $new_invoice_number;
$this->invoice->save();
} catch (\Exception $e) {
info("I could not wind back the invoice number");
nlog("I could not wind back the invoice number");
if(Ninja::isHosted()){
\Sentry\captureMessage("I could not wind back the invoice number");
app('sentry')->captureException($e);
}
}
}
}

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.1.62',
'app_tag' => '5.1.62-release',
'app_version' => '5.1.63',
'app_tag' => '5.1.63-release',
'minimum_client_version' => '5.0.16',
'terms_version' => '1.0.1',
'api_secret' => env('API_SECRET', ''),

View File

@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddShowTaskEndDateToCompaniesTable extends Migration
class AddShowTaskEndDateToCompaniesTables extends Migration
{
/**
* Run the migrations.