Items to Books-Mutiple ORG

PHOTO EMBED

Fri Apr 11 2025 04:21:27 GMT+0000 (Coordinated Universal Time)

Saved by @Pooja

void Integrations_to_books.ItemsToBooks_New(int itmid)
{
	fet_itm = Item_Master[ID == input.itmid];
	fetorg = Organization_Master[Organization_Code == fet_itm.Organization_Code.Organization_Code];
	orgid = fetorg.Organization_Code;
	fetapp = Approval[Item_ID.Item_Code == fet_itm.Item_Code];
	app = Approval[Organization_Name == fet_itm.Organization_Name && Item_ID.Item_Code == fet_itm.Item_Code];
	fet_itm.Status="Active";
	if(fet_itm.Item_Type == "Service")
	{
		mattype = "service";
	}
	else
	{
		mattype = "goods";
	}
	itmmap = Map();
	itmmap.put("name",fet_itm.Item_Name);
	itmmap.put("sku",fet_itm.Item_Code);
	itmmap.put("product_type",mattype);
	itmmap.put("unit",fet_itm.UOM);
	if(fet_itm.Selling_Price != null)
	{
		itmmap.put("rate",ifnull(fet_itm.Selling_Price,0.00));
		itmmap.put("description",fet_itm.Selling_Description);
		itmmap.put("account_name",fet_itm.Account.Accounts_Type);
		//itmmap.put("purchase_description",fet_itm.Specification);
	}
	if(fet_itm.Cost_Price != null)
	{
		itmmap.put("purchase_rate",ifnull(fet_itm.Cost_Price,0.00));
		itmmap.put("purchase_description",fet_itm.Purchase_Description);
		itmmap.put("account_name",fet_itm.Account.Accounts_Type);
		//itmmap.put("purchase_description",fet_itm.Specification);
	}
	if(fetapp.Do_You_want_to_create_Item_for_other_organization == "No")
	{
		response_books = invokeurl
		[
			url :"https://www.zohoapis.in/books/v3/items?organization_id=" + orgid
			type :POST
			parameters:itmmap.toString()
			connection:"books"
		];
		info response_books;
		for each  rec1 in app.Organization_Name
		{
			if(0 == response_books.get("code"))
			{
				contect_Data = response_books.get("item");
				zbid = contect_Data.get("item_id");
			}
			// 			ins = insert into Item_Master_Books_Details
			// 			[
			// 				Type_field="Item"
			// 				Added_User=zoho.loginuser
			// 				Organization_Name=rec1.ID
			// 				Item_Master_ID=fet_itm.ID
			// 				Organization_Code=rec1.ID
			// 				Item_Books_ID=zbid
			// 			];
		}
	}
	if(fetapp.Do_You_want_to_create_Item_for_other_organization == "Yes")
	{
		for each  rec in app.Organization_Name
		{
			org = rec.Organization_Code;
			resp = invokeurl
			[
				url :"https://www.zohoapis.in/books/v3/items?organization_id=" + org
				type :POST
				parameters:itmmap.toString()
				connection:"books"
			];
			info resp;
			if(0 == resp.get("code"))
			{
				contect_Data = resp.get("item");
				zbid = contect_Data.get("item_id");
			}
			// 			ins = insert into Item_Master_Books_Details
			// 			[
			// 				Type_field="Item"
			// 				Added_User=zoho.loginuser
			// 				Organization_Name=rec.ID
			// 				Item_Master_ID=fet_itm.ID
			// 				Organization_Code=rec.ID
			// 				Item_Books_ID=zbid
			// 			];
		}
	}
	//266977000000445214
}
content_copyCOPY