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

export async function getJurnalType(prm) {
    try {
        var resp = await axios.post(URL + '/getTipeJurnal', 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 searchPeriode(prm) {
    try {
        var resp = await axios.post(URL + '/getPeriode', 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 searchSupplier(prm) {
    try {
        var resp = await axios.post(URL + '/getSupplier', 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 searchCoa(prm) {
    try {
        var resp = await axios.post(URL + '/getCoa', 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 saveJurnal(prm) {
    try {
        var resp = await axios.post(URL + '/createJurnal', 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 loadEditDialog(prm) {
    try {
        var resp = await axios.post(URL + '/loadEditDialog', 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 updateJurnal(prm) {
    try {
        var resp = await axios.post(URL + '/updateJurnal', 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
        };
    }
}