Skip to content
Snippets Groups Projects
Commit a3eb3ce7 authored by Patrick Barroca's avatar Patrick Barroca 😁
Browse files

Merge branch...

Merge branch 'hotline#73599_pergame_bokeh_suppressions_de_reservations_depuis_bokeh_ne_remontent_pas_dans_pergame' into 'hotline'

Hotline#73599 pergame bokeh suppressions de reservations depuis bokeh ne remontent pas dans pergame

See merge request !2686
parents d5835317 037a709a
3 merge requests!2695Master,!2694Hotline,!2686Hotline#73599 pergame bokeh suppressions de reservations depuis bokeh ne remontent pas dans pergame
Pipeline #4329 passed with stage
in 33 minutes and 55 seconds
- ticket #73599 : SIGB Pergame: correction du fichier de transactions pour l'annulation des réservations
\ No newline at end of file
...@@ -244,23 +244,6 @@ class Class_Systeme_PergameService { ...@@ -244,23 +244,6 @@ class Class_Systeme_PergameService {
} }
public function supprimerReservation($id_reservation) {
$resa = fetchEnreg("select * from reservations where ID_RESA=$id_reservation");
if(!$resa)
return false;
sqlExecute("delete from reservations where ID_RESA=$id_reservation");
// On cree la transaction
$id_abon=$this->user->IDABON;
$ordre_abon=$this->user->ORDREABON;
$id_origine=$resa["ID_NOTICE_ORIGINE"];
$date=$resa["DATE_RESA"];
$id_site=$resa["ID_SITE"];
$this->ecrireTransaction(7, array($id_abon,$ordre_abon,$date,$id_origine,$id_site));
}
public function prolongerPret($id_pret) { public function prolongerPret($id_pret) {
$pret = fetchEnreg("select * from prets where id_pret=$id_pret"); $pret = fetchEnreg("select * from prets where id_pret=$id_pret");
$dateJour = date("Y-m-d"); $dateJour = date("Y-m-d");
...@@ -325,9 +308,6 @@ class Class_Systeme_PergameService { ...@@ -325,9 +308,6 @@ class Class_Systeme_PergameService {
public function getReglesReservation($id_bib) { public function getReglesReservation($id_bib) {
if (!$id_bib) if (!$id_bib)
return false; return false;
......
...@@ -16,12 +16,21 @@ ...@@ -16,12 +16,21 @@
* *
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software * along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
class Class_Transaction extends Storm_Model_Abstract { class Class_Transaction extends Storm_Model_Abstract {
const CANCEL_HOLD = 7;
protected $_table_name = 'transactions'; protected $_table_name = 'transactions';
protected $_table_primary = 'id_mvt'; protected $_table_primary = 'id_mvt';
public function setData($string_or_array) {
return is_array($string_or_array)
? parent::_set('data', implode('|', $string_or_array) . '|')
: parent::_set('data', $string_or_array);
}
} }
?> ?>
\ No newline at end of file
...@@ -129,7 +129,20 @@ class Class_WebService_SIGB_Pergame_Service extends Class_WebService_SIGB_Abstra ...@@ -129,7 +129,20 @@ class Class_WebService_SIGB_Pergame_Service extends Class_WebService_SIGB_Abstra
public function supprimerReservation($user, $reservation_id) { public function supprimerReservation($user, $reservation_id) {
return $this->getLegacyService()->supprimerReservation($reservation_id); if (!$hold = Class_Reservation::find($reservation_id))
return $this->_error($this->_('Réservation non trouvée'));
(new Class_Transaction())
->setTypeMvt(Class_Transaction::CANCEL_HOLD)
->setData([$hold->getIdabon(),
$hold->getOrdreabon(),
substr($hold->getDateResa(), 0, 10),
$hold->getIdNoticeOrigine(),
$hold->getIdSite()])
->save();
$hold->delete();
return $this->_success();
} }
......
...@@ -19,7 +19,10 @@ ...@@ -19,7 +19,10 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
abstract class PergameTestCase extends Storm_Test_ModelTestCase { abstract class PergameTestCase extends ModelTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();
...@@ -398,6 +401,77 @@ class PergameServiceGetExemplairePotterTest extends PergameTestCase { ...@@ -398,6 +401,77 @@ class PergameServiceGetExemplairePotterTest extends PergameTestCase {
class PergameServiceCancelHoldTest extends PergameTestCase {
protected $_cancel_result;
public function setUp() {
parent::setUp();
$this->fixture('Class_Reservation',
['id' => 1234,
'id_site' => 1,
'idabon' => 23,
'ordreabon' => 2,
'date_resa' => '2018-05-22 16:53:17',
'support' => 1,
'id_notice_origine' => 876]);
$this->_cancel_result = $this->_service_cran->supprimerReservation(Class_Users::getIdentity(),
1234);
}
/** @test */
public function resultShouldBeSuccess() {
$this->assertEquals(['statut' => true,
'erreur' => ''],
$this->_cancel_result);
}
/** @test */
public function hold1234ShouldBeDeleted() {
$this->assertNull(Class_Reservation::find(1234));
}
/** @test */
public function transactionShouldBeCreatedForPergame() {
$transaction = Class_Transaction::find(1);
$this->assertNotNull($transaction);
return $transaction;
}
/**
* @test
* @depends transactionShouldBeCreatedForPergame
*/
public function transactionTypeMvtShouldBe7($transaction) {
$this->assertEquals(7, $transaction->getTypeMvt());
}
/**
* @test
* @depends transactionShouldBeCreatedForPergame
*/
public function transactionDataShouldContainsIdAbonOrdreAbonDateIdOrigineIdSite($transaction) {
$this->assertEquals('23|2|2018-05-22|876|1|',
$transaction->getData());
}
/** @test */
public function deleteUnknownHoldShouldReturnError() {
$this->assertEquals(['statut' => false,
'erreur' => 'Réservation non trouvée'],
$this->_service_cran->supprimerReservation(Class_Users::getIdentity(),
666));
}
}
class PergameServiceDelegateLegacyTest extends PergameTestCase { class PergameServiceDelegateLegacyTest extends PergameTestCase {
public function setUp() { public function setUp() {
...@@ -431,19 +505,6 @@ class PergameServiceDelegateLegacyTest extends PergameTestCase { ...@@ -431,19 +505,6 @@ class PergameServiceDelegateLegacyTest extends PergameTestCase {
} }
/** @test */
public function supprimerReservationShouldDelegateToLegacyPergameService() {
$this->_legacy_service
->whenCalled('supprimerReservation')
->with('1234')
->answers(['statut' => 0, 'erreur' => ''])
->beStrict();
$result = $this->_service_cran->supprimerReservation(Class_Users::getIdentity(), '1234');
$this->assertEquals(['statut' => 0, 'erreur' => ''], $result);
}
/** @test */ /** @test */
public function prolongerPretShouldDelegateToLegacyPergameService() { public function prolongerPretShouldDelegateToLegacyPergameService() {
$this->_legacy_service $this->_legacy_service
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment