const URL = "/one-api/mockup/masterdata/accounting/"

export async function searchitem(prm) {
    try {
        var resp = await axios.post(URL + 'unitconvert/search', prm);
        if (resp.status != 200) {
            return {
                status: "ERR",
                message: resp.statusText
            };
        }

        let data = resp.data;
        return data;
    } catch (e) {
        return {
            status: "ERR",
            message: e.message
        };
    }
}

export async function searchitemx(prm) {
    try {
        var resp = await axios.post(URL + 'unitconvert/searchitemx', prm);
        if (resp.status != 200) {
            return {
                status: "ERR",
                message: resp.statusText
            };
        }
        let data = resp.data;
        return data;
    } catch(e) {
        return {
            status: "ERR",
            message: e.message
        };
    }
}

export async function fromitemunit(prm) {
    try {
       var resp = await axios.post(URL + 'unitconvert/fromitemunit', prm);
       if (resp.status != 200) {
          return {
             status: "ERR",
             message: resp.statusText
          };
       }
       let data = resp.data;
       return data;
    } catch(e) {
       return {
          status: "ERR",
          message: e.message
       };
    }
}

export async function toitemunit(prm) {
    try {
       var resp = await axios.post(URL + 'unitconvert/toitemunit', prm);
       if (resp.status != 200) {
          return {
             status: "ERR",
             message: resp.statusText
          };
       }
       let data = resp.data;
       return data;
    } catch(e) {
       return {
          status: "ERR",
          message: e.message
       };
    }
}

export async function saveAdd(prm) {
    try {
      var resp = await axios.post(URL + 'unitconvert/save', prm);
      if (resp.status != 200) {
        return {
          status: "ERR",
        };
      }
      let data = resp.data;
      return data;
    } catch (e) {
      return {
        status: "ERR",
        message: e.message,
      };
    }
}

export async function saveedit(prm) {
  try {
        var resp = await axios.post(URL + 'unitconvert/edit', prm);
        if (resp.status != 200) {
            return {
              status: "ERR",
              message: resp.statusText
            };
        }
        let data = resp.data;
        return data;
  } catch (e) {
      return {
          status: "ERR",
          message: e.message
        };
    }
}

export async function xdelete(prm) {
    try {
        var resp = await axios.post(URL + 'unitconvert/delete', prm);
        if (resp.status != 200) {
            return {
                status: "ERR",
            };
        }
        let data = resp.data;
        return data;
    } catch (e) {
        return {
            status: "ERR",
            message: e.message,
        };
    }
}