const URL = "/one-api/fixedasset/";

export async function getPeriode(prm) {
    try {
        var resp = await axios.post(URL + 'journalfixedassetv2/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 search(token, xdate, periodeid, branchid, regionalid) {
    try {
        var resp = await axios.post(URL + 'journalfixedassetv2/search', {
            token:token,
            xdate:xdate,
            periodeid:periodeid,
            branchid:branchid,
            regionalid:regionalid
        });
        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 getdetail(prm) {
    try {
        var resp = await axios.post(URL + 'journalfixedassetv2/getdetail', 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 insertSales(branchCode, date, jurnalno) {
    try {
        var resp = await axios.get(URL + `mediajurnalauto/insertSales/${branchCode}/${date}?isregen=1&jurnalno=${jurnalno}`);
        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 addConfirm(prm) {
    try {
        var resp = await axios.post(URL + 'journalfixedassetv2/addConfirm', 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
        };
    }
}
