[-] BO : Update Accounting geolocalization for France

This commit is contained in:
vSchoener
2012-03-09 14:36:43 +00:00
parent 63ac66958f
commit df3bd0e146
6 changed files with 67 additions and 25 deletions
+24 -14
View File
@@ -31,30 +31,29 @@ class AccountingCore
/** /**
* Default Values * Default Values
* * All key modification have to be changed into the localization pack and xml
* @TODO: Check to put the default value into the localization pack
* This configuration is applied for a specific shop * This configuration is applied for a specific shop
* *
* @var array * @var array
*/ */
public static $acc_conf = array( public static $acc_conf = array(
'customer_prefix' => '411', 'customer_prefix' => '',
'journal' => 'VE', 'journal' => '',
'account_length' => 13, 'account_length' => '',
'account_submit_shipping_charge' => '708510', 'account_submit_shipping_charge' => '',
'account_unsubmit_shipping_charge' => '708520', 'account_unsubmit_shipping_charge' => '',
'account_gift_wripping' => '', 'account_gift_wripping' => '',
'account_handling' => '' 'account_handling' => ''
); );
public static $acc_conf_cached = false; public static $acc_conf_cached = false;
/** /**
* Set an account number to a zone (will be refactoring for a dynamic use depending of the Controller) * Set an account number to a zone (will be refactoring for a dynamic use depending of the Controller)
* @var array $assoZoneShopList correspond to an associated list of id_zone - id_shop - num * @var array $asso_zone_shop_list correspond to an associated list of id_zone - id_shop - num
* @return bool To know if any modification in the database succeed * @return bool To know if any modification in the database succeed
*/ */
public static function setAccountNumberByZoneShop($assoZoneShopList) public static function setAccountNumberByZoneShop($asso_zone_shop_list)
{ {
$query = ' $query = '
REPLACE INTO`'._DB_PREFIX_.'accounting_zone_shop` REPLACE INTO`'._DB_PREFIX_.'accounting_zone_shop`
@@ -64,7 +63,7 @@ class AccountingCore
$values = ''; $values = '';
// Build the query for the update // Build the query for the update
foreach ($assoZoneShopList as $asso) foreach ($asso_zone_shop_list as $asso)
if (array_key_exists('id_zone', $asso) && if (array_key_exists('id_zone', $asso) &&
array_key_exists('id_shop', $asso) && array_key_exists('id_shop', $asso) &&
array_key_exists('num', $asso)) array_key_exists('num', $asso))
@@ -78,10 +77,10 @@ class AccountingCore
/** /**
* Add or update product accounting information for a product (will be refactoring for a dynamic use depending of the Controller) * Add or update product accounting information for a product (will be refactoring for a dynamic use depending of the Controller)
* @param array $assoProductZoneShop * @param array $asso_product_zone_shop
* @return mixed bool|array * @return mixed bool|array
*/ */
public static function saveProductAccountingInformations($assoProductZoneShop) public static function saveProductAccountingInformations($asso_product_zone_shop)
{ {
$query = ' $query = '
REPLACE INTO`'._DB_PREFIX_.'accounting_product_zone_shop` REPLACE INTO`'._DB_PREFIX_.'accounting_product_zone_shop`
@@ -89,7 +88,7 @@ class AccountingCore
VALUES %s'; VALUES %s';
$values = ''; $values = '';
foreach ($assoProductZoneShop as $asso) foreach ($asso_product_zone_shop as $asso)
if (array_key_exists('id_zone', $asso) && if (array_key_exists('id_zone', $asso) &&
array_key_exists('id_shop', $asso) && array_key_exists('id_shop', $asso) &&
array_key_exists('id_product', $asso) && array_key_exists('id_product', $asso) &&
@@ -155,6 +154,17 @@ class AccountingCore
return (!$key) ? self::$acc_conf : ((isset(self::$acc_conf[$key]) ? self::$acc_conf[$key] : false)); return (!$key) ? self::$acc_conf : ((isset(self::$acc_conf[$key]) ? self::$acc_conf[$key] : false));
} }
/**
* Update Accounting configuration
*
* @static
* @param $acc_conf
*/
public static function updateConfiguration($acc_conf)
{
Configuration::updateValue(Accounting::CONF_NAME, serialize($acc_conf));
}
/** /**
* Get the list of export done * Get the list of export done
* *
+25
View File
@@ -53,6 +53,7 @@ class LocalizationPackCore
$res &= $this->installConfiguration($xml); $res &= $this->installConfiguration($xml);
$res &= $this->installModules($xml); $res &= $this->installModules($xml);
$res &= $this->updateDefaultGroupDisplayMethod($xml); $res &= $this->updateDefaultGroupDisplayMethod($xml);
$res &= $this->installAccounting($xml);
if (!defined('_PS_MODE_DEV_') || !_PS_MODE_DEV_) if (!defined('_PS_MODE_DEV_') || !_PS_MODE_DEV_)
$res &= $this->_installLanguages($xml, $install_mode); $res &= $this->_installLanguages($xml, $install_mode);
@@ -75,6 +76,30 @@ class LocalizationPackCore
return true; return true;
} }
/**
* Install the default value for accounting
*
* @param $xml
* @return true
*/
protected function installAccounting($xml)
{
if (isset($xml->accounting->conf))
{
$acc_conf = Accounting::getConfiguration();
foreach ($xml->accounting->conf as $conf)
{
$attributes = $conf->attributes();
if (isset($attributes['name']) &&
isset($attributes['value']) &&
isset($acc_conf[(string)($attributes['name'])]))
$acc_conf[(string)($attributes['name'])] = (string)$attributes['value'];
}
Accounting::updateConfiguration($acc_conf);
}
return true;
}
protected function _installStates($xml) protected function _installStates($xml)
{ {
if (isset($xml->states->state)) if (isset($xml->states->state))
@@ -141,7 +141,7 @@ class AdminAccountingConfigurationControllerCore extends AdminController
foreach ($this->acc_conf as $name => $val) foreach ($this->acc_conf as $name => $val)
$this->acc_conf[$name] = Tools::getValue($name); $this->acc_conf[$name] = Tools::getValue($name);
Configuration::updateValue(Accounting::CONF_NAME, serialize($this->acc_conf)); Accounting::updateConfiguration($this->acc_conf);
Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token.'&update=true'); Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token.'&update=true');
} }
else if (Tools::getValue('update')) else if (Tools::getValue('update'))
@@ -59,11 +59,11 @@ class AdminAccountingManagementControllerCore extends AdminController
$shop['default_account_number'] = Configuration::get('default_account_number', null, null, $id_shop); $shop['default_account_number'] = Configuration::get('default_account_number', null, null, $id_shop);
ksort($shop['zones']); ksort($shop['zones']);
$zoneShopList = Accounting::getAccountNumberZoneShop($id_shop); $zone_shop_list = Accounting::getAccountNumberZoneShop($id_shop);
// Set Account number to the id_zone for the id_shop if exist // Set Account number to the id_zone for the id_shop if exist
foreach ($zoneShopList as $zoneShop) foreach ($zone_shop_list as $zone_shop)
$shop['zones'][$zoneShop['id_zone']]['account_number'] = $zoneShop['account_number']; $shop['zones'][$zone_shop['id_zone']]['account_number'] = $zone_shop['account_number'];
} }
$this->context->smarty->assign(array( $this->context->smarty->assign(array(
@@ -130,8 +130,6 @@ class AdminAccountingManagementControllerCore extends AdminController
$this->confirmations[] = $this->l('Account numbers have been updated'); $this->confirmations[] = $this->l('Account numbers have been updated');
else else
$this->errors[] = $this->l('Account Numbers could not be updated or added in the database'); $this->errors[] = $this->l('Account Numbers could not be updated or added in the database');
//$token = Tools::getValue('token') ? Tools::getValue('token') : $this->token;
//Tools::redirectAdmin(self::$currentIndex.'&token='.$token);
} }
} }
@@ -63,7 +63,7 @@ class AdminAccountingRegisteredNumberControllerCore extends AdminController
'title' => $this->l('Taxes Account number list'), 'title' => $this->l('Taxes Account number list'),
'list' => array()), 'list' => array()),
// Gift wrapping definition, for now Only one available using Configuration // Gift wrapping definition
'gift_wrapping' => array( 'gift_wrapping' => array(
'func_call' => 'getAccountingNumberConfiguration', 'func_call' => 'getAccountingNumberConfiguration',
'key' => 'account_gift_wripping', 'key' => 'account_gift_wripping',
@@ -74,7 +74,7 @@ class AdminAccountingRegisteredNumberControllerCore extends AdminController
'title' => $this->l('Gift wrapping account number list'), 'title' => $this->l('Gift wrapping account number list'),
'list' => array()), 'list' => array()),
// Submited shipping charge definition, for now Only one available using Configuration // Submited shipping charge definition
'submited_shipping_charge' => array( 'submited_shipping_charge' => array(
'func_call' => 'getAccountingNumberConfiguration', 'func_call' => 'getAccountingNumberConfiguration',
'key' => 'account_submit_shipping_charge', 'key' => 'account_submit_shipping_charge',
@@ -85,7 +85,7 @@ class AdminAccountingRegisteredNumberControllerCore extends AdminController
'title' => $this->l('Submited shipping charge account number list'), 'title' => $this->l('Submited shipping charge account number list'),
'list' => array()), 'list' => array()),
// Unsubmited shipping charge definition, for now Only one available using Configuration // Unsubmited shipping charge definition
'unsubmited_shipping_charge' => array( 'unsubmited_shipping_charge' => array(
'func_call' => 'getAccountingNumberConfiguration', 'func_call' => 'getAccountingNumberConfiguration',
'key' => 'account_unsubmit_shipping_charge', 'key' => 'account_unsubmit_shipping_charge',
@@ -127,7 +127,6 @@ class AdminAccountingRegisteredNumberControllerCore extends AdminController
{ {
$this->initToolbarTitle(); $this->initToolbarTitle();
$this->toolbar_btn = array(); $this->toolbar_btn = array();
} }
public function initContent() public function initContent()
@@ -144,7 +143,7 @@ class AdminAccountingRegisteredNumberControllerCore extends AdminController
} }
/** /**
* Return the gift wripping number set. * Return the value configuration requested.
* *
* @TODO : Add the possibility to check in all shop * @TODO : Add the possibility to check in all shop
* @param string $key of the Accounting configuration * @param string $key of the Accounting configuration
+10
View File
@@ -7,6 +7,16 @@
<language iso_code="fr" /> <language iso_code="fr" />
</languages> </languages>
<accounting>
<conf name="customer_prefix" value="411" />
<conf name="journal" value="VE" />
<conf name="account_length" value="13" />
<conf name="account_submit_shipping_charge" value="708510" />
<conf name="account_unsubmit_shipping_charge" value="708520" />
<conf name="account_gift_wripping" value="" />
<conf name="account_handling" value="" />
</accounting>
<taxes> <taxes>
<tax id="1" name="TVA FR 19.6%" rate="19.6" account_number="445711" /> <tax id="1" name="TVA FR 19.6%" rate="19.6" account_number="445711" />
<tax id="2" name="TVA FR 7%" rate="7" account_number="" /> <tax id="2" name="TVA FR 7%" rate="7" account_number="" />