Pulling address from account within a custom function in Deals

Pulling address from account within a custom function in Deals

I have this function and I need to pull the billing and shipping address from accounts and put it in the quote that is created when this function is run, you can see the section that I tried to put in there before I realized the addresss isn't in deals, so it can't pull what isn't there.

potDetails = zoho.crm.getRecordById("Deals",potIdStr.toLong());
data = Map();
if(ifnull(potDetails.get("Contact_Name"),"") != "")
{
contact = ifnull(potDetails.get("Contact_Name"),"").get("id");
data.put("Contact_Name",contact);
}
if(ifnull(potDetails.get("Account_Name"),"") != "")
{
account = ifnull(potDetails.get("Account_Name"),"").get("id");
data.put("Account_Name",account);
}
RelatedProducts = ifnull(potDetails.get("Subform_4"),"");
info "Sub " + RelatedProducts.size();
product_items = List();
for each  product in RelatedProducts
{
proid = product.get("Product").get("id");
proname = product.get("Product").get("name");
price = ifnull(product.get("Customer_Price"),"0.0").toDecimal();
lineitem = Map();
lineitem.put("Product_Name",proid);
lineitem.put("Description",ifnull(product.get("Description_1"),""));
lineitem.put("Quantity",ifnull(product.get("QTY"),"0.0").toDecimal());
lineitem.put("Customer_Price",ifnull(product.get("Customer_1"),"0.0").toDecimal());
lineitem.put("Reseller_Price",ifnull(product.get("Reseller_1"),"0.0").toDecimal());
lineitem.put("MSRP",ifnull(product.get("MSRP_1"),"0.0").toDecimal());
lineitem.put("Shipping",ifnull(product.get("Shipping_1"),"0.0").toDecimal());
lineitem.put("Net_total",ifnull(product.get("Subtotal"),"0.0").toDecimal());
product_items.add(lineitem);
}
dataList = List();
data.put("Quoted_Items",product_items);
data.put("Subject",ifnull(potDetails.get("Deal_Name"),""));
data.put("Deal_Name",potIdStr.toLong());
data.put("Owner",ifnull(potDetails.get("Owner"),""));
data.put("Description",ifnull(potDetails.get("Description"),""));
// THIS IS THE PART I PUT IN THAT DIDN'T WORK
// data.put("Billing_Street",ifnull(potDetails.get("Billing_Street"),""));
// data.put("Billing_State",ifnull(potDetails.get("Billing_State"),""));
// data.put("Billing_City",ifnull(potDetails.get("Billing_City"),""));
// data.put("Billing_Code",ifnull(potDetails.get("Billing_Code"),""));
// data.put("Billing_Country",ifnull(potDetails.get("Billing_Country"),""));
// data.put("Shipping_Street",ifnull(potDetails.get("Shipping_Street"),""));
// data.put("Shipping_State",ifnull(potDetails.get("Shipping_State"),""));
// data.put("Shipping_City",ifnull(potDetails.get("Shipping_City"),""));
// data.put("Shipping_Code",ifnull(potDetails.get("Shipping_Code"),""));
// data.put("Shipping_Country",ifnull(potDetails.get("Shipping_Country"),""));
// END WRONG CODE
dataList.add(data);
param = Map();
param.put("data",dataList);
info param;
CreateResp = invokeurl
[
type :POST
parameters:param.tostring()
connection:"dealtoquote"
];
info CreateResp;
// CreateResp = invokeurl
// [
// type :POST
// parameters:param + ""
// connection:"dealtoquote"
// ];
// info "Paramap--->" + param;
// info "CreateResp--->" + CreateResp;
newid = CreateResp.getJson("data");
id = newid.getJson("details").getjson("id");
info id;
if(newid != "")
{
return "New Quote created successfuly";
}
else
{
return "Quote could not be created. Missing product details in Deal.";
}