[-] BO : Update Accounting

This commit is contained in:
vSchoener committed 2012-03-09 10:47:56 +00:00
1 parent bd7c501085
commit 969ba9bb1a
3 files changed
+86 -34

No files matched your search

+7 -3
View File
@@ -32,6 +32,9 @@ class AccountingCore
/** /**
* Default Values * Default Values
* *
* @TODO: Check to put the default value into the localization pack
* This configuration is applied for a specific shop
*
* @var array * @var array
*/ */
public static $acc_conf = array( public static $acc_conf = array(
@@ -40,7 +43,8 @@ class AccountingCore
'account_length' => 13, 'account_length' => 13,
'account_submit_shipping_charge' => '708510', 'account_submit_shipping_charge' => '708510',
'account_unsubmit_shipping_charge' => '708520', 'account_unsubmit_shipping_charge' => '708520',
'account_gift_wripping' => '' 'account_gift_wripping' => '',
'account_handling' => ''
); );
public static $acc_conf_cached = false; public static $acc_conf_cached = false;
@@ -74,8 +78,8 @@ 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 int $id_product * @param array $assoProductZoneShop
* @param array $accountingInfos * @return mixed bool|array
*/ */
public static function saveProductAccountingInformations($assoProductZoneShop) public static function saveProductAccountingInformations($assoProductZoneShop)
{ {
@@ -63,7 +63,13 @@ class AdminAccountingConfigurationControllerCore extends AdminController
'value' => $this->acc_conf['account_length'], 'value' => $this->acc_conf['account_length'],
'size' => '15', 'size' => '15',
'auto_value' => false 'auto_value' => false
), )
)
),
'account_number_list' => array(
'title' => $this->l('Default account number Management'),
'fields' => array(
'account_submit_shipping_charge' => array( 'account_submit_shipping_charge' => array(
'title' => $this->l('Submited shipping charge account:'), 'title' => $this->l('Submited shipping charge account:'),
'desc' => $this->l('Set the account for submited shipping charged'), 'desc' => $this->l('Set the account for submited shipping charged'),
@@ -87,7 +93,15 @@ class AdminAccountingConfigurationControllerCore extends AdminController
'value' => $this->acc_conf['account_gift_wripping'], 'value' => $this->acc_conf['account_gift_wripping'],
'size' => '15', 'size' => '15',
'auto_value' => false 'auto_value' => false
) ),
'account_handling' => array(
'title' => $this->l('Handling account number:'),
'desc' => $this->l('Set the account number for handling'),
'type' => 'text',
'value' => $this->acc_conf['account_handling'],
'size' => '15',
'auto_value' => false
)
), ),
'submit' => array('name' => 'update_cfg') 'submit' => array('name' => 'update_cfg')
), ),
@@ -37,7 +37,7 @@ class AdminAccountingRegisteredNumberControllerCore extends AdminController
$id_lang = $this->context->language->id; $id_lang = $this->context->language->id;
// p. => main table, s. => join table // p. => main table, s. => join table
// Contains rules to build sql query // Contains rules to build sql query, or method call to special traitment
$this->account_number_list = array( $this->account_number_list = array(
// Product definition // Product definition
'product' => array( 'product' => array(
@@ -65,16 +65,37 @@ class AdminAccountingRegisteredNumberControllerCore extends AdminController
// Gift wrapping definition, for now Only one available using Configuration // Gift wrapping definition, for now Only one available using Configuration
'gift_wrapping' => array( 'gift_wrapping' => array(
'table' => '', 'func_call' => 'getAccountingNumberConfiguration',
'key' => 'account_gift_wripping',
'fields' => array( 'fields' => array(
'account_number' => $this->l('Account number'), 'account_number' => $this->l('Account number'),
'total' => $this->l('Number of gift-wrapping associated to this account') 'total' => $this->l('Number of gift-wrapping associated to this account')
), ),
'condition' => 'account_number <> "" AND account_number IS NOT NULL',
'group_by' => 'account_number',
'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' => array(
'func_call' => 'getAccountingNumberConfiguration',
'key' => 'account_submit_shipping_charge',
'fields' => array(
'account_number' => $this->l('Account number'),
'total' => $this->l('Number of submited shipping charge associated to this account')
),
'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' => array(
'func_call' => 'getAccountingNumberConfiguration',
'key' => 'account_unsubmit_shipping_charge',
'fields' => array(
'account_number' => $this->l('Account number'),
'total' => $this->l('Number of unsubmited shipping charge associated to this account')
),
'title' => $this->l('Unsubmited shipping charge account number list'),
'list' => array()),
// Customer definition // Customer definition
'customer' => array( 'customer' => array(
'table' => 'customer', 'table' => 'customer',
@@ -122,35 +143,48 @@ class AdminAccountingRegisteredNumberControllerCore extends AdminController
parent::initContent(); parent::initContent();
} }
public function initAccountNumberList() /**
{ * Return the gift wripping number set.
foreach ($this->account_number_list as $name => &$detail) *
{ * @TODO : Add the possibility to check in all shop
if (isset($detail['table']) && !empty($detail['table'])) * @param string $key of the Accounting configuration
{ * @return array
$join = ''; */
public function getAccountingNumberConfiguration($key)
{
if (($num = Accounting::getConfiguration($key)))
return array(array($num, '1'));
return array();
}
if (isset($detail['left_join'])) public function initAccountNumberList()
{ {
$join = 'LEFT JOIN '._DB_PREFIX_.$detail['left_join']['table'].' s ON ('; foreach ($this->account_number_list as $name => &$detail)
foreach ($detail['left_join']['on'] as $on) {
$join .= 'p.'.$on.' = s.'.$on.' AND '; if (isset($detail['table']) && !empty($detail['table']))
$join = rtrim($join, ' AND ').')'; {
} $join = '';
$query = 'SELECT '.implode(', ', array_keys($detail['fields'])).' if (isset($detail['left_join']))
{
$join = 'LEFT JOIN '._DB_PREFIX_.$detail['left_join']['table'].' s ON (';
foreach ($detail['left_join']['on'] as $on)
$join .= 'p.'.$on.' = s.'.$on.' AND ';
$join = rtrim($join, ' AND ').')';
}
$query = '
SELECT '.implode(', ', array_keys($detail['fields'])).'
FROM `'._DB_PREFIX_.$detail['table'].'` p '.$join.' FROM `'._DB_PREFIX_.$detail['table'].'` p '.$join.'
WHERE '.$detail['condition']; WHERE '.$detail['condition'];
if (isset($detail['group_by'])) if (isset($detail['group_by']))
$query .= ' GROUP BY '.$detail['group_by']; $query .= ' GROUP BY '.$detail['group_by'];
$detail['list'] = Db::getInstance()->executeS($query);
}
}
$num = Configuration::get('PS_GIFT_WRAPPING_ACCOUNT_NUMBER'); $detail['list'] = Db::getInstance()->executeS($query);
if (!empty($num)) }
$this->account_number_list['gift_wrapping']['list'][] = array($num, '1'); else if (isset($detail['func_call']) && isset($detail['key']) && method_exists($this, $detail['func_call']))
} $detail['list'] = $this->{$detail['func_call']}($detail['key']);
}
}
} }