const db = require('../db/config');

exports.getAllLedgerEntries = () => {
  return db.query('SELECT * FROM accounts_ledger ORDER BY created_at DESC');
};

exports.addLedgerEntry = ({ type, reference, debit, credit, description, bank_id }) => {
    return db.query(
      'INSERT INTO accounts_ledger (type, reference, debit, credit, description, bank_id) VALUES (?, ?, ?, ?, ?, ?)',
      [type, reference, debit || 0, credit || 0, description, bank_id || null]
    );
  };
