From b064427661febb32a0f4ad015a706790fe96131e Mon Sep 17 00:00:00 2001 From: blair2004 Date: Fri, 14 Jan 2022 14:53:19 +0000 Subject: [PATCH] Update --- .../Dashboard/CashRegistersController.php | 12 +++ config/nexopos.php | 2 +- phpunit.ci.xml | 1 + phpunit.xml | 1 + tests/Feature/CashRegisterActionsTest.php | 79 +++++++++++++++++++ .../Feature/CashRegisterDispursementTest.php | 22 ------ 6 files changed, 94 insertions(+), 23 deletions(-) create mode 100644 tests/Feature/CashRegisterActionsTest.php delete mode 100644 tests/Feature/CashRegisterDispursementTest.php diff --git a/app/Http/Controllers/Dashboard/CashRegistersController.php b/app/Http/Controllers/Dashboard/CashRegistersController.php index ce3d4d67b..3936215a8 100755 --- a/app/Http/Controllers/Dashboard/CashRegistersController.php +++ b/app/Http/Controllers/Dashboard/CashRegistersController.php @@ -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, diff --git a/config/nexopos.php b/config/nexopos.php index 47b5a4878..3bc1db4cf 100755 --- a/config/nexopos.php +++ b/config/nexopos.php @@ -1,6 +1,6 @@ '4.6.9', + 'version' => '4.6.10', 'languages' => [ 'en' => 'English', 'fr' => 'Français', diff --git a/phpunit.ci.xml b/phpunit.ci.xml index 5cdceb139..c3a18ccd3 100755 --- a/phpunit.ci.xml +++ b/phpunit.ci.xml @@ -26,6 +26,7 @@ ./tests/Feature ./tests/Feature ./tests/Feature + ./tests/Feature ./tests/Feature ./tests/Feature ./tests/Feature diff --git a/phpunit.xml b/phpunit.xml index 13bbe7968..796e53376 100755 --- a/phpunit.xml +++ b/phpunit.xml @@ -26,6 +26,7 @@ ./tests/Feature ./tests/Feature ./tests/Feature + ./tests/Feature ./tests/Feature ./tests/Feature ./tests/Feature diff --git a/tests/Feature/CashRegisterActionsTest.php b/tests/Feature/CashRegisterActionsTest.php new file mode 100644 index 000000000..2802854a9 --- /dev/null +++ b/tests/Feature/CashRegisterActionsTest.php @@ -0,0 +1,79 @@ +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); + } +} diff --git a/tests/Feature/CashRegisterDispursementTest.php b/tests/Feature/CashRegisterDispursementTest.php deleted file mode 100644 index ec5921ba3..000000000 --- a/tests/Feature/CashRegisterDispursementTest.php +++ /dev/null @@ -1,22 +0,0 @@ -get('/'); - - $response->assertStatus(200); - } -}