import api from "src/api";

export const getReceivablesMe = async (params = {}) => {
  const { data } = await api.get("/unit-receivable/me", { params });
  return data.payload;
};

export const settleReceivableMe = async (id, payload = {}) => {
  const { data } = await api.post(`/unit-receivable/me/${id}/settle`, payload);
  return data.payload;
};

export const reopenReceivableMe = async (id) => {
  const { data } = await api.post(`/unit-receivable/me/${id}/reopen`);
  return data.payload;
};

export const chargeReceivableMe = async (id) => {
  const { data } = await api.post(`/unit-receivable/me/${id}/charge`);
  return data.payload;
};

// Recebíveis avulsos (manuais)
export const createManualReceivableMe = async (payload) => {
  const { data } = await api.post("/unit-receivable/me/manual", payload);
  return data.payload;
};

export const settleManualReceivableMe = async (id, payload = {}) => {
  const { data } = await api.post(`/unit-receivable/me/manual/${id}/settle`, payload);
  return data.payload;
};

export const reopenManualReceivableMe = async (id) => {
  const { data } = await api.post(`/unit-receivable/me/manual/${id}/reopen`);
  return data.payload;
};
