diff --git a/classes/Accounting.php b/classes/Accounting.php
index cb217f071..38a17b852 100644
--- a/classes/Accounting.php
+++ b/classes/Accounting.php
@@ -31,30 +31,29 @@ class AccountingCore
/**
* Default Values
- *
- * @TODO: Check to put the default value into the localization pack
+ * All key modification have to be changed into the localization pack and xml
* This configuration is applied for a specific shop
*
* @var array
*/
public static $acc_conf = array(
- 'customer_prefix' => '411',
- 'journal' => 'VE',
- 'account_length' => 13,
- 'account_submit_shipping_charge' => '708510',
- 'account_unsubmit_shipping_charge' => '708520',
+ 'customer_prefix' => '',
+ 'journal' => '',
+ 'account_length' => '',
+ 'account_submit_shipping_charge' => '',
+ 'account_unsubmit_shipping_charge' => '',
'account_gift_wripping' => '',
- 'account_handling' => ''
+ 'account_handling' => ''
);
public static $acc_conf_cached = false;
/**
* 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
*/
- public static function setAccountNumberByZoneShop($assoZoneShopList)
+ public static function setAccountNumberByZoneShop($asso_zone_shop_list)
{
$query = '
REPLACE INTO`'._DB_PREFIX_.'accounting_zone_shop`
@@ -64,7 +63,7 @@ class AccountingCore
$values = '';
// Build the query for the update
- foreach ($assoZoneShopList as $asso)
+ foreach ($asso_zone_shop_list as $asso)
if (array_key_exists('id_zone', $asso) &&
array_key_exists('id_shop', $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)
- * @param array $assoProductZoneShop
+ * @param array $asso_product_zone_shop
* @return mixed bool|array
*/
- public static function saveProductAccountingInformations($assoProductZoneShop)
+ public static function saveProductAccountingInformations($asso_product_zone_shop)
{
$query = '
REPLACE INTO`'._DB_PREFIX_.'accounting_product_zone_shop`
@@ -89,7 +88,7 @@ class AccountingCore
VALUES %s';
$values = '';
- foreach ($assoProductZoneShop as $asso)
+ foreach ($asso_product_zone_shop as $asso)
if (array_key_exists('id_zone', $asso) &&
array_key_exists('id_shop', $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));
}
+ /**
+ * 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
*
diff --git a/classes/LocalizationPack.php b/classes/LocalizationPack.php
index 19eb68ce1..f1d0129ed 100644
--- a/classes/LocalizationPack.php
+++ b/classes/LocalizationPack.php
@@ -53,6 +53,7 @@ class LocalizationPackCore
$res &= $this->installConfiguration($xml);
$res &= $this->installModules($xml);
$res &= $this->updateDefaultGroupDisplayMethod($xml);
+ $res &= $this->installAccounting($xml);
if (!defined('_PS_MODE_DEV_') || !_PS_MODE_DEV_)
$res &= $this->_installLanguages($xml, $install_mode);
@@ -75,6 +76,30 @@ class LocalizationPackCore
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)
{
if (isset($xml->states->state))
diff --git a/controllers/admin/AdminAccountingConfigurationController.php b/controllers/admin/AdminAccountingConfigurationController.php
index 9e658533c..91115f6a2 100644
--- a/controllers/admin/AdminAccountingConfigurationController.php
+++ b/controllers/admin/AdminAccountingConfigurationController.php
@@ -141,7 +141,7 @@ class AdminAccountingConfigurationControllerCore extends AdminController
foreach ($this->acc_conf as $name => $val)
$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');
}
else if (Tools::getValue('update'))
diff --git a/controllers/admin/AdminAccountingManagementController.php b/controllers/admin/AdminAccountingManagementController.php
index eeb6750a8..e9d8eccb5 100644
--- a/controllers/admin/AdminAccountingManagementController.php
+++ b/controllers/admin/AdminAccountingManagementController.php
@@ -59,11 +59,11 @@ class AdminAccountingManagementControllerCore extends AdminController
$shop['default_account_number'] = Configuration::get('default_account_number', null, null, $id_shop);
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
- foreach ($zoneShopList as $zoneShop)
- $shop['zones'][$zoneShop['id_zone']]['account_number'] = $zoneShop['account_number'];
+ foreach ($zone_shop_list as $zone_shop)
+ $shop['zones'][$zone_shop['id_zone']]['account_number'] = $zone_shop['account_number'];
}
$this->context->smarty->assign(array(
@@ -130,8 +130,6 @@ class AdminAccountingManagementControllerCore extends AdminController
$this->confirmations[] = $this->l('Account numbers have been updated');
else
$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);
}
}
diff --git a/controllers/admin/AdminAccountingRegisteredNumberController.php b/controllers/admin/AdminAccountingRegisteredNumberController.php
index eb79502cc..4ffd8fc34 100644
--- a/controllers/admin/AdminAccountingRegisteredNumberController.php
+++ b/controllers/admin/AdminAccountingRegisteredNumberController.php
@@ -63,7 +63,7 @@ class AdminAccountingRegisteredNumberControllerCore extends AdminController
'title' => $this->l('Taxes Account number list'),
'list' => array()),
- // Gift wrapping definition, for now Only one available using Configuration
+ // Gift wrapping definition
'gift_wrapping' => array(
'func_call' => 'getAccountingNumberConfiguration',
'key' => 'account_gift_wripping',
@@ -74,7 +74,7 @@ class AdminAccountingRegisteredNumberControllerCore extends AdminController
'title' => $this->l('Gift wrapping account number list'),
'list' => array()),
- // Submited shipping charge definition, for now Only one available using Configuration
+ // Submited shipping charge definition
'submited_shipping_charge' => array(
'func_call' => 'getAccountingNumberConfiguration',
'key' => 'account_submit_shipping_charge',
@@ -85,7 +85,7 @@ class AdminAccountingRegisteredNumberControllerCore extends AdminController
'title' => $this->l('Submited shipping charge account number list'),
'list' => array()),
- // Unsubmited shipping charge definition, for now Only one available using Configuration
+ // Unsubmited shipping charge definition
'unsubmited_shipping_charge' => array(
'func_call' => 'getAccountingNumberConfiguration',
'key' => 'account_unsubmit_shipping_charge',
@@ -127,7 +127,6 @@ class AdminAccountingRegisteredNumberControllerCore extends AdminController
{
$this->initToolbarTitle();
$this->toolbar_btn = array();
-
}
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
* @param string $key of the Accounting configuration
diff --git a/localization/fr.xml b/localization/fr.xml
index bb3ed9773..d88f5739b 100644
--- a/localization/fr.xml
+++ b/localization/fr.xml
@@ -7,6 +7,16 @@
+
+
+
+
+
+
+
+
+
+