0.1.4Updated 6 months ago
declare namespace Ledger {
  namespace Expiration {
    interface Options {
      /**
       * Whether entries expire.
       * 
       * Default: `false`
       */
      entries_expire?: boolean
    
      /**
       * How long entries have before they expire.
       * 
       * Only used if **entries_expire** is `true`.
       * 
       * Default: `[1, 'week']`
       */
      period?: [number, Measurement]
    
      /**
       * After calculating an expiration timestamp, it will be rounded up to the end of this period.
       * 
       * Only used if **entries_expire** is `true`.
       * 
       * Default: `none`
       */
      round_up_to?: 'none' | MeasurementSingular
    
      /**
       * Instead of using **period** and **round_up_to**, pass a function 
       * 
       * @param entry The ledger entry being added. [Immutable]
       * @returns Date
       */
      custom_calculator?: () => Date
    
    }
    
    interface Override_False {
      override_expiration_date?: false
    }

    interface Override_True {
      override_expiration_date: true
      expiration_date: Date
    }

    type Override = Override_False | Override_True

    type MeasurementSingular = 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year'
    type MeasurementPlural = `${MeasurementSingular}s`

    type Measurement = MeasurementSingular | MeasurementPlural
  }
}