How to fetch data from Zoho Books to Zoho Creator? 200+ records - zoho

I need to fetch Data from Zoho Books to Zoho Creator.
How to get Invoice, Estimate, Customer data?
How to fetch 200+ records?
Through single API call we will get only 200 records.

First we have to make a connection from Zoho Creator to Zoho Books ,
For that Go to Zoho Creator/ Setup/ Connection and Make a connection (Select Zoho books module only).
Now you have to go to Zoho Books and in settings you will find User and Roles, Assign user to that email in which you want to fetch the data. Make that email Role as Admin.
you need to accept the invitation from Zoho books.
For example here I am fetching Invoice module from Zoho Books to Zoho Creator.
void invoice()
{
organizationID = input org_id number;
invlist = List();
pageList = {1,2,3};
itemList = List();
customerList = List();
i = 0;
for each page in pageList
{
i = i + 1;
invoices = invokeurl
[
url :"https://books.zoho.in/api/v3/invoices?page=" + page + "&per_page=200&organization_id=" + organizationID
type :GET
connection:"zohobooks"
];
invoices = invoices.get("invoices");
info "invoices" + invoices;
for each findItems in invoices
{
info "findItems" + findItems;
invoiceID = findItems.get("invoice_number");
customerID = findItems.get("customer_name");
balanceID = findItems.get("balance");
dateID = findItems.get("date");
amountID = findItems.get("total");
itemID = findItems.get("line_items");
statusID = findItems.get("status");
// Invoice is form name, We are inserting data in that form
insert into Invoice
[
Added_User=zoho.loginuser
Invoice_Number=invoiceID
Customer_Name=customerID
Balance=balanceID
Date_field=dateID
Amount=amountID
Status=statusID
]
}
}
info invlist;
}

Please check related to Zoho License Subscription usage and restriction.
The link is
Zoho Help Link
If you have exhausted the usage limit take help from Zoho for increasing your usage limit as per your company requirement.

Related

Laravel left join check if a conditon is greater than a count

I would like to check a limit in number of user payment where a limit is set on user table.
So i have the following database structure
table user
id,name,...,pay_limit
and payment table
table payment
id, user_id, payment_ref
So i have created the following code
$query = User::query();
//other stuff
$query->leftJoin('payment','payment.user_id','=','user.id')
//stuck
Am stuck on how to check if the totals of payments on a user is not greater than the user pay_limit
How can i check the above in a query
Simple with relations. Suppose payment model is Payment and payment amount in payment_amount column
class User extends Model{
public function payments()
{
return $this->hasMany(Payment::class);
}
public function getIsOverLimitedAttribute(): bool
{
//if you check amount
return $this->payments()->sum('payment_amount') > $this->pay_limit;
//or if you check count of payments
return $this->payments()->count() > $this->pay_limit;
}
public function scopeNoOverLimited($query){
return $query->withCount('payments')->having('payments_count', '<', $this->pay_limit);
}
}
And use
if($user->isOverLimited){
//do stuff
}
Or get not over limited users:
User::noOverLimited()->get();
In terms of performance (since you want to be able to return all such users), the best approach is to store a summary column in your users table... total_payment
You can update all current users maybe via a migration file as such:
$table->integer('total_payment')->unsigned()->nullable();
DB::update("update users set total_payment = ('select count(id) from payments where user_id = id')");
Then to get all such users, you can do:
User::whereRaw('total_payment > pay_limit')->get();
Then add a PaymentObserver to increase the total_payment on new successful payments.
If you don't have access to modify the table, you can still use a scope like, but this can be performance intensive if being run all the time such as on user login without caching:
public function scopeAboveLimit($query)
{
$id = $this->id;//user id
return $query->whereRaw("pay_limit < ('select count(id) from payments where user_id = $id')");
}

Zoho creator integration with zoho books

