import BatchHeaders from './header';
import BatchControls from './control';
import Entry from '../entry';

interface BatchOptions {
  header?: BatchHeaders;
  control?: BatchControls;
  /** Name of the Originator known and recognized by the Receiver. (Filerr)
   * Max Length 16
   */
  companyName?: string;
  /**Originator inserts this field's value to provide the Receiver with a description of the entry's purpose;
   * however some SEC Codes require specific values for this field.
   * Only uppercase letters*/
  companyEntryDescription?: string;
  /**The Originator establishes this field as the date it would like to see displayed
   * to the Receiver for descriptive purposes. This field is never used to control
   * timing of any computer or manual operation. It is solely for descriptive
   * purposes. Examples of possible content in this field are “011311,” “01 11,”
   * “Jan 13,” “JAN 11,” etc.
   */
  companyDescriptiveDate?: string;
  effectiveEntryDate?: string | Date;
  /**The routing number of the DFI originating the entries within the batch. */
  originatingDFI?: string;
  /** Identifies the general classification of dollar entries to be exchanged (i.e. debit and/or credit entries)
   * - 200 ACH Entries Mixed Debits and Credits
   * - 220 ACH Credits Only
   * - 225 ACH Debits Only
   * - 280 ACH Automated Accounting Advices  */
  serviceClassCode?: string;
  /**Originator/ODFI may include codes of significance only to them
   * to enable specialized handling of all entries within the batch. */
  companyDiscretionaryData?: string;
  /** Used to identify the Originator. Assigned by the ODFI.*/
  companyIdentification?: string;
  /** Three-character code used to identify distinct types of entries.
   * https://dev-ach-guide.pantheonsite.io/ach-file-details#pageContent-1 */
  standardEntryClassCode?: string;
  addendaCount?: string;
  entryHash?: string;
  totalDebit?: string;
  totalCredit?: string;
}

declare class Batch {
  private _entries: Entry[];
  header: BatchHeaders;
  control: BatchControls;

  constructor(options: BatchOptions, autoValidate?: boolean);

  private _validate(): void;

  addEntry(entry: Entry): void;

  getEntries(): Entry[];

  generateHeader(cb: (headerString: string) => void): void;

  generateControl(cb: (controlString: string) => void): void;

  generateEntries(cb: (result: string) => void): void;

  generateString(cb: (batchString: string) => void): void;

  get(field: keyof typeof BatchHeaders | keyof typeof BatchControls): string;

  set(
    field: keyof typeof BatchHeaders | keyof typeof BatchControls,
    value: string
  ): void;
}

export = Batch;
