Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Blair2004 committed Jan 14, 2022
1 parent 1b40daf commit b064427
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 23 deletions.
12 changes: 12 additions & 0 deletions app/Http/Controllers/Dashboard/CashRegistersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,24 @@ public function performAction( Request $request, $action, Register $register ) {
$request->input( 'amount' ),
$request->input( 'description' )
);
} else if ( $action === RegisterHistory::ACTION_OPENING ) {
return $this->registersService->openRegister(
$register,
$request->input( 'amount' ),
$request->input( 'description' )
);
} else if( $action === 'close' ) {
return $this->registersService->closeRegister(
$register,
$request->input( 'amount' ),
$request->input( 'description' )
);
} else if( $action === RegisterHistory::ACTION_CLOSING ) {
return $this->registersService->closeRegister(
$register,
$request->input( 'amount' ),
$request->input( 'description' )
);
} else if( $action === RegisterHistory::ACTION_CASHING ) {
return $this->registersService->cashIn(
$register,
Expand Down
2 changes: 1 addition & 1 deletion config/nexopos.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
return [
'version' => '4.6.9',
'version' => '4.6.10',
'languages' => [
'en' => 'English',
'fr' => 'Français',
Expand Down
1 change: 1 addition & 0 deletions phpunit.ci.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<directory suffix="MakeProcurementTest.php">./tests/Feature</directory>
<directory suffix="PerformStockAdjustmentTest.php">./tests/Feature</directory>
<directory suffix="CreateRegisterTest.php">./tests/Feature</directory>
<directory suffix="CashRegisterActionsTest.php">./tests/Feature</directory>
<directory suffix="CreateOrderOnRegister.php">./tests/Feature</directory>
<directory suffix="CreateOrderTest.php">./tests/Feature</directory>
<directory suffix="CreateOrderPaidWithCustomerCredit.php">./tests/Feature</directory>
Expand Down
1 change: 1 addition & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<directory suffix="MakeProcurementTest.php">./tests/Feature</directory>
<directory suffix="PerformStockAdjustmentTest.php">./tests/Feature</directory>
<directory suffix="CreateRegisterTest.php">./tests/Feature</directory>
<directory suffix="CashRegisterActionsTest.php">./tests/Feature</directory>
<directory suffix="CreateOrderOnRegister.php">./tests/Feature</directory>
<directory suffix="CreateOrderTest.php">./tests/Feature</directory>
<directory suffix="CreateOrderPaidWithCustomerCredit.php">./tests/Feature</directory>
Expand Down
79 changes: 79 additions & 0 deletions tests/Feature/CashRegisterActionsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php

namespace Tests\Feature;

use App\Models\Register;
use App\Models\RegisterHistory;
use App\Models\Role;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Laravel\Sanctum\Sanctum;
use Tests\TestCase;

class CashRegisterActionsTest extends TestCase
{
/**
* A basic feature test example.
*
* @return void
*/
public function test_example()
{
Sanctum::actingAs(
Role::namespace( 'admin' )->users->first(),
['*']
);

$response = $this->withSession( $this->app[ 'session' ]->all() )
->json( 'POST', 'api/nexopos/v4/crud/ns.registers', [
'name' => __( 'Test Cash Register' ),
'general' => [
'status' => Register::STATUS_CLOSED
]
]);

$response->assertOk();

$register = Register::where( 'name', 'Test Cash Register' )->first();

/**
* Opening cash register
*/
$response = $this->withSession( $this->app[ 'session' ]->all() )
->json( 'POST', 'api/nexopos/v4/cash-registers/open/' . $register->id, [
'amount' => 100
]);

$response->assertStatus(200);

/**
* cashing on the cash register
*/
$response = $this->withSession( $this->app[ 'session' ]->all() )
->json( 'POST', 'api/nexopos/v4/cash-registers/' . RegisterHistory::ACTION_CASHING . '/' . $register->id, [
'amount' => 100
]);

$response->assertStatus(200);

/**
* cashout on the cash register
*/
$response = $this->withSession( $this->app[ 'session' ]->all() )
->json( 'POST', 'api/nexopos/v4/cash-registers/' . RegisterHistory::ACTION_CASHOUT . '/' . $register->id, [
'amount' => 100
]);

$response->assertStatus(200);

/**
* close cash register
*/
$response = $this->withSession( $this->app[ 'session' ]->all() )
->json( 'POST', 'api/nexopos/v4/cash-registers/' . RegisterHistory::ACTION_CLOSING . '/' . $register->id, [
'amount' => 100
]);

$response->assertStatus(200);
}
}
22 changes: 0 additions & 22 deletions tests/Feature/CashRegisterDispursementTest.php

This file was deleted.

0 comments on commit b064427

Please sign in to comment.