So i recently started working with the Zoho platform so im quite new to it, ive been assigned the following task:
Build a Customer form on zoho creator with various different fields (name, company name, billing address and some extra custom fields.
Integrate the data from the form to the zoho books platform.
Basically, a user submit the form and on submission a new record on zoho books its created.
enter image description here
enter image description here
My issue, when the form is submitted theres no new customer on zoho books.
Can someone help me please
Thank You
cpList = List();
firstName = input.Contact_Name.first_name;
lastName = input.Contact_Name.last_name;
contactName = firstName + " " + lastName;
contactMap = Map();
contactMap.put("contact_name",contactName);
contactMap.put("company_name",input.Company_Name);
contactMap.put("website",input.Website);
billingMap = Map();
billingMap.put("zip",input.Billing_Address.postal_Code);
billingMap.put("country",input.Billing_Address.country);
billingMap.put("address",input.Billing_Address.address_line_1);
billingMap.put("street2",input.Billing_Address.address_line_2);
billingMap.put("city",input.Billing_Address.district_city);
billingMap.put("state",input.Billing_Address.state_province);
contactP = Map();
contactP.put("first_name",firstName);
contactP.put("last_name",lastName);
contactP.put("designation",input.Designation);
contactP.put("department",input.Department);
contactP.put("contact_salutation","Mr/Mrs");
contactP.put("mobile",input.Mobile_Phone);
contactP.put("phone",input.Phone_Number);
contactP.put("email",input.Email);
contactP.put("is_primary_contact",true);
contactMap.put("billing_address",billingMap);
cpList.add(contactP);
contactMap.put("contact_persons",cpList);
params = Map();
params.put("JSONString",contactMap);
createContact = invokeurl
[
url :"https://books.zoho.eu/api/v3/contacts?organization_id="
type :POST
parameters:params
connection:"books"
];
This was the way i was able to make it work.
There might need to be an authentication token for 'books' included in the headers. Check the books.zoho API documentation to see if there is information regarding creating and using an API token.
Also by adding detailed:true to the invokeurl call you can get some visibility into any information or error-messages in the response from invokeurl. Here is some example code:
response = invokeurl
[
url : "https://books.zoho.eu/api/v3/contacts?orgainization_id=20077348839
type :POST
parameters:datamap
connection:"books_contact_auth"
detailed:true
];
// To see all headers and content
info response;

Zoho creator + zoho books integration

So been given this recent task, create a form for new customers and integrate it with zoho books.
I know almost nothing about Deluge or zoho platform.
anyway this is what i have achieved so far:
1-Create the form ✅
2-On form submission->create new contact on zoho books ❌
Here is my form:
I managed to create the new contact on zoho books but i am not able to push the last 3 fields to zoho books("Legal Document", "Accounts Document" and "Tax Document").
This last 3 fields have a file attached.
Heres the script:
cpList = List();
firstName = input.Contact_Name.first_name;
lastName = input.Contact_Name.last_name;
contactName = firstName + " " + lastName;
contactMap = Map();
contactMap.put("contact_name",contactName);
contactMap.put("company_name",input.Company_Name);
contactMap.put("website",input.Website);
contactMap.put("twitter",input.Twitter);
/////////
//contactMap.put("skype_name",input.Skype_Name);
billingMap = Map();
billingMap.put("zip",input.Billing_Address.postal_Code);
billingMap.put("country",input.Billing_Address.country);
billingMap.put("address",input.Billing_Address.address_line_1);
billingMap.put("street2",input.Billing_Address.address_line_2);
billingMap.put("city",input.Billing_Address.district_city);
billingMap.put("state",input.Billing_Address.state_province);
contactP = Map();
contactP.put("salutation",input.Contact_Name.prefix);
contactP.put("first_name",firstName);
contactP.put("last_name",lastName);
contactP.put("designation",input.Designation);
contactP.put("department",input.Department);
contactP.put("contact_salutation","Mr/Mrs");
contactP.put("mobile",input.Mobile_Phone);
contactP.put("phone",input.Phone_Number);
contactP.put("email",input.Email);
//Skype does not work here or on the contactMap
//contactP.put("skype_name",input.Skype_Name);
contactP.put("is_primary_contact",true);
contactMap.put("billing_address",billingMap);
// Custom Fields
cpList.add(contactP);
cFields = List();
cFields.add({"index":"1","value":input.Registration_Number});
cFields.add({"index":"2","value":input.Industry});
cFields.add({"index":"3","value":input.VAT});
//next doesn’t work
//cFields.add({"index":"4","value":input.Legal_Form});
cFields.add({"index":"5","value":input.Tax_Dossier_No});
cFields.add({"index":"6","value":input.Legal_Rep_SSN_No});
cFields.add({"index":"7","value":input.Balance_Sheet.toDecimal()});
cFields.add({"index":"8","value":input.Annual_Turnover.toDecimal()});
These are the fields :
//cFields.add({"index":"9","value":input.Legal_Document});
//cFields.add({"index":"10","value":input.Accounts_Document});
//cFields.add({"index":"11","value":input.Tax_Document});
contactMap.put("custom_fields",cFields);
contactMap.put("contact_persons",cpList);
params = Map();
params.put("JSONString",contactMap);
createContact = invokeurl
[
url :"https://books.zoho.eu/api/v3/contacts?organization_id=..."
type :POST
parameters:params
connection:"..."
];
Somehow, if i dont use the last 3 fields i can add a new contact on zoho books,
but if i add the last 3 fields the call is not made, no new contact on zoho books
My issu, how can i upload the files to zoho books?
Thank You
You have to create a connection from zoho Oauth. That connection will integrate your creator and books. You have to enable insert from zoho creator to zoho books in that connection.
Put here the connection name in connection webhook. You need must add organization id. createContact = invokeurl [ url :"https://books.zoho.eu/api/v3/contacts?organization_id=..." type :POST parameters:params connection:"..." ];
The last 3 fields are File type and you must send them as attachements to your invokeurl.

How to fetch data from Zoho Inventory into Zoho Creator

response = zoho.inventory.getRecords("Item","i inserted ID in here");
var = response.get("Product Name");
for each hey in var
{
insert into SKU #SKU is a form in Zoho Creator
[
Added_User=zoho.loginuser
Item_Name=hey #Item_Name is my field in SKU
]
}
Above code not fetching the Product Name Data from Inventory into Zoho Creator
To serarch in Inventory you must use:
<response> = zoho.inventory.getRecords(<module>, <org_id>, [<criteria_map>], [<connection>]);
The module is Items. In "Settigs" -> "Profile organization" you can obtain your org_id. It returns a map and you have to iterate over response.get("Items")
I you want to get a single item and you have the ID you can use the next function
<response> = zoho.inventory.getRecordsByID(<module>, <org_id>, <record_id>, [<connection>]);
If you want to view the reponse, you can use "info response;" or "alert response;" depend where you are using it.
Are you sure, you are using the correct link name of 'Product Name' field, try 'Product_Name' instead.
Please Used the Correct API Name for fetch out in Map.
getRecords()- used to get all records (200) at time & for Individual records try this:getRecordsByID()
response = zoho.inventory.getRecords("Item","i inserted ID in here");
Org id is missing in this get record code.
var = response.get("Product Name");
make sure you are using a correct api name of the product name

Magento: Retrieve payment information with Authorize.net gateway

I am using Authorize.net payment gateway in my magento based shopping cart. It is Authorize Only, which means I first authorize the card, an after shipping product to customer I captures the amount.
Authorize paygate stores information like cc_exp_month, cc_exp_year inside "additional_information" field in table sales_flat_order_payment in serialize form.
Is there any method in magento to simply retrieve these values (cc_exp_month, cc_exp_year) from additional_information column?
I believe the next 2 lines will do the trick:
$ccExpMonth = $order->getPayment()->getAdditionalInformation('cc_exp_month');
$ccExpYear = $order->getPayment()->getAdditionalInformation('cc_exp_year');
Of course $order is instance of Mage_Sales_Model_Order.
For reference you also can check: how to get payment information on Magento?
Is there any method in magento to simply retrieve these values (cc_exp_month, cc_exp_year) from additional_information column?
No, there isn't. You need to drill into the additional_information array. Here's a method I added to retrieve the cc_type value. It can easily be adjusted to return all the data or just another piece:
public function getCcType(Mage_Sales_Model_Order_Payment $payment)
{
if(count($payment->getAdditionalInformation()))
{
foreach($payment->getAdditionalInformation() as $auth_cards)
{
foreach($auth_cards as $ac_id)
{
if(isset($ac_id['cc_type']))
{
return $ac_id['cc_type'];
}
}
}
}
return false;
}
Try
$order_id = 113
$order = Mage::getModel('sales/order')->load($order_id);
If info is stored cc_exp_month and cc_exp_year
$ccExpMonth = $order->getPayment()->getCcExpMonth();
$ccExpYear = $order->getPayment()->getCcExpYear();
If info is stored in Additional Info
$ccExpMonth = $order->getPayment()->getAdditionalInformation('cc_exp_month');
$ccExpYear = $order->getPayment()->getAdditionalInformation('cc_exp_year');

Resources