var_org = organization.get("organization_id");
aaa = vendor_payment.get("payment_id");
amount = vendor_payment.getJSON("amount");
paymentnumber = vendor_payment.get("payment_number");
dateformatted = vendor_payment.getJSON("date_formatted");
refno = vendor_payment.getJSON("reference_number");
billID = vendor_payment.get("bills").get(0).get("bill_id");
// status=vendor_payment.get("bills").get(0).get("status");
// info status;
// info billID;
resp = invokeurl
[
url :"https://www.zohoapis.in/books/v3/vendorpayments/" + aaa + "?organization_id=" + var_org
type :GET
connection:"books"
];
// info resp;
item_list = List();
item_map = Map();
item_map.put("Payment_Amount",amount);
item_map.put("Payment_Date",zoho.currentdate);
item_map.put("Payment_Number",paymentnumber);
item_map.put("Reference_Number",refno);
item_list.add(item_map);
Head1 = Map();
otherParams = Map();
Head1.put("Payment_Details_Subform",item_list);
response = invokeurl
[
url :"https://www.zohoapis.in/creator/v2.1/data/dev07uat21/organic/report/All_Purchase_Order_Bills?Bill_Books_ID=" + billID
type :GET
connection:"creator"
];
info response;
var = response.get("data");
if(var.size() > 0)
{
creator_id = var.getJSON("ID");
getMap = Map();
item_map.put("Bills_ID",creator_id);
item_map.put("Zoho_Books_ID",aaa);
getpaymentResponse = zoho.creator.getRecords("dev07uat21","organic","Payment_Detail_Subform_Report","Zoho_Books_ID ==\"" + aaa + "\"",1,200,"creator");
newresponse = getpaymentResponse.getJson("data");
if(newresponse.size() > 0)
{
info "update";
/*update payment*/
updateotherMap = Map();
updateMap = Map();
updateMap.put("Payment_Amount",amount);
info "P" + updateMap;
updatePayment = zoho.creator.updateRecord("dev07uat21","organic","Payment_Detail_Subform_Report",newresponse.getJson("ID"),updateMap,updateotherMap,"creator");
info "UR " + updatePayment;
}
else
{
info "create";
/*Create payment*/
createPayment = zoho.creator.createRecord("dev07uat21","organic","Payment_Details_Subform",item_map,otherParams,"creator");
}
}
resp1 = invokeurl
[
url :"https://www.zohoapis.in/creator/v2.1/data/dev07uat21/organic/report/All_Purchase_Order_Bills?Bill_Books_ID=" + billID
type :GET
connection:"creator"
];
info "resp" + resp;
det = resp1.getJson("data");
// info "s" + det;
total = 0;
// if(det.size() > 0)
// {
// info "amount " + det.getJson("Paid_Amount");
// if(det.getJson("Paid_Amount") == "")
// {
// dt = 0;
// }
// else
// {
// dt = det.getJson("Paid_Amount");
// }
// newdt = dt.toNumber().round(2);
// info "s" + newdt;
// newamount = amount.toNumber().round(2);
// info "y" + newamount;
// total = newdt + newamount;
// info "total " + total;
// mps = Map();
// Other = Map();
// mps.put("Paid_Amount",total);
// // info mps;
// ids = det.getJson("ID");
// upcreatorrec = zoho.creator.updateRecord("dev07uat21","organic","All_Purchase_Order_Bills",ids,mps,Other,"creator");
// info "update rec" + upcreatorrec;
// }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter