Convert Sales Order to Invoice in custom function (code)
Hi..
I have tried to run this code
Unfortunately it didn't work
I am trying to convert a sales order into an invoice on the same date as the sales order
This is done when updating a specific field of the sales order
- respMap = zoho.books.getRecordById("Sales_Orders", input.soId.toLong());
- productDet = ifnull(respMap.get("product"),"");
- productList = productDet.toJSONList();
- pdlist = List();
- for each eachProd in productList
- {
- eachProdDet = eachProd.toMap();
- productDesc = ifnull(eachProdDet.get("Product Description"),"");
- quantity = ifnull(eachProdDet.get("Quantity"),"0");
- listPrice = (ifnull(eachProdDet.get("List Price"),"0.0")).toDecimal();
- netTotal = (ifnull(eachProdDet.get("Net Total"),"0.0")).toDecimal();
- linediscount = (ifnull(eachProdDet.get(("Discount")),"0.0")).toDecimal();
- total = (ifnull(eachProdDet.get("Total"),"0.0")).toDecimal();
- productId = ifnull(eachProdDet.get("Product Id"),"");
- linetax = (ifnull(eachProdDet.get("Tax"),"")).toDecimal();
- mp = map();
- mp.put("Product Id", productId);
- mp.put("Quantity", quantity);
- mp.put("List Price", listPrice);
- mp.put(("Discount"), linediscount);
- mp.put("Total", total);
- mp.put("Tax", linetax);
- mp.put("Net Total", netTotal);
- pdlist.add(mp);
- }
- paramap = map();
- paramap.put("Products", pdlist);
- paramap.put("Subject", ifnull(respMap.get("Subject"),""));
- paramap.put("CONTACTID", ifnull(respMap.get("CONTACTID"),""));
- paramap.put("Terms and Conditions", ifnull(respMap.get("Terms and Conditions"),""));
- paramap.put("Description", ifnull(respMap.get("Description"),""));
- paramap.put("Tax", (ifnull(respMap.get("Tax"),"0.0")).toDecimal());
- paramap.put("Adjustment", (ifnull(respMap.get("Adjustment"),"0.0")).toDecimal());
- paramap.put(("Discount"), (ifnull(respMap.get(("Discount")),"0.0")).toDecimal());
- paramap.put("Sub Total", (ifnull(respMap.get("Sub Total"),"0.0")).toDecimal());
- paramap.put("Grand Total", (ifnull(respMap.get("Grand Total"),"0.0")).toDecimal());
- paramap.put("Invoice Date", (ifnull(respMap.get("Order Date"),"0.0")).toDecimal());
- createResp = zoho.books.create("Invoices", paramap);
- return "Invoice created successfully";
Deliver unforgettable customer experiences
Deliver unforgettable customer experiences
New to Zoho Marketing Plus?
Everything you need to run your marketing
New to Zoho Marketing Plus?
Everything you need to run your marketing
Zoho Desk Resources
-
Desk Community Learning Series
-
-
-
-
-
-
-
-
-
Zoho TeamInbox Resources
Zoho DataPrep Resources
Zoho CRM Plus Resources
Zoho Books Resources
Zoho Subscriptions Resources
Zoho Projects Resources
Zoho Sprints Resources
Qntrl Resources
Zoho Creator Resources
Zoho WorkDrive Resources
Zoho Campaigns Resources
Zoho CRM Resources
Zoho Show Resources
Writer Get Started. Write Away!
Writer is a powerful online word processor, designed for collaborative work.