From b826ed46432b04bdc8c2069e4b1f84b12eeb6bcc Mon Sep 17 00:00:00 2001 From: Arthur Suzuki <arthur.suzuki@biblibre.com> Date: Tue, 17 Oct 2023 15:50:18 +0000 Subject: [PATCH] hotline#187250 : fix endRenewals and endRenewals_count behavior for Koha --- VERSIONS_HOTLINE/187250 | 1 + .../WebService/SIGB/Koha/LoansPageReader.php | 5 ---- .../WebService/SIGB/Koha/PatronInfoReader.php | 26 +++++++++++++++++++ tests/fixtures/KohaFixtures.php | 3 ++- .../Class/WebService/SIGB/KohaTest.php | 8 ++++++ 5 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 VERSIONS_HOTLINE/187250 diff --git a/VERSIONS_HOTLINE/187250 b/VERSIONS_HOTLINE/187250 new file mode 100644 index 00000000000..e8191658c33 --- /dev/null +++ b/VERSIONS_HOTLINE/187250 @@ -0,0 +1 @@ + - correctif #187250 : SIGB Koha : Le nombre de prolongations de prêts affichée est dorénavant le nombre de prolongations faites pour ce prêt et non le nombre de prolongations totales pour l'exemplaire (cumul de tous les prêts). \ No newline at end of file diff --git a/library/Class/WebService/SIGB/Koha/LoansPageReader.php b/library/Class/WebService/SIGB/Koha/LoansPageReader.php index 909d32bd732..e10ef554514 100644 --- a/library/Class/WebService/SIGB/Koha/LoansPageReader.php +++ b/library/Class/WebService/SIGB/Koha/LoansPageReader.php @@ -37,11 +37,6 @@ class Class_WebService_SIGB_Koha_LoansPageReader } - public function endLoan($data) { - $this->_loans [] = $this->_currentLoan; - } - - public function endTotal_Loans($data) { $this->_total = ((int)$data); } diff --git a/library/Class/WebService/SIGB/Koha/PatronInfoReader.php b/library/Class/WebService/SIGB/Koha/PatronInfoReader.php index 363cd6cd15a..dd32f499d6c 100644 --- a/library/Class/WebService/SIGB/Koha/PatronInfoReader.php +++ b/library/Class/WebService/SIGB/Koha/PatronInfoReader.php @@ -27,6 +27,8 @@ class Class_WebService_SIGB_Koha_PatronInfoReader $_current_exemplaire_operation, $_grouped_holds_itypes = []; + protected int $_renewals_count = 0; + protected int $_renewals = 0; public static function newInstance() { return new self(); @@ -193,6 +195,30 @@ class Class_WebService_SIGB_Koha_PatronInfoReader } + public function endLoan($data) { + $renewals = $this->_renewals_count + ? $this->_renewals_count + : $this->_renewals; + + if ($renewals && $this->_currentLoan) + $this->_currentLoan->setRenewals($renewals); + + $this->_renewals_count = $this->_renewals = 0; + + parent::endLoan($data); + } + + + public function endRenewals($data) { + $this->_renewals = (int) $data; + } + + + public function endRenewals_count($data) { + $this->_renewals_count = (int) $data; + } + + public function endTotal_Loans($data) { $this->getEmprunteur()->setNbEmprunts((int)$data); } diff --git a/tests/fixtures/KohaFixtures.php b/tests/fixtures/KohaFixtures.php index c68ceb2c0e4..15ff58091cb 100644 --- a/tests/fixtures/KohaFixtures.php +++ b/tests/fixtures/KohaFixtures.php @@ -4108,7 +4108,8 @@ class KohaFixtures { <homebranch>BIB</homebranch> <holdingbranch>BIB</holdingbranch> <biblionumber>4486</biblionumber> - <renewals>3</renewals> + <renewals>36</renewals> + <renewals_count>3</renewals_count> <damaged>0</damaged> <cn_sort>78787_BUC</cn_sort> <volume>une méthode simple et facile pour apprendre la guitare</volume> diff --git a/tests/library/Class/WebService/SIGB/KohaTest.php b/tests/library/Class/WebService/SIGB/KohaTest.php index 1b8b29a7bcf..2f6f9ff74d1 100644 --- a/tests/library/Class/WebService/SIGB/KohaTest.php +++ b/tests/library/Class/WebService/SIGB/KohaTest.php @@ -1126,6 +1126,14 @@ class KohaGetEmprunteurJeanAndreWithIdSIGBTest extends KohaTestCase { } + /** @test */ + public function firstEmpruntRenewalsShouldBeThree() { + $this->assertEquals(3, + $this->jean->getEmpruntAt(0)->getRenewals()); + + } + + /** @test */ public function secondEmpruntTitreShouldBeLIleAuTresor() { $this->assertEquals('L\'Île au trésor', $this->jean->getEmpruntAt(1)->getTitre()); -- GitLab