import {
  createJournalEntry,
  postJournalEntry,
  createBalanceReservation,
  releaseBalanceReservation,
  clearPayoutJournalStores,
} from './omnl-payout-journal';

describe('omnl payout journal', () => {
  beforeEach(() => {
    clearPayoutJournalStores();
  });

  it('creates and posts journal entry', () => {
    const je = createJournalEntry({
      instructionId: 'PAY-1',
      debitGlCode: '1000',
      creditGlCode: '2000',
      amount: '100.00',
      currency: 'USD',
    });
    expect(je.status).toBe('DRAFT');
    const posted = postJournalEntry(je.id);
    expect(posted.status).toBe('POSTED');
  });

  it('creates and releases balance reservation', () => {
    const r = createBalanceReservation({
      instructionId: 'PAY-2',
      amount: '50.00',
      currency: 'USD',
      accountRef: 'ACCT-1',
    });
    expect(r.status).toBe('HELD');
    const released = releaseBalanceReservation(r.id);
    expect(released.status).toBe('RELEASED');
  });
});
