import HeldBill from '../models/HeldBill.js';

export const findAll = async () => HeldBill.find({ status: 'HELD' }).sort('-createdAt');

export const findById = async (id) => HeldBill.findById(id);

export const create = async (data) => {
  const doc = new HeldBill(data);
  await doc.save();
  return doc;
};

export const save = async (doc) => doc.save();

export const countHeld = async () => HeldBill.countDocuments({ status: 'HELD' });

export const findLatest = async () => HeldBill.findOne().sort('-createdAt');
