diff --git a/library/Class/Album/UsageConstraint.php b/library/Class/Album/UsageConstraint.php
index 475f54351aeeba0cd10b8f52c199f5935b792ec4..450c92e96f656e50ffb8298bb77209b9a1b64f06 100644
--- a/library/Class/Album/UsageConstraint.php
+++ b/library/Class/Album/UsageConstraint.php
@@ -70,7 +70,12 @@ class Class_Album_UsageConstraint extends Storm_Model_Abstract {
 
 
   public function getDuration() {
-    return (int)$this->getDatas()->get(self::DURATION);
+    $pnb_duration = (int)$this->getDatas()->get(self::DURATION);
+    $max_duration = (int)Class_AdminVar::get('DILICOM_PNB_MAX_LOAN_DURATION');
+    if (!$max_duration)
+      return $pnb_duration;
+
+    return min($max_duration, $pnb_duration);
   }
 
 
diff --git a/library/Class/WebService/BibNumerique/Dilicom/Hub.php b/library/Class/WebService/BibNumerique/Dilicom/Hub.php
index 00349dd19b741087737ddfbbf44ca460738e1d6b..24706fbacea5ae6719ab348406df3d2d6c9249ab 100644
--- a/library/Class/WebService/BibNumerique/Dilicom/Hub.php
+++ b/library/Class/WebService/BibNumerique/Dilicom/Hub.php
@@ -88,7 +88,7 @@ class Class_WebService_BibNumerique_Dilicom_Hub extends Class_WebService_Abstrac
                                          'user_id' => $user->getId(),
                                          'ongoing' => true,
                                          'loan_date' => $this->startDate(),
-                                         'expected_return_date' => $this->endDate(),
+                                         'expected_return_date' => $this->endLoanDate($album),
                                          'record_origin_id' => $album->getIdOrigine()]);
     $loan->save();
 
@@ -96,7 +96,7 @@ class Class_WebService_BibNumerique_Dilicom_Hub extends Class_WebService_Abstrac
                                    ['orderLineId' => $this->getOrderLineId($album),
                                     'accessMedium' => 'DOWNLOAD',
                                     'localization' => 'EX_SITU',
-                                    'loanEndDate' => urlencode($this->endDate()),
+                                    'loanEndDate' => urlencode($this->endLoanDate($album)),
                                     'ean13' => $album->getISBN(),
                                     'loanId' =>  $loan->getId(),
                                    ]);
