org.gitana.platform.services.billing

## Class BillingCalculator

- java.lang.Object
- - org.gitana.platform.services.billing.BillingCalculator

    public class BillingCalculator
    extends Object

Author:
  uzi

### Constructor Summary

Constructors
Constructor and Description
`BillingCalculator()`

### Method Summary

All Methods Static Methods Concrete Methods
`static BigDecimal` `calculateOverageCost(long allowance, DataUnit unit, long byteCount, BigDecimal pricePerUnit)` Computes the overage cost given an allowance specified in units (i.e.
`static Calendar` `getCurrentBillingEndDate()`
`static Calendar` `getCurrentBillingStartDate()`
`static Calendar` `getNextBillingStartDate()`
`static Calendar` `getStartOfMonth(int month)`
`static long` `toByteCount(BigDecimal unitCount, DataUnit unit)` Converts a unit count (length in MB, GB, etc) to a byte count.
`static long` `toByteCount(long unitCount, DataUnit unit)` Converts a unit count (length in MB, GB, etc) to a byte count.
`static BigDecimal` `toUnitCount(long byteCount, DataUnit unit, int scale)` Converts an byte count (length in bytes) to a unit count (length in MB, GB, etc).

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### BillingCalculator

    public BillingCalculator()

### Method Detail

#### toUnitCount

    public static BigDecimal toUnitCount(long byteCount,
                                         DataUnit unit,
                                         int scale)

Converts an byte count (length in bytes) to a unit count (length in MB, GB, etc).

Parameters:
  `byteCount` -
  `unit` -
  `scale` -
Returns:

#### toByteCount

    public static long toByteCount(BigDecimal unitCount,
                                   DataUnit unit)

Converts a unit count (length in MB, GB, etc) to a byte count.

Parameters:
  `unitCount` -
  `unit` -
Returns:

#### toByteCount

    public static long toByteCount(long unitCount,
                                   DataUnit unit)

Converts a unit count (length in MB, GB, etc) to a byte count.

Parameters:
  `unitCount` -
  `unit` -
Returns:

#### calculateOverageCost

    public static BigDecimal calculateOverageCost(long allowance,
                                                  DataUnit unit,
                                                  long byteCount,
                                                  BigDecimal pricePerUnit)

Computes the overage cost given an allowance specified in units (i.e. 5 GB) and a usage byte count.

Parameters:
  `allowance` -
  `unit` -
  `byteCount` -
Returns:

#### getStartOfMonth

    public static Calendar getStartOfMonth(int month)

#### getCurrentBillingStartDate

    public static Calendar getCurrentBillingStartDate()

#### getNextBillingStartDate

    public static Calendar getNextBillingStartDate()

#### getCurrentBillingEndDate

    public static Calendar getCurrentBillingEndDate()