Merge pull request #5255 from turbo124/v5-develop

v5.1.32
This commit is contained in:
David Bomba 2021-03-26 19:21:59 +11:00 committed by GitHub
commit 4f78b39edc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 46 additions and 18 deletions

View File

@ -1 +1 @@
5.1.31 5.1.32

View File

@ -572,7 +572,6 @@ class QuoteController extends BaseController
* description="Performs a custom action on an Quote. * description="Performs a custom action on an Quote.
The current range of actions are as follows The current range of actions are as follows
- clone_to_Quote
- clone_to_quote - clone_to_quote
- history - history
- delivery_note - delivery_note
@ -580,6 +579,8 @@ class QuoteController extends BaseController
- download - download
- archive - archive
- delete - delete
- convert
- convert_to_invoice
- email", - email",
* @OA\Parameter(ref="#/components/parameters/X-Api-Secret"), * @OA\Parameter(ref="#/components/parameters/X-Api-Secret"),
* @OA\Parameter(ref="#/components/parameters/X-Api-Token"), * @OA\Parameter(ref="#/components/parameters/X-Api-Token"),
@ -640,6 +641,14 @@ class QuoteController extends BaseController
private function performAction(Quote $quote, $action, $bulk = false) private function performAction(Quote $quote, $action, $bulk = false)
{ {
switch ($action) { switch ($action) {
case 'convert':
case 'convert_to_invoice':
$this->entity_type = Invoice::class;
$this->entity_transformer = InvoiceTransformer::class;
return $this->itemResponse($quote->service()->convertToInvoice());
break;
case 'clone_to_invoice': case 'clone_to_invoice':
$this->entity_type = Invoice::class; $this->entity_type = Invoice::class;

View File

@ -608,14 +608,19 @@ class UserController extends BaseController
*/ */
public function detach(DetachCompanyUserRequest $request, User $user) public function detach(DetachCompanyUserRequest $request, User $user)
{ {
if($user->isOwner())
return response()->json(['message', 'Cannot detach owner.'],400); if ($request->entityIsDeleted($user)) {
return $request->disallowUpdate();
}
$company_user = CompanyUser::whereUserId($user->id) $company_user = CompanyUser::whereUserId($user->id)
->whereCompanyId(auth()->user()->companyId()) ->whereCompanyId(auth()->user()->companyId())
->withTrashed() ->withTrashed()
->first(); ->first();
if($company_user->is_owner)
return response()->json(['message', 'Cannot detach owner.'], 401);
$token = $company_user->token->where('company_id', $company_user->company_id)->where('user_id', $company_user->user_id)->first(); $token = $company_user->token->where('company_id', $company_user->company_id)->where('user_id', $company_user->user_id)->first();
if ($token) { if ($token) {

View File

@ -13,11 +13,13 @@ namespace App\Http\Requests\User;
use App\Http\Requests\Request; use App\Http\Requests\Request;
use App\Models\User; use App\Models\User;
use App\Utils\Traits\ChecksEntityStatus;
use App\Utils\Traits\MakesHash; use App\Utils\Traits\MakesHash;
class DetachCompanyUserRequest extends Request class DetachCompanyUserRequest extends Request
{ {
use MakesHash; use MakesHash;
use ChecksEntityStatus;
/** /**
* Determine if the user is authorized to make this request. * Determine if the user is authorized to make this request.

View File

@ -22,10 +22,9 @@ class Subscription extends BaseModel
protected $fillable = [ protected $fillable = [
'user_id', 'user_id',
'product_id', 'product_ids',
'recurring_product_ids',
'company_id', 'company_id',
'product_id',
'is_recurring',
'frequency_id', 'frequency_id',
'auto_bill', 'auto_bill',
'promo_code', 'promo_code',
@ -43,6 +42,7 @@ class Subscription extends BaseModel
'refund_period', 'refund_period',
'webhook_configuration', 'webhook_configuration',
'currency_id', 'currency_id',
'group_id',
]; ];
protected $casts = [ protected $casts = [

View File

@ -148,9 +148,9 @@ class UserRepository extends BaseRepository
event(new UserWasDeleted($user, auth()->user(), $company, Ninja::eventVars())); event(new UserWasDeleted($user, auth()->user(), $company, Ninja::eventVars()));
// $user->is_deleted = true; $user->is_deleted = true;
// $user->save(); $user->save();
// $user->delete(); $user->delete();
return $user->fresh(); return $user->fresh();
@ -177,7 +177,17 @@ class UserRepository extends BaseRepository
return; return;
} }
$user->is_deleted = false;
$user->save();
$user->restore(); $user->restore();
// $user->company_user->restore();
$cu = CompanyUser::withTrashed()
->where('user_id', $user->id)
->where('company_id', auth()->user()->company()->id)
->first();
$cu->restore();
event(new UserWasRestored($user, auth()->user(), auth()->user()->company, Ninja::eventVars())); event(new UserWasRestored($user, auth()->user(), auth()->user()->company, Ninja::eventVars()));

View File

@ -186,7 +186,7 @@ class PaymentMethod
foreach ($child_array as $gateway_id => $gateway_type_id) { foreach ($child_array as $gateway_id => $gateway_type_id) {
$gateway = CompanyGateway::find($gateway_id); $gateway = CompanyGateway::find($gateway_id);
$fee_label = $gateway->calcGatewayFeeLabel($this->amount, $this->client); $fee_label = $gateway->calcGatewayFeeLabel($this->amount, $this->client, $gateway_type_id);
if(!$gateway_type_id){ if(!$gateway_type_id){

View File

@ -106,7 +106,7 @@
}, },
"scripts": { "scripts": {
"post-install-cmd": [ "post-install-cmd": [
"vendor/bin/snappdf download" "if [ '${IS_DOCKER:-false}' != 'true' ]; then vendor/bin/snappdf download; fi"
], ],
"post-update-cmd": [ "post-update-cmd": [
"vendor/bin/snappdf download" "vendor/bin/snappdf download"

View File

@ -13,7 +13,7 @@ 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', ''), 'app_domain' => env('APP_DOMAIN', ''),
'app_version' => '5.1.31', 'app_version' => '5.1.32',
'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', false), 'api_secret' => env('API_SECRET', false),

View File

@ -21,10 +21,12 @@ class RefactorBillingScriptionsTable extends Migration
$table->text('recurring_product_ids'); $table->text('recurring_product_ids');
$table->string('name'); $table->string('name');
$table->unique(['company_id', 'name']); $table->unique(['company_id', 'name']);
$table->unsignedInteger('group_id');
}); });
Schema::table('subscriptions', function (Blueprint $table) { Schema::table('subscriptions', function (Blueprint $table) {
$table->renameColumn('product_id', 'product_ids'); $table->renameColumn('product_id', 'product_ids');
$table->dropColumn('is_recurring');
}); });
} }

View File

@ -53,7 +53,7 @@ class SubscriptionApiTest extends TestCase
]); ]);
$billing_subscription = Subscription::factory()->create([ $billing_subscription = Subscription::factory()->create([
'product_id' => $product->id, 'product_ids' => $product->id,
'company_id' => $this->company->id, 'company_id' => $this->company->id,
]); ]);
@ -78,7 +78,7 @@ class SubscriptionApiTest extends TestCase
$response = $this->withHeaders([ $response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'), 'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token, 'X-API-TOKEN' => $this->token,
])->post('/api/v1/subscriptions', ['product_id' => $product->id, 'allow_cancellation' => true]); ])->post('/api/v1/subscriptions', ['product_ids' => $product->id, 'allow_cancellation' => true]);
$response->assertStatus(200); $response->assertStatus(200);
} }
@ -92,7 +92,7 @@ class SubscriptionApiTest extends TestCase
$response1 = $this $response1 = $this
->withHeaders(['X-API-SECRET' => config('ninja.api_secret'),'X-API-TOKEN' => $this->token]) ->withHeaders(['X-API-SECRET' => config('ninja.api_secret'),'X-API-TOKEN' => $this->token])
->post('/api/v1/subscriptions', ['product_id' => $product->id]) ->post('/api/v1/subscriptions', ['product_ids' => $product->id])
->assertStatus(200) ->assertStatus(200)
->json(); ->json();
@ -123,7 +123,7 @@ class SubscriptionApiTest extends TestCase
]); ]);
$billing_subscription = Subscription::factory()->create([ $billing_subscription = Subscription::factory()->create([
'product_id' => $product->id, 'product_ids' => $product->id,
'company_id' => $this->company->id, 'company_id' => $this->company->id,
]); ]);