@@ -118,7 +118,7 @@ class Class_WebService_BibNumerique_Dilicom_Hub extends Class_WebService_Abstrac
                               ['orderLineId' => $this->getOrderLineId($album),
                                'accessMedium' => 'STREAMING',
                                'localization' => 'IN_SITU',
-                               'consultEndDate' => urlencode($this->endDate()),
+                               'consultEndDate' => urlencode($this->endConsultDate()),
                                'ean13' => $album->getISBN(),
                                'ipAddress' => $ip_address,
                                'loanId' =>  implode('',
@@ -139,7 +139,14 @@ class Class_WebService_BibNumerique_Dilicom_Hub extends Class_WebService_Abstrac
   }
 
 
-  public function endDate() {
+  public function endLoanDate($album) {
+    xdebug_break();
+    return $this->iso8601($this->_now +
+                          $album->getUsageConstraints()->getLoanDuration() * 3600 * 24);
+  }
+
+
+  public function endConsultDate() {
     return $this->iso8601($this->_now + 3600);
   }
 
diff --git a/library/Class/WebService/BibNumerique/Dilicom/ONIXFile.php b/library/Class/WebService/BibNumerique/Dilicom/ONIXFile.php
index fcfe347cf8e0aa1f06515e68d8281bd1c60c9d11..9f1cc83ff5359bed01ba31e6be6b4aefdc451def 100644
--- a/library/Class/WebService/BibNumerique/Dilicom/ONIXFile.php
+++ b/library/Class/WebService/BibNumerique/Dilicom/ONIXFile.php
@@ -211,8 +211,7 @@ class Class_WebService_BibNumerique_Dilicom_ONIXFile {
 
   public function endEPubUsageLimit() {
     if ($this->_current_usage_unit == self::USAGE_UNIT_DAYS) {
-      $quantity = Class_WebService_BibNumerique_Dilicom_PNBOffersFile::loanDuration($this->_current_quantity);
-      $this->_current_usage_constraint->setDuration($quantity);
+      $this->_current_usage_constraint->setDuration($this->_current_quantity);
       $this->_current_usage_constraint->setEndDate();
       return;
     }
diff --git a/library/Class/WebService/BibNumerique/Dilicom/PNBOffersFile.php b/library/Class/WebService/BibNumerique/Dilicom/PNBOffersFile.php
index bdcee53a8bcb700009286b996e75c70abbd04e9a..72d3f0e71da829c0c8eea3b1415e0a0a6e803662 100644
--- a/library/Class/WebService/BibNumerique/Dilicom/PNBOffersFile.php
+++ b/library/Class/WebService/BibNumerique/Dilicom/PNBOffersFile.php
@@ -31,17 +31,6 @@ class Class_WebService_BibNumerique_Dilicom_PNBOffersFile {
   }
 
 
-  public static function loanDuration($duration) {
-    if (!Class_AdminVar::get('DILICOM_PNB_MAX_LOAN_DURATION'))
-      return $duration;
-
-    if (Class_AdminVar::get('DILICOM_PNB_MAX_LOAN_DURATION') <= $duration)
-      return Class_AdminVar::get('DILICOM_PNB_MAX_LOAN_DURATION');
-
-    return $duration;
-  }
-
-
   public function parseXML($xml) {
     $this->_books = [];
 
diff --git a/tests/application/modules/opac/controllers/BibNumeriqueControllerDilicomTest.php b/tests/application/modules/opac/controllers/BibNumeriqueControllerDilicomTest.php
index 1d0e53dee2e8ba35a5799352370c664410f8656e..01148c2bb665eb6d7bddbe61b45750988cd7e20e 100644
--- a/tests/application/modules/opac/controllers/BibNumeriqueControllerDilicomTest.php
+++ b/tests/application/modules/opac/controllers/BibNumeriqueControllerDilicomTest.php
@@ -29,6 +29,8 @@ abstract class BibNumeriqueContollerDilicomTestCase extends AbstractControllerTe
   public function setUp() {
     parent::setUp();
 
+    Class_AdminVar::set('DILICOM_PNB_MAX_LOAN_DURATION', 0);
+
     $logged_user = $this->fixture('Class_Users',
                                   ['id' => 6,
                                    'nom'=>'Pito',
@@ -61,6 +63,7 @@ abstract class BibNumeriqueContollerDilicomTestCase extends AbstractControllerTe
                                                                           'usage_type' => Class_Album_UsageConstraint::LOAN_CONSTRAINT,
                                                                           Class_Album_UsageConstraint::MAX_NB_OF_USERS => 40,
                                                                           Class_Album_Usageconstraint::QUANTITY => 50,
+                                                                          Class_Album_UsageConstraint::DURATION => '100',
                                                                           'order_line_id' => 'x321']),
                                                           $this->fixture('Class_Album_UsageConstraint',
                                                                          ['id' => 2,
@@ -177,7 +180,7 @@ class BibNumeriqueControllerDilicomLoanBookActionTest extends BibNumeriqueContol
 
     $this->_http
       ->whenCalled('open_url')
-      ->with('https://pnb-test.centprod.com/v2/pnb-numerique/json/loanBook?glnContractor=123456789&orderLineId=x321&accessMedium=DOWNLOAD&localization=EX_SITU&loanEndDate=2014-05-02T15%3A14%3A14%2B0200&ean13=435465&loanId=1')
+      ->with('https://pnb-test.centprod.com/v2/pnb-numerique/json/loanBook?glnContractor=123456789&orderLineId=x321&accessMedium=DOWNLOAD&localization=EX_SITU&loanEndDate=2014-08-10T14%3A14%3A14%2B0200&ean13=435465&loanId=1')
       ->answers(DilicomFixtures::loanBookResponse())
       ->beStrict();
 
@@ -210,9 +213,11 @@ class BibNumeriqueControllerDilicomLoanBookActionErrorsTest extends BibNumerique
     parent::setUp();
     $_SERVER['HTTP_REFERER'] = '/viewnotice/id/3';
 
+    Class_AdminVar::set('DILICOM_PNB_MAX_LOAN_DURATION', 10);
+
     $this->_http
       ->whenCalled('open_url')
-      ->with('https://pnb-test.centprod.com/v2/pnb-numerique/json/loanBook?glnContractor=123456789&orderLineId=x321&accessMedium=DOWNLOAD&localization=EX_SITU&loanEndDate=2014-05-02T15%3A14%3A14%2B0200&ean13=435465&loanId=1')
+      ->with('https://pnb-test.centprod.com/v2/pnb-numerique/json/loanBook?glnContractor=123456789&orderLineId=x321&accessMedium=DOWNLOAD&localization=EX_SITU&loanEndDate=2014-05-12T14%3A14%3A14%2B0200&ean13=435465&loanId=1')
       ->answers(DilicomFixtures::loanBookErrorResponse())
       ->beStrict();