Uploaded image for project: 'Subscription Watch'
  1. Subscription Watch
  2. SWATCH-3429

Update covered by contract metric to track only usage that won't be billed

XMLWordPrintable

      In BillableUsageService we have a metric called "swatch_contract_usage_total" that increments by the total contract amount each time a usage is remitted.  This doesn't give an accurate account of what usage is covered by the contract however since it will increment by the full amount for every remittance that occurs.

      Instead it should only increment by the amount of usage that is being covered by the contract during processing of said billable usage. 

      This formula can be used to determine what to increment by:

      remaining_allowable_contract_usage = max(0, contract_value - (current_total_usage - usage))
      swatch_contract_usage_total += min(usage, remaining_allowable_contract_usage)) 

      Ex: (Contract value = 10, current_total_usage = 3, usage = 3, swatch_contract_usage_total += 3)

      Ex: (Contract value = 10, current_total_usage = 6, usage = 4, swatch_contract_usage_total += 4)

      Ex: (Contract value = 10, current_total_usage = 12, usage = 3, swatch_contract_usage_total += 1)

      Ex: (Contract value = 10, current_total_usage = 20, usage=5, swatch_contract_usage_total += 0)

       

      Done:

      • swatch_contract_usage_total increments by the usage being covered within the given month

       

              jcarvaja@redhat.com Jose Carvajal Hilario
              kflahert@redhat.com Kevin Flaherty
              Trayvon McKnight Trayvon McKnight
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: