Skip to content

Commit

Permalink
fix pannello quantità prodotti in ordine con multi-gas
Browse files Browse the repository at this point in the history
  • Loading branch information
madbob committed Dec 19, 2023
1 parent 1bc8569 commit c78f43f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 25 deletions.
5 changes: 0 additions & 5 deletions code/app/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,6 @@ public function suppliers(): BelongsToMany
return $this->belongsToMany('App\Supplier');
}

public function allnotifications(): BelongsToMany
{
return $this->belongsToMany('App\Notification')->orderBy('start_date', 'desc');
}

public function shippingplace(): BelongsTo
{
return $this->belongsTo('App\Delivery', 'preferred_delivery_id');
Expand Down
6 changes: 3 additions & 3 deletions code/resources/views/order/fixes.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,17 @@
<td>
<label>{{ _i('Multi-GAS: %s', [$other_gas->name]) }}</label>
</td>
<td>
<td class="text-end">
<label>
<?php
App::make('GlobalScopeHub')->setGas($other_gas->id);
$summary = $order->reduxData();
$other_gas_quantity = $summary->products[$product->id]->quantity;
$other_gas_quantity = $summary->products[$product->id]->quantity ?? 0;
?>

{{ $other_gas_quantity }}
{{ sprintf('%s %s', $other_gas_quantity, $measure) }}
</label>
</td>
</tr>
Expand Down
42 changes: 25 additions & 17 deletions code/tests/Services/UsersServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;

use Tests\TestCase;
use App\Exceptions\IllegalArgumentException;
use App\Exceptions\AuthException;
use App\User;
use App\Supplier;

class UsersServiceTest extends TestCase
{
Expand All @@ -25,18 +28,18 @@ public function setUp(): void
$this->actingAs($this->userAdmin);
$role = \App\Role::factory()->create(['actions' => 'users.self,users.subusers']);
app()->make('RolesService')->setMasterRole($this->gas, 'user', $role->id);
$this->userWithBasePerm = \App\User::factory()->create(['gas_id' => $this->gas->id]);
$this->userWithBasePerm = User::factory()->create(['gas_id' => $this->gas->id]);
$this->userWithBasePerm->addRole($role->id, $this->gas);

$this->userWithNoPerms = \App\User::factory()->create(['gas_id' => $this->gas->id]);
$this->userWithNoPerms = User::factory()->create(['gas_id' => $this->gas->id]);

$this->supplier = \App\Supplier::factory()->create();
$this->supplier = Supplier::factory()->create();
$this->userWithShippingPerms = $this->createRoleAndUser($this->gas, 'supplier.shippings', $this->supplier);

\App\User::factory()->count(3)->create(['gas_id' => $this->gas->id]);
User::factory()->count(3)->create(['gas_id' => $this->gas->id]);

$otherGas = \App\Gas::factory()->create();
\App\User::factory()->count(3)->create(['gas_id' => $otherGas->id]);
User::factory()->count(3)->create(['gas_id' => $otherGas->id]);
}

/*
Expand Down Expand Up @@ -86,7 +89,7 @@ public function testCease()
]);

$this->actingAs($this->userWithViewPerm);
$users = app()->make('UsersService')->list();
$users = app()->make('UsersService')->list('', true);
$this->assertEquals($initial_count - 1, $users->count());
}

Expand All @@ -97,17 +100,17 @@ public function testListWithSearchParam()
{
$this->actingAs($this->userWithViewPerm);

$user1 = \App\User::factory()->create([
$user1 = User::factory()->create([
'gas_id' => $this->gas->id,
'firstname' => 'pippo'
]);

$user2 = \App\User::factory()->create([
$user2 = User::factory()->create([
'gas_id' => $this->gas->id,
'lastname' => 'super pippo'
]);

\App\User::factory()->create([
User::factory()->create([
'gas_id' => $this->gas->id,
'firstname' => 'luigi'
]);
Expand Down Expand Up @@ -168,7 +171,7 @@ public function testStore()
]);

$this->assertEquals('test user', $newUser->username);
$this->assertTrue(\Hash::check('password', $newUser->password));
$this->assertTrue(Hash::check('password', $newUser->password));
$this->assertEquals('rossi mario', $newUser->printableName());
$this->assertEquals(0, $newUser->pending_balance);
}
Expand Down Expand Up @@ -199,6 +202,8 @@ public function testStoreAndMail()
*/
public function testStoreFriend()
{
$initial_count = $users->count();

$this->actingAs($this->userWithViewPerm);

$newUser = app()->make('UsersService')->storeFriend([
Expand All @@ -211,13 +216,16 @@ public function testStoreFriend()
$this->nextRound();

$parent = app()->make('UsersService')->show($this->userWithViewPerm->id);
$newUser = app()->make('UsersService')->show($newUser->id);

$this->assertEquals('test friend user', $newUser->username);
$this->assertEquals(1, $parent->friends->count());
$this->assertEquals($parent->id, $newUser->parent_id);
$this->assertTrue(\Hash::check('password', $newUser->password));
$this->assertTrue(Hash::check('password', $newUser->password));
$this->assertEquals('rossi mario', $newUser->printableName());
$this->assertEquals(0, $newUser->pending_balance);

$this->assertEquals($initial_count, User::query()->creditable()->count());
}

/*
Expand Down Expand Up @@ -300,7 +308,7 @@ public function testUpdate()
{
$this->actingAs($this->userWithAdminPerm);

$user = \App\User::factory()->create([
$user = User::factory()->create([
'gas_id' => $this->gas->id
]);

Expand All @@ -321,9 +329,9 @@ public function testInvalidUsername()
$this->expectException(IllegalArgumentException::class);

$this->actingAs($this->userWithAdminPerm);
$sample = \App\User::inRandomOrder()->first();
$sample = User::inRandomOrder()->first();

$user = \App\User::factory()->create([
$user = User::factory()->create([
'gas_id' => $this->gas->id
]);

Expand All @@ -340,9 +348,9 @@ public function testInvalidCardNumber()
$this->expectException(IllegalArgumentException::class);

$this->actingAs($this->userWithAdminPerm);
$sample = \App\User::where('gas_id', $this->gas->id)->where('card_number', '!=', '')->whereNotNull('card_number')->inRandomOrder()->first();
$sample = User::where('gas_id', $this->gas->id)->where('card_number', '!=', '')->whereNotNull('card_number')->inRandomOrder()->first();

$user = \App\User::factory()->create([
$user = User::factory()->create([
'gas_id' => $this->gas->id
]);

Expand Down Expand Up @@ -494,7 +502,7 @@ public function testAnnualFee()

$movement = new \App\Movement();
$movement->type = 'annual-fee';
$movement->sender_type = 'App\User';
$movement->sender_type = User::class;
$movement->sender_id = $this->userWithNoPerms->id;
$movement->target_type = 'App\Gas';
$movement->target_id = $this->gas->id;
Expand Down

0 comments on commit c78f43f

Please sign in to comment.