dev-master
9999999-dev https://github.com/kairosagency/ZohoInvoiceConnectorBundleZoho invoice bundle for symfony2
LGPL-3.0
The Requires
The Development Requires
by t0k4rt
symfony2 bundle zoho zoho invoice
Wallogit.com
2017 © Pedro Peláez
Zoho invoice bundle for symfony2
This php 5.4+ bundle is aimed at easing the integration of zoho invoice api in a symfony2 app., (*1)
It currently handles, contacts / customers, items and invoices., (*2)
This bundle was create to delegate our app invoice management to zoho invoice. We wanted to connect stuff from our backoffice to zoho invoice for example : * our users are connected to zoho contacts * our plans are connected to zoho items, (*3)
In order to achieve that we built a collection of traits that include all the needed elements in your local database and implemented lifecycle events to synchronize local object with zoho remote objects., (*4)
When you'll persist a connected entity (eg: an user), the bundle will make an api call to create a remote object (eg : a contact) on zoho side, then it will get the zoho object id and store this reference in your database., (*5)
Each time you'll make changes to your entity, it will be synced with zoho. When an api call fails, the error messages are logged as error in your logs and the corresponding entity has a "synced" flag set to false (if the api call is successful, the flag is set tu true)., (*6)
Add first in your config.yml these informations :, (*7)
kairos_zoho_invoice_connector:
auth_token: your auth token (mandatory)
organization_id: your org id (mandatory)
default_tax_id: default tax id (optional)
Then add your bundle in your AppKernel.php, (*8)
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
...
new Kairos\ZohoInvoiceConnectorBundle\KairosZohoInvoiceConnectorBundle(),
...
);
....
}
}
In your user entity which should correspond to your customer, add the corresponding trait :, (*9)
namespace Acme\AcmeBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Kairos\ZohoInvoiceConnectorBundle\Model as ZohoInvoiceConnector;
/**
* @ORM\Table(name="user")
* @ORM\Entity
*/
class User
{
use ZohoInvoiceConnector\Contact\ContactConnector;
....
}
In your product entity which should correspond to zoho items, add the corresponding trait :, (*10)
namespace Acme\AcmeBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Kairos\ZohoInvoiceConnectorBundle\Model as ZohoInvoiceConnector;
/**
* @ORM\Table(name="product")
* @ORM\Entity
*/
class Product
{
use ZohoInvoiceConnector\Item\ItemConnector;
....
}
In your invoice entity which should correspond to zoho invoices, add the corresponding trait :, (*11)
namespace Acme\AcmeBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Kairos\ZohoInvoiceConnectorBundle\Model as ZohoInvoiceConnector;
/**
* @ORM\Table(name="invoice")
* @ORM\Entity
*/
class Invoice
{
use ZohoInvoiceConnector\Invoice\InvoiceConnector;
....
}
To create an invoice :, (*12)
// get a product $product = ..... // get a customer $user = ... // create an invoice $invoice = new Invoice(); $invoice ->addItem(array('item_id' => $product->getZohoItemId(), 'quantity' => 1)) ->setZohoCustomerId($user->getZohoContactId()) ->addZohoContactPerson($user->getZohoContactPersonId()) ->setSendInvoice(true); // will send and email with the invoice to the contact person // then persist and flush $em->persist($invoice); $em->flush();
Sometimes zoho sync will fail, so your entity will have its "synced" set to false. You can use symfony command "php app/console kairos:zohoinvoiceconnector:sync" to trigger a manual synchronization with zoho invoice api on all unsynced entities., (*13)
Zoho invoice bundle for symfony2
LGPL-3.0
symfony2 bundle zoho zoho invoice