export default async function addScopeService(db, { siteId, jobId, serviceId, amount, quantity, price }) {
  const collectionPath = siteId
    ? `/sites/${siteId}/services`
    : `/jobs/${jobId}/services`;
  const data = {
    amount,
    quantity,
    price,
    total: parseFloat(`${amount || 0}`) *
      parseFloat(`${quantity || 1}`) *
      parseFloat(`${price || 0}`),
    createdAt: new Date(),
    service: db.document("services", serviceId),
  };
  const service = await db.add(collectionPath, data, serviceId);
  return service;
}
