/**
  * Implements CommerceLicenseBillingUsageGroupInterface::currentUsage().
  */
 public function currentUsage($billingCycle = NULL)
 {
     if (is_null($billingCycle)) {
         // Default to the current billing cycle.
         $billingCycle = commerce_license_billing_get_license_billing_cycle($this->license);
         if (!$billingCycle) {
             // A billing cycle could not be found, possibly because the license
             // hasn't been activated yet.
             return 0;
         }
     }
     // Get the quantity of the usage record with the highest usage_id
     // for the current revision and billing cycle.
     $current_usage = 0;
     $previous_usage_id = 0;
     $usage = $this->usageHistory($billingCycle);
     foreach ($usage as $usage_record) {
         if ($usage_record['revision_id'] == $this->license->revision_id) {
             if ($usage_record['usage_id'] > $previous_usage_id) {
                 $current_usage = $usage_record['quantity'];
                 $previous_usage_id = $usage_record['usage_id'];
             }
         }
     }
     return $current_usage;
 }
 /**
  * Implements CommerceLicenseBillingUsageGroupInterface::currentUsage().
  */
 public function currentUsage($billingCycle = NULL)
 {
     if (is_null($billingCycle)) {
         // Default to the current billing cycle.
         $billingCycle = commerce_license_billing_get_license_billing_cycle($this->license);
         if (!$billingCycle) {
             // A billing cycle could not be found, possibly because the license
             // hasn't been activated yet.
             return 0;
         }
     }
     // Sum up all usage for the current billing cycle and revisions up to
     // (and including) the current one.
     $current_usage = 0;
     $usage = $this->usageHistory($billingCycle);
     foreach ($usage as $usage_record) {
         if ($usage_record['revision_id'] <= $this->license->revision_id) {
             $current_usage += $usage_record['quantity'];
         }
     }
     return $current_usage;
 }