From 8bef192fcbedae363f3d2b0b157efd621178e737 Mon Sep 17 00:00:00 2001 From: vSchoener Date: Fri, 2 Dec 2011 14:35:35 +0000 Subject: [PATCH] // 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 --- classes/PaymentCC.php | 34 +++++------- .../admin/AdminAccountingExportController.php | 54 +++++++++---------- 2 files changed, 41 insertions(+), 47 deletions(-) diff --git a/classes/PaymentCC.php b/classes/PaymentCC.php index a623d0b74..826c4fa5d 100644 --- a/classes/PaymentCC.php +++ b/classes/PaymentCC.php @@ -31,7 +31,7 @@ * @see OrderPaymentCore * */ -class PaymentCCCore extends ObjectModel +class PaymentCCCore extends OrderPayment { public $id_order; public $id_currency; @@ -52,29 +52,24 @@ class PaymentCCCore extends ObjectModel protected $table = 'payment_cc'; protected $identifier = 'id_payment_cc'; + /** + * @deprecated 1.5.0.2 + * @see OrderPaymentCore + */ public function getFields() { - $this->validateFields(); - $fields['id_order'] = (int)($this->id_order); - $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; + Tools::displayAsDeprecated(); + return parent::getFields(); } + /** + * @deprecated 1.5.0.2 + * @see OrderPaymentCore + */ public function add($autodate = true, $nullValues = false) { - if (parent::add($autodate, $nullValues)) - { - Hook::exec('paymentCCAdded', array('paymentCC' => $this)); - return true; - } - return false; + Tools::displayAsDeprecated(); + return parent::add($autodate, $nullValues); } /** @@ -87,7 +82,6 @@ class PaymentCCCore extends ObjectModel public static function getByOrderId($id_order) { Tools::displayAsDeprecated(); - return null; + return OrderPayment::getByOrderId($id_order); } } - diff --git a/controllers/admin/AdminAccountingExportController.php b/controllers/admin/AdminAccountingExportController.php index 562741328..26ae2df06 100644 --- a/controllers/admin/AdminAccountingExportController.php +++ b/controllers/admin/AdminAccountingExportController.php @@ -69,8 +69,7 @@ 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() { @@ -109,8 +108,7 @@ class AdminAccountingExportControllerCore extends AdminController } /** - * Init the block Menu - * + * Init the block Menu */ private function initMenu() { @@ -194,7 +192,7 @@ class AdminAccountingExportControllerCore extends AdminController Configuration::updateValue('ACCOUNTING_CLIENT_PREFIX_EXPORT', $this->clientPrefix); // 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); switch($this->exportSelected) @@ -247,28 +245,28 @@ class AdminAccountingExportControllerCore extends AdminController } /** - * Start the reconciliation export type - * + * Start the reconciliation export type */ private function runReconciliationExport() { $query = ' 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 WHEN (a.`company` != "" AND a.`company` IS NOT NULL) THEN a.`company` ELSE a.`lastname` END AS wording, o.`total_paid_real`, - o.`invoice_date`, + 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->clientPrefix).'\', 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` - 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 - AND o.`invoice_date` + AND oi.`date_add` BETWEEN \''.pSQL($this->date['begin']).'\' AND \''.pSQL($this->date['end']).'\''; @@ -291,8 +289,8 @@ class AdminAccountingExportControllerCore extends AdminController $line[1] = Tools::getValue('journal'); $line[2] = ''; // account number $line[3] = $row['invoice_number']; - $line[4] = 0.00; // Credit TTC - $line[5] = 0.00; // Debit HT (used for tax too) + $line[4] = 0.00; // Credit TTC (Total for first csv line, 0 for others) + $line[5] = 0.00; // Debit HT (0 For the first line, used for tax too) $line[6] = $row['transaction_id']; $line[7] = $row['payment_type']; $line[8] = $row['currency_code']; @@ -303,18 +301,18 @@ class AdminAccountingExportControllerCore extends AdminController { case 0: $line[2] = $row['account_client']; - $line[4] = 'Wait Franck Commit'; + $line[4] = $row['total_price_tax_incl']; break; case 1: $line[2] = !empty($row['account']) ? $row['account'] : Configuration::get('default_account_number', NULL, NULL, $row['id_shop']); // 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']; break; case 2: $line[2] = $row['tax_accounting_account_number']; - $line[5] = 'Wait Franck Commit'; + $line[5] = $row['tax_total_amount']; break; } return $line; @@ -375,44 +373,46 @@ class AdminAccountingExportControllerCore extends AdminController $query = ' SELECT od.`id_order`, - o.`invoice_date`, + oi.`date_add` as invoice_date, CASE 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` ELSE "" END AS account, - CONCAT(\''.Configuration::get('PS_INVOICE_PREFIX').'\', LPAD(o.`invoice_number`, 6, "0")) AS invoice_number, - o.`total_paid_real`, + CONCAT(\''.Configuration::get('PS_INVOICE_PREFIX').'\', LPAD(oi.`number`, 6, "0")) AS invoice_number, + od.`total_price_tax_incl`, od.`product_price` AS product_price_ht, 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, + currency.`iso_code` AS currency_code, + CONCAT(\''.pSQL($this->clientPrefix).'\', LPAD(customer.`id_customer`, 6, "0")) AS account_client, CASE WHEN (a.`company` != "" AND a.`company` IS NOT NULL) THEN a.`company` ELSE a.`lastname` END AS wording, t.account_number AS tax_accounting_account_number, t.id_tax, - o.id_shop + o.id_shop, + odt.total_amount AS tax_total_amount FROM `'._DB_PREFIX_.'orders` o 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_.'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_.'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_.'tax` t ON t.`id_tax` = odt.`id_tax` LEFT JOIN `'._DB_PREFIX_.'country` country ON country.`id_country` = a.`id_country` - LEFT JOIN `'._DB_PREFIX_.'accounting_product_zone_shop` acc_pzs + LEFT JOIN `'._DB_PREFIX_.'accounting_product_zone_shop` acc_pzs ON (acc_pzs.`id_shop` = o.`id_shop` AND acc_pzs.`id_zone` = country.`id_zone` AND acc_pzs.`id_product` = od.`product_id`) LEFT JOIN `'._DB_PREFIX_.'accounting_zone_shop` acc_zs ON (acc_zs.`id_shop` = o.`id_shop` 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 - AND o.`invoice_date` + AND oi.`date_add` BETWEEN \''.pSQL($this->date['begin']).'\' AND \''.pSQL($this->date['end']).'\' ORDER BY o.`id_order` ASC'; @@ -432,7 +432,7 @@ class AdminAccountingExportControllerCore extends AdminController header('Content-length: ' . filesize($path)); header('Content-Disposition: attachment; filename="'.$fileName.'"'); - // Flush data unproper data page before reading the file + // Flush buffered data before reading the file ob_clean(); flush();