Italian Tax Code ('Codice Fiscale' or 'Fiscal Code' 'Codice Fiscale e Partita IVa') for Magento

The Codice Fiscale or Italian Tax Code is a Tax Identification Number used in Italy for Natural Persons or Companies.

This Tax Code in Italy is an alphanumeric code of 16 characters, and serves to identify unambiguously individuals residing in Italy irrespective of residency status or companies doing business in Italy. Designed by and for the Italian Tax Office, it is now used for several other purposes, e.g. uniquely identifying individuals in the health system, or natural persons who act as parties in private contracts.

In case your Magento Ecommerce Store is in requirement to collect and validate the Codice Fiscale for customer accounts and purchases this extension will provide the related necessary functionality.

  1. Take your Magento Shop offline in case you are installing on your Production System. In case during installation your Magento Store is activated the installation may become incomplete and error messages or malfunctions may result.

  2. Unpack the contents of the package and copy the content into the home directory of your Magento installation on your server:
    The Installation Package contains a directory structure that already holdes the individual files correct positions, and that is relative to the Magento Store's home directory (or installation path) on your server.
    If your Magento Store is installed in /home/www/magento then your home directory is to show a app subdirectory (as in the installation package).
    Extract the content of the Archive (or upload its content) into the home directory of your Magento Store, the head subdirectories of the Installation Package shall match the subdirectory structure of the home directory (as a check).

  3. If you are using Caching in your Magento Store, login into your Magento Administration and refresh your Cache: System » Cache Management » All Cache » Refresh.
  4. Continue to read here to make the initial configuration of your Magento Store to work with this extension.



Upgrading

  1. Take your Magento Shop offline in case you are upgrading your Production System. In case during upgrade your Magento Store is activated the upgrade may become incomplete and error messages or malfunctions may result.

  2. Backup your Magento installation, or at least backup the folder app/code/local/Pisc/EuvatFiscalCode for saving any current installed version of this extension.
  3. Delete the folder app/code/local/Pisc/EuvatFiscalCode to ensure correct updating of store resources required by the extension.
  4. Unpack the contents of the package and upload the content into the home directory of your Magento installation on your server.
  5. Alternatively you may just unpack the files in app/code/local/Pisc/EuvatFiscalCode and app/etc/modules for the main extension files, and update any template related files later manually.
  6. If you are using Caching in your Magento Store, login into your Magento Administration and refresh your Cache: System » Cache Management » All Cache » Refresh.



For certain eCommerce Applications in Italy, or with italian customers, you may need to be required to collect the Italian Fiscal Code (Codice Fiscale e Partita IVa) for the Customer Account or during Checkout. This Magento extension is adding this feature to your store:

It is able to collect the type of Legal Entity (Natural Person or Company) and the Italian Fiscal Code on following store pages:

  • Customer Registration Page
  • Addresses in the Customer Account
  • Checkout Page
  • Customer Account Page in the Administrator

The Italian Fiscal Code is also validated by a pattern validation to ensure integrity of the collected Fiscal Code.

For more about this read here on the Italian Fiscal Code Card, for testing you may create your individual Italian Fiscal Code here.

The configuration options for the Codice Fiscale (Italian Fiscal Code) are located in System » Config » Tax:

On the individual configuration options:

Use Fiscal Code

Enables or disables the Fiscal Code for the current store, website or default configuration. This allows to use the extension on a store related basis when needed in a multi-store environment.

Use for Billing Address Countries

The form elements on the Codice Fiscale (Italian Fiscal Code) are shown for the selected Billing Address Countries, if the Billing Address Country is not one of the selected countries then the related form element is hidden.

Defaults to Italy.

For Natural Person

Sets if the Fiscal Code is Optional or Required for the Legal Entity of a Natural Person.

For Company

Sets if the Fiscal Code is Optional or Required for the Legal Entity of a Company.

The following functions are added to the Administrator backend:

Customer Account - Addresses

If the Billing Address of the Customer Account is set to one of the countries for which the Fiscal Code is optional or required, the related fields to select the Legal Entity (Natural Person or Company) and the enter the Fiscal Code:

