[-] BO : Make a lot of changement on the Accounting (accouting plan / configuration / customer)
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@13987 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -24,74 +24,6 @@
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*}
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
function validateInputDate(input, displayError)
|
||||
{
|
||||
{literal}
|
||||
dateRegex = /^\d{4}-\d{1,2}-\d{1,2}$/
|
||||
{/literal}
|
||||
|
||||
if (!input.val().match(dateRegex))
|
||||
{
|
||||
input.parent().find('span.input-error').fadeIn('fast');
|
||||
return false;
|
||||
}
|
||||
input.parent().find('span.input-error').css('display','none');
|
||||
return true;
|
||||
}
|
||||
|
||||
function validateAccountingForm()
|
||||
{
|
||||
validation = true;
|
||||
|
||||
$('span.input-error').css('display', 'none');
|
||||
$('.datepicker:visible').each(function() {
|
||||
if (!(validateInputDate($(this), true)))
|
||||
validation = false;
|
||||
});
|
||||
|
||||
return validation;
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$('#export_menu').find('a').each(function() {
|
||||
$(this).click(function() {
|
||||
blockID = 'block_' + $(this).attr('id');
|
||||
if (!$('#' + blockID).is(':visible'))
|
||||
{
|
||||
|
||||
$('.formAccountingExport:visible').each(function() {
|
||||
$(this).fadeOut('fast', function() {
|
||||
$('#' + blockID).fadeIn('fast');
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#' + '{$defaultType}').fadeIn('fast');
|
||||
|
||||
$('.datepicker').each(function() {
|
||||
$(this).change(function() {
|
||||
validateInputDate($(this), true);
|
||||
});
|
||||
$(this).datepicker({
|
||||
prevText: '',
|
||||
nextText: '',
|
||||
dateFormat: 'yy-mm-dd'
|
||||
});
|
||||
});
|
||||
|
||||
$('.formAccountingExport form input[type="submit"]').each(function()
|
||||
{
|
||||
$(this).click(function() {
|
||||
return validateAccountingForm();
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
{foreach from=$preventList key=name item=preventType}
|
||||
{if !empty($preventType)}
|
||||
<div class="{$name}">
|
||||
@@ -102,16 +34,4 @@
|
||||
{/if}
|
||||
{/foreach}
|
||||
|
||||
<div id="export_menu">
|
||||
<div class="toolbarBox">
|
||||
<div class="pageTitle">
|
||||
<h3>
|
||||
<span id="current_obj" style="font-weight: normal;">{l s='Export:'}</span>
|
||||
</h3>
|
||||
{l s='Select which export you want to do:'}<br />
|
||||
{foreach from=$exportTypeList item=export}
|
||||
<a id="{$export['type']}" class="button" href="javascript:void(0);">{$export['name']}</a>
|
||||
{/foreach}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Vendored
+2
@@ -13,6 +13,8 @@
|
||||
'AddressesControllerCore' => 'controllers/front/AddressesController.php',
|
||||
'AdminAccessController' => 'override/controllers/admin/AdminAccessController.php',
|
||||
'AdminAccessControllerCore' => 'controllers/admin/AdminAccessController.php',
|
||||
'AdminAccountingConfigurationController' => '',
|
||||
'AdminAccountingConfigurationControllerCore' => 'controllers/admin/AdminAccountingConfigurationController.php',
|
||||
'AdminAccountingExportController' => 'override/controllers/admin/AdminAccountingExportController.php',
|
||||
'AdminAccountingExportControllerCore' => 'controllers/admin/AdminAccountingExportController.php',
|
||||
'AdminAccountingManagementController' => 'override/controllers/admin/AdminAccountingManagementController.php',
|
||||
|
||||
@@ -27,6 +27,24 @@
|
||||
|
||||
class AccountingCore
|
||||
{
|
||||
const CONF_NAME = 'ACCOUNTING_CONFIGURATION';
|
||||
|
||||
/**
|
||||
* Default Values
|
||||
*
|
||||
* @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',
|
||||
'account_gift_wripping' => ''
|
||||
);
|
||||
|
||||
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
|
||||
@@ -108,4 +126,73 @@ class AccountingCore
|
||||
FROM `'._DB_PREFIX_.'accounting_zone_shop`
|
||||
WHERE `id_shop` = '.(int)$id_shop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Accounting Configuration
|
||||
* If a key is defined, then it will try to get the value
|
||||
*
|
||||
* @static
|
||||
* @param null $key
|
||||
* @return array|bool
|
||||
*/
|
||||
public static function getConfiguration($key = null)
|
||||
{
|
||||
// Cache for call performance
|
||||
if (!self::$acc_conf_cached)
|
||||
{
|
||||
// Merge default values with the configured values
|
||||
if ($conf = unserialize(Configuration::get(Accounting::CONF_NAME)))
|
||||
self::$acc_conf = array_merge(self::$acc_conf, $conf);
|
||||
self::$acc_conf_cached = true;
|
||||
}
|
||||
|
||||
|
||||
// Return value key or the complete configuration depending of the $key definition
|
||||
return (!$key) ? self::$acc_conf : ((isset(self::$acc_conf[$key]) ? self::$acc_conf[$key] : false));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of export done
|
||||
*
|
||||
* @static
|
||||
* @return array
|
||||
*/
|
||||
public static function getExportedList()
|
||||
{
|
||||
return Db::getInstance()->executeS('
|
||||
SELECT * FROM `'._DB_PREFIX_.'accounting_export` ORDER BY `date` DESC');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the displayed customer account.
|
||||
* Pad with / without prefix if the account is set
|
||||
*
|
||||
* @static
|
||||
* @param $id_customer
|
||||
* @param $default_value
|
||||
* @return string
|
||||
*/
|
||||
public static function getDisplayedCustomerAccount($id_customer, $default_value = false)
|
||||
{
|
||||
$acc_num = Db::getInstance()->getValue('
|
||||
SELECT account_number FROM `'._DB_PREFIX_.'customer`
|
||||
WHERE id_customer = '.(int)$id_customer);
|
||||
|
||||
$display = $acc_num;
|
||||
if (empty($acc_num) || $default_value)
|
||||
{
|
||||
$display = Accounting::getConfiguration('customer_prefix');
|
||||
$max_len = Accounting::getConfiguration('account_length');
|
||||
$len = Tools::strlen($display) + Tools::strlen((string)$id_customer);
|
||||
|
||||
// Pad the displayed string
|
||||
while ($max_len > 0 && $max_len > $len)
|
||||
{
|
||||
$display .= '0';
|
||||
--$max_len;
|
||||
}
|
||||
$display .= (string)$id_customer;
|
||||
}
|
||||
return $display;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ class CustomerCore extends ObjectModel
|
||||
|
||||
public $groupBox;
|
||||
|
||||
public $account_number;
|
||||
public $account_number = '';
|
||||
|
||||
protected $webserviceParameters = array(
|
||||
'fields' => array(
|
||||
|
||||
@@ -151,6 +151,7 @@ class LocalizationPackCore
|
||||
$tax = new Tax();
|
||||
$tax->name[(int)Configuration::get('PS_LANG_DEFAULT')] = (string)$attributes['name'];
|
||||
$tax->rate = (float)$attributes['rate'];
|
||||
$tax->account_number = isset($attributes['account_number']) ? (string)$attributes['account_number'] : '';
|
||||
$tax->active = 1;
|
||||
|
||||
if (!$tax->validateFields())
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2012 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
ing*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/osl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2012 PrestaShop SA
|
||||
* @version Release: $Revision: 9841 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class AdminAccountingConfigurationControllerCore extends AdminController
|
||||
{
|
||||
public $acc_conf = array();
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->acc_conf = Accounting::getConfiguration();
|
||||
$this->className = 'Accounting';
|
||||
|
||||
$this->options = array(
|
||||
'general' => array(
|
||||
'title' => $this->l('Export'),
|
||||
'fields' => array(
|
||||
'customer_prefix' => array(
|
||||
'title' => $this->l('Customer prefix:'),
|
||||
'desc' => $this->l('Set your default customer prefix'),
|
||||
'type' => 'text',
|
||||
'value' => $this->acc_conf['customer_prefix'],
|
||||
'size' => '15',
|
||||
'auto_value' => false
|
||||
),
|
||||
'journal' => array(
|
||||
'title' => $this->l('Journal:'),
|
||||
'desc' => '',
|
||||
'type' => 'text',
|
||||
'value' => $this->acc_conf['journal'],
|
||||
'size' => '15',
|
||||
'auto_value' => false
|
||||
),
|
||||
'account_length' => array(
|
||||
'title' => $this->l('Customer account length:'),
|
||||
'desc' => $this->l('Set the length of the customer account number (the prefix will always be displayed with the customer id)'),
|
||||
'type' => 'text',
|
||||
'value' => $this->acc_conf['account_length'],
|
||||
'size' => '15',
|
||||
'auto_value' => false
|
||||
),
|
||||
'account_submit_shipping_charge' => array(
|
||||
'title' => $this->l('Submited shipping charge account:'),
|
||||
'desc' => $this->l('Set the account for submited shipping charged'),
|
||||
'type' => 'text',
|
||||
'value' => $this->acc_conf['account_submit_shipping_charge'],
|
||||
'size' => '15',
|
||||
'auto_value' => false
|
||||
),
|
||||
'account_unsubmit_shipping_charge' => array(
|
||||
'title' => $this->l('Unsubmited shipping charge account:'),
|
||||
'desc' => $this->l('Set the account for unsubmited shipping charged'),
|
||||
'type' => 'text',
|
||||
'value' => $this->acc_conf['account_unsubmit_shipping_charge'],
|
||||
'size' => '15',
|
||||
'auto_value' => false
|
||||
),
|
||||
'account_gift_wripping' => array(
|
||||
'title' => $this->l('Gift-wrapping account number:'),
|
||||
'desc' => $this->l('Set the account number for the gift-wrapping'),
|
||||
'type' => 'text',
|
||||
'value' => $this->acc_conf['account_gift_wripping'],
|
||||
'size' => '15',
|
||||
'auto_value' => false
|
||||
)
|
||||
),
|
||||
'submit' => array('name' => 'update_cfg')
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function initToolbar()
|
||||
{
|
||||
$this->initToolbarTitle();
|
||||
$this->toolbar_btn['save'] = array(
|
||||
'href' => '#',
|
||||
'desc' => $this->l('Save')
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
public function initContent()
|
||||
{
|
||||
$this->display = 'options';
|
||||
parent::initContent();
|
||||
|
||||
$this->initToolbar();
|
||||
//$this->initInputList();
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
'title' => $this->l('Accounting Configuration'),
|
||||
'acc_conf' => $this->acc_conf,
|
||||
'table' => 'accounting',
|
||||
'toolbar_btn' => $this->toolbar_btn
|
||||
));
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (Tools::isSubmit('update_cfg'))
|
||||
{
|
||||
foreach ($this->acc_conf as $name => $val)
|
||||
$this->acc_conf[$name] = Tools::getValue($name);
|
||||
|
||||
Configuration::updateValue(Accounting::CONF_NAME, serialize($this->acc_conf));
|
||||
Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token.'&update=true');
|
||||
}
|
||||
else if (Tools::getValue('update'))
|
||||
$this->confirmations[] = $this->l('Configuration updated');
|
||||
}
|
||||
}
|
||||
@@ -29,13 +29,13 @@ class AdminAccountingExportControllerCore extends AdminController
|
||||
{
|
||||
public $exportTypeList = array();
|
||||
|
||||
public $pathTheme = '';
|
||||
|
||||
public $defaultType = 'block_global_export';
|
||||
|
||||
public $downloadDir = '';
|
||||
|
||||
public $downloadFile = '';
|
||||
|
||||
public $file = '';
|
||||
|
||||
public $already_generated = false;
|
||||
|
||||
public $exportSelected = '';
|
||||
|
||||
@@ -48,12 +48,14 @@ class AdminAccountingExportControllerCore extends AdminController
|
||||
|
||||
public $prevent = array(
|
||||
'errors' => array(),
|
||||
'warns' => array(),
|
||||
'warn' => array(),
|
||||
'hints' => array());
|
||||
|
||||
public $exportedFilePath = '';
|
||||
|
||||
public $clientPrefix = '';
|
||||
public $acc_conf = array();
|
||||
|
||||
public $file_format;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@@ -88,7 +90,8 @@ class AdminAccountingExportControllerCore extends AdminController
|
||||
'payment_type' => $this->l('Payment Type', 'AdminTab', false, false),
|
||||
'currency_code' => $this->l('Currency Code', 'AdminTab', false, false),
|
||||
'wording' => $this->l('Wording', 'AdminTab', false, false)
|
||||
)
|
||||
),
|
||||
'type' => 0
|
||||
),
|
||||
'reconciliation_export' => array(
|
||||
'name' => $this->l('Reconciliation Export'),
|
||||
@@ -101,26 +104,12 @@ class AdminAccountingExportControllerCore extends AdminController
|
||||
'invoice_date' => $this->l('Invoice Date', 'AdminTab', false, false),
|
||||
'transaction_id' => $this->l('Transaction Number', 'AdminTab', false, false),
|
||||
'account_client' => $this->l('Account client', 'AdminTab', false, false)
|
||||
)
|
||||
),
|
||||
'type' => 1
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Init the block Menu
|
||||
*/
|
||||
protected function initMenu()
|
||||
{
|
||||
$this->context->smarty->assign(array(
|
||||
'exportTypeList' => $this->exportTypeList,
|
||||
'defaultType' => $this->defaultType,
|
||||
'preventList' => $this->prevent
|
||||
)
|
||||
);
|
||||
|
||||
$this->content .= $this->createTemplate('menu.tpl')->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* AdminController::setMedia() override
|
||||
* @see AdminController::setMedia()
|
||||
@@ -135,40 +124,72 @@ class AdminAccountingExportControllerCore extends AdminController
|
||||
protected function checkRights()
|
||||
{
|
||||
if (!is_writeable($this->downloadDir))
|
||||
$this->errors[] = $this->l('The download folder doesn\'t have the sufficient right…');
|
||||
$this->errors[] = $this->l('The download folder doesn\'t have the sufficient right');
|
||||
if (!($this->fd = fopen($this->downloadFile, 'w+')))
|
||||
$this->errors[] = $this->l('The file can\'t be opened or created, please check the right');
|
||||
@chmod($this->downloadFile, 0777);
|
||||
}
|
||||
|
||||
|
||||
public function getExportedList()
|
||||
{
|
||||
$exported_list = Accounting::getExportedList();
|
||||
foreach ($exported_list as &$export)
|
||||
foreach ($this->exportTypeList as $export_type)
|
||||
{
|
||||
$export['title'] = $this->l('Undefined');
|
||||
if (((int)$export_type['type']) == ((int)$export['type']))
|
||||
{
|
||||
$export['title'] = $export_type['name'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $exported_list;
|
||||
}
|
||||
|
||||
/**
|
||||
* AdminController::init() override
|
||||
* @see AdminController::init()
|
||||
*/
|
||||
public function initContent()
|
||||
{
|
||||
$this->initMenu();
|
||||
|
||||
{
|
||||
$this->context->smarty->assign(array(
|
||||
'clientPrefix' => Configuration::get('ACCOUNTING_CLIENT_PREFIX_EXPORT'),
|
||||
'journal' => Configuration::get('ACCOUNTING_JOURNAL_EXPORT'),
|
||||
'begin_date' => Tools::getValue('beginDate'),
|
||||
'end_date' => Tools::getValue('endDate'),
|
||||
'urlDownload' => Tools::getShopDomain().'/download/'
|
||||
'begin_date' => Tools::getValue('begin_date'),
|
||||
'end_date' => Tools::getValue('end_date'),
|
||||
'file_format' => $this->file_format,
|
||||
'export_type' => $this->exportSelected,
|
||||
'urlDownload' => Tools::getShopDomain().'/download/',
|
||||
'preventList' => $this->prevent,
|
||||
'export_type_list' => $this->exportTypeList,
|
||||
'exported_list' => $this->getExportedList(),
|
||||
'already_generated' => Configuration::get('REQUEST_URI').$this->already_generated,
|
||||
));
|
||||
|
||||
foreach ($this->exportTypeList as $exportType)
|
||||
{
|
||||
$this->context->smarty->assign(array(
|
||||
'title' => $exportType['name'],
|
||||
'type' => $exportType['type'],
|
||||
'existingExport' => file_exists($this->downloadDir.$exportType['file']) ? true : false
|
||||
));
|
||||
|
||||
$this->content .= $this->createTemplate($exportType['type'].'.tpl')->fetch();
|
||||
}
|
||||
|
||||
parent::initContent();
|
||||
}
|
||||
|
||||
public function saveRangeDate()
|
||||
{
|
||||
$keys = array('`begin_to`', '`end_to`', '`type`', '`file`');
|
||||
|
||||
$values = array(
|
||||
'"'.pSQL($this->date['begin']).'"',
|
||||
'"'.pSQL($this->date['end']).'"',
|
||||
(int)$this->exportTypeList[$this->exportSelected]['type'],
|
||||
'"'.pSQL($this->file).'"'
|
||||
);
|
||||
|
||||
if (!($id_acc_export = Tools::getValue('regenerate')))
|
||||
$query = '
|
||||
INSERT INTO `'._DB_PREFIX_.'accounting_export`
|
||||
('.implode(', ', $keys).')
|
||||
VALUES('.implode(', ', $values).')';
|
||||
else
|
||||
$query = 'UPDATE `'._DB_PREFIX_.'accounting_export`
|
||||
SET `date` = CURRENT_TIMESTAMP, `file` = "'.$this->file.'"
|
||||
WHERE `id_accounting_export` = '.(int)$id_acc_export;
|
||||
|
||||
Db::getInstance()->execute($query);
|
||||
}
|
||||
|
||||
/**
|
||||
* AdminController::postProcess() override
|
||||
@@ -176,38 +197,71 @@ class AdminAccountingExportControllerCore extends AdminController
|
||||
*/
|
||||
public function postProcess()
|
||||
{
|
||||
if (Tools::isSubmit('submitAccountingExportType'))
|
||||
$succeed = false;
|
||||
|
||||
if (Tools::isSubmit('accounting_export'))
|
||||
{
|
||||
$this->date['begin'] = Tools::getValue('beginDate');
|
||||
$this->date['end'] = Tools::getValue('endDate');
|
||||
$this->clientPrefix = Tools::getValue('clientPrefix');
|
||||
$this->exportSelected = Tools::getValue('exportType');
|
||||
$this->downloadFile = $this->downloadDir.'accounting_'.$this->exportSelected.'.csv';
|
||||
|
||||
Configuration::updateValue('ACCOUNTING_CLIENT_PREFIX_EXPORT', $this->clientPrefix);
|
||||
$this->acc_conf = Accounting::getConfiguration();
|
||||
$this->date['begin'] = Tools::getValue('begin_date');
|
||||
$this->date['end'] = Tools::getValue('end_date');
|
||||
$this->exportSelected = Tools::getValue('type');
|
||||
$this->file_format = Tools::getValue('format');
|
||||
$this->file = $this->exportSelected.'-'.$this->date['begin'].
|
||||
'to'.$this->date['end'].'.'.$this->file_format;
|
||||
$this->downloadFile = $this->downloadDir.$this->file;
|
||||
|
||||
// Depends of the number of order and the range dates
|
||||
// Switch to ajax if there is any problems with time
|
||||
ini_set('max_execution_time', 0);
|
||||
|
||||
switch ($this->exportSelected)
|
||||
if (!in_array($this->file_format, array('csv', 'txt')))
|
||||
$this->prevent['error'][] = $this->l('Please select file format');
|
||||
else if (!empty($this->date['begin']) && !empty($this->date['end']) &&
|
||||
(Tools::getValue('regenerate') || !$this->isAlreadyGenerated()))
|
||||
{
|
||||
case 'reconciliation_export':
|
||||
$this->runReconciliationExport();
|
||||
break;
|
||||
case 'global_export':
|
||||
$this->runGlobalExport();
|
||||
Configuration::updateValue('ACCOUNTING_JOURNAL_EXPORT', Tools::getValue('journal'));
|
||||
break;
|
||||
default:
|
||||
// If not defined, set export type to default
|
||||
$this->exportSelected = 'global_export';
|
||||
switch ($this->exportSelected)
|
||||
{
|
||||
case 'reconciliation_export':
|
||||
$succeed = $this->runReconciliationExport();
|
||||
break;
|
||||
case 'global_export':
|
||||
$succeed = $this->runGlobalExport();
|
||||
break;
|
||||
default:
|
||||
$this->prevent['error'][] = $this->l('Please select a export type');
|
||||
}
|
||||
if ($succeed)
|
||||
$this->saveRangeDate();
|
||||
}
|
||||
|
||||
// Set back the default block type to display
|
||||
$this->defaultType = 'block_'.$this->exportSelected.'';
|
||||
else if (!$this->already_generated)
|
||||
$this->prevent['error'][] = $this->l('Please select the date');
|
||||
}
|
||||
else if (($type = Tools::getValue('download')) && array_key_exists($type, $this->exportTypeList))
|
||||
$this->downloadFile($this->exportTypeList[$type]['file']);
|
||||
else if (($file = Tools::getValue('download')) && file_exists($this->downloadDir.$file))
|
||||
$this->launchDownloadFile($this->downloadDir.$file);
|
||||
}
|
||||
|
||||
public function isAlreadyGenerated()
|
||||
{
|
||||
$query = '
|
||||
SELECT ae.`type`, ae.`id_accounting_export`
|
||||
FROM `'._DB_PREFIX_.'accounting_export` ae
|
||||
WHERE ae.`begin_to` = "'.pSQL($this->date['begin']).'"
|
||||
AND ae.`end_to` = "'.pSQL($this->date['end']).'"
|
||||
AND ae.`type` = '.(int)$this->exportTypeList[$this->exportSelected]['type'];
|
||||
|
||||
if (($entry = Db::getInstance()->getRow($query)) !== false)
|
||||
{
|
||||
if ($this->exportTypeList[$this->exportSelected]['type'] == $entry['type'])
|
||||
{
|
||||
$this->prevent['warn'][] = $this->l('This export has already be proceed with this file format');
|
||||
$this->already_generated = $entry['id_accounting_export'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->prevent['warn'][] = $this->l('This export has already be proceed with a different file format');
|
||||
$this->already_generated = true;
|
||||
}
|
||||
}
|
||||
return (bool)$this->already_generated;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -235,7 +289,9 @@ class AdminAccountingExportControllerCore extends AdminController
|
||||
fwrite($this->fd, mb_convert_encoding(rtrim($buffer, ';')."\r\n", 'UTF-16LE'));
|
||||
}
|
||||
$this->confirmations[] = $this->l('Export has been successfully done');
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -253,7 +309,7 @@ class AdminAccountingExportControllerCore extends AdminController
|
||||
o.`total_paid_real`,
|
||||
oi.`date_add` as invoice_date,
|
||||
pcc.`transaction_id`,
|
||||
CONCAT(\''.pSQL($this->clientPrefix).'\', LPAD(c.`id_customer`, 6, "0")) AS account_client
|
||||
CONCAT(\''.pSQL($this->acc_conf['client_prefix']).'\', LPAD(c.`id_customer`, 6, "0")) AS account_client
|
||||
FROM `'._DB_PREFIX_.'orders` o
|
||||
LEFT JOIN `'._DB_PREFIX_.'customer` c ON c.`id_customer` = o.`id_customer`
|
||||
LEFT JOIN `'._DB_PREFIX_.'address` a ON a.`id_customer` = o.`id_customer`
|
||||
@@ -266,7 +322,7 @@ class AdminAccountingExportControllerCore extends AdminController
|
||||
|
||||
$list = Db::getInstance()->executeS($query);
|
||||
|
||||
$this->writeExportToFile($list);
|
||||
return $this->writeExportToFile($list);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -282,7 +338,7 @@ class AdminAccountingExportControllerCore extends AdminController
|
||||
|
||||
// Default Values
|
||||
$line[0] = $row['invoice_date'];
|
||||
$line[1] = Tools::getValue('journal');
|
||||
$line[1] = $this->acc_conf['journal'];
|
||||
$line[2] = ''; // account number
|
||||
$line[3] = $row['invoice_number'];
|
||||
$line[4] = 0.00; // Credit TTC (Total for first csv line, 0 for others)
|
||||
@@ -418,8 +474,9 @@ class AdminAccountingExportControllerCore extends AdminController
|
||||
pcc.`transaction_id`,
|
||||
o.`payment` AS payment_type,
|
||||
currency.`iso_code` AS currency_code,
|
||||
CONCAT(\''.pSQL($this->clientPrefix).'\', LPAD(customer.`id_customer`, 6, "0")) AS account_client,
|
||||
CASE
|
||||
CONCAT(\''.pSQL($this->acc_conf['client_prefix']).'\', LPAD(customer.`id_customer`, 6, "0")) AS account_client,
|
||||
CASE
|
||||
WHEN (customer.`account_number` != "" AND customer.`account_number` IS NOT NULL) THEN customer.`account_number`
|
||||
WHEN (a.`company` != "" AND a.`company` IS NOT NULL) THEN a.`company`
|
||||
ELSE a.`lastname`
|
||||
END AS wording,
|
||||
@@ -455,14 +512,14 @@ class AdminAccountingExportControllerCore extends AdminController
|
||||
ORDER BY o.`id_order` ASC';
|
||||
|
||||
$list = $this->buildGlobalExportlist(Db::getInstance()->executeS($query));
|
||||
$this->writeExportToFile($list);
|
||||
return $this->writeExportToFile($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow to download the last export file
|
||||
* @var string File name
|
||||
*/
|
||||
protected function downloadFile($fileName)
|
||||
protected function launchDownloadFile($fileName)
|
||||
{
|
||||
$path = $this->downloadDir.$fileName;
|
||||
header('Content-length: '.filesize($path));
|
||||
|
||||
@@ -47,7 +47,7 @@ class AdminAccountingRegisteredNumberControllerCore extends AdminController
|
||||
'COUNT(*) AS total' => $this->l('Number of product associated to this account')
|
||||
),
|
||||
'group_by' => 'account_number',
|
||||
'condition' => 'p.account_number <> ""',
|
||||
'condition' => 'p.account_number <> "" AND account_number IS NOT NULL',
|
||||
'title' => $this->l('Product account number list'),
|
||||
'list' => array()),
|
||||
|
||||
@@ -59,7 +59,7 @@ class AdminAccountingRegisteredNumberControllerCore extends AdminController
|
||||
'COUNT(*) AS total' => $this->l('Number of taxes associated to this account')
|
||||
),
|
||||
'group_by' => 'account_number',
|
||||
'condition' => 'account_number <> ""',
|
||||
'condition' => 'account_number <> "" AND account_number IS NOT NULL',
|
||||
'title' => $this->l('Taxes Account number list'),
|
||||
'list' => array()),
|
||||
|
||||
@@ -70,7 +70,7 @@ class AdminAccountingRegisteredNumberControllerCore extends AdminController
|
||||
'account_number' => $this->l('Account number'),
|
||||
'total' => $this->l('Number of gift-wrapping associated to this account')
|
||||
),
|
||||
'condition' => 'account_number <> ""',
|
||||
'condition' => 'account_number <> "" AND account_number IS NOT NULL',
|
||||
'group_by' => 'account_number',
|
||||
'title' => $this->l('Gift wrapping account number list'),
|
||||
'list' => array()),
|
||||
@@ -84,7 +84,7 @@ class AdminAccountingRegisteredNumberControllerCore extends AdminController
|
||||
'lastname' => $this->l('Last name')
|
||||
),
|
||||
'group_by' => 'account_number',
|
||||
'condition' => 'account_number <> ""',
|
||||
'condition' => 'account_number <> "" AND account_number IS NOT NULL',
|
||||
'title' => $this->l('Customer account number list'),
|
||||
'list' => array()),
|
||||
|
||||
@@ -96,7 +96,7 @@ class AdminAccountingRegisteredNumberControllerCore extends AdminController
|
||||
'COUNT(*) AS total' => $this->l('Number of zone associated to this account')
|
||||
),
|
||||
'group_by' => 'account_number',
|
||||
'condition' => 'account_number <> ""',
|
||||
'condition' => 'account_number <> "" AND account_number IS NOT NULL',
|
||||
'title' => $this->l('Zone shop account number list'),
|
||||
'list' => array())
|
||||
);
|
||||
@@ -113,6 +113,13 @@ class AdminAccountingRegisteredNumberControllerCore extends AdminController
|
||||
{
|
||||
$this->initToolbar();
|
||||
$this->initAccountNumberList();
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
'toolbar_btn' => $this->toolbar_btn,
|
||||
'title' => $this->l('Accounting Plan'),
|
||||
'account_number_list' => $this->account_number_list));
|
||||
|
||||
parent::initContent();
|
||||
}
|
||||
|
||||
public function initAccountNumberList()
|
||||
@@ -144,13 +151,6 @@ class AdminAccountingRegisteredNumberControllerCore extends AdminController
|
||||
|
||||
$num = Configuration::get('PS_GIFT_WRAPPING_ACCOUNT_NUMBER');
|
||||
if (!empty($num))
|
||||
$this->account_number_list['gift_wrapping']['list'][] = array($num, '1');
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
'toolbar_btn' => $this->toolbar_btn,
|
||||
'title' => $this->l('Accounting Plan'),
|
||||
'account_number_list' => $this->account_number_list));
|
||||
|
||||
parent::initContent();
|
||||
$this->account_number_list['gift_wrapping']['list'][] = array($num, '1');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,7 +278,8 @@ class AdminCustomersControllerCore extends AdminController
|
||||
'name' => 'account_number',
|
||||
'size' => 33,
|
||||
'required' => false,
|
||||
'desc' => $this->l('Used for the accounting export')
|
||||
'desc' => $this->l('Used for the accounting export. If this field is empty, the accounting export will use this number ').
|
||||
Accounting::getDisplayedCustomerAccount($this->getFieldValue($obj, 'id_customer'), true)
|
||||
),
|
||||
array(
|
||||
'type' => 'birthday',
|
||||
|
||||
@@ -158,13 +158,6 @@ class AdminOrderPreferencesControllerCore extends AdminController
|
||||
'cast' => 'intval',
|
||||
'type' => 'bool'
|
||||
),
|
||||
'PS_GIFT_WRAPPING_ACCOUNT_NUMBER' => array(
|
||||
'title' => $this->l('Gift-wrapping account number'),
|
||||
'desc' => $this->l('Set an account number for your gift-wrapping (used for accounting)'),
|
||||
'validation' => 'isString',
|
||||
'type' => 'text',
|
||||
'size' => 30,
|
||||
),
|
||||
),
|
||||
'submit' => array('title' => $this->l(' Save '), 'class' => 'button'),
|
||||
),
|
||||
|
||||
Executable
BIN
Binary file not shown.
|
After Width: | Height: | Size: 568 B |
@@ -542,7 +542,7 @@ CREATE TABLE `PREFIX_customer` (
|
||||
`passwd` varchar(32) NOT NULL,
|
||||
`last_passwd_gen` timestamp NOT NULL default CURRENT_TIMESTAMP,
|
||||
`birthday` date default NULL,
|
||||
`account_number` varchar(128) NULL,
|
||||
`account_number` varchar(128) NULL,
|
||||
`newsletter` tinyint(1) unsigned NOT NULL default '0',
|
||||
`ip_registration_newsletter` varchar(15) default NULL,
|
||||
`newsletter_date_add` datetime default NULL,
|
||||
@@ -2305,6 +2305,26 @@ CREATE TABLE `PREFIX_supplier_rates` (
|
||||
PRIMARY KEY (`id_product_supplier`)
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `ps_accounting_export` (
|
||||
`id_accounting_export` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`begin_to` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||
`end_to` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||
`type` int(11) NOT NULL,
|
||||
`file` varchar(256) NOT NULL,
|
||||
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id_accounting_export`)
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `PREFIX_accounting_export` (
|
||||
`id_accounting_export` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`begin_to` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||
`end_to` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||
`type` int(11) NOT NULL,
|
||||
`file` varchar(256) NOT NULL,
|
||||
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id_accounting_export`)
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `PREFIX_accounting_zone_shop` (
|
||||
`id_accounting_zone_shop` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`id_zone` int(11) NOT NULL,
|
||||
|
||||
@@ -250,7 +250,10 @@
|
||||
<class_name>AdminRequestSql</class_name>
|
||||
</tab>
|
||||
<tab id="Accounting" id_parent="Advanced_parameters" active="1">
|
||||
<class_name>AdminAccountingManagement</class_name>
|
||||
<class_name>AdminAccountingConfiguration</class_name>
|
||||
</tab>
|
||||
<tab id="Accounting_plan" id_parent="Advanced_parameters" active="1">
|
||||
<class_name>AdminAccountingRegisteredNumber</class_name>
|
||||
</tab>
|
||||
<tab id="Logs" id_parent="Advanced_parameters" active="1">
|
||||
<class_name>AdminLogs</class_name>
|
||||
|
||||
@@ -82,6 +82,7 @@
|
||||
<tab id="DB_Backup" name="DB-Backup"/>
|
||||
<tab id="SQL_Manager" name="SQL Manager"/>
|
||||
<tab id="Accounting" name="Accounting"/>
|
||||
<tab id="Accounting_plan" name="Accounting plan"/>
|
||||
<tab id="Logs" name="Log"/>
|
||||
<tab id="Subdomains" name="Subdomains"/>
|
||||
<tab id="Webservice" name="Webservice"/>
|
||||
|
||||
@@ -82,6 +82,7 @@
|
||||
<tab id="DB_Backup" name="DB Backup"/>
|
||||
<tab id="SQL_Manager" name="SQL Manager"/>
|
||||
<tab id="Accounting" name="Accounting"/>
|
||||
<tab id="Accounting_plan" name="Accounting plan"/>
|
||||
<tab id="Logs" name="Logs"/>
|
||||
<tab id="Subdomains" name="Subdomains"/>
|
||||
<tab id="Webservice" name="Webservice"/>
|
||||
|
||||
@@ -82,6 +82,7 @@
|
||||
<tab id="DB_Backup" name="Copia de seguridad"/>
|
||||
<tab id="SQL_Manager" name="SQL Manager"/>
|
||||
<tab id="Accounting" name="Accounting"/>
|
||||
<tab id="Accounting_plan" name="Accounting plan"/>
|
||||
<tab id="Logs" name="Log"/>
|
||||
<tab id="Subdomains" name="Subcampos"/>
|
||||
<tab id="Webservice" name="Web service"/>
|
||||
|
||||
@@ -82,6 +82,7 @@
|
||||
<tab id="DB_Backup" name="Sauvegarde BDD"/>
|
||||
<tab id="SQL_Manager" name="SQL Manager"/>
|
||||
<tab id="Accounting" name="Comptabilité"/>
|
||||
<tab id="Accounting_plan" name="Plan comptable"/>
|
||||
<tab id="Logs" name="Log"/>
|
||||
<tab id="Subdomains" name="Sous domaines"/>
|
||||
<tab id="Webservice" name="Service web"/>
|
||||
|
||||
@@ -82,6 +82,7 @@
|
||||
<tab id="DB_Backup" name="DB backup"/>
|
||||
<tab id="SQL_Manager" name="SQL Manager"/>
|
||||
<tab id="Accounting" name="Accounting"/>
|
||||
<tab id="Accounting_plan" name="Accounting plan"/>
|
||||
<tab id="Logs" name="Log"/>
|
||||
<tab id="Subdomains" name="Sottodomini"/>
|
||||
<tab id="Webservice" name="Webservice"/>
|
||||
|
||||
@@ -2,4 +2,12 @@ SET NAMES 'utf8';
|
||||
|
||||
ALTER TABLE `PREFIX_product` ADD `visibility` ENUM('both', 'catalog', 'search', 'none') NOT NULL default 'both' AFTER `indexed`;
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `PREFIX_accounting_export` (
|
||||
`id_accounting_export` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`begin_to` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||
`end_to` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||
`type` int(11) NOT NULL,
|
||||
`file` varchar(256) NOT NULL,
|
||||
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id_accounting_export`)
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
+4
-4
@@ -8,10 +8,10 @@
|
||||
</languages>
|
||||
|
||||
<taxes>
|
||||
<tax id="1" name="TVA FR 19.6%" rate="19.6" />
|
||||
<tax id="2" name="TVA FR 7%" rate="7" />
|
||||
<tax id="3" name="TVA FR 5.5%" rate="5.5" />
|
||||
<tax id="4" name="TVA FR 2.1%" rate="2.1" />
|
||||
<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="3" name="TVA FR 5.5%" rate="5.5" account_number="445712" />
|
||||
<tax id="4" name="TVA FR 2.1%" rate="2.1" account_number="445711" />
|
||||
|
||||
<taxRulesGroup name="FR Taux standard (19.6%)">
|
||||
<taxRule iso_code_country="be" id_tax="1" />
|
||||
|
||||
Reference in New Issue
Block a user