'use strict';

const defaultInventarioService = require('../../services/inventarioService');
const { validateFoodcostRecalculate } = require('./schemas');

function service(deps = {}) {
  return deps.inventarioService || defaultInventarioService;
}

async function recalculate(command, _config = {}, deps = {}) {
  const payload = validateFoodcostRecalculate(command.payload || {});
  const result = await service(deps).getFoodCostEnVivo();
  return {
    ok: true,
    entity_type: 'foodcost',
    entity_id: payload.idproducto || 'live',
    result,
  };
}

module.exports = { recalculate };