To have the Codice Fiscale (Italian Fiscal Code) included in the customer and checkout related address fields the following template files require modification as shown here.

In general the Codice Fiscal for Magento extension is providing an template Widget to use in combination with the Customer Address fields for the customer account and the checkout process:

Fiscal Code template widget code

<?php
$_fiscalcode = $this->getLayout()->createBlock('euvatfiscalcode/widget_fiscalcode');
if ($_fiscalcode && $_fiscalcode->isEnabled()) {
   echo $_fiscalcode->setObject($this->getAddress())->toHtml();
}
?>

Use the Template Widget in the following forms:

Customer Registration Form

app/design/frontend/.../template/persistent/customer/form/register.phtml

<!-- Around line #50: -->
 
<?php if($this->getShowAddressFields()): ?>
    <div class="fieldset">
        <input type="hidden" name="create_address" value="1" />
        <h2 class="legend"><?php echo $this->__('Address Information') ?></h2>
        <p class="legend"><?php echo $this->__('Please enter your Address which will be your default Billing and Shipping Address for your orders:') ?></p>
        <ul class="form-list">
 
	    <!-- Adding the Fiscal Code Form Element -->
	    <?php $_fiscalcode = $this->getLayout()->createBlock('euvatfiscalcode/widget_fiscalcode') ?>
            <?php if ($_fiscalcode->isEnabled()): ?>
            <li class="wide">
                <?php echo $_fiscalcode->setObject($this->getFormData())->toHtml() ?>
            </li>
            <?php endif; ?>
 
            <li class="fields">
                <div class="field">
                    <label for="company"><?php echo $this->__('Company') ?></label>
                    <div class="input-box">
                        <input type="text" name="company" id="company" value="<?php echo $this->escapeHtml($this->getFormData()->getCompany()) ?>" title="<?php echo $this->__('Company') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('company') ?>" />
                    </div>
                </div>
            </li>



Customer Account Address Edit Form

app/design/frontend/.../template/customer/address/edit.phtml

<!-- Around line #46: -->
 
<h2 class="legend"><?php echo $this->__('Contact Information') ?></h2>
<ul class="form-list">
    <li class="fields">
        <?php echo $this->getNameBlockHtml() ?>
    </li>
 
	<!-- Adding the Fiscal Code Form Element -->
    <?php $_fiscalcode = $this->getLayout()->createBlock('euvatfiscalcode/widget_fiscalcode') ?>
    <?php if ($_fiscalcode && $_fiscalcode->isEnabled()): ?>
        <?php echo $_fiscalcode->setObject($this->getAddress())->toHtml() ?>
    <?php endif; ?>
 
    <li class="wide">
        <div class="field">
            <label for="company"><?php echo $this->__('Company') ?></label>
            <div class="input-box">
                <input type="text" name="company" id="company" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Company')) ?>" value="<?php echo $this->escapeHtml($this->getAddress()->getCompany()) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('company') ?>" />
            </div>
        </div>
    </li>



Magento Onepage Checkout: Billing Address Form

app/design/frontend/.../template/checlout/onepage/billing.phtml

<!-- Around line #38: -->
 
<li id="billing-new-address-form"<?php if ($this->customerHasAddresses()): ?> style="display:none;"<?php endif; ?>>
    <fieldset>
        <input type="hidden" name="billing[address_id]" value="<?php echo $this->getAddress()->getId() ?>" id="billing:address_id" />
        <ul>
            <li class="fields"><?php echo $this->getLayout()->createBlock('customer/widget_name')->setObject($this->getAddress()->getFirstname() ? $this->getAddress() : $this->getQuote()->getCustomer())->setForceUseCustomerRequiredAttributes(!$this->isCustomerLoggedIn())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?></li>
 
    <!-- Adding the Fiscal Code Form Element -->
    <?php $_fiscalcode = $this->getLayout()->createBlock('euvatfiscalcode/widget_fiscalcode') ?>
    <?php if ($_fiscalcode->isEnabled()): ?>
            <li class="wide">
                <?php echo $_fiscalcode->setObject($this->getAddress())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?>
            </li>
    <?php endif; ?>