From 23f48bba3aaca6ab091e0be4a47128ac3df3eeca Mon Sep 17 00:00:00 2001
From: Henri-Damien LAURENT <hdlaurent@afi-sa.fr>
Date: Tue, 5 Jul 2022 16:46:35 +0200
Subject: [PATCH] hotline#157441 : SIGB Carthame : fix Library display in
 Abonne Reservations tab

---
 VERSIONS_HOTLINE/157441                       |  1 +
 .../SIGB/Carthame/AccountResponseReader.php   | 12 +++++++++++
 .../Class/WebService/SIGB/CarthameTest.php    | 21 +++++++++++++++++++
 3 files changed, 34 insertions(+)
 create mode 100644 VERSIONS_HOTLINE/157441

diff --git a/VERSIONS_HOTLINE/157441 b/VERSIONS_HOTLINE/157441
new file mode 100644
index 00000000000..4198fda99ad
--- /dev/null
+++ b/VERSIONS_HOTLINE/157441
@@ -0,0 +1 @@
+ - correctif #157441 : Carthame : Correction de l'affichage de la bibliothèque dans l'onglet réservation des abonnés.
\ No newline at end of file
diff --git a/library/Class/WebService/SIGB/Carthame/AccountResponseReader.php b/library/Class/WebService/SIGB/Carthame/AccountResponseReader.php
index dfe79c9a4f7..c35cd7a82fb 100644
--- a/library/Class/WebService/SIGB/Carthame/AccountResponseReader.php
+++ b/library/Class/WebService/SIGB/Carthame/AccountResponseReader.php
@@ -146,6 +146,18 @@ class Class_WebService_SIGB_Carthame_AccountResponseReader {
   }
 
 
+  public function endSFe($data) {
+    if ($this->_xml_parser->inParents('F500'))
+      return $this->_current_reservation->setBibliotheque($data);
+  }
+
+
+  public function endSFj($data) {
+    if ($this->_xml_parser->inParents('F500'))
+      return $this->_current_reservation->setPickupLocationLabel($data);
+  }
+
+
   protected function _holdStatus($data) {
     $mapping = ['A' => $this->_('En attente'),
                 'D' => $this->_('Disponible'),
diff --git a/tests/library/Class/WebService/SIGB/CarthameTest.php b/tests/library/Class/WebService/SIGB/CarthameTest.php
index ab69ce55ccb..6d257cfbccc 100644
--- a/tests/library/Class/WebService/SIGB/CarthameTest.php
+++ b/tests/library/Class/WebService/SIGB/CarthameTest.php
@@ -763,6 +763,18 @@ class CarthameEmprunteurPatrickBTest extends CarthameOperationTestCase {
   }
 
 
+  /** @test */
+  public function firstReservationPickupLocationLabelShouldBeLunelViel() {
+    $this->assertEquals('Lunel-Viel', $this->emprunteur->getReservationAt(0)->getPickupLocationLabel());
+  }
+
+
+  /** @test */
+  public function firstReservationBibliothequeShouldBeMediathequePaysDeLunel() {
+    $this->assertEquals('Médiathèque Pays de Lunel', $this->emprunteur->getReservationAt(0)->getBibliotheque());
+  }
+
+
   /** @test */
   public function firstReservationStatusShouldBeEnAttente() {
     $this->assertEquals('En attente', $this->emprunteur->getReservationAt(0)->getEtat());
@@ -847,6 +859,12 @@ class CarthameEmprunteurPatrickBTest extends CarthameOperationTestCase {
   }
 
 
+  /** @test */
+  public function thirdReservationPickupLocationLabelShouldBeBazace() {
+    $this->assertEquals('Bazace', $this->emprunteur->getReservationAt(2)->getPickupLocationLabel());
+  }
+
+
   /** @test */
   public function emprunteurShouldHave3LoansInHistory() {
     $this->assertCount(3, $this->emprunteur->getLoansHistory()->getLoans());
@@ -1214,6 +1232,8 @@ class CarthameTestFixtures {
                       <SFa>Millenium</SFa>
                       <SFb>20110505</SFb>
                       <SFd>A</SFd>
+                      <SFe>Médiathèque Pays de Lunel</SFe>
+                      <SFj>Lunel-Viel</SFj>
                       <SFh>MillRes</SFh>
                     </F500>
                     <F500>
@@ -1226,6 +1246,7 @@ class CarthameTestFixtures {
                       <SFa>Al Amut</SFa>
                       <SFb>20110517</SFb>
                       <SFd>T</SFd>
+                      <SFj>Bazace</SFj>
                       <SFh>AmutRes</SFh>
                     </F500>
                     <F490>
-- 
GitLab