mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-03 22:07:33 -05:00 
			
		
		
		
	
						commit
						4183c1a2ae
					
				@ -1 +1 @@
 | 
				
			|||||||
5.1.62
 | 
					5.1.63
 | 
				
			||||||
@ -107,6 +107,12 @@ class LicenseController extends BaseController
 | 
				
			|||||||
                        'errors' => new stdClass,
 | 
					                        '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);
 | 
					                    return response()->json($error, 400);
 | 
				
			||||||
                } else {
 | 
					                } else {
 | 
				
			||||||
                    $account = auth()->user()->company()->account;
 | 
					                    $account = auth()->user()->company()->account;
 | 
				
			||||||
 | 
				
			|||||||
@ -21,13 +21,18 @@ class PaymentWebhookController extends Controller
 | 
				
			|||||||
    public function __invoke(PaymentWebhookRequest $request, string $company_key, string $company_gateway_id)
 | 
					    public function __invoke(PaymentWebhookRequest $request, string $company_key, string $company_gateway_id)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    	MultiDB::findAndSetDbByCompanyKey($company_key);
 | 
					    	// MultiDB::findAndSetDbByCompanyKey($company_key);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $payment = $request->getPayment();
 | 
					        $payment = $request->getPayment();
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if(!$payment)
 | 
				
			||||||
 | 
					        	return response()->json(['message' => 'Payment record not found.'], 400);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $client = is_null($payment) ? $request->getClient() : $payment->client;
 | 
					        $client = is_null($payment) ? $request->getClient() : $payment->client;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // $contact= $client->primary_contact()->first();
 | 
					        if(!$client)
 | 
				
			||||||
        // Auth::guard('contact')->login($contact, true);
 | 
						        return response()->json(['message' => 'Client record not found.'], 400);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $request->getCompanyGateway()
 | 
					        return $request->getCompanyGateway()
 | 
				
			||||||
            ->driver($client)
 | 
					            ->driver($client)
 | 
				
			||||||
 | 
				
			|||||||
@ -11,6 +11,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
namespace App\Http\Middleware;
 | 
					namespace App\Http\Middleware;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use App\Utils\Ninja;
 | 
				
			||||||
use Closure;
 | 
					use Closure;
 | 
				
			||||||
use Illuminate\Http\Request;
 | 
					use Illuminate\Http\Request;
 | 
				
			||||||
use stdClass;
 | 
					use stdClass;
 | 
				
			||||||
@ -26,7 +27,7 @@ class ApiSecretCheck
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public function handle($request, Closure $next)
 | 
					    public function handle($request, Closure $next)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (! config('ninja.api_secret')) {
 | 
					        if (! config('ninja.api_secret') || Ninja::isHosted()) {
 | 
				
			||||||
            return $next($request);
 | 
					            return $next($request);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -27,7 +27,7 @@ class PaymentWebhookRequest extends Request
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function authorize()
 | 
					    public function authorize()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        MultiDB::findAndSetDbByCompanyKey($this->getCompany()->company_key);
 | 
					        MultiDB::findAndSetDbByCompanyKey($this->company_key);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -45,7 +45,7 @@ class PaymentWebhookRequest extends Request
 | 
				
			|||||||
     * @param mixed $id
 | 
					     * @param mixed $id
 | 
				
			||||||
     * @return null|\App\Models\CompanyGateway
 | 
					     * @return null|\App\Models\CompanyGateway
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public function getCompanyGateway(): ?CompanyGateway
 | 
					    public function getCompanyGateway()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        return CompanyGateway::findOrFail($this->decodePrimaryKey($this->company_gateway_id));
 | 
					        return CompanyGateway::findOrFail($this->decodePrimaryKey($this->company_gateway_id));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -56,13 +56,13 @@ class PaymentWebhookRequest extends Request
 | 
				
			|||||||
     * @param string $hash
 | 
					     * @param string $hash
 | 
				
			||||||
     * @return null|\App\Models\PaymentHash
 | 
					     * @return null|\App\Models\PaymentHash
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public function getPaymentHash(): ?PaymentHash
 | 
					    public function getPaymentHash()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if ($this->query('hash')) {
 | 
					        if ($this->query('hash')) {
 | 
				
			||||||
            return PaymentHash::where('hash', $this->query('hash'))->firstOrFail();
 | 
					            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
 | 
					        // If none of previously done logics is correct, we'll just display
 | 
				
			||||||
        // not found page.
 | 
					        // not found page.
 | 
				
			||||||
        abort(404);
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@ -102,11 +102,14 @@ class PaymentWebhookRequest extends Request
 | 
				
			|||||||
     *
 | 
					     *
 | 
				
			||||||
     * @return null|\App\Models\Client
 | 
					     * @return null|\App\Models\Client
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public function getClient(): ?Client
 | 
					    public function getClient()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $hash = $this->getPaymentHash();
 | 
					        $hash = $this->getPaymentHash();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return Client::find($hash->data->client_id)->firstOrFail();
 | 
					        if($hash)
 | 
				
			||||||
 | 
					            return Client::find($hash->data->client_id)->firstOrFail();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
 | 
				
			|||||||
@ -15,6 +15,7 @@ use App\Http\Requests\Request;
 | 
				
			|||||||
use App\Http\ValidationRules\ValidVendorGroupSettingsRule;
 | 
					use App\Http\ValidationRules\ValidVendorGroupSettingsRule;
 | 
				
			||||||
use App\Models\Vendor;
 | 
					use App\Models\Vendor;
 | 
				
			||||||
use App\Utils\Traits\MakesHash;
 | 
					use App\Utils\Traits\MakesHash;
 | 
				
			||||||
 | 
					use Illuminate\Validation\Rule;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class StoreVendorRequest extends Request
 | 
					class StoreVendorRequest extends Request
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -39,6 +40,9 @@ class StoreVendorRequest extends Request
 | 
				
			|||||||
        //$rules['settings'] = new ValidVendorGroupSettingsRule();
 | 
					        //$rules['settings'] = new ValidVendorGroupSettingsRule();
 | 
				
			||||||
        $rules['contacts.*.email'] = 'nullable|distinct';
 | 
					        $rules['contacts.*.email'] = 'nullable|distinct';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (isset($this->number)) {
 | 
				
			||||||
 | 
					            $rules['number'] = Rule::unique('vendors')->where('company_id', auth()->user()->company()->id);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $rules;
 | 
					        return $rules;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -116,10 +116,12 @@ class NinjaMailerJob implements ShouldQueue
 | 
				
			|||||||
        } catch (\Exception $e) {
 | 
					        } catch (\Exception $e) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            nlog("error failed with {$e->getMessage()}");
 | 
					            nlog("error failed with {$e->getMessage()}");
 | 
				
			||||||
            // nlog($e);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if($this->nmo->entity)
 | 
					            if($this->nmo->entity)
 | 
				
			||||||
                $this->entityEmailFailed($e->getMessage());
 | 
					                $this->entityEmailFailed($e->getMessage());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if(Ninja::isHosted())
 | 
				
			||||||
 | 
					                app('sentry')->captureException($e);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -1618,6 +1618,9 @@ class Import implements ShouldQueue
 | 
				
			|||||||
                 ->batch();
 | 
					                 ->batch();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        info(print_r($exception->getMessage(), 1));
 | 
					        info(print_r($exception->getMessage(), 1));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(Ninja::isHosted())
 | 
				
			||||||
 | 
					            app('sentry')->captureException($exception);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1642,7 +1645,7 @@ class Import implements ShouldQueue
 | 
				
			|||||||
        return $response->getBody();
 | 
					        return $response->getBody();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function buildNewUserPlan() :Client
 | 
					    private function buildNewUserPlan() 
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $local_company = Company::find($this->company->id);
 | 
					        $local_company = Company::find($this->company->id);
 | 
				
			||||||
        $owner = $local_company->owner();
 | 
					        $owner = $local_company->owner();
 | 
				
			||||||
@ -1674,6 +1677,8 @@ class Import implements ShouldQueue
 | 
				
			|||||||
        $ninja_client_contact->phone = $owner->phone;
 | 
					        $ninja_client_contact->phone = $owner->phone;
 | 
				
			||||||
        $ninja_client_contact->save();
 | 
					        $ninja_client_contact->save();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return $ninja_client;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function processNinjaTokens(array $data)
 | 
					    private function processNinjaTokens(array $data)
 | 
				
			||||||
 | 
				
			|||||||
@ -139,7 +139,7 @@ class StartMigration implements ShouldQueue
 | 
				
			|||||||
            $this->company->update_products = $update_product_flag;
 | 
					            $this->company->update_products = $update_product_flag;
 | 
				
			||||||
            $this->company->save();
 | 
					            $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') {
 | 
					            if (app()->environment() !== 'production') {
 | 
				
			||||||
                info($e->getMessage());
 | 
					                info($e->getMessage());
 | 
				
			||||||
 | 
				
			|||||||
@ -13,9 +13,13 @@ namespace App\Services\Invoice;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
use App\Models\Invoice;
 | 
					use App\Models\Invoice;
 | 
				
			||||||
use App\Services\AbstractService;
 | 
					use App\Services\AbstractService;
 | 
				
			||||||
 | 
					use App\Utils\Ninja;
 | 
				
			||||||
 | 
					use App\Utils\Traits\GeneratesCounter;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class HandleRestore extends AbstractService
 | 
					class HandleRestore extends AbstractService
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    use GeneratesCounter;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private $invoice;
 | 
					    private $invoice;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private $payment_total = 0;
 | 
					    private $payment_total = 0;
 | 
				
			||||||
@ -100,10 +104,22 @@ class HandleRestore extends AbstractService
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        try {
 | 
					        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->number = $new_invoice_number;
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
            $this->invoice->save();
 | 
					            $this->invoice->save();
 | 
				
			||||||
        } catch (\Exception $e) {
 | 
					        } 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);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -14,8 +14,8 @@ return [
 | 
				
			|||||||
    'require_https' => env('REQUIRE_HTTPS', true),
 | 
					    'require_https' => env('REQUIRE_HTTPS', true),
 | 
				
			||||||
    'app_url' => rtrim(env('APP_URL', ''), '/'),
 | 
					    'app_url' => rtrim(env('APP_URL', ''), '/'),
 | 
				
			||||||
    'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
 | 
					    'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
 | 
				
			||||||
    'app_version' => '5.1.62',
 | 
					    'app_version' => '5.1.63',
 | 
				
			||||||
    'app_tag' => '5.1.62-release',
 | 
					    'app_tag' => '5.1.63-release',
 | 
				
			||||||
    'minimum_client_version' => '5.0.16',
 | 
					    'minimum_client_version' => '5.0.16',
 | 
				
			||||||
    'terms_version' => '1.0.1',
 | 
					    'terms_version' => '1.0.1',
 | 
				
			||||||
    'api_secret' => env('API_SECRET', ''),
 | 
					    'api_secret' => env('API_SECRET', ''),
 | 
				
			||||||
 | 
				
			|||||||
@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
 | 
				
			|||||||
use Illuminate\Database\Schema\Blueprint;
 | 
					use Illuminate\Database\Schema\Blueprint;
 | 
				
			||||||
use Illuminate\Support\Facades\Schema;
 | 
					use Illuminate\Support\Facades\Schema;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class AddShowTaskEndDateToCompaniesTable extends Migration
 | 
					class AddShowTaskEndDateToCompaniesTables extends Migration
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Run the migrations.
 | 
					     * Run the migrations.
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user