// Update Accounting export working now with new order table relation

// Add retro-compatibility to PaymentCC for module (inherit of OrderPayment and uses parent methods)



git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@10859 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
vSchoener
2011-12-02 14:35:35 +00:00
parent 975a56d3bd
commit 8bef192fcb
2 changed files with 41 additions and 47 deletions
+14 -20
View File
@@ -31,7 +31,7 @@
* @see OrderPaymentCore * @see OrderPaymentCore
* *
*/ */
class PaymentCCCore extends ObjectModel class PaymentCCCore extends OrderPayment
{ {
public $id_order; public $id_order;
public $id_currency; public $id_currency;
@@ -52,29 +52,24 @@ class PaymentCCCore extends ObjectModel
protected $table = 'payment_cc'; protected $table = 'payment_cc';
protected $identifier = 'id_payment_cc'; protected $identifier = 'id_payment_cc';
/**
* @deprecated 1.5.0.2
* @see OrderPaymentCore
*/
public function getFields() public function getFields()
{ {
$this->validateFields(); Tools::displayAsDeprecated();
$fields['id_order'] = (int)($this->id_order); return parent::getFields();
$fields['id_currency'] = (int)($this->id_currency);
$fields['amount'] = (float)($this->amount);
$fields['transaction_id'] = pSQL($this->transaction_id);
$fields['card_number'] = pSQL($this->card_number);
$fields['card_brand'] = pSQL($this->card_brand);
$fields['card_expiration'] = pSQL($this->card_expiration);
$fields['card_holder'] = pSQL($this->card_holder);
$fields['date_add'] = pSQL($this->date_add);
return $fields;
} }
/**
* @deprecated 1.5.0.2
* @see OrderPaymentCore
*/
public function add($autodate = true, $nullValues = false) public function add($autodate = true, $nullValues = false)
{ {
if (parent::add($autodate, $nullValues)) Tools::displayAsDeprecated();
{ return parent::add($autodate, $nullValues);
Hook::exec('paymentCCAdded', array('paymentCC' => $this));
return true;
}
return false;
} }
/** /**
@@ -87,7 +82,6 @@ class PaymentCCCore extends ObjectModel
public static function getByOrderId($id_order) public static function getByOrderId($id_order)
{ {
Tools::displayAsDeprecated(); Tools::displayAsDeprecated();
return null; return OrderPayment::getByOrderId($id_order);
} }
} }
@@ -70,7 +70,6 @@ class AdminAccountingExportControllerCore extends AdminController
/** /**
* Init the available fields by export type with associated translation * Init the available fields by export type with associated translation
*
*/ */
private function initExportFieldList() private function initExportFieldList()
{ {
@@ -110,7 +109,6 @@ class AdminAccountingExportControllerCore extends AdminController
/** /**
* Init the block Menu * Init the block Menu
*
*/ */
private function initMenu() private function initMenu()
{ {
@@ -194,7 +192,7 @@ class AdminAccountingExportControllerCore extends AdminController
Configuration::updateValue('ACCOUNTING_CLIENT_PREFIX_EXPORT', $this->clientPrefix); Configuration::updateValue('ACCOUNTING_CLIENT_PREFIX_EXPORT', $this->clientPrefix);
// Depends of the number of order and the range dates // Depends of the number of order and the range dates
// Switch to ajax if any problem with time occured // Switch to ajax if there is any problems with time
ini_set('max_execution_time', 0); ini_set('max_execution_time', 0);
switch($this->exportSelected) switch($this->exportSelected)
@@ -248,27 +246,27 @@ class AdminAccountingExportControllerCore extends AdminController
/** /**
* Start the reconciliation export type * Start the reconciliation export type
*
*/ */
private function runReconciliationExport() private function runReconciliationExport()
{ {
$query = ' $query = '
SELECT SELECT
CONCAT(\''.Configuration::get('PS_INVOICE_PREFIX').'\', LPAD(o.`invoice_number`, 6, 0)) AS invoice_number, CONCAT(\''.Configuration::get('PS_INVOICE_PREFIX').'\', LPAD(oi.`number`, 6, "0")) AS invoice_number,
CASE CASE
WHEN (a.`company` != "" AND a.`company` IS NOT NULL) THEN a.`company` WHEN (a.`company` != "" AND a.`company` IS NOT NULL) THEN a.`company`
ELSE a.`lastname` ELSE a.`lastname`
END AS wording, END AS wording,
o.`total_paid_real`, o.`total_paid_real`,
o.`invoice_date`, oi.`date_add` as invoice_date,
pcc.`transaction_id`, pcc.`transaction_id`,
CONCAT(\''.pSQL($this->clientPrefix).'\', LPAD(c.`id_customer`, 6, 0)) AS account_client CONCAT(\''.pSQL($this->clientPrefix).'\', LPAD(c.`id_customer`, 6, "0")) AS account_client
FROM `'._DB_PREFIX_.'orders` o FROM `'._DB_PREFIX_.'orders` o
LEFT JOIN `'._DB_PREFIX_.'customer` c ON c.`id_customer` = o.`id_customer` 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` LEFT JOIN `'._DB_PREFIX_.'address` a ON a.`id_customer` = o.`id_customer`
LEFT JOIN `'._DB_PREFIX_.'payment_cc` pcc ON pcc.`id_order` = o.`id_order` LEFT JOIN `'._DB_PREFIX_.'order_payment` pcc ON pcc.`id_order` = o.`id_order`
LEFT JOIN `'._DB_PREFIX_.'order_invoice` oi ON oi.`id_order` = o.`id_order`
WHERE o.`valid` = 1 WHERE o.`valid` = 1
AND o.`invoice_date` AND oi.`date_add`
BETWEEN \''.pSQL($this->date['begin']).'\' BETWEEN \''.pSQL($this->date['begin']).'\'
AND \''.pSQL($this->date['end']).'\''; AND \''.pSQL($this->date['end']).'\'';
@@ -291,8 +289,8 @@ class AdminAccountingExportControllerCore extends AdminController
$line[1] = Tools::getValue('journal'); $line[1] = Tools::getValue('journal');
$line[2] = ''; // account number $line[2] = ''; // account number
$line[3] = $row['invoice_number']; $line[3] = $row['invoice_number'];
$line[4] = 0.00; // Credit TTC $line[4] = 0.00; // Credit TTC (Total for first csv line, 0 for others)
$line[5] = 0.00; // Debit HT (used for tax too) $line[5] = 0.00; // Debit HT (0 For the first line, used for tax too)
$line[6] = $row['transaction_id']; $line[6] = $row['transaction_id'];
$line[7] = $row['payment_type']; $line[7] = $row['payment_type'];
$line[8] = $row['currency_code']; $line[8] = $row['currency_code'];
@@ -303,18 +301,18 @@ class AdminAccountingExportControllerCore extends AdminController
{ {
case 0: case 0:
$line[2] = $row['account_client']; $line[2] = $row['account_client'];
$line[4] = 'Wait Franck Commit'; $line[4] = $row['total_price_tax_incl'];
break; break;
case 1: case 1:
$line[2] = !empty($row['account']) ? $row['account'] : $line[2] = !empty($row['account']) ? $row['account'] :
Configuration::get('default_account_number', NULL, NULL, $row['id_shop']); Configuration::get('default_account_number', NULL, NULL, $row['id_shop']);
// Force an empty string if Configuration send false // Force an empty string if Configuration send false
$line[2] = empty($line[2]) ? '' : $linep[2]; $line[2] = empty($line[2]) ? '' : $line[2];
$line[5] = $row['product_price_ht']; $line[5] = $row['product_price_ht'];
break; break;
case 2: case 2:
$line[2] = $row['tax_accounting_account_number']; $line[2] = $row['tax_accounting_account_number'];
$line[5] = 'Wait Franck Commit'; $line[5] = $row['tax_total_amount'];
break; break;
} }
return $line; return $line;
@@ -375,30 +373,31 @@ class AdminAccountingExportControllerCore extends AdminController
$query = ' $query = '
SELECT SELECT
od.`id_order`, od.`id_order`,
o.`invoice_date`, oi.`date_add` as invoice_date,
CASE CASE
WHEN (acc_pzs.`account_number` != "" AND acc_pzs.`account_number` IS NOT NULL) THEN acc_pzs.`account_number` WHEN (acc_pzs.`account_number` != "" AND acc_pzs.`account_number` IS NOT NULL) THEN acc_pzs.`account_number`
WHEN (acc_zs.`account_number` != "" AND acc_zs.`account_number` IS NOT NULL) THEN acc_zs.`account_number` WHEN (acc_zs.`account_number` != "" AND acc_zs.`account_number` IS NOT NULL) THEN acc_zs.`account_number`
ELSE "" ELSE ""
END AS account, END AS account,
CONCAT(\''.Configuration::get('PS_INVOICE_PREFIX').'\', LPAD(o.`invoice_number`, 6, "0")) AS invoice_number, CONCAT(\''.Configuration::get('PS_INVOICE_PREFIX').'\', LPAD(oi.`number`, 6, "0")) AS invoice_number,
o.`total_paid_real`, od.`total_price_tax_incl`,
od.`product_price` AS product_price_ht, od.`product_price` AS product_price_ht,
pcc.`transaction_id`, pcc.`transaction_id`,
o.`payment` AS payment_type, o.`payment` AS payment_type,
currency.`iso_code` as currency_code, currency.`iso_code` AS currency_code,
CONCAT(\''.pSQL($this->clientPrefix).'\', LPAD(customer.`id_customer`, 6, 0)) AS account_client, CONCAT(\''.pSQL($this->clientPrefix).'\', LPAD(customer.`id_customer`, 6, "0")) AS account_client,
CASE CASE
WHEN (a.`company` != "" AND a.`company` IS NOT NULL) THEN a.`company` WHEN (a.`company` != "" AND a.`company` IS NOT NULL) THEN a.`company`
ELSE a.`lastname` ELSE a.`lastname`
END AS wording, END AS wording,
t.account_number AS tax_accounting_account_number, t.account_number AS tax_accounting_account_number,
t.id_tax, t.id_tax,
o.id_shop o.id_shop,
odt.total_amount AS tax_total_amount
FROM `'._DB_PREFIX_.'orders` o FROM `'._DB_PREFIX_.'orders` o
LEFT JOIN `'._DB_PREFIX_.'customer` customer ON customer.`id_customer` = o.`id_customer` LEFT JOIN `'._DB_PREFIX_.'customer` customer ON customer.`id_customer` = o.`id_customer`
LEFT JOIN `'._DB_PREFIX_.'address` a ON a.`id_customer` = o.`id_customer` LEFT JOIN `'._DB_PREFIX_.'address` a ON a.`id_customer` = o.`id_customer`
LEFT JOIN `'._DB_PREFIX_.'payment_cc` pcc ON pcc.`id_order` = o.`id_order` LEFT JOIN `'._DB_PREFIX_.'order_payment` pcc ON pcc.`id_order` = o.`id_order`
LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON od.`id_order` = o.`id_order` LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON od.`id_order` = o.`id_order`
LEFT JOIN `'._DB_PREFIX_.'currency` currency ON currency.`id_currency` = o.`id_currency` LEFT JOIN `'._DB_PREFIX_.'currency` currency ON currency.`id_currency` = o.`id_currency`
LEFT JOIN `'._DB_PREFIX_.'order_detail_tax` odt ON odt.`id_order_detail` = od.`id_order_detail` LEFT JOIN `'._DB_PREFIX_.'order_detail_tax` odt ON odt.`id_order_detail` = od.`id_order_detail`
@@ -411,8 +410,9 @@ class AdminAccountingExportControllerCore extends AdminController
LEFT JOIN `'._DB_PREFIX_.'accounting_zone_shop` acc_zs LEFT JOIN `'._DB_PREFIX_.'accounting_zone_shop` acc_zs
ON (acc_zs.`id_shop` = o.`id_shop` ON (acc_zs.`id_shop` = o.`id_shop`
AND acc_zs.`id_zone` = country.`id_zone`) AND acc_zs.`id_zone` = country.`id_zone`)
LEFT JOIN `'._DB_PREFIX_.'order_invoice` oi ON oi.id_order = o.id_order
WHERE o.`valid` = 1 WHERE o.`valid` = 1
AND o.`invoice_date` AND oi.`date_add`
BETWEEN \''.pSQL($this->date['begin']).'\' BETWEEN \''.pSQL($this->date['begin']).'\'
AND \''.pSQL($this->date['end']).'\' AND \''.pSQL($this->date['end']).'\'
ORDER BY o.`id_order` ASC'; ORDER BY o.`id_order` ASC';
@@ -432,7 +432,7 @@ class AdminAccountingExportControllerCore extends AdminController
header('Content-length: ' . filesize($path)); header('Content-length: ' . filesize($path));
header('Content-Disposition: attachment; filename="'.$fileName.'"'); header('Content-Disposition: attachment; filename="'.$fileName.'"');
// Flush data unproper data page before reading the file // Flush buffered data before reading the file
ob_clean(); ob_clean();
flush(); flush();