const URL = "/one-api/mockup/supplierpaymentcashierv5/";

export async function lookup_type(token) {
    try {
        var resp = await axios.post(URL + 'payment/lookup_type',{token:token});
        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 lookup_banks(token) {
    try {
        var resp = await axios.post(URL + 'payment/lookup_banks',{token:token});
        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 lookup_accounts(token) {
    try {
        var resp = await axios.post(URL + 'payment/lookup_accounts',{token:token});
        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 searchcard(token,prm) {
    try {
       var resp = await axios.post(URL + 'payment/searchcard',{token:token,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 pay(prm) {
    try {
        // var resp = await axios.post(URL + 'payment/paymanual',prm);
        var resp = await axios.post(URL + 'PaymentV2/paymanual',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 delete_note(prm) {
    try {
        var resp = await axios.post(URL + 'payment/delete_note',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 edit_note(prm) {
    try {
        var resp = await axios.post(URL + 'payment/edit_note',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 selecttagihan(prm) {
    try {
       var resp = await axios.post(URL + 'payment/selecttagihan',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 selectpaymenttype(prm) {
    try {
       var resp = await axios.post(URL + 'payment/selectpaymenttype',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 selectsupplier(prm) {
    try {
       var resp = await axios.post(URL + 'payment/selectsupplier',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 selectcard(token) {
    try {
       var resp = await axios.post(URL + 'payment/selectbank',{token:token});
       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 selectedc(token) {
    try {
       var resp = await axios.post(URL + 'payment/selectaccount',{token:token});
       if (resp.status != 200) {
          return {
             status: "ERR",
             message: resp.statusText
          };
       }
       let data = resp.data;
       return data;
    } catch(e) {
       return {
          status: "ERR",
          message: e.message
       };
    }
 }
