import api from "src/api";

export const getReceivablesMe = async (params = {}) => {
  const { data } = await api.get("/franchisee/financial/receivables", { params });
  return data.payload;
};

export const settleReceivableMe = async (id, payload = {}) => {
  const { data } = await api.post(`/franchisee/financial/receivables/${id}/settle`, payload);
  return data.payload;
};

export const reopenReceivableMe = async (id) => {
  const { data } = await api.post(`/franchisee/financial/receivables/${id}/reopen`);
  return data.payload;
};

export const chargeReceivableMe = async (id) => {
  const { data } = await api.post(`/franchisee/financial/receivables/${id}/charge`);
  return data.payload;
};

// Recebíveis avulsos (manuais)
export const createManualReceivableMe = async (payload) => {
  const { data } = await api.post("/franchisee/financial/receivables", payload);
  return data.payload;
};

export const settleManualReceivableMe = async (id, payload = {}) => {
  const { data } = await api.post(`/franchisee/financial/receivables/manual/${id}/settle`, payload);
  return data.payload;
};

export const reopenManualReceivableMe = async (id) => {
  const { data } = await api.post(`/franchisee/financial/receivables/manual/${id}/reopen`);
  return data.payload;
};
